2 HII Library implementation that uses DXE protocols and services.
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "InternalHiiLib.h"
17 #define GUID_CONFIG_STRING_TYPE 0x00
18 #define NAME_CONFIG_STRING_TYPE 0x01
19 #define PATH_CONFIG_STRING_TYPE 0x02
21 #define ACTION_SET_DEFAUTL_VALUE 0x01
22 #define ACTION_VALIDATE_SETTING 0x02
24 #define HII_LIB_DEFAULT_VARSTORE_SIZE 0x200
27 LIST_ENTRY Entry
; // Link to Block array
35 EFI_VARSTORE_ID VarStoreId
;
37 } IFR_VARSTORAGE_DATA
;
40 // <ConfigHdr> Template
42 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR16 mConfigHdrTemplate
[] = L
"GUID=00000000000000000000000000000000&NAME=0000&PATH=00";
44 EFI_FORM_BROWSER2_PROTOCOL
*mUefiFormBrowser2
= NULL
;
47 // Template used to mark the end of a list of packages
49 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_PACKAGE_HEADER mEndOfPakageList
= {
50 sizeof (EFI_HII_PACKAGE_HEADER
),
55 Extract Hii package list GUID for given HII handle.
57 If HiiHandle could not be found in the HII database, then ASSERT.
58 If Guid is NULL, then ASSERT.
60 @param Handle Hii handle
61 @param Guid Package list GUID
63 @retval EFI_SUCCESS Successfully extract GUID from Hii database.
68 InternalHiiExtractGuidFromHiiHandle (
69 IN EFI_HII_HANDLE Handle
,
75 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
77 ASSERT (Guid
!= NULL
);
78 ASSERT (Handle
!= NULL
);
81 // Get HII PackageList
84 HiiPackageList
= NULL
;
86 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &BufferSize
, HiiPackageList
);
87 ASSERT (Status
!= EFI_NOT_FOUND
);
89 if (Status
== EFI_BUFFER_TOO_SMALL
) {
90 HiiPackageList
= AllocatePool (BufferSize
);
91 ASSERT (HiiPackageList
!= NULL
);
93 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &BufferSize
, HiiPackageList
);
95 if (EFI_ERROR (Status
)) {
96 FreePool (HiiPackageList
);
103 CopyGuid (Guid
, &HiiPackageList
->PackageListGuid
);
105 FreePool (HiiPackageList
);
111 Registers a list of packages in the HII Database and returns the HII Handle
112 associated with that registration. If an HII Handle has already been registered
113 with the same PackageListGuid and DeviceHandle, then NULL is returned. If there
114 are not enough resources to perform the registration, then NULL is returned.
115 If an empty list of packages is passed in, then NULL is returned. If the size of
116 the list of package is 0, then NULL is returned.
118 The variable arguments are pointers which point to package header that defined
119 by UEFI VFR compiler and StringGather tool.
121 #pragma pack (push, 1)
124 EFI_HII_PACKAGE_HEADER PackageHeader;
125 } EDKII_AUTOGEN_PACKAGES_HEADER;
128 @param[in] PackageListGuid The GUID of the package list.
129 @param[in] DeviceHandle If not NULL, the Device Handle on which
130 an instance of DEVICE_PATH_PROTOCOL is installed.
131 This Device Handle uniquely defines the device that
132 the added packages are associated with.
133 @param[in] ... The variable argument list that contains pointers
134 to packages terminated by a NULL.
136 @retval NULL A HII Handle has already been registered in the HII Database with
137 the same PackageListGuid and DeviceHandle.
138 @retval NULL The HII Handle could not be created.
139 @retval NULL An empty list of packages was passed in.
140 @retval NULL All packages are empty.
141 @retval Other The HII Handle associated with the newly registered package list.
147 IN CONST EFI_GUID
*PackageListGuid
,
148 IN EFI_HANDLE DeviceHandle OPTIONAL
,
155 EFI_HII_PACKAGE_LIST_HEADER
*PackageListHeader
;
156 EFI_HII_HANDLE HiiHandle
;
160 ASSERT (PackageListGuid
!= NULL
);
163 // Calculate the length of all the packages in the variable argument list
165 for (Length
= 0, VA_START (Args
, DeviceHandle
); (Package
= VA_ARG (Args
, UINT32
*)) != NULL
; ) {
166 Length
+= (ReadUnaligned32 (Package
) - sizeof (UINT32
));
171 // If there are no packages in the variable argument list or all the packages
172 // are empty, then return a NULL HII Handle
179 // Add the length of the Package List Header and the terminating Package Header
181 Length
+= sizeof (EFI_HII_PACKAGE_LIST_HEADER
) + sizeof (EFI_HII_PACKAGE_HEADER
);
184 // Allocate the storage for the entire Package List
186 PackageListHeader
= AllocateZeroPool (Length
);
189 // If the Package List can not be allocated, then return a NULL HII Handle
191 if (PackageListHeader
== NULL
) {
196 // Fill in the GUID and Length of the Package List Header
198 CopyGuid (&PackageListHeader
->PackageListGuid
, PackageListGuid
);
199 PackageListHeader
->PackageLength
= Length
;
202 // Initialize a pointer to the beginning if the Package List data
204 Data
= (UINT8
*)(PackageListHeader
+ 1);
207 // Copy the data from each package in the variable argument list
209 for (VA_START (Args
, DeviceHandle
); (Package
= VA_ARG (Args
, UINT32
*)) != NULL
; ) {
210 Length
= ReadUnaligned32 (Package
) - sizeof (UINT32
);
211 CopyMem (Data
, Package
+ 1, Length
);
217 // Append a package of type EFI_HII_PACKAGE_END to mark the end of the package list
219 CopyMem (Data
, &mEndOfPakageList
, sizeof (mEndOfPakageList
));
222 // Register the package list with the HII Database
224 Status
= gHiiDatabase
->NewPackageList (
230 if (EFI_ERROR (Status
)) {
235 // Free the allocated package list
237 FreePool (PackageListHeader
);
240 // Return the new HII Handle
246 Removes a package list from the HII database.
248 If HiiHandle is NULL, then ASSERT.
249 If HiiHandle is not a valid EFI_HII_HANDLE in the HII database, then ASSERT.
251 @param[in] HiiHandle The handle that was previously registered in the HII database
257 IN EFI_HII_HANDLE HiiHandle
262 ASSERT (HiiHandle
!= NULL
);
263 Status
= gHiiDatabase
->RemovePackageList (gHiiDatabase
, HiiHandle
);
264 ASSERT_EFI_ERROR (Status
);
269 Retrieves the array of all the HII Handles or the HII handles of a specific
270 package list GUID in the HII Database.
271 This array is terminated with a NULL HII Handle.
272 This function allocates the returned array using AllocatePool().
273 The caller is responsible for freeing the array with FreePool().
275 @param[in] PackageListGuid An optional parameter that is used to request
276 HII Handles associated with a specific
277 Package List GUID. If this parameter is NULL,
278 then all the HII Handles in the HII Database
279 are returned. If this parameter is not NULL,
280 then zero or more HII Handles associated with
281 PackageListGuid are returned.
283 @retval NULL No HII handles were found in the HII database
284 @retval NULL The array of HII Handles could not be retrieved
285 @retval Other A pointer to the NULL terminated array of HII Handles
291 IN CONST EFI_GUID
*PackageListGuid OPTIONAL
295 UINTN HandleBufferLength
;
296 EFI_HII_HANDLE TempHiiHandleBuffer
;
297 EFI_HII_HANDLE
*HiiHandleBuffer
;
303 // Retrieve the size required for the buffer of all HII handles.
305 HandleBufferLength
= 0;
306 Status
= gHiiDatabase
->ListPackageLists (
308 EFI_HII_PACKAGE_TYPE_ALL
,
315 // If ListPackageLists() returns EFI_SUCCESS for a zero size,
316 // then there are no HII handles in the HII database. If ListPackageLists()
317 // returns an error other than EFI_BUFFER_TOO_SMALL, then there are no HII
318 // handles in the HII database.
320 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
322 // Return NULL if the size can not be retrieved, or if there are no HII
323 // handles in the HII Database
329 // Allocate the array of HII handles to hold all the HII Handles and a NULL terminator
331 HiiHandleBuffer
= AllocateZeroPool (HandleBufferLength
+ sizeof (EFI_HII_HANDLE
));
332 if (HiiHandleBuffer
== NULL
) {
334 // Return NULL if allocation fails.
340 // Retrieve the array of HII Handles in the HII Database
342 Status
= gHiiDatabase
->ListPackageLists (
344 EFI_HII_PACKAGE_TYPE_ALL
,
349 if (EFI_ERROR (Status
)) {
351 // Free the buffer and return NULL if the HII handles can not be retrieved.
353 FreePool (HiiHandleBuffer
);
357 if (PackageListGuid
== NULL
) {
359 // Return the NULL terminated array of HII handles in the HII Database
361 return HiiHandleBuffer
;
363 for (Index1
= 0, Index2
= 0; HiiHandleBuffer
[Index1
] != NULL
; Index1
++) {
364 Status
= InternalHiiExtractGuidFromHiiHandle (HiiHandleBuffer
[Index1
], &Guid
);
365 ASSERT_EFI_ERROR (Status
);
366 if (CompareGuid (&Guid
, PackageListGuid
)) {
367 HiiHandleBuffer
[Index2
++] = HiiHandleBuffer
[Index1
];
371 HiiHandleBuffer
[Index2
] = NULL
;
372 return HiiHandleBuffer
;
374 FreePool (HiiHandleBuffer
);
381 This function allows a caller to extract the form set opcode form the Hii Handle.
382 The returned buffer is allocated using AllocatePool().The caller is responsible
383 for freeing the allocated buffer using FreePool().
385 @param Handle The HII handle.
386 @param Buffer On return, points to a pointer which point to the buffer that contain the formset opcode.
387 @param BufferSize On return, points to the length of the buffer.
389 @retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated.
390 @retval EFI_NOT_FOUND Can't find the package data for the input Handle.
391 @retval EFI_INVALID_PARAMETER The input parameters are not correct.
392 @retval EFI_SUCCESS Get the formset opcode from the hii handle successfully.
397 HiiGetFormSetFromHiiHandle(
398 IN EFI_HII_HANDLE Handle
,
399 OUT EFI_IFR_FORM_SET
**Buffer
,
400 OUT UINTN
*BufferSize
404 UINTN PackageListSize
;
406 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
409 UINT8
*FormSetBuffer
;
413 UINT32 PackageListLength
;
414 EFI_HII_PACKAGE_HEADER PackageHeader
;
417 FormSetBuffer
= NULL
;
421 // Get HII PackageList
424 HiiPackageList
= NULL
;
425 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &PackageListSize
, HiiPackageList
);
426 if (EFI_ERROR (Status
) && (Status
!= EFI_BUFFER_TOO_SMALL
)) {
430 HiiPackageList
= AllocatePool (PackageListSize
);
431 if (HiiPackageList
== NULL
) {
432 return EFI_OUT_OF_RESOURCES
;
435 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &PackageListSize
, HiiPackageList
);
436 ASSERT_EFI_ERROR (Status
);
439 // Get Form package from this HII package List
441 Status
= EFI_NOT_FOUND
;
442 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
443 PackageListLength
= ReadUnaligned32 (&HiiPackageList
->PackageLength
);
445 while (Offset
< PackageListLength
) {
446 Package
= ((UINT8
*) HiiPackageList
) + Offset
;
447 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
448 Offset
+= PackageHeader
.Length
;
450 if (PackageHeader
.Type
!= EFI_HII_PACKAGE_FORMS
) {
455 // Search FormSet Opcode in this Form Package
457 Offset2
= sizeof (EFI_HII_PACKAGE_HEADER
);
458 while (Offset2
< PackageHeader
.Length
) {
459 OpCodeData
= Package
+ Offset2
;
460 Offset2
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
462 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
!= EFI_IFR_FORM_SET_OP
) {
466 if (FormSetBuffer
!= NULL
){
467 TempBuffer
= AllocateCopyPool (TempSize
+ ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
, FormSetBuffer
);
468 FreePool(FormSetBuffer
);
469 FormSetBuffer
= NULL
;
470 if (TempBuffer
== NULL
) {
471 Status
= EFI_OUT_OF_RESOURCES
;
474 CopyMem (TempBuffer
+ TempSize
, OpCodeData
, ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
);
476 TempBuffer
= AllocateCopyPool (TempSize
+ ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
, OpCodeData
);
477 if (TempBuffer
== NULL
) {
478 Status
= EFI_OUT_OF_RESOURCES
;
482 TempSize
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
483 FormSetBuffer
= TempBuffer
;
485 Status
= EFI_SUCCESS
;
487 //One form package has one formset, exit current form package to search other form package in the packagelist.
493 FreePool (HiiPackageList
);
495 *BufferSize
= TempSize
;
496 *Buffer
= (EFI_IFR_FORM_SET
*)FormSetBuffer
;
502 Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for
503 hex digits that appear between a '=' and a '&' in a config string.
505 If ConfigString is NULL, then ASSERT().
507 @param[in] ConfigString Pointer to a Null-terminated Unicode string.
509 @return Pointer to the Null-terminated Unicode result string.
514 InternalHiiLowerConfigString (
515 IN EFI_STRING ConfigString
521 ASSERT (ConfigString
!= NULL
);
524 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
526 for (String
= ConfigString
, Lower
= FALSE
; *String
!= L
'\0'; String
++) {
527 if (*String
== L
'=') {
529 } else if (*String
== L
'&') {
531 } else if (Lower
&& *String
>= L
'A' && *String
<= L
'F') {
532 *String
= (CHAR16
) (*String
- L
'A' + L
'a');
540 Uses the BlockToConfig() service of the Config Routing Protocol to
541 convert <ConfigRequest> and a buffer to a <ConfigResp>
543 If ConfigRequest is NULL, then ASSERT().
544 If Block is NULL, then ASSERT().
546 @param[in] ConfigRequest Pointer to a Null-terminated Unicode string.
547 @param[in] Block Pointer to a block of data.
548 @param[in] BlockSize The zie, in bytes, of Block.
550 @retval NULL The <ConfigResp> string could not be generated.
551 @retval Other Pointer to the Null-terminated Unicode <ConfigResp> string.
556 InternalHiiBlockToConfig (
557 IN CONST EFI_STRING ConfigRequest
,
558 IN CONST UINT8
*Block
,
563 EFI_STRING ConfigResp
;
566 ASSERT (ConfigRequest
!= NULL
);
567 ASSERT (Block
!= NULL
);
570 // Convert <ConfigRequest> to <ConfigResp>
572 Status
= gHiiConfigRouting
->BlockToConfig (
580 if (EFI_ERROR (Status
)) {
587 Uses the BrowserCallback() service of the Form Browser Protocol to retrieve
588 or set uncommitted data. If sata i being retrieved, then the buffer is
589 allocated using AllocatePool(). The caller is then responsible for freeing
590 the buffer using FreePool().
592 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
593 parameter that may be NULL.
594 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
595 is an optional parameter that may be NULL.
596 @param[in] SetResultsData If not NULL, then this parameter specified the buffer
597 of uncommited data to set. If this parameter is NULL,
598 then the caller is requesting to get the uncommited data
599 from the Form Browser.
601 @retval NULL The uncommitted data could not be retrieved.
602 @retval Other A pointer to a buffer containing the uncommitted data.
607 InternalHiiBrowserCallback (
608 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
609 IN CONST CHAR16
*VariableName
, OPTIONAL
610 IN CONST EFI_STRING SetResultsData OPTIONAL
614 UINTN ResultsDataSize
;
615 EFI_STRING ResultsData
;
616 CHAR16 TempResultsData
;
621 if (mUefiFormBrowser2
== NULL
) {
622 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &mUefiFormBrowser2
);
623 if (EFI_ERROR (Status
) || mUefiFormBrowser2
== NULL
) {
630 if (SetResultsData
!= NULL
) {
632 // Request to to set data in the uncommitted browser state information
634 ResultsData
= SetResultsData
;
637 // Retrieve the length of the buffer required ResultsData from the Browser Callback
639 Status
= mUefiFormBrowser2
->BrowserCallback (
648 if (!EFI_ERROR (Status
)) {
650 // No Resluts Data, only allocate one char for '\0'
652 ResultsData
= AllocateZeroPool (sizeof (CHAR16
));
656 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
661 // Allocate the ResultsData buffer
663 ResultsData
= AllocateZeroPool (ResultsDataSize
);
664 if (ResultsData
== NULL
) {
670 // Retrieve or set the ResultsData from the Browser Callback
672 Status
= mUefiFormBrowser2
->BrowserCallback (
676 (BOOLEAN
)(SetResultsData
== NULL
),
680 if (EFI_ERROR (Status
)) {
688 Allocates and returns a Null-terminated Unicode <ConfigHdr> string using routing
689 information that includes a GUID, an optional Unicode string name, and a device
690 path. The string returned is allocated with AllocatePool(). The caller is
691 responsible for freeing the allocated string with FreePool().
693 The format of a <ConfigHdr> is as follows:
695 GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize<Null>
697 @param[in] Guid Pointer to an EFI_GUID that is the routing information
698 GUID. Each of the 16 bytes in Guid is converted to
699 a 2 Unicode character hexadecimal string. This is
700 an optional parameter that may be NULL.
701 @param[in] Name Pointer to a Null-terminated Unicode string that is
702 the routing information NAME. This is an optional
703 parameter that may be NULL. Each 16-bit Unicode
704 character in Name is converted to a 4 character Unicode
706 @param[in] DriverHandle The driver handle which supports a Device Path Protocol
707 that is the routing information PATH. Each byte of
708 the Device Path associated with DriverHandle is converted
709 to a 2 Unicode character hexadecimal string.
711 @retval NULL DriverHandle does not support the Device Path Protocol.
712 @retval Other A pointer to the Null-terminate Unicode <ConfigHdr> string
717 HiiConstructConfigHdr (
718 IN CONST EFI_GUID
*Guid
, OPTIONAL
719 IN CONST CHAR16
*Name
, OPTIONAL
720 IN EFI_HANDLE DriverHandle
724 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
725 UINTN DevicePathSize
;
727 CHAR16
*ReturnString
;
733 // Compute the length of Name in Unicode characters.
734 // If Name is NULL, then the length is 0.
738 NameLength
= StrLen (Name
);
744 // Retrieve DevicePath Protocol associated with DriverHandle
746 if (DriverHandle
!= NULL
) {
747 DevicePath
= DevicePathFromHandle (DriverHandle
);
748 if (DevicePath
== NULL
) {
752 // Compute the size of the device path in bytes
754 DevicePathSize
= GetDevicePathSize (DevicePath
);
758 // GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize <Null>
759 // | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 |
761 MaxLen
= 5 + sizeof (EFI_GUID
) * 2 + 6 + NameLength
* 4 + 6 + DevicePathSize
* 2 + 1;
762 String
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
763 if (String
== NULL
) {
768 // Start with L"GUID="
770 StrCpyS (String
, MaxLen
, L
"GUID=");
771 ReturnString
= String
;
772 String
+= StrLen (String
);
776 // Append Guid converted to <HexCh>32
778 for (Index
= 0, Buffer
= (UINT8
*)Guid
; Index
< sizeof (EFI_GUID
); Index
++) {
779 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, *(Buffer
++), 2);
786 StrCatS (ReturnString
, MaxLen
, L
"&NAME=");
787 String
+= StrLen (String
);
791 // Append Name converted to <Char>NameLength
793 for (; *Name
!= L
'\0'; Name
++) {
794 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, *Name
, 4);
801 StrCatS (ReturnString
, MaxLen
, L
"&PATH=");
802 String
+= StrLen (String
);
805 // Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize
807 for (Index
= 0, Buffer
= (UINT8
*)DevicePath
; Index
< DevicePathSize
; Index
++) {
808 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, *(Buffer
++), 2);
812 // Null terminate the Unicode string
817 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
819 return InternalHiiLowerConfigString (ReturnString
);
823 Convert the hex UNICODE encoding string of UEFI GUID, NAME or device path
824 to binary buffer from <ConfigHdr>.
826 This is a internal function.
828 @param String UEFI configuration string.
829 @param Flag Flag specifies what type buffer will be retrieved.
830 @param Buffer Binary of Guid, Name or Device path.
832 @retval EFI_INVALID_PARAMETER Any incoming parameter is invalid.
833 @retval EFI_OUT_OF_RESOURCES Lake of resources to store neccesary structures.
834 @retval EFI_SUCCESS The buffer data is retrieved and translated to
839 InternalHiiGetBufferFromString (
840 IN EFI_STRING String
,
846 EFI_STRING ConfigHdr
;
853 if (String
== NULL
|| Buffer
== NULL
) {
854 return EFI_INVALID_PARAMETER
;
861 // The content between 'GUID', 'NAME', 'PATH' of <ConfigHdr> and '&' of next element
862 // or '\0' (end of configuration string) is the UNICODE %02x bytes encoding string.
864 for (Length
= 0; *String
!= 0 && *String
!= L
'&'; String
++, Length
++);
867 case GUID_CONFIG_STRING_TYPE
:
868 case PATH_CONFIG_STRING_TYPE
:
870 // The data in <ConfigHdr> is encoded as hex UNICODE %02x bytes in the same order
871 // as the device path and Guid resides in RAM memory.
872 // Translate the data into binary.
874 DataBuffer
= (UINT8
*) AllocateZeroPool ((Length
+ 1) / 2);
875 if (DataBuffer
== NULL
) {
876 return EFI_OUT_OF_RESOURCES
;
879 // Convert binary byte one by one
881 ZeroMem (TemStr
, sizeof (TemStr
));
882 for (Index
= 0; Index
< Length
; Index
++) {
883 TemStr
[0] = ConfigHdr
[Index
];
884 DigitUint8
= (UINT8
) StrHexToUint64 (TemStr
);
885 if ((Index
& 1) == 0) {
886 DataBuffer
[Index
/2] = DigitUint8
;
888 DataBuffer
[Index
/2] = (UINT8
) ((DataBuffer
[Index
/2] << 4) + DigitUint8
);
892 *Buffer
= DataBuffer
;
895 case NAME_CONFIG_STRING_TYPE
:
897 // Convert Config String to Unicode String, e.g. "0041004200430044" => "ABCD"
901 // Add the tailling char L'\0'
903 DataBuffer
= (UINT8
*) AllocateZeroPool ((Length
/4 + 1) * sizeof (CHAR16
));
904 if (DataBuffer
== NULL
) {
905 return EFI_OUT_OF_RESOURCES
;
908 // Convert character one by one
910 StringPtr
= (CHAR16
*) DataBuffer
;
911 ZeroMem (TemStr
, sizeof (TemStr
));
912 for (Index
= 0; Index
< Length
; Index
+= 4) {
913 StrnCpyS (TemStr
, sizeof (TemStr
) / sizeof (CHAR16
), ConfigHdr
+ Index
, 4);
914 StringPtr
[Index
/4] = (CHAR16
) StrHexToUint64 (TemStr
);
917 // Add tailing L'\0' character
919 StringPtr
[Index
/4] = L
'\0';
921 *Buffer
= DataBuffer
;
925 return EFI_INVALID_PARAMETER
;
932 This function checks VarOffset and VarWidth is in the block range.
934 @param BlockArray The block array is to be checked.
935 @param VarOffset Offset of var to the structure
936 @param VarWidth Width of var.
938 @retval TRUE This Var is in the block range.
939 @retval FALSE This Var is not in the block range.
943 IN IFR_BLOCK_DATA
*BlockArray
,
949 IFR_BLOCK_DATA
*BlockData
;
952 // No Request Block array, all vars are got.
954 if (BlockArray
== NULL
) {
959 // Check the input var is in the request block range.
961 for (Link
= BlockArray
->Entry
.ForwardLink
; Link
!= &BlockArray
->Entry
; Link
= Link
->ForwardLink
) {
962 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
963 if ((VarOffset
>= BlockData
->Offset
) && ((VarOffset
+ VarWidth
) <= (BlockData
->Offset
+ BlockData
->Width
))) {
972 Get the value of <Number> in <BlockConfig> format, i.e. the value of OFFSET
974 <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE'=<Number>
976 @param ValueString String in <BlockConfig> format and points to the
977 first character of <Number>.
978 @param ValueData The output value. Caller takes the responsibility
980 @param ValueLength Length of the <Number>, in characters.
982 @retval EFI_OUT_OF_RESOURCES Insufficient resources to store neccessary
984 @retval EFI_SUCCESS Value of <Number> is outputted in Number
990 InternalHiiGetValueOfNumber (
991 IN EFI_STRING ValueString
,
992 OUT UINT8
**ValueData
,
993 OUT UINTN
*ValueLength
996 EFI_STRING StringPtr
;
1003 ASSERT (ValueString
!= NULL
&& ValueData
!= NULL
&& ValueLength
!= NULL
);
1004 ASSERT (*ValueString
!= L
'\0');
1007 // Get the length of value string
1009 StringPtr
= ValueString
;
1010 while (*StringPtr
!= L
'\0' && *StringPtr
!= L
'&') {
1013 Length
= StringPtr
- ValueString
;
1016 // Allocate buffer to store the value
1018 Buf
= (UINT8
*) AllocateZeroPool ((Length
+ 1) / 2);
1020 return EFI_OUT_OF_RESOURCES
;
1024 // Convert character one by one to the value buffer
1026 ZeroMem (TemStr
, sizeof (TemStr
));
1027 for (Index
= 0; Index
< Length
; Index
++) {
1028 TemStr
[0] = ValueString
[Length
- Index
- 1];
1029 DigitUint8
= (UINT8
) StrHexToUint64 (TemStr
);
1030 if ((Index
& 1) == 0) {
1031 Buf
[Index
/2] = DigitUint8
;
1033 Buf
[Index
/2] = (UINT8
) ((DigitUint8
<< 4) + Buf
[Index
/2]);
1038 // Set the converted value and string length.
1041 *ValueLength
= Length
;
1046 Get value from config request resp string.
1048 @param ConfigElement ConfigResp string contains the current setting.
1049 @param VarName The variable name which need to get value.
1050 @param VarValue The return value.
1052 @retval EFI_SUCCESS Get the value for the VarName
1053 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1056 GetValueFromRequest (
1057 IN CHAR16
*ConfigElement
,
1059 OUT UINT64
*VarValue
1068 // Find VarName related string.
1070 StringPtr
= StrStr (ConfigElement
, VarName
);
1071 ASSERT (StringPtr
!= NULL
);
1074 // Skip the "VarName=" string
1076 StringPtr
+= StrLen (VarName
) + 1;
1081 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1082 if (EFI_ERROR (Status
)) {
1087 CopyMem (VarValue
, TmpBuffer
, (((Length
+ 1) / 2) < sizeof (UINT64
)) ? ((Length
+ 1) / 2) : sizeof (UINT64
));
1089 FreePool (TmpBuffer
);
1095 This internal function parses IFR data to validate current setting.
1097 Base on the NameValueType, if it is TRUE, RequestElement and HiiHandle is valid;
1098 else the VarBuffer and CurrentBlockArray is valid.
1100 @param HiiPackageList Point to Hii package list.
1101 @param PackageListLength The length of the pacakge.
1102 @param VarGuid Guid of the buffer storage.
1103 @param VarName Name of the buffer storage.
1104 @param VarBuffer The data buffer for the storage.
1105 @param CurrentBlockArray The block array from the config Requst string.
1106 @param RequestElement The config string for this storage.
1107 @param HiiHandle The HiiHandle for this formset.
1108 @param NameValueType Whether current storage is name/value varstore or not.
1110 @retval EFI_SUCCESS The current setting is valid.
1111 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1112 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1115 ValidateQuestionFromVfr (
1116 IN EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
,
1117 IN UINTN PackageListLength
,
1118 IN EFI_GUID
*VarGuid
,
1120 IN UINT8
*VarBuffer
,
1121 IN IFR_BLOCK_DATA
*CurrentBlockArray
,
1122 IN CHAR16
*RequestElement
,
1123 IN EFI_HII_HANDLE HiiHandle
,
1124 IN BOOLEAN NameValueType
1127 IFR_BLOCK_DATA VarBlockData
;
1131 EFI_IFR_TYPE_VALUE TmpValue
;
1133 EFI_HII_PACKAGE_HEADER PackageHeader
;
1134 UINT32 PackageOffset
;
1137 EFI_IFR_OP_HEADER
*IfrOpHdr
;
1138 EFI_IFR_VARSTORE
*IfrVarStore
;
1139 EFI_IFR_VARSTORE_NAME_VALUE
*IfrNameValueStore
;
1140 EFI_IFR_VARSTORE_EFI
*IfrEfiVarStore
;
1141 IFR_VARSTORAGE_DATA VarStoreData
;
1142 EFI_IFR_ONE_OF
*IfrOneOf
;
1143 EFI_IFR_NUMERIC
*IfrNumeric
;
1144 EFI_IFR_ONE_OF_OPTION
*IfrOneOfOption
;
1145 EFI_IFR_CHECKBOX
*IfrCheckBox
;
1146 EFI_IFR_STRING
*IfrString
;
1147 CHAR8
*VarStoreName
;
1149 CHAR16
*QuestionName
;
1153 // Initialize the local variables.
1156 VarStoreName
= NULL
;
1157 Status
= EFI_SUCCESS
;
1160 IfrNameValueStore
= NULL
;
1161 IfrEfiVarStore
= NULL
;
1162 ZeroMem (&VarStoreData
, sizeof (IFR_VARSTORAGE_DATA
));
1163 ZeroMem (&VarBlockData
, sizeof (VarBlockData
));
1166 // Check IFR value is in block data, then Validate Value
1168 PackageOffset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
1169 while (PackageOffset
< PackageListLength
) {
1170 CopyMem (&PackageHeader
, (UINT8
*) HiiPackageList
+ PackageOffset
, sizeof (PackageHeader
));
1173 // Parse IFR opcode from the form package.
1175 if (PackageHeader
.Type
== EFI_HII_PACKAGE_FORMS
) {
1176 IfrOffset
= sizeof (PackageHeader
);
1177 PackageData
= (UINT8
*) HiiPackageList
+ PackageOffset
;
1178 while (IfrOffset
< PackageHeader
.Length
) {
1179 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) (PackageData
+ IfrOffset
);
1181 // Validate current setting to the value built in IFR opcode
1183 switch (IfrOpHdr
->OpCode
) {
1184 case EFI_IFR_VARSTORE_OP
:
1186 // VarStoreId has been found. No further found.
1188 if (VarStoreData
.VarStoreId
!= 0) {
1192 // Find the matched VarStoreId to the input VarGuid and VarName
1194 IfrVarStore
= (EFI_IFR_VARSTORE
*) IfrOpHdr
;
1195 if (CompareGuid ((EFI_GUID
*) (VOID
*) &IfrVarStore
->Guid
, VarGuid
)) {
1196 VarStoreName
= (CHAR8
*) IfrVarStore
->Name
;
1197 for (Index
= 0; VarStoreName
[Index
] != 0; Index
++) {
1198 if ((CHAR16
) VarStoreName
[Index
] != VarName
[Index
]) {
1203 // The matched VarStore is found.
1205 if ((VarStoreName
[Index
] != 0) || (VarName
[Index
] != 0)) {
1212 if (IfrVarStore
!= NULL
) {
1213 VarStoreData
.VarStoreId
= IfrVarStore
->VarStoreId
;
1214 VarStoreData
.Size
= IfrVarStore
->Size
;
1217 case EFI_IFR_VARSTORE_NAME_VALUE_OP
:
1219 // VarStoreId has been found. No further found.
1221 if (VarStoreData
.VarStoreId
!= 0) {
1225 // Find the matched VarStoreId to the input VarGuid
1227 IfrNameValueStore
= (EFI_IFR_VARSTORE_NAME_VALUE
*) IfrOpHdr
;
1228 if (!CompareGuid ((EFI_GUID
*) (VOID
*) &IfrNameValueStore
->Guid
, VarGuid
)) {
1229 IfrNameValueStore
= NULL
;
1232 if (IfrNameValueStore
!= NULL
) {
1233 VarStoreData
.VarStoreId
= IfrNameValueStore
->VarStoreId
;
1236 case EFI_IFR_VARSTORE_EFI_OP
:
1238 // VarStore is found. Don't need to search any more.
1240 if (VarStoreData
.VarStoreId
!= 0) {
1244 IfrEfiVarStore
= (EFI_IFR_VARSTORE_EFI
*) IfrOpHdr
;
1247 // If the length is small than the structure, this is from old efi
1248 // varstore definition. Old efi varstore get config directly from
1249 // GetVariable function.
1251 if (IfrOpHdr
->Length
< sizeof (EFI_IFR_VARSTORE_EFI
)) {
1255 if (CompareGuid ((EFI_GUID
*) (VOID
*) &IfrEfiVarStore
->Guid
, VarGuid
)) {
1256 VarStoreName
= (CHAR8
*) IfrEfiVarStore
->Name
;
1257 for (Index
= 0; VarStoreName
[Index
] != 0; Index
++) {
1258 if ((CHAR16
) VarStoreName
[Index
] != VarName
[Index
]) {
1263 // The matched VarStore is found.
1265 if ((VarStoreName
[Index
] != 0) || (VarName
[Index
] != 0)) {
1266 IfrEfiVarStore
= NULL
;
1269 IfrEfiVarStore
= NULL
;
1272 if (IfrEfiVarStore
!= NULL
) {
1274 // Find the matched VarStore
1276 VarStoreData
.VarStoreId
= IfrEfiVarStore
->VarStoreId
;
1277 VarStoreData
.Size
= IfrEfiVarStore
->Size
;
1280 case EFI_IFR_FORM_OP
:
1281 case EFI_IFR_FORM_MAP_OP
:
1283 // Check the matched VarStoreId is found.
1285 if (VarStoreData
.VarStoreId
== 0) {
1289 case EFI_IFR_ONE_OF_OP
:
1291 // Check whether current value is the one of option.
1295 // OneOf question is not in IFR Form. This IFR form is not valid.
1297 if (VarStoreData
.VarStoreId
== 0) {
1298 return EFI_INVALID_PARAMETER
;
1301 // Check whether this question is for the requested varstore.
1303 IfrOneOf
= (EFI_IFR_ONE_OF
*) IfrOpHdr
;
1304 if (IfrOneOf
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1308 if (NameValueType
) {
1309 QuestionName
= HiiGetString (HiiHandle
, IfrOneOf
->Question
.VarStoreInfo
.VarName
, NULL
);
1310 ASSERT (QuestionName
!= NULL
);
1312 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1314 // This question is not in the current configuration string. Skip it.
1319 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1320 if (EFI_ERROR (Status
)) {
1325 // Get Offset by Question header and Width by DataType Flags
1327 Offset
= IfrOneOf
->Question
.VarStoreInfo
.VarOffset
;
1328 Width
= (UINT16
) (1 << (IfrOneOf
->Flags
& EFI_IFR_NUMERIC_SIZE
));
1330 // Check whether this question is in current block array.
1332 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1334 // This question is not in the current configuration string. Skip it.
1339 // Check this var question is in the var storage
1341 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1343 // This question exceeds the var store size.
1345 return EFI_INVALID_PARAMETER
;
1349 // Get the current value for oneof opcode
1352 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1355 // Set Block Data, to be checked in the following Oneof option opcode.
1357 VarBlockData
.OpCode
= IfrOpHdr
->OpCode
;
1358 VarBlockData
.Scope
= IfrOpHdr
->Scope
;
1360 case EFI_IFR_NUMERIC_OP
:
1362 // Check the current value is in the numeric range.
1366 // Numeric question is not in IFR Form. This IFR form is not valid.
1368 if (VarStoreData
.VarStoreId
== 0) {
1369 return EFI_INVALID_PARAMETER
;
1372 // Check whether this question is for the requested varstore.
1374 IfrNumeric
= (EFI_IFR_NUMERIC
*) IfrOpHdr
;
1375 if (IfrNumeric
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1379 if (NameValueType
) {
1380 QuestionName
= HiiGetString (HiiHandle
, IfrNumeric
->Question
.VarStoreInfo
.VarName
, NULL
);
1381 ASSERT (QuestionName
!= NULL
);
1383 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1385 // This question is not in the current configuration string. Skip it.
1390 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1391 if (EFI_ERROR (Status
)) {
1396 // Get Offset by Question header and Width by DataType Flags
1398 Offset
= IfrNumeric
->Question
.VarStoreInfo
.VarOffset
;
1399 Width
= (UINT16
) (1 << (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
));
1401 // Check whether this question is in current block array.
1403 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1405 // This question is not in the current configuration string. Skip it.
1410 // Check this var question is in the var storage
1412 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1414 // This question exceeds the var store size.
1416 return EFI_INVALID_PARAMETER
;
1420 // Check the current value is in the numeric range.
1423 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1425 if ((IfrNumeric
->Flags
& EFI_IFR_DISPLAY
) == 0) {
1426 switch (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1427 case EFI_IFR_NUMERIC_SIZE_1
:
1428 if ((INT8
) VarValue
< (INT8
) IfrNumeric
->data
.u8
.MinValue
|| (INT8
) VarValue
> (INT8
) IfrNumeric
->data
.u8
.MaxValue
) {
1430 // Not in the valid range.
1432 return EFI_INVALID_PARAMETER
;
1435 case EFI_IFR_NUMERIC_SIZE_2
:
1436 if ((INT16
) VarValue
< (INT16
) IfrNumeric
->data
.u16
.MinValue
|| (INT16
) VarValue
> (INT16
) IfrNumeric
->data
.u16
.MaxValue
) {
1438 // Not in the valid range.
1440 return EFI_INVALID_PARAMETER
;
1443 case EFI_IFR_NUMERIC_SIZE_4
:
1444 if ((INT32
) VarValue
< (INT32
) IfrNumeric
->data
.u32
.MinValue
|| (INT32
) VarValue
> (INT32
) IfrNumeric
->data
.u32
.MaxValue
) {
1446 // Not in the valid range.
1448 return EFI_INVALID_PARAMETER
;
1451 case EFI_IFR_NUMERIC_SIZE_8
:
1452 if ((INT64
) VarValue
< (INT64
) IfrNumeric
->data
.u64
.MinValue
|| (INT64
) VarValue
> (INT64
) IfrNumeric
->data
.u64
.MaxValue
) {
1454 // Not in the valid range.
1456 return EFI_INVALID_PARAMETER
;
1461 switch (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1462 case EFI_IFR_NUMERIC_SIZE_1
:
1463 if ((UINT8
) VarValue
< IfrNumeric
->data
.u8
.MinValue
|| (UINT8
) VarValue
> IfrNumeric
->data
.u8
.MaxValue
) {
1465 // Not in the valid range.
1467 return EFI_INVALID_PARAMETER
;
1470 case EFI_IFR_NUMERIC_SIZE_2
:
1471 if ((UINT16
) VarValue
< IfrNumeric
->data
.u16
.MinValue
|| (UINT16
) VarValue
> IfrNumeric
->data
.u16
.MaxValue
) {
1473 // Not in the valid range.
1475 return EFI_INVALID_PARAMETER
;
1478 case EFI_IFR_NUMERIC_SIZE_4
:
1479 if ((UINT32
) VarValue
< IfrNumeric
->data
.u32
.MinValue
|| (UINT32
) VarValue
> IfrNumeric
->data
.u32
.MaxValue
) {
1481 // Not in the valid range.
1483 return EFI_INVALID_PARAMETER
;
1486 case EFI_IFR_NUMERIC_SIZE_8
:
1487 if ((UINT64
) VarValue
< IfrNumeric
->data
.u64
.MinValue
|| (UINT64
) VarValue
> IfrNumeric
->data
.u64
.MaxValue
) {
1489 // Not in the valid range.
1491 return EFI_INVALID_PARAMETER
;
1497 case EFI_IFR_CHECKBOX_OP
:
1499 // Check value is BOOLEAN type, only 0 and 1 is valid.
1503 // CheckBox question is not in IFR Form. This IFR form is not valid.
1505 if (VarStoreData
.VarStoreId
== 0) {
1506 return EFI_INVALID_PARAMETER
;
1510 // Check whether this question is for the requested varstore.
1512 IfrCheckBox
= (EFI_IFR_CHECKBOX
*) IfrOpHdr
;
1513 if (IfrCheckBox
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1517 if (NameValueType
) {
1518 QuestionName
= HiiGetString (HiiHandle
, IfrCheckBox
->Question
.VarStoreInfo
.VarName
, NULL
);
1519 ASSERT (QuestionName
!= NULL
);
1521 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1523 // This question is not in the current configuration string. Skip it.
1528 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1529 if (EFI_ERROR (Status
)) {
1534 // Get Offset by Question header
1536 Offset
= IfrCheckBox
->Question
.VarStoreInfo
.VarOffset
;
1537 Width
= (UINT16
) sizeof (BOOLEAN
);
1539 // Check whether this question is in current block array.
1541 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1543 // This question is not in the current configuration string. Skip it.
1548 // Check this var question is in the var storage
1550 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1552 // This question exceeds the var store size.
1554 return EFI_INVALID_PARAMETER
;
1557 // Check the current value is in the numeric range.
1560 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1563 // Boolean type, only 1 and 0 is valid.
1566 return EFI_INVALID_PARAMETER
;
1569 case EFI_IFR_STRING_OP
:
1571 // Check current string length is less than maxsize
1575 // CheckBox question is not in IFR Form. This IFR form is not valid.
1577 if (VarStoreData
.VarStoreId
== 0) {
1578 return EFI_INVALID_PARAMETER
;
1582 // Check whether this question is for the requested varstore.
1584 IfrString
= (EFI_IFR_STRING
*) IfrOpHdr
;
1585 if (IfrString
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1589 // Get Width by OneOf Flags
1591 Width
= (UINT16
) (IfrString
->MaxSize
* sizeof (UINT16
));
1592 if (NameValueType
) {
1593 QuestionName
= HiiGetString (HiiHandle
, IfrString
->Question
.VarStoreInfo
.VarName
, NULL
);
1594 ASSERT (QuestionName
!= NULL
);
1596 StringPtr
= StrStr (RequestElement
, QuestionName
);
1597 if (StringPtr
== NULL
) {
1599 // This question is not in the current configuration string. Skip it.
1610 // Check current string length is less than maxsize
1612 if (StrSize (StringPtr
) > Width
) {
1613 return EFI_INVALID_PARAMETER
;
1617 // Get Offset/Width by Question header and OneOf Flags
1619 Offset
= IfrString
->Question
.VarStoreInfo
.VarOffset
;
1621 // Check whether this question is in current block array.
1623 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1625 // This question is not in the current configuration string. Skip it.
1630 // Check this var question is in the var storage
1632 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1634 // This question exceeds the var store size.
1636 return EFI_INVALID_PARAMETER
;
1640 // Check current string length is less than maxsize
1642 if (StrSize ((CHAR16
*) (VarBuffer
+ Offset
)) > Width
) {
1643 return EFI_INVALID_PARAMETER
;
1647 case EFI_IFR_ONE_OF_OPTION_OP
:
1649 // Opcode Scope is zero. This one of option is not to be checked.
1651 if (VarBlockData
.Scope
== 0) {
1656 // Only check for OneOf and OrderList opcode
1658 IfrOneOfOption
= (EFI_IFR_ONE_OF_OPTION
*) IfrOpHdr
;
1659 if (VarBlockData
.OpCode
== EFI_IFR_ONE_OF_OP
) {
1661 // Check current value is the value of one of option.
1663 ASSERT (IfrOneOfOption
->Type
<= EFI_IFR_TYPE_NUM_SIZE_64
);
1664 ZeroMem (&TmpValue
, sizeof (EFI_IFR_TYPE_VALUE
));
1665 CopyMem (&TmpValue
, &IfrOneOfOption
->Value
, IfrOneOfOption
->Header
.Length
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
1666 if (VarValue
== TmpValue
.u64
) {
1668 // The value is one of option value.
1669 // Set OpCode to Zero, don't need check again.
1671 VarBlockData
.OpCode
= 0;
1675 case EFI_IFR_END_OP
:
1677 // Decrease opcode scope for the validated opcode
1679 if (VarBlockData
.Scope
> 0) {
1680 VarBlockData
.Scope
--;
1684 // OneOf value doesn't belong to one of option value.
1686 if ((VarBlockData
.Scope
== 0) && (VarBlockData
.OpCode
== EFI_IFR_ONE_OF_OP
)) {
1687 return EFI_INVALID_PARAMETER
;
1692 // Increase Scope for the validated opcode
1694 if (VarBlockData
.Scope
> 0) {
1695 VarBlockData
.Scope
= (UINT8
) (VarBlockData
.Scope
+ IfrOpHdr
->Scope
);
1700 // Go to the next opcode
1702 IfrOffset
+= IfrOpHdr
->Length
;
1705 // Only one form is in a package list.
1711 // Go to next package.
1713 PackageOffset
+= PackageHeader
.Length
;
1720 This internal function parses IFR data to validate current setting.
1722 @param ConfigElement ConfigResp element string contains the current setting.
1723 @param CurrentBlockArray Current block array.
1724 @param VarBuffer Data buffer for this varstore.
1726 @retval EFI_SUCCESS The current setting is valid.
1727 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1728 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1732 IN CHAR16
*ConfigElement
,
1733 OUT IFR_BLOCK_DATA
**CurrentBlockArray
,
1734 OUT UINT8
**VarBuffer
1737 IFR_BLOCK_DATA
*BlockData
;
1738 IFR_BLOCK_DATA
*NewBlockData
;
1739 EFI_STRING StringPtr
;
1745 UINTN MaxBufferSize
;
1747 IFR_BLOCK_DATA
*BlockArray
;
1751 // Initialize the local variables.
1753 Status
= EFI_SUCCESS
;
1755 NewBlockData
= NULL
;
1758 MaxBufferSize
= HII_LIB_DEFAULT_VARSTORE_SIZE
;
1759 DataBuffer
= AllocateZeroPool (MaxBufferSize
);
1760 if (DataBuffer
== NULL
) {
1761 return EFI_OUT_OF_RESOURCES
;
1767 BlockArray
= (IFR_BLOCK_DATA
*) AllocateZeroPool (sizeof (IFR_BLOCK_DATA
));
1768 if (BlockArray
== NULL
) {
1769 Status
= EFI_OUT_OF_RESOURCES
;
1772 InitializeListHead (&BlockArray
->Entry
);
1774 StringPtr
= StrStr (ConfigElement
, L
"&OFFSET=");
1775 ASSERT (StringPtr
!= NULL
);
1778 // Parse each <RequestElement> if exists
1779 // Only <BlockName> format is supported by this help function.
1780 // <BlockName> ::= &'OFFSET='<Number>&'WIDTH='<Number>
1782 while (*StringPtr
!= 0 && StrnCmp (StringPtr
, L
"&OFFSET=", StrLen (L
"&OFFSET=")) == 0) {
1784 // Skip the &OFFSET= string
1786 StringPtr
+= StrLen (L
"&OFFSET=");
1791 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1792 if (EFI_ERROR (Status
)) {
1799 (((Length
+ 1) / 2) < sizeof (UINT16
)) ? ((Length
+ 1) / 2) : sizeof (UINT16
)
1801 FreePool (TmpBuffer
);
1804 StringPtr
+= Length
;
1805 if (StrnCmp (StringPtr
, L
"&WIDTH=", StrLen (L
"&WIDTH=")) != 0) {
1806 Status
= EFI_INVALID_PARAMETER
;
1809 StringPtr
+= StrLen (L
"&WIDTH=");
1814 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1815 if (EFI_ERROR (Status
)) {
1822 (((Length
+ 1) / 2) < sizeof (UINT16
)) ? ((Length
+ 1) / 2) : sizeof (UINT16
)
1824 FreePool (TmpBuffer
);
1827 StringPtr
+= Length
;
1828 if (*StringPtr
!= 0 && *StringPtr
!= L
'&') {
1829 Status
= EFI_INVALID_PARAMETER
;
1833 if (StrnCmp (StringPtr
, L
"&VALUE=", StrLen (L
"&VALUE=")) != 0) {
1834 Status
= EFI_INVALID_PARAMETER
;
1837 StringPtr
+= StrLen (L
"&VALUE=");
1842 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1843 if (EFI_ERROR (Status
)) {
1847 StringPtr
+= Length
;
1848 if (*StringPtr
!= 0 && *StringPtr
!= L
'&') {
1849 Status
= EFI_INVALID_PARAMETER
;
1854 // Check whether VarBuffer is enough
1856 if ((UINTN
) (Offset
+ Width
) > MaxBufferSize
) {
1857 DataBuffer
= ReallocatePool (
1859 Offset
+ Width
+ HII_LIB_DEFAULT_VARSTORE_SIZE
,
1862 if (DataBuffer
== NULL
) {
1863 Status
= EFI_OUT_OF_RESOURCES
;
1866 MaxBufferSize
= Offset
+ Width
+ HII_LIB_DEFAULT_VARSTORE_SIZE
;
1870 // Update the Block with configuration info
1872 CopyMem (DataBuffer
+ Offset
, TmpBuffer
, Width
);
1873 FreePool (TmpBuffer
);
1877 // Set new Block Data
1879 NewBlockData
= (IFR_BLOCK_DATA
*) AllocateZeroPool (sizeof (IFR_BLOCK_DATA
));
1880 if (NewBlockData
== NULL
) {
1881 Status
= EFI_OUT_OF_RESOURCES
;
1884 NewBlockData
->Offset
= Offset
;
1885 NewBlockData
->Width
= Width
;
1888 // Insert the new block data into the block data array.
1890 for (Link
= BlockArray
->Entry
.ForwardLink
; Link
!= &BlockArray
->Entry
; Link
= Link
->ForwardLink
) {
1891 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
1892 if (NewBlockData
->Offset
== BlockData
->Offset
) {
1893 if (NewBlockData
->Width
> BlockData
->Width
) {
1894 BlockData
->Width
= NewBlockData
->Width
;
1896 FreePool (NewBlockData
);
1898 } else if (NewBlockData
->Offset
< BlockData
->Offset
) {
1900 // Insert new block data as the previous one of this link.
1902 InsertTailList (Link
, &NewBlockData
->Entry
);
1908 // Insert new block data into the array tail.
1910 if (Link
== &BlockArray
->Entry
) {
1911 InsertTailList (Link
, &NewBlockData
->Entry
);
1915 // If '\0', parsing is finished.
1917 if (*StringPtr
== 0) {
1921 // Go to next ConfigBlock
1926 // Merge the aligned block data into the single block data.
1928 Link
= BlockArray
->Entry
.ForwardLink
;
1929 while ((Link
!= &BlockArray
->Entry
) && (Link
->ForwardLink
!= &BlockArray
->Entry
)) {
1930 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
1931 NewBlockData
= BASE_CR (Link
->ForwardLink
, IFR_BLOCK_DATA
, Entry
);
1932 if ((NewBlockData
->Offset
>= BlockData
->Offset
) && (NewBlockData
->Offset
<= (BlockData
->Offset
+ BlockData
->Width
))) {
1933 if ((NewBlockData
->Offset
+ NewBlockData
->Width
) > (BlockData
->Offset
+ BlockData
->Width
)) {
1934 BlockData
->Width
= (UINT16
) (NewBlockData
->Offset
+ NewBlockData
->Width
- BlockData
->Offset
);
1936 RemoveEntryList (Link
->ForwardLink
);
1937 FreePool (NewBlockData
);
1940 Link
= Link
->ForwardLink
;
1943 *VarBuffer
= DataBuffer
;
1944 *CurrentBlockArray
= BlockArray
;
1948 if (DataBuffer
!= NULL
) {
1949 FreePool (DataBuffer
);
1952 if (BlockArray
!= NULL
) {
1954 // Free Link Array CurrentBlockArray
1956 while (!IsListEmpty (&BlockArray
->Entry
)) {
1957 BlockData
= BASE_CR (BlockArray
->Entry
.ForwardLink
, IFR_BLOCK_DATA
, Entry
);
1958 RemoveEntryList (&BlockData
->Entry
);
1959 FreePool (BlockData
);
1961 FreePool (BlockArray
);
1968 This internal function parses IFR data to validate current setting.
1970 @param ConfigResp ConfigResp string contains the current setting.
1971 @param HiiPackageList Point to Hii package list.
1972 @param PackageListLength The length of the pacakge.
1973 @param VarGuid Guid of the buffer storage.
1974 @param VarName Name of the buffer storage.
1975 @param HiiHandle The HiiHandle for this package.
1977 @retval EFI_SUCCESS The current setting is valid.
1978 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1979 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1983 InternalHiiValidateCurrentSetting (
1984 IN EFI_STRING ConfigResp
,
1985 IN EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
,
1986 IN UINTN PackageListLength
,
1987 IN EFI_GUID
*VarGuid
,
1989 IN EFI_HII_HANDLE HiiHandle
1994 IFR_BLOCK_DATA
*CurrentBlockArray
;
1995 IFR_BLOCK_DATA
*BlockData
;
1997 BOOLEAN NameValueType
;
1999 CurrentBlockArray
= NULL
;
2002 Status
= EFI_SUCCESS
;
2005 // If StringPtr != NULL, get the request elements.
2007 if (StrStr (ConfigResp
, L
"&OFFSET=") != NULL
) {
2008 Status
= GetBlockDataInfo(ConfigResp
, &CurrentBlockArray
, &VarBuffer
);
2009 if (EFI_ERROR (Status
)) {
2012 NameValueType
= FALSE
;
2015 // Skip header part.
2017 StringPtr
= StrStr (ConfigResp
, L
"PATH=");
2018 ASSERT (StringPtr
!= NULL
);
2020 if (StrStr (StringPtr
, L
"&") != NULL
) {
2021 NameValueType
= TRUE
;
2024 // Not found Request element, return success.
2030 Status
= ValidateQuestionFromVfr(
2042 if (VarBuffer
!= NULL
) {
2043 FreePool (VarBuffer
);
2046 if (CurrentBlockArray
!= NULL
) {
2048 // Free Link Array CurrentBlockArray
2050 while (!IsListEmpty (&CurrentBlockArray
->Entry
)) {
2051 BlockData
= BASE_CR (CurrentBlockArray
->Entry
.ForwardLink
, IFR_BLOCK_DATA
, Entry
);
2052 RemoveEntryList (&BlockData
->Entry
);
2053 FreePool (BlockData
);
2055 FreePool (CurrentBlockArray
);
2062 Check whether the ConfigRequest string has the request elements.
2063 For EFI_HII_VARSTORE_BUFFER type, the request has "&OFFSET=****&WIDTH=****..." format.
2064 For EFI_HII_VARSTORE_NAME_VALUE type, the request has "&NAME1**&NAME2..." format.
2066 @param ConfigRequest The input config request string.
2068 @retval TRUE The input include config request elements.
2069 @retval FALSE The input string not includes.
2073 GetElementsFromRequest (
2074 IN EFI_STRING ConfigRequest
2077 EFI_STRING TmpRequest
;
2079 TmpRequest
= StrStr (ConfigRequest
, L
"PATH=");
2080 ASSERT (TmpRequest
!= NULL
);
2082 if ((StrStr (TmpRequest
, L
"&OFFSET=") != NULL
) || (StrStr (TmpRequest
, L
"&") != NULL
)) {
2090 This function parses the input ConfigRequest string and its matched IFR code
2091 string for setting default value and validating current setting.
2093 1. For setting default action, Reset the default value specified by DefaultId
2094 to the driver configuration got by Request string.
2095 2. For validating current setting, Validate the current configuration
2096 by parsing HII form IFR opcode.
2098 NULL request string support depends on the ExportConfig interface of
2099 HiiConfigRouting protocol in UEFI specification.
2101 @param Request A null-terminated Unicode string in
2102 <MultiConfigRequest> format. It can be NULL.
2103 If it is NULL, all current configuration for the
2104 entirety of the current HII database will be validated.
2105 If it is NULL, all configuration for the
2106 entirety of the current HII database will be reset.
2107 @param DefaultId Specifies the type of defaults to retrieve only for setting default action.
2108 @param ActionType Action supports setting defaults and validate current setting.
2110 @retval TRUE Action runs successfully.
2111 @retval FALSE Action is not valid or Action can't be executed successfully..
2115 InternalHiiIfrValueAction (
2116 IN CONST EFI_STRING Request
, OPTIONAL
2117 IN UINT16 DefaultId
,
2121 EFI_STRING ConfigAltResp
;
2122 EFI_STRING ConfigAltHdr
;
2123 EFI_STRING ConfigResp
;
2124 EFI_STRING Progress
;
2125 EFI_STRING StringPtr
;
2126 EFI_STRING StringHdr
;
2128 EFI_HANDLE DriverHandle
;
2129 EFI_HANDLE TempDriverHandle
;
2130 EFI_HII_HANDLE
*HiiHandleBuffer
;
2131 EFI_HII_HANDLE HiiHandle
;
2136 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
2137 UINTN PackageListLength
;
2139 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2140 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
2142 ConfigAltResp
= NULL
;
2147 ConfigAltHdr
= NULL
;
2148 HiiHandleBuffer
= NULL
;
2150 TempDriverHandle
= NULL
;
2152 HiiPackageList
= NULL
;
2155 // Only support set default and validate setting action.
2157 if ((ActionType
!= ACTION_SET_DEFAUTL_VALUE
) && (ActionType
!= ACTION_VALIDATE_SETTING
)) {
2162 // Get the full requested value and deault value string.
2164 if (Request
!= NULL
) {
2165 Status
= gHiiConfigRouting
->ExtractConfig (
2172 Status
= gHiiConfigRouting
->ExportConfig (
2178 if (EFI_ERROR (Status
)) {
2182 StringPtr
= ConfigAltResp
;
2184 while (StringPtr
!= L
'\0') {
2186 // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
2188 StringHdr
= StringPtr
;
2193 if (StrnCmp (StringPtr
, L
"GUID=", StrLen (L
"GUID=")) != 0) {
2194 Status
= EFI_INVALID_PARAMETER
;
2197 StringPtr
+= StrLen (L
"GUID=");
2198 Status
= InternalHiiGetBufferFromString (StringPtr
, GUID_CONFIG_STRING_TYPE
, (UINT8
**) &VarGuid
);
2199 if (EFI_ERROR (Status
)) {
2204 // Get Name value VarName
2206 while (*StringPtr
!= L
'\0' && StrnCmp (StringPtr
, L
"&NAME=", StrLen (L
"&NAME=")) != 0) {
2209 if (*StringPtr
== L
'\0') {
2210 Status
= EFI_INVALID_PARAMETER
;
2213 StringPtr
+= StrLen (L
"&NAME=");
2214 Status
= InternalHiiGetBufferFromString (StringPtr
, NAME_CONFIG_STRING_TYPE
, (UINT8
**) &VarName
);
2215 if (EFI_ERROR (Status
)) {
2220 // Get Path value DevicePath
2222 while (*StringPtr
!= L
'\0' && StrnCmp (StringPtr
, L
"&PATH=", StrLen (L
"&PATH=")) != 0) {
2225 if (*StringPtr
== L
'\0') {
2226 Status
= EFI_INVALID_PARAMETER
;
2229 StringPtr
+= StrLen (L
"&PATH=");
2230 Status
= InternalHiiGetBufferFromString (StringPtr
, PATH_CONFIG_STRING_TYPE
, (UINT8
**) &DevicePath
);
2231 if (EFI_ERROR (Status
)) {
2236 // Get the Driver handle by the got device path.
2238 TempDevicePath
= DevicePath
;
2239 Status
= gBS
->LocateDevicePath (&gEfiDevicePathProtocolGuid
, &TempDevicePath
, &DriverHandle
);
2240 if (EFI_ERROR (Status
)) {
2245 // Find the matched Hii Handle for the found Driver handle
2247 HiiHandleBuffer
= HiiGetHiiHandles (NULL
);
2248 if (HiiHandleBuffer
== NULL
) {
2249 Status
= EFI_NOT_FOUND
;
2253 for (Index
= 0; HiiHandleBuffer
[Index
] != NULL
; Index
++) {
2254 gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, HiiHandleBuffer
[Index
], &TempDriverHandle
);
2255 if (TempDriverHandle
== DriverHandle
) {
2260 HiiHandle
= HiiHandleBuffer
[Index
];
2261 FreePool (HiiHandleBuffer
);
2263 if (HiiHandle
== NULL
) {
2265 // This request string has no its Hii package.
2266 // Its default value and validating can't execute by parsing IFR data.
2267 // Directly jump into the next ConfigAltResp string for another pair Guid, Name, and Path.
2269 Status
= EFI_SUCCESS
;
2270 goto NextConfigAltResp
;
2274 // 2. Get HiiPackage by HiiHandle
2276 PackageListLength
= 0;
2277 HiiPackageList
= NULL
;
2278 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &PackageListLength
, HiiPackageList
);
2281 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
2283 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
2284 Status
= EFI_INVALID_PARAMETER
;
2288 HiiPackageList
= AllocatePool (PackageListLength
);
2289 if (HiiPackageList
== NULL
) {
2290 Status
= EFI_OUT_OF_RESOURCES
;
2295 // Get PackageList on HiiHandle
2297 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &PackageListLength
, HiiPackageList
);
2298 if (EFI_ERROR (Status
)) {
2303 // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
2304 // Get the default configuration string according to the default ID.
2306 Status
= gHiiConfigRouting
->GetAltConfig (
2312 (ActionType
== ACTION_SET_DEFAUTL_VALUE
) ? &DefaultId
:NULL
, // it can be NULL to get the current setting.
2317 // The required setting can't be found. So, it is not required to be validated and set.
2319 if (EFI_ERROR (Status
)) {
2320 Status
= EFI_SUCCESS
;
2321 goto NextConfigAltResp
;
2324 // Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set.
2326 if (!GetElementsFromRequest (ConfigResp
)) {
2327 goto NextConfigAltResp
;
2331 // 4. Set the default configuration information or Validate current setting by parse IFR code.
2332 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2334 if (ActionType
== ACTION_SET_DEFAUTL_VALUE
) {
2336 // Set the default configuration information.
2338 Status
= gHiiConfigRouting
->RouteConfig (gHiiConfigRouting
, ConfigResp
, &Progress
);
2341 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2343 Status
= InternalHiiValidateCurrentSetting (ConfigResp
, HiiPackageList
, PackageListLength
, VarGuid
, VarName
, HiiHandle
);
2346 if (EFI_ERROR (Status
)) {
2352 // Free the allocated pacakge buffer and the got ConfigResp string.
2354 if (HiiPackageList
!= NULL
) {
2355 FreePool (HiiPackageList
);
2356 HiiPackageList
= NULL
;
2359 if (ConfigResp
!= NULL
) {
2360 FreePool (ConfigResp
);
2365 // Free the allocated buffer.
2373 FreePool (DevicePath
);
2377 // 5. Jump to next ConfigAltResp for another Guid, Name, Path.
2381 // Get and Skip ConfigHdr
2383 while (*StringPtr
!= L
'\0' && *StringPtr
!= L
'&') {
2386 if (*StringPtr
== L
'\0') {
2391 // Construct ConfigAltHdr string "&<ConfigHdr>&ALTCFG=\0"
2392 // | 1 | StrLen (ConfigHdr) | 8 | 1 |
2394 MaxLen
= 1 + StringPtr
- StringHdr
+ 8 + 1;
2395 ConfigAltHdr
= AllocateZeroPool ( MaxLen
* sizeof (CHAR16
));
2396 if (ConfigAltHdr
== NULL
) {
2397 Status
= EFI_OUT_OF_RESOURCES
;
2400 StrCpyS (ConfigAltHdr
, MaxLen
, L
"&");
2401 StrnCatS (ConfigAltHdr
, MaxLen
, StringHdr
, StringPtr
- StringHdr
);
2402 StrCatS (ConfigAltHdr
, MaxLen
, L
"&ALTCFG=");
2405 // Skip all AltResp (AltConfigHdr ConfigBody) for the same ConfigHdr
2407 while ((StringHdr
= StrStr (StringPtr
, ConfigAltHdr
)) != NULL
) {
2408 StringPtr
= StringHdr
+ StrLen (ConfigAltHdr
);
2409 if (*StringPtr
== L
'\0') {
2415 // Free the allocated ConfigAltHdr string
2417 FreePool (ConfigAltHdr
);
2418 if (*StringPtr
== L
'\0') {
2423 // Find &GUID as the next ConfigHdr
2425 StringPtr
= StrStr (StringPtr
, L
"&GUID");
2426 if (StringPtr
== NULL
) {
2437 if (VarGuid
!= NULL
) {
2441 if (VarName
!= NULL
) {
2445 if (DevicePath
!= NULL
) {
2446 FreePool (DevicePath
);
2449 if (ConfigResp
!= NULL
) {
2450 FreePool (ConfigResp
);
2453 if (ConfigAltResp
!= NULL
) {
2454 FreePool (ConfigAltResp
);
2457 if (HiiPackageList
!= NULL
) {
2458 FreePool (HiiPackageList
);
2461 if (EFI_ERROR (Status
)) {
2469 Validate the current configuration by parsing HII form IFR opcode.
2471 NULL request string support depends on the ExportConfig interface of
2472 HiiConfigRouting protocol in UEFI specification.
2474 @param Request A null-terminated Unicode string in
2475 <MultiConfigRequest> format. It can be NULL.
2476 If it is NULL, all current configuration for the
2477 entirety of the current HII database will be validated.
2479 @retval TRUE Current configuration is valid.
2480 @retval FALSE Current configuration is invalid.
2484 HiiValidateSettings (
2485 IN CONST EFI_STRING Request OPTIONAL
2488 return InternalHiiIfrValueAction (Request
, 0, ACTION_VALIDATE_SETTING
);
2492 Reset the default value specified by DefaultId to the driver
2493 configuration got by Request string.
2495 NULL request string support depends on the ExportConfig interface of
2496 HiiConfigRouting protocol in UEFI specification.
2498 @param Request A null-terminated Unicode string in
2499 <MultiConfigRequest> format. It can be NULL.
2500 If it is NULL, all configuration for the
2501 entirety of the current HII database will be reset.
2502 @param DefaultId Specifies the type of defaults to retrieve.
2504 @retval TRUE The default value is set successfully.
2505 @retval FALSE The default value can't be found and set.
2510 IN CONST EFI_STRING Request
, OPTIONAL
2514 return InternalHiiIfrValueAction (Request
, DefaultId
, ACTION_SET_DEFAUTL_VALUE
);
2518 Determines if two values in config strings match.
2520 Compares the substring between StartSearchString and StopSearchString in
2521 FirstString to the substring between StartSearchString and StopSearchString
2522 in SecondString. If the two substrings match, then TRUE is returned. If the
2523 two substrings do not match, then FALSE is returned.
2525 If FirstString is NULL, then ASSERT().
2526 If SecondString is NULL, then ASSERT().
2527 If StartSearchString is NULL, then ASSERT().
2528 If StopSearchString is NULL, then ASSERT().
2530 @param FirstString Pointer to the first Null-terminated Unicode string.
2531 @param SecondString Pointer to the second Null-terminated Unicode string.
2532 @param StartSearchString Pointer to the Null-terminated Unicode string that
2533 marks the start of the value string to compare.
2534 @param StopSearchString Pointer to the Null-terminated Unicode string that
2535 marks the end of the value string to compare.
2537 @retval FALSE StartSearchString is not present in FirstString.
2538 @retval FALSE StartSearchString is not present in SecondString.
2539 @retval FALSE StopSearchString is not present in FirstString.
2540 @retval FALSE StopSearchString is not present in SecondString.
2541 @retval FALSE The length of the substring in FirstString is not the
2542 same length as the substring in SecondString.
2543 @retval FALSE The value string in FirstString does not matche the
2544 value string in SecondString.
2545 @retval TRUE The value string in FirstString matches the value
2546 string in SecondString.
2551 InternalHiiCompareSubString (
2552 IN CHAR16
*FirstString
,
2553 IN CHAR16
*SecondString
,
2554 IN CHAR16
*StartSearchString
,
2555 IN CHAR16
*StopSearchString
2558 CHAR16
*EndFirstString
;
2559 CHAR16
*EndSecondString
;
2561 ASSERT (FirstString
!= NULL
);
2562 ASSERT (SecondString
!= NULL
);
2563 ASSERT (StartSearchString
!= NULL
);
2564 ASSERT (StopSearchString
!= NULL
);
2566 FirstString
= StrStr (FirstString
, StartSearchString
);
2567 if (FirstString
== NULL
) {
2571 SecondString
= StrStr (SecondString
, StartSearchString
);
2572 if (SecondString
== NULL
) {
2576 EndFirstString
= StrStr (FirstString
, StopSearchString
);
2577 if (EndFirstString
== NULL
) {
2581 EndSecondString
= StrStr (SecondString
, StopSearchString
);
2582 if (EndSecondString
== NULL
) {
2586 if ((EndFirstString
- FirstString
) != (EndSecondString
- SecondString
)) {
2590 return (BOOLEAN
)(StrnCmp (FirstString
, SecondString
, EndFirstString
- FirstString
) == 0);
2594 Determines if the routing data specified by GUID and NAME match a <ConfigHdr>.
2596 If ConfigHdr is NULL, then ASSERT().
2598 @param[in] ConfigHdr Either <ConfigRequest> or <ConfigResp>.
2599 @param[in] Guid GUID of the storage.
2600 @param[in] Name NAME of the storage.
2602 @retval TRUE Routing information matches <ConfigHdr>.
2603 @retval FALSE Routing information does not match <ConfigHdr>.
2608 HiiIsConfigHdrMatch (
2609 IN CONST EFI_STRING ConfigHdr
,
2610 IN CONST EFI_GUID
*Guid
, OPTIONAL
2611 IN CONST CHAR16
*Name OPTIONAL
2614 EFI_STRING CompareConfigHdr
;
2617 ASSERT (ConfigHdr
!= NULL
);
2620 // Use Guid and Name to generate a <ConfigHdr> string
2622 CompareConfigHdr
= HiiConstructConfigHdr (Guid
, Name
, NULL
);
2623 if (CompareConfigHdr
== NULL
) {
2630 // Compare GUID value strings
2632 Result
= InternalHiiCompareSubString (ConfigHdr
, CompareConfigHdr
, L
"GUID=", L
"&NAME=");
2635 if (Result
&& Name
!= NULL
) {
2637 // Compare NAME value strings
2639 Result
= InternalHiiCompareSubString (ConfigHdr
, CompareConfigHdr
, L
"&NAME=", L
"&PATH=");
2643 // Free the <ConfigHdr> string
2645 FreePool (CompareConfigHdr
);
2651 Retrieves uncommitted data from the Form Browser and converts it to a binary
2654 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
2655 parameter that may be NULL.
2656 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
2657 is an optional parameter that may be NULL.
2658 @param[in] BufferSize Length in bytes of buffer to hold retrieved data.
2659 @param[out] Buffer Buffer of data to be updated.
2661 @retval FALSE The uncommitted data could not be retrieved.
2662 @retval TRUE The uncommitted data was retrieved.
2668 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
2669 IN CONST CHAR16
*VariableName
, OPTIONAL
2670 IN UINTN BufferSize
,
2674 EFI_STRING ResultsData
;
2676 EFI_STRING ConfigResp
;
2681 // Retrieve the results data from the Browser Callback
2683 ResultsData
= InternalHiiBrowserCallback (VariableGuid
, VariableName
, NULL
);
2684 if (ResultsData
== NULL
) {
2689 // Construct <ConfigResp> mConfigHdrTemplate L'&' ResultsData L'\0'
2691 Size
= (StrLen (mConfigHdrTemplate
) + 1) * sizeof (CHAR16
);
2692 Size
= Size
+ (StrLen (ResultsData
) + 1) * sizeof (CHAR16
);
2693 ConfigResp
= AllocateZeroPool (Size
);
2694 UnicodeSPrint (ConfigResp
, Size
, L
"%s&%s", mConfigHdrTemplate
, ResultsData
);
2697 // Free the allocated buffer
2699 FreePool (ResultsData
);
2700 if (ConfigResp
== NULL
) {
2705 // Convert <ConfigResp> to a buffer
2707 Status
= gHiiConfigRouting
->ConfigToBlock (
2715 // Free the allocated buffer
2717 FreePool (ConfigResp
);
2719 if (EFI_ERROR (Status
)) {
2727 Updates uncommitted data in the Form Browser.
2729 If Buffer is NULL, then ASSERT().
2731 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
2732 parameter that may be NULL.
2733 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
2734 is an optional parameter that may be NULL.
2735 @param[in] BufferSize Length, in bytes, of Buffer.
2736 @param[in] Buffer Buffer of data to commit.
2737 @param[in] RequestElement An optional field to specify which part of the
2738 buffer data will be send back to Browser. If NULL,
2739 the whole buffer of data will be committed to
2741 <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*
2743 @retval FALSE The uncommitted data could not be updated.
2744 @retval TRUE The uncommitted data was updated.
2750 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
2751 IN CONST CHAR16
*VariableName
, OPTIONAL
2752 IN UINTN BufferSize
,
2753 IN CONST UINT8
*Buffer
,
2754 IN CONST CHAR16
*RequestElement OPTIONAL
2758 EFI_STRING ConfigRequest
;
2759 EFI_STRING ConfigResp
;
2760 EFI_STRING ResultsData
;
2762 ASSERT (Buffer
!= NULL
);
2765 // Construct <ConfigRequest>
2767 if (RequestElement
== NULL
) {
2769 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2770 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
2772 Size
= (StrLen (mConfigHdrTemplate
) + 32 + 1) * sizeof (CHAR16
);
2773 ConfigRequest
= AllocateZeroPool (Size
);
2774 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", mConfigHdrTemplate
, (UINT64
)BufferSize
);
2777 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2778 // followed by <RequestElement> followed by a Null-terminator
2780 Size
= StrLen (mConfigHdrTemplate
) * sizeof (CHAR16
);
2781 Size
= Size
+ (StrLen (RequestElement
) + 1) * sizeof (CHAR16
);
2782 ConfigRequest
= AllocateZeroPool (Size
);
2783 UnicodeSPrint (ConfigRequest
, Size
, L
"%s%s", mConfigHdrTemplate
, RequestElement
);
2785 if (ConfigRequest
== NULL
) {
2790 // Convert <ConfigRequest> to <ConfigResp>
2792 ConfigResp
= InternalHiiBlockToConfig (ConfigRequest
, Buffer
, BufferSize
);
2793 FreePool (ConfigRequest
);
2794 if (ConfigResp
== NULL
) {
2799 // Set data in the uncommitted browser state information
2801 ResultsData
= InternalHiiBrowserCallback (VariableGuid
, VariableName
, ConfigResp
+ StrLen(mConfigHdrTemplate
) + 1);
2802 FreePool (ConfigResp
);
2804 return (BOOLEAN
)(ResultsData
!= NULL
);
2807 /////////////////////////////////////////
2808 /////////////////////////////////////////
2810 /////////////////////////////////////////
2811 /////////////////////////////////////////
2813 #define HII_LIB_OPCODE_ALLOCATION_SIZE 0x200
2819 } HII_LIB_OPCODE_BUFFER
;
2822 /// Lookup table that converts EFI_IFR_TYPE_X enum values to a width in bytes
2824 GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiDefaultTypeToWidth
[] = {
2825 1, // EFI_IFR_TYPE_NUM_SIZE_8
2826 2, // EFI_IFR_TYPE_NUM_SIZE_16
2827 4, // EFI_IFR_TYPE_NUM_SIZE_32
2828 8, // EFI_IFR_TYPE_NUM_SIZE_64
2829 1, // EFI_IFR_TYPE_BOOLEAN
2830 3, // EFI_IFR_TYPE_TIME
2831 4, // EFI_IFR_TYPE_DATE
2832 2 // EFI_IFR_TYPE_STRING
2836 Allocates and returns a new OpCode Handle. OpCode Handles must be freed with
2837 HiiFreeOpCodeHandle().
2839 @retval NULL There are not enough resources to allocate a new OpCode Handle.
2840 @retval Other A new OpCode handle.
2845 HiiAllocateOpCodeHandle (
2849 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2851 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)AllocatePool (sizeof (HII_LIB_OPCODE_BUFFER
));
2852 if (OpCodeBuffer
== NULL
) {
2855 OpCodeBuffer
->Buffer
= (UINT8
*)AllocatePool (HII_LIB_OPCODE_ALLOCATION_SIZE
);
2856 if (OpCodeBuffer
->Buffer
== NULL
) {
2857 FreePool (OpCodeBuffer
);
2860 OpCodeBuffer
->BufferSize
= HII_LIB_OPCODE_ALLOCATION_SIZE
;
2861 OpCodeBuffer
->Position
= 0;
2862 return (VOID
*)OpCodeBuffer
;
2866 Frees an OpCode Handle that was previously allocated with HiiAllocateOpCodeHandle().
2867 When an OpCode Handle is freed, all of the opcodes associated with the OpCode
2868 Handle are also freed.
2870 If OpCodeHandle is NULL, then ASSERT().
2872 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2877 HiiFreeOpCodeHandle (
2881 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2883 ASSERT (OpCodeHandle
!= NULL
);
2885 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
;
2886 if (OpCodeBuffer
->Buffer
!= NULL
) {
2887 FreePool (OpCodeBuffer
->Buffer
);
2889 FreePool (OpCodeBuffer
);
2893 Internal function gets the current position of opcode buffer.
2895 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2897 @return Current position of opcode buffer.
2901 InternalHiiOpCodeHandlePosition (
2902 IN VOID
*OpCodeHandle
2905 return ((HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
)->Position
;
2909 Internal function gets the start pointer of opcode buffer.
2911 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2913 @return Pointer to the opcode buffer base.
2917 InternalHiiOpCodeHandleBuffer (
2918 IN VOID
*OpCodeHandle
2921 return ((HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
)->Buffer
;
2925 Internal function reserves the enough buffer for current opcode.
2926 When the buffer is not enough, Opcode buffer will be extended.
2928 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2929 @param[in] Size Size of current opcode.
2931 @return Pointer to the current opcode.
2935 InternalHiiGrowOpCodeHandle (
2936 IN VOID
*OpCodeHandle
,
2940 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2943 ASSERT (OpCodeHandle
!= NULL
);
2945 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
;
2946 if (OpCodeBuffer
->Position
+ Size
> OpCodeBuffer
->BufferSize
) {
2947 Buffer
= ReallocatePool (
2948 OpCodeBuffer
->BufferSize
,
2949 OpCodeBuffer
->BufferSize
+ (Size
+ HII_LIB_OPCODE_ALLOCATION_SIZE
),
2950 OpCodeBuffer
->Buffer
2952 ASSERT (Buffer
!= NULL
);
2953 OpCodeBuffer
->Buffer
= Buffer
;
2954 OpCodeBuffer
->BufferSize
+= (Size
+ HII_LIB_OPCODE_ALLOCATION_SIZE
);
2956 Buffer
= OpCodeBuffer
->Buffer
+ OpCodeBuffer
->Position
;
2957 OpCodeBuffer
->Position
+= Size
;
2962 Internal function creates opcode based on the template opcode.
2964 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2965 @param[in] OpCodeTemplate Pointer to the template buffer of opcode.
2966 @param[in] OpCode OpCode IFR value.
2967 @param[in] OpCodeSize Size of opcode.
2968 @param[in] ExtensionSize Size of extended opcode.
2969 @param[in] Scope Scope bit of opcode.
2971 @return Pointer to the current opcode with opcode data.
2975 InternalHiiCreateOpCodeExtended (
2976 IN VOID
*OpCodeHandle
,
2977 IN VOID
*OpCodeTemplate
,
2979 IN UINTN OpCodeSize
,
2980 IN UINTN ExtensionSize
,
2984 EFI_IFR_OP_HEADER
*Header
;
2987 ASSERT (OpCodeTemplate
!= NULL
);
2988 ASSERT ((OpCodeSize
+ ExtensionSize
) <= 0x7F);
2990 Header
= (EFI_IFR_OP_HEADER
*)OpCodeTemplate
;
2991 Header
->OpCode
= OpCode
;
2992 Header
->Scope
= Scope
;
2993 Header
->Length
= (UINT8
)(OpCodeSize
+ ExtensionSize
);
2994 Buffer
= InternalHiiGrowOpCodeHandle (OpCodeHandle
, Header
->Length
);
2995 return (UINT8
*)CopyMem (Buffer
, Header
, OpCodeSize
);
2999 Internal function creates opcode based on the template opcode for the normal opcode.
3001 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3002 @param[in] OpCodeTemplate Pointer to the template buffer of opcode.
3003 @param[in] OpCode OpCode IFR value.
3004 @param[in] OpCodeSize Size of opcode.
3006 @return Pointer to the current opcode with opcode data.
3010 InternalHiiCreateOpCode (
3011 IN VOID
*OpCodeHandle
,
3012 IN VOID
*OpCodeTemplate
,
3017 return InternalHiiCreateOpCodeExtended (OpCodeHandle
, OpCodeTemplate
, OpCode
, OpCodeSize
, 0, 0);
3021 Append raw opcodes to an OpCodeHandle.
3023 If OpCodeHandle is NULL, then ASSERT().
3024 If RawBuffer is NULL, then ASSERT();
3026 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3027 @param[in] RawBuffer Buffer of opcodes to append.
3028 @param[in] RawBufferSize The size, in bytes, of Buffer.
3030 @retval NULL There is not enough space left in Buffer to add the opcode.
3031 @retval Other A pointer to the appended opcodes.
3036 HiiCreateRawOpCodes (
3037 IN VOID
*OpCodeHandle
,
3038 IN UINT8
*RawBuffer
,
3039 IN UINTN RawBufferSize
3044 ASSERT (RawBuffer
!= NULL
);
3046 Buffer
= InternalHiiGrowOpCodeHandle (OpCodeHandle
, RawBufferSize
);
3047 return (UINT8
*)CopyMem (Buffer
, RawBuffer
, RawBufferSize
);
3051 Append opcodes from one OpCode Handle to another OpCode handle.
3053 If OpCodeHandle is NULL, then ASSERT().
3054 If RawOpCodeHandle is NULL, then ASSERT();
3056 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3057 @param[in] RawOpCodeHandle Handle to the buffer of opcodes.
3059 @retval NULL There is not enough space left in Buffer to add the opcode.
3060 @retval Other A pointer to the appended opcodes.
3065 InternalHiiAppendOpCodes (
3066 IN VOID
*OpCodeHandle
,
3067 IN VOID
*RawOpCodeHandle
3070 HII_LIB_OPCODE_BUFFER
*RawOpCodeBuffer
;
3072 ASSERT (RawOpCodeHandle
!= NULL
);
3074 RawOpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)RawOpCodeHandle
;
3075 return HiiCreateRawOpCodes (OpCodeHandle
, RawOpCodeBuffer
->Buffer
, RawOpCodeBuffer
->Position
);
3079 Create EFI_IFR_END_OP opcode.
3081 If OpCodeHandle is NULL, then ASSERT().
3083 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3085 @retval NULL There is not enough space left in Buffer to add the opcode.
3086 @retval Other A pointer to the created opcode.
3091 HiiCreateEndOpCode (
3092 IN VOID
*OpCodeHandle
3097 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_END_OP
, sizeof (OpCode
));
3101 Create EFI_IFR_ONE_OF_OPTION_OP opcode.
3103 If OpCodeHandle is NULL, then ASSERT().
3104 If Type is invalid, then ASSERT().
3105 If Flags is invalid, then ASSERT().
3107 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3108 @param[in] StringId StringId for the option
3109 @param[in] Flags Flags for the option
3110 @param[in] Type Type for the option
3111 @param[in] Value Value for the option
3113 @retval NULL There is not enough space left in Buffer to add the opcode.
3114 @retval Other A pointer to the created opcode.
3119 HiiCreateOneOfOptionOpCode (
3120 IN VOID
*OpCodeHandle
,
3127 EFI_IFR_ONE_OF_OPTION OpCode
;
3129 ASSERT (Type
< EFI_IFR_TYPE_OTHER
);
3131 ZeroMem (&OpCode
, sizeof (OpCode
));
3132 OpCode
.Option
= StringId
;
3133 OpCode
.Flags
= (UINT8
) (Flags
& (EFI_IFR_OPTION_DEFAULT
| EFI_IFR_OPTION_DEFAULT_MFG
));
3135 CopyMem (&OpCode
.Value
, &Value
, mHiiDefaultTypeToWidth
[Type
]);
3137 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_ONE_OF_OPTION_OP
, OFFSET_OF(EFI_IFR_ONE_OF_OPTION
, Value
) + mHiiDefaultTypeToWidth
[Type
]);
3141 Create EFI_IFR_DEFAULT_OP opcode.
3143 If OpCodeHandle is NULL, then ASSERT().
3144 If Type is invalid, then ASSERT().
3146 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3147 @param[in] DefaultId DefaultId for the default
3148 @param[in] Type Type for the default
3149 @param[in] Value Value for the default
3151 @retval NULL There is not enough space left in Buffer to add the opcode.
3152 @retval Other A pointer to the created opcode.
3157 HiiCreateDefaultOpCode (
3158 IN VOID
*OpCodeHandle
,
3159 IN UINT16 DefaultId
,
3164 EFI_IFR_DEFAULT OpCode
;
3166 ASSERT (Type
< EFI_IFR_TYPE_OTHER
);
3168 ZeroMem (&OpCode
, sizeof (OpCode
));
3170 OpCode
.DefaultId
= DefaultId
;
3171 CopyMem (&OpCode
.Value
, &Value
, mHiiDefaultTypeToWidth
[Type
]);
3173 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_DEFAULT_OP
, OFFSET_OF(EFI_IFR_DEFAULT
, Value
) + mHiiDefaultTypeToWidth
[Type
]);
3177 Create EFI_IFR_GUID opcode.
3179 If OpCodeHandle is NULL, then ASSERT().
3180 If Guid is NULL, then ASSERT().
3181 If OpCodeSize < sizeof (EFI_IFR_GUID), then ASSERT().
3183 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3184 @param[in] Guid Pointer to EFI_GUID of this guided opcode.
3185 @param[in] GuidOpCode Pointer to an EFI_IFR_GUID opcode. This is an
3186 optional parameter that may be NULL. If this
3187 parameter is NULL, then the GUID extension
3188 region of the created opcode is filled with zeros.
3189 If this parameter is not NULL, then the GUID
3190 extension region of GuidData will be copied to
3191 the GUID extension region of the created opcode.
3192 @param[in] OpCodeSize The size, in bytes, of created opcode. This value
3193 must be >= sizeof(EFI_IFR_GUID).
3195 @retval NULL There is not enough space left in Buffer to add the opcode.
3196 @retval Other A pointer to the created opcode.
3201 HiiCreateGuidOpCode (
3202 IN VOID
*OpCodeHandle
,
3203 IN CONST EFI_GUID
*Guid
,
3204 IN CONST VOID
*GuidOpCode
, OPTIONAL
3208 EFI_IFR_GUID OpCode
;
3209 EFI_IFR_GUID
*OpCodePointer
;
3211 ASSERT (Guid
!= NULL
);
3212 ASSERT (OpCodeSize
>= sizeof (OpCode
));
3214 ZeroMem (&OpCode
, sizeof (OpCode
));
3215 CopyGuid ((EFI_GUID
*)(VOID
*)&OpCode
.Guid
, Guid
);
3217 OpCodePointer
= (EFI_IFR_GUID
*)InternalHiiCreateOpCodeExtended (
3222 OpCodeSize
- sizeof (OpCode
),
3225 if (OpCodePointer
!= NULL
&& GuidOpCode
!= NULL
) {
3226 CopyMem (OpCodePointer
+ 1, (EFI_IFR_GUID
*)GuidOpCode
+ 1, OpCodeSize
- sizeof (OpCode
));
3228 return (UINT8
*)OpCodePointer
;
3232 Create EFI_IFR_ACTION_OP opcode.
3234 If OpCodeHandle is NULL, then ASSERT().
3235 If any reserved bits are set in QuestionFlags, then ASSERT().
3237 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3238 @param[in] QuestionId Question ID
3239 @param[in] Prompt String ID for Prompt
3240 @param[in] Help String ID for Help
3241 @param[in] QuestionFlags Flags in Question Header
3242 @param[in] QuestionConfig String ID for configuration
3244 @retval NULL There is not enough space left in Buffer to add the opcode.
3245 @retval Other A pointer to the created opcode.
3250 HiiCreateActionOpCode (
3251 IN VOID
*OpCodeHandle
,
3252 IN EFI_QUESTION_ID QuestionId
,
3253 IN EFI_STRING_ID Prompt
,
3254 IN EFI_STRING_ID Help
,
3255 IN UINT8 QuestionFlags
,
3256 IN EFI_STRING_ID QuestionConfig
3259 EFI_IFR_ACTION OpCode
;
3261 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3263 ZeroMem (&OpCode
, sizeof (OpCode
));
3264 OpCode
.Question
.QuestionId
= QuestionId
;
3265 OpCode
.Question
.Header
.Prompt
= Prompt
;
3266 OpCode
.Question
.Header
.Help
= Help
;
3267 OpCode
.Question
.Flags
= QuestionFlags
;
3268 OpCode
.QuestionConfig
= QuestionConfig
;
3270 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_ACTION_OP
, sizeof (OpCode
));
3274 Create EFI_IFR_SUBTITLE_OP opcode.
3276 If OpCodeHandle is NULL, then ASSERT().
3277 If any reserved bits are set in Flags, then ASSERT().
3278 If Scope > 1, then ASSERT().
3280 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3281 @param[in] Prompt String ID for Prompt
3282 @param[in] Help String ID for Help
3283 @param[in] Flags Subtitle opcode flags
3284 @param[in] Scope 1 if this opcpde is the beginning of a new scope.
3285 0 if this opcode is within the current scope.
3287 @retval NULL There is not enough space left in Buffer to add the opcode.
3288 @retval Other A pointer to the created opcode.
3293 HiiCreateSubTitleOpCode (
3294 IN VOID
*OpCodeHandle
,
3295 IN EFI_STRING_ID Prompt
,
3296 IN EFI_STRING_ID Help
,
3301 EFI_IFR_SUBTITLE OpCode
;
3303 ASSERT (Scope
<= 1);
3304 ASSERT ((Flags
& (~(EFI_IFR_FLAGS_HORIZONTAL
))) == 0);
3306 ZeroMem (&OpCode
, sizeof (OpCode
));
3307 OpCode
.Statement
.Prompt
= Prompt
;
3308 OpCode
.Statement
.Help
= Help
;
3309 OpCode
.Flags
= Flags
;
3311 return InternalHiiCreateOpCodeExtended (
3314 EFI_IFR_SUBTITLE_OP
,
3322 Create EFI_IFR_REF_OP opcode.
3324 If OpCodeHandle is NULL, then ASSERT().
3325 If any reserved bits are set in QuestionFlags, then ASSERT().
3327 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3328 @param[in] FormId Destination Form ID
3329 @param[in] Prompt String ID for Prompt
3330 @param[in] Help String ID for Help
3331 @param[in] QuestionFlags Flags in Question Header
3332 @param[in] QuestionId Question ID
3334 @retval NULL There is not enough space left in Buffer to add the opcode.
3335 @retval Other A pointer to the created opcode.
3340 HiiCreateGotoOpCode (
3341 IN VOID
*OpCodeHandle
,
3342 IN EFI_FORM_ID FormId
,
3343 IN EFI_STRING_ID Prompt
,
3344 IN EFI_STRING_ID Help
,
3345 IN UINT8 QuestionFlags
,
3346 IN EFI_QUESTION_ID QuestionId
3351 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3353 ZeroMem (&OpCode
, sizeof (OpCode
));
3354 OpCode
.Question
.Header
.Prompt
= Prompt
;
3355 OpCode
.Question
.Header
.Help
= Help
;
3356 OpCode
.Question
.QuestionId
= QuestionId
;
3357 OpCode
.Question
.Flags
= QuestionFlags
;
3358 OpCode
.FormId
= FormId
;
3360 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_REF_OP
, sizeof (OpCode
));
3364 Create EFI_IFR_REF_OP, EFI_IFR_REF2_OP, EFI_IFR_REF3_OP and EFI_IFR_REF4_OP opcode.
3366 When RefDevicePath is not zero, EFI_IFR_REF4 opcode will be created.
3367 When RefDevicePath is zero and RefFormSetId is not NULL, EFI_IFR_REF3 opcode will be created.
3368 When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is not zero, EFI_IFR_REF2 opcode will be created.
3369 When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is zero, EFI_IFR_REF opcode will be created.
3371 If OpCodeHandle is NULL, then ASSERT().
3372 If any reserved bits are set in QuestionFlags, then ASSERT().
3374 @param[in] OpCodeHandle The handle to the buffer of opcodes.
3375 @param[in] RefFormId The Destination Form ID.
3376 @param[in] Prompt The string ID for Prompt.
3377 @param[in] Help The string ID for Help.
3378 @param[in] QuestionFlags The flags in Question Header
3379 @param[in] QuestionId Question ID.
3380 @param[in] RefQuestionId The question on the form to which this link is referring.
3381 If its value is zero, then the link refers to the top of the form.
3382 @param[in] RefFormSetId The form set to which this link is referring. If its value is NULL, and RefDevicePath is
3383 zero, then the link is to the current form set.
3384 @param[in] RefDevicePath The string identifier that specifies the string containing the text representation of
3385 the device path to which the form set containing the form specified by FormId.
3386 If its value is zero, then the link refers to the current page.
3388 @retval NULL There is not enough space left in Buffer to add the opcode.
3389 @retval Other A pointer to the created opcode.
3394 HiiCreateGotoExOpCode (
3395 IN VOID
*OpCodeHandle
,
3396 IN EFI_FORM_ID RefFormId
,
3397 IN EFI_STRING_ID Prompt
,
3398 IN EFI_STRING_ID Help
,
3399 IN UINT8 QuestionFlags
,
3400 IN EFI_QUESTION_ID QuestionId
,
3401 IN EFI_QUESTION_ID RefQuestionId
,
3402 IN EFI_GUID
*RefFormSetId
, OPTIONAL
3403 IN EFI_STRING_ID RefDevicePath
3406 EFI_IFR_REF4 OpCode
;
3409 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3411 ZeroMem (&OpCode
, sizeof (OpCode
));
3412 OpCode
.Question
.Header
.Prompt
= Prompt
;
3413 OpCode
.Question
.Header
.Help
= Help
;
3414 OpCode
.Question
.QuestionId
= QuestionId
;
3415 OpCode
.Question
.Flags
= QuestionFlags
;
3416 OpCode
.FormId
= RefFormId
;
3417 OpCode
.QuestionId
= RefQuestionId
;
3418 OpCode
.DevicePath
= RefDevicePath
;
3419 if (RefFormSetId
!= NULL
) {
3420 CopyMem (&OpCode
.FormSetId
, RefFormSetId
, sizeof (OpCode
.FormSetId
));
3424 // Cacluate OpCodeSize based on the input Ref value.
3425 // Try to use the small OpCode to save size.
3427 OpCodeSize
= sizeof (EFI_IFR_REF
);
3428 if (RefDevicePath
!= 0) {
3429 OpCodeSize
= sizeof (EFI_IFR_REF4
);
3430 } else if (RefFormSetId
!= NULL
) {
3431 OpCodeSize
= sizeof (EFI_IFR_REF3
);
3432 } else if (RefQuestionId
!= 0) {
3433 OpCodeSize
= sizeof (EFI_IFR_REF2
);
3436 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_REF_OP
, OpCodeSize
);
3440 Create EFI_IFR_CHECKBOX_OP opcode.
3442 If OpCodeHandle is NULL, then ASSERT().
3443 If any reserved bits are set in QuestionFlags, then ASSERT().
3444 If any reserved bits are set in CheckBoxFlags, then ASSERT().
3446 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3447 @param[in] QuestionId Question ID
3448 @param[in] VarStoreId Storage ID
3449 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3450 for this name/value pair.
3451 @param[in] Prompt String ID for Prompt
3452 @param[in] Help String ID for Help
3453 @param[in] QuestionFlags Flags in Question Header
3454 @param[in] CheckBoxFlags Flags for checkbox opcode
3455 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3456 is an optional parameter that may be NULL.
3458 @retval NULL There is not enough space left in Buffer to add the opcode.
3459 @retval Other A pointer to the created opcode.
3464 HiiCreateCheckBoxOpCode (
3465 IN VOID
*OpCodeHandle
,
3466 IN EFI_QUESTION_ID QuestionId
,
3467 IN EFI_VARSTORE_ID VarStoreId
,
3468 IN UINT16 VarOffset
,
3469 IN EFI_STRING_ID Prompt
,
3470 IN EFI_STRING_ID Help
,
3471 IN UINT8 QuestionFlags
,
3472 IN UINT8 CheckBoxFlags
,
3473 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3476 EFI_IFR_CHECKBOX OpCode
;
3479 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3481 ZeroMem (&OpCode
, sizeof (OpCode
));
3482 OpCode
.Question
.QuestionId
= QuestionId
;
3483 OpCode
.Question
.VarStoreId
= VarStoreId
;
3484 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3485 OpCode
.Question
.Header
.Prompt
= Prompt
;
3486 OpCode
.Question
.Header
.Help
= Help
;
3487 OpCode
.Question
.Flags
= QuestionFlags
;
3488 OpCode
.Flags
= CheckBoxFlags
;
3490 if (DefaultsOpCodeHandle
== NULL
) {
3491 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_CHECKBOX_OP
, sizeof (OpCode
));
3494 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3495 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_CHECKBOX_OP
, sizeof (OpCode
), 0, 1);
3496 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3497 HiiCreateEndOpCode (OpCodeHandle
);
3498 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3502 Create EFI_IFR_NUMERIC_OP opcode.
3504 If OpCodeHandle is NULL, then ASSERT().
3505 If any reserved bits are set in QuestionFlags, then ASSERT().
3506 If any reserved bits are set in NumericFlags, then ASSERT().
3508 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3509 @param[in] QuestionId Question ID
3510 @param[in] VarStoreId Storage ID
3511 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3512 for this name/value pair.
3513 @param[in] Prompt String ID for Prompt
3514 @param[in] Help String ID for Help
3515 @param[in] QuestionFlags Flags in Question Header
3516 @param[in] NumericFlags Flags for numeric opcode
3517 @param[in] Minimum Numeric minimum value
3518 @param[in] Maximum Numeric maximum value
3519 @param[in] Step Numeric step for edit
3520 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3521 is an optional parameter that may be NULL.
3523 @retval NULL There is not enough space left in Buffer to add the opcode.
3524 @retval Other A pointer to the created opcode.
3529 HiiCreateNumericOpCode (
3530 IN VOID
*OpCodeHandle
,
3531 IN EFI_QUESTION_ID QuestionId
,
3532 IN EFI_VARSTORE_ID VarStoreId
,
3533 IN UINT16 VarOffset
,
3534 IN EFI_STRING_ID Prompt
,
3535 IN EFI_STRING_ID Help
,
3536 IN UINT8 QuestionFlags
,
3537 IN UINT8 NumericFlags
,
3541 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3544 EFI_IFR_NUMERIC OpCode
;
3548 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3551 ZeroMem (&OpCode
, sizeof (OpCode
));
3552 OpCode
.Question
.QuestionId
= QuestionId
;
3553 OpCode
.Question
.VarStoreId
= VarStoreId
;
3554 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3555 OpCode
.Question
.Header
.Prompt
= Prompt
;
3556 OpCode
.Question
.Header
.Help
= Help
;
3557 OpCode
.Question
.Flags
= QuestionFlags
;
3558 OpCode
.Flags
= NumericFlags
;
3560 switch (NumericFlags
& EFI_IFR_NUMERIC_SIZE
) {
3561 case EFI_IFR_NUMERIC_SIZE_1
:
3562 OpCode
.data
.u8
.MinValue
= (UINT8
)Minimum
;
3563 OpCode
.data
.u8
.MaxValue
= (UINT8
)Maximum
;
3564 OpCode
.data
.u8
.Step
= (UINT8
)Step
;
3568 case EFI_IFR_NUMERIC_SIZE_2
:
3569 OpCode
.data
.u16
.MinValue
= (UINT16
)Minimum
;
3570 OpCode
.data
.u16
.MaxValue
= (UINT16
)Maximum
;
3571 OpCode
.data
.u16
.Step
= (UINT16
)Step
;
3575 case EFI_IFR_NUMERIC_SIZE_4
:
3576 OpCode
.data
.u32
.MinValue
= (UINT32
)Minimum
;
3577 OpCode
.data
.u32
.MaxValue
= (UINT32
)Maximum
;
3578 OpCode
.data
.u32
.Step
= (UINT32
)Step
;
3582 case EFI_IFR_NUMERIC_SIZE_8
:
3583 OpCode
.data
.u64
.MinValue
= Minimum
;
3584 OpCode
.data
.u64
.MaxValue
= Maximum
;
3585 OpCode
.data
.u64
.Step
= Step
;
3590 Length
+= OFFSET_OF (EFI_IFR_NUMERIC
, data
);
3592 if (DefaultsOpCodeHandle
== NULL
) {
3593 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_NUMERIC_OP
, Length
);
3596 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3597 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_NUMERIC_OP
, Length
, 0, 1);
3598 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3599 HiiCreateEndOpCode (OpCodeHandle
);
3600 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3604 Create EFI_IFR_STRING_OP opcode.
3606 If OpCodeHandle is NULL, then ASSERT().
3607 If any reserved bits are set in QuestionFlags, then ASSERT().
3608 If any reserved bits are set in StringFlags, then ASSERT().
3610 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3611 @param[in] QuestionId Question ID
3612 @param[in] VarStoreId Storage ID
3613 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3614 for this name/value pair.
3615 @param[in] Prompt String ID for Prompt
3616 @param[in] Help String ID for Help
3617 @param[in] QuestionFlags Flags in Question Header
3618 @param[in] StringFlags Flags for string opcode
3619 @param[in] MinSize String minimum length
3620 @param[in] MaxSize String maximum length
3621 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3622 is an optional parameter that may be NULL.
3624 @retval NULL There is not enough space left in Buffer to add the opcode.
3625 @retval Other A pointer to the created opcode.
3630 HiiCreateStringOpCode (
3631 IN VOID
*OpCodeHandle
,
3632 IN EFI_QUESTION_ID QuestionId
,
3633 IN EFI_VARSTORE_ID VarStoreId
,
3634 IN UINT16 VarOffset
,
3635 IN EFI_STRING_ID Prompt
,
3636 IN EFI_STRING_ID Help
,
3637 IN UINT8 QuestionFlags
,
3638 IN UINT8 StringFlags
,
3641 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3644 EFI_IFR_STRING OpCode
;
3647 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3649 ZeroMem (&OpCode
, sizeof (OpCode
));
3650 OpCode
.Question
.Header
.Prompt
= Prompt
;
3651 OpCode
.Question
.Header
.Help
= Help
;
3652 OpCode
.Question
.QuestionId
= QuestionId
;
3653 OpCode
.Question
.VarStoreId
= VarStoreId
;
3654 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3655 OpCode
.Question
.Flags
= QuestionFlags
;
3656 OpCode
.MinSize
= MinSize
;
3657 OpCode
.MaxSize
= MaxSize
;
3658 OpCode
.Flags
= (UINT8
) (StringFlags
& EFI_IFR_STRING_MULTI_LINE
);
3660 if (DefaultsOpCodeHandle
== NULL
) {
3661 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_STRING_OP
, sizeof (OpCode
));
3664 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3665 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_STRING_OP
, sizeof (OpCode
), 0, 1);
3666 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3667 HiiCreateEndOpCode (OpCodeHandle
);
3668 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3672 Create EFI_IFR_ONE_OF_OP opcode.
3674 If OpCodeHandle is NULL, then ASSERT().
3675 If any reserved bits are set in QuestionFlags, then ASSERT().
3676 If any reserved bits are set in OneOfFlags, then ASSERT().
3678 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3679 @param[in] QuestionId Question ID
3680 @param[in] VarStoreId Storage ID
3681 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3682 for this name/value pair.
3683 @param[in] Prompt String ID for Prompt
3684 @param[in] Help String ID for Help
3685 @param[in] QuestionFlags Flags in Question Header
3686 @param[in] OneOfFlags Flags for oneof opcode
3687 @param[in] OptionsOpCodeHandle Handle for a buffer of ONE_OF_OPTION opcodes.
3688 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3689 is an optional parameter that may be NULL.
3691 @retval NULL There is not enough space left in Buffer to add the opcode.
3692 @retval Other A pointer to the created opcode.
3697 HiiCreateOneOfOpCode (
3698 IN VOID
*OpCodeHandle
,
3699 IN EFI_QUESTION_ID QuestionId
,
3700 IN EFI_VARSTORE_ID VarStoreId
,
3701 IN UINT16 VarOffset
,
3702 IN EFI_STRING_ID Prompt
,
3703 IN EFI_STRING_ID Help
,
3704 IN UINT8 QuestionFlags
,
3705 IN UINT8 OneOfFlags
,
3706 IN VOID
*OptionsOpCodeHandle
,
3707 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3710 EFI_IFR_ONE_OF OpCode
;
3714 ASSERT (OptionsOpCodeHandle
!= NULL
);
3715 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
| EFI_IFR_FLAG_OPTIONS_ONLY
))) == 0);
3717 ZeroMem (&OpCode
, sizeof (OpCode
));
3718 OpCode
.Question
.Header
.Prompt
= Prompt
;
3719 OpCode
.Question
.Header
.Help
= Help
;
3720 OpCode
.Question
.QuestionId
= QuestionId
;
3721 OpCode
.Question
.VarStoreId
= VarStoreId
;
3722 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3723 OpCode
.Question
.Flags
= QuestionFlags
;
3724 OpCode
.Flags
= OneOfFlags
;
3726 Length
= OFFSET_OF (EFI_IFR_ONE_OF
, data
);
3727 Length
+= (1 << (OneOfFlags
& EFI_IFR_NUMERIC_SIZE
)) * 3;
3729 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3730 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_ONE_OF_OP
, Length
, 0, 1);
3731 InternalHiiAppendOpCodes (OpCodeHandle
, OptionsOpCodeHandle
);
3732 if (DefaultsOpCodeHandle
!= NULL
) {
3733 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3735 HiiCreateEndOpCode (OpCodeHandle
);
3736 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3740 Create EFI_IFR_ORDERED_LIST_OP opcode.
3742 If OpCodeHandle is NULL, then ASSERT().
3743 If any reserved bits are set in QuestionFlags, then ASSERT().
3744 If any reserved bits are set in OrderedListFlags, then ASSERT().
3746 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3747 @param[in] QuestionId Question ID
3748 @param[in] VarStoreId Storage ID
3749 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3750 for this name/value pair.
3751 @param[in] Prompt String ID for Prompt
3752 @param[in] Help String ID for Help
3753 @param[in] QuestionFlags Flags in Question Header
3754 @param[in] OrderedListFlags Flags for ordered list opcode
3755 @param[in] DataType Type for option value
3756 @param[in] MaxContainers Maximum count for options in this ordered list
3757 @param[in] OptionsOpCodeHandle Handle for a buffer of ONE_OF_OPTION opcodes.
3758 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3759 is an optional parameter that may be NULL.
3761 @retval NULL There is not enough space left in Buffer to add the opcode.
3762 @retval Other A pointer to the created opcode.
3767 HiiCreateOrderedListOpCode (
3768 IN VOID
*OpCodeHandle
,
3769 IN EFI_QUESTION_ID QuestionId
,
3770 IN EFI_VARSTORE_ID VarStoreId
,
3771 IN UINT16 VarOffset
,
3772 IN EFI_STRING_ID Prompt
,
3773 IN EFI_STRING_ID Help
,
3774 IN UINT8 QuestionFlags
,
3775 IN UINT8 OrderedListFlags
,
3777 IN UINT8 MaxContainers
,
3778 IN VOID
*OptionsOpCodeHandle
,
3779 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3782 EFI_IFR_ORDERED_LIST OpCode
;
3785 ASSERT (OptionsOpCodeHandle
!= NULL
);
3786 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
| EFI_IFR_FLAG_OPTIONS_ONLY
))) == 0);
3788 ZeroMem (&OpCode
, sizeof (OpCode
));
3789 OpCode
.Question
.Header
.Prompt
= Prompt
;
3790 OpCode
.Question
.Header
.Help
= Help
;
3791 OpCode
.Question
.QuestionId
= QuestionId
;
3792 OpCode
.Question
.VarStoreId
= VarStoreId
;
3793 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3794 OpCode
.Question
.Flags
= QuestionFlags
;
3795 OpCode
.MaxContainers
= MaxContainers
;
3796 OpCode
.Flags
= OrderedListFlags
;
3798 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3799 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_ORDERED_LIST_OP
, sizeof (OpCode
), 0, 1);
3800 InternalHiiAppendOpCodes (OpCodeHandle
, OptionsOpCodeHandle
);
3801 if (DefaultsOpCodeHandle
!= NULL
) {
3802 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3804 HiiCreateEndOpCode (OpCodeHandle
);
3805 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3809 Create EFI_IFR_TEXT_OP opcode.
3811 If OpCodeHandle is NULL, then ASSERT().
3813 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3814 @param[in] Prompt String ID for Prompt.
3815 @param[in] Help String ID for Help.
3816 @param[in] TextTwo String ID for TextTwo.
3818 @retval NULL There is not enough space left in Buffer to add the opcode.
3819 @retval Other A pointer to the created opcode.
3824 HiiCreateTextOpCode (
3825 IN VOID
*OpCodeHandle
,
3826 IN EFI_STRING_ID Prompt
,
3827 IN EFI_STRING_ID Help
,
3828 IN EFI_STRING_ID TextTwo
3831 EFI_IFR_TEXT OpCode
;
3833 ZeroMem (&OpCode
, sizeof (OpCode
));
3834 OpCode
.Statement
.Prompt
= Prompt
;
3835 OpCode
.Statement
.Help
= Help
;
3836 OpCode
.TextTwo
= TextTwo
;
3838 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_TEXT_OP
, sizeof (OpCode
));
3842 Create EFI_IFR_DATE_OP opcode.
3844 If OpCodeHandle is NULL, then ASSERT().
3845 If any reserved bits are set in QuestionFlags, then ASSERT().
3846 If any reserved bits are set in DateFlags, then ASSERT().
3848 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3849 @param[in] QuestionId Question ID
3850 @param[in] VarStoreId Storage ID, optional. If DateFlags is not
3851 QF_DATE_STORAGE_NORMAL, this parameter is ignored.
3852 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3853 for this name/value pair, optional. If DateFlags is not
3854 QF_DATE_STORAGE_NORMAL, this parameter is ignored.
3855 @param[in] Prompt String ID for Prompt
3856 @param[in] Help String ID for Help
3857 @param[in] QuestionFlags Flags in Question Header
3858 @param[in] DateFlags Flags for date opcode
3859 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3860 is an optional parameter that may be NULL.
3862 @retval NULL There is not enough space left in Buffer to add the opcode.
3863 @retval Other A pointer to the created opcode.
3868 HiiCreateDateOpCode (
3869 IN VOID
*OpCodeHandle
,
3870 IN EFI_QUESTION_ID QuestionId
,
3871 IN EFI_VARSTORE_ID VarStoreId
, OPTIONAL
3872 IN UINT16 VarOffset
, OPTIONAL
3873 IN EFI_STRING_ID Prompt
,
3874 IN EFI_STRING_ID Help
,
3875 IN UINT8 QuestionFlags
,
3877 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3880 EFI_IFR_DATE OpCode
;
3883 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3884 ASSERT ((DateFlags
& (~(EFI_QF_DATE_YEAR_SUPPRESS
| EFI_QF_DATE_MONTH_SUPPRESS
| EFI_QF_DATE_DAY_SUPPRESS
| EFI_QF_DATE_STORAGE
))) == 0);
3886 ZeroMem (&OpCode
, sizeof (OpCode
));
3887 OpCode
.Question
.Header
.Prompt
= Prompt
;
3888 OpCode
.Question
.Header
.Help
= Help
;
3889 OpCode
.Question
.QuestionId
= QuestionId
;
3890 OpCode
.Question
.VarStoreId
= VarStoreId
;
3891 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3892 OpCode
.Question
.Flags
= QuestionFlags
;
3893 OpCode
.Flags
= DateFlags
;
3895 if (DefaultsOpCodeHandle
== NULL
) {
3896 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_DATE_OP
, sizeof (OpCode
));
3899 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3900 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_DATE_OP
, sizeof (OpCode
), 0, 1);
3901 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3902 HiiCreateEndOpCode (OpCodeHandle
);
3903 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3907 Create EFI_IFR_TIME_OP opcode.
3909 If OpCodeHandle is NULL, then ASSERT().
3910 If any reserved bits are set in QuestionFlags, then ASSERT().
3911 If any reserved bits are set in TimeFlags, then ASSERT().
3913 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3914 @param[in] QuestionId Question ID
3915 @param[in] VarStoreId Storage ID, optional. If TimeFlags is not
3916 QF_TIME_STORAGE_NORMAL, this parameter is ignored.
3917 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3918 for this name/value pair, optional. If TimeFlags is not
3919 QF_TIME_STORAGE_NORMAL, this parameter is ignored.
3920 @param[in] Prompt String ID for Prompt
3921 @param[in] Help String ID for Help
3922 @param[in] QuestionFlags Flags in Question Header
3923 @param[in] TimeFlags Flags for time opcode
3924 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3925 is an optional parameter that may be NULL.
3927 @retval NULL There is not enough space left in Buffer to add the opcode.
3928 @retval Other A pointer to the created opcode.
3933 HiiCreateTimeOpCode (
3934 IN VOID
*OpCodeHandle
,
3935 IN EFI_QUESTION_ID QuestionId
,
3936 IN EFI_VARSTORE_ID VarStoreId
, OPTIONAL
3937 IN UINT16 VarOffset
, OPTIONAL
3938 IN EFI_STRING_ID Prompt
,
3939 IN EFI_STRING_ID Help
,
3940 IN UINT8 QuestionFlags
,
3942 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3945 EFI_IFR_TIME OpCode
;
3948 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3949 ASSERT ((TimeFlags
& (~(QF_TIME_HOUR_SUPPRESS
| QF_TIME_MINUTE_SUPPRESS
| QF_TIME_SECOND_SUPPRESS
| QF_TIME_STORAGE
))) == 0);
3951 ZeroMem (&OpCode
, sizeof (OpCode
));
3952 OpCode
.Question
.Header
.Prompt
= Prompt
;
3953 OpCode
.Question
.Header
.Help
= Help
;
3954 OpCode
.Question
.QuestionId
= QuestionId
;
3955 OpCode
.Question
.VarStoreId
= VarStoreId
;
3956 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3957 OpCode
.Question
.Flags
= QuestionFlags
;
3958 OpCode
.Flags
= TimeFlags
;
3960 if (DefaultsOpCodeHandle
== NULL
) {
3961 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_TIME_OP
, sizeof (OpCode
));
3964 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3965 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_TIME_OP
, sizeof (OpCode
), 0, 1);
3966 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3967 HiiCreateEndOpCode (OpCodeHandle
);
3968 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3972 This is the internal worker function to update the data in
3973 a form specified by FormSetGuid, FormId and Label.
3975 @param[in] FormSetGuid The optional Formset GUID.
3976 @param[in] FormId The Form ID.
3977 @param[in] Package The package header.
3978 @param[in] OpCodeBufferStart An OpCode buffer that contains the set of IFR
3979 opcodes to be inserted or replaced in the form.
3980 @param[in] OpCodeBufferEnd An OpCcode buffer that contains the IFR opcode
3981 that marks the end of a replace operation in the form.
3982 @param[out] TempPackage The resultant package.
3984 @retval EFI_SUCCESS The function completes successfully.
3985 @retval EFI_NOT_FOUND The updated opcode or endopcode is not found.
3990 InternalHiiUpdateFormPackageData (
3991 IN EFI_GUID
*FormSetGuid
, OPTIONAL
3992 IN EFI_FORM_ID FormId
,
3993 IN EFI_HII_PACKAGE_HEADER
*Package
,
3994 IN HII_LIB_OPCODE_BUFFER
*OpCodeBufferStart
,
3995 IN HII_LIB_OPCODE_BUFFER
*OpCodeBufferEnd
, OPTIONAL
3996 OUT EFI_HII_PACKAGE_HEADER
*TempPackage
4001 EFI_HII_PACKAGE_HEADER PackageHeader
;
4003 EFI_IFR_OP_HEADER
*IfrOpHdr
;
4004 EFI_IFR_OP_HEADER
*UpdateIfrOpHdr
;
4008 UINTN UpdatePackageLength
;
4010 CopyMem (TempPackage
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4011 UpdatePackageLength
= sizeof (EFI_HII_PACKAGE_HEADER
);
4012 BufferPos
= (UINT8
*) (TempPackage
+ 1);
4014 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4015 IfrOpHdr
= (EFI_IFR_OP_HEADER
*)((UINT8
*) Package
+ sizeof (EFI_HII_PACKAGE_HEADER
));
4016 Offset
= sizeof (EFI_HII_PACKAGE_HEADER
);
4017 GetFormSet
= (BOOLEAN
) ((FormSetGuid
== NULL
) ? TRUE
: FALSE
);
4021 while (Offset
< PackageHeader
.Length
) {
4022 CopyMem (BufferPos
, IfrOpHdr
, IfrOpHdr
->Length
);
4023 BufferPos
+= IfrOpHdr
->Length
;
4024 UpdatePackageLength
+= IfrOpHdr
->Length
;
4027 // Find the matched FormSet and Form
4029 if ((IfrOpHdr
->OpCode
== EFI_IFR_FORM_SET_OP
) && (FormSetGuid
!= NULL
)) {
4030 if (CompareGuid((GUID
*)(VOID
*)&((EFI_IFR_FORM_SET
*) IfrOpHdr
)->Guid
, FormSetGuid
)) {
4035 } else if (IfrOpHdr
->OpCode
== EFI_IFR_FORM_OP
|| IfrOpHdr
->OpCode
== EFI_IFR_FORM_MAP_OP
) {
4036 if (CompareMem (&((EFI_IFR_FORM
*) IfrOpHdr
)->FormId
, &FormId
, sizeof (EFI_FORM_ID
)) == 0) {
4044 // The matched Form is found, and Update data in this form
4046 if (GetFormSet
&& GetForm
) {
4047 UpdateIfrOpHdr
= (EFI_IFR_OP_HEADER
*) OpCodeBufferStart
->Buffer
;
4048 if ((UpdateIfrOpHdr
->Length
== IfrOpHdr
->Length
) && \
4049 (CompareMem (IfrOpHdr
, UpdateIfrOpHdr
, UpdateIfrOpHdr
->Length
) == 0)) {
4051 // Remove the original data when End OpCode buffer exist.
4053 if (OpCodeBufferEnd
!= NULL
) {
4054 Offset
+= IfrOpHdr
->Length
;
4055 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((UINT8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4056 UpdateIfrOpHdr
= (EFI_IFR_OP_HEADER
*) OpCodeBufferEnd
->Buffer
;
4057 while (Offset
< PackageHeader
.Length
) {
4059 // Search the matched end opcode
4061 if ((UpdateIfrOpHdr
->Length
== IfrOpHdr
->Length
) && \
4062 (CompareMem (IfrOpHdr
, UpdateIfrOpHdr
, UpdateIfrOpHdr
->Length
) == 0)) {
4066 // Go to the next Op-Code
4068 Offset
+= IfrOpHdr
->Length
;
4069 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((UINT8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4072 if (Offset
>= PackageHeader
.Length
) {
4074 // The end opcode is not found.
4076 return EFI_NOT_FOUND
;
4081 // Insert the updated data
4083 AddSize
= ((EFI_IFR_OP_HEADER
*) OpCodeBufferStart
->Buffer
)->Length
;
4084 CopyMem (BufferPos
, OpCodeBufferStart
->Buffer
+ AddSize
, OpCodeBufferStart
->Position
- AddSize
);
4085 BufferPos
+= OpCodeBufferStart
->Position
- AddSize
;
4086 UpdatePackageLength
+= OpCodeBufferStart
->Position
- AddSize
;
4088 if (OpCodeBufferEnd
!= NULL
) {
4090 // Add the end opcode
4092 CopyMem (BufferPos
, IfrOpHdr
, IfrOpHdr
->Length
);
4093 BufferPos
+= IfrOpHdr
->Length
;
4094 UpdatePackageLength
+= IfrOpHdr
->Length
;
4098 // Copy the left package data.
4100 Offset
+= IfrOpHdr
->Length
;
4101 CopyMem (BufferPos
, (UINT8
*) Package
+ Offset
, PackageHeader
.Length
- Offset
);
4102 UpdatePackageLength
+= PackageHeader
.Length
- Offset
;
4113 // Go to the next Op-Code
4115 Offset
+= IfrOpHdr
->Length
;
4116 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((CHAR8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4121 // The updated opcode buffer is not found.
4123 return EFI_NOT_FOUND
;
4126 // Update the package length.
4128 PackageHeader
.Length
= (UINT32
) UpdatePackageLength
;
4129 CopyMem (TempPackage
, &PackageHeader
, sizeof (EFI_HII_PACKAGE_HEADER
));
4135 This function updates a form that has previously been registered with the HII
4136 Database. This function will perform at most one update operation.
4138 The form to update is specified by Handle, FormSetGuid, and FormId. Binary
4139 comparisons of IFR opcodes are performed from the beginning of the form being
4140 updated until an IFR opcode is found that exactly matches the first IFR opcode
4141 specified by StartOpCodeHandle. The following rules are used to determine if
4142 an insert, replace, or delete operation is performed.
4144 1) If no matches are found, then NULL is returned.
4145 2) If a match is found, and EndOpCodeHandle is NULL, then all of the IFR opcodes
4146 from StartOpCodeHandle except the first opcode are inserted immediately after
4147 the matching IFR opcode in the form to be updated.
4148 3) If a match is found, and EndOpCodeHandle is not NULL, then a search is made
4149 from the matching IFR opcode until an IFR opcode exactly matches the first
4150 IFR opcode specified by EndOpCodeHandle. If no match is found for the first
4151 IFR opcode specified by EndOpCodeHandle, then NULL is returned. If a match
4152 is found, then all of the IFR opcodes between the start match and the end
4153 match are deleted from the form being updated and all of the IFR opcodes
4154 from StartOpCodeHandle except the first opcode are inserted immediately after
4155 the matching start IFR opcode. If StartOpCcodeHandle only contains one
4156 IFR instruction, then the result of this operation will delete all of the IFR
4157 opcodes between the start end matches.
4159 If HiiHandle is NULL, then ASSERT().
4160 If StartOpCodeHandle is NULL, then ASSERT().
4162 @param[in] HiiHandle The HII Handle of the form to update.
4163 @param[in] FormSetGuid The Formset GUID of the form to update. This
4164 is an optional parameter that may be NULL.
4165 If it is NULL, all FormSet will be updated.
4166 @param[in] FormId The ID of the form to update.
4167 @param[in] StartOpCodeHandle An OpCode Handle that contains the set of IFR
4168 opcodes to be inserted or replaced in the form.
4169 The first IFR instruction in StartOpCodeHandle
4170 is used to find matching IFR opcode in the
4172 @param[in] EndOpCodeHandle An OpCcode Handle that contains the IFR opcode
4173 that marks the end of a replace operation in
4174 the form. This is an optional parameter that
4175 may be NULL. If it is NULL, then an the IFR
4176 opcodes specified by StartOpCodeHandle are
4177 inserted into the form.
4179 @retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated.
4180 @retval EFI_NOT_FOUND The following cases will return EFI_NOT_FOUND.
4181 1) The form specified by HiiHandle, FormSetGuid,
4182 and FormId could not be found in the HII Database.
4183 2) No IFR opcodes in the target form match the first
4184 IFR opcode in StartOpCodeHandle.
4185 3) EndOpCOde is not NULL, and no IFR opcodes in the
4186 target form following a matching start opcode match
4187 the first IFR opcode in EndOpCodeHandle.
4188 @retval EFI_SUCCESS The matched form is updated by StartOpcode.
4194 IN EFI_HII_HANDLE HiiHandle
,
4195 IN EFI_GUID
*FormSetGuid
, OPTIONAL
4196 IN EFI_FORM_ID FormId
,
4197 IN VOID
*StartOpCodeHandle
,
4198 IN VOID
*EndOpCodeHandle OPTIONAL
4202 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
4203 UINT32 PackageListLength
;
4205 EFI_HII_PACKAGE_LIST_HEADER
*UpdatePackageList
;
4207 UINT8
*UpdateBufferPos
;
4208 EFI_HII_PACKAGE_HEADER
*Package
;
4209 EFI_HII_PACKAGE_HEADER
*TempPackage
;
4210 EFI_HII_PACKAGE_HEADER PackageHeader
;
4212 HII_LIB_OPCODE_BUFFER
*OpCodeBufferStart
;
4213 HII_LIB_OPCODE_BUFFER
*OpCodeBufferEnd
;
4216 // Input update data can't be NULL.
4218 ASSERT (HiiHandle
!= NULL
);
4219 ASSERT (StartOpCodeHandle
!= NULL
);
4220 UpdatePackageList
= NULL
;
4222 HiiPackageList
= NULL
;
4225 // Retrieve buffer data from Opcode Handle
4227 OpCodeBufferStart
= (HII_LIB_OPCODE_BUFFER
*) StartOpCodeHandle
;
4228 OpCodeBufferEnd
= (HII_LIB_OPCODE_BUFFER
*) EndOpCodeHandle
;
4231 // Get the original package list
4234 HiiPackageList
= NULL
;
4235 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
4237 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
4239 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
4243 HiiPackageList
= AllocatePool (BufferSize
);
4244 if (HiiPackageList
== NULL
) {
4245 Status
= EFI_OUT_OF_RESOURCES
;
4249 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
4250 if (EFI_ERROR (Status
)) {
4255 // Calculate and allocate space for retrieval of IFR data
4257 BufferSize
+= OpCodeBufferStart
->Position
;
4258 UpdatePackageList
= AllocateZeroPool (BufferSize
);
4259 if (UpdatePackageList
== NULL
) {
4260 Status
= EFI_OUT_OF_RESOURCES
;
4265 // Allocate temp buffer to store the temp updated package buffer
4267 TempPackage
= AllocateZeroPool (BufferSize
);
4268 if (TempPackage
== NULL
) {
4269 Status
= EFI_OUT_OF_RESOURCES
;
4273 UpdateBufferPos
= (UINT8
*) UpdatePackageList
;
4276 // Copy the package list header
4278 CopyMem (UpdateBufferPos
, HiiPackageList
, sizeof (EFI_HII_PACKAGE_LIST_HEADER
));
4279 UpdateBufferPos
+= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
4282 // Go through each package to find the matched package and update one by one
4285 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
4286 PackageListLength
= ReadUnaligned32 (&HiiPackageList
->PackageLength
);
4287 while (Offset
< PackageListLength
) {
4288 Package
= (EFI_HII_PACKAGE_HEADER
*) (((UINT8
*) HiiPackageList
) + Offset
);
4289 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4290 Offset
+= Package
->Length
;
4292 if (Package
->Type
== EFI_HII_PACKAGE_FORMS
) {
4294 // Check this package is the matched package.
4296 Status
= InternalHiiUpdateFormPackageData (FormSetGuid
, FormId
, Package
, OpCodeBufferStart
, OpCodeBufferEnd
, TempPackage
);
4298 // The matched package is found. Its package buffer will be updated by the input new data.
4300 if (!EFI_ERROR(Status
)) {
4306 // Add updated package buffer
4308 Package
= TempPackage
;
4313 // Add pacakge buffer
4315 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4316 CopyMem (UpdateBufferPos
, Package
, PackageHeader
.Length
);
4317 UpdateBufferPos
+= PackageHeader
.Length
;
4322 // Update package list length
4324 BufferSize
= UpdateBufferPos
- (UINT8
*) UpdatePackageList
;
4325 WriteUnaligned32 (&UpdatePackageList
->PackageLength
, (UINT32
) BufferSize
);
4328 // Update Package to show form
4330 Status
= gHiiDatabase
->UpdatePackageList (gHiiDatabase
, HiiHandle
, UpdatePackageList
);
4333 // Not matched form is found and updated.
4335 Status
= EFI_NOT_FOUND
;
4339 if (HiiPackageList
!= NULL
) {
4340 FreePool (HiiPackageList
);
4343 if (UpdatePackageList
!= NULL
) {
4344 FreePool (UpdatePackageList
);
4347 if (TempPackage
!= NULL
) {
4348 FreePool (TempPackage
);