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