2 The implementation for the 'http' Shell command.
4 Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
5 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved. <BR>
6 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
7 Copyright (c) 2020, Broadcom. All rights reserved. <BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
17 // Constant strings and definitions related to the message
18 // indicating the amount of progress in the dowloading of a HTTP file.
22 // Number of steps in the progression slider.
24 #define HTTP_PROGRESS_SLIDER_STEPS \
25 ((sizeof (HTTP_PROGR_FRAME) / sizeof (CHAR16)) - 3)
28 // Size in number of characters plus one (final zero) of the message to
29 // indicate the progress of an HTTP download. The format is "[(progress slider:
30 // 40 characters)] (nb of KBytes downloaded so far: 7 characters) Kb". There
31 // are thus the number of characters in HTTP_PROGR_FRAME[] plus 11 characters
32 // (2 // spaces, "Kb" and seven characters for the number of KBytes).
34 #define HTTP_PROGRESS_MESSAGE_SIZE \
35 ((sizeof (HTTP_PROGR_FRAME) / sizeof (CHAR16)) + 12)
38 // Buffer size. Note that larger buffer does not mean better speed.
40 #define DEFAULT_BUF_SIZE SIZE_32KB
41 #define MAX_BUF_SIZE SIZE_4MB
43 #define MIN_PARAM_COUNT 2
44 #define MAX_PARAM_COUNT 4
45 #define NEED_REDIRECTION(Code) \
46 (((Code >= HTTP_STATUS_300_MULTIPLE_CHOICES) \
47 && (Code <= HTTP_STATUS_307_TEMPORARY_REDIRECT)) \
48 || (Code == HTTP_STATUS_308_PERMANENT_REDIRECT))
50 #define CLOSE_HTTP_HANDLE(ControllerHandle, HttpChildHandle) \
52 if (HttpChildHandle) { \
53 CloseProtocolAndDestroyServiceChild ( \
55 &gEfiHttpServiceBindingProtocolGuid, \
56 &gEfiHttpProtocolGuid, \
59 HttpChildHandle = NULL; \
70 #define USER_AGENT_HDR "Mozilla/5.0 (EDK2; Linux) Gecko/20100101 Firefox/79.0"
72 #define TIMER_MAX_TIMEOUT_S 10
75 // File name to use when Uri ends with "/".
77 #define DEFAULT_HTML_FILE L"index.html"
78 #define DEFAULT_HTTP_PROTO L"http"
81 // String to delete the HTTP progress message to be able to update it :
82 // (HTTP_PROGRESS_MESSAGE_SIZE-1) '\b'.
84 #define HTTP_PROGRESS_DEL \
85 L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\
86 \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
88 #define HTTP_KB L"\b\b\b\b\b\b\b\b\b\b"
90 // Frame for the progression slider.
92 #define HTTP_PROGR_FRAME L"[ ]"
95 // Improve readability by using these macros.
97 #define PRINT_HII(token, ...) \
99 -1, -1, NULL, token, mHttpHiiHandle, __VA_ARGS__)
101 #define PRINT_HII_APP(token, value) \
102 PRINT_HII (token, HTTP_APP_NAME, value)
105 // TimeBaseLib.h constants.
106 // These will be removed once the library gets fixed.
110 // Define EPOCH (1970-JANUARY-01) in the Julian Date representation.
112 #define EPOCH_JULIAN_DATE 2440588
117 #define SEC_PER_MIN ((UINTN) 60)
118 #define SEC_PER_HOUR ((UINTN) 3600)
119 #define SEC_PER_DAY ((UINTN) 86400)
122 // String descriptions for server errors.
124 STATIC CONST CHAR16
*ErrStatusDesc
[] =
128 L
"402 Payment required",
131 L
"405 Method not allowed",
132 L
"406 Not acceptable",
133 L
"407 Proxy authentication required",
134 L
"408 Request time out",
137 L
"411 Length required",
138 L
"412 Precondition failed",
139 L
"413 Request entity too large",
140 L
"414 Request URI to large",
141 L
"415 Unsupported media type",
142 L
"416 Requested range not satisfied",
143 L
"417 Expectation failed",
144 L
"500 Internal server error",
145 L
"501 Not implemented",
147 L
"503 Service unavailable",
148 L
"504 Gateway timeout",
149 L
"505 HTTP version not supported"
152 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
153 { L
"-i", TypeValue
},
155 { L
"-l", TypeValue
},
157 { L
"-s", TypeValue
},
158 { L
"-t", TypeValue
},
163 // Local File Handle.
165 STATIC SHELL_FILE_HANDLE mFileHandle
= NULL
;
168 // Path of the local file, Unicode encoded.
170 STATIC CONST CHAR16
*mLocalFilePath
;
172 STATIC BOOLEAN gRequestCallbackComplete
= FALSE
;
173 STATIC BOOLEAN gResponseCallbackComplete
= FALSE
;
175 STATIC BOOLEAN gHttpError
;
177 EFI_HII_HANDLE mHttpHiiHandle
;
180 // Functions declarations.
184 Check and convert the UINT16 option values of the 'http' command.
186 @param[in] ValueStr Value as an Unicode encoded string.
187 @param[out] Value UINT16 value.
189 @retval TRUE The value was returned.
190 @retval FALSE A parsing error occured.
195 IN CONST CHAR16
*ValueStr
,
200 Get the name of the NIC.
202 @param[in] ControllerHandle The network physical device handle.
203 @param[in] NicNumber The network physical device number.
204 @param[out] NicName Address where to store the NIC name.
205 The memory area has to be at least
206 IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH
209 @retval EFI_SUCCESS The name of the NIC was returned.
210 @retval Others The creation of the child for the Managed
211 Network Service failed or the opening of
212 the Managed Network Protocol failed or
213 the operational parameters for the
214 Managed Network Protocol could not be
220 IN EFI_HANDLE ControllerHandle
,
226 Create a child for the service identified by its service binding protocol GUID
227 and get from the child the interface of the protocol identified by its GUID.
229 @param[in] ControllerHandle Controller handle.
230 @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
231 service to be created.
232 @param[in] ProtocolGuid GUID of the protocol to be open.
233 @param[out] ChildHandle Address where the handler of the
234 created child is returned. NULL is
235 returned in case of error.
236 @param[out] Interface Address where a pointer to the
237 protocol interface is returned in
240 @retval EFI_SUCCESS The child was created and the protocol opened.
241 @retval Others Either the creation of the child or the opening
242 of the protocol failed.
246 CreateServiceChildAndOpenProtocol (
247 IN EFI_HANDLE ControllerHandle
,
248 IN EFI_GUID
*ServiceBindingProtocolGuid
,
249 IN EFI_GUID
*ProtocolGuid
,
250 OUT EFI_HANDLE
*ChildHandle
,
255 Close the protocol identified by its GUID on the child handle of the service
256 identified by its service binding protocol GUID, then destroy the child
259 @param[in] ControllerHandle Controller handle.
260 @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
261 service to be destroyed.
262 @param[in] ProtocolGuid GUID of the protocol to be closed.
263 @param[in] ChildHandle Handle of the child to be destroyed.
268 CloseProtocolAndDestroyServiceChild (
269 IN EFI_HANDLE ControllerHandle
,
270 IN EFI_GUID
*ServiceBindingProtocolGuid
,
271 IN EFI_GUID
*ProtocolGuid
,
272 IN EFI_HANDLE ChildHandle
276 Worker function that download the data of a file from an HTTP server given
277 the path of the file and its size.
279 @param[in] Context A pointer to the download context.
281 @retval EFI_SUCCESS The file was downloaded.
282 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
283 @retval Others The downloading of the file
284 from the server failed.
289 IN HTTP_DOWNLOAD_CONTEXT
*Context
,
290 IN EFI_HANDLE ControllerHandle
,
295 Cleans off leading and trailing spaces and tabs.
297 @param[in] String pointer to the string to trim them off.
299 @retval EFI_SUCCESS No errors.
300 @retval EFI_INVALID_PARAMETER String pointer is NULL.
311 ASSERT (String
!= NULL
);
313 if (String
== NULL
) {
314 return EFI_INVALID_PARAMETER
;
320 // Remove any whitespace at the beginning of the Str.
322 while (*Str
== L
' ' || *Str
== L
'\t') {
327 // Remove any whitespace at the end of the Str.
331 if (!Len
|| ((Str
[Len
- 1] != L
' ') && (Str
[Len
- 1] != '\t'))) {
335 Str
[Len
- 1] = CHAR_NULL
;
338 CopyMem (String
, Str
, StrSize (Str
));
344 // Callbacks for request and response.
345 // We just acknowledge that operation has completed here.
349 Callback to set the request completion flag.
351 @param[in] Event: The event.
352 @param[in] Context: pointer to Notification Context.
362 gRequestCallbackComplete
= TRUE
;
366 Callback to set the response completion flag.
367 @param[in] Event: The event.
368 @param[in] Context: pointer to Notification Context.
378 gResponseCallbackComplete
= TRUE
;
382 // Set of functions from TimeBaseLib.
383 // This will be removed once TimeBaseLib is enabled for ShellPkg.
387 Calculate Epoch days.
389 @param[in] Time - a pointer to the EFI_TIME abstraction.
391 @retval Number of days elapsed since EPOCH_JULIAN_DAY.
403 // Absolute Julian Date representation of the supplied Time.
407 // Number of days elapsed since EPOCH_JULIAN_DAY.
411 a
= (14 - Time
->Month
) / 12;
412 y
= Time
->Year
+ 4800 - a
;
413 m
= Time
->Month
+ (12 * a
) - 3;
415 JulianDate
= Time
->Day
+ ((153 * m
+ 2) / 5) + (365 * y
) + (y
/ 4) -
416 (y
/ 100) + (y
/ 400) - 32045;
418 ASSERT (JulianDate
>= EPOCH_JULIAN_DATE
);
419 EpochDays
= JulianDate
- EPOCH_JULIAN_DATE
;
425 Converts EFI_TIME to Epoch seconds
426 (elapsed since 1970 JANUARY 01, 00:00:00 UTC).
428 @param[in] Time: a pointer to EFI_TIME abstraction.
438 // Number of days elapsed since EPOCH_JULIAN_DAY.
443 EpochDays
= EfiGetEpochDays (Time
);
445 EpochSeconds
= (EpochDays
* SEC_PER_DAY
) +
446 ((UINTN
)Time
->Hour
* SEC_PER_HOUR
) +
447 (Time
->Minute
* SEC_PER_MIN
) + Time
->Second
;
453 Function for 'http' command.
455 @param[in] ImageHandle Handle to the Image (NULL if Internal).
456 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
458 @retval SHELL_SUCCESS The 'http' command completed successfully.
459 @retval SHELL_ABORTED The Shell Library initialization failed.
460 @retval SHELL_INVALID_PARAMETER At least one of the command's arguments is
462 @retval SHELL_OUT_OF_RESOURCES A memory allocation failed.
463 @retval SHELL_NOT_FOUND Network Interface Card not found.
464 @retval SHELL_UNSUPPORTED Command was valid, but the server returned
465 a status code indicating some error.
466 Examine the file requested for error body.
470 IN EFI_HANDLE ImageHandle
,
471 IN EFI_SYSTEM_TABLE
*SystemTable
475 LIST_ENTRY
*CheckPackage
;
482 CHAR16
*ProblemParam
;
483 CHAR16 NicName
[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH
];
486 CONST CHAR16
*UserNicName
;
487 CONST CHAR16
*ValueStr
;
488 CONST CHAR16
*RemoteFilePath
;
489 CONST CHAR16
*Walker
;
490 EFI_HTTPv4_ACCESS_POINT IPv4Node
;
492 EFI_HANDLE ControllerHandle
;
493 HTTP_DOWNLOAD_CONTEXT Context
;
497 RemoteFilePath
= NULL
;
502 // Initialize the Shell library (we must be in non-auto-init...).
507 Status
= ShellInitialize ();
508 if (EFI_ERROR (Status
)) {
509 ASSERT_EFI_ERROR (Status
);
510 return SHELL_ABORTED
;
513 ZeroMem (&Context
, sizeof (Context
));
516 // Parse the command line.
518 Status
= ShellCommandLineParse (
524 if (EFI_ERROR (Status
)) {
525 if ( (Status
== EFI_VOLUME_CORRUPTED
)
526 && (ProblemParam
!= NULL
))
528 PRINT_HII_APP (STRING_TOKEN (STR_GEN_PROBLEM
), ProblemParam
);
529 SHELL_FREE_NON_NULL (ProblemParam
);
538 // Check the number of parameters.
540 Status
= EFI_INVALID_PARAMETER
;
542 ParamCount
= ShellCommandLineGetCount (CheckPackage
);
543 if (ParamCount
> MAX_PARAM_COUNT
) {
544 PRINT_HII_APP (STRING_TOKEN (STR_GEN_TOO_MANY
), NULL
);
548 if (ParamCount
< MIN_PARAM_COUNT
) {
549 PRINT_HII_APP (STRING_TOKEN (STR_GEN_TOO_FEW
), NULL
);
553 ZeroMem (&Context
.HttpConfigData
, sizeof (Context
.HttpConfigData
));
554 ZeroMem (&IPv4Node
, sizeof (IPv4Node
));
555 IPv4Node
.UseDefaultAddress
= TRUE
;
557 Context
.HttpConfigData
.HttpVersion
= HttpVersion11
;
558 Context
.HttpConfigData
.AccessPoint
.IPv4Node
= &IPv4Node
;
561 // Get the host address (not necessarily IPv4 format).
563 ValueStr
= ShellCommandLineGetRawValue (CheckPackage
, 1);
565 PRINT_HII_APP (STRING_TOKEN (STR_GEN_PARAM_INV
), ValueStr
);
569 TrimSpaces ((CHAR16
*)ValueStr
);
570 if (!StrStr (ValueStr
, L
"://")) {
571 Context
.ServerAddrAndProto
= StrnCatGrow (
572 &Context
.ServerAddrAndProto
,
575 StrLen (DEFAULT_HTTP_PROTO
)
577 Context
.ServerAddrAndProto
= StrnCatGrow (
578 &Context
.ServerAddrAndProto
,
583 VStr
= (CHAR16
*)ValueStr
;
585 VStr
= StrStr (ValueStr
, L
"://") + StrLen (L
"://");
588 for (Walker1
= VStr
; *Walker1
; Walker1
++) {
589 if (*Walker1
== L
'/') {
594 if (*Walker1
== L
'/') {
596 RemoteFilePath
= Walker1
;
599 Context
.ServerAddrAndProto
= StrnCatGrow (
600 &Context
.ServerAddrAndProto
,
603 StrLen (ValueStr
) - StrLen (Walker1
)
605 if (!Context
.ServerAddrAndProto
) {
606 Status
= EFI_OUT_OF_RESOURCES
;
611 if (!RemoteFilePath
) {
612 RemoteFilePath
= ShellCommandLineGetRawValue (CheckPackage
, 2);
613 if (!RemoteFilePath
) {
615 // If no path given, assume just "/".
617 RemoteFilePath
= L
"/";
621 TrimSpaces ((CHAR16
*)RemoteFilePath
);
623 if (ParamCount
== MAX_PARAM_COUNT
- ParamOffset
) {
624 mLocalFilePath
= ShellCommandLineGetRawValue (
626 MAX_PARAM_COUNT
- 1 - ParamOffset
629 Walker
= RemoteFilePath
+ StrLen (RemoteFilePath
);
630 while ((--Walker
) >= RemoteFilePath
) {
631 if ((*Walker
== L
'\\') ||
638 mLocalFilePath
= Walker
+ 1;
641 if (!StrLen (mLocalFilePath
)) {
642 mLocalFilePath
= DEFAULT_HTML_FILE
;
646 Context
.Uri
= StrnCatGrow (
650 StrLen (RemoteFilePath
)
653 Status
= EFI_OUT_OF_RESOURCES
;
658 // Get the name of the Network Interface Card to be used if any.
660 UserNicName
= ShellCommandLineGetValue (CheckPackage
, L
"-i");
662 ValueStr
= ShellCommandLineGetValue (CheckPackage
, L
"-l");
663 if ( (ValueStr
!= NULL
)
664 && (!StringToUint16 (
666 &Context
.HttpConfigData
.AccessPoint
.IPv4Node
->LocalPort
673 Context
.BufferSize
= DEFAULT_BUF_SIZE
;
675 ValueStr
= ShellCommandLineGetValue (CheckPackage
, L
"-s");
676 if (ValueStr
!= NULL
) {
677 Context
.BufferSize
= ShellStrToUintn (ValueStr
);
678 if (!Context
.BufferSize
|| (Context
.BufferSize
> MAX_BUF_SIZE
)) {
679 PRINT_HII_APP (STRING_TOKEN (STR_GEN_PARAM_INV
), ValueStr
);
684 ValueStr
= ShellCommandLineGetValue (CheckPackage
, L
"-t");
685 if (ValueStr
!= NULL
) {
686 Context
.HttpConfigData
.TimeOutMillisec
= (UINT32
)ShellStrToUintn (ValueStr
);
690 // Locate all HTTP Service Binding protocols.
692 Status
= gBS
->LocateHandleBuffer (
694 &gEfiManagedNetworkServiceBindingProtocolGuid
,
699 if (EFI_ERROR (Status
) || (HandleCount
== 0)) {
700 PRINT_HII (STRING_TOKEN (STR_HTTP_ERR_NO_NIC
), NULL
);
701 if (!EFI_ERROR (Status
)) {
702 Status
= EFI_NOT_FOUND
;
708 Status
= EFI_NOT_FOUND
;
711 if (ShellCommandLineGetFlag (CheckPackage
, L
"-m")) {
712 Context
.Flags
|= DL_FLAG_TIME
;
715 if (ShellCommandLineGetFlag (CheckPackage
, L
"-k")) {
716 Context
.Flags
|= DL_FLAG_KEEP_BAD
;
720 (NicNumber
< HandleCount
) && (Status
!= EFI_SUCCESS
);
723 ControllerHandle
= Handles
[NicNumber
];
725 Status
= GetNicName (ControllerHandle
, NicNumber
, NicName
);
726 if (EFI_ERROR (Status
)) {
727 PRINT_HII (STRING_TOKEN (STR_HTTP_ERR_NIC_NAME
), NicNumber
, Status
);
731 if (UserNicName
!= NULL
) {
732 if (StrCmp (NicName
, UserNicName
) != 0) {
733 Status
= EFI_NOT_FOUND
;
740 Status
= DownloadFile (&Context
, ControllerHandle
, NicName
);
741 PRINT_HII (STRING_TOKEN (STR_GEN_CRLF
), NULL
);
743 if (EFI_ERROR (Status
)) {
745 STRING_TOKEN (STR_HTTP_ERR_DOWNLOAD
),
751 // If a user aborted the operation,
752 // do not try another controller.
754 if (Status
== EFI_ABORTED
) {
761 // This is not related to connection, so no need to repeat with
762 // another interface.
768 if ((UserNicName
!= NULL
) && (!NicFound
)) {
769 PRINT_HII (STRING_TOKEN (STR_HTTP_ERR_NIC_NOT_FOUND
), UserNicName
);
773 ShellCommandLineFreeVarList (CheckPackage
);
774 SHELL_FREE_NON_NULL (Handles
);
775 SHELL_FREE_NON_NULL (Context
.ServerAddrAndProto
);
776 SHELL_FREE_NON_NULL (Context
.Uri
);
778 return Status
& ~MAX_BIT
;
782 Check and convert the UINT16 option values of the 'http' command
784 @param[in] ValueStr Value as an Unicode encoded string
785 @param[out] Value UINT16 value
787 @retval TRUE The value was returned.
788 @retval FALSE A parsing error occured.
793 IN CONST CHAR16
*ValueStr
,
799 Val
= ShellStrToUintn (ValueStr
);
800 if (Val
> MAX_UINT16
) {
801 PRINT_HII_APP (STRING_TOKEN (STR_GEN_PARAM_INV
), ValueStr
);
805 *Value
= (UINT16
)Val
;
810 Get the name of the NIC.
812 @param[in] ControllerHandle The network physical device handle.
813 @param[in] NicNumber The network physical device number.
814 @param[out] NicName Address where to store the NIC name.
815 The memory area has to be at least
816 IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH
819 @retval EFI_SUCCESS The name of the NIC was returned.
820 @retval Others The creation of the child for the Managed
821 Network Service failed or the opening of
822 the Managed Network Protocol failed or
823 the operational parameters for the
824 Managed Network Protocol could not be
830 IN EFI_HANDLE ControllerHandle
,
836 EFI_HANDLE MnpHandle
;
837 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
838 EFI_SIMPLE_NETWORK_MODE SnpMode
;
840 Status
= CreateServiceChildAndOpenProtocol (
842 &gEfiManagedNetworkServiceBindingProtocolGuid
,
843 &gEfiManagedNetworkProtocolGuid
,
847 if (EFI_ERROR (Status
)) {
851 Status
= Mnp
->GetModeData (Mnp
, NULL
, &SnpMode
);
852 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_STARTED
)) {
858 IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH
,
859 SnpMode
.IfType
== NET_IFTYPE_ETHERNET
? L
"eth%d" : L
"unk%d",
863 Status
= EFI_SUCCESS
;
867 if (MnpHandle
!= NULL
) {
868 CloseProtocolAndDestroyServiceChild (
870 &gEfiManagedNetworkServiceBindingProtocolGuid
,
871 &gEfiManagedNetworkProtocolGuid
,
880 Create a child for the service identified by its service binding protocol GUID
881 and get from the child the interface of the protocol identified by its GUID.
883 @param[in] ControllerHandle Controller handle.
884 @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
885 service to be created.
886 @param[in] ProtocolGuid GUID of the protocol to be open.
887 @param[out] ChildHandle Address where the handler of the
888 created child is returned. NULL is
889 returned in case of error.
890 @param[out] Interface Address where a pointer to the
891 protocol interface is returned in
894 @retval EFI_SUCCESS The child was created and the protocol opened.
895 @retval Others Either the creation of the child or the opening
896 of the protocol failed.
900 CreateServiceChildAndOpenProtocol (
901 IN EFI_HANDLE ControllerHandle
,
902 IN EFI_GUID
*ServiceBindingProtocolGuid
,
903 IN EFI_GUID
*ProtocolGuid
,
904 OUT EFI_HANDLE
*ChildHandle
,
911 Status
= NetLibCreateServiceChild (
914 ServiceBindingProtocolGuid
,
917 if (!EFI_ERROR (Status
)) {
918 Status
= gBS
->OpenProtocol (
924 EFI_OPEN_PROTOCOL_GET_PROTOCOL
926 if (EFI_ERROR (Status
)) {
927 NetLibDestroyServiceChild (
930 ServiceBindingProtocolGuid
,
941 Close the protocol identified by its GUID on the child handle of the service
942 identified by its service binding protocol GUID, then destroy the child
945 @param[in] ControllerHandle Controller handle.
946 @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
947 service to be destroyed.
948 @param[in] ProtocolGuid GUID of the protocol to be closed.
949 @param[in] ChildHandle Handle of the child to be destroyed.
953 CloseProtocolAndDestroyServiceChild (
954 IN EFI_HANDLE ControllerHandle
,
955 IN EFI_GUID
*ServiceBindingProtocolGuid
,
956 IN EFI_GUID
*ProtocolGuid
,
957 IN EFI_HANDLE ChildHandle
967 NetLibDestroyServiceChild (
970 ServiceBindingProtocolGuid
,
976 Wait until operation completes. Completion is indicated by
977 setting of an appropriate variable.
979 @param[in] Context A pointer to the HTTP download context.
980 @param[in, out] CallBackComplete A pointer to the callback completion
981 variable set by the callback.
983 @retval EFI_SUCCESS Callback signalled completion.
984 @retval EFI_TIMEOUT Timed out waiting for completion.
985 @retval Others Error waiting for completion.
990 IN HTTP_DOWNLOAD_CONTEXT
*Context
,
991 IN OUT BOOLEAN
*CallBackComplete
997 Status
= EFI_SUCCESS
;
1000 // Use a timer to measure timeout. Cannot use Stall here!
1002 Status
= gBS
->CreateEvent (
1009 ASSERT_EFI_ERROR (Status
);
1011 if (!EFI_ERROR (Status
)) {
1012 Status
= gBS
->SetTimer (
1015 EFI_TIMER_PERIOD_SECONDS (TIMER_MAX_TIMEOUT_S
)
1018 ASSERT_EFI_ERROR (Status
);
1021 while ( !*CallBackComplete
1022 && (!EFI_ERROR (Status
))
1023 && EFI_ERROR (gBS
->CheckEvent (WaitEvt
)))
1025 Status
= Context
->Http
->Poll (Context
->Http
);
1026 if ( !Context
->ContentDownloaded
1027 && (CallBackComplete
== &gResponseCallbackComplete
))
1030 // An HTTP server may just send a response redirection header.
1031 // In this case, don't wait for the event as
1032 // it might never happen and we waste 10s waiting.
1033 // Note that at this point Response may not has been populated,
1034 // so it needs to be checked first.
1036 if ( Context
->ResponseToken
.Message
1037 && Context
->ResponseToken
.Message
->Data
.Response
1038 && (NEED_REDIRECTION (
1039 Context
->ResponseToken
.Message
->Data
.Response
->StatusCode
1048 gBS
->SetTimer (WaitEvt
, TimerCancel
, 0);
1049 gBS
->CloseEvent (WaitEvt
);
1051 if (*CallBackComplete
) {
1055 if (!EFI_ERROR (Status
)) {
1056 Status
= EFI_TIMEOUT
;
1063 Generate and send a request to the http server.
1065 @param[in] Context HTTP download context.
1066 @param[in] DownloadUrl Fully qualified URL to be downloaded.
1068 @retval EFI_SUCCESS Request has been sent successfully.
1069 @retval EFI_INVALID_PARAMETER Invalid URL.
1070 @retval EFI_OUT_OF_RESOURCES Out of memory.
1071 @retval EFI_DEVICE_ERROR If HTTPS is used, this probably
1072 means that TLS support either was not
1073 installed or not configured.
1074 @retval Others Error sending the request.
1079 IN HTTP_DOWNLOAD_CONTEXT
*Context
,
1080 IN CHAR16
*DownloadUrl
1083 EFI_HTTP_REQUEST_DATA RequestData
;
1084 EFI_HTTP_HEADER RequestHeader
[HdrMax
];
1085 EFI_HTTP_MESSAGE RequestMessage
;
1090 ZeroMem (&RequestData
, sizeof (RequestData
));
1091 ZeroMem (&RequestHeader
, sizeof (RequestHeader
));
1092 ZeroMem (&RequestMessage
, sizeof (RequestMessage
));
1093 ZeroMem (&Context
->RequestToken
, sizeof (Context
->RequestToken
));
1095 RequestHeader
[HdrHost
].FieldName
= "Host";
1096 RequestHeader
[HdrConn
].FieldName
= "Connection";
1097 RequestHeader
[HdrAgent
].FieldName
= "User-Agent";
1099 Host
= (CHAR16
*)Context
->ServerAddrAndProto
;
1100 while (*Host
!= CHAR_NULL
&& *Host
!= L
'/') {
1104 if (*Host
== CHAR_NULL
) {
1105 return EFI_INVALID_PARAMETER
;
1109 // Get the next slash.
1113 // And now the host name.
1117 StringSize
= StrLen (Host
) + 1;
1118 RequestHeader
[HdrHost
].FieldValue
= AllocatePool (StringSize
);
1119 if (!RequestHeader
[HdrHost
].FieldValue
) {
1120 return EFI_OUT_OF_RESOURCES
;
1123 UnicodeStrToAsciiStrS (
1125 RequestHeader
[HdrHost
].FieldValue
,
1129 RequestHeader
[HdrConn
].FieldValue
= "close";
1130 RequestHeader
[HdrAgent
].FieldValue
= USER_AGENT_HDR
;
1131 RequestMessage
.HeaderCount
= HdrMax
;
1133 RequestData
.Method
= HttpMethodGet
;
1134 RequestData
.Url
= DownloadUrl
;
1136 RequestMessage
.Data
.Request
= &RequestData
;
1137 RequestMessage
.Headers
= RequestHeader
;
1138 RequestMessage
.BodyLength
= 0;
1139 RequestMessage
.Body
= NULL
;
1140 Context
->RequestToken
.Event
= NULL
;
1143 // Completion callback event to be set when Request completes.
1145 Status
= gBS
->CreateEvent (
1150 &Context
->RequestToken
.Event
1152 ASSERT_EFI_ERROR (Status
);
1154 Context
->RequestToken
.Status
= EFI_SUCCESS
;
1155 Context
->RequestToken
.Message
= &RequestMessage
;
1156 gRequestCallbackComplete
= FALSE
;
1157 Status
= Context
->Http
->Request (Context
->Http
, &Context
->RequestToken
);
1158 if (EFI_ERROR (Status
)) {
1162 Status
= WaitForCompletion (Context
, &gRequestCallbackComplete
);
1163 if (EFI_ERROR (Status
)) {
1164 Context
->Http
->Cancel (Context
->Http
, &Context
->RequestToken
);
1168 SHELL_FREE_NON_NULL (RequestHeader
[HdrHost
].FieldValue
);
1169 if (Context
->RequestToken
.Event
) {
1170 gBS
->CloseEvent (Context
->RequestToken
.Event
);
1171 ZeroMem (&Context
->RequestToken
, sizeof (Context
->RequestToken
));
1178 Update the progress of a file download
1179 This procedure is called each time a new HTTP body portion is received.
1181 @param[in] Context HTTP download context.
1182 @param[in] DownloadLen Portion size, in bytes.
1183 @param[in] Buffer The pointer to the parsed buffer.
1185 @retval EFI_SUCCESS Portion saved.
1186 @retval Other Error saving the portion.
1192 IN HTTP_DOWNLOAD_CONTEXT
*Context
,
1193 IN UINTN DownloadLen
,
1197 CHAR16 Progress
[HTTP_PROGRESS_MESSAGE_SIZE
];
1207 ShellSetFilePosition (mFileHandle
, Context
->LastReportedNbOfBytes
);
1208 Status
= ShellWriteFile (mFileHandle
, &DownloadLen
, Buffer
);
1209 if (EFI_ERROR (Status
)) {
1210 if (Context
->ContentDownloaded
> 0) {
1211 PRINT_HII (STRING_TOKEN (STR_GEN_CRLF
), NULL
);
1214 PRINT_HII (STRING_TOKEN (STR_HTTP_ERR_WRITE
), mLocalFilePath
, Status
);
1218 if (Context
->ContentDownloaded
== 0) {
1219 ShellPrintEx (-1, -1, L
"%s 0 Kb", HTTP_PROGR_FRAME
);
1222 Context
->ContentDownloaded
+= DownloadLen
;
1223 NbOfKb
= Context
->ContentDownloaded
>> 10;
1225 Progress
[0] = L
'\0';
1226 if (Context
->ContentLength
) {
1227 LastStep
= (Context
->LastReportedNbOfBytes
* HTTP_PROGRESS_SLIDER_STEPS
) /
1228 Context
->ContentLength
;
1229 Step
= (Context
->ContentDownloaded
* HTTP_PROGRESS_SLIDER_STEPS
) /
1230 Context
->ContentLength
;
1233 Context
->LastReportedNbOfBytes
= Context
->ContentDownloaded
;
1235 if (Step
<= LastStep
) {
1236 if (!Context
->ContentLength
) {
1238 // Update downloaded size, there is no length info available.
1240 ShellPrintEx (-1, -1, L
"%s", HTTP_KB
);
1241 ShellPrintEx (-1, -1, L
"%7d Kb", NbOfKb
);
1247 ShellPrintEx (-1, -1, L
"%s", HTTP_PROGRESS_DEL
);
1249 Status
= StrCpyS (Progress
, HTTP_PROGRESS_MESSAGE_SIZE
, HTTP_PROGR_FRAME
);
1250 if (EFI_ERROR (Status
)) {
1254 for (Index
= 1; Index
< Step
; Index
++) {
1255 Progress
[Index
] = L
'=';
1259 Progress
[Step
] = L
'>';
1263 Progress
+ (sizeof (HTTP_PROGR_FRAME
) / sizeof (CHAR16
)) - 1,
1264 sizeof (Progress
) - sizeof (HTTP_PROGR_FRAME
),
1269 ShellPrintEx (-1, -1, L
"%s", Progress
);
1275 Replace the original Host and Uri with Host and Uri returned by the
1276 HTTP server in 'Location' header (redirection).
1278 @param[in] Location A pointer to the 'Location' string
1279 provided by HTTP server.
1280 @param[in] Context A pointer to HTTP download context.
1281 @param[in] DownloadUrl Fully qualified HTTP URL.
1283 @retval EFI_SUCCESS Host and Uri were successfully set.
1284 @retval EFI_OUT_OF_RESOURCES Error setting Host or Uri.
1290 IN HTTP_DOWNLOAD_CONTEXT
*Context
,
1291 IN CHAR16
*DownloadUrl
1303 BOOLEAN IsAbEmptyUrl
;
1307 IsAbEmptyUrl
= FALSE
;
1310 StringSize
= (AsciiStrSize (Location
) * sizeof (CHAR16
));
1311 Url
= AllocateZeroPool (StringSize
);
1313 return EFI_OUT_OF_RESOURCES
;
1316 Status
= AsciiStrToUnicodeStrS (
1317 (CONST CHAR8
*)Location
,
1322 if (EFI_ERROR (Status
)) {
1327 // If an HTTP server redirects to the same location more than once,
1328 // then stop attempts and tell it is not reachable.
1330 if (!StrCmp (Url
, DownloadUrl
)) {
1331 Status
= EFI_NO_MAPPING
;
1335 if (AsciiStrLen (Location
) > 2) {
1337 // Some servers return 'Location: //server/resource'
1339 IsAbEmptyUrl
= (Location
[0] == '/') && (Location
[1] == '/');
1349 if (AsciiStrStr (Location
, "://") || IsAbEmptyUrl
) {
1353 for (Step
= FirstStep
; Step
< 2; Step
++) {
1354 for ( ; *Walker
!= '/' && *Walker
!= '\0'; Walker
++) {
1367 Tmp
= AllocateZeroPool (Idx
+ 1);
1369 Status
= EFI_OUT_OF_RESOURCES
;
1373 CopyMem (Tmp
, Location
, Idx
);
1376 // Location now points to Uri
1379 StringSize
= (Idx
+ 1) * sizeof (CHAR16
);
1381 SHELL_FREE_NON_NULL (Context
->ServerAddrAndProto
);
1383 Temp
= AllocateZeroPool (StringSize
);
1385 Status
= EFI_OUT_OF_RESOURCES
;
1389 Status
= AsciiStrToUnicodeStrS (
1394 if (EFI_ERROR (Status
)) {
1395 SHELL_FREE_NON_NULL (Temp
);
1401 Context
->ServerAddrAndProto
= StrnCatGrow (
1402 &Context
->ServerAddrAndProto
,
1409 Context
->ServerAddrAndProto
= StrnCatGrow (
1410 &Context
->ServerAddrAndProto
,
1415 SHELL_FREE_NON_NULL (Temp
);
1416 if (!Context
->ServerAddrAndProto
) {
1417 Status
= EFI_OUT_OF_RESOURCES
;
1422 SHELL_FREE_NON_NULL (Context
->Uri
);
1424 StringSize
= AsciiStrSize (Location
) * sizeof (CHAR16
);
1425 Context
->Uri
= AllocateZeroPool (StringSize
);
1426 if (!Context
->Uri
) {
1427 Status
= EFI_OUT_OF_RESOURCES
;
1432 // Now make changes to the Uri part.
1434 Status
= AsciiStrToUnicodeStrS (
1435 (CONST CHAR8
*)Location
,
1440 SHELL_FREE_NON_NULL (Tmp
);
1441 SHELL_FREE_NON_NULL (Url
);
1447 Message parser callback.
1448 Save a portion of HTTP body.
1450 @param[in] EventType Type of event. Can be either
1451 OnComplete or OnData.
1452 @param[in] Data A pointer to the buffer with data.
1453 @param[in] Length Data length of this portion.
1454 @param[in] Context A pointer to the HTTP download context.
1456 @retval EFI_SUCCESS The portion was processed successfully.
1457 @retval Other Error returned by SavePortion.
1463 IN HTTP_BODY_PARSE_EVENT EventType
,
1470 || (EventType
== BodyParseEventOnComplete
)
1471 || (Context
== NULL
))
1476 return SavePortion (Context
, Length
, Data
);
1480 Get HTTP server response and collect the whole body as a file.
1481 Set appropriate status in Context (REQ_OK, REQ_REPEAT, REQ_ERROR).
1482 Note that even if HTTP server returns an error code, it might send
1483 the body as well. This body will be collected in the resultant file.
1485 @param[in] Context A pointer to the HTTP download context.
1486 @param[in] DownloadUrl A pointer to the fully qualified URL to download.
1488 @retval EFI_SUCCESS Valid file. Body successfully collected.
1489 @retval EFI_HTTP_ERROR Response is a valid HTTP response, but the
1491 indicated an error (HTTP code >= 400).
1492 Response body MAY contain full
1493 HTTP server response.
1494 @retval Others Error getting the reponse from the HTTP server.
1495 Response body is not collected.
1500 IN HTTP_DOWNLOAD_CONTEXT
*Context
,
1501 IN CHAR16
*DownloadUrl
1504 EFI_HTTP_RESPONSE_DATA ResponseData
;
1505 EFI_HTTP_MESSAGE ResponseMessage
;
1506 EFI_HTTP_HEADER
*Header
;
1512 UINTN ElapsedSeconds
;
1514 BOOLEAN CanMeasureTime
;
1516 ZeroMem (&ResponseData
, sizeof (ResponseData
));
1517 ZeroMem (&ResponseMessage
, sizeof (ResponseMessage
));
1518 ZeroMem (&Context
->ResponseToken
, sizeof (Context
->ResponseToken
));
1521 ResponseMessage
.Body
= Context
->Buffer
;
1522 Context
->ResponseToken
.Status
= EFI_SUCCESS
;
1523 Context
->ResponseToken
.Message
= &ResponseMessage
;
1524 Context
->ContentLength
= 0;
1525 Context
->Status
= REQ_OK
;
1526 Status
= EFI_SUCCESS
;
1528 ResponseData
.StatusCode
= HTTP_STATUS_UNSUPPORTED_STATUS
;
1529 ResponseMessage
.Data
.Response
= &ResponseData
;
1530 Context
->ResponseToken
.Event
= NULL
;
1531 CanMeasureTime
= FALSE
;
1532 if (Context
->Flags
& DL_FLAG_TIME
) {
1533 ZeroMem (&StartTime
, sizeof (StartTime
));
1534 CanMeasureTime
= !EFI_ERROR (gRT
->GetTime (&StartTime
, NULL
));
1538 SHELL_FREE_NON_NULL (ResponseMessage
.Headers
);
1539 ResponseMessage
.HeaderCount
= 0;
1540 gResponseCallbackComplete
= FALSE
;
1541 ResponseMessage
.BodyLength
= Context
->BufferSize
;
1543 if (ShellGetExecutionBreakFlag ()) {
1544 Status
= EFI_ABORTED
;
1548 if (!Context
->ContentDownloaded
&& !Context
->ResponseToken
.Event
) {
1549 Status
= gBS
->CreateEvent (
1554 &Context
->ResponseToken
.Event
1556 ASSERT_EFI_ERROR (Status
);
1558 ResponseMessage
.Data
.Response
= NULL
;
1561 if (EFI_ERROR (Status
)) {
1565 Status
= Context
->Http
->Response (Context
->Http
, &Context
->ResponseToken
);
1566 if (EFI_ERROR (Status
)) {
1570 Status
= WaitForCompletion (Context
, &gResponseCallbackComplete
);
1571 if (EFI_ERROR (Status
) && ResponseMessage
.HeaderCount
) {
1572 Status
= EFI_SUCCESS
;
1575 if (EFI_ERROR (Status
)) {
1576 Context
->Http
->Cancel (Context
->Http
, &Context
->ResponseToken
);
1580 if (!Context
->ContentDownloaded
) {
1581 if (NEED_REDIRECTION (ResponseData
.StatusCode
)) {
1583 // Need to repeat the request with new Location (server redirected).
1585 Context
->Status
= REQ_NEED_REPEAT
;
1587 Header
= HttpFindHeader (
1588 ResponseMessage
.HeaderCount
,
1589 ResponseMessage
.Headers
,
1593 Status
= SetHostURI (Header
->FieldValue
, Context
, DownloadUrl
);
1594 if (Status
== EFI_NO_MAPPING
) {
1596 STRING_TOKEN (STR_HTTP_ERR_STATUSCODE
),
1597 Context
->ServerAddrAndProto
,
1598 L
"Recursive HTTP server relocation",
1604 // Bad reply from the server. Server must specify the location.
1605 // Indicate that resource was not found, and no body collected.
1607 Status
= EFI_NOT_FOUND
;
1610 Context
->Http
->Cancel (Context
->Http
, &Context
->ResponseToken
);
1615 // Init message-body parser by header information.
1618 Status
= HttpInitMsgParser (
1619 ResponseMessage
.Data
.Request
->Method
,
1620 ResponseData
.StatusCode
,
1621 ResponseMessage
.HeaderCount
,
1622 ResponseMessage
.Headers
,
1627 if (EFI_ERROR (Status
)) {
1633 // If it is a trunked message, rely on the parser.
1635 Header
= HttpFindHeader (
1636 ResponseMessage
.HeaderCount
,
1637 ResponseMessage
.Headers
,
1640 IsTrunked
= (Header
&& !AsciiStrCmp (Header
->FieldValue
, "chunked"));
1642 HttpGetEntityLength (MsgParser
, &Context
->ContentLength
);
1644 if ( (ResponseData
.StatusCode
>= HTTP_STATUS_400_BAD_REQUEST
)
1645 && (ResponseData
.StatusCode
!= HTTP_STATUS_308_PERMANENT_REDIRECT
))
1648 // Server reported an error via Response code.
1649 // Collect the body if any.
1654 Desc
= ErrStatusDesc
[ResponseData
.StatusCode
-
1655 HTTP_STATUS_400_BAD_REQUEST
];
1657 STRING_TOKEN (STR_HTTP_ERR_STATUSCODE
),
1658 Context
->ServerAddrAndProto
,
1664 // This gives an RFC HTTP error.
1666 Context
->Status
= ShellStrToUintn (Desc
);
1667 Status
= ENCODE_ERROR (Context
->Status
);
1673 // Do NOT try to parse an empty body.
1675 if (ResponseMessage
.BodyLength
|| IsTrunked
) {
1676 Status
= HttpParseMessageBody (
1678 ResponseMessage
.BodyLength
,
1679 ResponseMessage
.Body
1682 } while ( !HttpIsMessageComplete (MsgParser
)
1683 && !EFI_ERROR (Status
)
1684 && ResponseMessage
.BodyLength
);
1686 if ( (Context
->Status
!= REQ_NEED_REPEAT
)
1687 && (Status
== EFI_SUCCESS
)
1690 if (!EFI_ERROR (gRT
->GetTime (&EndTime
, NULL
))) {
1691 ElapsedSeconds
= EfiTimeToEpoch (&EndTime
) - EfiTimeToEpoch (&StartTime
);
1694 ElapsedSeconds
? " " : " < ",
1695 ElapsedSeconds
> 1 ? (UINT64
)ElapsedSeconds
: 1
1700 SHELL_FREE_NON_NULL (MsgParser
);
1701 if (Context
->ResponseToken
.Event
) {
1702 gBS
->CloseEvent (Context
->ResponseToken
.Event
);
1703 ZeroMem (&Context
->ResponseToken
, sizeof (Context
->ResponseToken
));
1710 Worker function that downloads the data of a file from an HTTP server given
1711 the path of the file and its size.
1713 @param[in] Context A pointer to the HTTP download context.
1714 @param[in] ControllerHandle The handle of the network interface controller
1715 @param[in] NicName NIC name
1717 @retval EFI_SUCCESS The file was downloaded.
1718 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
1719 #return EFI_HTTP_ERROR The server returned a valid HTTP error.
1720 Examine the mLocalFilePath file
1722 @retval Others The downloading of the file from the server
1728 IN HTTP_DOWNLOAD_CONTEXT
*Context
,
1729 IN EFI_HANDLE ControllerHandle
,
1734 CHAR16
*DownloadUrl
;
1736 EFI_HANDLE HttpChildHandle
;
1739 if (Context
== NULL
) {
1740 return EFI_INVALID_PARAMETER
;
1744 HttpChildHandle
= NULL
;
1746 Context
->Buffer
= AllocatePool (Context
->BufferSize
);
1747 if (Context
->Buffer
== NULL
) {
1748 Status
= EFI_OUT_OF_RESOURCES
;
1755 if (!EFI_ERROR (ShellFileExists (mLocalFilePath
))) {
1756 ShellDeleteFileByName (mLocalFilePath
);
1759 Status
= ShellOpenFileByName (
1762 EFI_FILE_MODE_CREATE
|
1763 EFI_FILE_MODE_WRITE
|
1767 if (EFI_ERROR (Status
)) {
1768 PRINT_HII_APP (STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL
), mLocalFilePath
);
1773 SHELL_FREE_NON_NULL (DownloadUrl
);
1775 CLOSE_HTTP_HANDLE (ControllerHandle
, HttpChildHandle
);
1777 Status
= CreateServiceChildAndOpenProtocol (
1779 &gEfiHttpServiceBindingProtocolGuid
,
1780 &gEfiHttpProtocolGuid
,
1782 (VOID
**)&Context
->Http
1785 if (EFI_ERROR (Status
)) {
1786 PRINT_HII (STRING_TOKEN (STR_HTTP_ERR_OPEN_PROTOCOL
), NicName
, Status
);
1790 Status
= Context
->Http
->Configure (Context
->Http
, &Context
->HttpConfigData
);
1791 if (EFI_ERROR (Status
)) {
1792 PRINT_HII (STRING_TOKEN (STR_HTTP_ERR_CONFIGURE
), NicName
, Status
);
1797 DownloadUrl
= StrnCatGrow (
1800 Context
->ServerAddrAndProto
,
1801 StrLen (Context
->ServerAddrAndProto
)
1803 if (Context
->Uri
[0] != L
'/') {
1804 DownloadUrl
= StrnCatGrow (
1808 StrLen (Context
->ServerAddrAndProto
)
1812 DownloadUrl
= StrnCatGrow (
1816 StrLen (Context
->Uri
)
1819 PRINT_HII (STRING_TOKEN (STR_HTTP_DOWNLOADING
), DownloadUrl
);
1821 Status
= SendRequest (Context
, DownloadUrl
);
1826 Status
= GetResponse (Context
, DownloadUrl
);
1831 } while (Context
->Status
== REQ_NEED_REPEAT
);
1833 if (Context
->Status
) {
1834 Status
= ENCODE_ERROR (Context
->Status
);
1841 if (mFileHandle
!= NULL
) {
1842 if (EFI_ERROR (Status
) && !(Context
->Flags
& DL_FLAG_KEEP_BAD
)) {
1843 ShellDeleteFile (&mFileHandle
);
1845 ShellCloseFile (&mFileHandle
);
1849 SHELL_FREE_NON_NULL (DownloadUrl
);
1850 SHELL_FREE_NON_NULL (Context
->Buffer
);
1852 CLOSE_HTTP_HANDLE (ControllerHandle
, HttpChildHandle
);
1858 Retrive HII package list from ImageHandle and publish to HII database.
1860 @param[in] ImageHandle The image handle of the process.
1865 InitializeHiiPackage (
1866 IN EFI_HANDLE ImageHandle
1870 EFI_HII_PACKAGE_LIST_HEADER
*PackageList
;
1871 EFI_HII_HANDLE HiiHandle
;
1874 // Retrieve HII package list from ImageHandle.
1876 Status
= gBS
->OpenProtocol (
1878 &gEfiHiiPackageListProtocolGuid
,
1879 (VOID
**)&PackageList
,
1882 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1884 ASSERT_EFI_ERROR (Status
);
1885 if (EFI_ERROR (Status
)) {
1890 // Publish HII package list to HII Database.
1892 Status
= gHiiDatabase
->NewPackageList (
1898 ASSERT_EFI_ERROR (Status
);
1899 if (EFI_ERROR (Status
)) {