]>
Commit | Line | Data |
---|---|---|
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 | |
7 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | #include "Tftp.h"\r | |
17 | #include <Protocol/ShellDynamicCommand.h>\r | |
18 | \r | |
19 | /**\r | |
20 | This is the shell command handler function pointer callback type. This\r | |
21 | function handles the command when it is invoked in the shell.\r | |
22 | \r | |
23 | @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r | |
24 | @param[in] SystemTable The pointer to the system table.\r | |
25 | @param[in] ShellParameters The parameters associated with the command.\r | |
26 | @param[in] Shell The instance of the shell protocol used in the context\r | |
27 | of processing this command.\r | |
28 | \r | |
29 | @return EFI_SUCCESS the operation was sucessful\r | |
30 | @return other the operation failed.\r | |
31 | **/\r | |
32 | SHELL_STATUS\r | |
33 | EFIAPI\r | |
34 | TftpCommandHandler (\r | |
35 | IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r | |
36 | IN EFI_SYSTEM_TABLE *SystemTable,\r | |
37 | IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
38 | IN EFI_SHELL_PROTOCOL *Shell\r | |
39 | )\r | |
40 | {\r | |
41 | gEfiShellParametersProtocol = ShellParameters;\r | |
42 | gEfiShellProtocol = Shell;\r | |
43 | return RunTftp (gImageHandle, SystemTable);\r | |
44 | }\r | |
45 | \r | |
46 | /**\r | |
47 | This is the command help handler function pointer callback type. This\r | |
48 | function is responsible for displaying help information for the associated\r | |
49 | command.\r | |
50 | \r | |
51 | @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r | |
52 | @param[in] Language The pointer to the language string to use.\r | |
53 | \r | |
54 | @return string Pool allocated help string, must be freed by caller\r | |
55 | **/\r | |
56 | CHAR16 *\r | |
57 | EFIAPI\r | |
58 | TftpCommandGetHelp (\r | |
59 | IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r | |
60 | IN CONST CHAR8 *Language\r | |
61 | )\r | |
62 | {\r | |
63 | return HiiGetString (mTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP), Language);\r | |
64 | }\r | |
65 | \r | |
66 | EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {\r | |
67 | L"tftp",\r | |
68 | TftpCommandHandler,\r | |
69 | TftpCommandGetHelp\r | |
70 | };\r | |
71 | \r | |
72 | /**\r | |
73 | Entry point of Tftp Dynamic Command.\r | |
74 | \r | |
75 | Produce the DynamicCommand protocol to handle "tftp" command.\r | |
76 | \r | |
77 | @param ImageHandle The image handle of the process.\r | |
78 | @param SystemTable The EFI System Table pointer.\r | |
79 | \r | |
80 | @retval EFI_SUCCESS Tftp command is executed sucessfully.\r | |
81 | @retval EFI_ABORTED HII package was failed to initialize.\r | |
82 | @retval others Other errors when executing tftp command.\r | |
83 | **/\r | |
84 | EFI_STATUS\r | |
85 | EFIAPI\r | |
86 | TftpCommandInitialize (\r | |
87 | IN EFI_HANDLE ImageHandle,\r | |
88 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
89 | )\r | |
90 | {\r | |
91 | EFI_STATUS Status;\r | |
92 | mTftpHiiHandle = InitializeHiiPackage (ImageHandle);\r | |
93 | if (mTftpHiiHandle == NULL) {\r | |
94 | return EFI_ABORTED;\r | |
95 | }\r | |
96 | \r | |
97 | Status = gBS->InstallProtocolInterface (\r | |
98 | &ImageHandle,\r | |
99 | &gEfiShellDynamicCommandProtocolGuid,\r | |
100 | EFI_NATIVE_INTERFACE,\r | |
101 | &mTftpDynamicCommand\r | |
102 | );\r | |
103 | ASSERT_EFI_ERROR (Status);\r | |
104 | return Status;\r | |
105 | }\r | |
106 | \r | |
107 | /**\r | |
108 | Tftp driver unload handler.\r | |
109 | \r | |
110 | @param ImageHandle The image handle of the process.\r | |
111 | \r | |
112 | @retval EFI_SUCCESS The image is unloaded.\r | |
113 | @retval Others Failed to unload the image.\r | |
114 | **/\r | |
115 | EFI_STATUS\r | |
116 | EFIAPI\r | |
117 | TftpUnload (\r | |
118 | IN EFI_HANDLE ImageHandle\r | |
119 | )\r | |
120 | {\r | |
121 | EFI_STATUS Status;\r | |
122 | Status = gBS->UninstallProtocolInterface (\r | |
123 | ImageHandle,\r | |
124 | &gEfiShellDynamicCommandProtocolGuid,\r | |
125 | &mTftpDynamicCommand\r | |
126 | );\r | |
127 | if (EFI_ERROR (Status)) {\r | |
128 | return Status;\r | |
129 | }\r | |
130 | HiiRemovePackages (mTftpHiiHandle);\r | |
131 | return EFI_SUCCESS;\r | |
132 | }\r |