2 HII Library implementation that uses DXE protocols and services.
4 Copyright (c) 2006 - 2015, 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, opints 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 sucessfully.
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 CopyMem (TempBuffer
+ TempSize
, OpCodeData
, ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
);
469 FreePool(FormSetBuffer
);
471 TempBuffer
= AllocateCopyPool (TempSize
+ ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
, OpCodeData
);
473 TempSize
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
474 FormSetBuffer
= TempBuffer
;
476 Status
= EFI_SUCCESS
;
478 //One form package has one formset, exit current form package to search other form package in the packagelist.
483 FreePool (HiiPackageList
);
485 *BufferSize
= TempSize
;
486 *Buffer
= (EFI_IFR_FORM_SET
*)FormSetBuffer
;
492 Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for
493 hex digits that appear between a '=' and a '&' in a config string.
495 If ConfigString is NULL, then ASSERT().
497 @param[in] ConfigString Pointer to a Null-terminated Unicode string.
499 @return Pointer to the Null-terminated Unicode result string.
504 InternalHiiLowerConfigString (
505 IN EFI_STRING ConfigString
511 ASSERT (ConfigString
!= NULL
);
514 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
516 for (String
= ConfigString
, Lower
= FALSE
; *String
!= L
'\0'; String
++) {
517 if (*String
== L
'=') {
519 } else if (*String
== L
'&') {
521 } else if (Lower
&& *String
>= L
'A' && *String
<= L
'F') {
522 *String
= (CHAR16
) (*String
- L
'A' + L
'a');
530 Uses the BlockToConfig() service of the Config Routing Protocol to
531 convert <ConfigRequest> and a buffer to a <ConfigResp>
533 If ConfigRequest is NULL, then ASSERT().
534 If Block is NULL, then ASSERT().
536 @param[in] ConfigRequest Pointer to a Null-terminated Unicode string.
537 @param[in] Block Pointer to a block of data.
538 @param[in] BlockSize The zie, in bytes, of Block.
540 @retval NULL The <ConfigResp> string could not be generated.
541 @retval Other Pointer to the Null-terminated Unicode <ConfigResp> string.
546 InternalHiiBlockToConfig (
547 IN CONST EFI_STRING ConfigRequest
,
548 IN CONST UINT8
*Block
,
553 EFI_STRING ConfigResp
;
556 ASSERT (ConfigRequest
!= NULL
);
557 ASSERT (Block
!= NULL
);
560 // Convert <ConfigRequest> to <ConfigResp>
562 Status
= gHiiConfigRouting
->BlockToConfig (
570 if (EFI_ERROR (Status
)) {
577 Uses the BrowserCallback() service of the Form Browser Protocol to retrieve
578 or set uncommitted data. If sata i being retrieved, then the buffer is
579 allocated using AllocatePool(). The caller is then responsible for freeing
580 the buffer using FreePool().
582 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
583 parameter that may be NULL.
584 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
585 is an optional parameter that may be NULL.
586 @param[in] SetResultsData If not NULL, then this parameter specified the buffer
587 of uncommited data to set. If this parameter is NULL,
588 then the caller is requesting to get the uncommited data
589 from the Form Browser.
591 @retval NULL The uncommitted data could not be retrieved.
592 @retval Other A pointer to a buffer containing the uncommitted data.
597 InternalHiiBrowserCallback (
598 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
599 IN CONST CHAR16
*VariableName
, OPTIONAL
600 IN CONST EFI_STRING SetResultsData OPTIONAL
604 UINTN ResultsDataSize
;
605 EFI_STRING ResultsData
;
606 CHAR16 TempResultsData
;
611 if (mUefiFormBrowser2
== NULL
) {
612 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &mUefiFormBrowser2
);
613 if (EFI_ERROR (Status
) || mUefiFormBrowser2
== NULL
) {
620 if (SetResultsData
!= NULL
) {
622 // Request to to set data in the uncommitted browser state information
624 ResultsData
= SetResultsData
;
627 // Retrieve the length of the buffer required ResultsData from the Browser Callback
629 Status
= mUefiFormBrowser2
->BrowserCallback (
638 if (!EFI_ERROR (Status
)) {
640 // No Resluts Data, only allocate one char for '\0'
642 ResultsData
= AllocateZeroPool (sizeof (CHAR16
));
646 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
651 // Allocate the ResultsData buffer
653 ResultsData
= AllocateZeroPool (ResultsDataSize
);
654 if (ResultsData
== NULL
) {
660 // Retrieve or set the ResultsData from the Browser Callback
662 Status
= mUefiFormBrowser2
->BrowserCallback (
666 (BOOLEAN
)(SetResultsData
== NULL
),
670 if (EFI_ERROR (Status
)) {
678 Allocates and returns a Null-terminated Unicode <ConfigHdr> string using routing
679 information that includes a GUID, an optional Unicode string name, and a device
680 path. The string returned is allocated with AllocatePool(). The caller is
681 responsible for freeing the allocated string with FreePool().
683 The format of a <ConfigHdr> is as follows:
685 GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize<Null>
687 @param[in] Guid Pointer to an EFI_GUID that is the routing information
688 GUID. Each of the 16 bytes in Guid is converted to
689 a 2 Unicode character hexidecimal string. This is
690 an optional parameter that may be NULL.
691 @param[in] Name Pointer to a Null-terminated Unicode string that is
692 the routing information NAME. This is an optional
693 parameter that may be NULL. Each 16-bit Unicode
694 character in Name is converted to a 4 character Unicode
696 @param[in] DriverHandle The driver handle which supports a Device Path Protocol
697 that is the routing information PATH. Each byte of
698 the Device Path associated with DriverHandle is converted
699 to a 2 Unicode character hexidecimal string.
701 @retval NULL DriverHandle does not support the Device Path Protocol.
702 @retval Other A pointer to the Null-terminate Unicode <ConfigHdr> string
707 HiiConstructConfigHdr (
708 IN CONST EFI_GUID
*Guid
, OPTIONAL
709 IN CONST CHAR16
*Name
, OPTIONAL
710 IN EFI_HANDLE DriverHandle
714 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
715 UINTN DevicePathSize
;
717 CHAR16
*ReturnString
;
723 // Compute the length of Name in Unicode characters.
724 // If Name is NULL, then the length is 0.
728 NameLength
= StrLen (Name
);
734 // Retrieve DevicePath Protocol associated with DriverHandle
736 if (DriverHandle
!= NULL
) {
737 DevicePath
= DevicePathFromHandle (DriverHandle
);
738 if (DevicePath
== NULL
) {
742 // Compute the size of the device path in bytes
744 DevicePathSize
= GetDevicePathSize (DevicePath
);
748 // GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize <Null>
749 // | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 |
751 MaxLen
= 5 + sizeof (EFI_GUID
) * 2 + 6 + NameLength
* 4 + 6 + DevicePathSize
* 2 + 1;
752 String
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
753 if (String
== NULL
) {
758 // Start with L"GUID="
760 StrCpyS (String
, MaxLen
, L
"GUID=");
761 ReturnString
= String
;
762 String
+= StrLen (String
);
766 // Append Guid converted to <HexCh>32
768 for (Index
= 0, Buffer
= (UINT8
*)Guid
; Index
< sizeof (EFI_GUID
); Index
++) {
769 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, *(Buffer
++), 2);
776 StrCatS (ReturnString
, MaxLen
, L
"&NAME=");
777 String
+= StrLen (String
);
781 // Append Name converted to <Char>NameLength
783 for (; *Name
!= L
'\0'; Name
++) {
784 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, *Name
, 4);
791 StrCatS (ReturnString
, MaxLen
, L
"&PATH=");
792 String
+= StrLen (String
);
795 // Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize
797 for (Index
= 0, Buffer
= (UINT8
*)DevicePath
; Index
< DevicePathSize
; Index
++) {
798 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, *(Buffer
++), 2);
802 // Null terminate the Unicode string
807 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
809 return InternalHiiLowerConfigString (ReturnString
);
813 Convert the hex UNICODE encoding string of UEFI GUID, NAME or device path
814 to binary buffer from <ConfigHdr>.
816 This is a internal function.
818 @param String UEFI configuration string.
819 @param Flag Flag specifies what type buffer will be retrieved.
820 @param Buffer Binary of Guid, Name or Device path.
822 @retval EFI_INVALID_PARAMETER Any incoming parameter is invalid.
823 @retval EFI_OUT_OF_RESOURCES Lake of resources to store neccesary structures.
824 @retval EFI_SUCCESS The buffer data is retrieved and translated to
829 InternalHiiGetBufferFromString (
830 IN EFI_STRING String
,
836 EFI_STRING ConfigHdr
;
843 if (String
== NULL
|| Buffer
== NULL
) {
844 return EFI_INVALID_PARAMETER
;
851 // The content between 'GUID', 'NAME', 'PATH' of <ConfigHdr> and '&' of next element
852 // or '\0' (end of configuration string) is the UNICODE %02x bytes encoding string.
854 for (Length
= 0; *String
!= 0 && *String
!= L
'&'; String
++, Length
++);
857 case GUID_CONFIG_STRING_TYPE
:
858 case PATH_CONFIG_STRING_TYPE
:
860 // The data in <ConfigHdr> is encoded as hex UNICODE %02x bytes in the same order
861 // as the device path and Guid resides in RAM memory.
862 // Translate the data into binary.
864 DataBuffer
= (UINT8
*) AllocateZeroPool ((Length
+ 1) / 2);
865 if (DataBuffer
== NULL
) {
866 return EFI_OUT_OF_RESOURCES
;
869 // Convert binary byte one by one
871 ZeroMem (TemStr
, sizeof (TemStr
));
872 for (Index
= 0; Index
< Length
; Index
++) {
873 TemStr
[0] = ConfigHdr
[Index
];
874 DigitUint8
= (UINT8
) StrHexToUint64 (TemStr
);
875 if ((Index
& 1) == 0) {
876 DataBuffer
[Index
/2] = DigitUint8
;
878 DataBuffer
[Index
/2] = (UINT8
) ((DataBuffer
[Index
/2] << 4) + DigitUint8
);
882 *Buffer
= DataBuffer
;
885 case NAME_CONFIG_STRING_TYPE
:
887 // Convert Config String to Unicode String, e.g. "0041004200430044" => "ABCD"
891 // Add the tailling char L'\0'
893 DataBuffer
= (UINT8
*) AllocateZeroPool ((Length
/4 + 1) * sizeof (CHAR16
));
894 if (DataBuffer
== NULL
) {
895 return EFI_OUT_OF_RESOURCES
;
898 // Convert character one by one
900 StringPtr
= (CHAR16
*) DataBuffer
;
901 ZeroMem (TemStr
, sizeof (TemStr
));
902 for (Index
= 0; Index
< Length
; Index
+= 4) {
903 StrnCpyS (TemStr
, sizeof (TemStr
) / sizeof (CHAR16
), ConfigHdr
+ Index
, 4);
904 StringPtr
[Index
/4] = (CHAR16
) StrHexToUint64 (TemStr
);
907 // Add tailing L'\0' character
909 StringPtr
[Index
/4] = L
'\0';
911 *Buffer
= DataBuffer
;
915 return EFI_INVALID_PARAMETER
;
922 This function checks VarOffset and VarWidth is in the block range.
924 @param BlockArray The block array is to be checked.
925 @param VarOffset Offset of var to the structure
926 @param VarWidth Width of var.
928 @retval TRUE This Var is in the block range.
929 @retval FALSE This Var is not in the block range.
933 IN IFR_BLOCK_DATA
*BlockArray
,
939 IFR_BLOCK_DATA
*BlockData
;
942 // No Request Block array, all vars are got.
944 if (BlockArray
== NULL
) {
949 // Check the input var is in the request block range.
951 for (Link
= BlockArray
->Entry
.ForwardLink
; Link
!= &BlockArray
->Entry
; Link
= Link
->ForwardLink
) {
952 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
953 if ((VarOffset
>= BlockData
->Offset
) && ((VarOffset
+ VarWidth
) <= (BlockData
->Offset
+ BlockData
->Width
))) {
962 Get the value of <Number> in <BlockConfig> format, i.e. the value of OFFSET
964 <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE'=<Number>
966 @param ValueString String in <BlockConfig> format and points to the
967 first character of <Number>.
968 @param ValueData The output value. Caller takes the responsibility
970 @param ValueLength Length of the <Number>, in characters.
972 @retval EFI_OUT_OF_RESOURCES Insufficient resources to store neccessary
974 @retval EFI_SUCCESS Value of <Number> is outputted in Number
980 InternalHiiGetValueOfNumber (
981 IN EFI_STRING ValueString
,
982 OUT UINT8
**ValueData
,
983 OUT UINTN
*ValueLength
986 EFI_STRING StringPtr
;
993 ASSERT (ValueString
!= NULL
&& ValueData
!= NULL
&& ValueLength
!= NULL
);
994 ASSERT (*ValueString
!= L
'\0');
997 // Get the length of value string
999 StringPtr
= ValueString
;
1000 while (*StringPtr
!= L
'\0' && *StringPtr
!= L
'&') {
1003 Length
= StringPtr
- ValueString
;
1006 // Allocate buffer to store the value
1008 Buf
= (UINT8
*) AllocateZeroPool ((Length
+ 1) / 2);
1010 return EFI_OUT_OF_RESOURCES
;
1014 // Convert character one by one to the value buffer
1016 ZeroMem (TemStr
, sizeof (TemStr
));
1017 for (Index
= 0; Index
< Length
; Index
++) {
1018 TemStr
[0] = ValueString
[Length
- Index
- 1];
1019 DigitUint8
= (UINT8
) StrHexToUint64 (TemStr
);
1020 if ((Index
& 1) == 0) {
1021 Buf
[Index
/2] = DigitUint8
;
1023 Buf
[Index
/2] = (UINT8
) ((DigitUint8
<< 4) + Buf
[Index
/2]);
1028 // Set the converted value and string length.
1031 *ValueLength
= Length
;
1036 Get value from config request resp string.
1038 @param ConfigElement ConfigResp string contains the current setting.
1039 @param VarName The variable name which need to get value.
1040 @param VarValue The return value.
1042 @retval EFI_SUCCESS Get the value for the VarName
1043 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1046 GetValueFromRequest (
1047 IN CHAR16
*ConfigElement
,
1049 OUT UINT64
*VarValue
1058 // Find VarName related string.
1060 StringPtr
= StrStr (ConfigElement
, VarName
);
1061 ASSERT (StringPtr
!= NULL
);
1064 // Skip the "VarName=" string
1066 StringPtr
+= StrLen (VarName
) + 1;
1071 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1072 if (EFI_ERROR (Status
)) {
1077 CopyMem (VarValue
, TmpBuffer
, (((Length
+ 1) / 2) < sizeof (UINT64
)) ? ((Length
+ 1) / 2) : sizeof (UINT64
));
1079 FreePool (TmpBuffer
);
1085 This internal function parses IFR data to validate current setting.
1087 Base on the NameValueType, if it is TRUE, RequestElement and HiiHandle is valid;
1088 else the VarBuffer and CurrentBlockArray is valid.
1090 @param HiiPackageList Point to Hii package list.
1091 @param PackageListLength The length of the pacakge.
1092 @param VarGuid Guid of the buffer storage.
1093 @param VarName Name of the buffer storage.
1094 @param VarBuffer The data buffer for the storage.
1095 @param CurrentBlockArray The block array from the config Requst string.
1096 @param RequestElement The config string for this storage.
1097 @param HiiHandle The HiiHandle for this formset.
1098 @param NameValueType Whether current storage is name/value varstore or not.
1100 @retval EFI_SUCCESS The current setting is valid.
1101 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1102 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1105 ValidateQuestionFromVfr (
1106 IN EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
,
1107 IN UINTN PackageListLength
,
1108 IN EFI_GUID
*VarGuid
,
1110 IN UINT8
*VarBuffer
,
1111 IN IFR_BLOCK_DATA
*CurrentBlockArray
,
1112 IN CHAR16
*RequestElement
,
1113 IN EFI_HII_HANDLE HiiHandle
,
1114 IN BOOLEAN NameValueType
1117 IFR_BLOCK_DATA VarBlockData
;
1121 EFI_IFR_TYPE_VALUE TmpValue
;
1123 EFI_HII_PACKAGE_HEADER PacakgeHeader
;
1124 UINT32 PackageOffset
;
1127 EFI_IFR_OP_HEADER
*IfrOpHdr
;
1128 EFI_IFR_VARSTORE
*IfrVarStore
;
1129 EFI_IFR_VARSTORE_NAME_VALUE
*IfrNameValueStore
;
1130 EFI_IFR_VARSTORE_EFI
*IfrEfiVarStore
;
1131 IFR_VARSTORAGE_DATA VarStoreData
;
1132 EFI_IFR_ONE_OF
*IfrOneOf
;
1133 EFI_IFR_NUMERIC
*IfrNumeric
;
1134 EFI_IFR_ONE_OF_OPTION
*IfrOneOfOption
;
1135 EFI_IFR_CHECKBOX
*IfrCheckBox
;
1136 EFI_IFR_STRING
*IfrString
;
1137 CHAR8
*VarStoreName
;
1139 CHAR16
*QuestionName
;
1143 // Initialize the local variables.
1146 VarStoreName
= NULL
;
1147 Status
= EFI_SUCCESS
;
1150 IfrNameValueStore
= NULL
;
1151 IfrEfiVarStore
= NULL
;
1152 ZeroMem (&VarStoreData
, sizeof (IFR_VARSTORAGE_DATA
));
1153 ZeroMem (&VarBlockData
, sizeof (VarBlockData
));
1156 // Check IFR value is in block data, then Validate Value
1158 PackageOffset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
1159 while (PackageOffset
< PackageListLength
) {
1160 CopyMem (&PacakgeHeader
, (UINT8
*) HiiPackageList
+ PackageOffset
, sizeof (PacakgeHeader
));
1163 // Parse IFR opcode from the form package.
1165 if (PacakgeHeader
.Type
== EFI_HII_PACKAGE_FORMS
) {
1166 IfrOffset
= sizeof (PacakgeHeader
);
1167 PackageData
= (UINT8
*) HiiPackageList
+ PackageOffset
;
1168 while (IfrOffset
< PacakgeHeader
.Length
) {
1169 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) (PackageData
+ IfrOffset
);
1171 // Validate current setting to the value built in IFR opcode
1173 switch (IfrOpHdr
->OpCode
) {
1174 case EFI_IFR_VARSTORE_OP
:
1176 // VarStoreId has been found. No further found.
1178 if (VarStoreData
.VarStoreId
!= 0) {
1182 // Find the matched VarStoreId to the input VarGuid and VarName
1184 IfrVarStore
= (EFI_IFR_VARSTORE
*) IfrOpHdr
;
1185 if (CompareGuid ((EFI_GUID
*) (VOID
*) &IfrVarStore
->Guid
, VarGuid
)) {
1186 VarStoreName
= (CHAR8
*) IfrVarStore
->Name
;
1187 for (Index
= 0; VarStoreName
[Index
] != 0; Index
++) {
1188 if ((CHAR16
) VarStoreName
[Index
] != VarName
[Index
]) {
1193 // The matched VarStore is found.
1195 if ((VarStoreName
[Index
] != 0) || (VarName
[Index
] != 0)) {
1202 if (IfrVarStore
!= NULL
) {
1203 VarStoreData
.VarStoreId
= IfrVarStore
->VarStoreId
;
1204 VarStoreData
.Size
= IfrVarStore
->Size
;
1207 case EFI_IFR_VARSTORE_NAME_VALUE_OP
:
1209 // VarStoreId has been found. No further found.
1211 if (VarStoreData
.VarStoreId
!= 0) {
1215 // Find the matched VarStoreId to the input VarGuid
1217 IfrNameValueStore
= (EFI_IFR_VARSTORE_NAME_VALUE
*) IfrOpHdr
;
1218 if (!CompareGuid ((EFI_GUID
*) (VOID
*) &IfrNameValueStore
->Guid
, VarGuid
)) {
1219 IfrNameValueStore
= NULL
;
1222 if (IfrNameValueStore
!= NULL
) {
1223 VarStoreData
.VarStoreId
= IfrNameValueStore
->VarStoreId
;
1226 case EFI_IFR_VARSTORE_EFI_OP
:
1228 // VarStore is found. Don't need to search any more.
1230 if (VarStoreData
.VarStoreId
!= 0) {
1234 IfrEfiVarStore
= (EFI_IFR_VARSTORE_EFI
*) IfrOpHdr
;
1237 // If the length is small than the structure, this is from old efi
1238 // varstore definition. Old efi varstore get config directly from
1239 // GetVariable function.
1241 if (IfrOpHdr
->Length
< sizeof (EFI_IFR_VARSTORE_EFI
)) {
1245 if (CompareGuid ((EFI_GUID
*) (VOID
*) &IfrEfiVarStore
->Guid
, VarGuid
)) {
1246 VarStoreName
= (CHAR8
*) IfrEfiVarStore
->Name
;
1247 for (Index
= 0; VarStoreName
[Index
] != 0; Index
++) {
1248 if ((CHAR16
) VarStoreName
[Index
] != VarName
[Index
]) {
1253 // The matched VarStore is found.
1255 if ((VarStoreName
[Index
] != 0) || (VarName
[Index
] != 0)) {
1256 IfrEfiVarStore
= NULL
;
1259 IfrEfiVarStore
= NULL
;
1262 if (IfrEfiVarStore
!= NULL
) {
1264 // Find the matched VarStore
1266 VarStoreData
.VarStoreId
= IfrEfiVarStore
->VarStoreId
;
1267 VarStoreData
.Size
= IfrEfiVarStore
->Size
;
1270 case EFI_IFR_FORM_OP
:
1271 case EFI_IFR_FORM_MAP_OP
:
1273 // Check the matched VarStoreId is found.
1275 if (VarStoreData
.VarStoreId
== 0) {
1279 case EFI_IFR_ONE_OF_OP
:
1281 // Check whether current value is the one of option.
1285 // OneOf question is not in IFR Form. This IFR form is not valid.
1287 if (VarStoreData
.VarStoreId
== 0) {
1288 return EFI_INVALID_PARAMETER
;
1291 // Check whether this question is for the requested varstore.
1293 IfrOneOf
= (EFI_IFR_ONE_OF
*) IfrOpHdr
;
1294 if (IfrOneOf
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1298 if (NameValueType
) {
1299 QuestionName
= HiiGetString (HiiHandle
, IfrOneOf
->Question
.VarStoreInfo
.VarName
, NULL
);
1300 ASSERT (QuestionName
!= NULL
);
1302 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1304 // This question is not in the current configuration string. Skip it.
1309 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1310 if (EFI_ERROR (Status
)) {
1315 // Get Offset by Question header and Width by DataType Flags
1317 Offset
= IfrOneOf
->Question
.VarStoreInfo
.VarOffset
;
1318 Width
= (UINT16
) (1 << (IfrOneOf
->Flags
& EFI_IFR_NUMERIC_SIZE
));
1320 // Check whether this question is in current block array.
1322 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1324 // This question is not in the current configuration string. Skip it.
1329 // Check this var question is in the var storage
1331 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1333 // This question exceeds the var store size.
1335 return EFI_INVALID_PARAMETER
;
1339 // Get the current value for oneof opcode
1342 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1345 // Set Block Data, to be checked in the following Oneof option opcode.
1347 VarBlockData
.OpCode
= IfrOpHdr
->OpCode
;
1348 VarBlockData
.Scope
= IfrOpHdr
->Scope
;
1350 case EFI_IFR_NUMERIC_OP
:
1352 // Check the current value is in the numeric range.
1356 // Numeric question is not in IFR Form. This IFR form is not valid.
1358 if (VarStoreData
.VarStoreId
== 0) {
1359 return EFI_INVALID_PARAMETER
;
1362 // Check whether this question is for the requested varstore.
1364 IfrNumeric
= (EFI_IFR_NUMERIC
*) IfrOpHdr
;
1365 if (IfrNumeric
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1369 if (NameValueType
) {
1370 QuestionName
= HiiGetString (HiiHandle
, IfrNumeric
->Question
.VarStoreInfo
.VarName
, NULL
);
1371 ASSERT (QuestionName
!= NULL
);
1373 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1375 // This question is not in the current configuration string. Skip it.
1380 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1381 if (EFI_ERROR (Status
)) {
1386 // Get Offset by Question header and Width by DataType Flags
1388 Offset
= IfrNumeric
->Question
.VarStoreInfo
.VarOffset
;
1389 Width
= (UINT16
) (1 << (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
));
1391 // Check whether this question is in current block array.
1393 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1395 // This question is not in the current configuration string. Skip it.
1400 // Check this var question is in the var storage
1402 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1404 // This question exceeds the var store size.
1406 return EFI_INVALID_PARAMETER
;
1410 // Check the current value is in the numeric range.
1413 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1415 if ((IfrNumeric
->Flags
& EFI_IFR_DISPLAY
) == 0) {
1416 switch (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1417 case EFI_IFR_NUMERIC_SIZE_1
:
1418 if ((INT8
) VarValue
< (INT8
) IfrNumeric
->data
.u8
.MinValue
|| (INT8
) VarValue
> (INT8
) IfrNumeric
->data
.u8
.MaxValue
) {
1420 // Not in the valid range.
1422 return EFI_INVALID_PARAMETER
;
1425 case EFI_IFR_NUMERIC_SIZE_2
:
1426 if ((INT16
) VarValue
< (INT16
) IfrNumeric
->data
.u16
.MinValue
|| (INT16
) VarValue
> (INT16
) IfrNumeric
->data
.u16
.MaxValue
) {
1428 // Not in the valid range.
1430 return EFI_INVALID_PARAMETER
;
1433 case EFI_IFR_NUMERIC_SIZE_4
:
1434 if ((INT32
) VarValue
< (INT32
) IfrNumeric
->data
.u32
.MinValue
|| (INT32
) VarValue
> (INT32
) IfrNumeric
->data
.u32
.MaxValue
) {
1436 // Not in the valid range.
1438 return EFI_INVALID_PARAMETER
;
1441 case EFI_IFR_NUMERIC_SIZE_8
:
1442 if ((INT64
) VarValue
< (INT64
) IfrNumeric
->data
.u64
.MinValue
|| (INT64
) VarValue
> (INT64
) IfrNumeric
->data
.u64
.MaxValue
) {
1444 // Not in the valid range.
1446 return EFI_INVALID_PARAMETER
;
1451 switch (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1452 case EFI_IFR_NUMERIC_SIZE_1
:
1453 if ((UINT8
) VarValue
< IfrNumeric
->data
.u8
.MinValue
|| (UINT8
) VarValue
> IfrNumeric
->data
.u8
.MaxValue
) {
1455 // Not in the valid range.
1457 return EFI_INVALID_PARAMETER
;
1460 case EFI_IFR_NUMERIC_SIZE_2
:
1461 if ((UINT16
) VarValue
< IfrNumeric
->data
.u16
.MinValue
|| (UINT16
) VarValue
> IfrNumeric
->data
.u16
.MaxValue
) {
1463 // Not in the valid range.
1465 return EFI_INVALID_PARAMETER
;
1468 case EFI_IFR_NUMERIC_SIZE_4
:
1469 if ((UINT32
) VarValue
< IfrNumeric
->data
.u32
.MinValue
|| (UINT32
) VarValue
> IfrNumeric
->data
.u32
.MaxValue
) {
1471 // Not in the valid range.
1473 return EFI_INVALID_PARAMETER
;
1476 case EFI_IFR_NUMERIC_SIZE_8
:
1477 if ((UINT64
) VarValue
< IfrNumeric
->data
.u64
.MinValue
|| (UINT64
) VarValue
> IfrNumeric
->data
.u64
.MaxValue
) {
1479 // Not in the valid range.
1481 return EFI_INVALID_PARAMETER
;
1487 case EFI_IFR_CHECKBOX_OP
:
1489 // Check value is BOOLEAN type, only 0 and 1 is valid.
1493 // CheckBox question is not in IFR Form. This IFR form is not valid.
1495 if (VarStoreData
.VarStoreId
== 0) {
1496 return EFI_INVALID_PARAMETER
;
1500 // Check whether this question is for the requested varstore.
1502 IfrCheckBox
= (EFI_IFR_CHECKBOX
*) IfrOpHdr
;
1503 if (IfrCheckBox
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1507 if (NameValueType
) {
1508 QuestionName
= HiiGetString (HiiHandle
, IfrCheckBox
->Question
.VarStoreInfo
.VarName
, NULL
);
1509 ASSERT (QuestionName
!= NULL
);
1511 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1513 // This question is not in the current configuration string. Skip it.
1518 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1519 if (EFI_ERROR (Status
)) {
1524 // Get Offset by Question header
1526 Offset
= IfrCheckBox
->Question
.VarStoreInfo
.VarOffset
;
1527 Width
= (UINT16
) sizeof (BOOLEAN
);
1529 // Check whether this question is in current block array.
1531 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1533 // This question is not in the current configuration string. Skip it.
1538 // Check this var question is in the var storage
1540 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1542 // This question exceeds the var store size.
1544 return EFI_INVALID_PARAMETER
;
1547 // Check the current value is in the numeric range.
1550 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1553 // Boolean type, only 1 and 0 is valid.
1556 return EFI_INVALID_PARAMETER
;
1559 case EFI_IFR_STRING_OP
:
1561 // Check current string length is less than maxsize
1565 // CheckBox question is not in IFR Form. This IFR form is not valid.
1567 if (VarStoreData
.VarStoreId
== 0) {
1568 return EFI_INVALID_PARAMETER
;
1572 // Check whether this question is for the requested varstore.
1574 IfrString
= (EFI_IFR_STRING
*) IfrOpHdr
;
1575 if (IfrString
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1579 // Get Width by OneOf Flags
1581 Width
= (UINT16
) (IfrString
->MaxSize
* sizeof (UINT16
));
1582 if (NameValueType
) {
1583 QuestionName
= HiiGetString (HiiHandle
, IfrString
->Question
.VarStoreInfo
.VarName
, NULL
);
1584 ASSERT (QuestionName
!= NULL
);
1586 StringPtr
= StrStr (RequestElement
, QuestionName
);
1587 if (StringPtr
== NULL
) {
1589 // This question is not in the current configuration string. Skip it.
1600 // Check current string length is less than maxsize
1602 if (StrSize (StringPtr
) > Width
) {
1603 return EFI_INVALID_PARAMETER
;
1607 // Get Offset/Width by Question header and OneOf Flags
1609 Offset
= IfrString
->Question
.VarStoreInfo
.VarOffset
;
1611 // Check whether this question is in current block array.
1613 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1615 // This question is not in the current configuration string. Skip it.
1620 // Check this var question is in the var storage
1622 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1624 // This question exceeds the var store size.
1626 return EFI_INVALID_PARAMETER
;
1630 // Check current string length is less than maxsize
1632 if (StrSize ((CHAR16
*) (VarBuffer
+ Offset
)) > Width
) {
1633 return EFI_INVALID_PARAMETER
;
1637 case EFI_IFR_ONE_OF_OPTION_OP
:
1639 // Opcode Scope is zero. This one of option is not to be checked.
1641 if (VarBlockData
.Scope
== 0) {
1646 // Only check for OneOf and OrderList opcode
1648 IfrOneOfOption
= (EFI_IFR_ONE_OF_OPTION
*) IfrOpHdr
;
1649 if (VarBlockData
.OpCode
== EFI_IFR_ONE_OF_OP
) {
1651 // Check current value is the value of one of option.
1653 ASSERT (IfrOneOfOption
->Type
<= EFI_IFR_TYPE_NUM_SIZE_64
);
1654 ZeroMem (&TmpValue
, sizeof (EFI_IFR_TYPE_VALUE
));
1655 CopyMem (&TmpValue
, &IfrOneOfOption
->Value
, IfrOneOfOption
->Header
.Length
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
1656 if (VarValue
== TmpValue
.u64
) {
1658 // The value is one of option value.
1659 // Set OpCode to Zero, don't need check again.
1661 VarBlockData
.OpCode
= 0;
1665 case EFI_IFR_END_OP
:
1667 // Decrease opcode scope for the validated opcode
1669 if (VarBlockData
.Scope
> 0) {
1670 VarBlockData
.Scope
--;
1674 // OneOf value doesn't belong to one of option value.
1676 if ((VarBlockData
.Scope
== 0) && (VarBlockData
.OpCode
== EFI_IFR_ONE_OF_OP
)) {
1677 return EFI_INVALID_PARAMETER
;
1682 // Increase Scope for the validated opcode
1684 if (VarBlockData
.Scope
> 0) {
1685 VarBlockData
.Scope
= (UINT8
) (VarBlockData
.Scope
+ IfrOpHdr
->Scope
);
1690 // Go to the next opcode
1692 IfrOffset
+= IfrOpHdr
->Length
;
1695 // Only one form is in a package list.
1701 // Go to next package.
1703 PackageOffset
+= PacakgeHeader
.Length
;
1710 This internal function parses IFR data to validate current setting.
1712 @param ConfigElement ConfigResp element string contains the current setting.
1713 @param CurrentBlockArray Current block array.
1714 @param VarBuffer Data buffer for this varstore.
1716 @retval EFI_SUCCESS The current setting is valid.
1717 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1718 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1722 IN CHAR16
*ConfigElement
,
1723 OUT IFR_BLOCK_DATA
**CurrentBlockArray
,
1724 OUT UINT8
**VarBuffer
1727 IFR_BLOCK_DATA
*BlockData
;
1728 IFR_BLOCK_DATA
*NewBlockData
;
1729 EFI_STRING StringPtr
;
1735 UINTN MaxBufferSize
;
1737 IFR_BLOCK_DATA
*BlockArray
;
1741 // Initialize the local variables.
1743 Status
= EFI_SUCCESS
;
1745 NewBlockData
= NULL
;
1748 MaxBufferSize
= HII_LIB_DEFAULT_VARSTORE_SIZE
;
1749 DataBuffer
= AllocateZeroPool (MaxBufferSize
);
1750 if (DataBuffer
== NULL
) {
1751 return EFI_OUT_OF_RESOURCES
;
1757 BlockArray
= (IFR_BLOCK_DATA
*) AllocateZeroPool (sizeof (IFR_BLOCK_DATA
));
1758 if (BlockArray
== NULL
) {
1759 Status
= EFI_OUT_OF_RESOURCES
;
1762 InitializeListHead (&BlockArray
->Entry
);
1764 StringPtr
= StrStr (ConfigElement
, L
"&OFFSET=");
1765 ASSERT (StringPtr
!= NULL
);
1768 // Parse each <RequestElement> if exists
1769 // Only <BlockName> format is supported by this help function.
1770 // <BlockName> ::= &'OFFSET='<Number>&'WIDTH='<Number>
1772 while (*StringPtr
!= 0 && StrnCmp (StringPtr
, L
"&OFFSET=", StrLen (L
"&OFFSET=")) == 0) {
1774 // Skip the &OFFSET= string
1776 StringPtr
+= StrLen (L
"&OFFSET=");
1781 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1782 if (EFI_ERROR (Status
)) {
1789 (((Length
+ 1) / 2) < sizeof (UINT16
)) ? ((Length
+ 1) / 2) : sizeof (UINT16
)
1791 FreePool (TmpBuffer
);
1794 StringPtr
+= Length
;
1795 if (StrnCmp (StringPtr
, L
"&WIDTH=", StrLen (L
"&WIDTH=")) != 0) {
1796 Status
= EFI_INVALID_PARAMETER
;
1799 StringPtr
+= StrLen (L
"&WIDTH=");
1804 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1805 if (EFI_ERROR (Status
)) {
1812 (((Length
+ 1) / 2) < sizeof (UINT16
)) ? ((Length
+ 1) / 2) : sizeof (UINT16
)
1814 FreePool (TmpBuffer
);
1817 StringPtr
+= Length
;
1818 if (*StringPtr
!= 0 && *StringPtr
!= L
'&') {
1819 Status
= EFI_INVALID_PARAMETER
;
1823 if (StrnCmp (StringPtr
, L
"&VALUE=", StrLen (L
"&VALUE=")) != 0) {
1824 Status
= EFI_INVALID_PARAMETER
;
1827 StringPtr
+= StrLen (L
"&VALUE=");
1832 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1833 if (EFI_ERROR (Status
)) {
1837 StringPtr
+= Length
;
1838 if (*StringPtr
!= 0 && *StringPtr
!= L
'&') {
1839 Status
= EFI_INVALID_PARAMETER
;
1844 // Check whether VarBuffer is enough
1846 if ((UINTN
) (Offset
+ Width
) > MaxBufferSize
) {
1847 DataBuffer
= ReallocatePool (
1849 Offset
+ Width
+ HII_LIB_DEFAULT_VARSTORE_SIZE
,
1852 if (DataBuffer
== NULL
) {
1853 Status
= EFI_OUT_OF_RESOURCES
;
1856 MaxBufferSize
= Offset
+ Width
+ HII_LIB_DEFAULT_VARSTORE_SIZE
;
1860 // Update the Block with configuration info
1862 CopyMem (DataBuffer
+ Offset
, TmpBuffer
, Width
);
1863 FreePool (TmpBuffer
);
1867 // Set new Block Data
1869 NewBlockData
= (IFR_BLOCK_DATA
*) AllocateZeroPool (sizeof (IFR_BLOCK_DATA
));
1870 if (NewBlockData
== NULL
) {
1871 Status
= EFI_OUT_OF_RESOURCES
;
1874 NewBlockData
->Offset
= Offset
;
1875 NewBlockData
->Width
= Width
;
1878 // Insert the new block data into the block data array.
1880 for (Link
= BlockArray
->Entry
.ForwardLink
; Link
!= &BlockArray
->Entry
; Link
= Link
->ForwardLink
) {
1881 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
1882 if (NewBlockData
->Offset
== BlockData
->Offset
) {
1883 if (NewBlockData
->Width
> BlockData
->Width
) {
1884 BlockData
->Width
= NewBlockData
->Width
;
1886 FreePool (NewBlockData
);
1888 } else if (NewBlockData
->Offset
< BlockData
->Offset
) {
1890 // Insert new block data as the previous one of this link.
1892 InsertTailList (Link
, &NewBlockData
->Entry
);
1898 // Insert new block data into the array tail.
1900 if (Link
== &BlockArray
->Entry
) {
1901 InsertTailList (Link
, &NewBlockData
->Entry
);
1905 // If '\0', parsing is finished.
1907 if (*StringPtr
== 0) {
1911 // Go to next ConfigBlock
1916 // Merge the aligned block data into the single block data.
1918 Link
= BlockArray
->Entry
.ForwardLink
;
1919 while ((Link
!= &BlockArray
->Entry
) && (Link
->ForwardLink
!= &BlockArray
->Entry
)) {
1920 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
1921 NewBlockData
= BASE_CR (Link
->ForwardLink
, IFR_BLOCK_DATA
, Entry
);
1922 if ((NewBlockData
->Offset
>= BlockData
->Offset
) && (NewBlockData
->Offset
<= (BlockData
->Offset
+ BlockData
->Width
))) {
1923 if ((NewBlockData
->Offset
+ NewBlockData
->Width
) > (BlockData
->Offset
+ BlockData
->Width
)) {
1924 BlockData
->Width
= (UINT16
) (NewBlockData
->Offset
+ NewBlockData
->Width
- BlockData
->Offset
);
1926 RemoveEntryList (Link
->ForwardLink
);
1927 FreePool (NewBlockData
);
1930 Link
= Link
->ForwardLink
;
1933 *VarBuffer
= DataBuffer
;
1934 *CurrentBlockArray
= BlockArray
;
1938 if (DataBuffer
!= NULL
) {
1939 FreePool (DataBuffer
);
1942 if (BlockArray
!= NULL
) {
1944 // Free Link Array CurrentBlockArray
1946 while (!IsListEmpty (&BlockArray
->Entry
)) {
1947 BlockData
= BASE_CR (BlockArray
->Entry
.ForwardLink
, IFR_BLOCK_DATA
, Entry
);
1948 RemoveEntryList (&BlockData
->Entry
);
1949 FreePool (BlockData
);
1951 FreePool (BlockArray
);
1958 This internal function parses IFR data to validate current setting.
1960 @param ConfigResp ConfigResp string contains the current setting.
1961 @param HiiPackageList Point to Hii package list.
1962 @param PackageListLength The length of the pacakge.
1963 @param VarGuid Guid of the buffer storage.
1964 @param VarName Name of the buffer storage.
1965 @param HiiHandle The HiiHandle for this package.
1967 @retval EFI_SUCCESS The current setting is valid.
1968 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1969 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1973 InternalHiiValidateCurrentSetting (
1974 IN EFI_STRING ConfigResp
,
1975 IN EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
,
1976 IN UINTN PackageListLength
,
1977 IN EFI_GUID
*VarGuid
,
1979 IN EFI_HII_HANDLE HiiHandle
1984 IFR_BLOCK_DATA
*CurrentBlockArray
;
1985 IFR_BLOCK_DATA
*BlockData
;
1987 BOOLEAN NameValueType
;
1989 CurrentBlockArray
= NULL
;
1992 Status
= EFI_SUCCESS
;
1995 // If StringPtr != NULL, get the request elements.
1997 if (StrStr (ConfigResp
, L
"&OFFSET=") != NULL
) {
1998 Status
= GetBlockDataInfo(ConfigResp
, &CurrentBlockArray
, &VarBuffer
);
1999 if (EFI_ERROR (Status
)) {
2002 NameValueType
= FALSE
;
2005 // Skip header part.
2007 StringPtr
= StrStr (ConfigResp
, L
"PATH=");
2008 ASSERT (StringPtr
!= NULL
);
2010 if (StrStr (StringPtr
, L
"&") != NULL
) {
2011 NameValueType
= TRUE
;
2014 // Not found Request element, return success.
2020 Status
= ValidateQuestionFromVfr(
2032 if (VarBuffer
!= NULL
) {
2033 FreePool (VarBuffer
);
2036 if (CurrentBlockArray
!= NULL
) {
2038 // Free Link Array CurrentBlockArray
2040 while (!IsListEmpty (&CurrentBlockArray
->Entry
)) {
2041 BlockData
= BASE_CR (CurrentBlockArray
->Entry
.ForwardLink
, IFR_BLOCK_DATA
, Entry
);
2042 RemoveEntryList (&BlockData
->Entry
);
2043 FreePool (BlockData
);
2045 FreePool (CurrentBlockArray
);
2052 Check whether the ConfigRequest string has the request elements.
2053 For EFI_HII_VARSTORE_BUFFER type, the request has "&OFFSET=****&WIDTH=****..." format.
2054 For EFI_HII_VARSTORE_NAME_VALUE type, the request has "&NAME1**&NAME2..." format.
2056 @param ConfigRequest The input config request string.
2058 @retval TRUE The input include config request elements.
2059 @retval FALSE The input string not includes.
2063 GetElementsFromRequest (
2064 IN EFI_STRING ConfigRequest
2067 EFI_STRING TmpRequest
;
2069 TmpRequest
= StrStr (ConfigRequest
, L
"PATH=");
2070 ASSERT (TmpRequest
!= NULL
);
2072 if ((StrStr (TmpRequest
, L
"&OFFSET=") != NULL
) || (StrStr (TmpRequest
, L
"&") != NULL
)) {
2080 This function parses the input ConfigRequest string and its matched IFR code
2081 string for setting default value and validating current setting.
2083 1. For setting default action, Reset the default value specified by DefaultId
2084 to the driver configuration got by Request string.
2085 2. For validating current setting, Validate the current configuration
2086 by parsing HII form IFR opcode.
2088 NULL request string support depends on the ExportConfig interface of
2089 HiiConfigRouting protocol in UEFI specification.
2091 @param Request A null-terminated Unicode string in
2092 <MultiConfigRequest> format. It can be NULL.
2093 If it is NULL, all current configuration for the
2094 entirety of the current HII database will be validated.
2095 If it is NULL, all configuration for the
2096 entirety of the current HII database will be reset.
2097 @param DefaultId Specifies the type of defaults to retrieve only for setting default action.
2098 @param ActionType Action supports setting defaults and validate current setting.
2100 @retval TURE Action runs successfully.
2101 @retval FALSE Action is not valid or Action can't be executed successfully..
2105 InternalHiiIfrValueAction (
2106 IN CONST EFI_STRING Request
, OPTIONAL
2107 IN UINT16 DefaultId
,
2111 EFI_STRING ConfigAltResp
;
2112 EFI_STRING ConfigAltHdr
;
2113 EFI_STRING ConfigResp
;
2114 EFI_STRING Progress
;
2115 EFI_STRING StringPtr
;
2116 EFI_STRING StringHdr
;
2118 EFI_HANDLE DriverHandle
;
2119 EFI_HANDLE TempDriverHandle
;
2120 EFI_HII_HANDLE
*HiiHandleBuffer
;
2121 EFI_HII_HANDLE HiiHandle
;
2126 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
2127 UINTN PackageListLength
;
2129 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2130 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
2132 ConfigAltResp
= NULL
;
2137 ConfigAltHdr
= NULL
;
2138 HiiHandleBuffer
= NULL
;
2140 TempDriverHandle
= NULL
;
2142 HiiPackageList
= NULL
;
2145 // Only support set default and validate setting action.
2147 if ((ActionType
!= ACTION_SET_DEFAUTL_VALUE
) && (ActionType
!= ACTION_VALIDATE_SETTING
)) {
2152 // Get the full requested value and deault value string.
2154 if (Request
!= NULL
) {
2155 Status
= gHiiConfigRouting
->ExtractConfig (
2162 Status
= gHiiConfigRouting
->ExportConfig (
2168 if (EFI_ERROR (Status
)) {
2172 StringPtr
= ConfigAltResp
;
2174 while (StringPtr
!= L
'\0') {
2176 // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
2178 StringHdr
= StringPtr
;
2183 if (StrnCmp (StringPtr
, L
"GUID=", StrLen (L
"GUID=")) != 0) {
2184 Status
= EFI_INVALID_PARAMETER
;
2187 StringPtr
+= StrLen (L
"GUID=");
2188 Status
= InternalHiiGetBufferFromString (StringPtr
, GUID_CONFIG_STRING_TYPE
, (UINT8
**) &VarGuid
);
2189 if (EFI_ERROR (Status
)) {
2194 // Get Name value VarName
2196 while (*StringPtr
!= L
'\0' && StrnCmp (StringPtr
, L
"&NAME=", StrLen (L
"&NAME=")) != 0) {
2199 if (*StringPtr
== L
'\0') {
2200 Status
= EFI_INVALID_PARAMETER
;
2203 StringPtr
+= StrLen (L
"&NAME=");
2204 Status
= InternalHiiGetBufferFromString (StringPtr
, NAME_CONFIG_STRING_TYPE
, (UINT8
**) &VarName
);
2205 if (EFI_ERROR (Status
)) {
2210 // Get Path value DevicePath
2212 while (*StringPtr
!= L
'\0' && StrnCmp (StringPtr
, L
"&PATH=", StrLen (L
"&PATH=")) != 0) {
2215 if (*StringPtr
== L
'\0') {
2216 Status
= EFI_INVALID_PARAMETER
;
2219 StringPtr
+= StrLen (L
"&PATH=");
2220 Status
= InternalHiiGetBufferFromString (StringPtr
, PATH_CONFIG_STRING_TYPE
, (UINT8
**) &DevicePath
);
2221 if (EFI_ERROR (Status
)) {
2226 // Get the Driver handle by the got device path.
2228 TempDevicePath
= DevicePath
;
2229 Status
= gBS
->LocateDevicePath (&gEfiDevicePathProtocolGuid
, &TempDevicePath
, &DriverHandle
);
2230 if (EFI_ERROR (Status
)) {
2235 // Find the matched Hii Handle for the found Driver handle
2237 HiiHandleBuffer
= HiiGetHiiHandles (NULL
);
2238 if (HiiHandleBuffer
== NULL
) {
2239 Status
= EFI_NOT_FOUND
;
2243 for (Index
= 0; HiiHandleBuffer
[Index
] != NULL
; Index
++) {
2244 gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, HiiHandleBuffer
[Index
], &TempDriverHandle
);
2245 if (TempDriverHandle
== DriverHandle
) {
2250 HiiHandle
= HiiHandleBuffer
[Index
];
2251 FreePool (HiiHandleBuffer
);
2253 if (HiiHandle
== NULL
) {
2255 // This request string has no its Hii package.
2256 // Its default value and validating can't execute by parsing IFR data.
2257 // Directly jump into the next ConfigAltResp string for another pair Guid, Name, and Path.
2259 Status
= EFI_SUCCESS
;
2260 goto NextConfigAltResp
;
2264 // 2. Get HiiPackage by HiiHandle
2266 PackageListLength
= 0;
2267 HiiPackageList
= NULL
;
2268 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &PackageListLength
, HiiPackageList
);
2271 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
2273 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
2274 Status
= EFI_INVALID_PARAMETER
;
2278 HiiPackageList
= AllocatePool (PackageListLength
);
2279 if (HiiPackageList
== NULL
) {
2280 Status
= EFI_OUT_OF_RESOURCES
;
2285 // Get PackageList on HiiHandle
2287 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &PackageListLength
, HiiPackageList
);
2288 if (EFI_ERROR (Status
)) {
2293 // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
2294 // Get the default configuration string according to the default ID.
2296 Status
= gHiiConfigRouting
->GetAltConfig (
2302 (ActionType
== ACTION_SET_DEFAUTL_VALUE
) ? &DefaultId
:NULL
, // it can be NULL to get the current setting.
2307 // The required setting can't be found. So, it is not required to be validated and set.
2309 if (EFI_ERROR (Status
)) {
2310 Status
= EFI_SUCCESS
;
2311 goto NextConfigAltResp
;
2314 // Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set.
2316 if (!GetElementsFromRequest (ConfigResp
)) {
2317 goto NextConfigAltResp
;
2321 // 4. Set the default configuration information or Validate current setting by parse IFR code.
2322 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2324 if (ActionType
== ACTION_SET_DEFAUTL_VALUE
) {
2326 // Set the default configuration information.
2328 Status
= gHiiConfigRouting
->RouteConfig (gHiiConfigRouting
, ConfigResp
, &Progress
);
2331 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2333 Status
= InternalHiiValidateCurrentSetting (ConfigResp
, HiiPackageList
, PackageListLength
, VarGuid
, VarName
, HiiHandle
);
2336 if (EFI_ERROR (Status
)) {
2342 // Free the allocated pacakge buffer and the got ConfigResp string.
2344 if (HiiPackageList
!= NULL
) {
2345 FreePool (HiiPackageList
);
2346 HiiPackageList
= NULL
;
2349 if (ConfigResp
!= NULL
) {
2350 FreePool (ConfigResp
);
2355 // Free the allocated buffer.
2363 FreePool (DevicePath
);
2367 // 5. Jump to next ConfigAltResp for another Guid, Name, Path.
2371 // Get and Skip ConfigHdr
2373 while (*StringPtr
!= L
'\0' && *StringPtr
!= L
'&') {
2376 if (*StringPtr
== L
'\0') {
2381 // Construct ConfigAltHdr string "&<ConfigHdr>&ALTCFG=\0"
2382 // | 1 | StrLen (ConfigHdr) | 8 | 1 |
2384 MaxLen
= 1 + StringPtr
- StringHdr
+ 8 + 1;
2385 ConfigAltHdr
= AllocateZeroPool ( MaxLen
* sizeof (CHAR16
));
2386 if (ConfigAltHdr
== NULL
) {
2387 Status
= EFI_OUT_OF_RESOURCES
;
2390 StrCpyS (ConfigAltHdr
, MaxLen
, L
"&");
2391 StrnCatS (ConfigAltHdr
, MaxLen
, StringHdr
, StringPtr
- StringHdr
);
2392 StrCatS (ConfigAltHdr
, MaxLen
, L
"&ALTCFG=");
2395 // Skip all AltResp (AltConfigHdr ConfigBody) for the same ConfigHdr
2397 while ((StringHdr
= StrStr (StringPtr
, ConfigAltHdr
)) != NULL
) {
2398 StringPtr
= StringHdr
+ StrLen (ConfigAltHdr
);
2399 if (*StringPtr
== L
'\0') {
2405 // Free the allocated ConfigAltHdr string
2407 FreePool (ConfigAltHdr
);
2408 if (*StringPtr
== L
'\0') {
2413 // Find &GUID as the next ConfigHdr
2415 StringPtr
= StrStr (StringPtr
, L
"&GUID");
2416 if (StringPtr
== NULL
) {
2427 if (VarGuid
!= NULL
) {
2431 if (VarName
!= NULL
) {
2435 if (DevicePath
!= NULL
) {
2436 FreePool (DevicePath
);
2439 if (ConfigResp
!= NULL
) {
2440 FreePool (ConfigResp
);
2443 if (ConfigAltResp
!= NULL
) {
2444 FreePool (ConfigAltResp
);
2447 if (HiiPackageList
!= NULL
) {
2448 FreePool (HiiPackageList
);
2451 if (EFI_ERROR (Status
)) {
2459 Validate the current configuration by parsing HII form IFR opcode.
2461 NULL request string support depends on the ExportConfig interface of
2462 HiiConfigRouting protocol in UEFI specification.
2464 @param Request A null-terminated Unicode string in
2465 <MultiConfigRequest> format. It can be NULL.
2466 If it is NULL, all current configuration for the
2467 entirety of the current HII database will be validated.
2469 @retval TRUE Current configuration is valid.
2470 @retval FALSE Current configuration is invalid.
2474 HiiValidateSettings (
2475 IN CONST EFI_STRING Request OPTIONAL
2478 return InternalHiiIfrValueAction (Request
, 0, ACTION_VALIDATE_SETTING
);
2482 Reset the default value specified by DefaultId to the driver
2483 configuration got by Request string.
2485 NULL request string support depends on the ExportConfig interface of
2486 HiiConfigRouting protocol in UEFI specification.
2488 @param Request A null-terminated Unicode string in
2489 <MultiConfigRequest> format. It can be NULL.
2490 If it is NULL, all configuration for the
2491 entirety of the current HII database will be reset.
2492 @param DefaultId Specifies the type of defaults to retrieve.
2494 @retval TURE The default value is set successfully.
2495 @retval FALSE The default value can't be found and set.
2500 IN CONST EFI_STRING Request
, OPTIONAL
2504 return InternalHiiIfrValueAction (Request
, DefaultId
, ACTION_SET_DEFAUTL_VALUE
);
2508 Determines if two values in config strings match.
2510 Compares the substring between StartSearchString and StopSearchString in
2511 FirstString to the substring between StartSearchString and StopSearchString
2512 in SecondString. If the two substrings match, then TRUE is returned. If the
2513 two substrings do not match, then FALSE is returned.
2515 If FirstString is NULL, then ASSERT().
2516 If SecondString is NULL, then ASSERT().
2517 If StartSearchString is NULL, then ASSERT().
2518 If StopSearchString is NULL, then ASSERT().
2520 @param FirstString Pointer to the first Null-terminated Unicode string.
2521 @param SecondString Pointer to the second Null-terminated Unicode string.
2522 @param StartSearchString Pointer to the Null-terminated Unicode string that
2523 marks the start of the value string to compare.
2524 @param StopSearchString Pointer to the Null-terminated Unicode string that
2525 marks the end of the value string to compare.
2527 @retval FALSE StartSearchString is not present in FirstString.
2528 @retval FALSE StartSearchString is not present in SecondString.
2529 @retval FALSE StopSearchString is not present in FirstString.
2530 @retval FALSE StopSearchString is not present in SecondString.
2531 @retval FALSE The length of the substring in FirstString is not the
2532 same length as the substring in SecondString.
2533 @retval FALSE The value string in FirstString does not matche the
2534 value string in SecondString.
2535 @retval TRUE The value string in FirstString matches the value
2536 string in SecondString.
2541 InternalHiiCompareSubString (
2542 IN CHAR16
*FirstString
,
2543 IN CHAR16
*SecondString
,
2544 IN CHAR16
*StartSearchString
,
2545 IN CHAR16
*StopSearchString
2548 CHAR16
*EndFirstString
;
2549 CHAR16
*EndSecondString
;
2551 ASSERT (FirstString
!= NULL
);
2552 ASSERT (SecondString
!= NULL
);
2553 ASSERT (StartSearchString
!= NULL
);
2554 ASSERT (StopSearchString
!= NULL
);
2556 FirstString
= StrStr (FirstString
, StartSearchString
);
2557 if (FirstString
== NULL
) {
2561 SecondString
= StrStr (SecondString
, StartSearchString
);
2562 if (SecondString
== NULL
) {
2566 EndFirstString
= StrStr (FirstString
, StopSearchString
);
2567 if (EndFirstString
== NULL
) {
2571 EndSecondString
= StrStr (SecondString
, StopSearchString
);
2572 if (EndSecondString
== NULL
) {
2576 if ((EndFirstString
- FirstString
) != (EndSecondString
- SecondString
)) {
2580 return (BOOLEAN
)(StrnCmp (FirstString
, SecondString
, EndFirstString
- FirstString
) == 0);
2584 Determines if the routing data specified by GUID and NAME match a <ConfigHdr>.
2586 If ConfigHdr is NULL, then ASSERT().
2588 @param[in] ConfigHdr Either <ConfigRequest> or <ConfigResp>.
2589 @param[in] Guid GUID of the storage.
2590 @param[in] Name NAME of the storage.
2592 @retval TRUE Routing information matches <ConfigHdr>.
2593 @retval FALSE Routing information does not match <ConfigHdr>.
2598 HiiIsConfigHdrMatch (
2599 IN CONST EFI_STRING ConfigHdr
,
2600 IN CONST EFI_GUID
*Guid
, OPTIONAL
2601 IN CONST CHAR16
*Name OPTIONAL
2604 EFI_STRING CompareConfigHdr
;
2607 ASSERT (ConfigHdr
!= NULL
);
2610 // Use Guid and Name to generate a <ConfigHdr> string
2612 CompareConfigHdr
= HiiConstructConfigHdr (Guid
, Name
, NULL
);
2613 if (CompareConfigHdr
== NULL
) {
2620 // Compare GUID value strings
2622 Result
= InternalHiiCompareSubString (ConfigHdr
, CompareConfigHdr
, L
"GUID=", L
"&NAME=");
2625 if (Result
&& Name
!= NULL
) {
2627 // Compare NAME value strings
2629 Result
= InternalHiiCompareSubString (ConfigHdr
, CompareConfigHdr
, L
"&NAME=", L
"&PATH=");
2633 // Free the <ConfigHdr> string
2635 FreePool (CompareConfigHdr
);
2641 Retrieves uncommitted data from the Form Browser and converts it to a binary
2644 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
2645 parameter that may be NULL.
2646 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
2647 is an optional parameter that may be NULL.
2648 @param[in] BufferSize Length in bytes of buffer to hold retrieved data.
2649 @param[out] Buffer Buffer of data to be updated.
2651 @retval FALSE The uncommitted data could not be retrieved.
2652 @retval TRUE The uncommitted data was retrieved.
2658 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
2659 IN CONST CHAR16
*VariableName
, OPTIONAL
2660 IN UINTN BufferSize
,
2664 EFI_STRING ResultsData
;
2666 EFI_STRING ConfigResp
;
2671 // Retrieve the results data from the Browser Callback
2673 ResultsData
= InternalHiiBrowserCallback (VariableGuid
, VariableName
, NULL
);
2674 if (ResultsData
== NULL
) {
2679 // Construct <ConfigResp> mConfigHdrTemplate L'&' ResultsData L'\0'
2681 Size
= (StrLen (mConfigHdrTemplate
) + 1) * sizeof (CHAR16
);
2682 Size
= Size
+ (StrLen (ResultsData
) + 1) * sizeof (CHAR16
);
2683 ConfigResp
= AllocateZeroPool (Size
);
2684 UnicodeSPrint (ConfigResp
, Size
, L
"%s&%s", mConfigHdrTemplate
, ResultsData
);
2687 // Free the allocated buffer
2689 FreePool (ResultsData
);
2690 if (ConfigResp
== NULL
) {
2695 // Convert <ConfigResp> to a buffer
2697 Status
= gHiiConfigRouting
->ConfigToBlock (
2705 // Free the allocated buffer
2707 FreePool (ConfigResp
);
2709 if (EFI_ERROR (Status
)) {
2717 Updates uncommitted data in the Form Browser.
2719 If Buffer is NULL, then ASSERT().
2721 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
2722 parameter that may be NULL.
2723 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
2724 is an optional parameter that may be NULL.
2725 @param[in] BufferSize Length, in bytes, of Buffer.
2726 @param[in] Buffer Buffer of data to commit.
2727 @param[in] RequestElement An optional field to specify which part of the
2728 buffer data will be send back to Browser. If NULL,
2729 the whole buffer of data will be committed to
2731 <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*
2733 @retval FALSE The uncommitted data could not be updated.
2734 @retval TRUE The uncommitted data was updated.
2740 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
2741 IN CONST CHAR16
*VariableName
, OPTIONAL
2742 IN UINTN BufferSize
,
2743 IN CONST UINT8
*Buffer
,
2744 IN CONST CHAR16
*RequestElement OPTIONAL
2748 EFI_STRING ConfigRequest
;
2749 EFI_STRING ConfigResp
;
2750 EFI_STRING ResultsData
;
2752 ASSERT (Buffer
!= NULL
);
2755 // Construct <ConfigRequest>
2757 if (RequestElement
== NULL
) {
2759 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2760 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
2762 Size
= (StrLen (mConfigHdrTemplate
) + 32 + 1) * sizeof (CHAR16
);
2763 ConfigRequest
= AllocateZeroPool (Size
);
2764 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", mConfigHdrTemplate
, (UINT64
)BufferSize
);
2767 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2768 // followed by <RequestElement> followed by a Null-terminator
2770 Size
= StrLen (mConfigHdrTemplate
) * sizeof (CHAR16
);
2771 Size
= Size
+ (StrLen (RequestElement
) + 1) * sizeof (CHAR16
);
2772 ConfigRequest
= AllocateZeroPool (Size
);
2773 UnicodeSPrint (ConfigRequest
, Size
, L
"%s%s", mConfigHdrTemplate
, RequestElement
);
2775 if (ConfigRequest
== NULL
) {
2780 // Convert <ConfigRequest> to <ConfigResp>
2782 ConfigResp
= InternalHiiBlockToConfig (ConfigRequest
, Buffer
, BufferSize
);
2783 FreePool (ConfigRequest
);
2784 if (ConfigResp
== NULL
) {
2789 // Set data in the uncommitted browser state information
2791 ResultsData
= InternalHiiBrowserCallback (VariableGuid
, VariableName
, ConfigResp
+ StrLen(mConfigHdrTemplate
) + 1);
2792 FreePool (ConfigResp
);
2794 return (BOOLEAN
)(ResultsData
!= NULL
);
2797 /////////////////////////////////////////
2798 /////////////////////////////////////////
2800 /////////////////////////////////////////
2801 /////////////////////////////////////////
2803 #define HII_LIB_OPCODE_ALLOCATION_SIZE 0x200
2809 } HII_LIB_OPCODE_BUFFER
;
2812 /// Lookup table that converts EFI_IFR_TYPE_X enum values to a width in bytes
2814 GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiDefaultTypeToWidth
[] = {
2815 1, // EFI_IFR_TYPE_NUM_SIZE_8
2816 2, // EFI_IFR_TYPE_NUM_SIZE_16
2817 4, // EFI_IFR_TYPE_NUM_SIZE_32
2818 8, // EFI_IFR_TYPE_NUM_SIZE_64
2819 1, // EFI_IFR_TYPE_BOOLEAN
2820 3, // EFI_IFR_TYPE_TIME
2821 4, // EFI_IFR_TYPE_DATE
2822 2 // EFI_IFR_TYPE_STRING
2826 Allocates and returns a new OpCode Handle. OpCode Handles must be freed with
2827 HiiFreeOpCodeHandle().
2829 @retval NULL There are not enough resources to allocate a new OpCode Handle.
2830 @retval Other A new OpCode handle.
2835 HiiAllocateOpCodeHandle (
2839 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2841 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)AllocatePool (sizeof (HII_LIB_OPCODE_BUFFER
));
2842 if (OpCodeBuffer
== NULL
) {
2845 OpCodeBuffer
->Buffer
= (UINT8
*)AllocatePool (HII_LIB_OPCODE_ALLOCATION_SIZE
);
2846 if (OpCodeBuffer
->Buffer
== NULL
) {
2847 FreePool (OpCodeBuffer
);
2850 OpCodeBuffer
->BufferSize
= HII_LIB_OPCODE_ALLOCATION_SIZE
;
2851 OpCodeBuffer
->Position
= 0;
2852 return (VOID
*)OpCodeBuffer
;
2856 Frees an OpCode Handle that was previously allocated with HiiAllocateOpCodeHandle().
2857 When an OpCode Handle is freed, all of the opcodes associated with the OpCode
2858 Handle are also freed.
2860 If OpCodeHandle is NULL, then ASSERT().
2862 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2867 HiiFreeOpCodeHandle (
2871 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2873 ASSERT (OpCodeHandle
!= NULL
);
2875 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
;
2876 if (OpCodeBuffer
->Buffer
!= NULL
) {
2877 FreePool (OpCodeBuffer
->Buffer
);
2879 FreePool (OpCodeBuffer
);
2883 Internal function gets the current position of opcode buffer.
2885 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2887 @return Current position of opcode buffer.
2891 InternalHiiOpCodeHandlePosition (
2892 IN VOID
*OpCodeHandle
2895 return ((HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
)->Position
;
2899 Internal function gets the start pointer of opcode buffer.
2901 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2903 @return Pointer to the opcode buffer base.
2907 InternalHiiOpCodeHandleBuffer (
2908 IN VOID
*OpCodeHandle
2911 return ((HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
)->Buffer
;
2915 Internal function reserves the enough buffer for current opcode.
2916 When the buffer is not enough, Opcode buffer will be extended.
2918 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2919 @param[in] Size Size of current opcode.
2921 @return Pointer to the current opcode.
2925 InternalHiiGrowOpCodeHandle (
2926 IN VOID
*OpCodeHandle
,
2930 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2933 ASSERT (OpCodeHandle
!= NULL
);
2935 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
;
2936 if (OpCodeBuffer
->Position
+ Size
> OpCodeBuffer
->BufferSize
) {
2937 Buffer
= ReallocatePool (
2938 OpCodeBuffer
->BufferSize
,
2939 OpCodeBuffer
->BufferSize
+ (Size
+ HII_LIB_OPCODE_ALLOCATION_SIZE
),
2940 OpCodeBuffer
->Buffer
2942 ASSERT (Buffer
!= NULL
);
2943 OpCodeBuffer
->Buffer
= Buffer
;
2944 OpCodeBuffer
->BufferSize
+= (Size
+ HII_LIB_OPCODE_ALLOCATION_SIZE
);
2946 Buffer
= OpCodeBuffer
->Buffer
+ OpCodeBuffer
->Position
;
2947 OpCodeBuffer
->Position
+= Size
;
2952 Internal function creates opcode based on the template opcode.
2954 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2955 @param[in] OpCodeTemplate Pointer to the template buffer of opcode.
2956 @param[in] OpCode OpCode IFR value.
2957 @param[in] OpCodeSize Size of opcode.
2958 @param[in] ExtensionSize Size of extended opcode.
2959 @param[in] Scope Scope bit of opcode.
2961 @return Pointer to the current opcode with opcode data.
2965 InternalHiiCreateOpCodeExtended (
2966 IN VOID
*OpCodeHandle
,
2967 IN VOID
*OpCodeTemplate
,
2969 IN UINTN OpCodeSize
,
2970 IN UINTN ExtensionSize
,
2974 EFI_IFR_OP_HEADER
*Header
;
2977 ASSERT (OpCodeTemplate
!= NULL
);
2978 ASSERT ((OpCodeSize
+ ExtensionSize
) <= 0x7F);
2980 Header
= (EFI_IFR_OP_HEADER
*)OpCodeTemplate
;
2981 Header
->OpCode
= OpCode
;
2982 Header
->Scope
= Scope
;
2983 Header
->Length
= (UINT8
)(OpCodeSize
+ ExtensionSize
);
2984 Buffer
= InternalHiiGrowOpCodeHandle (OpCodeHandle
, Header
->Length
);
2985 return (UINT8
*)CopyMem (Buffer
, Header
, OpCodeSize
);
2989 Internal function creates opcode based on the template opcode for the normal opcode.
2991 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2992 @param[in] OpCodeTemplate Pointer to the template buffer of opcode.
2993 @param[in] OpCode OpCode IFR value.
2994 @param[in] OpCodeSize Size of opcode.
2996 @return Pointer to the current opcode with opcode data.
3000 InternalHiiCreateOpCode (
3001 IN VOID
*OpCodeHandle
,
3002 IN VOID
*OpCodeTemplate
,
3007 return InternalHiiCreateOpCodeExtended (OpCodeHandle
, OpCodeTemplate
, OpCode
, OpCodeSize
, 0, 0);
3011 Append raw opcodes to an OpCodeHandle.
3013 If OpCodeHandle is NULL, then ASSERT().
3014 If RawBuffer is NULL, then ASSERT();
3016 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3017 @param[in] RawBuffer Buffer of opcodes to append.
3018 @param[in] RawBufferSize The size, in bytes, of Buffer.
3020 @retval NULL There is not enough space left in Buffer to add the opcode.
3021 @retval Other A pointer to the appended opcodes.
3026 HiiCreateRawOpCodes (
3027 IN VOID
*OpCodeHandle
,
3028 IN UINT8
*RawBuffer
,
3029 IN UINTN RawBufferSize
3034 ASSERT (RawBuffer
!= NULL
);
3036 Buffer
= InternalHiiGrowOpCodeHandle (OpCodeHandle
, RawBufferSize
);
3037 return (UINT8
*)CopyMem (Buffer
, RawBuffer
, RawBufferSize
);
3041 Append opcodes from one OpCode Handle to another OpCode handle.
3043 If OpCodeHandle is NULL, then ASSERT().
3044 If RawOpCodeHandle is NULL, then ASSERT();
3046 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3047 @param[in] RawOpCodeHandle Handle to the buffer of opcodes.
3049 @retval NULL There is not enough space left in Buffer to add the opcode.
3050 @retval Other A pointer to the appended opcodes.
3055 InternalHiiAppendOpCodes (
3056 IN VOID
*OpCodeHandle
,
3057 IN VOID
*RawOpCodeHandle
3060 HII_LIB_OPCODE_BUFFER
*RawOpCodeBuffer
;
3062 ASSERT (RawOpCodeHandle
!= NULL
);
3064 RawOpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)RawOpCodeHandle
;
3065 return HiiCreateRawOpCodes (OpCodeHandle
, RawOpCodeBuffer
->Buffer
, RawOpCodeBuffer
->Position
);
3069 Create EFI_IFR_END_OP opcode.
3071 If OpCodeHandle is NULL, then ASSERT().
3073 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3075 @retval NULL There is not enough space left in Buffer to add the opcode.
3076 @retval Other A pointer to the created opcode.
3081 HiiCreateEndOpCode (
3082 IN VOID
*OpCodeHandle
3087 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_END_OP
, sizeof (OpCode
));
3091 Create EFI_IFR_ONE_OF_OPTION_OP opcode.
3093 If OpCodeHandle is NULL, then ASSERT().
3094 If Type is invalid, then ASSERT().
3095 If Flags is invalid, then ASSERT().
3097 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3098 @param[in] StringId StringId for the option
3099 @param[in] Flags Flags for the option
3100 @param[in] Type Type for the option
3101 @param[in] Value Value for the option
3103 @retval NULL There is not enough space left in Buffer to add the opcode.
3104 @retval Other A pointer to the created opcode.
3109 HiiCreateOneOfOptionOpCode (
3110 IN VOID
*OpCodeHandle
,
3117 EFI_IFR_ONE_OF_OPTION OpCode
;
3119 ASSERT (Type
< EFI_IFR_TYPE_OTHER
);
3121 ZeroMem (&OpCode
, sizeof (OpCode
));
3122 OpCode
.Option
= StringId
;
3123 OpCode
.Flags
= (UINT8
) (Flags
& (EFI_IFR_OPTION_DEFAULT
| EFI_IFR_OPTION_DEFAULT_MFG
));
3125 CopyMem (&OpCode
.Value
, &Value
, mHiiDefaultTypeToWidth
[Type
]);
3127 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_ONE_OF_OPTION_OP
, OFFSET_OF(EFI_IFR_ONE_OF_OPTION
, Value
) + mHiiDefaultTypeToWidth
[Type
]);
3131 Create EFI_IFR_DEFAULT_OP opcode.
3133 If OpCodeHandle is NULL, then ASSERT().
3134 If Type is invalid, then ASSERT().
3136 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3137 @param[in] DefaultId DefaultId for the default
3138 @param[in] Type Type for the default
3139 @param[in] Value Value for the default
3141 @retval NULL There is not enough space left in Buffer to add the opcode.
3142 @retval Other A pointer to the created opcode.
3147 HiiCreateDefaultOpCode (
3148 IN VOID
*OpCodeHandle
,
3149 IN UINT16 DefaultId
,
3154 EFI_IFR_DEFAULT OpCode
;
3156 ASSERT (Type
< EFI_IFR_TYPE_OTHER
);
3158 ZeroMem (&OpCode
, sizeof (OpCode
));
3160 OpCode
.DefaultId
= DefaultId
;
3161 CopyMem (&OpCode
.Value
, &Value
, mHiiDefaultTypeToWidth
[Type
]);
3163 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_DEFAULT_OP
, OFFSET_OF(EFI_IFR_DEFAULT
, Value
) + mHiiDefaultTypeToWidth
[Type
]);
3167 Create EFI_IFR_GUID opcode.
3169 If OpCodeHandle is NULL, then ASSERT().
3170 If Guid is NULL, then ASSERT().
3171 If OpCodeSize < sizeof (EFI_IFR_GUID), then ASSERT().
3173 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3174 @param[in] Guid Pointer to EFI_GUID of this guided opcode.
3175 @param[in] GuidOpCode Pointer to an EFI_IFR_GUID opcode. This is an
3176 optional parameter that may be NULL. If this
3177 parameter is NULL, then the GUID extension
3178 region of the created opcode is filled with zeros.
3179 If this parameter is not NULL, then the GUID
3180 extension region of GuidData will be copied to
3181 the GUID extension region of the created opcode.
3182 @param[in] OpCodeSize The size, in bytes, of created opcode. This value
3183 must be >= sizeof(EFI_IFR_GUID).
3185 @retval NULL There is not enough space left in Buffer to add the opcode.
3186 @retval Other A pointer to the created opcode.
3191 HiiCreateGuidOpCode (
3192 IN VOID
*OpCodeHandle
,
3193 IN CONST EFI_GUID
*Guid
,
3194 IN CONST VOID
*GuidOpCode
, OPTIONAL
3198 EFI_IFR_GUID OpCode
;
3199 EFI_IFR_GUID
*OpCodePointer
;
3201 ASSERT (Guid
!= NULL
);
3202 ASSERT (OpCodeSize
>= sizeof (OpCode
));
3204 ZeroMem (&OpCode
, sizeof (OpCode
));
3205 CopyGuid ((EFI_GUID
*)(VOID
*)&OpCode
.Guid
, Guid
);
3207 OpCodePointer
= (EFI_IFR_GUID
*)InternalHiiCreateOpCodeExtended (
3212 OpCodeSize
- sizeof (OpCode
),
3215 if (OpCodePointer
!= NULL
&& GuidOpCode
!= NULL
) {
3216 CopyMem (OpCodePointer
+ 1, (EFI_IFR_GUID
*)GuidOpCode
+ 1, OpCodeSize
- sizeof (OpCode
));
3218 return (UINT8
*)OpCodePointer
;
3222 Create EFI_IFR_ACTION_OP opcode.
3224 If OpCodeHandle is NULL, then ASSERT().
3225 If any reserved bits are set in QuestionFlags, then ASSERT().
3227 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3228 @param[in] QuestionId Question ID
3229 @param[in] Prompt String ID for Prompt
3230 @param[in] Help String ID for Help
3231 @param[in] QuestionFlags Flags in Question Header
3232 @param[in] QuestionConfig String ID for configuration
3234 @retval NULL There is not enough space left in Buffer to add the opcode.
3235 @retval Other A pointer to the created opcode.
3240 HiiCreateActionOpCode (
3241 IN VOID
*OpCodeHandle
,
3242 IN EFI_QUESTION_ID QuestionId
,
3243 IN EFI_STRING_ID Prompt
,
3244 IN EFI_STRING_ID Help
,
3245 IN UINT8 QuestionFlags
,
3246 IN EFI_STRING_ID QuestionConfig
3249 EFI_IFR_ACTION OpCode
;
3251 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3253 ZeroMem (&OpCode
, sizeof (OpCode
));
3254 OpCode
.Question
.QuestionId
= QuestionId
;
3255 OpCode
.Question
.Header
.Prompt
= Prompt
;
3256 OpCode
.Question
.Header
.Help
= Help
;
3257 OpCode
.Question
.Flags
= QuestionFlags
;
3258 OpCode
.QuestionConfig
= QuestionConfig
;
3260 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_ACTION_OP
, sizeof (OpCode
));
3264 Create EFI_IFR_SUBTITLE_OP opcode.
3266 If OpCodeHandle is NULL, then ASSERT().
3267 If any reserved bits are set in Flags, then ASSERT().
3268 If Scope > 1, then ASSERT().
3270 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3271 @param[in] Prompt String ID for Prompt
3272 @param[in] Help String ID for Help
3273 @param[in] Flags Subtitle opcode flags
3274 @param[in] Scope 1 if this opcpde is the beginning of a new scope.
3275 0 if this opcode is within the current scope.
3277 @retval NULL There is not enough space left in Buffer to add the opcode.
3278 @retval Other A pointer to the created opcode.
3283 HiiCreateSubTitleOpCode (
3284 IN VOID
*OpCodeHandle
,
3285 IN EFI_STRING_ID Prompt
,
3286 IN EFI_STRING_ID Help
,
3291 EFI_IFR_SUBTITLE OpCode
;
3293 ASSERT (Scope
<= 1);
3294 ASSERT ((Flags
& (~(EFI_IFR_FLAGS_HORIZONTAL
))) == 0);
3296 ZeroMem (&OpCode
, sizeof (OpCode
));
3297 OpCode
.Statement
.Prompt
= Prompt
;
3298 OpCode
.Statement
.Help
= Help
;
3299 OpCode
.Flags
= Flags
;
3301 return InternalHiiCreateOpCodeExtended (
3304 EFI_IFR_SUBTITLE_OP
,
3312 Create EFI_IFR_REF_OP opcode.
3314 If OpCodeHandle is NULL, then ASSERT().
3315 If any reserved bits are set in QuestionFlags, then ASSERT().
3317 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3318 @param[in] FormId Destination Form ID
3319 @param[in] Prompt String ID for Prompt
3320 @param[in] Help String ID for Help
3321 @param[in] QuestionFlags Flags in Question Header
3322 @param[in] QuestionId Question ID
3324 @retval NULL There is not enough space left in Buffer to add the opcode.
3325 @retval Other A pointer to the created opcode.
3330 HiiCreateGotoOpCode (
3331 IN VOID
*OpCodeHandle
,
3332 IN EFI_FORM_ID FormId
,
3333 IN EFI_STRING_ID Prompt
,
3334 IN EFI_STRING_ID Help
,
3335 IN UINT8 QuestionFlags
,
3336 IN EFI_QUESTION_ID QuestionId
3341 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3343 ZeroMem (&OpCode
, sizeof (OpCode
));
3344 OpCode
.Question
.Header
.Prompt
= Prompt
;
3345 OpCode
.Question
.Header
.Help
= Help
;
3346 OpCode
.Question
.QuestionId
= QuestionId
;
3347 OpCode
.Question
.Flags
= QuestionFlags
;
3348 OpCode
.FormId
= FormId
;
3350 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_REF_OP
, sizeof (OpCode
));
3354 Create EFI_IFR_REF_OP, EFI_IFR_REF2_OP, EFI_IFR_REF3_OP and EFI_IFR_REF4_OP opcode.
3356 When RefDevicePath is not zero, EFI_IFR_REF4 opcode will be created.
3357 When RefDevicePath is zero and RefFormSetId is not NULL, EFI_IFR_REF3 opcode will be created.
3358 When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is not zero, EFI_IFR_REF2 opcode will be created.
3359 When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is zero, EFI_IFR_REF opcode will be created.
3361 If OpCodeHandle is NULL, then ASSERT().
3362 If any reserved bits are set in QuestionFlags, then ASSERT().
3364 @param[in] OpCodeHandle The handle to the buffer of opcodes.
3365 @param[in] RefFormId The Destination Form ID.
3366 @param[in] Prompt The string ID for Prompt.
3367 @param[in] Help The string ID for Help.
3368 @param[in] QuestionFlags The flags in Question Header
3369 @param[in] QuestionId Question ID.
3370 @param[in] RefQuestionId The question on the form to which this link is referring.
3371 If its value is zero, then the link refers to the top of the form.
3372 @param[in] RefFormSetId The form set to which this link is referring. If its value is NULL, and RefDevicePath is
3373 zero, then the link is to the current form set.
3374 @param[in] RefDevicePath The string identifier that specifies the string containing the text representation of
3375 the device path to which the form set containing the form specified by FormId.
3376 If its value is zero, then the link refers to the current page.
3378 @retval NULL There is not enough space left in Buffer to add the opcode.
3379 @retval Other A pointer to the created opcode.
3384 HiiCreateGotoExOpCode (
3385 IN VOID
*OpCodeHandle
,
3386 IN EFI_FORM_ID RefFormId
,
3387 IN EFI_STRING_ID Prompt
,
3388 IN EFI_STRING_ID Help
,
3389 IN UINT8 QuestionFlags
,
3390 IN EFI_QUESTION_ID QuestionId
,
3391 IN EFI_QUESTION_ID RefQuestionId
,
3392 IN EFI_GUID
*RefFormSetId
, OPTIONAL
3393 IN EFI_STRING_ID RefDevicePath
3396 EFI_IFR_REF4 OpCode
;
3399 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3401 ZeroMem (&OpCode
, sizeof (OpCode
));
3402 OpCode
.Question
.Header
.Prompt
= Prompt
;
3403 OpCode
.Question
.Header
.Help
= Help
;
3404 OpCode
.Question
.QuestionId
= QuestionId
;
3405 OpCode
.Question
.Flags
= QuestionFlags
;
3406 OpCode
.FormId
= RefFormId
;
3407 OpCode
.QuestionId
= RefQuestionId
;
3408 OpCode
.DevicePath
= RefDevicePath
;
3409 if (RefFormSetId
!= NULL
) {
3410 CopyMem (&OpCode
.FormSetId
, RefFormSetId
, sizeof (OpCode
.FormSetId
));
3414 // Cacluate OpCodeSize based on the input Ref value.
3415 // Try to use the small OpCode to save size.
3417 OpCodeSize
= sizeof (EFI_IFR_REF
);
3418 if (RefDevicePath
!= 0) {
3419 OpCodeSize
= sizeof (EFI_IFR_REF4
);
3420 } else if (RefFormSetId
!= NULL
) {
3421 OpCodeSize
= sizeof (EFI_IFR_REF3
);
3422 } else if (RefQuestionId
!= 0) {
3423 OpCodeSize
= sizeof (EFI_IFR_REF2
);
3426 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_REF_OP
, OpCodeSize
);
3430 Create EFI_IFR_CHECKBOX_OP opcode.
3432 If OpCodeHandle is NULL, then ASSERT().
3433 If any reserved bits are set in QuestionFlags, then ASSERT().
3434 If any reserved bits are set in CheckBoxFlags, then ASSERT().
3436 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3437 @param[in] QuestionId Question ID
3438 @param[in] VarStoreId Storage ID
3439 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3440 for this name/value pair.
3441 @param[in] Prompt String ID for Prompt
3442 @param[in] Help String ID for Help
3443 @param[in] QuestionFlags Flags in Question Header
3444 @param[in] CheckBoxFlags Flags for checkbox opcode
3445 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3446 is an optional parameter that may be NULL.
3448 @retval NULL There is not enough space left in Buffer to add the opcode.
3449 @retval Other A pointer to the created opcode.
3454 HiiCreateCheckBoxOpCode (
3455 IN VOID
*OpCodeHandle
,
3456 IN EFI_QUESTION_ID QuestionId
,
3457 IN EFI_VARSTORE_ID VarStoreId
,
3458 IN UINT16 VarOffset
,
3459 IN EFI_STRING_ID Prompt
,
3460 IN EFI_STRING_ID Help
,
3461 IN UINT8 QuestionFlags
,
3462 IN UINT8 CheckBoxFlags
,
3463 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3466 EFI_IFR_CHECKBOX OpCode
;
3469 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3471 ZeroMem (&OpCode
, sizeof (OpCode
));
3472 OpCode
.Question
.QuestionId
= QuestionId
;
3473 OpCode
.Question
.VarStoreId
= VarStoreId
;
3474 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3475 OpCode
.Question
.Header
.Prompt
= Prompt
;
3476 OpCode
.Question
.Header
.Help
= Help
;
3477 OpCode
.Question
.Flags
= QuestionFlags
;
3478 OpCode
.Flags
= CheckBoxFlags
;
3480 if (DefaultsOpCodeHandle
== NULL
) {
3481 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_CHECKBOX_OP
, sizeof (OpCode
));
3484 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3485 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_CHECKBOX_OP
, sizeof (OpCode
), 0, 1);
3486 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3487 HiiCreateEndOpCode (OpCodeHandle
);
3488 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3492 Create EFI_IFR_NUMERIC_OP opcode.
3494 If OpCodeHandle is NULL, then ASSERT().
3495 If any reserved bits are set in QuestionFlags, then ASSERT().
3496 If any reserved bits are set in NumericFlags, then ASSERT().
3498 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3499 @param[in] QuestionId Question ID
3500 @param[in] VarStoreId Storage ID
3501 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3502 for this name/value pair.
3503 @param[in] Prompt String ID for Prompt
3504 @param[in] Help String ID for Help
3505 @param[in] QuestionFlags Flags in Question Header
3506 @param[in] NumericFlags Flags for numeric opcode
3507 @param[in] Minimum Numeric minimum value
3508 @param[in] Maximum Numeric maximum value
3509 @param[in] Step Numeric step for edit
3510 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3511 is an optional parameter that may be NULL.
3513 @retval NULL There is not enough space left in Buffer to add the opcode.
3514 @retval Other A pointer to the created opcode.
3519 HiiCreateNumericOpCode (
3520 IN VOID
*OpCodeHandle
,
3521 IN EFI_QUESTION_ID QuestionId
,
3522 IN EFI_VARSTORE_ID VarStoreId
,
3523 IN UINT16 VarOffset
,
3524 IN EFI_STRING_ID Prompt
,
3525 IN EFI_STRING_ID Help
,
3526 IN UINT8 QuestionFlags
,
3527 IN UINT8 NumericFlags
,
3531 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3534 EFI_IFR_NUMERIC OpCode
;
3538 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3541 ZeroMem (&OpCode
, sizeof (OpCode
));
3542 OpCode
.Question
.QuestionId
= QuestionId
;
3543 OpCode
.Question
.VarStoreId
= VarStoreId
;
3544 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3545 OpCode
.Question
.Header
.Prompt
= Prompt
;
3546 OpCode
.Question
.Header
.Help
= Help
;
3547 OpCode
.Question
.Flags
= QuestionFlags
;
3548 OpCode
.Flags
= NumericFlags
;
3550 switch (NumericFlags
& EFI_IFR_NUMERIC_SIZE
) {
3551 case EFI_IFR_NUMERIC_SIZE_1
:
3552 OpCode
.data
.u8
.MinValue
= (UINT8
)Minimum
;
3553 OpCode
.data
.u8
.MaxValue
= (UINT8
)Maximum
;
3554 OpCode
.data
.u8
.Step
= (UINT8
)Step
;
3558 case EFI_IFR_NUMERIC_SIZE_2
:
3559 OpCode
.data
.u16
.MinValue
= (UINT16
)Minimum
;
3560 OpCode
.data
.u16
.MaxValue
= (UINT16
)Maximum
;
3561 OpCode
.data
.u16
.Step
= (UINT16
)Step
;
3565 case EFI_IFR_NUMERIC_SIZE_4
:
3566 OpCode
.data
.u32
.MinValue
= (UINT32
)Minimum
;
3567 OpCode
.data
.u32
.MaxValue
= (UINT32
)Maximum
;
3568 OpCode
.data
.u32
.Step
= (UINT32
)Step
;
3572 case EFI_IFR_NUMERIC_SIZE_8
:
3573 OpCode
.data
.u64
.MinValue
= Minimum
;
3574 OpCode
.data
.u64
.MaxValue
= Maximum
;
3575 OpCode
.data
.u64
.Step
= Step
;
3580 Length
+= OFFSET_OF (EFI_IFR_NUMERIC
, data
);
3582 if (DefaultsOpCodeHandle
== NULL
) {
3583 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_NUMERIC_OP
, Length
);
3586 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3587 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_NUMERIC_OP
, Length
, 0, 1);
3588 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3589 HiiCreateEndOpCode (OpCodeHandle
);
3590 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3594 Create EFI_IFR_STRING_OP opcode.
3596 If OpCodeHandle is NULL, then ASSERT().
3597 If any reserved bits are set in QuestionFlags, then ASSERT().
3598 If any reserved bits are set in StringFlags, then ASSERT().
3600 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3601 @param[in] QuestionId Question ID
3602 @param[in] VarStoreId Storage ID
3603 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3604 for this name/value pair.
3605 @param[in] Prompt String ID for Prompt
3606 @param[in] Help String ID for Help
3607 @param[in] QuestionFlags Flags in Question Header
3608 @param[in] StringFlags Flags for string opcode
3609 @param[in] MinSize String minimum length
3610 @param[in] MaxSize String maximum length
3611 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3612 is an optional parameter that may be NULL.
3614 @retval NULL There is not enough space left in Buffer to add the opcode.
3615 @retval Other A pointer to the created opcode.
3620 HiiCreateStringOpCode (
3621 IN VOID
*OpCodeHandle
,
3622 IN EFI_QUESTION_ID QuestionId
,
3623 IN EFI_VARSTORE_ID VarStoreId
,
3624 IN UINT16 VarOffset
,
3625 IN EFI_STRING_ID Prompt
,
3626 IN EFI_STRING_ID Help
,
3627 IN UINT8 QuestionFlags
,
3628 IN UINT8 StringFlags
,
3631 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3634 EFI_IFR_STRING OpCode
;
3637 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3639 ZeroMem (&OpCode
, sizeof (OpCode
));
3640 OpCode
.Question
.Header
.Prompt
= Prompt
;
3641 OpCode
.Question
.Header
.Help
= Help
;
3642 OpCode
.Question
.QuestionId
= QuestionId
;
3643 OpCode
.Question
.VarStoreId
= VarStoreId
;
3644 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3645 OpCode
.Question
.Flags
= QuestionFlags
;
3646 OpCode
.MinSize
= MinSize
;
3647 OpCode
.MaxSize
= MaxSize
;
3648 OpCode
.Flags
= (UINT8
) (StringFlags
& EFI_IFR_STRING_MULTI_LINE
);
3650 if (DefaultsOpCodeHandle
== NULL
) {
3651 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_STRING_OP
, sizeof (OpCode
));
3654 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3655 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_STRING_OP
, sizeof (OpCode
), 0, 1);
3656 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3657 HiiCreateEndOpCode (OpCodeHandle
);
3658 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3662 Create EFI_IFR_ONE_OF_OP opcode.
3664 If OpCodeHandle is NULL, then ASSERT().
3665 If any reserved bits are set in QuestionFlags, then ASSERT().
3666 If any reserved bits are set in OneOfFlags, then ASSERT().
3668 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3669 @param[in] QuestionId Question ID
3670 @param[in] VarStoreId Storage ID
3671 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3672 for this name/value pair.
3673 @param[in] Prompt String ID for Prompt
3674 @param[in] Help String ID for Help
3675 @param[in] QuestionFlags Flags in Question Header
3676 @param[in] OneOfFlags Flags for oneof opcode
3677 @param[in] OptionsOpCodeHandle Handle for a buffer of ONE_OF_OPTION opcodes.
3678 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3679 is an optional parameter that may be NULL.
3681 @retval NULL There is not enough space left in Buffer to add the opcode.
3682 @retval Other A pointer to the created opcode.
3687 HiiCreateOneOfOpCode (
3688 IN VOID
*OpCodeHandle
,
3689 IN EFI_QUESTION_ID QuestionId
,
3690 IN EFI_VARSTORE_ID VarStoreId
,
3691 IN UINT16 VarOffset
,
3692 IN EFI_STRING_ID Prompt
,
3693 IN EFI_STRING_ID Help
,
3694 IN UINT8 QuestionFlags
,
3695 IN UINT8 OneOfFlags
,
3696 IN VOID
*OptionsOpCodeHandle
,
3697 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3700 EFI_IFR_ONE_OF OpCode
;
3704 ASSERT (OptionsOpCodeHandle
!= NULL
);
3705 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
| EFI_IFR_FLAG_OPTIONS_ONLY
))) == 0);
3707 ZeroMem (&OpCode
, sizeof (OpCode
));
3708 OpCode
.Question
.Header
.Prompt
= Prompt
;
3709 OpCode
.Question
.Header
.Help
= Help
;
3710 OpCode
.Question
.QuestionId
= QuestionId
;
3711 OpCode
.Question
.VarStoreId
= VarStoreId
;
3712 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3713 OpCode
.Question
.Flags
= QuestionFlags
;
3714 OpCode
.Flags
= OneOfFlags
;
3716 Length
= OFFSET_OF (EFI_IFR_ONE_OF
, data
);
3717 Length
+= (1 << (OneOfFlags
& EFI_IFR_NUMERIC_SIZE
)) * 3;
3719 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3720 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_ONE_OF_OP
, Length
, 0, 1);
3721 InternalHiiAppendOpCodes (OpCodeHandle
, OptionsOpCodeHandle
);
3722 if (DefaultsOpCodeHandle
!= NULL
) {
3723 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3725 HiiCreateEndOpCode (OpCodeHandle
);
3726 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3730 Create EFI_IFR_ORDERED_LIST_OP opcode.
3732 If OpCodeHandle is NULL, then ASSERT().
3733 If any reserved bits are set in QuestionFlags, then ASSERT().
3734 If any reserved bits are set in OrderedListFlags, then ASSERT().
3736 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3737 @param[in] QuestionId Question ID
3738 @param[in] VarStoreId Storage ID
3739 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3740 for this name/value pair.
3741 @param[in] Prompt String ID for Prompt
3742 @param[in] Help String ID for Help
3743 @param[in] QuestionFlags Flags in Question Header
3744 @param[in] OrderedListFlags Flags for ordered list opcode
3745 @param[in] DataType Type for option value
3746 @param[in] MaxContainers Maximum count for options in this ordered list
3747 @param[in] OptionsOpCodeHandle Handle for a buffer of ONE_OF_OPTION opcodes.
3748 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3749 is an optional parameter that may be NULL.
3751 @retval NULL There is not enough space left in Buffer to add the opcode.
3752 @retval Other A pointer to the created opcode.
3757 HiiCreateOrderedListOpCode (
3758 IN VOID
*OpCodeHandle
,
3759 IN EFI_QUESTION_ID QuestionId
,
3760 IN EFI_VARSTORE_ID VarStoreId
,
3761 IN UINT16 VarOffset
,
3762 IN EFI_STRING_ID Prompt
,
3763 IN EFI_STRING_ID Help
,
3764 IN UINT8 QuestionFlags
,
3765 IN UINT8 OrderedListFlags
,
3767 IN UINT8 MaxContainers
,
3768 IN VOID
*OptionsOpCodeHandle
,
3769 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3772 EFI_IFR_ORDERED_LIST OpCode
;
3775 ASSERT (OptionsOpCodeHandle
!= NULL
);
3776 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
| EFI_IFR_FLAG_OPTIONS_ONLY
))) == 0);
3778 ZeroMem (&OpCode
, sizeof (OpCode
));
3779 OpCode
.Question
.Header
.Prompt
= Prompt
;
3780 OpCode
.Question
.Header
.Help
= Help
;
3781 OpCode
.Question
.QuestionId
= QuestionId
;
3782 OpCode
.Question
.VarStoreId
= VarStoreId
;
3783 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3784 OpCode
.Question
.Flags
= QuestionFlags
;
3785 OpCode
.MaxContainers
= MaxContainers
;
3786 OpCode
.Flags
= OrderedListFlags
;
3788 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3789 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_ORDERED_LIST_OP
, sizeof (OpCode
), 0, 1);
3790 InternalHiiAppendOpCodes (OpCodeHandle
, OptionsOpCodeHandle
);
3791 if (DefaultsOpCodeHandle
!= NULL
) {
3792 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3794 HiiCreateEndOpCode (OpCodeHandle
);
3795 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3799 Create EFI_IFR_TEXT_OP opcode.
3801 If OpCodeHandle is NULL, then ASSERT().
3803 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3804 @param[in] Prompt String ID for Prompt.
3805 @param[in] Help String ID for Help.
3806 @param[in] TextTwo String ID for TextTwo.
3808 @retval NULL There is not enough space left in Buffer to add the opcode.
3809 @retval Other A pointer to the created opcode.
3814 HiiCreateTextOpCode (
3815 IN VOID
*OpCodeHandle
,
3816 IN EFI_STRING_ID Prompt
,
3817 IN EFI_STRING_ID Help
,
3818 IN EFI_STRING_ID TextTwo
3821 EFI_IFR_TEXT OpCode
;
3823 ZeroMem (&OpCode
, sizeof (OpCode
));
3824 OpCode
.Statement
.Prompt
= Prompt
;
3825 OpCode
.Statement
.Help
= Help
;
3826 OpCode
.TextTwo
= TextTwo
;
3828 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_TEXT_OP
, sizeof (OpCode
));
3832 Create EFI_IFR_DATE_OP opcode.
3834 If OpCodeHandle is NULL, then ASSERT().
3835 If any reserved bits are set in QuestionFlags, then ASSERT().
3836 If any reserved bits are set in DateFlags, then ASSERT().
3838 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3839 @param[in] QuestionId Question ID
3840 @param[in] VarStoreId Storage ID, optional. If DateFlags is not
3841 QF_DATE_STORAGE_NORMAL, this parameter is ignored.
3842 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3843 for this name/value pair, optional. If DateFlags is not
3844 QF_DATE_STORAGE_NORMAL, this parameter is ignored.
3845 @param[in] Prompt String ID for Prompt
3846 @param[in] Help String ID for Help
3847 @param[in] QuestionFlags Flags in Question Header
3848 @param[in] DateFlags Flags for date opcode
3849 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3850 is an optional parameter that may be NULL.
3852 @retval NULL There is not enough space left in Buffer to add the opcode.
3853 @retval Other A pointer to the created opcode.
3858 HiiCreateDateOpCode (
3859 IN VOID
*OpCodeHandle
,
3860 IN EFI_QUESTION_ID QuestionId
,
3861 IN EFI_VARSTORE_ID VarStoreId
, OPTIONAL
3862 IN UINT16 VarOffset
, OPTIONAL
3863 IN EFI_STRING_ID Prompt
,
3864 IN EFI_STRING_ID Help
,
3865 IN UINT8 QuestionFlags
,
3867 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3870 EFI_IFR_DATE OpCode
;
3873 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3874 ASSERT ((DateFlags
& (~(EFI_QF_DATE_YEAR_SUPPRESS
| EFI_QF_DATE_MONTH_SUPPRESS
| EFI_QF_DATE_DAY_SUPPRESS
| EFI_QF_DATE_STORAGE
))) == 0);
3876 ZeroMem (&OpCode
, sizeof (OpCode
));
3877 OpCode
.Question
.Header
.Prompt
= Prompt
;
3878 OpCode
.Question
.Header
.Help
= Help
;
3879 OpCode
.Question
.QuestionId
= QuestionId
;
3880 OpCode
.Question
.VarStoreId
= VarStoreId
;
3881 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3882 OpCode
.Question
.Flags
= QuestionFlags
;
3883 OpCode
.Flags
= DateFlags
;
3885 if (DefaultsOpCodeHandle
== NULL
) {
3886 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_DATE_OP
, sizeof (OpCode
));
3889 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3890 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_DATE_OP
, sizeof (OpCode
), 0, 1);
3891 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3892 HiiCreateEndOpCode (OpCodeHandle
);
3893 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3897 Create EFI_IFR_TIME_OP opcode.
3899 If OpCodeHandle is NULL, then ASSERT().
3900 If any reserved bits are set in QuestionFlags, then ASSERT().
3901 If any reserved bits are set in TimeFlags, then ASSERT().
3903 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3904 @param[in] QuestionId Question ID
3905 @param[in] VarStoreId Storage ID, optional. If TimeFlags is not
3906 QF_TIME_STORAGE_NORMAL, this parameter is ignored.
3907 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3908 for this name/value pair, optional. If TimeFlags is not
3909 QF_TIME_STORAGE_NORMAL, this parameter is ignored.
3910 @param[in] Prompt String ID for Prompt
3911 @param[in] Help String ID for Help
3912 @param[in] QuestionFlags Flags in Question Header
3913 @param[in] TimeFlags Flags for time opcode
3914 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3915 is an optional parameter that may be NULL.
3917 @retval NULL There is not enough space left in Buffer to add the opcode.
3918 @retval Other A pointer to the created opcode.
3923 HiiCreateTimeOpCode (
3924 IN VOID
*OpCodeHandle
,
3925 IN EFI_QUESTION_ID QuestionId
,
3926 IN EFI_VARSTORE_ID VarStoreId
, OPTIONAL
3927 IN UINT16 VarOffset
, OPTIONAL
3928 IN EFI_STRING_ID Prompt
,
3929 IN EFI_STRING_ID Help
,
3930 IN UINT8 QuestionFlags
,
3932 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3935 EFI_IFR_TIME OpCode
;
3938 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3939 ASSERT ((TimeFlags
& (~(QF_TIME_HOUR_SUPPRESS
| QF_TIME_MINUTE_SUPPRESS
| QF_TIME_SECOND_SUPPRESS
| QF_TIME_STORAGE
))) == 0);
3941 ZeroMem (&OpCode
, sizeof (OpCode
));
3942 OpCode
.Question
.Header
.Prompt
= Prompt
;
3943 OpCode
.Question
.Header
.Help
= Help
;
3944 OpCode
.Question
.QuestionId
= QuestionId
;
3945 OpCode
.Question
.VarStoreId
= VarStoreId
;
3946 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3947 OpCode
.Question
.Flags
= QuestionFlags
;
3948 OpCode
.Flags
= TimeFlags
;
3950 if (DefaultsOpCodeHandle
== NULL
) {
3951 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_TIME_OP
, sizeof (OpCode
));
3954 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3955 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_TIME_OP
, sizeof (OpCode
), 0, 1);
3956 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3957 HiiCreateEndOpCode (OpCodeHandle
);
3958 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3962 This is the internal worker function to update the data in
3963 a form specified by FormSetGuid, FormId and Label.
3965 @param[in] FormSetGuid The optional Formset GUID.
3966 @param[in] FormId The Form ID.
3967 @param[in] Package The package header.
3968 @param[in] OpCodeBufferStart An OpCode buffer that contains the set of IFR
3969 opcodes to be inserted or replaced in the form.
3970 @param[in] OpCodeBufferEnd An OpCcode buffer that contains the IFR opcode
3971 that marks the end of a replace operation in the form.
3972 @param[out] TempPackage The resultant package.
3974 @retval EFI_SUCCESS The function completes successfully.
3975 @retval EFI_NOT_FOUND The updated opcode or endopcode is not found.
3980 InternalHiiUpdateFormPackageData (
3981 IN EFI_GUID
*FormSetGuid
, OPTIONAL
3982 IN EFI_FORM_ID FormId
,
3983 IN EFI_HII_PACKAGE_HEADER
*Package
,
3984 IN HII_LIB_OPCODE_BUFFER
*OpCodeBufferStart
,
3985 IN HII_LIB_OPCODE_BUFFER
*OpCodeBufferEnd
, OPTIONAL
3986 OUT EFI_HII_PACKAGE_HEADER
*TempPackage
3991 EFI_HII_PACKAGE_HEADER PackageHeader
;
3993 EFI_IFR_OP_HEADER
*IfrOpHdr
;
3994 EFI_IFR_OP_HEADER
*UpdateIfrOpHdr
;
3998 UINTN UpdatePackageLength
;
4000 CopyMem (TempPackage
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4001 UpdatePackageLength
= sizeof (EFI_HII_PACKAGE_HEADER
);
4002 BufferPos
= (UINT8
*) (TempPackage
+ 1);
4004 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4005 IfrOpHdr
= (EFI_IFR_OP_HEADER
*)((UINT8
*) Package
+ sizeof (EFI_HII_PACKAGE_HEADER
));
4006 Offset
= sizeof (EFI_HII_PACKAGE_HEADER
);
4007 GetFormSet
= (BOOLEAN
) ((FormSetGuid
== NULL
) ? TRUE
: FALSE
);
4011 while (Offset
< PackageHeader
.Length
) {
4012 CopyMem (BufferPos
, IfrOpHdr
, IfrOpHdr
->Length
);
4013 BufferPos
+= IfrOpHdr
->Length
;
4014 UpdatePackageLength
+= IfrOpHdr
->Length
;
4017 // Find the matched FormSet and Form
4019 if ((IfrOpHdr
->OpCode
== EFI_IFR_FORM_SET_OP
) && (FormSetGuid
!= NULL
)) {
4020 if (CompareGuid((GUID
*)(VOID
*)&((EFI_IFR_FORM_SET
*) IfrOpHdr
)->Guid
, FormSetGuid
)) {
4025 } else if (IfrOpHdr
->OpCode
== EFI_IFR_FORM_OP
|| IfrOpHdr
->OpCode
== EFI_IFR_FORM_MAP_OP
) {
4026 if (CompareMem (&((EFI_IFR_FORM
*) IfrOpHdr
)->FormId
, &FormId
, sizeof (EFI_FORM_ID
)) == 0) {
4034 // The matched Form is found, and Update data in this form
4036 if (GetFormSet
&& GetForm
) {
4037 UpdateIfrOpHdr
= (EFI_IFR_OP_HEADER
*) OpCodeBufferStart
->Buffer
;
4038 if ((UpdateIfrOpHdr
->Length
== IfrOpHdr
->Length
) && \
4039 (CompareMem (IfrOpHdr
, UpdateIfrOpHdr
, UpdateIfrOpHdr
->Length
) == 0)) {
4041 // Remove the original data when End OpCode buffer exist.
4043 if (OpCodeBufferEnd
!= NULL
) {
4044 Offset
+= IfrOpHdr
->Length
;
4045 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((UINT8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4046 UpdateIfrOpHdr
= (EFI_IFR_OP_HEADER
*) OpCodeBufferEnd
->Buffer
;
4047 while (Offset
< PackageHeader
.Length
) {
4049 // Search the matched end opcode
4051 if ((UpdateIfrOpHdr
->Length
== IfrOpHdr
->Length
) && \
4052 (CompareMem (IfrOpHdr
, UpdateIfrOpHdr
, UpdateIfrOpHdr
->Length
) == 0)) {
4056 // Go to the next Op-Code
4058 Offset
+= IfrOpHdr
->Length
;
4059 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((UINT8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4062 if (Offset
>= PackageHeader
.Length
) {
4064 // The end opcode is not found.
4066 return EFI_NOT_FOUND
;
4071 // Insert the updated data
4073 AddSize
= ((EFI_IFR_OP_HEADER
*) OpCodeBufferStart
->Buffer
)->Length
;
4074 CopyMem (BufferPos
, OpCodeBufferStart
->Buffer
+ AddSize
, OpCodeBufferStart
->Position
- AddSize
);
4075 BufferPos
+= OpCodeBufferStart
->Position
- AddSize
;
4076 UpdatePackageLength
+= OpCodeBufferStart
->Position
- AddSize
;
4078 if (OpCodeBufferEnd
!= NULL
) {
4080 // Add the end opcode
4082 CopyMem (BufferPos
, IfrOpHdr
, IfrOpHdr
->Length
);
4083 BufferPos
+= IfrOpHdr
->Length
;
4084 UpdatePackageLength
+= IfrOpHdr
->Length
;
4088 // Copy the left package data.
4090 Offset
+= IfrOpHdr
->Length
;
4091 CopyMem (BufferPos
, (UINT8
*) Package
+ Offset
, PackageHeader
.Length
- Offset
);
4092 UpdatePackageLength
+= PackageHeader
.Length
- Offset
;
4103 // Go to the next Op-Code
4105 Offset
+= IfrOpHdr
->Length
;
4106 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((CHAR8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4111 // The updated opcode buffer is not found.
4113 return EFI_NOT_FOUND
;
4116 // Update the package length.
4118 PackageHeader
.Length
= (UINT32
) UpdatePackageLength
;
4119 CopyMem (TempPackage
, &PackageHeader
, sizeof (EFI_HII_PACKAGE_HEADER
));
4125 This function updates a form that has previously been registered with the HII
4126 Database. This function will perform at most one update operation.
4128 The form to update is specified by Handle, FormSetGuid, and FormId. Binary
4129 comparisons of IFR opcodes are performed from the beginning of the form being
4130 updated until an IFR opcode is found that exactly matches the first IFR opcode
4131 specified by StartOpCodeHandle. The following rules are used to determine if
4132 an insert, replace, or delete operation is performed.
4134 1) If no matches are found, then NULL is returned.
4135 2) If a match is found, and EndOpCodeHandle is NULL, then all of the IFR opcodes
4136 from StartOpCodeHandle except the first opcode are inserted immediately after
4137 the matching IFR opcode in the form to be updated.
4138 3) If a match is found, and EndOpCodeHandle is not NULL, then a search is made
4139 from the matching IFR opcode until an IFR opcode exactly matches the first
4140 IFR opcode specified by EndOpCodeHandle. If no match is found for the first
4141 IFR opcode specified by EndOpCodeHandle, then NULL is returned. If a match
4142 is found, then all of the IFR opcodes between the start match and the end
4143 match are deleted from the form being updated and all of the IFR opcodes
4144 from StartOpCodeHandle except the first opcode are inserted immediately after
4145 the matching start IFR opcode. If StartOpCcodeHandle only contains one
4146 IFR instruction, then the result of this operation will delete all of the IFR
4147 opcodes between the start end matches.
4149 If HiiHandle is NULL, then ASSERT().
4150 If StartOpCodeHandle is NULL, then ASSERT().
4152 @param[in] HiiHandle The HII Handle of the form to update.
4153 @param[in] FormSetGuid The Formset GUID of the form to update. This
4154 is an optional parameter that may be NULL.
4155 If it is NULL, all FormSet will be updated.
4156 @param[in] FormId The ID of the form to update.
4157 @param[in] StartOpCodeHandle An OpCode Handle that contains the set of IFR
4158 opcodes to be inserted or replaced in the form.
4159 The first IFR instruction in StartOpCodeHandle
4160 is used to find matching IFR opcode in the
4162 @param[in] EndOpCodeHandle An OpCcode Handle that contains the IFR opcode
4163 that marks the end of a replace operation in
4164 the form. This is an optional parameter that
4165 may be NULL. If it is NULL, then an the IFR
4166 opcodes specified by StartOpCodeHandle are
4167 inserted into the form.
4169 @retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated.
4170 @retval EFI_NOT_FOUND The following cases will return EFI_NOT_FOUND.
4171 1) The form specified by HiiHandle, FormSetGuid,
4172 and FormId could not be found in the HII Database.
4173 2) No IFR opcodes in the target form match the first
4174 IFR opcode in StartOpCodeHandle.
4175 3) EndOpCOde is not NULL, and no IFR opcodes in the
4176 target form following a matching start opcode match
4177 the first IFR opcode in EndOpCodeHandle.
4178 @retval EFI_SUCCESS The matched form is updated by StartOpcode.
4184 IN EFI_HII_HANDLE HiiHandle
,
4185 IN EFI_GUID
*FormSetGuid
, OPTIONAL
4186 IN EFI_FORM_ID FormId
,
4187 IN VOID
*StartOpCodeHandle
,
4188 IN VOID
*EndOpCodeHandle OPTIONAL
4192 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
4193 UINT32 PackageListLength
;
4195 EFI_HII_PACKAGE_LIST_HEADER
*UpdatePackageList
;
4197 UINT8
*UpdateBufferPos
;
4198 EFI_HII_PACKAGE_HEADER
*Package
;
4199 EFI_HII_PACKAGE_HEADER
*TempPacakge
;
4200 EFI_HII_PACKAGE_HEADER PackageHeader
;
4202 HII_LIB_OPCODE_BUFFER
*OpCodeBufferStart
;
4203 HII_LIB_OPCODE_BUFFER
*OpCodeBufferEnd
;
4206 // Input update data can't be NULL.
4208 ASSERT (HiiHandle
!= NULL
);
4209 ASSERT (StartOpCodeHandle
!= NULL
);
4210 UpdatePackageList
= NULL
;
4212 HiiPackageList
= NULL
;
4215 // Retrieve buffer data from Opcode Handle
4217 OpCodeBufferStart
= (HII_LIB_OPCODE_BUFFER
*) StartOpCodeHandle
;
4218 OpCodeBufferEnd
= (HII_LIB_OPCODE_BUFFER
*) EndOpCodeHandle
;
4221 // Get the original package list
4224 HiiPackageList
= NULL
;
4225 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
4227 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
4229 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
4233 HiiPackageList
= AllocatePool (BufferSize
);
4234 if (HiiPackageList
== NULL
) {
4235 Status
= EFI_OUT_OF_RESOURCES
;
4239 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
4240 if (EFI_ERROR (Status
)) {
4245 // Calculate and allocate space for retrieval of IFR data
4247 BufferSize
+= OpCodeBufferStart
->Position
;
4248 UpdatePackageList
= AllocateZeroPool (BufferSize
);
4249 if (UpdatePackageList
== NULL
) {
4250 Status
= EFI_OUT_OF_RESOURCES
;
4255 // Allocate temp buffer to store the temp updated package buffer
4257 TempPacakge
= AllocateZeroPool (BufferSize
);
4258 if (TempPacakge
== NULL
) {
4259 Status
= EFI_OUT_OF_RESOURCES
;
4263 UpdateBufferPos
= (UINT8
*) UpdatePackageList
;
4266 // Copy the package list header
4268 CopyMem (UpdateBufferPos
, HiiPackageList
, sizeof (EFI_HII_PACKAGE_LIST_HEADER
));
4269 UpdateBufferPos
+= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
4272 // Go through each package to find the matched package and update one by one
4275 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
4276 PackageListLength
= ReadUnaligned32 (&HiiPackageList
->PackageLength
);
4277 while (Offset
< PackageListLength
) {
4278 Package
= (EFI_HII_PACKAGE_HEADER
*) (((UINT8
*) HiiPackageList
) + Offset
);
4279 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4280 Offset
+= Package
->Length
;
4282 if (Package
->Type
== EFI_HII_PACKAGE_FORMS
) {
4284 // Check this package is the matched package.
4286 Status
= InternalHiiUpdateFormPackageData (FormSetGuid
, FormId
, Package
, OpCodeBufferStart
, OpCodeBufferEnd
, TempPacakge
);
4288 // The matched package is found. Its package buffer will be updated by the input new data.
4290 if (!EFI_ERROR(Status
)) {
4296 // Add updated package buffer
4298 Package
= TempPacakge
;
4303 // Add pacakge buffer
4305 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4306 CopyMem (UpdateBufferPos
, Package
, PackageHeader
.Length
);
4307 UpdateBufferPos
+= PackageHeader
.Length
;
4312 // Update package list length
4314 BufferSize
= UpdateBufferPos
- (UINT8
*) UpdatePackageList
;
4315 WriteUnaligned32 (&UpdatePackageList
->PackageLength
, (UINT32
) BufferSize
);
4318 // Update Package to show form
4320 Status
= gHiiDatabase
->UpdatePackageList (gHiiDatabase
, HiiHandle
, UpdatePackageList
);
4323 // Not matched form is found and updated.
4325 Status
= EFI_NOT_FOUND
;
4329 if (HiiPackageList
!= NULL
) {
4330 FreePool (HiiPackageList
);
4333 if (UpdatePackageList
!= NULL
) {
4334 FreePool (UpdatePackageList
);
4337 if (TempPacakge
!= NULL
) {
4338 FreePool (TempPacakge
);