]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c
ShellPkg: Apply uncrustify changes
[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
f16bd394 23 @return EFI_SUCCESS the operation was successful\r
09610023
RN
24 @return other the operation failed.\r
25**/\r
26SHELL_STATUS\r
27EFIAPI\r
28TftpCommandHandler (\r
47d20b54
MK
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
09610023
RN
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
47d20b54
MK
53 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
54 IN CONST CHAR8 *Language\r
09610023
RN
55 )\r
56{\r
57 return HiiGetString (mTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP), Language);\r
58}\r
59\r
47d20b54 60EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {\r
09610023
RN
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
f16bd394 74 @retval EFI_SUCCESS Tftp command is executed successfully.\r
09610023
RN
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
47d20b54
MK
81 IN EFI_HANDLE ImageHandle,\r
82 IN EFI_SYSTEM_TABLE *SystemTable\r
09610023
RN
83 )\r
84{\r
47d20b54
MK
85 EFI_STATUS Status;\r
86\r
09610023
RN
87 mTftpHiiHandle = InitializeHiiPackage (ImageHandle);\r
88 if (mTftpHiiHandle == NULL) {\r
89 return EFI_ABORTED;\r
90 }\r
91\r
92 Status = gBS->InstallProtocolInterface (\r
93 &ImageHandle,\r
94 &gEfiShellDynamicCommandProtocolGuid,\r
95 EFI_NATIVE_INTERFACE,\r
96 &mTftpDynamicCommand\r
97 );\r
98 ASSERT_EFI_ERROR (Status);\r
99 return Status;\r
100}\r
101\r
102/**\r
103 Tftp driver unload handler.\r
104\r
105 @param ImageHandle The image handle of the process.\r
106\r
107 @retval EFI_SUCCESS The image is unloaded.\r
108 @retval Others Failed to unload the image.\r
109**/\r
110EFI_STATUS\r
111EFIAPI\r
112TftpUnload (\r
47d20b54
MK
113 IN EFI_HANDLE ImageHandle\r
114 )\r
09610023 115{\r
47d20b54
MK
116 EFI_STATUS Status;\r
117\r
09610023
RN
118 Status = gBS->UninstallProtocolInterface (\r
119 ImageHandle,\r
120 &gEfiShellDynamicCommandProtocolGuid,\r
121 &mTftpDynamicCommand\r
122 );\r
123 if (EFI_ERROR (Status)) {\r
124 return Status;\r
125 }\r
47d20b54 126\r
09610023
RN
127 HiiRemovePackages (mTftpHiiHandle);\r
128 return EFI_SUCCESS;\r
129}\r