TianoCore EDK2 master
Loading...
Searching...
No Matches
HiiLib.c
Go to the documentation of this file.
1
9#include "InternalHiiLib.h"
10
11#define GUID_CONFIG_STRING_TYPE 0x00
12#define NAME_CONFIG_STRING_TYPE 0x01
13#define PATH_CONFIG_STRING_TYPE 0x02
14
15#define ACTION_SET_DEFAUTL_VALUE 0x01
16#define ACTION_VALIDATE_SETTING 0x02
17
18#define HII_LIB_DEFAULT_VARSTORE_SIZE 0x200
19
20typedef struct {
21 LIST_ENTRY Entry; // Link to Block array
22 UINT16 Offset;
23 UINT16 Width;
24 UINT8 OpCode;
25 UINT8 Scope;
27
28typedef struct {
29 EFI_VARSTORE_ID VarStoreId;
30 UINT16 Size;
32
33//
34// <ConfigHdr> Template
35//
36GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR16 mConfigHdrTemplate[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=00";
37
38EFI_FORM_BROWSER2_PROTOCOL *mUefiFormBrowser2 = NULL;
39
40//
41// Template used to mark the end of a list of packages
42//
45 EFI_HII_PACKAGE_END
46};
47
61EFIAPI
63 IN EFI_HII_HANDLE Handle,
64 OUT EFI_GUID *Guid
65 )
66{
67 EFI_STATUS Status;
68 UINTN BufferSize;
69 EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
70
71 ASSERT (Guid != NULL);
72 ASSERT (Handle != NULL);
73
74 //
75 // Get HII PackageList
76 //
77 BufferSize = 0;
78 HiiPackageList = NULL;
79
80 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);
81 ASSERT (Status != EFI_NOT_FOUND);
82
83 if (Status == EFI_BUFFER_TOO_SMALL) {
84 HiiPackageList = AllocatePool (BufferSize);
85 ASSERT (HiiPackageList != NULL);
86
87 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);
88 }
89
90 if (EFI_ERROR (Status)) {
91 FreePool (HiiPackageList);
92 return Status;
93 }
94
95 //
96 // Extract GUID
97 //
98 CopyGuid (Guid, &HiiPackageList->PackageListGuid);
99
100 FreePool (HiiPackageList);
101
102 return EFI_SUCCESS;
103}
104
140EFIAPI
142 IN CONST EFI_GUID *PackageListGuid,
143 IN EFI_HANDLE DeviceHandle OPTIONAL,
144 ...
145 )
146{
147 EFI_STATUS Status;
148 VA_LIST Args;
149 UINT32 *Package;
150 EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
151 EFI_HII_HANDLE HiiHandle;
152 UINT32 Length;
153 UINT8 *Data;
154
155 ASSERT (PackageListGuid != NULL);
156
157 //
158 // Calculate the length of all the packages in the variable argument list
159 //
160 for (Length = 0, VA_START (Args, DeviceHandle); (Package = VA_ARG (Args, UINT32 *)) != NULL; ) {
161 Length += (ReadUnaligned32 (Package) - sizeof (UINT32));
162 }
163
164 VA_END (Args);
165
166 //
167 // If there are no packages in the variable argument list or all the packages
168 // are empty, then return a NULL HII Handle
169 //
170 if (Length == 0) {
171 return NULL;
172 }
173
174 //
175 // Add the length of the Package List Header and the terminating Package Header
176 //
177 Length += sizeof (EFI_HII_PACKAGE_LIST_HEADER) + sizeof (EFI_HII_PACKAGE_HEADER);
178
179 //
180 // Allocate the storage for the entire Package List
181 //
182 PackageListHeader = AllocateZeroPool (Length);
183
184 //
185 // If the Package List can not be allocated, then return a NULL HII Handle
186 //
187 if (PackageListHeader == NULL) {
188 return NULL;
189 }
190
191 //
192 // Fill in the GUID and Length of the Package List Header
193 //
194 CopyGuid (&PackageListHeader->PackageListGuid, PackageListGuid);
195 PackageListHeader->PackageLength = Length;
196
197 //
198 // Initialize a pointer to the beginning if the Package List data
199 //
200 Data = (UINT8 *)(PackageListHeader + 1);
201
202 //
203 // Copy the data from each package in the variable argument list
204 //
205 for (VA_START (Args, DeviceHandle); (Package = VA_ARG (Args, UINT32 *)) != NULL; ) {
206 Length = ReadUnaligned32 (Package) - sizeof (UINT32);
207 CopyMem (Data, Package + 1, Length);
208 Data += Length;
209 }
210
211 VA_END (Args);
212
213 //
214 // Append a package of type EFI_HII_PACKAGE_END to mark the end of the package list
215 //
216 CopyMem (Data, &mEndOfPakageList, sizeof (mEndOfPakageList));
217
218 //
219 // Register the package list with the HII Database
220 //
221 Status = gHiiDatabase->NewPackageList (
223 PackageListHeader,
224 DeviceHandle,
225 &HiiHandle
226 );
227 if (EFI_ERROR (Status)) {
228 HiiHandle = NULL;
229 }
230
231 //
232 // Free the allocated package list
233 //
234 FreePool (PackageListHeader);
235
236 //
237 // Return the new HII Handle
238 //
239 return HiiHandle;
240}
241
251VOID
252EFIAPI
254 IN EFI_HII_HANDLE HiiHandle
255 )
256{
257 EFI_STATUS Status;
258
259 ASSERT (HiiHandle != NULL);
260 Status = gHiiDatabase->RemovePackageList (gHiiDatabase, HiiHandle);
261 ASSERT_EFI_ERROR (Status);
262}
263
285EFIAPI
287 IN CONST EFI_GUID *PackageListGuid OPTIONAL
288 )
289{
290 EFI_STATUS Status;
291 UINTN HandleBufferLength;
292 EFI_HII_HANDLE TempHiiHandleBuffer;
293 EFI_HII_HANDLE *HiiHandleBuffer;
294 EFI_GUID Guid;
295 UINTN Index1;
296 UINTN Index2;
297
298 //
299 // Retrieve the size required for the buffer of all HII handles.
300 //
301 HandleBufferLength = 0;
302 Status = gHiiDatabase->ListPackageLists (
304 EFI_HII_PACKAGE_TYPE_ALL,
305 NULL,
306 &HandleBufferLength,
307 &TempHiiHandleBuffer
308 );
309
310 //
311 // If ListPackageLists() returns EFI_SUCCESS for a zero size,
312 // then there are no HII handles in the HII database. If ListPackageLists()
313 // returns an error other than EFI_BUFFER_TOO_SMALL, then there are no HII
314 // handles in the HII database.
315 //
316 if (Status != EFI_BUFFER_TOO_SMALL) {
317 //
318 // Return NULL if the size can not be retrieved, or if there are no HII
319 // handles in the HII Database
320 //
321 return NULL;
322 }
323
324 //
325 // Allocate the array of HII handles to hold all the HII Handles and a NULL terminator
326 //
327 HiiHandleBuffer = AllocateZeroPool (HandleBufferLength + sizeof (EFI_HII_HANDLE));
328 if (HiiHandleBuffer == NULL) {
329 //
330 // Return NULL if allocation fails.
331 //
332 return NULL;
333 }
334
335 //
336 // Retrieve the array of HII Handles in the HII Database
337 //
338 Status = gHiiDatabase->ListPackageLists (
340 EFI_HII_PACKAGE_TYPE_ALL,
341 NULL,
342 &HandleBufferLength,
343 HiiHandleBuffer
344 );
345 if (EFI_ERROR (Status)) {
346 //
347 // Free the buffer and return NULL if the HII handles can not be retrieved.
348 //
349 FreePool (HiiHandleBuffer);
350 return NULL;
351 }
352
353 if (PackageListGuid == NULL) {
354 //
355 // Return the NULL terminated array of HII handles in the HII Database
356 //
357 return HiiHandleBuffer;
358 } else {
359 for (Index1 = 0, Index2 = 0; HiiHandleBuffer[Index1] != NULL; Index1++) {
360 Status = InternalHiiExtractGuidFromHiiHandle (HiiHandleBuffer[Index1], &Guid);
361 ASSERT_EFI_ERROR (Status);
362 if (CompareGuid (&Guid, PackageListGuid)) {
363 HiiHandleBuffer[Index2++] = HiiHandleBuffer[Index1];
364 }
365 }
366
367 if (Index2 > 0) {
368 HiiHandleBuffer[Index2] = NULL;
369 return HiiHandleBuffer;
370 } else {
371 FreePool (HiiHandleBuffer);
372 return NULL;
373 }
374 }
375}
376
393EFIAPI
395 IN EFI_HII_HANDLE Handle,
396 OUT EFI_IFR_FORM_SET **Buffer,
397 OUT UINTN *BufferSize
398 )
399{
400 EFI_STATUS Status;
401 UINTN PackageListSize;
402 UINTN TempSize;
403 EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
404 UINT8 *Package;
405 UINT8 *OpCodeData;
406 UINT8 *FormSetBuffer;
407 UINT8 *TempBuffer;
408 UINT32 Offset;
409 UINT32 Offset2;
410 UINT32 PackageListLength;
411 EFI_HII_PACKAGE_HEADER PackageHeader;
412
413 TempSize = 0;
414 FormSetBuffer = NULL;
415 TempBuffer = NULL;
416
417 //
418 // Get HII PackageList
419 //
420 PackageListSize = 0;
421 HiiPackageList = NULL;
422 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList);
423 if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
424 return Status;
425 }
426
427 HiiPackageList = AllocatePool (PackageListSize);
428 if (HiiPackageList == NULL) {
429 return EFI_OUT_OF_RESOURCES;
430 }
431
432 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList);
433 ASSERT_EFI_ERROR (Status);
434
435 //
436 // Get Form package from this HII package List
437 //
438 Status = EFI_NOT_FOUND;
439 Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
440 PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);
441
442 while (Offset < PackageListLength) {
443 Package = ((UINT8 *)HiiPackageList) + Offset;
444 CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
445 Offset += PackageHeader.Length;
446
447 if (PackageHeader.Type != EFI_HII_PACKAGE_FORMS) {
448 continue;
449 }
450
451 //
452 // Search FormSet Opcode in this Form Package
453 //
454 Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
455 while (Offset2 < PackageHeader.Length) {
456 OpCodeData = Package + Offset2;
457 Offset2 += ((EFI_IFR_OP_HEADER *)OpCodeData)->Length;
458
459 if (((EFI_IFR_OP_HEADER *)OpCodeData)->OpCode != EFI_IFR_FORM_SET_OP) {
460 continue;
461 }
462
463 if (FormSetBuffer != NULL) {
464 TempBuffer = ReallocatePool (
465 TempSize,
466 TempSize + ((EFI_IFR_OP_HEADER *)OpCodeData)->Length,
467 FormSetBuffer
468 );
469 if (TempBuffer == NULL) {
470 Status = EFI_OUT_OF_RESOURCES;
471 goto Done;
472 }
473
474 CopyMem (TempBuffer + TempSize, OpCodeData, ((EFI_IFR_OP_HEADER *)OpCodeData)->Length);
475 FormSetBuffer = NULL;
476 } else {
477 TempBuffer = AllocatePool (TempSize + ((EFI_IFR_OP_HEADER *)OpCodeData)->Length);
478 if (TempBuffer == NULL) {
479 Status = EFI_OUT_OF_RESOURCES;
480 goto Done;
481 }
482
483 CopyMem (TempBuffer, OpCodeData, ((EFI_IFR_OP_HEADER *)OpCodeData)->Length);
484 }
485
486 TempSize += ((EFI_IFR_OP_HEADER *)OpCodeData)->Length;
487 FormSetBuffer = TempBuffer;
488
489 Status = EFI_SUCCESS;
490 //
491 // One form package has one formset, exit current form package to search other form package in the packagelist.
492 //
493 break;
494 }
495 }
496
497Done:
498 FreePool (HiiPackageList);
499
500 *BufferSize = TempSize;
501 *Buffer = (EFI_IFR_FORM_SET *)FormSetBuffer;
502
503 return Status;
504}
505
517EFI_STRING
518EFIAPI
520 IN EFI_STRING ConfigString
521 )
522{
523 EFI_STRING String;
524 BOOLEAN Lower;
525
526 ASSERT (ConfigString != NULL);
527
528 //
529 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
530 //
531 for (String = ConfigString, Lower = FALSE; *String != L'\0'; String++) {
532 if (*String == L'=') {
533 Lower = TRUE;
534 } else if (*String == L'&') {
535 Lower = FALSE;
536 } else if (Lower && (*String >= L'A') && (*String <= L'F')) {
537 *String = (CHAR16)(*String - L'A' + L'a');
538 }
539 }
540
541 return ConfigString;
542}
543
559EFI_STRING
560EFIAPI
562 IN CONST EFI_STRING ConfigRequest,
563 IN CONST UINT8 *Block,
564 IN UINTN BlockSize
565 )
566{
567 EFI_STATUS Status;
568 EFI_STRING ConfigResp;
569 CHAR16 *Progress;
570
571 ASSERT (ConfigRequest != NULL);
572 ASSERT (Block != NULL);
573
574 //
575 // Convert <ConfigRequest> to <ConfigResp>
576 //
577 Status = gHiiConfigRouting->BlockToConfig (
579 ConfigRequest,
580 Block,
581 BlockSize,
582 &ConfigResp,
583 &Progress
584 );
585 if (EFI_ERROR (Status)) {
586 return NULL;
587 }
588
589 return ConfigResp;
590}
591
611EFI_STRING
612EFIAPI
614 IN CONST EFI_GUID *VariableGuid OPTIONAL,
615 IN CONST CHAR16 *VariableName OPTIONAL,
616 IN CONST EFI_STRING SetResultsData OPTIONAL
617 )
618{
619 EFI_STATUS Status;
620 UINTN ResultsDataSize;
621 EFI_STRING ResultsData;
622 CHAR16 TempResultsData;
623
624 //
625 // Locate protocols
626 //
627 if (mUefiFormBrowser2 == NULL) {
628 Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&mUefiFormBrowser2);
629 if (EFI_ERROR (Status) || (mUefiFormBrowser2 == NULL)) {
630 return NULL;
631 }
632 }
633
634 ResultsDataSize = 0;
635
636 if (SetResultsData != NULL) {
637 //
638 // Request to to set data in the uncommitted browser state information
639 //
640 ResultsData = SetResultsData;
641 } else {
642 //
643 // Retrieve the length of the buffer required ResultsData from the Browser Callback
644 //
645 Status = mUefiFormBrowser2->BrowserCallback (
646 mUefiFormBrowser2,
647 &ResultsDataSize,
648 &TempResultsData,
649 TRUE,
650 VariableGuid,
651 VariableName
652 );
653
654 if (!EFI_ERROR (Status)) {
655 //
656 // No Resluts Data, only allocate one char for '\0'
657 //
658 ResultsData = AllocateZeroPool (sizeof (CHAR16));
659 return ResultsData;
660 }
661
662 if (Status != EFI_BUFFER_TOO_SMALL) {
663 return NULL;
664 }
665
666 //
667 // Allocate the ResultsData buffer
668 //
669 ResultsData = AllocateZeroPool (ResultsDataSize);
670 if (ResultsData == NULL) {
671 return NULL;
672 }
673 }
674
675 //
676 // Retrieve or set the ResultsData from the Browser Callback
677 //
678 Status = mUefiFormBrowser2->BrowserCallback (
679 mUefiFormBrowser2,
680 &ResultsDataSize,
681 ResultsData,
682 (BOOLEAN)(SetResultsData == NULL),
683 VariableGuid,
684 VariableName
685 );
686 if (EFI_ERROR (Status)) {
687 return NULL;
688 }
689
690 return ResultsData;
691}
692
721EFI_STRING
722EFIAPI
724 IN CONST EFI_GUID *Guid OPTIONAL,
725 IN CONST CHAR16 *Name OPTIONAL,
726 IN EFI_HANDLE DriverHandle
727 )
728{
729 UINTN NameLength;
730 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
731 UINTN DevicePathSize;
732 CHAR16 *String;
733 CHAR16 *ReturnString;
734 UINTN Index;
735 UINT8 *Buffer;
736 UINTN MaxLen;
737
738 //
739 // Compute the length of Name in Unicode characters.
740 // If Name is NULL, then the length is 0.
741 //
742 NameLength = 0;
743 if (Name != NULL) {
744 NameLength = StrLen (Name);
745 }
746
747 DevicePath = NULL;
748 DevicePathSize = 0;
749 //
750 // Retrieve DevicePath Protocol associated with DriverHandle
751 //
752 if (DriverHandle != NULL) {
753 DevicePath = DevicePathFromHandle (DriverHandle);
754 if (DevicePath == NULL) {
755 return NULL;
756 }
757
758 //
759 // Compute the size of the device path in bytes
760 //
761 DevicePathSize = GetDevicePathSize (DevicePath);
762 }
763
764 //
765 // GUID=<HexCh>32&NAME=<Char>NameLength&PATH=<HexChar>DevicePathSize <Null>
766 // | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 |
767 //
768 MaxLen = 5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1;
769 String = AllocateZeroPool (MaxLen * sizeof (CHAR16));
770 if (String == NULL) {
771 return NULL;
772 }
773
774 //
775 // Start with L"GUID="
776 //
777 StrCpyS (String, MaxLen, L"GUID=");
778 ReturnString = String;
779 String += StrLen (String);
780
781 if (Guid != NULL) {
782 //
783 // Append Guid converted to <HexCh>32
784 //
785 for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) {
787 String,
788 MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString),
789 PREFIX_ZERO | RADIX_HEX,
790 *(Buffer++),
791 2
792 );
793 String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16));
794 }
795 }
796
797 //
798 // Append L"&NAME="
799 //
800 StrCatS (ReturnString, MaxLen, L"&NAME=");
801 String += StrLen (String);
802
803 if (Name != NULL) {
804 //
805 // Append Name converted to <Char>NameLength
806 //
807 for ( ; *Name != L'\0'; Name++) {
809 String,
810 sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString),
811 PREFIX_ZERO | RADIX_HEX,
812 *Name,
813 4
814 );
815 String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16));
816 }
817 }
818
819 //
820 // Append L"&PATH="
821 //
822 StrCatS (ReturnString, MaxLen, L"&PATH=");
823 String += StrLen (String);
824
825 //
826 // Append the device path associated with DriverHandle converted to <HexChar>DevicePathSize
827 //
828 for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) {
830 String,
831 sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString),
832 PREFIX_ZERO | RADIX_HEX,
833 *(Buffer++),
834 2
835 );
836 String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16));
837 }
838
839 //
840 // Null terminate the Unicode string
841 //
842 *String = L'\0';
843
844 //
845 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
846 //
847 return InternalHiiLowerConfigString (ReturnString);
848}
849
868 IN EFI_STRING String,
869 IN UINT8 Flag,
870 OUT UINT8 **Buffer
871 )
872{
873 UINTN Length;
874 EFI_STRING ConfigHdr;
875 CHAR16 *StringPtr;
876 UINT8 *DataBuffer;
877 CHAR16 TemStr[5];
878 UINTN Index;
879 UINT8 DigitUint8;
880
881 if ((String == NULL) || (Buffer == NULL)) {
882 return EFI_INVALID_PARAMETER;
883 }
884
885 DataBuffer = NULL;
886 StringPtr = NULL;
887 ConfigHdr = String;
888 //
889 // The content between 'GUID', 'NAME', 'PATH' of <ConfigHdr> and '&' of next element
890 // or '\0' (end of configuration string) is the UNICODE %02x bytes encoding string.
891 //
892 for (Length = 0; *String != 0 && *String != L'&'; String++, Length++) {
893 }
894
895 switch (Flag) {
896 case GUID_CONFIG_STRING_TYPE:
897 case PATH_CONFIG_STRING_TYPE:
898 //
899 // The data in <ConfigHdr> is encoded as hex UNICODE %02x bytes in the same order
900 // as the device path and Guid resides in RAM memory.
901 // Translate the data into binary.
902 //
903 DataBuffer = (UINT8 *)AllocateZeroPool ((Length + 1) / 2);
904 if (DataBuffer == NULL) {
905 return EFI_OUT_OF_RESOURCES;
906 }
907
908 //
909 // Convert binary byte one by one
910 //
911 ZeroMem (TemStr, sizeof (TemStr));
912 for (Index = 0; Index < Length; Index++) {
913 TemStr[0] = ConfigHdr[Index];
914 DigitUint8 = (UINT8)StrHexToUint64 (TemStr);
915 if ((Index & 1) == 0) {
916 DataBuffer[Index/2] = DigitUint8;
917 } else {
918 DataBuffer[Index/2] = (UINT8)((DataBuffer[Index/2] << 4) + DigitUint8);
919 }
920 }
921
922 *Buffer = DataBuffer;
923 break;
924
925 case NAME_CONFIG_STRING_TYPE:
926 //
927 // Convert Config String to Unicode String, e.g. "0041004200430044" => "ABCD"
928 //
929
930 //
931 // Add the tailling char L'\0'
932 //
933 DataBuffer = (UINT8 *)AllocateZeroPool ((Length/4 + 1) * sizeof (CHAR16));
934 if (DataBuffer == NULL) {
935 return EFI_OUT_OF_RESOURCES;
936 }
937
938 //
939 // Convert character one by one
940 //
941 StringPtr = (CHAR16 *)DataBuffer;
942 ZeroMem (TemStr, sizeof (TemStr));
943 for (Index = 0; Index < Length; Index += 4) {
944 StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), ConfigHdr + Index, 4);
945 StringPtr[Index/4] = (CHAR16)StrHexToUint64 (TemStr);
946 }
947
948 //
949 // Add tailing L'\0' character
950 //
951 StringPtr[Index/4] = L'\0';
952
953 *Buffer = DataBuffer;
954 break;
955
956 default:
957 return EFI_INVALID_PARAMETER;
958 }
959
960 return EFI_SUCCESS;
961}
962
973BOOLEAN
975 IN IFR_BLOCK_DATA *BlockArray,
976 IN UINT16 VarOffset,
977 IN UINT16 VarWidth
978 )
979{
980 LIST_ENTRY *Link;
981 IFR_BLOCK_DATA *BlockData;
982
983 //
984 // No Request Block array, all vars are got.
985 //
986 if (BlockArray == NULL) {
987 return TRUE;
988 }
989
990 //
991 // Check the input var is in the request block range.
992 //
993 for (Link = BlockArray->Entry.ForwardLink; Link != &BlockArray->Entry; Link = Link->ForwardLink) {
994 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
995 if ((VarOffset >= BlockData->Offset) && ((VarOffset + VarWidth) <= (BlockData->Offset + BlockData->Width))) {
996 return TRUE;
997 }
998 }
999
1000 return FALSE;
1001}
1002
1021EFIAPI
1023 IN EFI_STRING ValueString,
1024 OUT UINT8 **ValueData,
1025 OUT UINTN *ValueLength
1026 )
1027{
1028 EFI_STRING StringPtr;
1029 UINTN Length;
1030 UINT8 *Buf;
1031 UINT8 DigitUint8;
1032 UINTN Index;
1033 CHAR16 TemStr[2];
1034
1035 ASSERT (ValueString != NULL && ValueData != NULL && ValueLength != NULL);
1036 ASSERT (*ValueString != L'\0');
1037
1038 //
1039 // Get the length of value string
1040 //
1041 StringPtr = ValueString;
1042 while (*StringPtr != L'\0' && *StringPtr != L'&') {
1043 StringPtr++;
1044 }
1045
1046 Length = StringPtr - ValueString;
1047
1048 //
1049 // Allocate buffer to store the value
1050 //
1051 Buf = (UINT8 *)AllocateZeroPool ((Length + 1) / 2);
1052 if (Buf == NULL) {
1053 return EFI_OUT_OF_RESOURCES;
1054 }
1055
1056 //
1057 // Convert character one by one to the value buffer
1058 //
1059 ZeroMem (TemStr, sizeof (TemStr));
1060 for (Index = 0; Index < Length; Index++) {
1061 TemStr[0] = ValueString[Length - Index - 1];
1062 DigitUint8 = (UINT8)StrHexToUint64 (TemStr);
1063 if ((Index & 1) == 0) {
1064 Buf[Index/2] = DigitUint8;
1065 } else {
1066 Buf[Index/2] = (UINT8)((DigitUint8 << 4) + Buf[Index/2]);
1067 }
1068 }
1069
1070 //
1071 // Set the converted value and string length.
1072 //
1073 *ValueData = Buf;
1074 *ValueLength = Length;
1075 return EFI_SUCCESS;
1076}
1077
1090 IN CHAR16 *ConfigElement,
1091 IN CHAR16 *VarName,
1092 OUT UINT64 *VarValue
1093 )
1094{
1095 UINT8 *TmpBuffer;
1096 CHAR16 *StringPtr;
1097 UINTN Length;
1098 EFI_STATUS Status;
1099
1100 //
1101 // Find VarName related string.
1102 //
1103 StringPtr = StrStr (ConfigElement, VarName);
1104 ASSERT (StringPtr != NULL);
1105
1106 //
1107 // Skip the "VarName=" string
1108 //
1109 StringPtr += StrLen (VarName) + 1;
1110
1111 //
1112 // Get Offset
1113 //
1114 Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length);
1115 if (EFI_ERROR (Status)) {
1116 return Status;
1117 }
1118
1119 *VarValue = 0;
1120 CopyMem (VarValue, TmpBuffer, (((Length + 1) / 2) < sizeof (UINT64)) ? ((Length + 1) / 2) : sizeof (UINT64));
1121
1122 FreePool (TmpBuffer);
1123
1124 return EFI_SUCCESS;
1125}
1126
1149 IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
1150 IN UINTN PackageListLength,
1151 IN EFI_GUID *VarGuid,
1152 IN CHAR16 *VarName,
1153 IN UINT8 *VarBuffer,
1154 IN IFR_BLOCK_DATA *CurrentBlockArray,
1155 IN CHAR16 *RequestElement,
1156 IN EFI_HII_HANDLE HiiHandle,
1157 IN BOOLEAN NameValueType
1158 )
1159{
1160 IFR_BLOCK_DATA VarBlockData;
1161 UINT16 Offset;
1162 UINT16 Width;
1163 UINT64 VarValue;
1164 EFI_IFR_TYPE_VALUE TmpValue;
1165 EFI_STATUS Status;
1166 EFI_HII_PACKAGE_HEADER PackageHeader;
1167 UINT32 PackageOffset;
1168 UINT8 *PackageData;
1169 UINTN IfrOffset;
1170 EFI_IFR_OP_HEADER *IfrOpHdr;
1171 EFI_IFR_VARSTORE *IfrVarStore;
1172 EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueStore;
1173 EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
1174 IFR_VARSTORAGE_DATA VarStoreData;
1175 EFI_IFR_ONE_OF *IfrOneOf;
1176 EFI_IFR_NUMERIC *IfrNumeric;
1177 EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;
1178 EFI_IFR_CHECKBOX *IfrCheckBox;
1179 EFI_IFR_STRING *IfrString;
1180 CHAR8 *VarStoreName;
1181 UINTN Index;
1182 CHAR16 *QuestionName;
1183 CHAR16 *StringPtr;
1184 UINT16 BitOffset;
1185 UINT16 BitWidth;
1186 UINT16 TotalBits;
1187 UINTN StartBit;
1188 UINTN EndBit;
1189 BOOLEAN QuestionReferBitField;
1190 UINT32 BufferValue;
1191
1192 //
1193 // Initialize the local variables.
1194 //
1195 Index = 0;
1196 VarStoreName = NULL;
1197 Status = EFI_SUCCESS;
1198 VarValue = 0;
1199 IfrVarStore = NULL;
1200 IfrNameValueStore = NULL;
1201 IfrEfiVarStore = NULL;
1202 ZeroMem (&VarStoreData, sizeof (IFR_VARSTORAGE_DATA));
1203 ZeroMem (&VarBlockData, sizeof (VarBlockData));
1204 BitOffset = 0;
1205 BitWidth = 0;
1206 QuestionReferBitField = FALSE;
1207
1208 //
1209 // Check IFR value is in block data, then Validate Value
1210 //
1211 PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
1212 while (PackageOffset < PackageListLength) {
1213 CopyMem (&PackageHeader, (UINT8 *)HiiPackageList + PackageOffset, sizeof (PackageHeader));
1214
1215 //
1216 // Parse IFR opcode from the form package.
1217 //
1218 if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
1219 IfrOffset = sizeof (PackageHeader);
1220 PackageData = (UINT8 *)HiiPackageList + PackageOffset;
1221 while (IfrOffset < PackageHeader.Length) {
1222 IfrOpHdr = (EFI_IFR_OP_HEADER *)(PackageData + IfrOffset);
1223 //
1224 // Validate current setting to the value built in IFR opcode
1225 //
1226 switch (IfrOpHdr->OpCode) {
1227 case EFI_IFR_VARSTORE_OP:
1228 //
1229 // VarStoreId has been found. No further found.
1230 //
1231 if (VarStoreData.VarStoreId != 0) {
1232 break;
1233 }
1234
1235 //
1236 // Find the matched VarStoreId to the input VarGuid and VarName
1237 //
1238 IfrVarStore = (EFI_IFR_VARSTORE *)IfrOpHdr;
1239 if (CompareGuid ((EFI_GUID *)(VOID *)&IfrVarStore->Guid, VarGuid)) {
1240 VarStoreName = (CHAR8 *)IfrVarStore->Name;
1241 for (Index = 0; VarStoreName[Index] != 0; Index++) {
1242 if ((CHAR16)VarStoreName[Index] != VarName[Index]) {
1243 break;
1244 }
1245 }
1246
1247 //
1248 // The matched VarStore is found.
1249 //
1250 if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) {
1251 IfrVarStore = NULL;
1252 }
1253 } else {
1254 IfrVarStore = NULL;
1255 }
1256
1257 if (IfrVarStore != NULL) {
1258 VarStoreData.VarStoreId = IfrVarStore->VarStoreId;
1259 VarStoreData.Size = IfrVarStore->Size;
1260 }
1261
1262 break;
1263 case EFI_IFR_VARSTORE_NAME_VALUE_OP:
1264 //
1265 // VarStoreId has been found. No further found.
1266 //
1267 if (VarStoreData.VarStoreId != 0) {
1268 break;
1269 }
1270
1271 //
1272 // Find the matched VarStoreId to the input VarGuid
1273 //
1274 IfrNameValueStore = (EFI_IFR_VARSTORE_NAME_VALUE *)IfrOpHdr;
1275 if (!CompareGuid ((EFI_GUID *)(VOID *)&IfrNameValueStore->Guid, VarGuid)) {
1276 IfrNameValueStore = NULL;
1277 }
1278
1279 if (IfrNameValueStore != NULL) {
1280 VarStoreData.VarStoreId = IfrNameValueStore->VarStoreId;
1281 }
1282
1283 break;
1284 case EFI_IFR_VARSTORE_EFI_OP:
1285 //
1286 // VarStore is found. Don't need to search any more.
1287 //
1288 if (VarStoreData.VarStoreId != 0) {
1289 break;
1290 }
1291
1292 IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *)IfrOpHdr;
1293
1294 //
1295 // If the length is small than the structure, this is from old efi
1296 // varstore definition. Old efi varstore get config directly from
1297 // GetVariable function.
1298 //
1299 if (IfrOpHdr->Length < sizeof (EFI_IFR_VARSTORE_EFI)) {
1300 break;
1301 }
1302
1303 if (CompareGuid ((EFI_GUID *)(VOID *)&IfrEfiVarStore->Guid, VarGuid)) {
1304 VarStoreName = (CHAR8 *)IfrEfiVarStore->Name;
1305 for (Index = 0; VarStoreName[Index] != 0; Index++) {
1306 if ((CHAR16)VarStoreName[Index] != VarName[Index]) {
1307 break;
1308 }
1309 }
1310
1311 //
1312 // The matched VarStore is found.
1313 //
1314 if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) {
1315 IfrEfiVarStore = NULL;
1316 }
1317 } else {
1318 IfrEfiVarStore = NULL;
1319 }
1320
1321 if (IfrEfiVarStore != NULL) {
1322 //
1323 // Find the matched VarStore
1324 //
1325 VarStoreData.VarStoreId = IfrEfiVarStore->VarStoreId;
1326 VarStoreData.Size = IfrEfiVarStore->Size;
1327 }
1328
1329 break;
1330 case EFI_IFR_FORM_OP:
1331 case EFI_IFR_FORM_MAP_OP:
1332 //
1333 // Check the matched VarStoreId is found.
1334 //
1335 if (VarStoreData.VarStoreId == 0) {
1336 return EFI_SUCCESS;
1337 }
1338
1339 break;
1340 case EFI_IFR_ONE_OF_OP:
1341 //
1342 // Check whether current value is the one of option.
1343 //
1344
1345 //
1346 // OneOf question is not in IFR Form. This IFR form is not valid.
1347 //
1348 if (VarStoreData.VarStoreId == 0) {
1349 return EFI_INVALID_PARAMETER;
1350 }
1351
1352 //
1353 // Check whether this question is for the requested varstore.
1354 //
1355 IfrOneOf = (EFI_IFR_ONE_OF *)IfrOpHdr;
1356 if (IfrOneOf->Question.VarStoreId != VarStoreData.VarStoreId) {
1357 break;
1358 }
1359
1360 if (NameValueType) {
1361 QuestionName = HiiGetString (HiiHandle, IfrOneOf->Question.VarStoreInfo.VarName, NULL);
1362 ASSERT (QuestionName != NULL);
1363
1364 if (StrStr (RequestElement, QuestionName) == NULL) {
1365 //
1366 // This question is not in the current configuration string. Skip it.
1367 //
1368 break;
1369 }
1370
1371 Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
1372 if (EFI_ERROR (Status)) {
1373 return Status;
1374 }
1375 } else {
1376 //
1377 // Get Offset by Question header and Width by DataType Flags
1378 //
1379 if (QuestionReferBitField) {
1380 //
1381 // Get the byte offset/width for bit field.
1382 //
1383 BitOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
1384 BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
1385 Offset = BitOffset / 8;
1386 TotalBits = BitOffset % 8 + BitWidth;
1387 Width = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
1388 } else {
1389 Offset = IfrOneOf->Question.VarStoreInfo.VarOffset;
1390 Width = (UINT16)(1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
1391 }
1392
1393 //
1394 // Check whether this question is in current block array.
1395 //
1396 if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
1397 //
1398 // This question is not in the current configuration string. Skip it.
1399 //
1400 break;
1401 }
1402
1403 //
1404 // Check this var question is in the var storage
1405 //
1406 if ((Offset + Width) > VarStoreData.Size) {
1407 //
1408 // This question exceeds the var store size.
1409 //
1410 return EFI_INVALID_PARAMETER;
1411 }
1412
1413 //
1414 // Get the current value for oneof opcode
1415 //
1416 VarValue = 0;
1417 if (QuestionReferBitField) {
1418 //
1419 // Get the value in bit fields.
1420 //
1421 StartBit = BitOffset % 8;
1422 EndBit = StartBit + BitWidth - 1;
1423 CopyMem ((UINT8 *)&BufferValue, VarBuffer + Offset, Width);
1424 VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
1425 } else {
1426 CopyMem (&VarValue, VarBuffer + Offset, Width);
1427 }
1428 }
1429
1430 //
1431 // Set Block Data, to be checked in the following Oneof option opcode.
1432 //
1433 VarBlockData.OpCode = IfrOpHdr->OpCode;
1434 VarBlockData.Scope = IfrOpHdr->Scope;
1435 break;
1436 case EFI_IFR_NUMERIC_OP:
1437 //
1438 // Check the current value is in the numeric range.
1439 //
1440
1441 //
1442 // Numeric question is not in IFR Form. This IFR form is not valid.
1443 //
1444 if (VarStoreData.VarStoreId == 0) {
1445 return EFI_INVALID_PARAMETER;
1446 }
1447
1448 //
1449 // Check whether this question is for the requested varstore.
1450 //
1451 IfrNumeric = (EFI_IFR_NUMERIC *)IfrOpHdr;
1452 if (IfrNumeric->Question.VarStoreId != VarStoreData.VarStoreId) {
1453 break;
1454 }
1455
1456 if (NameValueType) {
1457 QuestionName = HiiGetString (HiiHandle, IfrNumeric->Question.VarStoreInfo.VarName, NULL);
1458 ASSERT (QuestionName != NULL);
1459
1460 if (StrStr (RequestElement, QuestionName) == NULL) {
1461 //
1462 // This question is not in the current configuration string. Skip it.
1463 //
1464 break;
1465 }
1466
1467 Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
1468 if (EFI_ERROR (Status)) {
1469 return Status;
1470 }
1471 } else {
1472 //
1473 // Get Offset by Question header and Width by DataType Flags
1474 //
1475 if (QuestionReferBitField) {
1476 //
1477 // Get the byte offset/width for bit field.
1478 //
1479 BitOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
1480 BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
1481 Offset = BitOffset / 8;
1482 TotalBits = BitOffset % 8 + BitWidth;
1483 Width = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
1484 } else {
1485 Offset = IfrNumeric->Question.VarStoreInfo.VarOffset;
1486 Width = (UINT16)(1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
1487 }
1488
1489 //
1490 // Check whether this question is in current block array.
1491 //
1492 if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
1493 //
1494 // This question is not in the current configuration string. Skip it.
1495 //
1496 break;
1497 }
1498
1499 //
1500 // Check this var question is in the var storage
1501 //
1502 if ((Offset + Width) > VarStoreData.Size) {
1503 //
1504 // This question exceeds the var store size.
1505 //
1506 return EFI_INVALID_PARAMETER;
1507 }
1508
1509 //
1510 // Check the current value is in the numeric range.
1511 //
1512 VarValue = 0;
1513 if (QuestionReferBitField) {
1514 //
1515 // Get the value in the bit fields.
1516 //
1517 StartBit = BitOffset % 8;
1518 EndBit = StartBit + BitWidth - 1;
1519 CopyMem ((UINT8 *)&BufferValue, VarBuffer + Offset, Width);
1520 VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
1521 } else {
1522 CopyMem (&VarValue, VarBuffer + Offset, Width);
1523 }
1524 }
1525
1526 if ( QuestionReferBitField) {
1527 //
1528 // Value in bit fields was stored as UINt32 type.
1529 //
1530 if ((IfrNumeric->Flags & EDKII_IFR_DISPLAY_BIT) == 0) {
1531 if (((INT32)VarValue < (INT32)IfrNumeric->data.u32.MinValue) || ((INT32)VarValue > (INT32)IfrNumeric->data.u32.MaxValue)) {
1532 //
1533 // Not in the valid range.
1534 //
1535 return EFI_INVALID_PARAMETER;
1536 }
1537 } else {
1538 if ((VarValue < IfrNumeric->data.u32.MinValue) || (VarValue > IfrNumeric->data.u32.MaxValue)) {
1539 //
1540 // Not in the valid range.
1541 //
1542 return EFI_INVALID_PARAMETER;
1543 }
1544 }
1545 } else {
1546 if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) == 0) {
1547 switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
1548 case EFI_IFR_NUMERIC_SIZE_1:
1549 if (((INT8)VarValue < (INT8)IfrNumeric->data.u8.MinValue) || ((INT8)VarValue > (INT8)IfrNumeric->data.u8.MaxValue)) {
1550 //
1551 // Not in the valid range.
1552 //
1553 return EFI_INVALID_PARAMETER;
1554 }
1555
1556 break;
1557 case EFI_IFR_NUMERIC_SIZE_2:
1558 if (((INT16)VarValue < (INT16)IfrNumeric->data.u16.MinValue) || ((INT16)VarValue > (INT16)IfrNumeric->data.u16.MaxValue)) {
1559 //
1560 // Not in the valid range.
1561 //
1562 return EFI_INVALID_PARAMETER;
1563 }
1564
1565 break;
1566 case EFI_IFR_NUMERIC_SIZE_4:
1567 if (((INT32)VarValue < (INT32)IfrNumeric->data.u32.MinValue) || ((INT32)VarValue > (INT32)IfrNumeric->data.u32.MaxValue)) {
1568 //
1569 // Not in the valid range.
1570 //
1571 return EFI_INVALID_PARAMETER;
1572 }
1573
1574 break;
1575 case EFI_IFR_NUMERIC_SIZE_8:
1576 if (((INT64)VarValue < (INT64)IfrNumeric->data.u64.MinValue) || ((INT64)VarValue > (INT64)IfrNumeric->data.u64.MaxValue)) {
1577 //
1578 // Not in the valid range.
1579 //
1580 return EFI_INVALID_PARAMETER;
1581 }
1582
1583 break;
1584 }
1585 } else {
1586 switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
1587 case EFI_IFR_NUMERIC_SIZE_1:
1588 if (((UINT8)VarValue < IfrNumeric->data.u8.MinValue) || ((UINT8)VarValue > IfrNumeric->data.u8.MaxValue)) {
1589 //
1590 // Not in the valid range.
1591 //
1592 return EFI_INVALID_PARAMETER;
1593 }
1594
1595 break;
1596 case EFI_IFR_NUMERIC_SIZE_2:
1597 if (((UINT16)VarValue < IfrNumeric->data.u16.MinValue) || ((UINT16)VarValue > IfrNumeric->data.u16.MaxValue)) {
1598 //
1599 // Not in the valid range.
1600 //
1601 return EFI_INVALID_PARAMETER;
1602 }
1603
1604 break;
1605 case EFI_IFR_NUMERIC_SIZE_4:
1606 if (((UINT32)VarValue < IfrNumeric->data.u32.MinValue) || ((UINT32)VarValue > IfrNumeric->data.u32.MaxValue)) {
1607 //
1608 // Not in the valid range.
1609 //
1610 return EFI_INVALID_PARAMETER;
1611 }
1612
1613 break;
1614 case EFI_IFR_NUMERIC_SIZE_8:
1615 if (((UINT64)VarValue < IfrNumeric->data.u64.MinValue) || ((UINT64)VarValue > IfrNumeric->data.u64.MaxValue)) {
1616 //
1617 // Not in the valid range.
1618 //
1619 return EFI_INVALID_PARAMETER;
1620 }
1621
1622 break;
1623 }
1624 }
1625 }
1626
1627 break;
1628 case EFI_IFR_CHECKBOX_OP:
1629 //
1630 // Check value is BOOLEAN type, only 0 and 1 is valid.
1631 //
1632
1633 //
1634 // CheckBox question is not in IFR Form. This IFR form is not valid.
1635 //
1636 if (VarStoreData.VarStoreId == 0) {
1637 return EFI_INVALID_PARAMETER;
1638 }
1639
1640 //
1641 // Check whether this question is for the requested varstore.
1642 //
1643 IfrCheckBox = (EFI_IFR_CHECKBOX *)IfrOpHdr;
1644 if (IfrCheckBox->Question.VarStoreId != VarStoreData.VarStoreId) {
1645 break;
1646 }
1647
1648 if (NameValueType) {
1649 QuestionName = HiiGetString (HiiHandle, IfrCheckBox->Question.VarStoreInfo.VarName, NULL);
1650 ASSERT (QuestionName != NULL);
1651
1652 if (StrStr (RequestElement, QuestionName) == NULL) {
1653 //
1654 // This question is not in the current configuration string. Skip it.
1655 //
1656 break;
1657 }
1658
1659 Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
1660 if (EFI_ERROR (Status)) {
1661 return Status;
1662 }
1663 } else {
1664 //
1665 // Get Offset by Question header
1666 //
1667 if (QuestionReferBitField) {
1668 //
1669 // Get the byte offset/width for bit field.
1670 //
1671 BitOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
1672 BitWidth = 1;
1673 Offset = BitOffset / 8;
1674 TotalBits = BitOffset % 8 + BitWidth;
1675 Width = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
1676 } else {
1677 Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
1678 Width = (UINT16)sizeof (BOOLEAN);
1679 }
1680
1681 //
1682 // Check whether this question is in current block array.
1683 //
1684 if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
1685 //
1686 // This question is not in the current configuration string. Skip it.
1687 //
1688 break;
1689 }
1690
1691 //
1692 // Check this var question is in the var storage
1693 //
1694 if ((Offset + Width) > VarStoreData.Size) {
1695 //
1696 // This question exceeds the var store size.
1697 //
1698 return EFI_INVALID_PARAMETER;
1699 }
1700
1701 //
1702 // Check the current value is in the numeric range.
1703 //
1704 VarValue = 0;
1705 if (QuestionReferBitField) {
1706 //
1707 // Get the value in bit fields.
1708 //
1709 StartBit = BitOffset % 8;
1710 EndBit = StartBit + BitWidth - 1;
1711 CopyMem ((UINT8 *)&BufferValue, VarBuffer + Offset, Width);
1712 VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
1713 } else {
1714 CopyMem (&VarValue, VarBuffer + Offset, Width);
1715 }
1716 }
1717
1718 //
1719 // Boolean type, only 1 and 0 is valid.
1720 //
1721 if (VarValue > 1) {
1722 return EFI_INVALID_PARAMETER;
1723 }
1724
1725 break;
1726 case EFI_IFR_STRING_OP:
1727 //
1728 // Check current string length is less than maxsize
1729 //
1730
1731 //
1732 // CheckBox question is not in IFR Form. This IFR form is not valid.
1733 //
1734 if (VarStoreData.VarStoreId == 0) {
1735 return EFI_INVALID_PARAMETER;
1736 }
1737
1738 //
1739 // Check whether this question is for the requested varstore.
1740 //
1741 IfrString = (EFI_IFR_STRING *)IfrOpHdr;
1742 if (IfrString->Question.VarStoreId != VarStoreData.VarStoreId) {
1743 break;
1744 }
1745
1746 //
1747 // Get the Max size of the string.
1748 //
1749 Width = (UINT16)(IfrString->MaxSize * sizeof (UINT16));
1750 if (NameValueType) {
1751 QuestionName = HiiGetString (HiiHandle, IfrString->Question.VarStoreInfo.VarName, NULL);
1752 ASSERT (QuestionName != NULL);
1753
1754 StringPtr = StrStr (RequestElement, QuestionName);
1755 if (StringPtr == NULL) {
1756 //
1757 // This question is not in the current configuration string. Skip it.
1758 //
1759 break;
1760 }
1761
1762 //
1763 // Skip the VarName.
1764 //
1765 StringPtr += StrLen (QuestionName);
1766
1767 //
1768 // Skip the "=".
1769 //
1770 StringPtr += 1;
1771
1772 //
1773 // Check current string length is less than maxsize
1774 // e.g Config String: "0041004200430044", Unicode String: "ABCD". Unicode String length = Config String length / 4.
1775 // Config string format in UEFI spec.
1776 // <NvConfig> ::= <Label>'='<String>
1777 // <String> ::= [<Char>]+
1778 // <Char> ::= <HexCh>4
1779 //
1780 if (StrLen (StringPtr) / 4 > IfrString->MaxSize) {
1781 return EFI_INVALID_PARAMETER;
1782 }
1783 } else {
1784 //
1785 // Get Offset/Width by Question header and OneOf Flags
1786 //
1787 Offset = IfrString->Question.VarStoreInfo.VarOffset;
1788 //
1789 // Check whether this question is in current block array.
1790 //
1791 if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
1792 //
1793 // This question is not in the current configuration string. Skip it.
1794 //
1795 break;
1796 }
1797
1798 //
1799 // Check this var question is in the var storage
1800 //
1801 if ((Offset + Width) > VarStoreData.Size) {
1802 //
1803 // This question exceeds the var store size.
1804 //
1805 return EFI_INVALID_PARAMETER;
1806 }
1807
1808 //
1809 // Check current string length is less than maxsize
1810 //
1811 if (StrLen ((CHAR16 *)(VarBuffer + Offset)) > IfrString->MaxSize) {
1812 return EFI_INVALID_PARAMETER;
1813 }
1814 }
1815
1816 break;
1817 case EFI_IFR_ONE_OF_OPTION_OP:
1818 //
1819 // Opcode Scope is zero. This one of option is not to be checked.
1820 //
1821 if (VarBlockData.Scope == 0) {
1822 break;
1823 }
1824
1825 //
1826 // Only check for OneOf and OrderList opcode
1827 //
1828 IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *)IfrOpHdr;
1829 if (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP) {
1830 //
1831 // Check current value is the value of one of option.
1832 //
1833 ASSERT (IfrOneOfOption->Type <= EFI_IFR_TYPE_NUM_SIZE_64);
1834 ZeroMem (&TmpValue, sizeof (EFI_IFR_TYPE_VALUE));
1835 CopyMem (&TmpValue, &IfrOneOfOption->Value, IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value));
1836 if (VarValue == TmpValue.u64) {
1837 //
1838 // The value is one of option value.
1839 // Set OpCode to Zero, don't need check again.
1840 //
1841 VarBlockData.OpCode = 0;
1842 }
1843 }
1844
1845 break;
1846 case EFI_IFR_END_OP:
1847 QuestionReferBitField = FALSE;
1848 //
1849 // Decrease opcode scope for the validated opcode
1850 //
1851 if (VarBlockData.Scope > 0) {
1852 VarBlockData.Scope--;
1853 }
1854
1855 //
1856 // OneOf value doesn't belong to one of option value.
1857 //
1858 if ((VarBlockData.Scope == 0) && (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP)) {
1859 return EFI_INVALID_PARAMETER;
1860 }
1861
1862 break;
1863 case EFI_IFR_GUID_OP:
1864 if (CompareGuid ((EFI_GUID *)((UINT8 *)IfrOpHdr + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) {
1865 QuestionReferBitField = TRUE;
1866 }
1867
1868 break;
1869 default:
1870 //
1871 // Increase Scope for the validated opcode
1872 //
1873 if (VarBlockData.Scope > 0) {
1874 VarBlockData.Scope = (UINT8)(VarBlockData.Scope + IfrOpHdr->Scope);
1875 }
1876
1877 break;
1878 }
1879
1880 //
1881 // Go to the next opcode
1882 //
1883 IfrOffset += IfrOpHdr->Length;
1884 }
1885
1886 //
1887 // Only one form is in a package list.
1888 //
1889 break;
1890 }
1891
1892 //
1893 // Go to next package.
1894 //
1895 PackageOffset += PackageHeader.Length;
1896 }
1897
1898 return EFI_SUCCESS;
1899}
1900
1914 IN CHAR16 *ConfigElement,
1915 OUT IFR_BLOCK_DATA **CurrentBlockArray,
1916 OUT UINT8 **VarBuffer
1917 )
1918{
1919 IFR_BLOCK_DATA *BlockData;
1920 IFR_BLOCK_DATA *NewBlockData;
1921 EFI_STRING StringPtr;
1922 UINTN Length;
1923 UINT8 *TmpBuffer;
1924 UINT16 Offset;
1925 UINT16 Width;
1926 LIST_ENTRY *Link;
1927 UINTN MaxBufferSize;
1928 EFI_STATUS Status;
1929 IFR_BLOCK_DATA *BlockArray;
1930 UINT8 *DataBuffer;
1931
1932 //
1933 // Initialize the local variables.
1934 //
1935 Status = EFI_SUCCESS;
1936 BlockData = NULL;
1937 NewBlockData = NULL;
1938 TmpBuffer = NULL;
1939 BlockArray = NULL;
1940 MaxBufferSize = HII_LIB_DEFAULT_VARSTORE_SIZE;
1941 DataBuffer = AllocateZeroPool (MaxBufferSize);
1942 if (DataBuffer == NULL) {
1943 return EFI_OUT_OF_RESOURCES;
1944 }
1945
1946 //
1947 // Init BlockArray
1948 //
1949 BlockArray = (IFR_BLOCK_DATA *)AllocateZeroPool (sizeof (IFR_BLOCK_DATA));
1950 if (BlockArray == NULL) {
1951 Status = EFI_OUT_OF_RESOURCES;
1952 goto Done;
1953 }
1954
1955 InitializeListHead (&BlockArray->Entry);
1956
1957 StringPtr = StrStr (ConfigElement, L"&OFFSET=");
1958 ASSERT (StringPtr != NULL);
1959
1960 //
1961 // Parse each <RequestElement> if exists
1962 // Only <BlockName> format is supported by this help function.
1963 // <BlockName> ::= &'OFFSET='<Number>&'WIDTH='<Number>
1964 //
1965 while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) {
1966 //
1967 // Skip the &OFFSET= string
1968 //
1969 StringPtr += StrLen (L"&OFFSET=");
1970
1971 //
1972 // Get Offset
1973 //
1974 Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length);
1975 if (EFI_ERROR (Status)) {
1976 goto Done;
1977 }
1978
1979 Offset = 0;
1980 CopyMem (
1981 &Offset,
1982 TmpBuffer,
1983 (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16)
1984 );
1985 FreePool (TmpBuffer);
1986 TmpBuffer = NULL;
1987
1988 StringPtr += Length;
1989 if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {
1990 Status = EFI_INVALID_PARAMETER;
1991 goto Done;
1992 }
1993
1994 StringPtr += StrLen (L"&WIDTH=");
1995
1996 //
1997 // Get Width
1998 //
1999 Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length);
2000 if (EFI_ERROR (Status)) {
2001 goto Done;
2002 }
2003
2004 Width = 0;
2005 CopyMem (
2006 &Width,
2007 TmpBuffer,
2008 (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16)
2009 );
2010 FreePool (TmpBuffer);
2011 TmpBuffer = NULL;
2012
2013 StringPtr += Length;
2014 if ((*StringPtr != 0) && (*StringPtr != L'&')) {
2015 Status = EFI_INVALID_PARAMETER;
2016 goto Done;
2017 }
2018
2019 if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) {
2020 Status = EFI_INVALID_PARAMETER;
2021 goto Done;
2022 }
2023
2024 StringPtr += StrLen (L"&VALUE=");
2025
2026 //
2027 // Get Value
2028 //
2029 Status = InternalHiiGetValueOfNumber (StringPtr, &TmpBuffer, &Length);
2030 if (EFI_ERROR (Status)) {
2031 goto Done;
2032 }
2033
2034 StringPtr += Length;
2035 if ((*StringPtr != 0) && (*StringPtr != L'&')) {
2036 Status = EFI_INVALID_PARAMETER;
2037 goto Done;
2038 }
2039
2040 //
2041 // Check whether VarBuffer is enough
2042 //
2043 if ((UINT32)Offset + Width > MaxBufferSize) {
2044 DataBuffer = ReallocatePool (
2045 MaxBufferSize,
2046 Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE,
2047 DataBuffer
2048 );
2049 if (DataBuffer == NULL) {
2050 Status = EFI_OUT_OF_RESOURCES;
2051 goto Done;
2052 }
2053
2054 MaxBufferSize = Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE;
2055 }
2056
2057 //
2058 // Update the Block with configuration info
2059 //
2060 CopyMem (DataBuffer + Offset, TmpBuffer, Width);
2061 FreePool (TmpBuffer);
2062 TmpBuffer = NULL;
2063
2064 //
2065 // Set new Block Data
2066 //
2067 NewBlockData = (IFR_BLOCK_DATA *)AllocateZeroPool (sizeof (IFR_BLOCK_DATA));
2068 if (NewBlockData == NULL) {
2069 Status = EFI_OUT_OF_RESOURCES;
2070 goto Done;
2071 }
2072
2073 NewBlockData->Offset = Offset;
2074 NewBlockData->Width = Width;
2075
2076 //
2077 // Insert the new block data into the block data array.
2078 //
2079 for (Link = BlockArray->Entry.ForwardLink; Link != &BlockArray->Entry; Link = Link->ForwardLink) {
2080 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
2081 if (NewBlockData->Offset == BlockData->Offset) {
2082 if (NewBlockData->Width > BlockData->Width) {
2083 BlockData->Width = NewBlockData->Width;
2084 }
2085
2086 FreePool (NewBlockData);
2087 break;
2088 } else if (NewBlockData->Offset < BlockData->Offset) {
2089 //
2090 // Insert new block data as the previous one of this link.
2091 //
2092 InsertTailList (Link, &NewBlockData->Entry);
2093 break;
2094 }
2095 }
2096
2097 //
2098 // Insert new block data into the array tail.
2099 //
2100 if (Link == &BlockArray->Entry) {
2101 InsertTailList (Link, &NewBlockData->Entry);
2102 }
2103
2104 //
2105 // If '\0', parsing is finished.
2106 //
2107 if (*StringPtr == 0) {
2108 break;
2109 }
2110
2111 //
2112 // Go to next ConfigBlock
2113 //
2114 }
2115
2116 //
2117 // Merge the aligned block data into the single block data.
2118 //
2119 Link = BlockArray->Entry.ForwardLink;
2120 while ((Link != &BlockArray->Entry) && (Link->ForwardLink != &BlockArray->Entry)) {
2121 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
2122 NewBlockData = BASE_CR (Link->ForwardLink, IFR_BLOCK_DATA, Entry);
2123 if ((NewBlockData->Offset >= BlockData->Offset) && (NewBlockData->Offset <= (BlockData->Offset + BlockData->Width))) {
2124 if ((NewBlockData->Offset + NewBlockData->Width) > (BlockData->Offset + BlockData->Width)) {
2125 BlockData->Width = (UINT16)(NewBlockData->Offset + NewBlockData->Width - BlockData->Offset);
2126 }
2127
2128 RemoveEntryList (Link->ForwardLink);
2129 FreePool (NewBlockData);
2130 continue;
2131 }
2132
2133 Link = Link->ForwardLink;
2134 }
2135
2136 *VarBuffer = DataBuffer;
2137 *CurrentBlockArray = BlockArray;
2138 return EFI_SUCCESS;
2139
2140Done:
2141 if (DataBuffer != NULL) {
2142 FreePool (DataBuffer);
2143 }
2144
2145 if (BlockArray != NULL) {
2146 //
2147 // Free Link Array CurrentBlockArray
2148 //
2149 while (!IsListEmpty (&BlockArray->Entry)) {
2150 BlockData = BASE_CR (BlockArray->Entry.ForwardLink, IFR_BLOCK_DATA, Entry);
2151 RemoveEntryList (&BlockData->Entry);
2152 FreePool (BlockData);
2153 }
2154
2155 FreePool (BlockArray);
2156 }
2157
2158 return Status;
2159}
2160
2176EFIAPI
2178 IN EFI_STRING ConfigResp,
2179 IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
2180 IN UINTN PackageListLength,
2181 IN EFI_GUID *VarGuid,
2182 IN CHAR16 *VarName,
2183 IN EFI_HII_HANDLE HiiHandle
2184 )
2185{
2186 CHAR16 *StringPtr;
2187 EFI_STATUS Status;
2188 IFR_BLOCK_DATA *CurrentBlockArray;
2189 IFR_BLOCK_DATA *BlockData;
2190 UINT8 *VarBuffer;
2191 BOOLEAN NameValueType;
2192
2193 CurrentBlockArray = NULL;
2194 VarBuffer = NULL;
2195 StringPtr = NULL;
2196 Status = EFI_SUCCESS;
2197
2198 //
2199 // If StringPtr != NULL, get the request elements.
2200 //
2201 if (StrStr (ConfigResp, L"&OFFSET=") != NULL) {
2202 Status = GetBlockDataInfo (ConfigResp, &CurrentBlockArray, &VarBuffer);
2203 if (EFI_ERROR (Status)) {
2204 return Status;
2205 }
2206
2207 NameValueType = FALSE;
2208 } else {
2209 //
2210 // Skip header part.
2211 //
2212 StringPtr = StrStr (ConfigResp, L"PATH=");
2213 ASSERT (StringPtr != NULL);
2214
2215 if (StrStr (StringPtr, L"&") != NULL) {
2216 NameValueType = TRUE;
2217 } else {
2218 //
2219 // Not found Request element, return success.
2220 //
2221 return EFI_SUCCESS;
2222 }
2223 }
2224
2225 Status = ValidateQuestionFromVfr (
2226 HiiPackageList,
2227 PackageListLength,
2228 VarGuid,
2229 VarName,
2230 VarBuffer,
2231 CurrentBlockArray,
2232 ConfigResp,
2233 HiiHandle,
2234 NameValueType
2235 );
2236
2237 if (VarBuffer != NULL) {
2238 FreePool (VarBuffer);
2239 }
2240
2241 if (CurrentBlockArray != NULL) {
2242 //
2243 // Free Link Array CurrentBlockArray
2244 //
2245 while (!IsListEmpty (&CurrentBlockArray->Entry)) {
2246 BlockData = BASE_CR (CurrentBlockArray->Entry.ForwardLink, IFR_BLOCK_DATA, Entry);
2247 RemoveEntryList (&BlockData->Entry);
2248 FreePool (BlockData);
2249 }
2250
2251 FreePool (CurrentBlockArray);
2252 }
2253
2254 return Status;
2255}
2256
2268BOOLEAN
2270 IN EFI_STRING ConfigRequest
2271 )
2272{
2273 EFI_STRING TmpRequest;
2274
2275 TmpRequest = StrStr (ConfigRequest, L"PATH=");
2276 ASSERT (TmpRequest != NULL);
2277
2278 if ((StrStr (TmpRequest, L"&OFFSET=") != NULL) || (StrStr (TmpRequest, L"&") != NULL)) {
2279 return TRUE;
2280 }
2281
2282 return FALSE;
2283}
2284
2309BOOLEAN
2310EFIAPI
2312 IN CONST EFI_STRING Request OPTIONAL,
2313 IN UINT16 DefaultId,
2314 IN UINT8 ActionType
2315 )
2316{
2317 EFI_STRING ConfigAltResp;
2318 EFI_STRING ConfigAltHdr;
2319 EFI_STRING ConfigResp;
2320 EFI_STRING Progress;
2321 EFI_STRING StringPtr;
2322 EFI_STRING StringHdr;
2323 EFI_STATUS Status;
2324 EFI_HANDLE DriverHandle;
2325 EFI_HANDLE TempDriverHandle;
2326 EFI_HII_HANDLE *HiiHandleBuffer;
2327 EFI_HII_HANDLE HiiHandle;
2328 UINT32 Index;
2329 EFI_GUID *VarGuid;
2330 EFI_STRING VarName;
2331
2332 EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
2333 UINTN PackageListLength;
2334 UINTN MaxLen;
2335 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
2336 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
2337
2338 ConfigAltResp = NULL;
2339 ConfigResp = NULL;
2340 VarGuid = NULL;
2341 VarName = NULL;
2342 DevicePath = NULL;
2343 ConfigAltHdr = NULL;
2344 HiiHandleBuffer = NULL;
2345 Index = 0;
2346 TempDriverHandle = NULL;
2347 HiiHandle = NULL;
2348 HiiPackageList = NULL;
2349
2350 //
2351 // Only support set default and validate setting action.
2352 //
2353 if ((ActionType != ACTION_SET_DEFAUTL_VALUE) && (ActionType != ACTION_VALIDATE_SETTING)) {
2354 return FALSE;
2355 }
2356
2357 //
2358 // Get the full requested value and deault value string.
2359 //
2360 if (Request != NULL) {
2361 Status = gHiiConfigRouting->ExtractConfig (
2363 Request,
2364 &Progress,
2365 &ConfigAltResp
2366 );
2367 } else {
2368 Status = gHiiConfigRouting->ExportConfig (
2370 &ConfigAltResp
2371 );
2372 }
2373
2374 if (EFI_ERROR (Status)) {
2375 return FALSE;
2376 }
2377
2378 StringPtr = ConfigAltResp;
2379 ASSERT (StringPtr != NULL);
2380
2381 while (*StringPtr != L'\0') {
2382 //
2383 // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
2384 //
2385 StringHdr = StringPtr;
2386
2387 //
2388 // Get Guid value
2389 //
2390 if (StrnCmp (StringPtr, L"GUID=", StrLen (L"GUID=")) != 0) {
2391 Status = EFI_INVALID_PARAMETER;
2392 goto Done;
2393 }
2394
2395 StringPtr += StrLen (L"GUID=");
2396 Status = InternalHiiGetBufferFromString (StringPtr, GUID_CONFIG_STRING_TYPE, (UINT8 **)&VarGuid);
2397 if (EFI_ERROR (Status)) {
2398 goto Done;
2399 }
2400
2401 //
2402 // Get Name value VarName
2403 //
2404 while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&NAME=", StrLen (L"&NAME=")) != 0) {
2405 StringPtr++;
2406 }
2407
2408 if (*StringPtr == L'\0') {
2409 Status = EFI_INVALID_PARAMETER;
2410 goto Done;
2411 }
2412
2413 StringPtr += StrLen (L"&NAME=");
2414 Status = InternalHiiGetBufferFromString (StringPtr, NAME_CONFIG_STRING_TYPE, (UINT8 **)&VarName);
2415 if (EFI_ERROR (Status)) {
2416 goto Done;
2417 }
2418
2419 //
2420 // Get Path value DevicePath
2421 //
2422 while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&PATH=", StrLen (L"&PATH=")) != 0) {
2423 StringPtr++;
2424 }
2425
2426 if (*StringPtr == L'\0') {
2427 Status = EFI_INVALID_PARAMETER;
2428 goto Done;
2429 }
2430
2431 StringPtr += StrLen (L"&PATH=");
2432 Status = InternalHiiGetBufferFromString (StringPtr, PATH_CONFIG_STRING_TYPE, (UINT8 **)&DevicePath);
2433 if (EFI_ERROR (Status)) {
2434 goto Done;
2435 }
2436
2437 //
2438 // Get the Driver handle by the got device path.
2439 //
2440 TempDevicePath = DevicePath;
2441 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &TempDevicePath, &DriverHandle);
2442 if (EFI_ERROR (Status)) {
2443 goto Done;
2444 }
2445
2446 //
2447 // Find the matched Hii Handle for the found Driver handle
2448 //
2449 HiiHandleBuffer = HiiGetHiiHandles (NULL);
2450 if (HiiHandleBuffer == NULL) {
2451 Status = EFI_NOT_FOUND;
2452 goto Done;
2453 }
2454
2455 for (Index = 0; HiiHandleBuffer[Index] != NULL; Index++) {
2456 gHiiDatabase->GetPackageListHandle (gHiiDatabase, HiiHandleBuffer[Index], &TempDriverHandle);
2457 if (TempDriverHandle == DriverHandle) {
2458 break;
2459 }
2460 }
2461
2462 HiiHandle = HiiHandleBuffer[Index];
2463 FreePool (HiiHandleBuffer);
2464
2465 if (HiiHandle == NULL) {
2466 //
2467 // This request string has no its Hii package.
2468 // Its default value and validating can't execute by parsing IFR data.
2469 // Directly jump into the next ConfigAltResp string for another pair Guid, Name, and Path.
2470 //
2471 Status = EFI_SUCCESS;
2472 goto NextConfigAltResp;
2473 }
2474
2475 //
2476 // 2. Get HiiPackage by HiiHandle
2477 //
2478 PackageListLength = 0;
2479 HiiPackageList = NULL;
2480 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &PackageListLength, HiiPackageList);
2481
2482 //
2483 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
2484 //
2485 if (Status != EFI_BUFFER_TOO_SMALL) {
2486 Status = EFI_INVALID_PARAMETER;
2487 goto Done;
2488 }
2489
2490 HiiPackageList = AllocatePool (PackageListLength);
2491 if (HiiPackageList == NULL) {
2492 Status = EFI_OUT_OF_RESOURCES;
2493 goto Done;
2494 }
2495
2496 //
2497 // Get PackageList on HiiHandle
2498 //
2499 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &PackageListLength, HiiPackageList);
2500 if (EFI_ERROR (Status)) {
2501 goto Done;
2502 }
2503
2504 //
2505 // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
2506 // Get the default configuration string according to the default ID.
2507 //
2508 Status = gHiiConfigRouting->GetAltConfig (
2510 ConfigAltResp,
2511 VarGuid,
2512 VarName,
2513 DevicePath,
2514 (ActionType == ACTION_SET_DEFAUTL_VALUE) ? &DefaultId : NULL, // it can be NULL to get the current setting.
2515 &ConfigResp
2516 );
2517
2518 //
2519 // The required setting can't be found. So, it is not required to be validated and set.
2520 //
2521 if (EFI_ERROR (Status)) {
2522 Status = EFI_SUCCESS;
2523 goto NextConfigAltResp;
2524 }
2525
2526 //
2527 // Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set.
2528 //
2529 if (!GetElementsFromRequest (ConfigResp)) {
2530 goto NextConfigAltResp;
2531 }
2532
2533 //
2534 // 4. Set the default configuration information or Validate current setting by parse IFR code.
2535 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2536 //
2537 if (ActionType == ACTION_SET_DEFAUTL_VALUE) {
2538 //
2539 // Set the default configuration information.
2540 //
2541 Status = gHiiConfigRouting->RouteConfig (gHiiConfigRouting, ConfigResp, &Progress);
2542 } else {
2543 //
2544 // Current Setting is in ConfigResp, will be set into buffer, then check it again.
2545 //
2546 Status = InternalHiiValidateCurrentSetting (ConfigResp, HiiPackageList, PackageListLength, VarGuid, VarName, HiiHandle);
2547 }
2548
2549 if (EFI_ERROR (Status)) {
2550 goto Done;
2551 }
2552
2553NextConfigAltResp:
2554 //
2555 // Free the allocated pacakge buffer and the got ConfigResp string.
2556 //
2557 if (HiiPackageList != NULL) {
2558 FreePool (HiiPackageList);
2559 HiiPackageList = NULL;
2560 }
2561
2562 if (ConfigResp != NULL) {
2563 FreePool (ConfigResp);
2564 ConfigResp = NULL;
2565 }
2566
2567 //
2568 // Free the allocated buffer.
2569 //
2570 FreePool (VarGuid);
2571 VarGuid = NULL;
2572
2573 FreePool (VarName);
2574 VarName = NULL;
2575
2576 FreePool (DevicePath);
2577 DevicePath = NULL;
2578
2579 //
2580 // 5. Jump to next ConfigAltResp for another Guid, Name, Path.
2581 //
2582
2583 //
2584 // Get and Skip ConfigHdr
2585 //
2586 while (*StringPtr != L'\0' && *StringPtr != L'&') {
2587 StringPtr++;
2588 }
2589
2590 if (*StringPtr == L'\0') {
2591 break;
2592 }
2593
2594 //
2595 // Construct ConfigAltHdr string "&<ConfigHdr>&ALTCFG=\0"
2596 // | 1 | StrLen (ConfigHdr) | 8 | 1 |
2597 //
2598 MaxLen = 1 + StringPtr - StringHdr + 8 + 1;
2599 ConfigAltHdr = AllocateZeroPool (MaxLen * sizeof (CHAR16));
2600 if (ConfigAltHdr == NULL) {
2601 Status = EFI_OUT_OF_RESOURCES;
2602 goto Done;
2603 }
2604
2605 StrCpyS (ConfigAltHdr, MaxLen, L"&");
2606 StrnCatS (ConfigAltHdr, MaxLen, StringHdr, StringPtr - StringHdr);
2607 StrCatS (ConfigAltHdr, MaxLen, L"&ALTCFG=");
2608
2609 //
2610 // Skip all AltResp (AltConfigHdr ConfigBody) for the same ConfigHdr
2611 //
2612 while ((StringHdr = StrStr (StringPtr, ConfigAltHdr)) != NULL) {
2613 StringPtr = StringHdr + StrLen (ConfigAltHdr);
2614 if (*StringPtr == L'\0') {
2615 break;
2616 }
2617 }
2618
2619 //
2620 // Free the allocated ConfigAltHdr string
2621 //
2622 FreePool (ConfigAltHdr);
2623 if (*StringPtr == L'\0') {
2624 break;
2625 }
2626
2627 //
2628 // Find &GUID as the next ConfigHdr
2629 //
2630 StringPtr = StrStr (StringPtr, L"&GUID");
2631 if (StringPtr == NULL) {
2632 break;
2633 }
2634
2635 //
2636 // Skip char '&'
2637 //
2638 StringPtr++;
2639 }
2640
2641Done:
2642 if (VarGuid != NULL) {
2643 FreePool (VarGuid);
2644 }
2645
2646 if (VarName != NULL) {
2647 FreePool (VarName);
2648 }
2649
2650 if (DevicePath != NULL) {
2651 FreePool (DevicePath);
2652 }
2653
2654 if (ConfigResp != NULL) {
2655 FreePool (ConfigResp);
2656 }
2657
2658 if (ConfigAltResp != NULL) {
2659 FreePool (ConfigAltResp);
2660 }
2661
2662 if (HiiPackageList != NULL) {
2663 FreePool (HiiPackageList);
2664 }
2665
2666 if (EFI_ERROR (Status)) {
2667 return FALSE;
2668 }
2669
2670 return TRUE;
2671}
2672
2687BOOLEAN
2688EFIAPI
2690 IN CONST EFI_STRING Request OPTIONAL
2691 )
2692{
2693 return InternalHiiIfrValueAction (Request, 0, ACTION_VALIDATE_SETTING);
2694}
2695
2712BOOLEAN
2713EFIAPI
2715 IN CONST EFI_STRING Request OPTIONAL,
2716 IN UINT16 DefaultId
2717 )
2718{
2719 return InternalHiiIfrValueAction (Request, DefaultId, ACTION_SET_DEFAUTL_VALUE);
2720}
2721
2754BOOLEAN
2755EFIAPI
2757 IN CHAR16 *FirstString,
2758 IN CHAR16 *SecondString,
2759 IN CHAR16 *StartSearchString,
2760 IN CHAR16 *StopSearchString
2761 )
2762{
2763 CHAR16 *EndFirstString;
2764 CHAR16 *EndSecondString;
2765
2766 ASSERT (FirstString != NULL);
2767 ASSERT (SecondString != NULL);
2768 ASSERT (StartSearchString != NULL);
2769 ASSERT (StopSearchString != NULL);
2770
2771 FirstString = StrStr (FirstString, StartSearchString);
2772 if (FirstString == NULL) {
2773 return FALSE;
2774 }
2775
2776 SecondString = StrStr (SecondString, StartSearchString);
2777 if (SecondString == NULL) {
2778 return FALSE;
2779 }
2780
2781 EndFirstString = StrStr (FirstString, StopSearchString);
2782 if (EndFirstString == NULL) {
2783 return FALSE;
2784 }
2785
2786 EndSecondString = StrStr (SecondString, StopSearchString);
2787 if (EndSecondString == NULL) {
2788 return FALSE;
2789 }
2790
2791 if ((EndFirstString - FirstString) != (EndSecondString - SecondString)) {
2792 return FALSE;
2793 }
2794
2795 return (BOOLEAN)(StrnCmp (FirstString, SecondString, EndFirstString - FirstString) == 0);
2796}
2797
2811BOOLEAN
2812EFIAPI
2814 IN CONST EFI_STRING ConfigHdr,
2815 IN CONST EFI_GUID *Guid OPTIONAL,
2816 IN CONST CHAR16 *Name OPTIONAL
2817 )
2818{
2819 EFI_STRING CompareConfigHdr;
2820 BOOLEAN Result;
2821
2822 ASSERT (ConfigHdr != NULL);
2823
2824 //
2825 // Use Guid and Name to generate a <ConfigHdr> string
2826 //
2827 CompareConfigHdr = HiiConstructConfigHdr (Guid, Name, NULL);
2828 if (CompareConfigHdr == NULL) {
2829 return FALSE;
2830 }
2831
2832 Result = TRUE;
2833 if (Guid != NULL) {
2834 //
2835 // Compare GUID value strings
2836 //
2837 Result = InternalHiiCompareSubString (ConfigHdr, CompareConfigHdr, L"GUID=", L"&NAME=");
2838 }
2839
2840 if (Result && (Name != NULL)) {
2841 //
2842 // Compare NAME value strings
2843 //
2844 Result = InternalHiiCompareSubString (ConfigHdr, CompareConfigHdr, L"&NAME=", L"&PATH=");
2845 }
2846
2847 //
2848 // Free the <ConfigHdr> string
2849 //
2850 FreePool (CompareConfigHdr);
2851
2852 return Result;
2853}
2854
2870BOOLEAN
2871EFIAPI
2873 IN CONST EFI_GUID *VariableGuid OPTIONAL,
2874 IN CONST CHAR16 *VariableName OPTIONAL,
2875 IN UINTN BufferSize,
2876 OUT UINT8 *Buffer
2877 )
2878{
2879 EFI_STRING ResultsData;
2880 UINTN Size;
2881 EFI_STRING ConfigResp;
2882 EFI_STATUS Status;
2883 CHAR16 *Progress;
2884
2885 //
2886 // Retrieve the results data from the Browser Callback
2887 //
2888 ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, NULL);
2889 if (ResultsData == NULL) {
2890 return FALSE;
2891 }
2892
2893 //
2894 // Construct <ConfigResp> mConfigHdrTemplate L'&' ResultsData L'\0'
2895 //
2896 Size = (StrLen (mConfigHdrTemplate) + 1) * sizeof (CHAR16);
2897 Size = Size + (StrLen (ResultsData) + 1) * sizeof (CHAR16);
2898 ConfigResp = AllocateZeroPool (Size);
2899 UnicodeSPrint (ConfigResp, Size, L"%s&%s", mConfigHdrTemplate, ResultsData);
2900
2901 //
2902 // Free the allocated buffer
2903 //
2904 FreePool (ResultsData);
2905 if (ConfigResp == NULL) {
2906 return FALSE;
2907 }
2908
2909 //
2910 // Convert <ConfigResp> to a buffer
2911 //
2912 Status = gHiiConfigRouting->ConfigToBlock (
2914 ConfigResp,
2915 Buffer,
2916 &BufferSize,
2917 &Progress
2918 );
2919 //
2920 // Free the allocated buffer
2921 //
2922 FreePool (ConfigResp);
2923
2924 if (EFI_ERROR (Status)) {
2925 return FALSE;
2926 }
2927
2928 return TRUE;
2929}
2930
2952BOOLEAN
2953EFIAPI
2955 IN CONST EFI_GUID *VariableGuid OPTIONAL,
2956 IN CONST CHAR16 *VariableName OPTIONAL,
2957 IN UINTN BufferSize,
2958 IN CONST UINT8 *Buffer,
2959 IN CONST CHAR16 *RequestElement OPTIONAL
2960 )
2961{
2962 UINTN Size;
2963 EFI_STRING ConfigRequest;
2964 EFI_STRING ConfigResp;
2965 EFI_STRING ResultsData;
2966
2967 ASSERT (Buffer != NULL);
2968
2969 //
2970 // Construct <ConfigRequest>
2971 //
2972 if (RequestElement == NULL) {
2973 //
2974 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2975 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
2976 //
2977 Size = (StrLen (mConfigHdrTemplate) + 32 + 1) * sizeof (CHAR16);
2978 ConfigRequest = AllocateZeroPool (Size);
2979 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", mConfigHdrTemplate, (UINT64)BufferSize);
2980 } else {
2981 //
2982 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
2983 // followed by <RequestElement> followed by a Null-terminator
2984 //
2985 Size = StrLen (mConfigHdrTemplate) * sizeof (CHAR16);
2986 Size = Size + (StrLen (RequestElement) + 1) * sizeof (CHAR16);
2987 ConfigRequest = AllocateZeroPool (Size);
2988 UnicodeSPrint (ConfigRequest, Size, L"%s%s", mConfigHdrTemplate, RequestElement);
2989 }
2990
2991 if (ConfigRequest == NULL) {
2992 return FALSE;
2993 }
2994
2995 //
2996 // Convert <ConfigRequest> to <ConfigResp>
2997 //
2998 ConfigResp = InternalHiiBlockToConfig (ConfigRequest, Buffer, BufferSize);
2999 FreePool (ConfigRequest);
3000 if (ConfigResp == NULL) {
3001 return FALSE;
3002 }
3003
3004 //
3005 // Set data in the uncommitted browser state information
3006 //
3007 ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, ConfigResp + StrLen (mConfigHdrTemplate) + 1);
3008 FreePool (ConfigResp);
3009
3010 return (BOOLEAN)(ResultsData != NULL);
3011}
3012
3018
3019#define HII_LIB_OPCODE_ALLOCATION_SIZE 0x200
3020
3021typedef struct {
3022 UINT8 *Buffer;
3023 UINTN BufferSize;
3024 UINTN Position;
3026
3031 1, // EFI_IFR_TYPE_NUM_SIZE_8
3032 2, // EFI_IFR_TYPE_NUM_SIZE_16
3033 4, // EFI_IFR_TYPE_NUM_SIZE_32
3034 8, // EFI_IFR_TYPE_NUM_SIZE_64
3035 1, // EFI_IFR_TYPE_BOOLEAN
3036 3, // EFI_IFR_TYPE_TIME
3037 4, // EFI_IFR_TYPE_DATE
3038 2 // EFI_IFR_TYPE_STRING
3039};
3040
3049VOID *
3050EFIAPI
3052 VOID
3053 )
3054{
3055 HII_LIB_OPCODE_BUFFER *OpCodeBuffer;
3056
3057 OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)AllocatePool (sizeof (HII_LIB_OPCODE_BUFFER));
3058 if (OpCodeBuffer == NULL) {
3059 return NULL;
3060 }
3061
3062 OpCodeBuffer->Buffer = (UINT8 *)AllocatePool (HII_LIB_OPCODE_ALLOCATION_SIZE);
3063 if (OpCodeBuffer->Buffer == NULL) {
3064 FreePool (OpCodeBuffer);
3065 return NULL;
3066 }
3067
3068 OpCodeBuffer->BufferSize = HII_LIB_OPCODE_ALLOCATION_SIZE;
3069 OpCodeBuffer->Position = 0;
3070 return (VOID *)OpCodeBuffer;
3071}
3072
3083VOID
3084EFIAPI
3086 VOID *OpCodeHandle
3087 )
3088{
3089 HII_LIB_OPCODE_BUFFER *OpCodeBuffer;
3090
3091 ASSERT (OpCodeHandle != NULL);
3092
3093 OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)OpCodeHandle;
3094 if (OpCodeBuffer->Buffer != NULL) {
3095 FreePool (OpCodeBuffer->Buffer);
3096 }
3097
3098 FreePool (OpCodeBuffer);
3099}
3100
3108UINTN
3109EFIAPI
3111 IN VOID *OpCodeHandle
3112 )
3113{
3114 return ((HII_LIB_OPCODE_BUFFER *)OpCodeHandle)->Position;
3115}
3116
3124UINT8 *
3125EFIAPI
3127 IN VOID *OpCodeHandle
3128 )
3129{
3130 return ((HII_LIB_OPCODE_BUFFER *)OpCodeHandle)->Buffer;
3131}
3132
3142UINT8 *
3143EFIAPI
3145 IN VOID *OpCodeHandle,
3146 IN UINTN Size
3147 )
3148{
3149 HII_LIB_OPCODE_BUFFER *OpCodeBuffer;
3150 UINT8 *Buffer;
3151
3152 ASSERT (OpCodeHandle != NULL);
3153
3154 OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)OpCodeHandle;
3155 if (OpCodeBuffer->Position + Size > OpCodeBuffer->BufferSize) {
3156 Buffer = ReallocatePool (
3157 OpCodeBuffer->BufferSize,
3158 OpCodeBuffer->BufferSize + (Size + HII_LIB_OPCODE_ALLOCATION_SIZE),
3159 OpCodeBuffer->Buffer
3160 );
3161 ASSERT (Buffer != NULL);
3162 OpCodeBuffer->Buffer = Buffer;
3163 OpCodeBuffer->BufferSize += (Size + HII_LIB_OPCODE_ALLOCATION_SIZE);
3164 }
3165
3166 Buffer = OpCodeBuffer->Buffer + OpCodeBuffer->Position;
3167 OpCodeBuffer->Position += Size;
3168 return Buffer;
3169}
3170
3183UINT8 *
3184EFIAPI
3186 IN VOID *OpCodeHandle,
3187 IN VOID *OpCodeTemplate,
3188 IN UINT8 OpCode,
3189 IN UINTN OpCodeSize,
3190 IN UINTN ExtensionSize,
3191 IN UINT8 Scope
3192 )
3193{
3194 EFI_IFR_OP_HEADER *Header;
3195 UINT8 *Buffer;
3196
3197 ASSERT (OpCodeTemplate != NULL);
3198 ASSERT ((OpCodeSize + ExtensionSize) <= 0x7F);
3199
3200 Header = (EFI_IFR_OP_HEADER *)OpCodeTemplate;
3201 Header->OpCode = OpCode;
3202 Header->Scope = Scope;
3203 Header->Length = (UINT8)(OpCodeSize + ExtensionSize);
3204 Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, Header->Length);
3205 return (UINT8 *)CopyMem (Buffer, Header, OpCodeSize);
3206}
3207
3218UINT8 *
3219EFIAPI
3221 IN VOID *OpCodeHandle,
3222 IN VOID *OpCodeTemplate,
3223 IN UINT8 OpCode,
3224 IN UINTN OpCodeSize
3225 )
3226{
3227 return InternalHiiCreateOpCodeExtended (OpCodeHandle, OpCodeTemplate, OpCode, OpCodeSize, 0, 0);
3228}
3229
3244UINT8 *
3245EFIAPI
3247 IN VOID *OpCodeHandle,
3248 IN UINT8 *RawBuffer,
3249 IN UINTN RawBufferSize
3250 )
3251{
3252 UINT8 *Buffer;
3253
3254 ASSERT (RawBuffer != NULL);
3255
3256 Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, RawBufferSize);
3257 return (UINT8 *)CopyMem (Buffer, RawBuffer, RawBufferSize);
3258}
3259
3273UINT8 *
3274EFIAPI
3276 IN VOID *OpCodeHandle,
3277 IN VOID *RawOpCodeHandle
3278 )
3279{
3280 HII_LIB_OPCODE_BUFFER *RawOpCodeBuffer;
3281
3282 ASSERT (RawOpCodeHandle != NULL);
3283
3284 RawOpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)RawOpCodeHandle;
3285 return HiiCreateRawOpCodes (OpCodeHandle, RawOpCodeBuffer->Buffer, RawOpCodeBuffer->Position);
3286}
3287
3299UINT8 *
3300EFIAPI
3302 IN VOID *OpCodeHandle
3303 )
3304{
3305 EFI_IFR_END OpCode;
3306
3307 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_END_OP, sizeof (OpCode));
3308}
3309
3327UINT8 *
3328EFIAPI
3330 IN VOID *OpCodeHandle,
3331 IN UINT16 StringId,
3332 IN UINT8 Flags,
3333 IN UINT8 Type,
3334 IN UINT64 Value
3335 )
3336{
3337 EFI_IFR_ONE_OF_OPTION OpCode;
3338
3339 ASSERT (Type < EFI_IFR_TYPE_OTHER);
3340
3341 ZeroMem (&OpCode, sizeof (OpCode));
3342 OpCode.Option = StringId;
3343 OpCode.Flags = (UINT8)(Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG));
3344 OpCode.Type = Type;
3345 CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]);
3346
3347 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OPTION_OP, OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value) + mHiiDefaultTypeToWidth[Type]);
3348}
3349
3365UINT8 *
3366EFIAPI
3368 IN VOID *OpCodeHandle,
3369 IN UINT16 DefaultId,
3370 IN UINT8 Type,
3371 IN UINT64 Value
3372 )
3373{
3374 EFI_IFR_DEFAULT OpCode;
3375
3376 ASSERT (Type < EFI_IFR_TYPE_OTHER);
3377
3378 ZeroMem (&OpCode, sizeof (OpCode));
3379 OpCode.Type = Type;
3380 OpCode.DefaultId = DefaultId;
3381 CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]);
3382
3383 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_DEFAULT_OP, OFFSET_OF (EFI_IFR_DEFAULT, Value) + mHiiDefaultTypeToWidth[Type]);
3384}
3385
3409UINT8 *
3410EFIAPI
3412 IN VOID *OpCodeHandle,
3413 IN CONST EFI_GUID *Guid,
3414 IN CONST VOID *GuidOpCode OPTIONAL,
3415 IN UINTN OpCodeSize
3416 )
3417{
3418 EFI_IFR_GUID OpCode;
3419 EFI_IFR_GUID *OpCodePointer;
3420
3421 ASSERT (Guid != NULL);
3422 ASSERT (OpCodeSize >= sizeof (OpCode));
3423
3424 ZeroMem (&OpCode, sizeof (OpCode));
3425 CopyGuid ((EFI_GUID *)(VOID *)&OpCode.Guid, Guid);
3426
3428 OpCodeHandle,
3429 &OpCode,
3430 EFI_IFR_GUID_OP,
3431 sizeof (OpCode),
3432 OpCodeSize - sizeof (OpCode),
3433 0
3434 );
3435 if ((OpCodePointer != NULL) && (GuidOpCode != NULL)) {
3436 CopyMem (OpCodePointer + 1, (EFI_IFR_GUID *)GuidOpCode + 1, OpCodeSize - sizeof (OpCode));
3437 }
3438
3439 return (UINT8 *)OpCodePointer;
3440}
3441
3459UINT8 *
3460EFIAPI
3462 IN VOID *OpCodeHandle,
3463 IN EFI_QUESTION_ID QuestionId,
3464 IN EFI_STRING_ID Prompt,
3465 IN EFI_STRING_ID Help,
3466 IN UINT8 QuestionFlags,
3467 IN EFI_STRING_ID QuestionConfig
3468 )
3469{
3470 EFI_IFR_ACTION OpCode;
3471
3472 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED))) == 0);
3473
3474 ZeroMem (&OpCode, sizeof (OpCode));
3475 OpCode.Question.QuestionId = QuestionId;
3476 OpCode.Question.Header.Prompt = Prompt;
3477 OpCode.Question.Header.Help = Help;
3478 OpCode.Question.Flags = QuestionFlags;
3479 OpCode.QuestionConfig = QuestionConfig;
3480
3481 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ACTION_OP, sizeof (OpCode));
3482}
3483
3502UINT8 *
3503EFIAPI
3505 IN VOID *OpCodeHandle,
3506 IN EFI_STRING_ID Prompt,
3507 IN EFI_STRING_ID Help,
3508 IN UINT8 Flags,
3509 IN UINT8 Scope
3510 )
3511{
3512 EFI_IFR_SUBTITLE OpCode;
3513
3514 ASSERT (Scope <= 1);
3515 ASSERT ((Flags & (~(EFI_IFR_FLAGS_HORIZONTAL))) == 0);
3516
3517 ZeroMem (&OpCode, sizeof (OpCode));
3518 OpCode.Statement.Prompt = Prompt;
3519 OpCode.Statement.Help = Help;
3520 OpCode.Flags = Flags;
3521
3523 OpCodeHandle,
3524 &OpCode,
3525 EFI_IFR_SUBTITLE_OP,
3526 sizeof (OpCode),
3527 0,
3528 Scope
3529 );
3530}
3531
3549UINT8 *
3550EFIAPI
3552 IN VOID *OpCodeHandle,
3553 IN EFI_FORM_ID FormId,
3554 IN EFI_STRING_ID Prompt,
3555 IN EFI_STRING_ID Help,
3556 IN UINT8 QuestionFlags,
3557 IN EFI_QUESTION_ID QuestionId
3558 )
3559{
3560 EFI_IFR_REF OpCode;
3561
3562 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED))) == 0);
3563
3564 ZeroMem (&OpCode, sizeof (OpCode));
3565 OpCode.Question.Header.Prompt = Prompt;
3566 OpCode.Question.Header.Help = Help;
3567 OpCode.Question.QuestionId = QuestionId;
3568 OpCode.Question.Flags = QuestionFlags;
3569 OpCode.FormId = FormId;
3570
3571 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_REF_OP, sizeof (OpCode));
3572}
3573
3603UINT8 *
3604EFIAPI
3606 IN VOID *OpCodeHandle,
3607 IN EFI_FORM_ID RefFormId,
3608 IN EFI_STRING_ID Prompt,
3609 IN EFI_STRING_ID Help,
3610 IN UINT8 QuestionFlags,
3611 IN EFI_QUESTION_ID QuestionId,
3612 IN EFI_QUESTION_ID RefQuestionId,
3613 IN EFI_GUID *RefFormSetId OPTIONAL,
3614 IN EFI_STRING_ID RefDevicePath
3615 )
3616{
3617 EFI_IFR_REF4 OpCode;
3618 UINTN OpCodeSize;
3619
3620 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED))) == 0);
3621
3622 ZeroMem (&OpCode, sizeof (OpCode));
3623 OpCode.Question.Header.Prompt = Prompt;
3624 OpCode.Question.Header.Help = Help;
3625 OpCode.Question.QuestionId = QuestionId;
3626 OpCode.Question.Flags = QuestionFlags;
3627 OpCode.FormId = RefFormId;
3628 OpCode.QuestionId = RefQuestionId;
3629 OpCode.DevicePath = RefDevicePath;
3630 if (RefFormSetId != NULL) {
3631 CopyMem (&OpCode.FormSetId, RefFormSetId, sizeof (OpCode.FormSetId));
3632 }
3633
3634 //
3635 // Cacluate OpCodeSize based on the input Ref value.
3636 // Try to use the small OpCode to save size.
3637 //
3638 OpCodeSize = sizeof (EFI_IFR_REF);
3639 if (RefDevicePath != 0) {
3640 OpCodeSize = sizeof (EFI_IFR_REF4);
3641 } else if (RefFormSetId != NULL) {
3642 OpCodeSize = sizeof (EFI_IFR_REF3);
3643 } else if (RefQuestionId != 0) {
3644 OpCodeSize = sizeof (EFI_IFR_REF2);
3645 }
3646
3647 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_REF_OP, OpCodeSize);
3648}
3649
3673UINT8 *
3674EFIAPI
3676 IN VOID *OpCodeHandle,
3677 IN EFI_QUESTION_ID QuestionId,
3678 IN EFI_VARSTORE_ID VarStoreId,
3679 IN UINT16 VarOffset,
3680 IN EFI_STRING_ID Prompt,
3681 IN EFI_STRING_ID Help,
3682 IN UINT8 QuestionFlags,
3683 IN UINT8 CheckBoxFlags,
3684 IN VOID *DefaultsOpCodeHandle OPTIONAL
3685 )
3686{
3687 EFI_IFR_CHECKBOX OpCode;
3688 UINTN Position;
3689
3690 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
3691
3692 ZeroMem (&OpCode, sizeof (OpCode));
3693 OpCode.Question.QuestionId = QuestionId;
3694 OpCode.Question.VarStoreId = VarStoreId;
3695 OpCode.Question.VarStoreInfo.VarOffset = VarOffset;
3696 OpCode.Question.Header.Prompt = Prompt;
3697 OpCode.Question.Header.Help = Help;
3698 OpCode.Question.Flags = QuestionFlags;
3699 OpCode.Flags = CheckBoxFlags;
3700
3701 if (DefaultsOpCodeHandle == NULL) {
3702 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_CHECKBOX_OP, sizeof (OpCode));
3703 }
3704
3705 Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);
3706 InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_CHECKBOX_OP, sizeof (OpCode), 0, 1);
3707 InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
3708 HiiCreateEndOpCode (OpCodeHandle);
3709 return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
3710}
3711
3738UINT8 *
3739EFIAPI
3741 IN VOID *OpCodeHandle,
3742 IN EFI_QUESTION_ID QuestionId,
3743 IN EFI_VARSTORE_ID VarStoreId,
3744 IN UINT16 VarOffset,
3745 IN EFI_STRING_ID Prompt,
3746 IN EFI_STRING_ID Help,
3747 IN UINT8 QuestionFlags,
3748 IN UINT8 NumericFlags,
3749 IN UINT64 Minimum,
3750 IN UINT64 Maximum,
3751 IN UINT64 Step,
3752 IN VOID *DefaultsOpCodeHandle OPTIONAL
3753 )
3754{
3755 EFI_IFR_NUMERIC OpCode;
3756 UINTN Position;
3757 UINTN Length;
3758
3759 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
3760
3761 Length = 0;
3762 ZeroMem (&OpCode, sizeof (OpCode));
3763 OpCode.Question.QuestionId = QuestionId;
3764 OpCode.Question.VarStoreId = VarStoreId;
3765 OpCode.Question.VarStoreInfo.VarOffset = VarOffset;
3766 OpCode.Question.Header.Prompt = Prompt;
3767 OpCode.Question.Header.Help = Help;
3768 OpCode.Question.Flags = QuestionFlags;
3769 OpCode.Flags = NumericFlags;
3770
3771 switch (NumericFlags & EFI_IFR_NUMERIC_SIZE) {
3772 case EFI_IFR_NUMERIC_SIZE_1:
3773 OpCode.data.u8.MinValue = (UINT8)Minimum;
3774 OpCode.data.u8.MaxValue = (UINT8)Maximum;
3775 OpCode.data.u8.Step = (UINT8)Step;
3776 Length = 3;
3777 break;
3778
3779 case EFI_IFR_NUMERIC_SIZE_2:
3780 OpCode.data.u16.MinValue = (UINT16)Minimum;
3781 OpCode.data.u16.MaxValue = (UINT16)Maximum;
3782 OpCode.data.u16.Step = (UINT16)Step;
3783 Length = 6;
3784 break;
3785
3786 case EFI_IFR_NUMERIC_SIZE_4:
3787 OpCode.data.u32.MinValue = (UINT32)Minimum;
3788 OpCode.data.u32.MaxValue = (UINT32)Maximum;
3789 OpCode.data.u32.Step = (UINT32)Step;
3790 Length = 12;
3791 break;
3792
3793 case EFI_IFR_NUMERIC_SIZE_8:
3794 OpCode.data.u64.MinValue = Minimum;
3795 OpCode.data.u64.MaxValue = Maximum;
3796 OpCode.data.u64.Step = Step;
3797 Length = 24;
3798 break;
3799 }
3800
3801 Length += OFFSET_OF (EFI_IFR_NUMERIC, data);
3802
3803 if (DefaultsOpCodeHandle == NULL) {
3804 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, Length);
3805 }
3806
3807 Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);
3808 InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_NUMERIC_OP, Length, 0, 1);
3809 InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
3810 HiiCreateEndOpCode (OpCodeHandle);
3811 return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
3812}
3813
3839UINT8 *
3840EFIAPI
3842 IN VOID *OpCodeHandle,
3843 IN EFI_QUESTION_ID QuestionId,
3844 IN EFI_VARSTORE_ID VarStoreId,
3845 IN UINT16 VarOffset,
3846 IN EFI_STRING_ID Prompt,
3847 IN EFI_STRING_ID Help,
3848 IN UINT8 QuestionFlags,
3849 IN UINT8 StringFlags,
3850 IN UINT8 MinSize,
3851 IN UINT8 MaxSize,
3852 IN VOID *DefaultsOpCodeHandle OPTIONAL
3853 )
3854{
3855 EFI_IFR_STRING OpCode;
3856 UINTN Position;
3857
3858 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
3859
3860 ZeroMem (&OpCode, sizeof (OpCode));
3861 OpCode.Question.Header.Prompt = Prompt;
3862 OpCode.Question.Header.Help = Help;
3863 OpCode.Question.QuestionId = QuestionId;
3864 OpCode.Question.VarStoreId = VarStoreId;
3865 OpCode.Question.VarStoreInfo.VarOffset = VarOffset;
3866 OpCode.Question.Flags = QuestionFlags;
3867 OpCode.MinSize = MinSize;
3868 OpCode.MaxSize = MaxSize;
3869 OpCode.Flags = (UINT8)(StringFlags & EFI_IFR_STRING_MULTI_LINE);
3870
3871 if (DefaultsOpCodeHandle == NULL) {
3872 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_STRING_OP, sizeof (OpCode));
3873 }
3874
3875 Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);
3876 InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_STRING_OP, sizeof (OpCode), 0, 1);
3877 InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
3878 HiiCreateEndOpCode (OpCodeHandle);
3879 return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
3880}
3881
3906UINT8 *
3907EFIAPI
3909 IN VOID *OpCodeHandle,
3910 IN EFI_QUESTION_ID QuestionId,
3911 IN EFI_VARSTORE_ID VarStoreId,
3912 IN UINT16 VarOffset,
3913 IN EFI_STRING_ID Prompt,
3914 IN EFI_STRING_ID Help,
3915 IN UINT8 QuestionFlags,
3916 IN UINT8 OneOfFlags,
3917 IN VOID *OptionsOpCodeHandle,
3918 IN VOID *DefaultsOpCodeHandle OPTIONAL
3919 )
3920{
3921 EFI_IFR_ONE_OF OpCode;
3922 UINTN Position;
3923 UINTN Length;
3924
3925 ASSERT (OptionsOpCodeHandle != NULL);
3926 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);
3927
3928 ZeroMem (&OpCode, sizeof (OpCode));
3929 OpCode.Question.Header.Prompt = Prompt;
3930 OpCode.Question.Header.Help = Help;
3931 OpCode.Question.QuestionId = QuestionId;
3932 OpCode.Question.VarStoreId = VarStoreId;
3933 OpCode.Question.VarStoreInfo.VarOffset = VarOffset;
3934 OpCode.Question.Flags = QuestionFlags;
3935 OpCode.Flags = OneOfFlags;
3936
3937 Length = OFFSET_OF (EFI_IFR_ONE_OF, data);
3938 Length += (1 << (OneOfFlags & EFI_IFR_NUMERIC_SIZE)) * 3;
3939
3940 Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);
3941 InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OP, Length, 0, 1);
3942 InternalHiiAppendOpCodes (OpCodeHandle, OptionsOpCodeHandle);
3943 if (DefaultsOpCodeHandle != NULL) {
3944 InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
3945 }
3946
3947 HiiCreateEndOpCode (OpCodeHandle);
3948 return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
3949}
3950
3977UINT8 *
3978EFIAPI
3980 IN VOID *OpCodeHandle,
3981 IN EFI_QUESTION_ID QuestionId,
3982 IN EFI_VARSTORE_ID VarStoreId,
3983 IN UINT16 VarOffset,
3984 IN EFI_STRING_ID Prompt,
3985 IN EFI_STRING_ID Help,
3986 IN UINT8 QuestionFlags,
3987 IN UINT8 OrderedListFlags,
3988 IN UINT8 DataType,
3989 IN UINT8 MaxContainers,
3990 IN VOID *OptionsOpCodeHandle,
3991 IN VOID *DefaultsOpCodeHandle OPTIONAL
3992 )
3993{
3994 EFI_IFR_ORDERED_LIST OpCode;
3995 UINTN Position;
3996
3997 ASSERT (OptionsOpCodeHandle != NULL);
3998 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE | EFI_IFR_FLAG_OPTIONS_ONLY))) == 0);
3999
4000 ZeroMem (&OpCode, sizeof (OpCode));
4001 OpCode.Question.Header.Prompt = Prompt;
4002 OpCode.Question.Header.Help = Help;
4003 OpCode.Question.QuestionId = QuestionId;
4004 OpCode.Question.VarStoreId = VarStoreId;
4005 OpCode.Question.VarStoreInfo.VarOffset = VarOffset;
4006 OpCode.Question.Flags = QuestionFlags;
4007 OpCode.MaxContainers = MaxContainers;
4008 OpCode.Flags = OrderedListFlags;
4009
4010 Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);
4011 InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_ORDERED_LIST_OP, sizeof (OpCode), 0, 1);
4012 InternalHiiAppendOpCodes (OpCodeHandle, OptionsOpCodeHandle);
4013 if (DefaultsOpCodeHandle != NULL) {
4014 InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
4015 }
4016
4017 HiiCreateEndOpCode (OpCodeHandle);
4018 return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
4019}
4020
4035UINT8 *
4036EFIAPI
4038 IN VOID *OpCodeHandle,
4039 IN EFI_STRING_ID Prompt,
4040 IN EFI_STRING_ID Help,
4041 IN EFI_STRING_ID TextTwo
4042 )
4043{
4044 EFI_IFR_TEXT OpCode;
4045
4046 ZeroMem (&OpCode, sizeof (OpCode));
4047 OpCode.Statement.Prompt = Prompt;
4048 OpCode.Statement.Help = Help;
4049 OpCode.TextTwo = TextTwo;
4050
4051 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_TEXT_OP, sizeof (OpCode));
4052}
4053
4079UINT8 *
4080EFIAPI
4082 IN VOID *OpCodeHandle,
4083 IN EFI_QUESTION_ID QuestionId,
4084 IN EFI_VARSTORE_ID VarStoreId OPTIONAL,
4085 IN UINT16 VarOffset OPTIONAL,
4086 IN EFI_STRING_ID Prompt,
4087 IN EFI_STRING_ID Help,
4088 IN UINT8 QuestionFlags,
4089 IN UINT8 DateFlags,
4090 IN VOID *DefaultsOpCodeHandle OPTIONAL
4091 )
4092{
4093 EFI_IFR_DATE OpCode;
4094 UINTN Position;
4095
4096 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
4097 ASSERT ((DateFlags & (~(EFI_QF_DATE_YEAR_SUPPRESS | EFI_QF_DATE_MONTH_SUPPRESS | EFI_QF_DATE_DAY_SUPPRESS | EFI_QF_DATE_STORAGE))) == 0);
4098
4099 ZeroMem (&OpCode, sizeof (OpCode));
4100 OpCode.Question.Header.Prompt = Prompt;
4101 OpCode.Question.Header.Help = Help;
4102 OpCode.Question.QuestionId = QuestionId;
4103 OpCode.Question.VarStoreId = VarStoreId;
4104 OpCode.Question.VarStoreInfo.VarOffset = VarOffset;
4105 OpCode.Question.Flags = QuestionFlags;
4106 OpCode.Flags = DateFlags;
4107
4108 if (DefaultsOpCodeHandle == NULL) {
4109 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_DATE_OP, sizeof (OpCode));
4110 }
4111
4112 Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);
4113 InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_DATE_OP, sizeof (OpCode), 0, 1);
4114 InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
4115 HiiCreateEndOpCode (OpCodeHandle);
4116 return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
4117}
4118
4144UINT8 *
4145EFIAPI
4147 IN VOID *OpCodeHandle,
4148 IN EFI_QUESTION_ID QuestionId,
4149 IN EFI_VARSTORE_ID VarStoreId OPTIONAL,
4150 IN UINT16 VarOffset OPTIONAL,
4151 IN EFI_STRING_ID Prompt,
4152 IN EFI_STRING_ID Help,
4153 IN UINT8 QuestionFlags,
4154 IN UINT8 TimeFlags,
4155 IN VOID *DefaultsOpCodeHandle OPTIONAL
4156 )
4157{
4158 EFI_IFR_TIME OpCode;
4159 UINTN Position;
4160
4161 ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
4162 ASSERT ((TimeFlags & (~(QF_TIME_HOUR_SUPPRESS | QF_TIME_MINUTE_SUPPRESS | QF_TIME_SECOND_SUPPRESS | QF_TIME_STORAGE))) == 0);
4163
4164 ZeroMem (&OpCode, sizeof (OpCode));
4165 OpCode.Question.Header.Prompt = Prompt;
4166 OpCode.Question.Header.Help = Help;
4167 OpCode.Question.QuestionId = QuestionId;
4168 OpCode.Question.VarStoreId = VarStoreId;
4169 OpCode.Question.VarStoreInfo.VarOffset = VarOffset;
4170 OpCode.Question.Flags = QuestionFlags;
4171 OpCode.Flags = TimeFlags;
4172
4173 if (DefaultsOpCodeHandle == NULL) {
4174 return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_TIME_OP, sizeof (OpCode));
4175 }
4176
4177 Position = InternalHiiOpCodeHandlePosition (OpCodeHandle);
4178 InternalHiiCreateOpCodeExtended (OpCodeHandle, &OpCode, EFI_IFR_TIME_OP, sizeof (OpCode), 0, 1);
4179 InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
4180 HiiCreateEndOpCode (OpCodeHandle);
4181 return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
4182}
4183
4202EFIAPI
4204 IN EFI_GUID *FormSetGuid OPTIONAL,
4205 IN EFI_FORM_ID FormId,
4206 IN EFI_HII_PACKAGE_HEADER *Package,
4207 IN HII_LIB_OPCODE_BUFFER *OpCodeBufferStart,
4208 IN HII_LIB_OPCODE_BUFFER *OpCodeBufferEnd OPTIONAL,
4209 OUT EFI_HII_PACKAGE_HEADER *TempPackage
4210 )
4211{
4212 UINTN AddSize;
4213 UINT8 *BufferPos;
4214 EFI_HII_PACKAGE_HEADER PackageHeader;
4215 UINTN Offset;
4216 EFI_IFR_OP_HEADER *IfrOpHdr;
4217 EFI_IFR_OP_HEADER *UpdateIfrOpHdr;
4218 BOOLEAN GetFormSet;
4219 BOOLEAN GetForm;
4220 BOOLEAN Updated;
4221 UINTN UpdatePackageLength;
4222
4223 CopyMem (TempPackage, Package, sizeof (EFI_HII_PACKAGE_HEADER));
4224 UpdatePackageLength = sizeof (EFI_HII_PACKAGE_HEADER);
4225 BufferPos = (UINT8 *)(TempPackage + 1);
4226
4227 CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
4228 IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *)Package + sizeof (EFI_HII_PACKAGE_HEADER));
4229 Offset = sizeof (EFI_HII_PACKAGE_HEADER);
4230 GetFormSet = (BOOLEAN)((FormSetGuid == NULL) ? TRUE : FALSE);
4231 GetForm = FALSE;
4232 Updated = FALSE;
4233
4234 while (Offset < PackageHeader.Length) {
4235 CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
4236 BufferPos += IfrOpHdr->Length;
4237 UpdatePackageLength += IfrOpHdr->Length;
4238
4239 //
4240 // Find the matched FormSet and Form
4241 //
4242 if ((IfrOpHdr->OpCode == EFI_IFR_FORM_SET_OP) && (FormSetGuid != NULL)) {
4243 if (CompareGuid ((GUID *)(VOID *)&((EFI_IFR_FORM_SET *)IfrOpHdr)->Guid, FormSetGuid)) {
4244 GetFormSet = TRUE;
4245 } else {
4246 GetFormSet = FALSE;
4247 }
4248 } else if ((IfrOpHdr->OpCode == EFI_IFR_FORM_OP) || (IfrOpHdr->OpCode == EFI_IFR_FORM_MAP_OP)) {
4249 if (CompareMem (&((EFI_IFR_FORM *)IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
4250 GetForm = TRUE;
4251 } else {
4252 GetForm = FALSE;
4253 }
4254 }
4255
4256 //
4257 // The matched Form is found, and Update data in this form
4258 //
4259 if (GetFormSet && GetForm) {
4260 UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *)OpCodeBufferStart->Buffer;
4261 if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \
4262 (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0))
4263 {
4264 //
4265 // Remove the original data when End OpCode buffer exist.
4266 //
4267 if (OpCodeBufferEnd != NULL) {
4268 Offset += IfrOpHdr->Length;
4269 IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *)(IfrOpHdr) + IfrOpHdr->Length);
4270 UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *)OpCodeBufferEnd->Buffer;
4271 while (Offset < PackageHeader.Length) {
4272 //
4273 // Search the matched end opcode
4274 //
4275 if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \
4276 (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0))
4277 {
4278 break;
4279 }
4280
4281 //
4282 // Go to the next Op-Code
4283 //
4284 Offset += IfrOpHdr->Length;
4285 IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *)(IfrOpHdr) + IfrOpHdr->Length);
4286 }
4287
4288 if (Offset >= PackageHeader.Length) {
4289 //
4290 // The end opcode is not found.
4291 //
4292 return EFI_NOT_FOUND;
4293 }
4294 }
4295
4296 //
4297 // Insert the updated data
4298 //
4299 AddSize = ((EFI_IFR_OP_HEADER *)OpCodeBufferStart->Buffer)->Length;
4300 CopyMem (BufferPos, OpCodeBufferStart->Buffer + AddSize, OpCodeBufferStart->Position - AddSize);
4301 BufferPos += OpCodeBufferStart->Position - AddSize;
4302 UpdatePackageLength += OpCodeBufferStart->Position - AddSize;
4303
4304 if (OpCodeBufferEnd != NULL) {
4305 //
4306 // Add the end opcode
4307 //
4308 CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
4309 BufferPos += IfrOpHdr->Length;
4310 UpdatePackageLength += IfrOpHdr->Length;
4311 }
4312
4313 //
4314 // Copy the left package data.
4315 //
4316 Offset += IfrOpHdr->Length;
4317 CopyMem (BufferPos, (UINT8 *)Package + Offset, PackageHeader.Length - Offset);
4318 UpdatePackageLength += PackageHeader.Length - Offset;
4319
4320 //
4321 // Set update flag
4322 //
4323 Updated = TRUE;
4324 break;
4325 }
4326 }
4327
4328 //
4329 // Go to the next Op-Code
4330 //
4331 Offset += IfrOpHdr->Length;
4332 IfrOpHdr = (EFI_IFR_OP_HEADER *)((CHAR8 *)(IfrOpHdr) + IfrOpHdr->Length);
4333 }
4334
4335 if (!Updated) {
4336 //
4337 // The updated opcode buffer is not found.
4338 //
4339 return EFI_NOT_FOUND;
4340 }
4341
4342 //
4343 // Update the package length.
4344 //
4345 PackageHeader.Length = (UINT32)UpdatePackageLength;
4346 CopyMem (TempPackage, &PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));
4347
4348 return EFI_SUCCESS;
4349}
4350
4409EFIAPI
4411 IN EFI_HII_HANDLE HiiHandle,
4412 IN EFI_GUID *FormSetGuid OPTIONAL,
4413 IN EFI_FORM_ID FormId,
4414 IN VOID *StartOpCodeHandle,
4415 IN VOID *EndOpCodeHandle OPTIONAL
4416 )
4417{
4418 EFI_STATUS Status;
4419 EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
4420 UINT32 PackageListLength;
4421 UINT32 Offset;
4422 EFI_HII_PACKAGE_LIST_HEADER *UpdatePackageList;
4423 UINTN BufferSize;
4424 UINT8 *UpdateBufferPos;
4425 EFI_HII_PACKAGE_HEADER *Package;
4426 EFI_HII_PACKAGE_HEADER *TempPackage;
4427 EFI_HII_PACKAGE_HEADER PackageHeader;
4428 BOOLEAN Updated;
4429 HII_LIB_OPCODE_BUFFER *OpCodeBufferStart;
4430 HII_LIB_OPCODE_BUFFER *OpCodeBufferEnd;
4431
4432 //
4433 // Input update data can't be NULL.
4434 //
4435 ASSERT (HiiHandle != NULL);
4436 ASSERT (StartOpCodeHandle != NULL);
4437 UpdatePackageList = NULL;
4438 TempPackage = NULL;
4439 HiiPackageList = NULL;
4440
4441 //
4442 // Retrieve buffer data from Opcode Handle
4443 //
4444 OpCodeBufferStart = (HII_LIB_OPCODE_BUFFER *)StartOpCodeHandle;
4445 OpCodeBufferEnd = (HII_LIB_OPCODE_BUFFER *)EndOpCodeHandle;
4446
4447 //
4448 // Get the original package list
4449 //
4450 BufferSize = 0;
4451 HiiPackageList = NULL;
4452 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &BufferSize, HiiPackageList);
4453 //
4454 // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
4455 //
4456 if (Status != EFI_BUFFER_TOO_SMALL) {
4457 return Status;
4458 }
4459
4460 HiiPackageList = AllocatePool (BufferSize);
4461 if (HiiPackageList == NULL) {
4462 Status = EFI_OUT_OF_RESOURCES;
4463 goto Finish;
4464 }
4465
4466 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &BufferSize, HiiPackageList);
4467 if (EFI_ERROR (Status)) {
4468 goto Finish;
4469 }
4470
4471 //
4472 // Calculate and allocate space for retrieval of IFR data
4473 //
4474 BufferSize += OpCodeBufferStart->Position;
4475 UpdatePackageList = AllocateZeroPool (BufferSize);
4476 if (UpdatePackageList == NULL) {
4477 Status = EFI_OUT_OF_RESOURCES;
4478 goto Finish;
4479 }
4480
4481 //
4482 // Allocate temp buffer to store the temp updated package buffer
4483 //
4484 TempPackage = AllocateZeroPool (BufferSize);
4485 if (TempPackage == NULL) {
4486 Status = EFI_OUT_OF_RESOURCES;
4487 goto Finish;
4488 }
4489
4490 UpdateBufferPos = (UINT8 *)UpdatePackageList;
4491
4492 //
4493 // Copy the package list header
4494 //
4495 CopyMem (UpdateBufferPos, HiiPackageList, sizeof (EFI_HII_PACKAGE_LIST_HEADER));
4496 UpdateBufferPos += sizeof (EFI_HII_PACKAGE_LIST_HEADER);
4497
4498 //
4499 // Go through each package to find the matched package and update one by one
4500 //
4501 Updated = FALSE;
4502 Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
4503 PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);
4504 while (Offset < PackageListLength) {
4505 Package = (EFI_HII_PACKAGE_HEADER *)(((UINT8 *)HiiPackageList) + Offset);
4506 CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
4507 Offset += Package->Length;
4508
4509 if (Package->Type == EFI_HII_PACKAGE_FORMS) {
4510 //
4511 // Check this package is the matched package.
4512 //
4513 Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPackage);
4514 //
4515 // The matched package is found. Its package buffer will be updated by the input new data.
4516 //
4517 if (!EFI_ERROR (Status)) {
4518 //
4519 // Set Update Flag
4520 //
4521 Updated = TRUE;
4522 //
4523 // Add updated package buffer
4524 //
4525 Package = TempPackage;
4526 }
4527 }
4528
4529 //
4530 // Add pacakge buffer
4531 //
4532 CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
4533 CopyMem (UpdateBufferPos, Package, PackageHeader.Length);
4534 UpdateBufferPos += PackageHeader.Length;
4535 }
4536
4537 if (Updated) {
4538 //
4539 // Update package list length
4540 //
4541 BufferSize = UpdateBufferPos - (UINT8 *)UpdatePackageList;
4542 WriteUnaligned32 (&UpdatePackageList->PackageLength, (UINT32)BufferSize);
4543
4544 //
4545 // Update Package to show form
4546 //
4547 Status = gHiiDatabase->UpdatePackageList (gHiiDatabase, HiiHandle, UpdatePackageList);
4548 } else {
4549 //
4550 // Not matched form is found and updated.
4551 //
4552 Status = EFI_NOT_FOUND;
4553 }
4554
4555Finish:
4556 if (HiiPackageList != NULL) {
4557 FreePool (HiiPackageList);
4558 }
4559
4560 if (UpdatePackageList != NULL) {
4561 FreePool (UpdatePackageList);
4562 }
4563
4564 if (TempPackage != NULL) {
4565 FreePool (TempPackage);
4566 }
4567
4568 return Status;
4569}
UINT64 UINTN
UINT64 EFIAPI StrHexToUint64(IN CONST CHAR16 *String)
Definition: String.c:560
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
Definition: SafeString.c:226
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
Definition: SafeString.c:405
UINTN EFIAPI StrnLenS(IN CONST CHAR16 *String, IN UINTN MaxSize)
Definition: SafeString.c:119
INTN EFIAPI StrnCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString, IN UINTN Length)
Definition: String.c:162
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
UINT32 EFIAPI WriteUnaligned32(OUT UINT32 *Buffer, IN UINT32 Value)
Definition: Unaligned.c:177
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
RETURN_STATUS EFIAPI StrnCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
Definition: SafeString.c:507
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
Definition: SafeString.c:310
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
Definition: String.c:30
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
Definition: String.c:224
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
UINT32 EFIAPI BitFieldRead32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit)
Definition: BitField.c:527
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
Definition: Unaligned.c:145
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING EFIAPI HiiConstructConfigHdr(IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL, IN EFI_HANDLE DriverHandle)
Definition: HiiLib.c:723
UINT8 *EFIAPI InternalHiiAppendOpCodes(IN VOID *OpCodeHandle, IN VOID *RawOpCodeHandle)
Definition: HiiLib.c:3275
UINT8 *EFIAPI HiiCreateSubTitleOpCode(IN VOID *OpCodeHandle, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 Flags, IN UINT8 Scope)
Definition: HiiLib.c:3504
UINT8 *EFIAPI InternalHiiGrowOpCodeHandle(IN VOID *OpCodeHandle, IN UINTN Size)
Definition: HiiLib.c:3144
UINT8 *EFIAPI HiiCreateDateOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId OPTIONAL, IN UINT16 VarOffset OPTIONAL, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 DateFlags, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:4081
EFI_STATUS GetValueFromRequest(IN CHAR16 *ConfigElement, IN CHAR16 *VarName, OUT UINT64 *VarValue)
Definition: HiiLib.c:1089
UINT8 *EFIAPI HiiCreateNumericOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 NumericFlags, IN UINT64 Minimum, IN UINT64 Maximum, IN UINT64 Step, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:3740
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiDefaultTypeToWidth[]
Definition: HiiLib.c:3030
EFI_STATUS EFIAPI InternalHiiUpdateFormPackageData(IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN EFI_HII_PACKAGE_HEADER *Package, IN HII_LIB_OPCODE_BUFFER *OpCodeBufferStart, IN HII_LIB_OPCODE_BUFFER *OpCodeBufferEnd OPTIONAL, OUT EFI_HII_PACKAGE_HEADER *TempPackage)
Definition: HiiLib.c:4203
#define HII_LIB_OPCODE_ALLOCATION_SIZE
Definition: HiiLib.c:3019
UINT8 *EFIAPI HiiCreateDefaultOpCode(IN VOID *OpCodeHandle, IN UINT16 DefaultId, IN UINT8 Type, IN UINT64 Value)
Definition: HiiLib.c:3367
BOOLEAN EFIAPI InternalHiiCompareSubString(IN CHAR16 *FirstString, IN CHAR16 *SecondString, IN CHAR16 *StartSearchString, IN CHAR16 *StopSearchString)
Definition: HiiLib.c:2756
BOOLEAN EFIAPI HiiGetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, OUT UINT8 *Buffer)
Definition: HiiLib.c:2872
EFI_STRING EFIAPI InternalHiiLowerConfigString(IN EFI_STRING ConfigString)
Definition: HiiLib.c:519
UINTN EFIAPI InternalHiiOpCodeHandlePosition(IN VOID *OpCodeHandle)
Definition: HiiLib.c:3110
UINT8 *EFIAPI HiiCreateGotoOpCode(IN VOID *OpCodeHandle, IN EFI_FORM_ID FormId, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN EFI_QUESTION_ID QuestionId)
Definition: HiiLib.c:3551
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
Definition: HiiLib.c:3051
EFI_STATUS GetBlockDataInfo(IN CHAR16 *ConfigElement, OUT IFR_BLOCK_DATA **CurrentBlockArray, OUT UINT8 **VarBuffer)
Definition: HiiLib.c:1913
EFI_STATUS EFIAPI InternalHiiGetValueOfNumber(IN EFI_STRING ValueString, OUT UINT8 **ValueData, OUT UINTN *ValueLength)
Definition: HiiLib.c:1022
UINT8 *EFIAPI HiiCreateTimeOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId OPTIONAL, IN UINT16 VarOffset OPTIONAL, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 TimeFlags, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:4146
EFI_STATUS ValidateQuestionFromVfr(IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList, IN UINTN PackageListLength, IN EFI_GUID *VarGuid, IN CHAR16 *VarName, IN UINT8 *VarBuffer, IN IFR_BLOCK_DATA *CurrentBlockArray, IN CHAR16 *RequestElement, IN EFI_HII_HANDLE HiiHandle, IN BOOLEAN NameValueType)
Definition: HiiLib.c:1148
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
Definition: HiiLib.c:3085
UINT8 *EFIAPI InternalHiiCreateOpCode(IN VOID *OpCodeHandle, IN VOID *OpCodeTemplate, IN UINT8 OpCode, IN UINTN OpCodeSize)
Definition: HiiLib.c:3220
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
Definition: HiiLib.c:141
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
Definition: HiiLib.c:3411
UINT8 *EFIAPI HiiCreateStringOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 StringFlags, IN UINT8 MinSize, IN UINT8 MaxSize, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:3841
UINT8 *EFIAPI HiiCreateCheckBoxOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 CheckBoxFlags, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:3675
BOOLEAN EFIAPI HiiSetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, IN CONST UINT8 *Buffer, IN CONST CHAR16 *RequestElement OPTIONAL)
Definition: HiiLib.c:2954
EFI_STATUS InternalHiiGetBufferFromString(IN EFI_STRING String, IN UINT8 Flag, OUT UINT8 **Buffer)
Definition: HiiLib.c:867
EFI_HII_HANDLE *EFIAPI HiiGetHiiHandles(IN CONST EFI_GUID *PackageListGuid OPTIONAL)
Definition: HiiLib.c:286
BOOLEAN EFIAPI InternalHiiIfrValueAction(IN CONST EFI_STRING Request OPTIONAL, IN UINT16 DefaultId, IN UINT8 ActionType)
Definition: HiiLib.c:2311
UINT8 *EFIAPI HiiCreateEndOpCode(IN VOID *OpCodeHandle)
Definition: HiiLib.c:3301
EFI_STRING EFIAPI InternalHiiBlockToConfig(IN CONST EFI_STRING ConfigRequest, IN CONST UINT8 *Block, IN UINTN BlockSize)
Definition: HiiLib.c:561
EFI_STATUS EFIAPI InternalHiiExtractGuidFromHiiHandle(IN EFI_HII_HANDLE Handle, OUT EFI_GUID *Guid)
Definition: HiiLib.c:62
UINT8 *EFIAPI HiiCreateOneOfOptionOpCode(IN VOID *OpCodeHandle, IN UINT16 StringId, IN UINT8 Flags, IN UINT8 Type, IN UINT64 Value)
Definition: HiiLib.c:3329
EFI_STATUS EFIAPI InternalHiiValidateCurrentSetting(IN EFI_STRING ConfigResp, IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList, IN UINTN PackageListLength, IN EFI_GUID *VarGuid, IN CHAR16 *VarName, IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLib.c:2177
BOOLEAN BlockArrayCheck(IN IFR_BLOCK_DATA *BlockArray, IN UINT16 VarOffset, IN UINT16 VarWidth)
Definition: HiiLib.c:974
UINT8 *EFIAPI HiiCreateRawOpCodes(IN VOID *OpCodeHandle, IN UINT8 *RawBuffer, IN UINTN RawBufferSize)
Definition: HiiLib.c:3246
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
Definition: HiiLib.c:4410
BOOLEAN EFIAPI HiiIsConfigHdrMatch(IN CONST EFI_STRING ConfigHdr, IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL)
Definition: HiiLib.c:2813
UINT8 *EFIAPI HiiCreateOneOfOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 OneOfFlags, IN VOID *OptionsOpCodeHandle, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:3908
UINT8 *EFIAPI InternalHiiOpCodeHandleBuffer(IN VOID *OpCodeHandle)
Definition: HiiLib.c:3126
BOOLEAN GetElementsFromRequest(IN EFI_STRING ConfigRequest)
Definition: HiiLib.c:2269
EFI_STRING EFIAPI InternalHiiBrowserCallback(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN CONST EFI_STRING SetResultsData OPTIONAL)
Definition: HiiLib.c:613
UINT8 *EFIAPI InternalHiiCreateOpCodeExtended(IN VOID *OpCodeHandle, IN VOID *OpCodeTemplate, IN UINT8 OpCode, IN UINTN OpCodeSize, IN UINTN ExtensionSize, IN UINT8 Scope)
Definition: HiiLib.c:3185
UINT8 *EFIAPI HiiCreateGotoExOpCode(IN VOID *OpCodeHandle, IN EFI_FORM_ID RefFormId, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN EFI_QUESTION_ID QuestionId, IN EFI_QUESTION_ID RefQuestionId, IN EFI_GUID *RefFormSetId OPTIONAL, IN EFI_STRING_ID RefDevicePath)
Definition: HiiLib.c:3605
UINT8 *EFIAPI HiiCreateActionOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN EFI_STRING_ID QuestionConfig)
Definition: HiiLib.c:3461
UINT8 *EFIAPI HiiCreateOrderedListOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 OrderedListFlags, IN UINT8 DataType, IN UINT8 MaxContainers, IN VOID *OptionsOpCodeHandle, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:3979
EFI_STATUS EFIAPI HiiGetFormSetFromHiiHandle(IN EFI_HII_HANDLE Handle, OUT EFI_IFR_FORM_SET **Buffer, OUT UINTN *BufferSize)
Definition: HiiLib.c:394
UINT8 *EFIAPI HiiCreateTextOpCode(IN VOID *OpCodeHandle, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN EFI_STRING_ID TextTwo)
Definition: HiiLib.c:4037
BOOLEAN EFIAPI HiiValidateSettings(IN CONST EFI_STRING Request OPTIONAL)
Definition: HiiLib.c:2689
BOOLEAN EFIAPI HiiSetToDefaults(IN CONST EFI_STRING Request OPTIONAL, IN UINT16 DefaultId)
Definition: HiiLib.c:2714
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLib.c:253
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
Definition: HiiString.c:211
#define EDKII_IFR_DISPLAY_BIT
Definition: MdeModuleHii.h:218
RETURN_STATUS EFIAPI UnicodeValueToStringS(IN OUT CHAR16 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
Definition: PrintLib.c:652
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
Definition: PrintLib.c:408
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define VA_ARG(Marker, TYPE)
Definition: Base.h:679
#define VA_START(Marker, Parameter)
Definition: Base.h:661
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
CHAR8 * VA_LIST
Definition: Base.h:643
#define IN
Definition: Base.h:279
#define OFFSET_OF(TYPE, Field)
Definition: Base.h:758
#define OUT
Definition: Base.h:284
#define GLOBAL_REMOVE_IF_UNREFERENCED
Definition: Base.h:48
#define BASE_CR(Record, TYPE, Field)
Definition: Base.h:891
#define VA_END(Marker)
Definition: Base.h:691
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
GUID EFI_GUID
Definition: UefiBaseType.h:25
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_HII_CONFIG_ROUTING_PROTOCOL * gHiiConfigRouting
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
VOID * EFI_HII_HANDLE
Definition: Base.h:213