2 HII Library implementation that uses DXE protocols and services.
4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "InternalHiiLib.h"
17 #define GUID_CONFIG_STRING_TYPE 0x00
18 #define NAME_CONFIG_STRING_TYPE 0x01
19 #define PATH_CONFIG_STRING_TYPE 0x02
21 #define ACTION_SET_DEFAUTL_VALUE 0x01
22 #define ACTION_VALIDATE_SETTING 0x02
24 #define HII_LIB_DEFAULT_VARSTORE_SIZE 0x200
27 LIST_ENTRY Entry
; // Link to Block array
35 EFI_VARSTORE_ID VarStoreId
;
37 } IFR_VARSTORAGE_DATA
;
40 // <ConfigHdr> Template
42 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR16 mConfigHdrTemplate
[] = L
"GUID=00000000000000000000000000000000&NAME=0000&PATH=00";
44 EFI_FORM_BROWSER2_PROTOCOL
*mUefiFormBrowser2
= NULL
;
47 // Template used to mark the end of a list of packages
49 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_PACKAGE_HEADER mEndOfPakageList
= {
50 sizeof (EFI_HII_PACKAGE_HEADER
),
55 Extract Hii package list GUID for given HII handle.
57 If HiiHandle could not be found in the HII database, then ASSERT.
58 If Guid is NULL, then ASSERT.
60 @param Handle Hii handle
61 @param Guid Package list GUID
63 @retval EFI_SUCCESS Successfully extract GUID from Hii database.
68 InternalHiiExtractGuidFromHiiHandle (
69 IN EFI_HII_HANDLE Handle
,
75 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
77 ASSERT (Guid
!= NULL
);
78 ASSERT (Handle
!= NULL
);
81 // Get HII PackageList
84 HiiPackageList
= NULL
;
86 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &BufferSize
, HiiPackageList
);
87 ASSERT (Status
!= EFI_NOT_FOUND
);
89 if (Status
== EFI_BUFFER_TOO_SMALL
) {
90 HiiPackageList
= AllocatePool (BufferSize
);
91 ASSERT (HiiPackageList
!= NULL
);
93 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &BufferSize
, HiiPackageList
);
95 if (EFI_ERROR (Status
)) {
96 FreePool (HiiPackageList
);
103 CopyGuid (Guid
, &HiiPackageList
->PackageListGuid
);
105 FreePool (HiiPackageList
);
111 Registers a list of packages in the HII Database and returns the HII Handle
112 associated with that registration. If an HII Handle has already been registered
113 with the same PackageListGuid and DeviceHandle, then NULL is returned. If there
114 are not enough resources to perform the registration, then NULL is returned.
115 If an empty list of packages is passed in, then NULL is returned. If the size of
116 the list of package is 0, then NULL is returned.
118 The variable arguments are pointers which point to package header that defined
119 by UEFI VFR compiler and StringGather tool.
121 #pragma pack (push, 1)
124 EFI_HII_PACKAGE_HEADER PackageHeader;
125 } EDKII_AUTOGEN_PACKAGES_HEADER;
128 @param[in] PackageListGuid The GUID of the package list.
129 @param[in] DeviceHandle If not NULL, the Device Handle on which
130 an instance of DEVICE_PATH_PROTOCOL is installed.
131 This Device Handle uniquely defines the device that
132 the added packages are associated with.
133 @param[in] ... The variable argument list that contains pointers
134 to packages terminated by a NULL.
136 @retval NULL A HII Handle has already been registered in the HII Database with
137 the same PackageListGuid and DeviceHandle.
138 @retval NULL The HII Handle could not be created.
139 @retval NULL An empty list of packages was passed in.
140 @retval NULL All packages are empty.
141 @retval Other The HII Handle associated with the newly registered package list.
147 IN CONST EFI_GUID
*PackageListGuid
,
148 IN EFI_HANDLE DeviceHandle OPTIONAL
,
155 EFI_HII_PACKAGE_LIST_HEADER
*PackageListHeader
;
156 EFI_HII_HANDLE HiiHandle
;
160 ASSERT (PackageListGuid
!= NULL
);
163 // Calculate the length of all the packages in the variable argument list
165 for (Length
= 0, VA_START (Args
, DeviceHandle
); (Package
= VA_ARG (Args
, UINT32
*)) != NULL
; ) {
166 Length
+= (ReadUnaligned32 (Package
) - sizeof (UINT32
));
171 // If there are no packages in the variable argument list or all the packages
172 // are empty, then return a NULL HII Handle
179 // Add the length of the Package List Header and the terminating Package Header
181 Length
+= sizeof (EFI_HII_PACKAGE_LIST_HEADER
) + sizeof (EFI_HII_PACKAGE_HEADER
);
184 // Allocate the storage for the entire Package List
186 PackageListHeader
= AllocateZeroPool (Length
);
189 // If the Package List can not be allocated, then return a NULL HII Handle
191 if (PackageListHeader
== NULL
) {
196 // Fill in the GUID and Length of the Package List Header
198 CopyGuid (&PackageListHeader
->PackageListGuid
, PackageListGuid
);
199 PackageListHeader
->PackageLength
= Length
;
202 // Initialize a pointer to the beginning if the Package List data
204 Data
= (UINT8
*)(PackageListHeader
+ 1);
207 // Copy the data from each package in the variable argument list
209 for (VA_START (Args
, DeviceHandle
); (Package
= VA_ARG (Args
, UINT32
*)) != NULL
; ) {
210 Length
= ReadUnaligned32 (Package
) - sizeof (UINT32
);
211 CopyMem (Data
, Package
+ 1, Length
);
217 // Append a package of type EFI_HII_PACKAGE_END to mark the end of the package list
219 CopyMem (Data
, &mEndOfPakageList
, sizeof (mEndOfPakageList
));
222 // Register the package list with the HII Database
224 Status
= gHiiDatabase
->NewPackageList (
230 if (EFI_ERROR (Status
)) {
235 // Free the allocated package list
237 FreePool (PackageListHeader
);
240 // Return the new HII Handle
246 Removes a package list from the HII database.
248 If HiiHandle is NULL, then ASSERT.
249 If HiiHandle is not a valid EFI_HII_HANDLE in the HII database, then ASSERT.
251 @param[in] HiiHandle The handle that was previously registered in the HII database
257 IN EFI_HII_HANDLE HiiHandle
262 ASSERT (HiiHandle
!= NULL
);
263 Status
= gHiiDatabase
->RemovePackageList (gHiiDatabase
, HiiHandle
);
264 ASSERT_EFI_ERROR (Status
);
269 Retrieves the array of all the HII Handles or the HII handles of a specific
270 package list GUID in the HII Database.
271 This array is terminated with a NULL HII Handle.
272 This function allocates the returned array using AllocatePool().
273 The caller is responsible for freeing the array with FreePool().
275 @param[in] PackageListGuid An optional parameter that is used to request
276 HII Handles associated with a specific
277 Package List GUID. If this parameter is NULL,
278 then all the HII Handles in the HII Database
279 are returned. If this parameter is not NULL,
280 then zero or more HII Handles associated with
281 PackageListGuid are returned.
283 @retval NULL No HII handles were found in the HII database
284 @retval NULL The array of HII Handles could not be retrieved
285 @retval Other A pointer to the NULL terminated array of HII Handles
291 IN CONST EFI_GUID
*PackageListGuid OPTIONAL
295 UINTN HandleBufferLength
;
296 EFI_HII_HANDLE TempHiiHandleBuffer
;
297 EFI_HII_HANDLE
*HiiHandleBuffer
;
303 // Retrieve the size required for the buffer of all HII handles.
305 HandleBufferLength
= 0;
306 Status
= gHiiDatabase
->ListPackageLists (
308 EFI_HII_PACKAGE_TYPE_ALL
,
315 // If ListPackageLists() returns EFI_SUCCESS for a zero size,
316 // then there are no HII handles in the HII database. If ListPackageLists()
317 // returns an error other than EFI_BUFFER_TOO_SMALL, then there are no HII
318 // handles in the HII database.
320 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
322 // Return NULL if the size can not be retrieved, or if there are no HII
323 // handles in the HII Database
329 // Allocate the array of HII handles to hold all the HII Handles and a NULL terminator
331 HiiHandleBuffer
= AllocateZeroPool (HandleBufferLength
+ sizeof (EFI_HII_HANDLE
));
332 if (HiiHandleBuffer
== NULL
) {
334 // Return NULL if allocation fails.
340 // Retrieve the array of HII Handles in the HII Database
342 Status
= gHiiDatabase
->ListPackageLists (
344 EFI_HII_PACKAGE_TYPE_ALL
,
349 if (EFI_ERROR (Status
)) {
351 // Free the buffer and return NULL if the HII handles can not be retrieved.
353 FreePool (HiiHandleBuffer
);
357 if (PackageListGuid
== NULL
) {
359 // Return the NULL terminated array of HII handles in the HII Database
361 return HiiHandleBuffer
;
363 for (Index1
= 0, Index2
= 0; HiiHandleBuffer
[Index1
] != NULL
; Index1
++) {
364 Status
= InternalHiiExtractGuidFromHiiHandle (HiiHandleBuffer
[Index1
], &Guid
);
365 ASSERT_EFI_ERROR (Status
);
366 if (CompareGuid (&Guid
, PackageListGuid
)) {
367 HiiHandleBuffer
[Index2
++] = HiiHandleBuffer
[Index1
];
371 HiiHandleBuffer
[Index2
] = NULL
;
372 return HiiHandleBuffer
;
374 FreePool (HiiHandleBuffer
);
381 This function allows a caller to extract the form set opcode form the Hii Handle.
382 The returned buffer is allocated using AllocatePool().The caller is responsible
383 for freeing the allocated buffer using FreePool().
385 @param Handle The HII handle.
386 @param Buffer On return, points to a pointer which point to the buffer that contain the formset opcode.
387 @param BufferSize On return, points to the length of the buffer.
389 @retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated.
390 @retval EFI_NOT_FOUND Can't find the package data for the input Handle.
391 @retval EFI_INVALID_PARAMETER The input parameters are not correct.
392 @retval EFI_SUCCESS Get the formset opcode from the hii handle successfully.
397 HiiGetFormSetFromHiiHandle(
398 IN EFI_HII_HANDLE Handle
,
399 OUT EFI_IFR_FORM_SET
**Buffer
,
400 OUT UINTN
*BufferSize
404 UINTN PackageListSize
;
406 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
409 UINT8
*FormSetBuffer
;
413 UINT32 PackageListLength
;
414 EFI_HII_PACKAGE_HEADER PackageHeader
;
417 FormSetBuffer
= NULL
;
421 // Get HII PackageList
424 HiiPackageList
= NULL
;
425 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &PackageListSize
, HiiPackageList
);
426 if (EFI_ERROR (Status
) && (Status
!= EFI_BUFFER_TOO_SMALL
)) {
430 HiiPackageList
= AllocatePool (PackageListSize
);
431 if (HiiPackageList
== NULL
) {
432 return EFI_OUT_OF_RESOURCES
;
435 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, Handle
, &PackageListSize
, HiiPackageList
);
436 ASSERT_EFI_ERROR (Status
);
439 // Get Form package from this HII package List
441 Status
= EFI_NOT_FOUND
;
442 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
443 PackageListLength
= ReadUnaligned32 (&HiiPackageList
->PackageLength
);
445 while (Offset
< PackageListLength
) {
446 Package
= ((UINT8
*) HiiPackageList
) + Offset
;
447 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
448 Offset
+= PackageHeader
.Length
;
450 if (PackageHeader
.Type
!= EFI_HII_PACKAGE_FORMS
) {
455 // Search FormSet Opcode in this Form Package
457 Offset2
= sizeof (EFI_HII_PACKAGE_HEADER
);
458 while (Offset2
< PackageHeader
.Length
) {
459 OpCodeData
= Package
+ Offset2
;
460 Offset2
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
462 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
!= EFI_IFR_FORM_SET_OP
) {
466 if (FormSetBuffer
!= NULL
){
467 TempBuffer
= AllocateCopyPool (TempSize
+ ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
, FormSetBuffer
);
468 FreePool(FormSetBuffer
);
469 FormSetBuffer
= NULL
;
470 if (TempBuffer
== NULL
) {
471 Status
= EFI_OUT_OF_RESOURCES
;
474 CopyMem (TempBuffer
+ TempSize
, OpCodeData
, ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
);
476 TempBuffer
= AllocateCopyPool (TempSize
+ ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
, OpCodeData
);
477 if (TempBuffer
== NULL
) {
478 Status
= EFI_OUT_OF_RESOURCES
;
482 TempSize
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
483 FormSetBuffer
= TempBuffer
;
485 Status
= EFI_SUCCESS
;
487 //One form package has one formset, exit current form package to search other form package in the packagelist.
493 FreePool (HiiPackageList
);
495 *BufferSize
= TempSize
;
496 *Buffer
= (EFI_IFR_FORM_SET
*)FormSetBuffer
;
502 Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for
503 hex digits that appear between a '=' and a '&' in a config string.
505 If ConfigString is NULL, then ASSERT().
507 @param[in] ConfigString Pointer to a Null-terminated Unicode string.
509 @return Pointer to the Null-terminated Unicode result string.
514 InternalHiiLowerConfigString (
515 IN EFI_STRING ConfigString
521 ASSERT (ConfigString
!= NULL
);
524 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
526 for (String
= ConfigString
, Lower
= FALSE
; *String
!= L
'\0'; String
++) {
527 if (*String
== L
'=') {
529 } else if (*String
== L
'&') {
531 } else if (Lower
&& *String
>= L
'A' && *String
<= L
'F') {
532 *String
= (CHAR16
) (*String
- L
'A' + L
'a');
540 Uses the BlockToConfig() service of the Config Routing Protocol to
541 convert <ConfigRequest> and a buffer to a <ConfigResp>
543 If ConfigRequest is NULL, then ASSERT().
544 If Block is NULL, then ASSERT().
546 @param[in] ConfigRequest Pointer to a Null-terminated Unicode string.
547 @param[in] Block Pointer to a block of data.
548 @param[in] BlockSize The zie, in bytes, of Block.
550 @retval NULL The <ConfigResp> string could not be generated.
551 @retval Other Pointer to the Null-terminated Unicode <ConfigResp> string.
556 InternalHiiBlockToConfig (
557 IN CONST EFI_STRING ConfigRequest
,
558 IN CONST UINT8
*Block
,
563 EFI_STRING ConfigResp
;
566 ASSERT (ConfigRequest
!= NULL
);
567 ASSERT (Block
!= NULL
);
570 // Convert <ConfigRequest> to <ConfigResp>
572 Status
= gHiiConfigRouting
->BlockToConfig (
580 if (EFI_ERROR (Status
)) {
587 Uses the BrowserCallback() service of the Form Browser Protocol to retrieve
588 or set uncommitted data. If sata i being retrieved, then the buffer is
589 allocated using AllocatePool(). The caller is then responsible for freeing
590 the buffer using FreePool().
592 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
593 parameter that may be NULL.
594 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
595 is an optional parameter that may be NULL.
596 @param[in] SetResultsData If not NULL, then this parameter specified the buffer
597 of uncommited data to set. If this parameter is NULL,
598 then the caller is requesting to get the uncommited data
599 from the Form Browser.
601 @retval NULL The uncommitted data could not be retrieved.
602 @retval Other A pointer to a buffer containing the uncommitted data.
607 InternalHiiBrowserCallback (
608 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
609 IN CONST CHAR16
*VariableName
, OPTIONAL
610 IN CONST EFI_STRING SetResultsData OPTIONAL
614 UINTN ResultsDataSize
;
615 EFI_STRING ResultsData
;
616 CHAR16 TempResultsData
;
621 if (mUefiFormBrowser2
== NULL
) {
622 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &mUefiFormBrowser2
);
623 if (EFI_ERROR (Status
) || mUefiFormBrowser2
== NULL
) {
630 if (SetResultsData
!= NULL
) {
632 // Request to to set data in the uncommitted browser state information
634 ResultsData
= SetResultsData
;
637 // Retrieve the length of the buffer required ResultsData from the Browser Callback
639 Status
= mUefiFormBrowser2
->BrowserCallback (
648 if (!EFI_ERROR (Status
)) {
650 // No Resluts Data, only allocate one char for '\0'
652 ResultsData
= AllocateZeroPool (sizeof (CHAR16
));
656 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
661 // Allocate the ResultsData buffer
663 ResultsData
= AllocateZeroPool (ResultsDataSize
);
664 if (ResultsData
== NULL
) {
670 // Retrieve or set the ResultsData from the Browser Callback
672 Status
= mUefiFormBrowser2
->BrowserCallback (
676 (BOOLEAN
)(SetResultsData
== NULL
),
680 if (EFI_ERROR (Status
)) {
688 Allocates and returns a Null-terminated Unicode <ConfigHdr> string using routing
689 information that includes a GUID, an optional Unicode string name, and a device
690 path. The string returned is allocated with AllocatePool(). The caller is
691 responsible for freeing the allocated string with FreePool().
693 The format of a <ConfigHdr> is as follows:
695 GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize<Null>
697 @param[in] Guid Pointer to an EFI_GUID that is the routing information
698 GUID. Each of the 16 bytes in Guid is converted to
699 a 2 Unicode character hexadecimal string. This is
700 an optional parameter that may be NULL.
701 @param[in] Name Pointer to a Null-terminated Unicode string that is
702 the routing information NAME. This is an optional
703 parameter that may be NULL. Each 16-bit Unicode
704 character in Name is converted to a 4 character Unicode
706 @param[in] DriverHandle The driver handle which supports a Device Path Protocol
707 that is the routing information PATH. Each byte of
708 the Device Path associated with DriverHandle is converted
709 to a 2 Unicode character hexadecimal string.
711 @retval NULL DriverHandle does not support the Device Path Protocol.
712 @retval Other A pointer to the Null-terminate Unicode <ConfigHdr> string
717 HiiConstructConfigHdr (
718 IN CONST EFI_GUID
*Guid
, OPTIONAL
719 IN CONST CHAR16
*Name
, OPTIONAL
720 IN EFI_HANDLE DriverHandle
724 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
725 UINTN DevicePathSize
;
727 CHAR16
*ReturnString
;
733 // Compute the length of Name in Unicode characters.
734 // If Name is NULL, then the length is 0.
738 NameLength
= StrLen (Name
);
744 // Retrieve DevicePath Protocol associated with DriverHandle
746 if (DriverHandle
!= NULL
) {
747 DevicePath
= DevicePathFromHandle (DriverHandle
);
748 if (DevicePath
== NULL
) {
752 // Compute the size of the device path in bytes
754 DevicePathSize
= GetDevicePathSize (DevicePath
);
758 // GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize <Null>
759 // | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 |
761 MaxLen
= 5 + sizeof (EFI_GUID
) * 2 + 6 + NameLength
* 4 + 6 + DevicePathSize
* 2 + 1;
762 String
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
763 if (String
== NULL
) {
768 // Start with L"GUID="
770 StrCpyS (String
, MaxLen
, L
"GUID=");
771 ReturnString
= String
;
772 String
+= StrLen (String
);
776 // Append Guid converted to <HexCh>32
778 for (Index
= 0, Buffer
= (UINT8
*)Guid
; Index
< sizeof (EFI_GUID
); Index
++) {
779 UnicodeValueToStringS (
781 MaxLen
* sizeof (CHAR16
) - ((UINTN
)String
- (UINTN
)ReturnString
),
782 PREFIX_ZERO
| RADIX_HEX
,
786 String
+= StrnLenS (String
, MaxLen
- ((UINTN
)String
- (UINTN
)ReturnString
) / sizeof (CHAR16
));
793 StrCatS (ReturnString
, MaxLen
, L
"&NAME=");
794 String
+= StrLen (String
);
798 // Append Name converted to <Char>NameLength
800 for (; *Name
!= L
'\0'; Name
++) {
801 UnicodeValueToStringS (
803 sizeof (CHAR16
) * MaxLen
- ((UINTN
)String
- (UINTN
)ReturnString
),
804 PREFIX_ZERO
| RADIX_HEX
,
808 String
+= StrnLenS (String
, MaxLen
- ((UINTN
)String
- (UINTN
)ReturnString
) / sizeof (CHAR16
));
815 StrCatS (ReturnString
, MaxLen
, L
"&PATH=");
816 String
+= StrLen (String
);
819 // Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize
821 for (Index
= 0, Buffer
= (UINT8
*)DevicePath
; Index
< DevicePathSize
; Index
++) {
822 UnicodeValueToStringS (
824 sizeof (CHAR16
) * MaxLen
- ((UINTN
)String
- (UINTN
)ReturnString
),
825 PREFIX_ZERO
| RADIX_HEX
,
829 String
+= StrnLenS (String
, MaxLen
- ((UINTN
)String
- (UINTN
)ReturnString
) / sizeof (CHAR16
));
833 // Null terminate the Unicode string
838 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
840 return InternalHiiLowerConfigString (ReturnString
);
844 Convert the hex UNICODE encoding string of UEFI GUID, NAME or device path
845 to binary buffer from <ConfigHdr>.
847 This is a internal function.
849 @param String UEFI configuration string.
850 @param Flag Flag specifies what type buffer will be retrieved.
851 @param Buffer Binary of Guid, Name or Device path.
853 @retval EFI_INVALID_PARAMETER Any incoming parameter is invalid.
854 @retval EFI_OUT_OF_RESOURCES Lake of resources to store neccesary structures.
855 @retval EFI_SUCCESS The buffer data is retrieved and translated to
860 InternalHiiGetBufferFromString (
861 IN EFI_STRING String
,
867 EFI_STRING ConfigHdr
;
874 if (String
== NULL
|| Buffer
== NULL
) {
875 return EFI_INVALID_PARAMETER
;
882 // The content between 'GUID', 'NAME', 'PATH' of <ConfigHdr> and '&' of next element
883 // or '\0' (end of configuration string) is the UNICODE %02x bytes encoding string.
885 for (Length
= 0; *String
!= 0 && *String
!= L
'&'; String
++, Length
++);
888 case GUID_CONFIG_STRING_TYPE
:
889 case PATH_CONFIG_STRING_TYPE
:
891 // The data in <ConfigHdr> is encoded as hex UNICODE %02x bytes in the same order
892 // as the device path and Guid resides in RAM memory.
893 // Translate the data into binary.
895 DataBuffer
= (UINT8
*) AllocateZeroPool ((Length
+ 1) / 2);
896 if (DataBuffer
== NULL
) {
897 return EFI_OUT_OF_RESOURCES
;
900 // Convert binary byte one by one
902 ZeroMem (TemStr
, sizeof (TemStr
));
903 for (Index
= 0; Index
< Length
; Index
++) {
904 TemStr
[0] = ConfigHdr
[Index
];
905 DigitUint8
= (UINT8
) StrHexToUint64 (TemStr
);
906 if ((Index
& 1) == 0) {
907 DataBuffer
[Index
/2] = DigitUint8
;
909 DataBuffer
[Index
/2] = (UINT8
) ((DataBuffer
[Index
/2] << 4) + DigitUint8
);
913 *Buffer
= DataBuffer
;
916 case NAME_CONFIG_STRING_TYPE
:
918 // Convert Config String to Unicode String, e.g. "0041004200430044" => "ABCD"
922 // Add the tailling char L'\0'
924 DataBuffer
= (UINT8
*) AllocateZeroPool ((Length
/4 + 1) * sizeof (CHAR16
));
925 if (DataBuffer
== NULL
) {
926 return EFI_OUT_OF_RESOURCES
;
929 // Convert character one by one
931 StringPtr
= (CHAR16
*) DataBuffer
;
932 ZeroMem (TemStr
, sizeof (TemStr
));
933 for (Index
= 0; Index
< Length
; Index
+= 4) {
934 StrnCpyS (TemStr
, sizeof (TemStr
) / sizeof (CHAR16
), ConfigHdr
+ Index
, 4);
935 StringPtr
[Index
/4] = (CHAR16
) StrHexToUint64 (TemStr
);
938 // Add tailing L'\0' character
940 StringPtr
[Index
/4] = L
'\0';
942 *Buffer
= DataBuffer
;
946 return EFI_INVALID_PARAMETER
;
953 This function checks VarOffset and VarWidth is in the block range.
955 @param BlockArray The block array is to be checked.
956 @param VarOffset Offset of var to the structure
957 @param VarWidth Width of var.
959 @retval TRUE This Var is in the block range.
960 @retval FALSE This Var is not in the block range.
964 IN IFR_BLOCK_DATA
*BlockArray
,
970 IFR_BLOCK_DATA
*BlockData
;
973 // No Request Block array, all vars are got.
975 if (BlockArray
== NULL
) {
980 // Check the input var is in the request block range.
982 for (Link
= BlockArray
->Entry
.ForwardLink
; Link
!= &BlockArray
->Entry
; Link
= Link
->ForwardLink
) {
983 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
984 if ((VarOffset
>= BlockData
->Offset
) && ((VarOffset
+ VarWidth
) <= (BlockData
->Offset
+ BlockData
->Width
))) {
993 Get the value of <Number> in <BlockConfig> format, i.e. the value of OFFSET
995 <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE'=<Number>
997 @param ValueString String in <BlockConfig> format and points to the
998 first character of <Number>.
999 @param ValueData The output value. Caller takes the responsibility
1001 @param ValueLength Length of the <Number>, in characters.
1003 @retval EFI_OUT_OF_RESOURCES Insufficient resources to store neccessary
1005 @retval EFI_SUCCESS Value of <Number> is outputted in Number
1011 InternalHiiGetValueOfNumber (
1012 IN EFI_STRING ValueString
,
1013 OUT UINT8
**ValueData
,
1014 OUT UINTN
*ValueLength
1017 EFI_STRING StringPtr
;
1024 ASSERT (ValueString
!= NULL
&& ValueData
!= NULL
&& ValueLength
!= NULL
);
1025 ASSERT (*ValueString
!= L
'\0');
1028 // Get the length of value string
1030 StringPtr
= ValueString
;
1031 while (*StringPtr
!= L
'\0' && *StringPtr
!= L
'&') {
1034 Length
= StringPtr
- ValueString
;
1037 // Allocate buffer to store the value
1039 Buf
= (UINT8
*) AllocateZeroPool ((Length
+ 1) / 2);
1041 return EFI_OUT_OF_RESOURCES
;
1045 // Convert character one by one to the value buffer
1047 ZeroMem (TemStr
, sizeof (TemStr
));
1048 for (Index
= 0; Index
< Length
; Index
++) {
1049 TemStr
[0] = ValueString
[Length
- Index
- 1];
1050 DigitUint8
= (UINT8
) StrHexToUint64 (TemStr
);
1051 if ((Index
& 1) == 0) {
1052 Buf
[Index
/2] = DigitUint8
;
1054 Buf
[Index
/2] = (UINT8
) ((DigitUint8
<< 4) + Buf
[Index
/2]);
1059 // Set the converted value and string length.
1062 *ValueLength
= Length
;
1067 Get value from config request resp string.
1069 @param ConfigElement ConfigResp string contains the current setting.
1070 @param VarName The variable name which need to get value.
1071 @param VarValue The return value.
1073 @retval EFI_SUCCESS Get the value for the VarName
1074 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1077 GetValueFromRequest (
1078 IN CHAR16
*ConfigElement
,
1080 OUT UINT64
*VarValue
1089 // Find VarName related string.
1091 StringPtr
= StrStr (ConfigElement
, VarName
);
1092 ASSERT (StringPtr
!= NULL
);
1095 // Skip the "VarName=" string
1097 StringPtr
+= StrLen (VarName
) + 1;
1102 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1103 if (EFI_ERROR (Status
)) {
1108 CopyMem (VarValue
, TmpBuffer
, (((Length
+ 1) / 2) < sizeof (UINT64
)) ? ((Length
+ 1) / 2) : sizeof (UINT64
));
1110 FreePool (TmpBuffer
);
1116 This internal function parses IFR data to validate current setting.
1118 Base on the NameValueType, if it is TRUE, RequestElement and HiiHandle is valid;
1119 else the VarBuffer and CurrentBlockArray is valid.
1121 @param HiiPackageList Point to Hii package list.
1122 @param PackageListLength The length of the pacakge.
1123 @param VarGuid Guid of the buffer storage.
1124 @param VarName Name of the buffer storage.
1125 @param VarBuffer The data buffer for the storage.
1126 @param CurrentBlockArray The block array from the config Requst string.
1127 @param RequestElement The config string for this storage.
1128 @param HiiHandle The HiiHandle for this formset.
1129 @param NameValueType Whether current storage is name/value varstore or not.
1131 @retval EFI_SUCCESS The current setting is valid.
1132 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1133 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1136 ValidateQuestionFromVfr (
1137 IN EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
,
1138 IN UINTN PackageListLength
,
1139 IN EFI_GUID
*VarGuid
,
1141 IN UINT8
*VarBuffer
,
1142 IN IFR_BLOCK_DATA
*CurrentBlockArray
,
1143 IN CHAR16
*RequestElement
,
1144 IN EFI_HII_HANDLE HiiHandle
,
1145 IN BOOLEAN NameValueType
1148 IFR_BLOCK_DATA VarBlockData
;
1152 EFI_IFR_TYPE_VALUE TmpValue
;
1154 EFI_HII_PACKAGE_HEADER PackageHeader
;
1155 UINT32 PackageOffset
;
1158 EFI_IFR_OP_HEADER
*IfrOpHdr
;
1159 EFI_IFR_VARSTORE
*IfrVarStore
;
1160 EFI_IFR_VARSTORE_NAME_VALUE
*IfrNameValueStore
;
1161 EFI_IFR_VARSTORE_EFI
*IfrEfiVarStore
;
1162 IFR_VARSTORAGE_DATA VarStoreData
;
1163 EFI_IFR_ONE_OF
*IfrOneOf
;
1164 EFI_IFR_NUMERIC
*IfrNumeric
;
1165 EFI_IFR_ONE_OF_OPTION
*IfrOneOfOption
;
1166 EFI_IFR_CHECKBOX
*IfrCheckBox
;
1167 EFI_IFR_STRING
*IfrString
;
1168 CHAR8
*VarStoreName
;
1170 CHAR16
*QuestionName
;
1174 // Initialize the local variables.
1177 VarStoreName
= NULL
;
1178 Status
= EFI_SUCCESS
;
1181 IfrNameValueStore
= NULL
;
1182 IfrEfiVarStore
= NULL
;
1183 ZeroMem (&VarStoreData
, sizeof (IFR_VARSTORAGE_DATA
));
1184 ZeroMem (&VarBlockData
, sizeof (VarBlockData
));
1187 // Check IFR value is in block data, then Validate Value
1189 PackageOffset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
1190 while (PackageOffset
< PackageListLength
) {
1191 CopyMem (&PackageHeader
, (UINT8
*) HiiPackageList
+ PackageOffset
, sizeof (PackageHeader
));
1194 // Parse IFR opcode from the form package.
1196 if (PackageHeader
.Type
== EFI_HII_PACKAGE_FORMS
) {
1197 IfrOffset
= sizeof (PackageHeader
);
1198 PackageData
= (UINT8
*) HiiPackageList
+ PackageOffset
;
1199 while (IfrOffset
< PackageHeader
.Length
) {
1200 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) (PackageData
+ IfrOffset
);
1202 // Validate current setting to the value built in IFR opcode
1204 switch (IfrOpHdr
->OpCode
) {
1205 case EFI_IFR_VARSTORE_OP
:
1207 // VarStoreId has been found. No further found.
1209 if (VarStoreData
.VarStoreId
!= 0) {
1213 // Find the matched VarStoreId to the input VarGuid and VarName
1215 IfrVarStore
= (EFI_IFR_VARSTORE
*) IfrOpHdr
;
1216 if (CompareGuid ((EFI_GUID
*) (VOID
*) &IfrVarStore
->Guid
, VarGuid
)) {
1217 VarStoreName
= (CHAR8
*) IfrVarStore
->Name
;
1218 for (Index
= 0; VarStoreName
[Index
] != 0; Index
++) {
1219 if ((CHAR16
) VarStoreName
[Index
] != VarName
[Index
]) {
1224 // The matched VarStore is found.
1226 if ((VarStoreName
[Index
] != 0) || (VarName
[Index
] != 0)) {
1233 if (IfrVarStore
!= NULL
) {
1234 VarStoreData
.VarStoreId
= IfrVarStore
->VarStoreId
;
1235 VarStoreData
.Size
= IfrVarStore
->Size
;
1238 case EFI_IFR_VARSTORE_NAME_VALUE_OP
:
1240 // VarStoreId has been found. No further found.
1242 if (VarStoreData
.VarStoreId
!= 0) {
1246 // Find the matched VarStoreId to the input VarGuid
1248 IfrNameValueStore
= (EFI_IFR_VARSTORE_NAME_VALUE
*) IfrOpHdr
;
1249 if (!CompareGuid ((EFI_GUID
*) (VOID
*) &IfrNameValueStore
->Guid
, VarGuid
)) {
1250 IfrNameValueStore
= NULL
;
1253 if (IfrNameValueStore
!= NULL
) {
1254 VarStoreData
.VarStoreId
= IfrNameValueStore
->VarStoreId
;
1257 case EFI_IFR_VARSTORE_EFI_OP
:
1259 // VarStore is found. Don't need to search any more.
1261 if (VarStoreData
.VarStoreId
!= 0) {
1265 IfrEfiVarStore
= (EFI_IFR_VARSTORE_EFI
*) IfrOpHdr
;
1268 // If the length is small than the structure, this is from old efi
1269 // varstore definition. Old efi varstore get config directly from
1270 // GetVariable function.
1272 if (IfrOpHdr
->Length
< sizeof (EFI_IFR_VARSTORE_EFI
)) {
1276 if (CompareGuid ((EFI_GUID
*) (VOID
*) &IfrEfiVarStore
->Guid
, VarGuid
)) {
1277 VarStoreName
= (CHAR8
*) IfrEfiVarStore
->Name
;
1278 for (Index
= 0; VarStoreName
[Index
] != 0; Index
++) {
1279 if ((CHAR16
) VarStoreName
[Index
] != VarName
[Index
]) {
1284 // The matched VarStore is found.
1286 if ((VarStoreName
[Index
] != 0) || (VarName
[Index
] != 0)) {
1287 IfrEfiVarStore
= NULL
;
1290 IfrEfiVarStore
= NULL
;
1293 if (IfrEfiVarStore
!= NULL
) {
1295 // Find the matched VarStore
1297 VarStoreData
.VarStoreId
= IfrEfiVarStore
->VarStoreId
;
1298 VarStoreData
.Size
= IfrEfiVarStore
->Size
;
1301 case EFI_IFR_FORM_OP
:
1302 case EFI_IFR_FORM_MAP_OP
:
1304 // Check the matched VarStoreId is found.
1306 if (VarStoreData
.VarStoreId
== 0) {
1310 case EFI_IFR_ONE_OF_OP
:
1312 // Check whether current value is the one of option.
1316 // OneOf question is not in IFR Form. This IFR form is not valid.
1318 if (VarStoreData
.VarStoreId
== 0) {
1319 return EFI_INVALID_PARAMETER
;
1322 // Check whether this question is for the requested varstore.
1324 IfrOneOf
= (EFI_IFR_ONE_OF
*) IfrOpHdr
;
1325 if (IfrOneOf
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1329 if (NameValueType
) {
1330 QuestionName
= HiiGetString (HiiHandle
, IfrOneOf
->Question
.VarStoreInfo
.VarName
, NULL
);
1331 ASSERT (QuestionName
!= NULL
);
1333 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1335 // This question is not in the current configuration string. Skip it.
1340 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1341 if (EFI_ERROR (Status
)) {
1346 // Get Offset by Question header and Width by DataType Flags
1348 Offset
= IfrOneOf
->Question
.VarStoreInfo
.VarOffset
;
1349 Width
= (UINT16
) (1 << (IfrOneOf
->Flags
& EFI_IFR_NUMERIC_SIZE
));
1351 // Check whether this question is in current block array.
1353 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1355 // This question is not in the current configuration string. Skip it.
1360 // Check this var question is in the var storage
1362 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1364 // This question exceeds the var store size.
1366 return EFI_INVALID_PARAMETER
;
1370 // Get the current value for oneof opcode
1373 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1376 // Set Block Data, to be checked in the following Oneof option opcode.
1378 VarBlockData
.OpCode
= IfrOpHdr
->OpCode
;
1379 VarBlockData
.Scope
= IfrOpHdr
->Scope
;
1381 case EFI_IFR_NUMERIC_OP
:
1383 // Check the current value is in the numeric range.
1387 // Numeric question is not in IFR Form. This IFR form is not valid.
1389 if (VarStoreData
.VarStoreId
== 0) {
1390 return EFI_INVALID_PARAMETER
;
1393 // Check whether this question is for the requested varstore.
1395 IfrNumeric
= (EFI_IFR_NUMERIC
*) IfrOpHdr
;
1396 if (IfrNumeric
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1400 if (NameValueType
) {
1401 QuestionName
= HiiGetString (HiiHandle
, IfrNumeric
->Question
.VarStoreInfo
.VarName
, NULL
);
1402 ASSERT (QuestionName
!= NULL
);
1404 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1406 // This question is not in the current configuration string. Skip it.
1411 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1412 if (EFI_ERROR (Status
)) {
1417 // Get Offset by Question header and Width by DataType Flags
1419 Offset
= IfrNumeric
->Question
.VarStoreInfo
.VarOffset
;
1420 Width
= (UINT16
) (1 << (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
));
1422 // Check whether this question is in current block array.
1424 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1426 // This question is not in the current configuration string. Skip it.
1431 // Check this var question is in the var storage
1433 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1435 // This question exceeds the var store size.
1437 return EFI_INVALID_PARAMETER
;
1441 // Check the current value is in the numeric range.
1444 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1446 if ((IfrNumeric
->Flags
& EFI_IFR_DISPLAY
) == 0) {
1447 switch (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1448 case EFI_IFR_NUMERIC_SIZE_1
:
1449 if ((INT8
) VarValue
< (INT8
) IfrNumeric
->data
.u8
.MinValue
|| (INT8
) VarValue
> (INT8
) IfrNumeric
->data
.u8
.MaxValue
) {
1451 // Not in the valid range.
1453 return EFI_INVALID_PARAMETER
;
1456 case EFI_IFR_NUMERIC_SIZE_2
:
1457 if ((INT16
) VarValue
< (INT16
) IfrNumeric
->data
.u16
.MinValue
|| (INT16
) VarValue
> (INT16
) IfrNumeric
->data
.u16
.MaxValue
) {
1459 // Not in the valid range.
1461 return EFI_INVALID_PARAMETER
;
1464 case EFI_IFR_NUMERIC_SIZE_4
:
1465 if ((INT32
) VarValue
< (INT32
) IfrNumeric
->data
.u32
.MinValue
|| (INT32
) VarValue
> (INT32
) IfrNumeric
->data
.u32
.MaxValue
) {
1467 // Not in the valid range.
1469 return EFI_INVALID_PARAMETER
;
1472 case EFI_IFR_NUMERIC_SIZE_8
:
1473 if ((INT64
) VarValue
< (INT64
) IfrNumeric
->data
.u64
.MinValue
|| (INT64
) VarValue
> (INT64
) IfrNumeric
->data
.u64
.MaxValue
) {
1475 // Not in the valid range.
1477 return EFI_INVALID_PARAMETER
;
1482 switch (IfrNumeric
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1483 case EFI_IFR_NUMERIC_SIZE_1
:
1484 if ((UINT8
) VarValue
< IfrNumeric
->data
.u8
.MinValue
|| (UINT8
) VarValue
> IfrNumeric
->data
.u8
.MaxValue
) {
1486 // Not in the valid range.
1488 return EFI_INVALID_PARAMETER
;
1491 case EFI_IFR_NUMERIC_SIZE_2
:
1492 if ((UINT16
) VarValue
< IfrNumeric
->data
.u16
.MinValue
|| (UINT16
) VarValue
> IfrNumeric
->data
.u16
.MaxValue
) {
1494 // Not in the valid range.
1496 return EFI_INVALID_PARAMETER
;
1499 case EFI_IFR_NUMERIC_SIZE_4
:
1500 if ((UINT32
) VarValue
< IfrNumeric
->data
.u32
.MinValue
|| (UINT32
) VarValue
> IfrNumeric
->data
.u32
.MaxValue
) {
1502 // Not in the valid range.
1504 return EFI_INVALID_PARAMETER
;
1507 case EFI_IFR_NUMERIC_SIZE_8
:
1508 if ((UINT64
) VarValue
< IfrNumeric
->data
.u64
.MinValue
|| (UINT64
) VarValue
> IfrNumeric
->data
.u64
.MaxValue
) {
1510 // Not in the valid range.
1512 return EFI_INVALID_PARAMETER
;
1518 case EFI_IFR_CHECKBOX_OP
:
1520 // Check value is BOOLEAN type, only 0 and 1 is valid.
1524 // CheckBox question is not in IFR Form. This IFR form is not valid.
1526 if (VarStoreData
.VarStoreId
== 0) {
1527 return EFI_INVALID_PARAMETER
;
1531 // Check whether this question is for the requested varstore.
1533 IfrCheckBox
= (EFI_IFR_CHECKBOX
*) IfrOpHdr
;
1534 if (IfrCheckBox
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1538 if (NameValueType
) {
1539 QuestionName
= HiiGetString (HiiHandle
, IfrCheckBox
->Question
.VarStoreInfo
.VarName
, NULL
);
1540 ASSERT (QuestionName
!= NULL
);
1542 if (StrStr (RequestElement
, QuestionName
) == NULL
) {
1544 // This question is not in the current configuration string. Skip it.
1549 Status
= GetValueFromRequest (RequestElement
, QuestionName
, &VarValue
);
1550 if (EFI_ERROR (Status
)) {
1555 // Get Offset by Question header
1557 Offset
= IfrCheckBox
->Question
.VarStoreInfo
.VarOffset
;
1558 Width
= (UINT16
) sizeof (BOOLEAN
);
1560 // Check whether this question is in current block array.
1562 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1564 // This question is not in the current configuration string. Skip it.
1569 // Check this var question is in the var storage
1571 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1573 // This question exceeds the var store size.
1575 return EFI_INVALID_PARAMETER
;
1578 // Check the current value is in the numeric range.
1581 CopyMem (&VarValue
, VarBuffer
+ Offset
, Width
);
1584 // Boolean type, only 1 and 0 is valid.
1587 return EFI_INVALID_PARAMETER
;
1590 case EFI_IFR_STRING_OP
:
1592 // Check current string length is less than maxsize
1596 // CheckBox question is not in IFR Form. This IFR form is not valid.
1598 if (VarStoreData
.VarStoreId
== 0) {
1599 return EFI_INVALID_PARAMETER
;
1603 // Check whether this question is for the requested varstore.
1605 IfrString
= (EFI_IFR_STRING
*) IfrOpHdr
;
1606 if (IfrString
->Question
.VarStoreId
!= VarStoreData
.VarStoreId
) {
1610 // Get Width by OneOf Flags
1612 Width
= (UINT16
) (IfrString
->MaxSize
* sizeof (UINT16
));
1613 if (NameValueType
) {
1614 QuestionName
= HiiGetString (HiiHandle
, IfrString
->Question
.VarStoreInfo
.VarName
, NULL
);
1615 ASSERT (QuestionName
!= NULL
);
1617 StringPtr
= StrStr (RequestElement
, QuestionName
);
1618 if (StringPtr
== NULL
) {
1620 // This question is not in the current configuration string. Skip it.
1631 // Check current string length is less than maxsize
1633 if (StrSize (StringPtr
) > Width
) {
1634 return EFI_INVALID_PARAMETER
;
1638 // Get Offset/Width by Question header and OneOf Flags
1640 Offset
= IfrString
->Question
.VarStoreInfo
.VarOffset
;
1642 // Check whether this question is in current block array.
1644 if (!BlockArrayCheck (CurrentBlockArray
, Offset
, Width
)) {
1646 // This question is not in the current configuration string. Skip it.
1651 // Check this var question is in the var storage
1653 if ((Offset
+ Width
) > VarStoreData
.Size
) {
1655 // This question exceeds the var store size.
1657 return EFI_INVALID_PARAMETER
;
1661 // Check current string length is less than maxsize
1663 if (StrSize ((CHAR16
*) (VarBuffer
+ Offset
)) > Width
) {
1664 return EFI_INVALID_PARAMETER
;
1668 case EFI_IFR_ONE_OF_OPTION_OP
:
1670 // Opcode Scope is zero. This one of option is not to be checked.
1672 if (VarBlockData
.Scope
== 0) {
1677 // Only check for OneOf and OrderList opcode
1679 IfrOneOfOption
= (EFI_IFR_ONE_OF_OPTION
*) IfrOpHdr
;
1680 if (VarBlockData
.OpCode
== EFI_IFR_ONE_OF_OP
) {
1682 // Check current value is the value of one of option.
1684 ASSERT (IfrOneOfOption
->Type
<= EFI_IFR_TYPE_NUM_SIZE_64
);
1685 ZeroMem (&TmpValue
, sizeof (EFI_IFR_TYPE_VALUE
));
1686 CopyMem (&TmpValue
, &IfrOneOfOption
->Value
, IfrOneOfOption
->Header
.Length
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
1687 if (VarValue
== TmpValue
.u64
) {
1689 // The value is one of option value.
1690 // Set OpCode to Zero, don't need check again.
1692 VarBlockData
.OpCode
= 0;
1696 case EFI_IFR_END_OP
:
1698 // Decrease opcode scope for the validated opcode
1700 if (VarBlockData
.Scope
> 0) {
1701 VarBlockData
.Scope
--;
1705 // OneOf value doesn't belong to one of option value.
1707 if ((VarBlockData
.Scope
== 0) && (VarBlockData
.OpCode
== EFI_IFR_ONE_OF_OP
)) {
1708 return EFI_INVALID_PARAMETER
;
1713 // Increase Scope for the validated opcode
1715 if (VarBlockData
.Scope
> 0) {
1716 VarBlockData
.Scope
= (UINT8
) (VarBlockData
.Scope
+ IfrOpHdr
->Scope
);
1721 // Go to the next opcode
1723 IfrOffset
+= IfrOpHdr
->Length
;
1726 // Only one form is in a package list.
1732 // Go to next package.
1734 PackageOffset
+= PackageHeader
.Length
;
1741 This internal function parses IFR data to validate current setting.
1743 @param ConfigElement ConfigResp element string contains the current setting.
1744 @param CurrentBlockArray Current block array.
1745 @param VarBuffer Data buffer for this varstore.
1747 @retval EFI_SUCCESS The current setting is valid.
1748 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
1749 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
1753 IN CHAR16
*ConfigElement
,
1754 OUT IFR_BLOCK_DATA
**CurrentBlockArray
,
1755 OUT UINT8
**VarBuffer
1758 IFR_BLOCK_DATA
*BlockData
;
1759 IFR_BLOCK_DATA
*NewBlockData
;
1760 EFI_STRING StringPtr
;
1766 UINTN MaxBufferSize
;
1768 IFR_BLOCK_DATA
*BlockArray
;
1772 // Initialize the local variables.
1774 Status
= EFI_SUCCESS
;
1776 NewBlockData
= NULL
;
1779 MaxBufferSize
= HII_LIB_DEFAULT_VARSTORE_SIZE
;
1780 DataBuffer
= AllocateZeroPool (MaxBufferSize
);
1781 if (DataBuffer
== NULL
) {
1782 return EFI_OUT_OF_RESOURCES
;
1788 BlockArray
= (IFR_BLOCK_DATA
*) AllocateZeroPool (sizeof (IFR_BLOCK_DATA
));
1789 if (BlockArray
== NULL
) {
1790 Status
= EFI_OUT_OF_RESOURCES
;
1793 InitializeListHead (&BlockArray
->Entry
);
1795 StringPtr
= StrStr (ConfigElement
, L
"&OFFSET=");
1796 ASSERT (StringPtr
!= NULL
);
1799 // Parse each <RequestElement> if exists
1800 // Only <BlockName> format is supported by this help function.
1801 // <BlockName> ::= &'OFFSET='<Number>&'WIDTH='<Number>
1803 while (*StringPtr
!= 0 && StrnCmp (StringPtr
, L
"&OFFSET=", StrLen (L
"&OFFSET=")) == 0) {
1805 // Skip the &OFFSET= string
1807 StringPtr
+= StrLen (L
"&OFFSET=");
1812 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1813 if (EFI_ERROR (Status
)) {
1820 (((Length
+ 1) / 2) < sizeof (UINT16
)) ? ((Length
+ 1) / 2) : sizeof (UINT16
)
1822 FreePool (TmpBuffer
);
1825 StringPtr
+= Length
;
1826 if (StrnCmp (StringPtr
, L
"&WIDTH=", StrLen (L
"&WIDTH=")) != 0) {
1827 Status
= EFI_INVALID_PARAMETER
;
1830 StringPtr
+= StrLen (L
"&WIDTH=");
1835 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1836 if (EFI_ERROR (Status
)) {
1843 (((Length
+ 1) / 2) < sizeof (UINT16
)) ? ((Length
+ 1) / 2) : sizeof (UINT16
)
1845 FreePool (TmpBuffer
);
1848 StringPtr
+= Length
;
1849 if (*StringPtr
!= 0 && *StringPtr
!= L
'&') {
1850 Status
= EFI_INVALID_PARAMETER
;
1854 if (StrnCmp (StringPtr
, L
"&VALUE=", StrLen (L
"&VALUE=")) != 0) {
1855 Status
= EFI_INVALID_PARAMETER
;
1858 StringPtr
+= StrLen (L
"&VALUE=");
1863 Status
= InternalHiiGetValueOfNumber (StringPtr
, &TmpBuffer
, &Length
);
1864 if (EFI_ERROR (Status
)) {
1868 StringPtr
+= Length
;
1869 if (*StringPtr
!= 0 && *StringPtr
!= L
'&') {
1870 Status
= EFI_INVALID_PARAMETER
;
1875 // Check whether VarBuffer is enough
1877 if ((UINT32
)Offset
+ Width
> MaxBufferSize
) {
1878 DataBuffer
= ReallocatePool (
1880 Offset
+ Width
+ HII_LIB_DEFAULT_VARSTORE_SIZE
,
1883 if (DataBuffer
== NULL
) {
1884 Status
= EFI_OUT_OF_RESOURCES
;
1887 MaxBufferSize
= Offset
+ Width
+ HII_LIB_DEFAULT_VARSTORE_SIZE
;
1891 // Update the Block with configuration info
1893 CopyMem (DataBuffer
+ Offset
, TmpBuffer
, Width
);
1894 FreePool (TmpBuffer
);
1898 // Set new Block Data
1900 NewBlockData
= (IFR_BLOCK_DATA
*) AllocateZeroPool (sizeof (IFR_BLOCK_DATA
));
1901 if (NewBlockData
== NULL
) {
1902 Status
= EFI_OUT_OF_RESOURCES
;
1905 NewBlockData
->Offset
= Offset
;
1906 NewBlockData
->Width
= Width
;
1909 // Insert the new block data into the block data array.
1911 for (Link
= BlockArray
->Entry
.ForwardLink
; Link
!= &BlockArray
->Entry
; Link
= Link
->ForwardLink
) {
1912 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
1913 if (NewBlockData
->Offset
== BlockData
->Offset
) {
1914 if (NewBlockData
->Width
> BlockData
->Width
) {
1915 BlockData
->Width
= NewBlockData
->Width
;
1917 FreePool (NewBlockData
);
1919 } else if (NewBlockData
->Offset
< BlockData
->Offset
) {
1921 // Insert new block data as the previous one of this link.
1923 InsertTailList (Link
, &NewBlockData
->Entry
);
1929 // Insert new block data into the array tail.
1931 if (Link
== &BlockArray
->Entry
) {
1932 InsertTailList (Link
, &NewBlockData
->Entry
);
1936 // If '\0', parsing is finished.
1938 if (*StringPtr
== 0) {
1942 // Go to next ConfigBlock
1947 // Merge the aligned block data into the single block data.
1949 Link
= BlockArray
->Entry
.ForwardLink
;
1950 while ((Link
!= &BlockArray
->Entry
) && (Link
->ForwardLink
!= &BlockArray
->Entry
)) {
1951 BlockData
= BASE_CR (Link
, IFR_BLOCK_DATA
, Entry
);
1952 NewBlockData
= BASE_CR (Link
->ForwardLink
, IFR_BLOCK_DATA
, Entry
);
1953 if ((NewBlockData
->Offset
>= BlockData
->Offset
) && (NewBlockData
->Offset
<= (BlockData
->Offset
+ BlockData
->Width
))) {
1954 if ((NewBlockData
->Offset
+ NewBlockData
->Width
) > (BlockData
->Offset
+ BlockData
->Width
)) {
1955 BlockData
->Width
= (UINT16
) (NewBlockData
->Offset
+ NewBlockData
->Width
- BlockData
->Offset
);
1957 RemoveEntryList (Link
->ForwardLink
);
1958 FreePool (NewBlockData
);
1961 Link
= Link
->ForwardLink
;
1964 *VarBuffer
= DataBuffer
;
1965 *CurrentBlockArray
= BlockArray
;
1969 if (DataBuffer
!= NULL
) {
1970 FreePool (DataBuffer
);
1973 if (BlockArray
!= NULL
) {
1975 // Free Link Array CurrentBlockArray
1977 while (!IsListEmpty (&BlockArray
->Entry
)) {
1978 BlockData
= BASE_CR (BlockArray
->Entry
.ForwardLink
, IFR_BLOCK_DATA
, Entry
);
1979 RemoveEntryList (&BlockData
->Entry
);
1980 FreePool (BlockData
);
1982 FreePool (BlockArray
);
1989 This internal function parses IFR data to validate current setting.
1991 @param ConfigResp ConfigResp string contains the current setting.
1992 @param HiiPackageList Point to Hii package list.
1993 @param PackageListLength The length of the pacakge.
1994 @param VarGuid Guid of the buffer storage.
1995 @param VarName Name of the buffer storage.
1996 @param HiiHandle The HiiHandle for this package.
1998 @retval EFI_SUCCESS The current setting is valid.
1999 @retval EFI_OUT_OF_RESOURCES The memory is not enough.
2000 @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
2004 InternalHiiValidateCurrentSetting (
2005 IN EFI_STRING ConfigResp
,
2006 IN EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
,
2007 IN UINTN PackageListLength
,
2008 IN EFI_GUID
*VarGuid
,
2010 IN EFI_HII_HANDLE HiiHandle
2015 IFR_BLOCK_DATA
*CurrentBlockArray
;
2016 IFR_BLOCK_DATA
*BlockData
;
2018 BOOLEAN NameValueType
;
2020 CurrentBlockArray
= NULL
;
2023 Status
= EFI_SUCCESS
;
2026 // If StringPtr != NULL, get the request elements.
2028 if (StrStr (ConfigResp
, L
"&OFFSET=") != NULL
) {
2029 Status
= GetBlockDataInfo(ConfigResp
, &CurrentBlockArray
, &VarBuffer
);
2030 if (EFI_ERROR (Status
)) {
2033 NameValueType
= FALSE
;
2036 // Skip header part.
2038 StringPtr
= StrStr (ConfigResp
, L
"PATH=");
2039 ASSERT (StringPtr
!= NULL
);
2041 if (StrStr (StringPtr
, L
"&") != NULL
) {
2042 NameValueType
= TRUE
;
2045 // Not found Request element, return success.
2051 Status
= ValidateQuestionFromVfr(
2063 if (VarBuffer
!= NULL
) {
2064 FreePool (VarBuffer
);
2067 if (CurrentBlockArray
!= NULL
) {
2069 // Free Link Array CurrentBlockArray
2071 while (!IsListEmpty (&CurrentBlockArray
->Entry
)) {
2072 BlockData
= BASE_CR (CurrentBlockArray
->Entry
.ForwardLink
, IFR_BLOCK_DATA
, Entry
);
2073 RemoveEntryList (&BlockData
->Entry
);
2074 FreePool (BlockData
);
2076 FreePool (CurrentBlockArray
);
2083 Check whether the ConfigRequest string has the request elements.
2084 For EFI_HII_VARSTORE_BUFFER type, the request has "&OFFSET=****&WIDTH=****..." format.
2085 For EFI_HII_VARSTORE_NAME_VALUE type, the request has "&NAME1**&NAME2..." format.
2087 @param ConfigRequest The input config request string.
2089 @retval TRUE The input include config request elements.
2090 @retval FALSE The input string not includes.
2094 GetElementsFromRequest (
2095 IN EFI_STRING ConfigRequest
2098 EFI_STRING TmpRequest
;
2100 TmpRequest
= StrStr (ConfigRequest
, L
"PATH=");
2101 ASSERT (TmpRequest
!= NULL
);
2103 if ((StrStr (TmpRequest
, L
"&OFFSET=") != NULL
) || (StrStr (TmpRequest
, L
"&") != NULL
)) {
2111 This function parses the input ConfigRequest string and its matched IFR code
2112 string for setting default value and validating current setting.
2114 1. For setting default action, Reset the default value specified by DefaultId
2115 to the driver configuration got by Request string.
2116 2. For validating current setting, Validate the current configuration
2117 by parsing HII form IFR opcode.
2119 NULL request string support depends on the ExportConfig interface of
2120 HiiConfigRouting protocol in UEFI specification.
2122 @param Request A null-terminated Unicode string in
2123 <MultiConfigRequest> format. It can be NULL.
2124 If it is NULL, all current configuration for the
2125 entirety of the current HII database will be validated.
2126 If it is NULL, all configuration for the
2127 entirety of the current HII database will be reset.
2128 @param DefaultId Specifies the type of defaults to retrieve only for setting default action.
2129 @param ActionType Action supports setting defaults and validate current setting.
2131 @retval TRUE Action runs successfully.
2132 @retval FALSE Action is not valid or Action can't be executed successfully..
2136 InternalHiiIfrValueAction (
2137 IN CONST EFI_STRING Request
, OPTIONAL
2138 IN UINT16 DefaultId
,
2142 EFI_STRING ConfigAltResp
;
2143 EFI_STRING ConfigAltHdr
;
2144 EFI_STRING ConfigResp
;
2145 EFI_STRING Progress
;
2146 EFI_STRING StringPtr
;
2147 EFI_STRING StringHdr
;
2149 EFI_HANDLE DriverHandle
;
2150 EFI_HANDLE TempDriverHandle
;
2151 EFI_HII_HANDLE
*HiiHandleBuffer
;
2152 EFI_HII_HANDLE HiiHandle
;
2157 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
2158 UINTN PackageListLength
;
2160 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2161 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
2163 ConfigAltResp
= NULL
;
2168 ConfigAltHdr
= NULL
;
2169 HiiHandleBuffer
= NULL
;
2171 TempDriverHandle
= NULL
;
2173 HiiPackageList
= NULL
;
2176 // Only support set default and validate setting action.
2178 if ((ActionType
!= ACTION_SET_DEFAUTL_VALUE
) && (ActionType
!= ACTION_VALIDATE_SETTING
)) {
2183 // Get the full requested value and deault value string.
2185 if (Request
!= NULL
) {
2186 Status
= gHiiConfigRouting
->ExtractConfig (
2193 Status
= gHiiConfigRouting
->ExportConfig (
2199 if (EFI_ERROR (Status
)) {
2203 StringPtr
= ConfigAltResp
;
2204 ASSERT (StringPtr
!= NULL
);
2206 while (*StringPtr
!= L
'\0') {
2208 // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
2210 StringHdr
= StringPtr
;
2215 if (StrnCmp (StringPtr
, L
"GUID=", StrLen (L
"GUID=")) != 0) {
2216 Status
= EFI_INVALID_PARAMETER
;
2219 StringPtr
+= StrLen (L
"GUID=");
2220 Status
= InternalHiiGetBufferFromString (StringPtr
, GUID_CONFIG_STRING_TYPE
, (UINT8
**) &VarGuid
);
2221 if (EFI_ERROR (Status
)) {
2226 // Get Name value VarName
2228 while (*StringPtr
!= L
'\0' && StrnCmp (StringPtr
, L
"&NAME=", StrLen (L
"&NAME=")) != 0) {
2231 if (*StringPtr
== L
'\0') {
2232 Status
= EFI_INVALID_PARAMETER
;
2235 StringPtr
+= StrLen (L
"&NAME=");
2236 Status
= InternalHiiGetBufferFromString (StringPtr
, NAME_CONFIG_STRING_TYPE
, (UINT8
**) &VarName
);
2237 if (EFI_ERROR (Status
)) {
2242 // Get Path value DevicePath
2244 while (*StringPtr
!= L
'\0' && StrnCmp (StringPtr
, L
"&PATH=", StrLen (L
"&PATH=")) != 0) {
2247 if (*StringPtr
== L
'\0') {
2248 Status
= EFI_INVALID_PARAMETER
;
2251 StringPtr
+= StrLen (L
"&PATH=");
2252 Status
= InternalHiiGetBufferFromString (StringPtr
, PATH_CONFIG_STRING_TYPE
, (UINT8
**) &DevicePath
);
2253 if (EFI_ERROR (Status
)) {
2258 // Get the Driver handle by the got device path.
2260 TempDevicePath
= DevicePath
;
2261 Status
= gBS
->LocateDevicePath (&gEfiDevicePathProtocolGuid
, &TempDevicePath
, &DriverHandle
);
2262 if (EFI_ERROR (Status
)) {
2267 // Find the matched Hii Handle for the found Driver handle
2269 HiiHandleBuffer
= HiiGetHiiHandles (NULL
);
2270 if (HiiHandleBuffer
== NULL
) {
2271 Status
= EFI_NOT_FOUND
;
2275 for (Index
= 0; HiiHandleBuffer
[Index
] != NULL
; Index
++) {
2276 gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, HiiHandleBuffer
[Index
], &TempDriverHandle
);
2277 if (TempDriverHandle
== DriverHandle
) {
2282 HiiHandle
= HiiHandleBuffer
[Index
];
2283 FreePool (HiiHandleBuffer
);
2285 if (HiiHandle
== NULL
) {
2287 // This request string has no its Hii package.
2288 // Its default value and validating can't execute by parsing IFR data.
2289 // Directly jump into the next ConfigAltResp string for another pair Guid, Name, and Path.
2291 Status
= EFI_SUCCESS
;
2292 goto NextConfigAltResp
;
2296 // 2. Get HiiPackage by HiiHandle
2298 PackageListLength
= 0;
2299 HiiPackageList
= NULL
;
2300 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &PackageListLength
, HiiPackageList
);
2303 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
2305 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
2306 Status
= EFI_INVALID_PARAMETER
;
2310 HiiPackageList
= AllocatePool (PackageListLength
);
2311 if (HiiPackageList
== NULL
) {
2312 Status
= EFI_OUT_OF_RESOURCES
;
2317 // Get PackageList on HiiHandle
2319 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &PackageListLength
, HiiPackageList
);
2320 if (EFI_ERROR (Status
)) {
2325 // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
2326 // Get the default configuration string according to the default ID.
2328 Status
= gHiiConfigRouting
->GetAltConfig (
2334 (ActionType
== ACTION_SET_DEFAUTL_VALUE
) ? &DefaultId
:NULL
, // it can be NULL to get the current setting.
2339 // The required setting can't be found. So, it is not required to be validated and set.
2341 if (EFI_ERROR (Status
)) {
2342 Status
= EFI_SUCCESS
;
2343 goto NextConfigAltResp
;
2346 // Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set.
2348 if (!GetElementsFromRequest (ConfigResp
)) {
2349 goto NextConfigAltResp
;
2353 // 4. Set the default configuration information or Validate current setting by parse IFR code.
2354 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2356 if (ActionType
== ACTION_SET_DEFAUTL_VALUE
) {
2358 // Set the default configuration information.
2360 Status
= gHiiConfigRouting
->RouteConfig (gHiiConfigRouting
, ConfigResp
, &Progress
);
2363 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2365 Status
= InternalHiiValidateCurrentSetting (ConfigResp
, HiiPackageList
, PackageListLength
, VarGuid
, VarName
, HiiHandle
);
2368 if (EFI_ERROR (Status
)) {
2374 // Free the allocated pacakge buffer and the got ConfigResp string.
2376 if (HiiPackageList
!= NULL
) {
2377 FreePool (HiiPackageList
);
2378 HiiPackageList
= NULL
;
2381 if (ConfigResp
!= NULL
) {
2382 FreePool (ConfigResp
);
2387 // Free the allocated buffer.
2395 FreePool (DevicePath
);
2399 // 5. Jump to next ConfigAltResp for another Guid, Name, Path.
2403 // Get and Skip ConfigHdr
2405 while (*StringPtr
!= L
'\0' && *StringPtr
!= L
'&') {
2408 if (*StringPtr
== L
'\0') {
2413 // Construct ConfigAltHdr string "&<ConfigHdr>&ALTCFG=\0"
2414 // | 1 | StrLen (ConfigHdr) | 8 | 1 |
2416 MaxLen
= 1 + StringPtr
- StringHdr
+ 8 + 1;
2417 ConfigAltHdr
= AllocateZeroPool ( MaxLen
* sizeof (CHAR16
));
2418 if (ConfigAltHdr
== NULL
) {
2419 Status
= EFI_OUT_OF_RESOURCES
;
2422 StrCpyS (ConfigAltHdr
, MaxLen
, L
"&");
2423 StrnCatS (ConfigAltHdr
, MaxLen
, StringHdr
, StringPtr
- StringHdr
);
2424 StrCatS (ConfigAltHdr
, MaxLen
, L
"&ALTCFG=");
2427 // Skip all AltResp (AltConfigHdr ConfigBody) for the same ConfigHdr
2429 while ((StringHdr
= StrStr (StringPtr
, ConfigAltHdr
)) != NULL
) {
2430 StringPtr
= StringHdr
+ StrLen (ConfigAltHdr
);
2431 if (*StringPtr
== L
'\0') {
2437 // Free the allocated ConfigAltHdr string
2439 FreePool (ConfigAltHdr
);
2440 if (*StringPtr
== L
'\0') {
2445 // Find &GUID as the next ConfigHdr
2447 StringPtr
= StrStr (StringPtr
, L
"&GUID");
2448 if (StringPtr
== NULL
) {
2459 if (VarGuid
!= NULL
) {
2463 if (VarName
!= NULL
) {
2467 if (DevicePath
!= NULL
) {
2468 FreePool (DevicePath
);
2471 if (ConfigResp
!= NULL
) {
2472 FreePool (ConfigResp
);
2475 if (ConfigAltResp
!= NULL
) {
2476 FreePool (ConfigAltResp
);
2479 if (HiiPackageList
!= NULL
) {
2480 FreePool (HiiPackageList
);
2483 if (EFI_ERROR (Status
)) {
2491 Validate the current configuration by parsing HII form IFR opcode.
2493 NULL request string support depends on the ExportConfig interface of
2494 HiiConfigRouting protocol in UEFI specification.
2496 @param Request A null-terminated Unicode string in
2497 <MultiConfigRequest> format. It can be NULL.
2498 If it is NULL, all current configuration for the
2499 entirety of the current HII database will be validated.
2501 @retval TRUE Current configuration is valid.
2502 @retval FALSE Current configuration is invalid.
2506 HiiValidateSettings (
2507 IN CONST EFI_STRING Request OPTIONAL
2510 return InternalHiiIfrValueAction (Request
, 0, ACTION_VALIDATE_SETTING
);
2514 Reset the default value specified by DefaultId to the driver
2515 configuration got by Request string.
2517 NULL request string support depends on the ExportConfig interface of
2518 HiiConfigRouting protocol in UEFI specification.
2520 @param Request A null-terminated Unicode string in
2521 <MultiConfigRequest> format. It can be NULL.
2522 If it is NULL, all configuration for the
2523 entirety of the current HII database will be reset.
2524 @param DefaultId Specifies the type of defaults to retrieve.
2526 @retval TRUE The default value is set successfully.
2527 @retval FALSE The default value can't be found and set.
2532 IN CONST EFI_STRING Request
, OPTIONAL
2536 return InternalHiiIfrValueAction (Request
, DefaultId
, ACTION_SET_DEFAUTL_VALUE
);
2540 Determines if two values in config strings match.
2542 Compares the substring between StartSearchString and StopSearchString in
2543 FirstString to the substring between StartSearchString and StopSearchString
2544 in SecondString. If the two substrings match, then TRUE is returned. If the
2545 two substrings do not match, then FALSE is returned.
2547 If FirstString is NULL, then ASSERT().
2548 If SecondString is NULL, then ASSERT().
2549 If StartSearchString is NULL, then ASSERT().
2550 If StopSearchString is NULL, then ASSERT().
2552 @param FirstString Pointer to the first Null-terminated Unicode string.
2553 @param SecondString Pointer to the second Null-terminated Unicode string.
2554 @param StartSearchString Pointer to the Null-terminated Unicode string that
2555 marks the start of the value string to compare.
2556 @param StopSearchString Pointer to the Null-terminated Unicode string that
2557 marks the end of the value string to compare.
2559 @retval FALSE StartSearchString is not present in FirstString.
2560 @retval FALSE StartSearchString is not present in SecondString.
2561 @retval FALSE StopSearchString is not present in FirstString.
2562 @retval FALSE StopSearchString is not present in SecondString.
2563 @retval FALSE The length of the substring in FirstString is not the
2564 same length as the substring in SecondString.
2565 @retval FALSE The value string in FirstString does not matche the
2566 value string in SecondString.
2567 @retval TRUE The value string in FirstString matches the value
2568 string in SecondString.
2573 InternalHiiCompareSubString (
2574 IN CHAR16
*FirstString
,
2575 IN CHAR16
*SecondString
,
2576 IN CHAR16
*StartSearchString
,
2577 IN CHAR16
*StopSearchString
2580 CHAR16
*EndFirstString
;
2581 CHAR16
*EndSecondString
;
2583 ASSERT (FirstString
!= NULL
);
2584 ASSERT (SecondString
!= NULL
);
2585 ASSERT (StartSearchString
!= NULL
);
2586 ASSERT (StopSearchString
!= NULL
);
2588 FirstString
= StrStr (FirstString
, StartSearchString
);
2589 if (FirstString
== NULL
) {
2593 SecondString
= StrStr (SecondString
, StartSearchString
);
2594 if (SecondString
== NULL
) {
2598 EndFirstString
= StrStr (FirstString
, StopSearchString
);
2599 if (EndFirstString
== NULL
) {
2603 EndSecondString
= StrStr (SecondString
, StopSearchString
);
2604 if (EndSecondString
== NULL
) {
2608 if ((EndFirstString
- FirstString
) != (EndSecondString
- SecondString
)) {
2612 return (BOOLEAN
)(StrnCmp (FirstString
, SecondString
, EndFirstString
- FirstString
) == 0);
2616 Determines if the routing data specified by GUID and NAME match a <ConfigHdr>.
2618 If ConfigHdr is NULL, then ASSERT().
2620 @param[in] ConfigHdr Either <ConfigRequest> or <ConfigResp>.
2621 @param[in] Guid GUID of the storage.
2622 @param[in] Name NAME of the storage.
2624 @retval TRUE Routing information matches <ConfigHdr>.
2625 @retval FALSE Routing information does not match <ConfigHdr>.
2630 HiiIsConfigHdrMatch (
2631 IN CONST EFI_STRING ConfigHdr
,
2632 IN CONST EFI_GUID
*Guid
, OPTIONAL
2633 IN CONST CHAR16
*Name OPTIONAL
2636 EFI_STRING CompareConfigHdr
;
2639 ASSERT (ConfigHdr
!= NULL
);
2642 // Use Guid and Name to generate a <ConfigHdr> string
2644 CompareConfigHdr
= HiiConstructConfigHdr (Guid
, Name
, NULL
);
2645 if (CompareConfigHdr
== NULL
) {
2652 // Compare GUID value strings
2654 Result
= InternalHiiCompareSubString (ConfigHdr
, CompareConfigHdr
, L
"GUID=", L
"&NAME=");
2657 if (Result
&& Name
!= NULL
) {
2659 // Compare NAME value strings
2661 Result
= InternalHiiCompareSubString (ConfigHdr
, CompareConfigHdr
, L
"&NAME=", L
"&PATH=");
2665 // Free the <ConfigHdr> string
2667 FreePool (CompareConfigHdr
);
2673 Retrieves uncommitted data from the Form Browser and converts it to a binary
2676 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
2677 parameter that may be NULL.
2678 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
2679 is an optional parameter that may be NULL.
2680 @param[in] BufferSize Length in bytes of buffer to hold retrieved data.
2681 @param[out] Buffer Buffer of data to be updated.
2683 @retval FALSE The uncommitted data could not be retrieved.
2684 @retval TRUE The uncommitted data was retrieved.
2690 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
2691 IN CONST CHAR16
*VariableName
, OPTIONAL
2692 IN UINTN BufferSize
,
2696 EFI_STRING ResultsData
;
2698 EFI_STRING ConfigResp
;
2703 // Retrieve the results data from the Browser Callback
2705 ResultsData
= InternalHiiBrowserCallback (VariableGuid
, VariableName
, NULL
);
2706 if (ResultsData
== NULL
) {
2711 // Construct <ConfigResp> mConfigHdrTemplate L'&' ResultsData L'\0'
2713 Size
= (StrLen (mConfigHdrTemplate
) + 1) * sizeof (CHAR16
);
2714 Size
= Size
+ (StrLen (ResultsData
) + 1) * sizeof (CHAR16
);
2715 ConfigResp
= AllocateZeroPool (Size
);
2716 UnicodeSPrint (ConfigResp
, Size
, L
"%s&%s", mConfigHdrTemplate
, ResultsData
);
2719 // Free the allocated buffer
2721 FreePool (ResultsData
);
2722 if (ConfigResp
== NULL
) {
2727 // Convert <ConfigResp> to a buffer
2729 Status
= gHiiConfigRouting
->ConfigToBlock (
2737 // Free the allocated buffer
2739 FreePool (ConfigResp
);
2741 if (EFI_ERROR (Status
)) {
2749 Updates uncommitted data in the Form Browser.
2751 If Buffer is NULL, then ASSERT().
2753 @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional
2754 parameter that may be NULL.
2755 @param[in] VariableName Pointer to a Null-terminated Unicode string. This
2756 is an optional parameter that may be NULL.
2757 @param[in] BufferSize Length, in bytes, of Buffer.
2758 @param[in] Buffer Buffer of data to commit.
2759 @param[in] RequestElement An optional field to specify which part of the
2760 buffer data will be send back to Browser. If NULL,
2761 the whole buffer of data will be committed to
2763 <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*
2765 @retval FALSE The uncommitted data could not be updated.
2766 @retval TRUE The uncommitted data was updated.
2772 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
2773 IN CONST CHAR16
*VariableName
, OPTIONAL
2774 IN UINTN BufferSize
,
2775 IN CONST UINT8
*Buffer
,
2776 IN CONST CHAR16
*RequestElement OPTIONAL
2780 EFI_STRING ConfigRequest
;
2781 EFI_STRING ConfigResp
;
2782 EFI_STRING ResultsData
;
2784 ASSERT (Buffer
!= NULL
);
2787 // Construct <ConfigRequest>
2789 if (RequestElement
== NULL
) {
2791 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2792 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
2794 Size
= (StrLen (mConfigHdrTemplate
) + 32 + 1) * sizeof (CHAR16
);
2795 ConfigRequest
= AllocateZeroPool (Size
);
2796 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", mConfigHdrTemplate
, (UINT64
)BufferSize
);
2799 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2800 // followed by <RequestElement> followed by a Null-terminator
2802 Size
= StrLen (mConfigHdrTemplate
) * sizeof (CHAR16
);
2803 Size
= Size
+ (StrLen (RequestElement
) + 1) * sizeof (CHAR16
);
2804 ConfigRequest
= AllocateZeroPool (Size
);
2805 UnicodeSPrint (ConfigRequest
, Size
, L
"%s%s", mConfigHdrTemplate
, RequestElement
);
2807 if (ConfigRequest
== NULL
) {
2812 // Convert <ConfigRequest> to <ConfigResp>
2814 ConfigResp
= InternalHiiBlockToConfig (ConfigRequest
, Buffer
, BufferSize
);
2815 FreePool (ConfigRequest
);
2816 if (ConfigResp
== NULL
) {
2821 // Set data in the uncommitted browser state information
2823 ResultsData
= InternalHiiBrowserCallback (VariableGuid
, VariableName
, ConfigResp
+ StrLen(mConfigHdrTemplate
) + 1);
2824 FreePool (ConfigResp
);
2826 return (BOOLEAN
)(ResultsData
!= NULL
);
2829 /////////////////////////////////////////
2830 /////////////////////////////////////////
2832 /////////////////////////////////////////
2833 /////////////////////////////////////////
2835 #define HII_LIB_OPCODE_ALLOCATION_SIZE 0x200
2841 } HII_LIB_OPCODE_BUFFER
;
2844 /// Lookup table that converts EFI_IFR_TYPE_X enum values to a width in bytes
2846 GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiDefaultTypeToWidth
[] = {
2847 1, // EFI_IFR_TYPE_NUM_SIZE_8
2848 2, // EFI_IFR_TYPE_NUM_SIZE_16
2849 4, // EFI_IFR_TYPE_NUM_SIZE_32
2850 8, // EFI_IFR_TYPE_NUM_SIZE_64
2851 1, // EFI_IFR_TYPE_BOOLEAN
2852 3, // EFI_IFR_TYPE_TIME
2853 4, // EFI_IFR_TYPE_DATE
2854 2 // EFI_IFR_TYPE_STRING
2858 Allocates and returns a new OpCode Handle. OpCode Handles must be freed with
2859 HiiFreeOpCodeHandle().
2861 @retval NULL There are not enough resources to allocate a new OpCode Handle.
2862 @retval Other A new OpCode handle.
2867 HiiAllocateOpCodeHandle (
2871 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2873 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)AllocatePool (sizeof (HII_LIB_OPCODE_BUFFER
));
2874 if (OpCodeBuffer
== NULL
) {
2877 OpCodeBuffer
->Buffer
= (UINT8
*)AllocatePool (HII_LIB_OPCODE_ALLOCATION_SIZE
);
2878 if (OpCodeBuffer
->Buffer
== NULL
) {
2879 FreePool (OpCodeBuffer
);
2882 OpCodeBuffer
->BufferSize
= HII_LIB_OPCODE_ALLOCATION_SIZE
;
2883 OpCodeBuffer
->Position
= 0;
2884 return (VOID
*)OpCodeBuffer
;
2888 Frees an OpCode Handle that was previously allocated with HiiAllocateOpCodeHandle().
2889 When an OpCode Handle is freed, all of the opcodes associated with the OpCode
2890 Handle are also freed.
2892 If OpCodeHandle is NULL, then ASSERT().
2894 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2899 HiiFreeOpCodeHandle (
2903 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2905 ASSERT (OpCodeHandle
!= NULL
);
2907 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
;
2908 if (OpCodeBuffer
->Buffer
!= NULL
) {
2909 FreePool (OpCodeBuffer
->Buffer
);
2911 FreePool (OpCodeBuffer
);
2915 Internal function gets the current position of opcode buffer.
2917 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2919 @return Current position of opcode buffer.
2923 InternalHiiOpCodeHandlePosition (
2924 IN VOID
*OpCodeHandle
2927 return ((HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
)->Position
;
2931 Internal function gets the start pointer of opcode buffer.
2933 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2935 @return Pointer to the opcode buffer base.
2939 InternalHiiOpCodeHandleBuffer (
2940 IN VOID
*OpCodeHandle
2943 return ((HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
)->Buffer
;
2947 Internal function reserves the enough buffer for current opcode.
2948 When the buffer is not enough, Opcode buffer will be extended.
2950 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2951 @param[in] Size Size of current opcode.
2953 @return Pointer to the current opcode.
2957 InternalHiiGrowOpCodeHandle (
2958 IN VOID
*OpCodeHandle
,
2962 HII_LIB_OPCODE_BUFFER
*OpCodeBuffer
;
2965 ASSERT (OpCodeHandle
!= NULL
);
2967 OpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)OpCodeHandle
;
2968 if (OpCodeBuffer
->Position
+ Size
> OpCodeBuffer
->BufferSize
) {
2969 Buffer
= ReallocatePool (
2970 OpCodeBuffer
->BufferSize
,
2971 OpCodeBuffer
->BufferSize
+ (Size
+ HII_LIB_OPCODE_ALLOCATION_SIZE
),
2972 OpCodeBuffer
->Buffer
2974 ASSERT (Buffer
!= NULL
);
2975 OpCodeBuffer
->Buffer
= Buffer
;
2976 OpCodeBuffer
->BufferSize
+= (Size
+ HII_LIB_OPCODE_ALLOCATION_SIZE
);
2978 Buffer
= OpCodeBuffer
->Buffer
+ OpCodeBuffer
->Position
;
2979 OpCodeBuffer
->Position
+= Size
;
2984 Internal function creates opcode based on the template opcode.
2986 @param[in] OpCodeHandle Handle to the buffer of opcodes.
2987 @param[in] OpCodeTemplate Pointer to the template buffer of opcode.
2988 @param[in] OpCode OpCode IFR value.
2989 @param[in] OpCodeSize Size of opcode.
2990 @param[in] ExtensionSize Size of extended opcode.
2991 @param[in] Scope Scope bit of opcode.
2993 @return Pointer to the current opcode with opcode data.
2997 InternalHiiCreateOpCodeExtended (
2998 IN VOID
*OpCodeHandle
,
2999 IN VOID
*OpCodeTemplate
,
3001 IN UINTN OpCodeSize
,
3002 IN UINTN ExtensionSize
,
3006 EFI_IFR_OP_HEADER
*Header
;
3009 ASSERT (OpCodeTemplate
!= NULL
);
3010 ASSERT ((OpCodeSize
+ ExtensionSize
) <= 0x7F);
3012 Header
= (EFI_IFR_OP_HEADER
*)OpCodeTemplate
;
3013 Header
->OpCode
= OpCode
;
3014 Header
->Scope
= Scope
;
3015 Header
->Length
= (UINT8
)(OpCodeSize
+ ExtensionSize
);
3016 Buffer
= InternalHiiGrowOpCodeHandle (OpCodeHandle
, Header
->Length
);
3017 return (UINT8
*)CopyMem (Buffer
, Header
, OpCodeSize
);
3021 Internal function creates opcode based on the template opcode for the normal opcode.
3023 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3024 @param[in] OpCodeTemplate Pointer to the template buffer of opcode.
3025 @param[in] OpCode OpCode IFR value.
3026 @param[in] OpCodeSize Size of opcode.
3028 @return Pointer to the current opcode with opcode data.
3032 InternalHiiCreateOpCode (
3033 IN VOID
*OpCodeHandle
,
3034 IN VOID
*OpCodeTemplate
,
3039 return InternalHiiCreateOpCodeExtended (OpCodeHandle
, OpCodeTemplate
, OpCode
, OpCodeSize
, 0, 0);
3043 Append raw opcodes to an OpCodeHandle.
3045 If OpCodeHandle is NULL, then ASSERT().
3046 If RawBuffer is NULL, then ASSERT();
3048 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3049 @param[in] RawBuffer Buffer of opcodes to append.
3050 @param[in] RawBufferSize The size, in bytes, of Buffer.
3052 @retval NULL There is not enough space left in Buffer to add the opcode.
3053 @retval Other A pointer to the appended opcodes.
3058 HiiCreateRawOpCodes (
3059 IN VOID
*OpCodeHandle
,
3060 IN UINT8
*RawBuffer
,
3061 IN UINTN RawBufferSize
3066 ASSERT (RawBuffer
!= NULL
);
3068 Buffer
= InternalHiiGrowOpCodeHandle (OpCodeHandle
, RawBufferSize
);
3069 return (UINT8
*)CopyMem (Buffer
, RawBuffer
, RawBufferSize
);
3073 Append opcodes from one OpCode Handle to another OpCode handle.
3075 If OpCodeHandle is NULL, then ASSERT().
3076 If RawOpCodeHandle is NULL, then ASSERT();
3078 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3079 @param[in] RawOpCodeHandle Handle to the buffer of opcodes.
3081 @retval NULL There is not enough space left in Buffer to add the opcode.
3082 @retval Other A pointer to the appended opcodes.
3087 InternalHiiAppendOpCodes (
3088 IN VOID
*OpCodeHandle
,
3089 IN VOID
*RawOpCodeHandle
3092 HII_LIB_OPCODE_BUFFER
*RawOpCodeBuffer
;
3094 ASSERT (RawOpCodeHandle
!= NULL
);
3096 RawOpCodeBuffer
= (HII_LIB_OPCODE_BUFFER
*)RawOpCodeHandle
;
3097 return HiiCreateRawOpCodes (OpCodeHandle
, RawOpCodeBuffer
->Buffer
, RawOpCodeBuffer
->Position
);
3101 Create EFI_IFR_END_OP opcode.
3103 If OpCodeHandle is NULL, then ASSERT().
3105 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3107 @retval NULL There is not enough space left in Buffer to add the opcode.
3108 @retval Other A pointer to the created opcode.
3113 HiiCreateEndOpCode (
3114 IN VOID
*OpCodeHandle
3119 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_END_OP
, sizeof (OpCode
));
3123 Create EFI_IFR_ONE_OF_OPTION_OP opcode.
3125 If OpCodeHandle is NULL, then ASSERT().
3126 If Type is invalid, then ASSERT().
3127 If Flags is invalid, then ASSERT().
3129 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3130 @param[in] StringId StringId for the option
3131 @param[in] Flags Flags for the option
3132 @param[in] Type Type for the option
3133 @param[in] Value Value for the option
3135 @retval NULL There is not enough space left in Buffer to add the opcode.
3136 @retval Other A pointer to the created opcode.
3141 HiiCreateOneOfOptionOpCode (
3142 IN VOID
*OpCodeHandle
,
3149 EFI_IFR_ONE_OF_OPTION OpCode
;
3151 ASSERT (Type
< EFI_IFR_TYPE_OTHER
);
3153 ZeroMem (&OpCode
, sizeof (OpCode
));
3154 OpCode
.Option
= StringId
;
3155 OpCode
.Flags
= (UINT8
) (Flags
& (EFI_IFR_OPTION_DEFAULT
| EFI_IFR_OPTION_DEFAULT_MFG
));
3157 CopyMem (&OpCode
.Value
, &Value
, mHiiDefaultTypeToWidth
[Type
]);
3159 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_ONE_OF_OPTION_OP
, OFFSET_OF(EFI_IFR_ONE_OF_OPTION
, Value
) + mHiiDefaultTypeToWidth
[Type
]);
3163 Create EFI_IFR_DEFAULT_OP opcode.
3165 If OpCodeHandle is NULL, then ASSERT().
3166 If Type is invalid, then ASSERT().
3168 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3169 @param[in] DefaultId DefaultId for the default
3170 @param[in] Type Type for the default
3171 @param[in] Value Value for the default
3173 @retval NULL There is not enough space left in Buffer to add the opcode.
3174 @retval Other A pointer to the created opcode.
3179 HiiCreateDefaultOpCode (
3180 IN VOID
*OpCodeHandle
,
3181 IN UINT16 DefaultId
,
3186 EFI_IFR_DEFAULT OpCode
;
3188 ASSERT (Type
< EFI_IFR_TYPE_OTHER
);
3190 ZeroMem (&OpCode
, sizeof (OpCode
));
3192 OpCode
.DefaultId
= DefaultId
;
3193 CopyMem (&OpCode
.Value
, &Value
, mHiiDefaultTypeToWidth
[Type
]);
3195 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_DEFAULT_OP
, OFFSET_OF(EFI_IFR_DEFAULT
, Value
) + mHiiDefaultTypeToWidth
[Type
]);
3199 Create EFI_IFR_GUID opcode.
3201 If OpCodeHandle is NULL, then ASSERT().
3202 If Guid is NULL, then ASSERT().
3203 If OpCodeSize < sizeof (EFI_IFR_GUID), then ASSERT().
3205 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3206 @param[in] Guid Pointer to EFI_GUID of this guided opcode.
3207 @param[in] GuidOpCode Pointer to an EFI_IFR_GUID opcode. This is an
3208 optional parameter that may be NULL. If this
3209 parameter is NULL, then the GUID extension
3210 region of the created opcode is filled with zeros.
3211 If this parameter is not NULL, then the GUID
3212 extension region of GuidData will be copied to
3213 the GUID extension region of the created opcode.
3214 @param[in] OpCodeSize The size, in bytes, of created opcode. This value
3215 must be >= sizeof(EFI_IFR_GUID).
3217 @retval NULL There is not enough space left in Buffer to add the opcode.
3218 @retval Other A pointer to the created opcode.
3223 HiiCreateGuidOpCode (
3224 IN VOID
*OpCodeHandle
,
3225 IN CONST EFI_GUID
*Guid
,
3226 IN CONST VOID
*GuidOpCode
, OPTIONAL
3230 EFI_IFR_GUID OpCode
;
3231 EFI_IFR_GUID
*OpCodePointer
;
3233 ASSERT (Guid
!= NULL
);
3234 ASSERT (OpCodeSize
>= sizeof (OpCode
));
3236 ZeroMem (&OpCode
, sizeof (OpCode
));
3237 CopyGuid ((EFI_GUID
*)(VOID
*)&OpCode
.Guid
, Guid
);
3239 OpCodePointer
= (EFI_IFR_GUID
*)InternalHiiCreateOpCodeExtended (
3244 OpCodeSize
- sizeof (OpCode
),
3247 if (OpCodePointer
!= NULL
&& GuidOpCode
!= NULL
) {
3248 CopyMem (OpCodePointer
+ 1, (EFI_IFR_GUID
*)GuidOpCode
+ 1, OpCodeSize
- sizeof (OpCode
));
3250 return (UINT8
*)OpCodePointer
;
3254 Create EFI_IFR_ACTION_OP opcode.
3256 If OpCodeHandle is NULL, then ASSERT().
3257 If any reserved bits are set in QuestionFlags, then ASSERT().
3259 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3260 @param[in] QuestionId Question ID
3261 @param[in] Prompt String ID for Prompt
3262 @param[in] Help String ID for Help
3263 @param[in] QuestionFlags Flags in Question Header
3264 @param[in] QuestionConfig String ID for configuration
3266 @retval NULL There is not enough space left in Buffer to add the opcode.
3267 @retval Other A pointer to the created opcode.
3272 HiiCreateActionOpCode (
3273 IN VOID
*OpCodeHandle
,
3274 IN EFI_QUESTION_ID QuestionId
,
3275 IN EFI_STRING_ID Prompt
,
3276 IN EFI_STRING_ID Help
,
3277 IN UINT8 QuestionFlags
,
3278 IN EFI_STRING_ID QuestionConfig
3281 EFI_IFR_ACTION OpCode
;
3283 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3285 ZeroMem (&OpCode
, sizeof (OpCode
));
3286 OpCode
.Question
.QuestionId
= QuestionId
;
3287 OpCode
.Question
.Header
.Prompt
= Prompt
;
3288 OpCode
.Question
.Header
.Help
= Help
;
3289 OpCode
.Question
.Flags
= QuestionFlags
;
3290 OpCode
.QuestionConfig
= QuestionConfig
;
3292 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_ACTION_OP
, sizeof (OpCode
));
3296 Create EFI_IFR_SUBTITLE_OP opcode.
3298 If OpCodeHandle is NULL, then ASSERT().
3299 If any reserved bits are set in Flags, then ASSERT().
3300 If Scope > 1, then ASSERT().
3302 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3303 @param[in] Prompt String ID for Prompt
3304 @param[in] Help String ID for Help
3305 @param[in] Flags Subtitle opcode flags
3306 @param[in] Scope 1 if this opcpde is the beginning of a new scope.
3307 0 if this opcode is within the current scope.
3309 @retval NULL There is not enough space left in Buffer to add the opcode.
3310 @retval Other A pointer to the created opcode.
3315 HiiCreateSubTitleOpCode (
3316 IN VOID
*OpCodeHandle
,
3317 IN EFI_STRING_ID Prompt
,
3318 IN EFI_STRING_ID Help
,
3323 EFI_IFR_SUBTITLE OpCode
;
3325 ASSERT (Scope
<= 1);
3326 ASSERT ((Flags
& (~(EFI_IFR_FLAGS_HORIZONTAL
))) == 0);
3328 ZeroMem (&OpCode
, sizeof (OpCode
));
3329 OpCode
.Statement
.Prompt
= Prompt
;
3330 OpCode
.Statement
.Help
= Help
;
3331 OpCode
.Flags
= Flags
;
3333 return InternalHiiCreateOpCodeExtended (
3336 EFI_IFR_SUBTITLE_OP
,
3344 Create EFI_IFR_REF_OP opcode.
3346 If OpCodeHandle is NULL, then ASSERT().
3347 If any reserved bits are set in QuestionFlags, then ASSERT().
3349 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3350 @param[in] FormId Destination Form ID
3351 @param[in] Prompt String ID for Prompt
3352 @param[in] Help String ID for Help
3353 @param[in] QuestionFlags Flags in Question Header
3354 @param[in] QuestionId Question ID
3356 @retval NULL There is not enough space left in Buffer to add the opcode.
3357 @retval Other A pointer to the created opcode.
3362 HiiCreateGotoOpCode (
3363 IN VOID
*OpCodeHandle
,
3364 IN EFI_FORM_ID FormId
,
3365 IN EFI_STRING_ID Prompt
,
3366 IN EFI_STRING_ID Help
,
3367 IN UINT8 QuestionFlags
,
3368 IN EFI_QUESTION_ID QuestionId
3373 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3375 ZeroMem (&OpCode
, sizeof (OpCode
));
3376 OpCode
.Question
.Header
.Prompt
= Prompt
;
3377 OpCode
.Question
.Header
.Help
= Help
;
3378 OpCode
.Question
.QuestionId
= QuestionId
;
3379 OpCode
.Question
.Flags
= QuestionFlags
;
3380 OpCode
.FormId
= FormId
;
3382 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_REF_OP
, sizeof (OpCode
));
3386 Create EFI_IFR_REF_OP, EFI_IFR_REF2_OP, EFI_IFR_REF3_OP and EFI_IFR_REF4_OP opcode.
3388 When RefDevicePath is not zero, EFI_IFR_REF4 opcode will be created.
3389 When RefDevicePath is zero and RefFormSetId is not NULL, EFI_IFR_REF3 opcode will be created.
3390 When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is not zero, EFI_IFR_REF2 opcode will be created.
3391 When RefDevicePath is zero, RefFormSetId is NULL and RefQuestionId is zero, EFI_IFR_REF opcode will be created.
3393 If OpCodeHandle is NULL, then ASSERT().
3394 If any reserved bits are set in QuestionFlags, then ASSERT().
3396 @param[in] OpCodeHandle The handle to the buffer of opcodes.
3397 @param[in] RefFormId The Destination Form ID.
3398 @param[in] Prompt The string ID for Prompt.
3399 @param[in] Help The string ID for Help.
3400 @param[in] QuestionFlags The flags in Question Header
3401 @param[in] QuestionId Question ID.
3402 @param[in] RefQuestionId The question on the form to which this link is referring.
3403 If its value is zero, then the link refers to the top of the form.
3404 @param[in] RefFormSetId The form set to which this link is referring. If its value is NULL, and RefDevicePath is
3405 zero, then the link is to the current form set.
3406 @param[in] RefDevicePath The string identifier that specifies the string containing the text representation of
3407 the device path to which the form set containing the form specified by FormId.
3408 If its value is zero, then the link refers to the current page.
3410 @retval NULL There is not enough space left in Buffer to add the opcode.
3411 @retval Other A pointer to the created opcode.
3416 HiiCreateGotoExOpCode (
3417 IN VOID
*OpCodeHandle
,
3418 IN EFI_FORM_ID RefFormId
,
3419 IN EFI_STRING_ID Prompt
,
3420 IN EFI_STRING_ID Help
,
3421 IN UINT8 QuestionFlags
,
3422 IN EFI_QUESTION_ID QuestionId
,
3423 IN EFI_QUESTION_ID RefQuestionId
,
3424 IN EFI_GUID
*RefFormSetId
, OPTIONAL
3425 IN EFI_STRING_ID RefDevicePath
3428 EFI_IFR_REF4 OpCode
;
3431 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3433 ZeroMem (&OpCode
, sizeof (OpCode
));
3434 OpCode
.Question
.Header
.Prompt
= Prompt
;
3435 OpCode
.Question
.Header
.Help
= Help
;
3436 OpCode
.Question
.QuestionId
= QuestionId
;
3437 OpCode
.Question
.Flags
= QuestionFlags
;
3438 OpCode
.FormId
= RefFormId
;
3439 OpCode
.QuestionId
= RefQuestionId
;
3440 OpCode
.DevicePath
= RefDevicePath
;
3441 if (RefFormSetId
!= NULL
) {
3442 CopyMem (&OpCode
.FormSetId
, RefFormSetId
, sizeof (OpCode
.FormSetId
));
3446 // Cacluate OpCodeSize based on the input Ref value.
3447 // Try to use the small OpCode to save size.
3449 OpCodeSize
= sizeof (EFI_IFR_REF
);
3450 if (RefDevicePath
!= 0) {
3451 OpCodeSize
= sizeof (EFI_IFR_REF4
);
3452 } else if (RefFormSetId
!= NULL
) {
3453 OpCodeSize
= sizeof (EFI_IFR_REF3
);
3454 } else if (RefQuestionId
!= 0) {
3455 OpCodeSize
= sizeof (EFI_IFR_REF2
);
3458 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_REF_OP
, OpCodeSize
);
3462 Create EFI_IFR_CHECKBOX_OP opcode.
3464 If OpCodeHandle is NULL, then ASSERT().
3465 If any reserved bits are set in QuestionFlags, then ASSERT().
3466 If any reserved bits are set in CheckBoxFlags, then ASSERT().
3468 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3469 @param[in] QuestionId Question ID
3470 @param[in] VarStoreId Storage ID
3471 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3472 for this name/value pair.
3473 @param[in] Prompt String ID for Prompt
3474 @param[in] Help String ID for Help
3475 @param[in] QuestionFlags Flags in Question Header
3476 @param[in] CheckBoxFlags Flags for checkbox opcode
3477 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3478 is an optional parameter that may be NULL.
3480 @retval NULL There is not enough space left in Buffer to add the opcode.
3481 @retval Other A pointer to the created opcode.
3486 HiiCreateCheckBoxOpCode (
3487 IN VOID
*OpCodeHandle
,
3488 IN EFI_QUESTION_ID QuestionId
,
3489 IN EFI_VARSTORE_ID VarStoreId
,
3490 IN UINT16 VarOffset
,
3491 IN EFI_STRING_ID Prompt
,
3492 IN EFI_STRING_ID Help
,
3493 IN UINT8 QuestionFlags
,
3494 IN UINT8 CheckBoxFlags
,
3495 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3498 EFI_IFR_CHECKBOX OpCode
;
3501 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3503 ZeroMem (&OpCode
, sizeof (OpCode
));
3504 OpCode
.Question
.QuestionId
= QuestionId
;
3505 OpCode
.Question
.VarStoreId
= VarStoreId
;
3506 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3507 OpCode
.Question
.Header
.Prompt
= Prompt
;
3508 OpCode
.Question
.Header
.Help
= Help
;
3509 OpCode
.Question
.Flags
= QuestionFlags
;
3510 OpCode
.Flags
= CheckBoxFlags
;
3512 if (DefaultsOpCodeHandle
== NULL
) {
3513 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_CHECKBOX_OP
, sizeof (OpCode
));
3516 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3517 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_CHECKBOX_OP
, sizeof (OpCode
), 0, 1);
3518 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3519 HiiCreateEndOpCode (OpCodeHandle
);
3520 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3524 Create EFI_IFR_NUMERIC_OP opcode.
3526 If OpCodeHandle is NULL, then ASSERT().
3527 If any reserved bits are set in QuestionFlags, then ASSERT().
3528 If any reserved bits are set in NumericFlags, then ASSERT().
3530 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3531 @param[in] QuestionId Question ID
3532 @param[in] VarStoreId Storage ID
3533 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3534 for this name/value pair.
3535 @param[in] Prompt String ID for Prompt
3536 @param[in] Help String ID for Help
3537 @param[in] QuestionFlags Flags in Question Header
3538 @param[in] NumericFlags Flags for numeric opcode
3539 @param[in] Minimum Numeric minimum value
3540 @param[in] Maximum Numeric maximum value
3541 @param[in] Step Numeric step for edit
3542 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3543 is an optional parameter that may be NULL.
3545 @retval NULL There is not enough space left in Buffer to add the opcode.
3546 @retval Other A pointer to the created opcode.
3551 HiiCreateNumericOpCode (
3552 IN VOID
*OpCodeHandle
,
3553 IN EFI_QUESTION_ID QuestionId
,
3554 IN EFI_VARSTORE_ID VarStoreId
,
3555 IN UINT16 VarOffset
,
3556 IN EFI_STRING_ID Prompt
,
3557 IN EFI_STRING_ID Help
,
3558 IN UINT8 QuestionFlags
,
3559 IN UINT8 NumericFlags
,
3563 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3566 EFI_IFR_NUMERIC OpCode
;
3570 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3573 ZeroMem (&OpCode
, sizeof (OpCode
));
3574 OpCode
.Question
.QuestionId
= QuestionId
;
3575 OpCode
.Question
.VarStoreId
= VarStoreId
;
3576 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3577 OpCode
.Question
.Header
.Prompt
= Prompt
;
3578 OpCode
.Question
.Header
.Help
= Help
;
3579 OpCode
.Question
.Flags
= QuestionFlags
;
3580 OpCode
.Flags
= NumericFlags
;
3582 switch (NumericFlags
& EFI_IFR_NUMERIC_SIZE
) {
3583 case EFI_IFR_NUMERIC_SIZE_1
:
3584 OpCode
.data
.u8
.MinValue
= (UINT8
)Minimum
;
3585 OpCode
.data
.u8
.MaxValue
= (UINT8
)Maximum
;
3586 OpCode
.data
.u8
.Step
= (UINT8
)Step
;
3590 case EFI_IFR_NUMERIC_SIZE_2
:
3591 OpCode
.data
.u16
.MinValue
= (UINT16
)Minimum
;
3592 OpCode
.data
.u16
.MaxValue
= (UINT16
)Maximum
;
3593 OpCode
.data
.u16
.Step
= (UINT16
)Step
;
3597 case EFI_IFR_NUMERIC_SIZE_4
:
3598 OpCode
.data
.u32
.MinValue
= (UINT32
)Minimum
;
3599 OpCode
.data
.u32
.MaxValue
= (UINT32
)Maximum
;
3600 OpCode
.data
.u32
.Step
= (UINT32
)Step
;
3604 case EFI_IFR_NUMERIC_SIZE_8
:
3605 OpCode
.data
.u64
.MinValue
= Minimum
;
3606 OpCode
.data
.u64
.MaxValue
= Maximum
;
3607 OpCode
.data
.u64
.Step
= Step
;
3612 Length
+= OFFSET_OF (EFI_IFR_NUMERIC
, data
);
3614 if (DefaultsOpCodeHandle
== NULL
) {
3615 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_NUMERIC_OP
, Length
);
3618 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3619 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_NUMERIC_OP
, Length
, 0, 1);
3620 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3621 HiiCreateEndOpCode (OpCodeHandle
);
3622 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3626 Create EFI_IFR_STRING_OP opcode.
3628 If OpCodeHandle is NULL, then ASSERT().
3629 If any reserved bits are set in QuestionFlags, then ASSERT().
3630 If any reserved bits are set in StringFlags, then ASSERT().
3632 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3633 @param[in] QuestionId Question ID
3634 @param[in] VarStoreId Storage ID
3635 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3636 for this name/value pair.
3637 @param[in] Prompt String ID for Prompt
3638 @param[in] Help String ID for Help
3639 @param[in] QuestionFlags Flags in Question Header
3640 @param[in] StringFlags Flags for string opcode
3641 @param[in] MinSize String minimum length
3642 @param[in] MaxSize String maximum length
3643 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3644 is an optional parameter that may be NULL.
3646 @retval NULL There is not enough space left in Buffer to add the opcode.
3647 @retval Other A pointer to the created opcode.
3652 HiiCreateStringOpCode (
3653 IN VOID
*OpCodeHandle
,
3654 IN EFI_QUESTION_ID QuestionId
,
3655 IN EFI_VARSTORE_ID VarStoreId
,
3656 IN UINT16 VarOffset
,
3657 IN EFI_STRING_ID Prompt
,
3658 IN EFI_STRING_ID Help
,
3659 IN UINT8 QuestionFlags
,
3660 IN UINT8 StringFlags
,
3663 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3666 EFI_IFR_STRING OpCode
;
3669 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3671 ZeroMem (&OpCode
, sizeof (OpCode
));
3672 OpCode
.Question
.Header
.Prompt
= Prompt
;
3673 OpCode
.Question
.Header
.Help
= Help
;
3674 OpCode
.Question
.QuestionId
= QuestionId
;
3675 OpCode
.Question
.VarStoreId
= VarStoreId
;
3676 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3677 OpCode
.Question
.Flags
= QuestionFlags
;
3678 OpCode
.MinSize
= MinSize
;
3679 OpCode
.MaxSize
= MaxSize
;
3680 OpCode
.Flags
= (UINT8
) (StringFlags
& EFI_IFR_STRING_MULTI_LINE
);
3682 if (DefaultsOpCodeHandle
== NULL
) {
3683 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_STRING_OP
, sizeof (OpCode
));
3686 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3687 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_STRING_OP
, sizeof (OpCode
), 0, 1);
3688 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3689 HiiCreateEndOpCode (OpCodeHandle
);
3690 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3694 Create EFI_IFR_ONE_OF_OP opcode.
3696 If OpCodeHandle is NULL, then ASSERT().
3697 If any reserved bits are set in QuestionFlags, then ASSERT().
3698 If any reserved bits are set in OneOfFlags, then ASSERT().
3700 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3701 @param[in] QuestionId Question ID
3702 @param[in] VarStoreId Storage ID
3703 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3704 for this name/value pair.
3705 @param[in] Prompt String ID for Prompt
3706 @param[in] Help String ID for Help
3707 @param[in] QuestionFlags Flags in Question Header
3708 @param[in] OneOfFlags Flags for oneof opcode
3709 @param[in] OptionsOpCodeHandle Handle for a buffer of ONE_OF_OPTION opcodes.
3710 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3711 is an optional parameter that may be NULL.
3713 @retval NULL There is not enough space left in Buffer to add the opcode.
3714 @retval Other A pointer to the created opcode.
3719 HiiCreateOneOfOpCode (
3720 IN VOID
*OpCodeHandle
,
3721 IN EFI_QUESTION_ID QuestionId
,
3722 IN EFI_VARSTORE_ID VarStoreId
,
3723 IN UINT16 VarOffset
,
3724 IN EFI_STRING_ID Prompt
,
3725 IN EFI_STRING_ID Help
,
3726 IN UINT8 QuestionFlags
,
3727 IN UINT8 OneOfFlags
,
3728 IN VOID
*OptionsOpCodeHandle
,
3729 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3732 EFI_IFR_ONE_OF OpCode
;
3736 ASSERT (OptionsOpCodeHandle
!= NULL
);
3737 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
| EFI_IFR_FLAG_OPTIONS_ONLY
))) == 0);
3739 ZeroMem (&OpCode
, sizeof (OpCode
));
3740 OpCode
.Question
.Header
.Prompt
= Prompt
;
3741 OpCode
.Question
.Header
.Help
= Help
;
3742 OpCode
.Question
.QuestionId
= QuestionId
;
3743 OpCode
.Question
.VarStoreId
= VarStoreId
;
3744 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3745 OpCode
.Question
.Flags
= QuestionFlags
;
3746 OpCode
.Flags
= OneOfFlags
;
3748 Length
= OFFSET_OF (EFI_IFR_ONE_OF
, data
);
3749 Length
+= (1 << (OneOfFlags
& EFI_IFR_NUMERIC_SIZE
)) * 3;
3751 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3752 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_ONE_OF_OP
, Length
, 0, 1);
3753 InternalHiiAppendOpCodes (OpCodeHandle
, OptionsOpCodeHandle
);
3754 if (DefaultsOpCodeHandle
!= NULL
) {
3755 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3757 HiiCreateEndOpCode (OpCodeHandle
);
3758 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3762 Create EFI_IFR_ORDERED_LIST_OP opcode.
3764 If OpCodeHandle is NULL, then ASSERT().
3765 If any reserved bits are set in QuestionFlags, then ASSERT().
3766 If any reserved bits are set in OrderedListFlags, then ASSERT().
3768 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3769 @param[in] QuestionId Question ID
3770 @param[in] VarStoreId Storage ID
3771 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3772 for this name/value pair.
3773 @param[in] Prompt String ID for Prompt
3774 @param[in] Help String ID for Help
3775 @param[in] QuestionFlags Flags in Question Header
3776 @param[in] OrderedListFlags Flags for ordered list opcode
3777 @param[in] DataType Type for option value
3778 @param[in] MaxContainers Maximum count for options in this ordered list
3779 @param[in] OptionsOpCodeHandle Handle for a buffer of ONE_OF_OPTION opcodes.
3780 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3781 is an optional parameter that may be NULL.
3783 @retval NULL There is not enough space left in Buffer to add the opcode.
3784 @retval Other A pointer to the created opcode.
3789 HiiCreateOrderedListOpCode (
3790 IN VOID
*OpCodeHandle
,
3791 IN EFI_QUESTION_ID QuestionId
,
3792 IN EFI_VARSTORE_ID VarStoreId
,
3793 IN UINT16 VarOffset
,
3794 IN EFI_STRING_ID Prompt
,
3795 IN EFI_STRING_ID Help
,
3796 IN UINT8 QuestionFlags
,
3797 IN UINT8 OrderedListFlags
,
3799 IN UINT8 MaxContainers
,
3800 IN VOID
*OptionsOpCodeHandle
,
3801 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3804 EFI_IFR_ORDERED_LIST OpCode
;
3807 ASSERT (OptionsOpCodeHandle
!= NULL
);
3808 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
| EFI_IFR_FLAG_OPTIONS_ONLY
))) == 0);
3810 ZeroMem (&OpCode
, sizeof (OpCode
));
3811 OpCode
.Question
.Header
.Prompt
= Prompt
;
3812 OpCode
.Question
.Header
.Help
= Help
;
3813 OpCode
.Question
.QuestionId
= QuestionId
;
3814 OpCode
.Question
.VarStoreId
= VarStoreId
;
3815 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3816 OpCode
.Question
.Flags
= QuestionFlags
;
3817 OpCode
.MaxContainers
= MaxContainers
;
3818 OpCode
.Flags
= OrderedListFlags
;
3820 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3821 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_ORDERED_LIST_OP
, sizeof (OpCode
), 0, 1);
3822 InternalHiiAppendOpCodes (OpCodeHandle
, OptionsOpCodeHandle
);
3823 if (DefaultsOpCodeHandle
!= NULL
) {
3824 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3826 HiiCreateEndOpCode (OpCodeHandle
);
3827 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3831 Create EFI_IFR_TEXT_OP opcode.
3833 If OpCodeHandle is NULL, then ASSERT().
3835 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3836 @param[in] Prompt String ID for Prompt.
3837 @param[in] Help String ID for Help.
3838 @param[in] TextTwo String ID for TextTwo.
3840 @retval NULL There is not enough space left in Buffer to add the opcode.
3841 @retval Other A pointer to the created opcode.
3846 HiiCreateTextOpCode (
3847 IN VOID
*OpCodeHandle
,
3848 IN EFI_STRING_ID Prompt
,
3849 IN EFI_STRING_ID Help
,
3850 IN EFI_STRING_ID TextTwo
3853 EFI_IFR_TEXT OpCode
;
3855 ZeroMem (&OpCode
, sizeof (OpCode
));
3856 OpCode
.Statement
.Prompt
= Prompt
;
3857 OpCode
.Statement
.Help
= Help
;
3858 OpCode
.TextTwo
= TextTwo
;
3860 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_TEXT_OP
, sizeof (OpCode
));
3864 Create EFI_IFR_DATE_OP opcode.
3866 If OpCodeHandle is NULL, then ASSERT().
3867 If any reserved bits are set in QuestionFlags, then ASSERT().
3868 If any reserved bits are set in DateFlags, then ASSERT().
3870 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3871 @param[in] QuestionId Question ID
3872 @param[in] VarStoreId Storage ID, optional. If DateFlags is not
3873 QF_DATE_STORAGE_NORMAL, this parameter is ignored.
3874 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3875 for this name/value pair, optional. If DateFlags is not
3876 QF_DATE_STORAGE_NORMAL, this parameter is ignored.
3877 @param[in] Prompt String ID for Prompt
3878 @param[in] Help String ID for Help
3879 @param[in] QuestionFlags Flags in Question Header
3880 @param[in] DateFlags Flags for date opcode
3881 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3882 is an optional parameter that may be NULL.
3884 @retval NULL There is not enough space left in Buffer to add the opcode.
3885 @retval Other A pointer to the created opcode.
3890 HiiCreateDateOpCode (
3891 IN VOID
*OpCodeHandle
,
3892 IN EFI_QUESTION_ID QuestionId
,
3893 IN EFI_VARSTORE_ID VarStoreId
, OPTIONAL
3894 IN UINT16 VarOffset
, OPTIONAL
3895 IN EFI_STRING_ID Prompt
,
3896 IN EFI_STRING_ID Help
,
3897 IN UINT8 QuestionFlags
,
3899 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3902 EFI_IFR_DATE OpCode
;
3905 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3906 ASSERT ((DateFlags
& (~(EFI_QF_DATE_YEAR_SUPPRESS
| EFI_QF_DATE_MONTH_SUPPRESS
| EFI_QF_DATE_DAY_SUPPRESS
| EFI_QF_DATE_STORAGE
))) == 0);
3908 ZeroMem (&OpCode
, sizeof (OpCode
));
3909 OpCode
.Question
.Header
.Prompt
= Prompt
;
3910 OpCode
.Question
.Header
.Help
= Help
;
3911 OpCode
.Question
.QuestionId
= QuestionId
;
3912 OpCode
.Question
.VarStoreId
= VarStoreId
;
3913 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3914 OpCode
.Question
.Flags
= QuestionFlags
;
3915 OpCode
.Flags
= DateFlags
;
3917 if (DefaultsOpCodeHandle
== NULL
) {
3918 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_DATE_OP
, sizeof (OpCode
));
3921 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3922 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_DATE_OP
, sizeof (OpCode
), 0, 1);
3923 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3924 HiiCreateEndOpCode (OpCodeHandle
);
3925 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3929 Create EFI_IFR_TIME_OP opcode.
3931 If OpCodeHandle is NULL, then ASSERT().
3932 If any reserved bits are set in QuestionFlags, then ASSERT().
3933 If any reserved bits are set in TimeFlags, then ASSERT().
3935 @param[in] OpCodeHandle Handle to the buffer of opcodes.
3936 @param[in] QuestionId Question ID
3937 @param[in] VarStoreId Storage ID, optional. If TimeFlags is not
3938 QF_TIME_STORAGE_NORMAL, this parameter is ignored.
3939 @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
3940 for this name/value pair, optional. If TimeFlags is not
3941 QF_TIME_STORAGE_NORMAL, this parameter is ignored.
3942 @param[in] Prompt String ID for Prompt
3943 @param[in] Help String ID for Help
3944 @param[in] QuestionFlags Flags in Question Header
3945 @param[in] TimeFlags Flags for time opcode
3946 @param[in] DefaultsOpCodeHandle Handle for a buffer of DEFAULT opcodes. This
3947 is an optional parameter that may be NULL.
3949 @retval NULL There is not enough space left in Buffer to add the opcode.
3950 @retval Other A pointer to the created opcode.
3955 HiiCreateTimeOpCode (
3956 IN VOID
*OpCodeHandle
,
3957 IN EFI_QUESTION_ID QuestionId
,
3958 IN EFI_VARSTORE_ID VarStoreId
, OPTIONAL
3959 IN UINT16 VarOffset
, OPTIONAL
3960 IN EFI_STRING_ID Prompt
,
3961 IN EFI_STRING_ID Help
,
3962 IN UINT8 QuestionFlags
,
3964 IN VOID
*DefaultsOpCodeHandle OPTIONAL
3967 EFI_IFR_TIME OpCode
;
3970 ASSERT ((QuestionFlags
& (~(EFI_IFR_FLAG_READ_ONLY
| EFI_IFR_FLAG_CALLBACK
| EFI_IFR_FLAG_RESET_REQUIRED
))) == 0);
3971 ASSERT ((TimeFlags
& (~(QF_TIME_HOUR_SUPPRESS
| QF_TIME_MINUTE_SUPPRESS
| QF_TIME_SECOND_SUPPRESS
| QF_TIME_STORAGE
))) == 0);
3973 ZeroMem (&OpCode
, sizeof (OpCode
));
3974 OpCode
.Question
.Header
.Prompt
= Prompt
;
3975 OpCode
.Question
.Header
.Help
= Help
;
3976 OpCode
.Question
.QuestionId
= QuestionId
;
3977 OpCode
.Question
.VarStoreId
= VarStoreId
;
3978 OpCode
.Question
.VarStoreInfo
.VarOffset
= VarOffset
;
3979 OpCode
.Question
.Flags
= QuestionFlags
;
3980 OpCode
.Flags
= TimeFlags
;
3982 if (DefaultsOpCodeHandle
== NULL
) {
3983 return InternalHiiCreateOpCode (OpCodeHandle
, &OpCode
, EFI_IFR_TIME_OP
, sizeof (OpCode
));
3986 Position
= InternalHiiOpCodeHandlePosition (OpCodeHandle
);
3987 InternalHiiCreateOpCodeExtended (OpCodeHandle
, &OpCode
, EFI_IFR_TIME_OP
, sizeof (OpCode
), 0, 1);
3988 InternalHiiAppendOpCodes (OpCodeHandle
, DefaultsOpCodeHandle
);
3989 HiiCreateEndOpCode (OpCodeHandle
);
3990 return InternalHiiOpCodeHandleBuffer (OpCodeHandle
) + Position
;
3994 This is the internal worker function to update the data in
3995 a form specified by FormSetGuid, FormId and Label.
3997 @param[in] FormSetGuid The optional Formset GUID.
3998 @param[in] FormId The Form ID.
3999 @param[in] Package The package header.
4000 @param[in] OpCodeBufferStart An OpCode buffer that contains the set of IFR
4001 opcodes to be inserted or replaced in the form.
4002 @param[in] OpCodeBufferEnd An OpCcode buffer that contains the IFR opcode
4003 that marks the end of a replace operation in the form.
4004 @param[out] TempPackage The resultant package.
4006 @retval EFI_SUCCESS The function completes successfully.
4007 @retval EFI_NOT_FOUND The updated opcode or endopcode is not found.
4012 InternalHiiUpdateFormPackageData (
4013 IN EFI_GUID
*FormSetGuid
, OPTIONAL
4014 IN EFI_FORM_ID FormId
,
4015 IN EFI_HII_PACKAGE_HEADER
*Package
,
4016 IN HII_LIB_OPCODE_BUFFER
*OpCodeBufferStart
,
4017 IN HII_LIB_OPCODE_BUFFER
*OpCodeBufferEnd
, OPTIONAL
4018 OUT EFI_HII_PACKAGE_HEADER
*TempPackage
4023 EFI_HII_PACKAGE_HEADER PackageHeader
;
4025 EFI_IFR_OP_HEADER
*IfrOpHdr
;
4026 EFI_IFR_OP_HEADER
*UpdateIfrOpHdr
;
4030 UINTN UpdatePackageLength
;
4032 CopyMem (TempPackage
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4033 UpdatePackageLength
= sizeof (EFI_HII_PACKAGE_HEADER
);
4034 BufferPos
= (UINT8
*) (TempPackage
+ 1);
4036 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4037 IfrOpHdr
= (EFI_IFR_OP_HEADER
*)((UINT8
*) Package
+ sizeof (EFI_HII_PACKAGE_HEADER
));
4038 Offset
= sizeof (EFI_HII_PACKAGE_HEADER
);
4039 GetFormSet
= (BOOLEAN
) ((FormSetGuid
== NULL
) ? TRUE
: FALSE
);
4043 while (Offset
< PackageHeader
.Length
) {
4044 CopyMem (BufferPos
, IfrOpHdr
, IfrOpHdr
->Length
);
4045 BufferPos
+= IfrOpHdr
->Length
;
4046 UpdatePackageLength
+= IfrOpHdr
->Length
;
4049 // Find the matched FormSet and Form
4051 if ((IfrOpHdr
->OpCode
== EFI_IFR_FORM_SET_OP
) && (FormSetGuid
!= NULL
)) {
4052 if (CompareGuid((GUID
*)(VOID
*)&((EFI_IFR_FORM_SET
*) IfrOpHdr
)->Guid
, FormSetGuid
)) {
4057 } else if (IfrOpHdr
->OpCode
== EFI_IFR_FORM_OP
|| IfrOpHdr
->OpCode
== EFI_IFR_FORM_MAP_OP
) {
4058 if (CompareMem (&((EFI_IFR_FORM
*) IfrOpHdr
)->FormId
, &FormId
, sizeof (EFI_FORM_ID
)) == 0) {
4066 // The matched Form is found, and Update data in this form
4068 if (GetFormSet
&& GetForm
) {
4069 UpdateIfrOpHdr
= (EFI_IFR_OP_HEADER
*) OpCodeBufferStart
->Buffer
;
4070 if ((UpdateIfrOpHdr
->Length
== IfrOpHdr
->Length
) && \
4071 (CompareMem (IfrOpHdr
, UpdateIfrOpHdr
, UpdateIfrOpHdr
->Length
) == 0)) {
4073 // Remove the original data when End OpCode buffer exist.
4075 if (OpCodeBufferEnd
!= NULL
) {
4076 Offset
+= IfrOpHdr
->Length
;
4077 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((UINT8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4078 UpdateIfrOpHdr
= (EFI_IFR_OP_HEADER
*) OpCodeBufferEnd
->Buffer
;
4079 while (Offset
< PackageHeader
.Length
) {
4081 // Search the matched end opcode
4083 if ((UpdateIfrOpHdr
->Length
== IfrOpHdr
->Length
) && \
4084 (CompareMem (IfrOpHdr
, UpdateIfrOpHdr
, UpdateIfrOpHdr
->Length
) == 0)) {
4088 // Go to the next Op-Code
4090 Offset
+= IfrOpHdr
->Length
;
4091 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((UINT8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4094 if (Offset
>= PackageHeader
.Length
) {
4096 // The end opcode is not found.
4098 return EFI_NOT_FOUND
;
4103 // Insert the updated data
4105 AddSize
= ((EFI_IFR_OP_HEADER
*) OpCodeBufferStart
->Buffer
)->Length
;
4106 CopyMem (BufferPos
, OpCodeBufferStart
->Buffer
+ AddSize
, OpCodeBufferStart
->Position
- AddSize
);
4107 BufferPos
+= OpCodeBufferStart
->Position
- AddSize
;
4108 UpdatePackageLength
+= OpCodeBufferStart
->Position
- AddSize
;
4110 if (OpCodeBufferEnd
!= NULL
) {
4112 // Add the end opcode
4114 CopyMem (BufferPos
, IfrOpHdr
, IfrOpHdr
->Length
);
4115 BufferPos
+= IfrOpHdr
->Length
;
4116 UpdatePackageLength
+= IfrOpHdr
->Length
;
4120 // Copy the left package data.
4122 Offset
+= IfrOpHdr
->Length
;
4123 CopyMem (BufferPos
, (UINT8
*) Package
+ Offset
, PackageHeader
.Length
- Offset
);
4124 UpdatePackageLength
+= PackageHeader
.Length
- Offset
;
4135 // Go to the next Op-Code
4137 Offset
+= IfrOpHdr
->Length
;
4138 IfrOpHdr
= (EFI_IFR_OP_HEADER
*) ((CHAR8
*) (IfrOpHdr
) + IfrOpHdr
->Length
);
4143 // The updated opcode buffer is not found.
4145 return EFI_NOT_FOUND
;
4148 // Update the package length.
4150 PackageHeader
.Length
= (UINT32
) UpdatePackageLength
;
4151 CopyMem (TempPackage
, &PackageHeader
, sizeof (EFI_HII_PACKAGE_HEADER
));
4157 This function updates a form that has previously been registered with the HII
4158 Database. This function will perform at most one update operation.
4160 The form to update is specified by Handle, FormSetGuid, and FormId. Binary
4161 comparisons of IFR opcodes are performed from the beginning of the form being
4162 updated until an IFR opcode is found that exactly matches the first IFR opcode
4163 specified by StartOpCodeHandle. The following rules are used to determine if
4164 an insert, replace, or delete operation is performed.
4166 1) If no matches are found, then NULL is returned.
4167 2) If a match is found, and EndOpCodeHandle is NULL, then all of the IFR opcodes
4168 from StartOpCodeHandle except the first opcode are inserted immediately after
4169 the matching IFR opcode in the form to be updated.
4170 3) If a match is found, and EndOpCodeHandle is not NULL, then a search is made
4171 from the matching IFR opcode until an IFR opcode exactly matches the first
4172 IFR opcode specified by EndOpCodeHandle. If no match is found for the first
4173 IFR opcode specified by EndOpCodeHandle, then NULL is returned. If a match
4174 is found, then all of the IFR opcodes between the start match and the end
4175 match are deleted from the form being updated and all of the IFR opcodes
4176 from StartOpCodeHandle except the first opcode are inserted immediately after
4177 the matching start IFR opcode. If StartOpCcodeHandle only contains one
4178 IFR instruction, then the result of this operation will delete all of the IFR
4179 opcodes between the start end matches.
4181 If HiiHandle is NULL, then ASSERT().
4182 If StartOpCodeHandle is NULL, then ASSERT().
4184 @param[in] HiiHandle The HII Handle of the form to update.
4185 @param[in] FormSetGuid The Formset GUID of the form to update. This
4186 is an optional parameter that may be NULL.
4187 If it is NULL, all FormSet will be updated.
4188 @param[in] FormId The ID of the form to update.
4189 @param[in] StartOpCodeHandle An OpCode Handle that contains the set of IFR
4190 opcodes to be inserted or replaced in the form.
4191 The first IFR instruction in StartOpCodeHandle
4192 is used to find matching IFR opcode in the
4194 @param[in] EndOpCodeHandle An OpCcode Handle that contains the IFR opcode
4195 that marks the end of a replace operation in
4196 the form. This is an optional parameter that
4197 may be NULL. If it is NULL, then an the IFR
4198 opcodes specified by StartOpCodeHandle are
4199 inserted into the form.
4201 @retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated.
4202 @retval EFI_NOT_FOUND The following cases will return EFI_NOT_FOUND.
4203 1) The form specified by HiiHandle, FormSetGuid,
4204 and FormId could not be found in the HII Database.
4205 2) No IFR opcodes in the target form match the first
4206 IFR opcode in StartOpCodeHandle.
4207 3) EndOpCOde is not NULL, and no IFR opcodes in the
4208 target form following a matching start opcode match
4209 the first IFR opcode in EndOpCodeHandle.
4210 @retval EFI_SUCCESS The matched form is updated by StartOpcode.
4216 IN EFI_HII_HANDLE HiiHandle
,
4217 IN EFI_GUID
*FormSetGuid
, OPTIONAL
4218 IN EFI_FORM_ID FormId
,
4219 IN VOID
*StartOpCodeHandle
,
4220 IN VOID
*EndOpCodeHandle OPTIONAL
4224 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
4225 UINT32 PackageListLength
;
4227 EFI_HII_PACKAGE_LIST_HEADER
*UpdatePackageList
;
4229 UINT8
*UpdateBufferPos
;
4230 EFI_HII_PACKAGE_HEADER
*Package
;
4231 EFI_HII_PACKAGE_HEADER
*TempPackage
;
4232 EFI_HII_PACKAGE_HEADER PackageHeader
;
4234 HII_LIB_OPCODE_BUFFER
*OpCodeBufferStart
;
4235 HII_LIB_OPCODE_BUFFER
*OpCodeBufferEnd
;
4238 // Input update data can't be NULL.
4240 ASSERT (HiiHandle
!= NULL
);
4241 ASSERT (StartOpCodeHandle
!= NULL
);
4242 UpdatePackageList
= NULL
;
4244 HiiPackageList
= NULL
;
4247 // Retrieve buffer data from Opcode Handle
4249 OpCodeBufferStart
= (HII_LIB_OPCODE_BUFFER
*) StartOpCodeHandle
;
4250 OpCodeBufferEnd
= (HII_LIB_OPCODE_BUFFER
*) EndOpCodeHandle
;
4253 // Get the original package list
4256 HiiPackageList
= NULL
;
4257 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
4259 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
4261 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
4265 HiiPackageList
= AllocatePool (BufferSize
);
4266 if (HiiPackageList
== NULL
) {
4267 Status
= EFI_OUT_OF_RESOURCES
;
4271 Status
= gHiiDatabase
->ExportPackageLists (gHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
4272 if (EFI_ERROR (Status
)) {
4277 // Calculate and allocate space for retrieval of IFR data
4279 BufferSize
+= OpCodeBufferStart
->Position
;
4280 UpdatePackageList
= AllocateZeroPool (BufferSize
);
4281 if (UpdatePackageList
== NULL
) {
4282 Status
= EFI_OUT_OF_RESOURCES
;
4287 // Allocate temp buffer to store the temp updated package buffer
4289 TempPackage
= AllocateZeroPool (BufferSize
);
4290 if (TempPackage
== NULL
) {
4291 Status
= EFI_OUT_OF_RESOURCES
;
4295 UpdateBufferPos
= (UINT8
*) UpdatePackageList
;
4298 // Copy the package list header
4300 CopyMem (UpdateBufferPos
, HiiPackageList
, sizeof (EFI_HII_PACKAGE_LIST_HEADER
));
4301 UpdateBufferPos
+= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
4304 // Go through each package to find the matched package and update one by one
4307 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
4308 PackageListLength
= ReadUnaligned32 (&HiiPackageList
->PackageLength
);
4309 while (Offset
< PackageListLength
) {
4310 Package
= (EFI_HII_PACKAGE_HEADER
*) (((UINT8
*) HiiPackageList
) + Offset
);
4311 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4312 Offset
+= Package
->Length
;
4314 if (Package
->Type
== EFI_HII_PACKAGE_FORMS
) {
4316 // Check this package is the matched package.
4318 Status
= InternalHiiUpdateFormPackageData (FormSetGuid
, FormId
, Package
, OpCodeBufferStart
, OpCodeBufferEnd
, TempPackage
);
4320 // The matched package is found. Its package buffer will be updated by the input new data.
4322 if (!EFI_ERROR(Status
)) {
4328 // Add updated package buffer
4330 Package
= TempPackage
;
4335 // Add pacakge buffer
4337 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
4338 CopyMem (UpdateBufferPos
, Package
, PackageHeader
.Length
);
4339 UpdateBufferPos
+= PackageHeader
.Length
;
4344 // Update package list length
4346 BufferSize
= UpdateBufferPos
- (UINT8
*) UpdatePackageList
;
4347 WriteUnaligned32 (&UpdatePackageList
->PackageLength
, (UINT32
) BufferSize
);
4350 // Update Package to show form
4352 Status
= gHiiDatabase
->UpdatePackageList (gHiiDatabase
, HiiHandle
, UpdatePackageList
);
4355 // Not matched form is found and updated.
4357 Status
= EFI_NOT_FOUND
;
4361 if (HiiPackageList
!= NULL
) {
4362 FreePool (HiiPackageList
);
4365 if (UpdatePackageList
!= NULL
) {
4366 FreePool (UpdatePackageList
);
4369 if (TempPackage
!= NULL
) {
4370 FreePool (TempPackage
);