]>
Commit | Line | Data |
---|---|---|
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 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
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 | |
22 | @return EFI_SUCCESS the operation was successful\r | |
23 | @return other the operation failed.\r | |
24 | **/\r | |
25 | SHELL_STATUS\r | |
26 | EFIAPI\r | |
27 | DpCommandHandler (\r | |
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 | |
32 | )\r | |
33 | {\r | |
34 | gEfiShellParametersProtocol = ShellParameters;\r | |
35 | gEfiShellProtocol = Shell;\r | |
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 | |
49 | CHAR16 *\r | |
50 | EFIAPI\r | |
51 | DpCommandGetHelp (\r | |
52 | IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r | |
53 | IN CONST CHAR8 *Language\r | |
54 | )\r | |
55 | {\r | |
56 | return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP), Language);\r | |
57 | }\r | |
58 | \r | |
59 | EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {\r | |
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 | |
73 | @retval EFI_SUCCESS Tftp command is executed successfully.\r | |
74 | @retval EFI_ABORTED HII package was failed to initialize.\r | |
75 | @retval others Other errors when executing tftp command.\r | |
76 | **/\r | |
77 | EFI_STATUS\r | |
78 | EFIAPI\r | |
79 | DpCommandInitialize (\r | |
80 | IN EFI_HANDLE ImageHandle,\r | |
81 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
82 | )\r | |
83 | {\r | |
84 | EFI_STATUS Status;\r | |
85 | mDpHiiHandle = InitializeHiiPackage (ImageHandle);\r | |
86 | if (mDpHiiHandle == NULL) {\r | |
87 | return EFI_ABORTED;\r | |
88 | }\r | |
89 | \r | |
90 | Status = gBS->InstallProtocolInterface (\r | |
91 | &ImageHandle,\r | |
92 | &gEfiShellDynamicCommandProtocolGuid,\r | |
93 | EFI_NATIVE_INTERFACE,\r | |
94 | &mDpDynamicCommand\r | |
95 | );\r | |
96 | ASSERT_EFI_ERROR (Status);\r | |
97 | return Status;\r | |
98 | }\r | |
99 | \r | |
100 | /**\r | |
101 | Tftp driver unload handler.\r | |
102 | \r | |
103 | @param ImageHandle The image handle of the process.\r | |
104 | \r | |
105 | @retval EFI_SUCCESS The image is unloaded.\r | |
106 | @retval Others Failed to unload the image.\r | |
107 | **/\r | |
108 | EFI_STATUS\r | |
109 | EFIAPI\r | |
110 | DpUnload (\r | |
111 | IN EFI_HANDLE ImageHandle\r | |
112 | )\r | |
113 | {\r | |
114 | EFI_STATUS Status;\r | |
115 | Status = gBS->UninstallProtocolInterface (\r | |
116 | ImageHandle,\r | |
117 | &gEfiShellDynamicCommandProtocolGuid,\r | |
118 | &mDpDynamicCommand\r | |
119 | );\r | |
120 | if (EFI_ERROR (Status)) {\r | |
121 | return Status;\r | |
122 | }\r | |
123 | HiiRemovePackages (mDpHiiHandle);\r | |
124 | return EFI_SUCCESS;\r | |
125 | }\r |