]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
ShellPkg/DP: Add more check for input parameters
[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
ff5a4bcf 41 gEfiShellProtocol = Shell;\r
92034c4c
RN
42 return RunDp (gImageHandle, SystemTable);\r
43}\r
44\r
45/**\r
46 This is the command help handler function pointer callback type. This\r
47 function is responsible for displaying help information for the associated\r
48 command.\r
49\r
50 @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
51 @param[in] Language The pointer to the language string to use.\r
52\r
53 @return string Pool allocated help string, must be freed by caller\r
54**/\r
55CHAR16 *\r
56EFIAPI\r
57DpCommandGetHelp (\r
58 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
59 IN CONST CHAR8 *Language\r
60 )\r
61{\r
62 return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP), Language);\r
63}\r
64\r
65EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {\r
66 L"dp",\r
67 DpCommandHandler,\r
68 DpCommandGetHelp\r
69};\r
70\r
71/**\r
72 Entry point of Tftp Dynamic Command.\r
73\r
74 Produce the DynamicCommand protocol to handle "tftp" command.\r
75\r
76 @param ImageHandle The image handle of the process.\r
77 @param SystemTable The EFI System Table pointer.\r
78\r
79 @retval EFI_SUCCESS Tftp command is executed sucessfully.\r
80 @retval EFI_ABORTED HII package was failed to initialize.\r
81 @retval others Other errors when executing tftp command.\r
82**/\r
83EFI_STATUS\r
84EFIAPI\r
85DpCommandInitialize (\r
86 IN EFI_HANDLE ImageHandle,\r
87 IN EFI_SYSTEM_TABLE *SystemTable\r
88 )\r
89{\r
90 EFI_STATUS Status;\r
91 mDpHiiHandle = InitializeHiiPackage (ImageHandle);\r
92 if (mDpHiiHandle == NULL) {\r
93 return EFI_ABORTED;\r
94 }\r
95\r
96 Status = gBS->InstallProtocolInterface (\r
97 &ImageHandle,\r
98 &gEfiShellDynamicCommandProtocolGuid,\r
99 EFI_NATIVE_INTERFACE,\r
100 &mDpDynamicCommand\r
101 );\r
102 ASSERT_EFI_ERROR (Status);\r
103 return Status;\r
104}\r
105\r
106/**\r
107 Tftp driver unload handler.\r
108\r
109 @param ImageHandle The image handle of the process.\r
110\r
111 @retval EFI_SUCCESS The image is unloaded.\r
112 @retval Others Failed to unload the image.\r
113**/\r
114EFI_STATUS\r
115EFIAPI\r
116DpUnload (\r
117 IN EFI_HANDLE ImageHandle\r
118)\r
119{\r
120 EFI_STATUS Status;\r
121 Status = gBS->UninstallProtocolInterface (\r
122 ImageHandle,\r
123 &gEfiShellDynamicCommandProtocolGuid,\r
124 &mDpDynamicCommand\r
125 );\r
126 if (EFI_ERROR (Status)) {\r
127 return Status;\r
128 }\r
129 HiiRemovePackages (mDpHiiHandle);\r
130 return EFI_SUCCESS;\r
131}\r