VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c@ 85718

Last change on this file since 85718 was 85718, checked in by vboxsync, 5 years ago

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1/** @file
2 Produce "tftp" shell dynamic command.
3
4 Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
5 Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10#include "Tftp.h"
11#include <Protocol/ShellDynamicCommand.h>
12
13/**
14 This is the shell command handler function pointer callback type. This
15 function handles the command when it is invoked in the shell.
16
17 @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
18 @param[in] SystemTable The pointer to the system table.
19 @param[in] ShellParameters The parameters associated with the command.
20 @param[in] Shell The instance of the shell protocol used in the context
21 of processing this command.
22
23 @return EFI_SUCCESS the operation was successful
24 @return other the operation failed.
25**/
26SHELL_STATUS
27EFIAPI
28TftpCommandHandler (
29 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
30 IN EFI_SYSTEM_TABLE *SystemTable,
31 IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
32 IN EFI_SHELL_PROTOCOL *Shell
33 )
34{
35 gEfiShellParametersProtocol = ShellParameters;
36 gEfiShellProtocol = Shell;
37 return RunTftp (gImageHandle, SystemTable);
38}
39
40/**
41 This is the command help handler function pointer callback type. This
42 function is responsible for displaying help information for the associated
43 command.
44
45 @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
46 @param[in] Language The pointer to the language string to use.
47
48 @return string Pool allocated help string, must be freed by caller
49**/
50CHAR16 *
51EFIAPI
52TftpCommandGetHelp (
53 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
54 IN CONST CHAR8 *Language
55 )
56{
57 return HiiGetString (mTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP), Language);
58}
59
60EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
61 L"tftp",
62 TftpCommandHandler,
63 TftpCommandGetHelp
64};
65
66/**
67 Entry point of Tftp Dynamic Command.
68
69 Produce the DynamicCommand protocol to handle "tftp" command.
70
71 @param ImageHandle The image handle of the process.
72 @param SystemTable The EFI System Table pointer.
73
74 @retval EFI_SUCCESS Tftp command is executed successfully.
75 @retval EFI_ABORTED HII package was failed to initialize.
76 @retval others Other errors when executing tftp command.
77**/
78EFI_STATUS
79EFIAPI
80TftpCommandInitialize (
81 IN EFI_HANDLE ImageHandle,
82 IN EFI_SYSTEM_TABLE *SystemTable
83 )
84{
85 EFI_STATUS Status;
86 mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
87 if (mTftpHiiHandle == NULL) {
88 return EFI_ABORTED;
89 }
90
91 Status = gBS->InstallProtocolInterface (
92 &ImageHandle,
93 &gEfiShellDynamicCommandProtocolGuid,
94 EFI_NATIVE_INTERFACE,
95 &mTftpDynamicCommand
96 );
97 ASSERT_EFI_ERROR (Status);
98 return Status;
99}
100
101/**
102 Tftp driver unload handler.
103
104 @param ImageHandle The image handle of the process.
105
106 @retval EFI_SUCCESS The image is unloaded.
107 @retval Others Failed to unload the image.
108**/
109EFI_STATUS
110EFIAPI
111TftpUnload (
112 IN EFI_HANDLE ImageHandle
113)
114{
115 EFI_STATUS Status;
116 Status = gBS->UninstallProtocolInterface (
117 ImageHandle,
118 &gEfiShellDynamicCommandProtocolGuid,
119 &mTftpDynamicCommand
120 );
121 if (EFI_ERROR (Status)) {
122 return Status;
123 }
124 HiiRemovePackages (mTftpHiiHandle);
125 return EFI_SUCCESS;
126}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette