--- /dev/null
+/** @file\r
+ Produce "http" shell dynamic command.\r
+\r
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>\r
+ Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
+ Copyright (c) 2020, Broadcom. All rights reserved.<BR>\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#include <Protocol/ShellDynamicCommand.h>\r
+#include "Http.h"\r
+\r
+/**\r
+ This is the shell command handler function pointer callback type. This\r
+ function handles the command when it is invoked in the shell.\r
+\r
+ @param[in] This The instance of the\r
+ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+ @param[in] SystemTable The pointer to the system table.\r
+ @param[in] ShellParameters The parameters associated with the command.\r
+ @param[in] Shell The instance of the shell protocol used in\r
+ the context of processing this command.\r
+\r
+ @return EFI_SUCCESS the operation was sucessful\r
+ @return other the operation failed.\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+HttpCommandHandler (\r
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
+ IN EFI_SYSTEM_TABLE *SystemTable,\r
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
+ IN EFI_SHELL_PROTOCOL *Shell\r
+ )\r
+{\r
+ gEfiShellParametersProtocol = ShellParameters;\r
+ gEfiShellProtocol = Shell;\r
+\r
+ return RunHttp (gImageHandle, SystemTable);\r
+}\r
+\r
+/**\r
+ This is the command help handler function pointer callback type. This\r
+ function is responsible for displaying help information for the associated\r
+ command.\r
+\r
+ @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+ @param[in] Language The pointer to the language string to use.\r
+\r
+ @return string Pool allocated help string, must be freed by caller\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+HttpCommandGetHelp (\r
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
+ IN CONST CHAR8 *Language\r
+ )\r
+{\r
+ return HiiGetString (\r
+ mHttpHiiHandle,\r
+ STRING_TOKEN (STR_GET_HELP_HTTP),\r
+ Language\r
+ );\r
+}\r
+\r
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {\r
+ HTTP_APP_NAME,\r
+ HttpCommandHandler,\r
+ HttpCommandGetHelp\r
+};\r
+\r
+/**\r
+ Entry point of Http Dynamic Command.\r
+\r
+ Produce the DynamicCommand protocol to handle "http" command.\r
+\r
+ @param ImageHandle The image handle of the process.\r
+ @param SystemTable The EFI System Table pointer.\r
+\r
+ @retval EFI_SUCCESS Http command is executed sucessfully.\r
+ @retval EFI_ABORTED HII package was failed to initialize.\r
+ @retval others Other errors when executing http command.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpCommandInitialize (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ mHttpHiiHandle = InitializeHiiPackage (ImageHandle);\r
+ if (mHttpHiiHandle == NULL) {\r
+ return EFI_ABORTED;\r
+ }\r
+\r
+ Status = gBS->InstallProtocolInterface (\r
+ &ImageHandle,\r
+ &gEfiShellDynamicCommandProtocolGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ &mHttpDynamicCommand\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Http driver unload handler.\r
+\r
+ @param ImageHandle The image handle of the process.\r
+\r
+ @retval EFI_SUCCESS The image is unloaded.\r
+ @retval Others Failed to unload the image.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpUnload (\r
+ IN EFI_HANDLE ImageHandle\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->UninstallProtocolInterface (\r
+ ImageHandle,\r
+ &gEfiShellDynamicCommandProtocolGuid,\r
+ &mHttpDynamicCommand\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ HiiRemovePackages (mHttpHiiHandle);\r
+\r
+ return EFI_SUCCESS;\r
+}\r