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