]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
56ba3746 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
92034c4c
RN
7\r
8**/\r
9#include "Dp.h"\r
10#include <Protocol/ShellDynamicCommand.h>\r
11\r
12/**\r
13 This is the shell command handler function pointer callback type. This\r
14 function handles the command when it is invoked in the shell.\r
15\r
16 @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
17 @param[in] SystemTable The pointer to the system table.\r
18 @param[in] ShellParameters The parameters associated with the command.\r
19 @param[in] Shell The instance of the shell protocol used in the context\r
20 of processing this command.\r
21\r
f16bd394 22 @return EFI_SUCCESS the operation was successful\r
92034c4c
RN
23 @return other the operation failed.\r
24**/\r
25SHELL_STATUS\r
26EFIAPI\r
27DpCommandHandler (\r
47d20b54
MK
28 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
29 IN EFI_SYSTEM_TABLE *SystemTable,\r
30 IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
31 IN EFI_SHELL_PROTOCOL *Shell\r
92034c4c
RN
32 )\r
33{\r
34 gEfiShellParametersProtocol = ShellParameters;\r
ff5a4bcf 35 gEfiShellProtocol = Shell;\r
92034c4c
RN
36 return RunDp (gImageHandle, SystemTable);\r
37}\r
38\r
39/**\r
40 This is the command help handler function pointer callback type. This\r
41 function is responsible for displaying help information for the associated\r
42 command.\r
43\r
44 @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
45 @param[in] Language The pointer to the language string to use.\r
46\r
47 @return string Pool allocated help string, must be freed by caller\r
48**/\r
49CHAR16 *\r
50EFIAPI\r
51DpCommandGetHelp (\r
47d20b54
MK
52 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
53 IN CONST CHAR8 *Language\r
92034c4c
RN
54 )\r
55{\r
56 return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP), Language);\r
57}\r
58\r
47d20b54 59EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {\r
92034c4c
RN
60 L"dp",\r
61 DpCommandHandler,\r
62 DpCommandGetHelp\r
63};\r
64\r
65/**\r
66 Entry point of Tftp Dynamic Command.\r
67\r
68 Produce the DynamicCommand protocol to handle "tftp" command.\r
69\r
70 @param ImageHandle The image handle of the process.\r
71 @param SystemTable The EFI System Table pointer.\r
72\r
f16bd394 73 @retval EFI_SUCCESS Tftp command is executed successfully.\r
92034c4c
RN
74 @retval EFI_ABORTED HII package was failed to initialize.\r
75 @retval others Other errors when executing tftp command.\r
76**/\r
77EFI_STATUS\r
78EFIAPI\r
79DpCommandInitialize (\r
47d20b54
MK
80 IN EFI_HANDLE ImageHandle,\r
81 IN EFI_SYSTEM_TABLE *SystemTable\r
92034c4c
RN
82 )\r
83{\r
47d20b54
MK
84 EFI_STATUS Status;\r
85\r
92034c4c
RN
86 mDpHiiHandle = InitializeHiiPackage (ImageHandle);\r
87 if (mDpHiiHandle == 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 &mDpDynamicCommand\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
111DpUnload (\r
47d20b54
MK
112 IN EFI_HANDLE ImageHandle\r
113 )\r
92034c4c 114{\r
47d20b54
MK
115 EFI_STATUS Status;\r
116\r
92034c4c
RN
117 Status = gBS->UninstallProtocolInterface (\r
118 ImageHandle,\r
119 &gEfiShellDynamicCommandProtocolGuid,\r
120 &mDpDynamicCommand\r
121 );\r
122 if (EFI_ERROR (Status)) {\r
123 return Status;\r
124 }\r
47d20b54 125\r
92034c4c
RN
126 HiiRemovePackages (mDpHiiHandle);\r
127 return EFI_SUCCESS;\r
128}\r