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