mirror of https://github.com/acidanthera/audk.git
ShellPkg/DynamicCommand: add HttpDynamicCommand
Introduce an http client utilizing EDK2 HTTP protocol, to allow fast image downloading from http/https servers. HTTP download speed is usually faster than tftp. The client is based on the same approach as tftp dynamic command, and uses the same UEFI Shell command line parameters. This makes it easy integrating http into existing UEFI Shell scripts. Note that to enable HTTP download, feature Pcd gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections must be set to TRUE. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2860 Signed-off-by: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Nd <nd@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
52dbaaeace
commit
d8ab884fe9
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,92 @@
|
||||||
|
/** @file
|
||||||
|
Header file for 'http' command functions.
|
||||||
|
|
||||||
|
Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
|
||||||
|
Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2020, Broadcom. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _HTTP_H_
|
||||||
|
#define _HTTP_H_
|
||||||
|
|
||||||
|
#include <Uefi.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HiiLib.h>
|
||||||
|
#include <Library/HttpLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/NetLib.h>
|
||||||
|
#include <Library/PrintLib.h>
|
||||||
|
#include <Library/ShellLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiHiiServicesLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
|
||||||
|
#include <Protocol/HiiPackageList.h>
|
||||||
|
#include <Protocol/HttpUtilities.h>
|
||||||
|
#include <Protocol/ServiceBinding.h>
|
||||||
|
|
||||||
|
#define HTTP_APP_NAME L"http"
|
||||||
|
|
||||||
|
#define REQ_OK 0
|
||||||
|
#define REQ_NEED_REPEAT 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// Download Flags.
|
||||||
|
//
|
||||||
|
#define DL_FLAG_TIME BIT0 // Show elapsed time.
|
||||||
|
#define DL_FLAG_KEEP_BAD BIT1 // Keep files even if download failed.
|
||||||
|
|
||||||
|
extern EFI_HII_HANDLE mHttpHiiHandle;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN ContentDownloaded;
|
||||||
|
UINTN ContentLength;
|
||||||
|
UINTN LastReportedNbOfBytes;
|
||||||
|
UINTN BufferSize;
|
||||||
|
UINTN Status;
|
||||||
|
UINTN Flags;
|
||||||
|
UINT8 *Buffer;
|
||||||
|
CHAR16 *ServerAddrAndProto;
|
||||||
|
CHAR16 *Uri;
|
||||||
|
EFI_HTTP_TOKEN ResponseToken;
|
||||||
|
EFI_HTTP_TOKEN RequestToken;
|
||||||
|
EFI_HTTP_PROTOCOL *Http;
|
||||||
|
EFI_HTTP_CONFIG_DATA HttpConfigData;
|
||||||
|
} HTTP_DOWNLOAD_CONTEXT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function for 'http' command.
|
||||||
|
|
||||||
|
@param[in] ImageHandle The image handle.
|
||||||
|
@param[in] SystemTable The system table.
|
||||||
|
|
||||||
|
@retval SHELL_SUCCESS Command completed successfully.
|
||||||
|
@retval SHELL_INVALID_PARAMETER Command usage error.
|
||||||
|
@retval SHELL_ABORTED The user aborts the operation.
|
||||||
|
@retval value Unknown error.
|
||||||
|
**/
|
||||||
|
SHELL_STATUS
|
||||||
|
RunHttp (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieve HII package list from ImageHandle and publish to HII database.
|
||||||
|
|
||||||
|
@param[in] ImageHandle The image handle of the process.
|
||||||
|
|
||||||
|
@retval HII handle.
|
||||||
|
**/
|
||||||
|
EFI_HII_HANDLE
|
||||||
|
InitializeHiiPackage (
|
||||||
|
IN EFI_HANDLE ImageHandle
|
||||||
|
);
|
||||||
|
#endif // _HTTP_H_
|
|
@ -0,0 +1,117 @@
|
||||||
|
// /**
|
||||||
|
//
|
||||||
|
// (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
|
||||||
|
// Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
|
||||||
|
// Copyright (c) 2020, Broadcom. All rights reserved.<BR>
|
||||||
|
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
//
|
||||||
|
// Module Name:
|
||||||
|
//
|
||||||
|
// Http.uni
|
||||||
|
//
|
||||||
|
// Abstract:
|
||||||
|
//
|
||||||
|
// String definitions for UEFI Shell HTTP command
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// **/
|
||||||
|
|
||||||
|
/=#
|
||||||
|
|
||||||
|
#langdef en-US "english"
|
||||||
|
|
||||||
|
#string STR_GEN_TOO_MANY #language en-US "%H%s%N: Too many arguments. Try help http.\r\n"
|
||||||
|
#string STR_GEN_TOO_FEW #language en-US "%H%s%N: Too few arguments. Try help http.\r\n"
|
||||||
|
#string STR_GEN_PARAM_INV #language en-US "%H%s%N: Invalid argument - '%H%s%N'. Try help http.\r\n"
|
||||||
|
#string STR_GEN_PROBLEM #language en-US "%H%s%N: Unknown flag - '%H%s%N'. Try help http.\r\n"
|
||||||
|
#string STR_GEN_FILE_OPEN_FAIL #language en-US "%H%s%N: Cannot open file - '%H%s%N'\r\n"
|
||||||
|
#string STR_GEN_CRLF #language en-US "\r\n"
|
||||||
|
|
||||||
|
#string STR_HTTP_ERR_NO_NIC #language en-US "No network interface card found.\r\n"
|
||||||
|
#string STR_HTTP_ERR_NIC_NAME #language en-US "Failed to get the name of the network interface card number %d - %r\r\n"
|
||||||
|
#string STR_HTTP_ERR_OPEN_PROTOCOL #language en-US "Unable to open HTTP protocol on '%H%s%N' - %r\r\n"
|
||||||
|
#string STR_HTTP_ERR_CONFIGURE #language en-US "Unable to configure HTTP protocol on '%H%s%N' - %r\r\n"
|
||||||
|
#string STR_HTTP_ERR_DOWNLOAD #language en-US "Unable to download the file '%H%s%N' on '%H%s%N' - %r\r\n"
|
||||||
|
#string STR_HTTP_ERR_WRITE #language en-US "Unable to write into file '%H%s%N' - %r\r\n"
|
||||||
|
#string STR_HTTP_ERR_NIC_NOT_FOUND #language en-US "Network Interface Card '%H%s%N' not found.\r\n"
|
||||||
|
#string STR_HTTP_ERR_STATUSCODE #language en-US "\r'%H%s%N' reports '%s' for '%H%s%N' \r\n"
|
||||||
|
#string STR_HTTP_DOWNLOADING #language en-US "Downloading '%H%s%N'\r\n"
|
||||||
|
|
||||||
|
#string STR_GET_HELP_HTTP #language en-US ""
|
||||||
|
".TH http 0 "Download a file from HTTP server."\r\n"
|
||||||
|
".SH NAME\r\n"
|
||||||
|
"Download a file from HTTP server.\r\n"
|
||||||
|
".SH SYNOPSIS\r\n"
|
||||||
|
" \r\n"
|
||||||
|
"HTTP [-i interface] [-l port] [-t timeout] [-s size] [-m] [-k]\r\n"
|
||||||
|
" <URL> [localfilepath]\r\n"
|
||||||
|
".SH OPTIONS\r\n"
|
||||||
|
" \r\n"
|
||||||
|
" -i interface - Specifies an adapter name, i.e., eth0.\r\n"
|
||||||
|
" -k Keep the downloaded file even if there was an error.\r\n"
|
||||||
|
" If this parameter is not used, the file will be deleted.\r\n"
|
||||||
|
" -l port - Specifies the local port number. Default value is 0\r\n"
|
||||||
|
" and the port number is automatically assigned.\r\n"
|
||||||
|
" -m Measure and report download time (in seconds). \r\n"
|
||||||
|
" -s size The size of the download buffer for a chunk, in bytes.\r\n"
|
||||||
|
" Default is 32K. Note that larger buffer does not imply\r\n"
|
||||||
|
" better speed.\r\n"
|
||||||
|
" -t timeout - The number of seconds to wait for completion of\r\n"
|
||||||
|
" requests and responses. Default is 0 which is 'automatic'.\r\n"
|
||||||
|
" %HURL%N\r\n"
|
||||||
|
" Two types of providing of URLs are supported:\r\n"
|
||||||
|
" 1. tftp-like, where host and http_uri are separate parameters\r\n"
|
||||||
|
" (example: host /host_uri), and\r\n\"
|
||||||
|
" 2. wget-like, where host and host_uri is one parameter.\r\n"
|
||||||
|
" (example: host/host_uri)\r\n"
|
||||||
|
"\r\n"
|
||||||
|
" host - Specifies HTTP Server address.\r\n
|
||||||
|
Can be either IPv4 address or 'http (or https)://addr'\r\n
|
||||||
|
Can use addresses resolvable by DNS as well. \r\n
|
||||||
|
Port can be specified after ':' if needed. \r\n
|
||||||
|
By default port 80 is used.\r\n"
|
||||||
|
" http_uri - HTTP server URI to download the file.\r\n"
|
||||||
|
"\r\n"
|
||||||
|
" localfilepath - Local destination file path.\r\n"
|
||||||
|
".SH DESCRIPTION\r\n"
|
||||||
|
" \r\n"
|
||||||
|
"NOTES:\r\n"
|
||||||
|
" 1. The HTTP command allows geting of the file specified by its 'http_uri'\r\n"
|
||||||
|
" path from the HTTP server specified by its 'host' IPv4 address. If the\r\n"
|
||||||
|
" optional 'localfilepath' parameter is provided, the downloaded file is\r\n"
|
||||||
|
" stored locally using the provided file path. If the local file path is\r\n"
|
||||||
|
" not specified, the file is stored in the current directory using the file\r\n"
|
||||||
|
" server's name.\r\n"
|
||||||
|
" 2. Before using the HTTP command, the network interface intended to be\r\n"
|
||||||
|
" used to retrieve the file must be configured. This configuration may be\r\n"
|
||||||
|
" done by means of the 'ifconfig' command.\r\n"
|
||||||
|
" 3. If a network interface is defined with the '-i' option then only this\r\n"
|
||||||
|
" interface will be used to retrieve the remote file. Otherwise, all network\r\n"
|
||||||
|
" interfaces are tried in the order they have been discovered during the\r\n"
|
||||||
|
" DXE phase.\r\n"
|
||||||
|
".SH EXAMPLES\r\n"
|
||||||
|
" \r\n"
|
||||||
|
"EXAMPLES:\r\n"
|
||||||
|
" * To get the file "dir1/file1.dat" from the HTTP server 192.168.1.1, port 8080, and\r\n"
|
||||||
|
" store it as file2.dat in the current directory (use tftp-like URL format) :\r\n"
|
||||||
|
" fs0:\> http 192.168.1.1:8080 dir1/file1.dat file2.dat\r\n"
|
||||||
|
" * To get the file /image.bin via HTTPS from server 192.168.1.1 at port 443 \r\n"
|
||||||
|
" (default HTTPS port), and store it in the current directory: \r\n"
|
||||||
|
" fs0:\> http https://192.168.1.1 image.bin\r\n"
|
||||||
|
" To get an index file from http://google.com and place it into the \r\n"
|
||||||
|
" current directory:\r\n"
|
||||||
|
" fs0:\> http google.com index.html\r\n"
|
||||||
|
".SH RETURNVALUES\r\n"
|
||||||
|
" \r\n"
|
||||||
|
"RETURN VALUES:\r\n"
|
||||||
|
" SHELL_SUCCESS The action was completed as requested.\r\n"
|
||||||
|
" SHELL_INVALID_PARAMETER One of the passed-in parameters was incorrectly\r\n"
|
||||||
|
" formatted or its value was out of bounds.\r\n"
|
||||||
|
" HTTP_ERROR No EFI errors, but the server reported a status code\r\n"
|
||||||
|
" which should be treated as an error. If an error body sent\r\n"
|
||||||
|
" by the server, and -k parameter is on command line,
|
||||||
|
" the file wil be saved either as localfilepath filename,\r\n"
|
||||||
|
" or as an URI name in the current directory.\r\n"
|
||||||
|
" If '/' is at the end of the URL, and no locafilepath filename\r\n"
|
||||||
|
" is given on the command line, the file will be retrieved as\r\n"
|
||||||
|
" index.html.\r\n"
|
|
@ -0,0 +1,61 @@
|
||||||
|
/** @file
|
||||||
|
Entrypoint of "http" shell standalone application.
|
||||||
|
|
||||||
|
Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
|
||||||
|
Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2020, Broadcom. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include "Http.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* String token ID of help message text.
|
||||||
|
* Shell supports to find help message in the resource section of an
|
||||||
|
* application image if * .MAN file is not found.
|
||||||
|
* This global variable is added to make build tool recognizes
|
||||||
|
* that the help string is consumed by user and then build tool will
|
||||||
|
* add the string into the resource section.
|
||||||
|
* Thus the application can use '-?' option to show help message in Shell.
|
||||||
|
*/
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED
|
||||||
|
EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_HTTP);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Entry point of Http standalone application.
|
||||||
|
|
||||||
|
@param ImageHandle The image handle of the process.
|
||||||
|
@param SystemTable The EFI System Table pointer.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Http command is executed sucessfully.
|
||||||
|
@retval EFI_ABORTED HII package was failed to initialize.
|
||||||
|
@retval others Other errors when executing http command.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
HttpAppInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
SHELL_STATUS ShellStatus;
|
||||||
|
|
||||||
|
mHttpHiiHandle = InitializeHiiPackage (ImageHandle);
|
||||||
|
if (mHttpHiiHandle == NULL) {
|
||||||
|
return EFI_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
ShellStatus = RunHttp (ImageHandle, SystemTable);
|
||||||
|
|
||||||
|
HiiRemovePackages (mHttpHiiHandle);
|
||||||
|
|
||||||
|
if (Status != SHELL_SUCCESS) {
|
||||||
|
Status = ENCODE_ERROR (ShellStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
## @file
|
||||||
|
# Provides Shell 'http' standalone application.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved. <BR>
|
||||||
|
# Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
|
||||||
|
# Copyright (c) 2020, Broadcom. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010006
|
||||||
|
BASE_NAME = http
|
||||||
|
FILE_GUID = 56B00FB7-91D2-869B-CE5C-26CD1A89C73C
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = HttpAppInitialize
|
||||||
|
#
|
||||||
|
# This flag specifies whether HII resource section is generated into PE image.
|
||||||
|
#
|
||||||
|
UEFI_HII_RESOURCE_SECTION = TRUE
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
Http.c
|
||||||
|
HttpApp.c
|
||||||
|
Http.h
|
||||||
|
Http.uni
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
NetworkPkg/NetworkPkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
BaseMemoryLib
|
||||||
|
DebugLib
|
||||||
|
FileHandleLib
|
||||||
|
HiiLib
|
||||||
|
HttpLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
NetLib
|
||||||
|
ShellLib
|
||||||
|
UefiApplicationEntryPoint
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiHiiServicesLib
|
||||||
|
UefiLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiHiiPackageListProtocolGuid ## CONSUMES
|
||||||
|
gEfiHttpProtocolGuid ## CONSUMES
|
||||||
|
gEfiHttpServiceBindingProtocolGuid ## CONSUMES
|
||||||
|
gEfiManagedNetworkServiceBindingProtocolGuid ## CONSUMES
|
|
@ -0,0 +1,137 @@
|
||||||
|
/** @file
|
||||||
|
Produce "http" shell dynamic command.
|
||||||
|
|
||||||
|
Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
|
||||||
|
Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2020, Broadcom. All rights reserved.<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Protocol/ShellDynamicCommand.h>
|
||||||
|
#include "Http.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is the shell command handler function pointer callback type. This
|
||||||
|
function handles the command when it is invoked in the shell.
|
||||||
|
|
||||||
|
@param[in] This The instance of the
|
||||||
|
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
|
||||||
|
@param[in] SystemTable The pointer to the system table.
|
||||||
|
@param[in] ShellParameters The parameters associated with the command.
|
||||||
|
@param[in] Shell The instance of the shell protocol used in
|
||||||
|
the context of processing this command.
|
||||||
|
|
||||||
|
@return EFI_SUCCESS the operation was sucessful
|
||||||
|
@return other the operation failed.
|
||||||
|
**/
|
||||||
|
SHELL_STATUS
|
||||||
|
EFIAPI
|
||||||
|
HttpCommandHandler (
|
||||||
|
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||||
|
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
||||||
|
IN EFI_SHELL_PROTOCOL *Shell
|
||||||
|
)
|
||||||
|
{
|
||||||
|
gEfiShellParametersProtocol = ShellParameters;
|
||||||
|
gEfiShellProtocol = Shell;
|
||||||
|
|
||||||
|
return RunHttp (gImageHandle, SystemTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is the command help handler function pointer callback type. This
|
||||||
|
function is responsible for displaying help information for the associated
|
||||||
|
command.
|
||||||
|
|
||||||
|
@param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
|
||||||
|
@param[in] Language The pointer to the language string to use.
|
||||||
|
|
||||||
|
@return string Pool allocated help string, must be freed by caller
|
||||||
|
**/
|
||||||
|
CHAR16 *
|
||||||
|
EFIAPI
|
||||||
|
HttpCommandGetHelp (
|
||||||
|
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
|
||||||
|
IN CONST CHAR8 *Language
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return HiiGetString (
|
||||||
|
mHttpHiiHandle,
|
||||||
|
STRING_TOKEN (STR_GET_HELP_HTTP),
|
||||||
|
Language
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mHttpDynamicCommand = {
|
||||||
|
HTTP_APP_NAME,
|
||||||
|
HttpCommandHandler,
|
||||||
|
HttpCommandGetHelp
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Entry point of Http Dynamic Command.
|
||||||
|
|
||||||
|
Produce the DynamicCommand protocol to handle "http" command.
|
||||||
|
|
||||||
|
@param ImageHandle The image handle of the process.
|
||||||
|
@param SystemTable The EFI System Table pointer.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Http command is executed sucessfully.
|
||||||
|
@retval EFI_ABORTED HII package was failed to initialize.
|
||||||
|
@retval others Other errors when executing http command.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
HttpCommandInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
mHttpHiiHandle = InitializeHiiPackage (ImageHandle);
|
||||||
|
if (mHttpHiiHandle == NULL) {
|
||||||
|
return EFI_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->InstallProtocolInterface (
|
||||||
|
&ImageHandle,
|
||||||
|
&gEfiShellDynamicCommandProtocolGuid,
|
||||||
|
EFI_NATIVE_INTERFACE,
|
||||||
|
&mHttpDynamicCommand
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Http driver unload handler.
|
||||||
|
|
||||||
|
@param ImageHandle The image handle of the process.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The image is unloaded.
|
||||||
|
@retval Others Failed to unload the image.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
HttpUnload (
|
||||||
|
IN EFI_HANDLE ImageHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = gBS->UninstallProtocolInterface (
|
||||||
|
ImageHandle,
|
||||||
|
&gEfiShellDynamicCommandProtocolGuid,
|
||||||
|
&mHttpDynamicCommand
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiiRemovePackages (mHttpHiiHandle);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
## @file
|
||||||
|
# Provides Shell 'http' dynamic command.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved. <BR>
|
||||||
|
# Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
|
||||||
|
# Copyright (c) 2020, Broadcom. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010006
|
||||||
|
BASE_NAME = httpDynamicCommand
|
||||||
|
FILE_GUID = 19618BCE-55AE-09C6-37E9-4CE04084C7A1
|
||||||
|
MODULE_TYPE = DXE_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = HttpCommandInitialize
|
||||||
|
UNLOAD_IMAGE = HttpUnload
|
||||||
|
#
|
||||||
|
# This flag specifies whether HII resource section is generated into PE image.
|
||||||
|
#
|
||||||
|
UEFI_HII_RESOURCE_SECTION = TRUE
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
Http.c
|
||||||
|
HttpDynamicCommand.c
|
||||||
|
Http.h
|
||||||
|
Http.uni
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
NetworkPkg/NetworkPkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
BaseMemoryLib
|
||||||
|
DebugLib
|
||||||
|
FileHandleLib
|
||||||
|
HiiLib
|
||||||
|
HttpLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
NetLib
|
||||||
|
ShellLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
UefiHiiServicesLib
|
||||||
|
UefiLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiHiiPackageListProtocolGuid ## CONSUMES
|
||||||
|
gEfiHttpProtocolGuid ## CONSUMES
|
||||||
|
gEfiHttpServiceBindingProtocolGuid ## CONSUMES
|
||||||
|
gEfiManagedNetworkServiceBindingProtocolGuid ## CONSUMES
|
||||||
|
gEfiShellDynamicCommandProtocolGuid ## PRODUCES
|
||||||
|
|
||||||
|
[DEPEX]
|
||||||
|
TRUE
|
|
@ -59,6 +59,10 @@
|
||||||
0x738a9314, 0x82c1, 0x4592, { 0x8f, 0xf7, 0xc1, 0xbd, 0xf1, 0xb2, 0x0e, 0xd4 } \
|
0x738a9314, 0x82c1, 0x4592, { 0x8f, 0xf7, 0xc1, 0xbd, 0xf1, 0xb2, 0x0e, 0xd4 } \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SHELL_HTTP_HII_GUID \
|
||||||
|
{ \
|
||||||
|
0x390f84b3, 0x221c, 0x4d9e, { 0xb5, 0x06, 0x6d, 0xb9, 0x42, 0x3e, 0x0a, 0x7e } \
|
||||||
|
}
|
||||||
|
|
||||||
#define SHELL_BCFG_HII_GUID \
|
#define SHELL_BCFG_HII_GUID \
|
||||||
{ \
|
{ \
|
||||||
|
@ -75,6 +79,7 @@ extern EFI_GUID gShellLevel3HiiGuid;
|
||||||
extern EFI_GUID gShellNetwork1HiiGuid;
|
extern EFI_GUID gShellNetwork1HiiGuid;
|
||||||
extern EFI_GUID gShellNetwork2HiiGuid;
|
extern EFI_GUID gShellNetwork2HiiGuid;
|
||||||
extern EFI_GUID gShellTftpHiiGuid;
|
extern EFI_GUID gShellTftpHiiGuid;
|
||||||
|
extern EFI_GUID gShellHttpHiiGuid;
|
||||||
extern EFI_GUID gShellBcfgHiiGuid;
|
extern EFI_GUID gShellBcfgHiiGuid;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
gShellNetwork1HiiGuid = {0xf3d301bb, 0xf4a5, 0x45a8, {0xb0, 0xb7, 0xfa, 0x99, 0x9c, 0x62, 0x37, 0xae}}
|
gShellNetwork1HiiGuid = {0xf3d301bb, 0xf4a5, 0x45a8, {0xb0, 0xb7, 0xfa, 0x99, 0x9c, 0x62, 0x37, 0xae}}
|
||||||
gShellNetwork2HiiGuid = {0x174b2b5, 0xf505, 0x4b12, {0xaa, 0x60, 0x59, 0xdf, 0xf8, 0xd6, 0xea, 0x37}}
|
gShellNetwork2HiiGuid = {0x174b2b5, 0xf505, 0x4b12, {0xaa, 0x60, 0x59, 0xdf, 0xf8, 0xd6, 0xea, 0x37}}
|
||||||
gShellTftpHiiGuid = {0x738a9314, 0x82c1, 0x4592, {0x8f, 0xf7, 0xc1, 0xbd, 0xf1, 0xb2, 0x0e, 0xd4}}
|
gShellTftpHiiGuid = {0x738a9314, 0x82c1, 0x4592, {0x8f, 0xf7, 0xc1, 0xbd, 0xf1, 0xb2, 0x0e, 0xd4}}
|
||||||
|
gShellHttpHiiGuid = {0x390f84b3, 0x221c, 0x4d9e, {0xb5, 0x06, 0x6d, 0xb9, 0x42, 0x3e, 0x0a, 0x7e}}
|
||||||
gShellBcfgHiiGuid = {0x5f5f605d, 0x1583, 0x4a2d, {0xa6, 0xb2, 0xeb, 0x12, 0xda, 0xb4, 0xa2, 0xb6}}
|
gShellBcfgHiiGuid = {0x5f5f605d, 0x1583, 0x4a2d, {0xa6, 0xb2, 0xeb, 0x12, 0xda, 0xb4, 0xa2, 0xb6}}
|
||||||
gShellAcpiViewHiiGuid = {0xda8ccdf4, 0xed8f, 0x4ffc, {0xb5, 0xef, 0x2e, 0xf5, 0x5e, 0x24, 0x93, 0x2a}}
|
gShellAcpiViewHiiGuid = {0xda8ccdf4, 0xed8f, 0x4ffc, {0xb5, 0xef, 0x2e, 0xf5, 0x5e, 0x24, 0x93, 0x2a}}
|
||||||
# FILE_GUID as defined in ShellPkg/Application/Shell/Shell.inf
|
# FILE_GUID as defined in ShellPkg/Application/Shell/Shell.inf
|
||||||
|
|
|
@ -139,6 +139,11 @@
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
|
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
|
||||||
}
|
}
|
||||||
ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
|
ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
|
||||||
|
ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
|
||||||
|
<PcdsFixedAtBuild>
|
||||||
|
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
|
||||||
|
}
|
||||||
|
ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.inf
|
||||||
ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
|
ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
|
||||||
<PcdsFixedAtBuild>
|
<PcdsFixedAtBuild>
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
|
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
|
||||||
|
|
Loading…
Reference in New Issue