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 | mDpHiiHandle = InitializeHiiPackage (ImageHandle);
|
---|
86 | if (mDpHiiHandle == NULL) {
|
---|
87 | return EFI_ABORTED;
|
---|
88 | }
|
---|
89 |
|
---|
90 | Status = gBS->InstallProtocolInterface (
|
---|
91 | &ImageHandle,
|
---|
92 | &gEfiShellDynamicCommandProtocolGuid,
|
---|
93 | EFI_NATIVE_INTERFACE,
|
---|
94 | &mDpDynamicCommand
|
---|
95 | );
|
---|
96 | ASSERT_EFI_ERROR (Status);
|
---|
97 | return Status;
|
---|
98 | }
|
---|
99 |
|
---|
100 | /**
|
---|
101 | Tftp driver unload handler.
|
---|
102 |
|
---|
103 | @param ImageHandle The image handle of the process.
|
---|
104 |
|
---|
105 | @retval EFI_SUCCESS The image is unloaded.
|
---|
106 | @retval Others Failed to unload the image.
|
---|
107 | **/
|
---|
108 | EFI_STATUS
|
---|
109 | EFIAPI
|
---|
110 | DpUnload (
|
---|
111 | IN EFI_HANDLE ImageHandle
|
---|
112 | )
|
---|
113 | {
|
---|
114 | EFI_STATUS Status;
|
---|
115 | Status = gBS->UninstallProtocolInterface (
|
---|
116 | ImageHandle,
|
---|
117 | &gEfiShellDynamicCommandProtocolGuid,
|
---|
118 | &mDpDynamicCommand
|
---|
119 | );
|
---|
120 | if (EFI_ERROR (Status)) {
|
---|
121 | return Status;
|
---|
122 | }
|
---|
123 | HiiRemovePackages (mDpHiiHandle);
|
---|
124 | return EFI_SUCCESS;
|
---|
125 | }
|
---|