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