Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
/vendor/edk2/current 103735-103757
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
r48674 r58459 2 2 Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL. 3 3 4 Copyright (c) 2007 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 243 243 *SubStr = AllocateCopyPool (StrSize (String), String); 244 244 ASSERT (*SubStr != NULL); 245 return 245 return; 246 246 } 247 247 … … 356 356 357 357 Length = TmpPtr - String; 358 if (Length == 0) { 359 return EFI_NOT_FOUND; 360 } 358 361 Result = AllocateCopyPool (Length * sizeof (CHAR16), String); 359 362 if (Result == NULL) { … … 629 632 // 630 633 *(AltConfigHdr + HeaderLength) = L'\0'; 631 StringPtrDefault = StrStr (StringPtrDefault + 1, AltConfigHdr); 634 StringPtrDefault = StrStr (StringPtrDefault + 1, AltConfigHdr); 632 635 } 633 636 … … 650 653 { 651 654 LIST_ENTRY *Link; 652 IFR_DEFAULT_DATA *DefaultValueArray; 653 654 for (Link = BlockData->DefaultValueEntry.ForwardLink; Link != &BlockData->DefaultValueEntry; Link = Link->ForwardLink) { 655 IFR_DEFAULT_DATA *DefaultValueArray; 656 LIST_ENTRY *DefaultLink; 657 658 DefaultLink = &BlockData->DefaultValueEntry; 659 660 for (Link = DefaultLink->ForwardLink; Link != DefaultLink; Link = Link->ForwardLink) { 655 661 DefaultValueArray = BASE_CR (Link, IFR_DEFAULT_DATA, Entry); 656 662 if (DefaultValueArray->DefaultId == DefaultValueData->DefaultId) { … … 682 688 This function inserts new BlockData into the block link 683 689 684 @param BlockLink The list entry points to block array.685 @param BlockData The point to BlockData is added.690 @param BlockLink The list entry points to block array. 691 @param BlockData The point to BlockData is added. 686 692 687 693 **/ … … 692 698 ) 693 699 { 694 LIST_ENTRY *Link;695 IFR_BLOCK_DATA *BlockArray;696 IFR_BLOCK_DATA *BlockSingleData;700 LIST_ENTRY *Link; 701 IFR_BLOCK_DATA *BlockArray; 702 IFR_BLOCK_DATA *BlockSingleData; 697 703 698 704 BlockSingleData = *BlockData; 699 705 706 if (BlockSingleData->Name != NULL) { 707 InsertTailList (BlockLink, &BlockSingleData->Entry); 708 return; 709 } 710 700 711 // 701 712 // Insert block data in its Offset and Width order. … … 716 727 // The same block array has been added. 717 728 // 718 FreePool (BlockSingleData); 719 *BlockData = BlockArray; 729 if (BlockSingleData != BlockArray) { 730 FreePool (BlockSingleData); 731 *BlockData = BlockArray; 732 } 720 733 return; 721 734 } … … 732 745 // Add new block data into the tail. 733 746 // 734 InsertTailList (Link, &BlockSingleData->Entry); 735 return; 747 InsertTailList (Link, &BlockSingleData->Entry); 748 } 749 750 /** 751 Retrieves a pointer to the a Null-terminated ASCII string containing the list 752 of languages that an HII handle in the HII Database supports. The returned 753 string is allocated using AllocatePool(). The caller is responsible for freeing 754 the returned string using FreePool(). The format of the returned string follows 755 the language format assumed the HII Database. 756 757 If HiiHandle is NULL, then ASSERT(). 758 759 @param[in] HiiHandle A handle that was previously registered in the HII Database. 760 761 @retval NULL HiiHandle is not registered in the HII database 762 @retval NULL There are not enough resources available to retrieve the suported 763 languages. 764 @retval NULL The list of suported languages could not be retrieved. 765 @retval Other A pointer to the Null-terminated ASCII string of supported languages. 766 767 **/ 768 CHAR8 * 769 GetSupportedLanguages ( 770 IN EFI_HII_HANDLE HiiHandle 771 ) 772 { 773 EFI_STATUS Status; 774 UINTN LanguageSize; 775 CHAR8 TempSupportedLanguages; 776 CHAR8 *SupportedLanguages; 777 778 ASSERT (HiiHandle != NULL); 779 780 // 781 // Retrieve the size required for the supported languages buffer. 782 // 783 LanguageSize = 0; 784 Status = mPrivate.HiiString.GetLanguages (&mPrivate.HiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize); 785 786 // 787 // If GetLanguages() returns EFI_SUCCESS for a zero size, 788 // then there are no supported languages registered for HiiHandle. If GetLanguages() 789 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present 790 // in the HII Database 791 // 792 if (Status != EFI_BUFFER_TOO_SMALL) { 793 // 794 // Return NULL if the size can not be retrieved, or if HiiHandle is not in the HII Database 795 // 796 return NULL; 797 } 798 799 // 800 // Allocate the supported languages buffer. 801 // 802 SupportedLanguages = AllocateZeroPool (LanguageSize); 803 if (SupportedLanguages == NULL) { 804 // 805 // Return NULL if allocation fails. 806 // 807 return NULL; 808 } 809 810 // 811 // Retrieve the supported languages string 812 // 813 Status = mPrivate.HiiString.GetLanguages (&mPrivate.HiiString, HiiHandle, SupportedLanguages, &LanguageSize); 814 if (EFI_ERROR (Status)) { 815 // 816 // Free the buffer and return NULL if the supported languages can not be retrieved. 817 // 818 FreePool (SupportedLanguages); 819 return NULL; 820 } 821 822 // 823 // Return the Null-terminated ASCII string of supported languages 824 // 825 return SupportedLanguages; 826 } 827 828 /** 829 Retrieves a string from a string package. 830 831 If HiiHandle is NULL, then ASSERT(). 832 If StringId is 0, then ASSET. 833 834 @param[in] HiiHandle A handle that was previously registered in the HII Database. 835 @param[in] StringId The identifier of the string to retrieved from the string 836 package associated with HiiHandle. 837 838 @retval NULL The string specified by StringId is not present in the string package. 839 @retval Other The string was returned. 840 841 **/ 842 EFI_STRING 843 InternalGetString ( 844 IN EFI_HII_HANDLE HiiHandle, 845 IN EFI_STRING_ID StringId 846 ) 847 { 848 EFI_STATUS Status; 849 UINTN StringSize; 850 CHAR16 TempString; 851 EFI_STRING String; 852 CHAR8 *SupportedLanguages; 853 CHAR8 *PlatformLanguage; 854 CHAR8 *BestLanguage; 855 CHAR8 *Language; 856 857 ASSERT (HiiHandle != NULL); 858 ASSERT (StringId != 0); 859 860 // 861 // Initialize all allocated buffers to NULL 862 // 863 SupportedLanguages = NULL; 864 PlatformLanguage = NULL; 865 BestLanguage = NULL; 866 String = NULL; 867 Language = ""; 868 869 // 870 // Get the languages that the package specified by HiiHandle supports 871 // 872 SupportedLanguages = GetSupportedLanguages (HiiHandle); 873 if (SupportedLanguages == NULL) { 874 goto Error; 875 } 876 877 // 878 // Get the current platform language setting 879 // 880 GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatformLanguage, NULL); 881 882 // 883 // Get the best matching language from SupportedLanguages 884 // 885 BestLanguage = GetBestLanguage ( 886 SupportedLanguages, 887 FALSE, // RFC 4646 mode 888 Language, // Highest priority 889 PlatformLanguage != NULL ? PlatformLanguage : "", // Next highest priority 890 SupportedLanguages, // Lowest priority 891 NULL 892 ); 893 if (BestLanguage == NULL) { 894 goto Error; 895 } 896 897 // 898 // Retrieve the size of the string in the string package for the BestLanguage 899 // 900 StringSize = 0; 901 Status = mPrivate.HiiString.GetString ( 902 &mPrivate.HiiString, 903 BestLanguage, 904 HiiHandle, 905 StringId, 906 &TempString, 907 &StringSize, 908 NULL 909 ); 910 // 911 // If GetString() returns EFI_SUCCESS for a zero size, 912 // then there are no supported languages registered for HiiHandle. If GetString() 913 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present 914 // in the HII Database 915 // 916 if (Status != EFI_BUFFER_TOO_SMALL) { 917 goto Error; 918 } 919 920 // 921 // Allocate a buffer for the return string 922 // 923 String = AllocateZeroPool (StringSize); 924 if (String == NULL) { 925 goto Error; 926 } 927 928 // 929 // Retrieve the string from the string package 930 // 931 Status = mPrivate.HiiString.GetString ( 932 &mPrivate.HiiString, 933 BestLanguage, 934 HiiHandle, 935 StringId, 936 String, 937 &StringSize, 938 NULL 939 ); 940 if (EFI_ERROR (Status)) { 941 // 942 // Free the buffer and return NULL if the supported languages can not be retrieved. 943 // 944 FreePool (String); 945 String = NULL; 946 } 947 948 Error: 949 // 950 // Free allocated buffers 951 // 952 if (SupportedLanguages != NULL) { 953 FreePool (SupportedLanguages); 954 } 955 if (PlatformLanguage != NULL) { 956 FreePool (PlatformLanguage); 957 } 958 if (BestLanguage != NULL) { 959 FreePool (BestLanguage); 960 } 961 962 // 963 // Return the Null-terminated Unicode string 964 // 965 return String; 736 966 } 737 967 … … 742 972 @param VarOffset Offset of var to the structure 743 973 @param VarWidth Width of var. 974 @param IsNameValueType Whether this varstore is name/value varstore or not. 975 @param HiiHandle Hii handle for this hii package. 744 976 745 977 @retval TRUE This Var is in the block range. … … 750 982 IN IFR_BLOCK_DATA *RequestBlockArray, 751 983 IN UINT16 VarOffset, 752 IN UINT16 VarWidth 984 IN UINT16 VarWidth, 985 IN BOOLEAN IsNameValueType, 986 IN EFI_HII_HANDLE HiiHandle 753 987 ) 754 988 { 755 989 LIST_ENTRY *Link; 756 990 IFR_BLOCK_DATA *BlockData; 757 991 EFI_STRING Name; 992 758 993 // 759 994 // No Request Block array, all vars are got. … … 762 997 return TRUE; 763 998 } 764 999 765 1000 // 766 1001 // Check the input var is in the request block range. … … 768 1003 for (Link = RequestBlockArray->Entry.ForwardLink; Link != &RequestBlockArray->Entry; Link = Link->ForwardLink) { 769 1004 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); 770 if ((VarOffset >= BlockData->Offset) && ((VarOffset + VarWidth) <= (BlockData->Offset + BlockData->Width))) { 771 return TRUE; 1005 1006 if (IsNameValueType) { 1007 Name = InternalGetString (HiiHandle, VarOffset); 1008 ASSERT (Name != NULL); 1009 1010 if (StrnCmp (BlockData->Name, Name, StrLen (Name)) == 0) { 1011 FreePool (Name); 1012 return TRUE; 1013 } 1014 FreePool (Name); 1015 } else { 1016 if ((VarOffset >= BlockData->Offset) && ((VarOffset + VarWidth) <= (BlockData->Offset + BlockData->Width))) { 1017 return TRUE; 1018 } 772 1019 } 773 1020 } … … 862 1109 OUT BOOLEAN *IsEfiVarstore, 863 1110 OUT EFI_IFR_VARSTORE_EFI **EfiVarStore 864 865 1111 ) 866 1112 { 867 1113 EFI_STATUS Status; 868 1114 UINTN IfrOffset; 1115 UINTN PackageOffset; 869 1116 EFI_IFR_OP_HEADER *IfrOpHdr; 870 1117 CHAR16 *VarStoreName; … … 876 1123 UINTN PackageSize; 877 1124 EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; 1125 EFI_HII_PACKAGE_HEADER *PackageHeader; 878 1126 879 1127 HiiFormPackage = NULL; … … 883 1131 NameStr = NULL; 884 1132 TempStr = NULL; 1133 *IsEfiVarstore = FALSE; 885 1134 886 1135 Status = GetFormPackageData(DataBaseRecord, &HiiFormPackage, &PackageSize); … … 889 1138 } 890 1139 891 IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1140 IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1141 PackageOffset = IfrOffset; 1142 PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage; 1143 892 1144 while (IfrOffset < PackageSize) { 893 IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); 1145 // 1146 // More than one form packages exist. 1147 // 1148 if (PackageOffset >= PackageHeader->Length) { 1149 // 1150 // Process the new form package. 1151 // 1152 PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1153 IfrOffset += PackageOffset; 1154 PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset); 1155 } 1156 1157 IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); 894 1158 IfrOffset += IfrOpHdr->Length; 1159 PackageOffset += IfrOpHdr->Length; 895 1160 896 1161 if (IfrOpHdr->OpCode == EFI_IFR_VARSTORE_EFI_OP ) { … … 947 1212 FreePool (NameStr); 948 1213 FreePool (TempStr); 1214 1215 // 1216 // Already found the varstore, break; 1217 // 1218 if (*IsEfiVarstore) { 1219 break; 1220 } 949 1221 } 950 1222 } … … 958 1230 959 1231 /** 1232 Check whether the ConfigRequest string has the request elements. 1233 For EFI_HII_VARSTORE_BUFFER type, the request has "&OFFSET=****&WIDTH=****..." format. 1234 For EFI_HII_VARSTORE_NAME_VALUE type, the request has "&NAME1**&NAME2..." format. 1235 1236 @param ConfigRequest The input config request string. 1237 1238 @retval TRUE The input include config request elements. 1239 @retval FALSE The input string not includes. 1240 1241 **/ 1242 BOOLEAN 1243 GetElementsFromRequest ( 1244 IN EFI_STRING ConfigRequest 1245 ) 1246 { 1247 EFI_STRING TmpRequest; 1248 1249 TmpRequest = StrStr (ConfigRequest, L"PATH="); 1250 ASSERT (TmpRequest != NULL); 1251 1252 if ((StrStr (TmpRequest, L"&OFFSET=") != NULL) || (StrStr (TmpRequest, L"&") != NULL)) { 1253 return TRUE; 1254 } 1255 1256 return FALSE; 1257 } 1258 1259 /** 1260 Check whether the this varstore is the request varstore. 1261 1262 @param VarstoreGuid Varstore guid. 1263 @param Name Varstore name. 1264 @param ConfigHdr Current configRequest info. 1265 1266 @retval TRUE This varstore is the requst one. 1267 @retval FALSE This varstore is not the requst one. 1268 1269 **/ 1270 BOOLEAN 1271 IsThisVarstore ( 1272 IN EFI_GUID *VarstoreGuid, 1273 IN CHAR16 *Name, 1274 IN CHAR16 *ConfigHdr 1275 ) 1276 { 1277 EFI_STRING GuidStr; 1278 EFI_STRING NameStr; 1279 EFI_STRING TempStr; 1280 UINTN LengthString; 1281 BOOLEAN RetVal; 1282 1283 RetVal = FALSE; 1284 GuidStr = NULL; 1285 TempStr = NULL; 1286 1287 // 1288 // If ConfigHdr has name field and varstore not has name, return FALSE. 1289 // 1290 if (Name == NULL && ConfigHdr != NULL && StrStr (ConfigHdr, L"NAME=&") == NULL) { 1291 return FALSE; 1292 } 1293 1294 GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *)VarstoreGuid, 1, &GuidStr); 1295 if (Name != NULL) { 1296 GenerateSubStr (L"NAME=", StrLen (Name) * sizeof (CHAR16), (VOID *) Name, 2, &NameStr); 1297 } else { 1298 GenerateSubStr (L"NAME=", 0, NULL, 2, &NameStr); 1299 } 1300 LengthString = StrLen (GuidStr); 1301 LengthString = LengthString + StrLen (NameStr) + 1; 1302 TempStr = AllocateZeroPool (LengthString * sizeof (CHAR16)); 1303 if (TempStr == NULL) { 1304 goto Done; 1305 } 1306 1307 StrCpy (TempStr, GuidStr); 1308 StrCat (TempStr, NameStr); 1309 1310 if (ConfigHdr == NULL || StrnCmp (ConfigHdr, TempStr, StrLen (TempStr)) == 0) { 1311 RetVal = TRUE; 1312 } 1313 1314 Done: 1315 if (GuidStr != NULL) { 1316 FreePool (GuidStr); 1317 } 1318 1319 if (NameStr != NULL) { 1320 FreePool (NameStr); 1321 } 1322 1323 if (TempStr != NULL) { 1324 FreePool (TempStr); 1325 } 1326 1327 return RetVal; 1328 } 1329 1330 /** 1331 This function parses Form Package to get the efi varstore info according to the request ConfigHdr. 1332 1333 @param DataBaseRecord The DataBaseRecord instance contains the found Hii handle and package. 1334 @param ConfigHdr Request string ConfigHdr. If it is NULL, 1335 the first found varstore will be as ConfigHdr. 1336 @retval TRUE This hii package is the reqeust one. 1337 @retval FALSE This hii package is not the reqeust one. 1338 **/ 1339 BOOLEAN 1340 IsThisPackageList ( 1341 IN HII_DATABASE_RECORD *DataBaseRecord, 1342 IN EFI_STRING ConfigHdr 1343 ) 1344 { 1345 EFI_STATUS Status; 1346 UINTN IfrOffset; 1347 UINTN PackageOffset; 1348 EFI_IFR_OP_HEADER *IfrOpHdr; 1349 CHAR16 *VarStoreName; 1350 UINT8 *HiiFormPackage; 1351 UINTN PackageSize; 1352 EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; 1353 EFI_HII_PACKAGE_HEADER *PackageHeader; 1354 EFI_IFR_VARSTORE *IfrVarStore; 1355 EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore; 1356 BOOLEAN FindVarstore; 1357 1358 HiiFormPackage = NULL; 1359 VarStoreName = NULL; 1360 Status = EFI_SUCCESS; 1361 FindVarstore = FALSE; 1362 1363 Status = GetFormPackageData(DataBaseRecord, &HiiFormPackage, &PackageSize); 1364 if (EFI_ERROR (Status)) { 1365 return FALSE; 1366 } 1367 1368 IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1369 PackageOffset = IfrOffset; 1370 PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage; 1371 1372 while (IfrOffset < PackageSize) { 1373 // 1374 // More than one form packages exist. 1375 // 1376 if (PackageOffset >= PackageHeader->Length) { 1377 // 1378 // Process the new form package. 1379 // 1380 PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1381 IfrOffset += PackageOffset; 1382 PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset); 1383 } 1384 1385 IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset); 1386 IfrOffset += IfrOpHdr->Length; 1387 PackageOffset += IfrOpHdr->Length; 1388 1389 switch (IfrOpHdr->OpCode) { 1390 1391 case EFI_IFR_VARSTORE_OP: 1392 IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr; 1393 1394 VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16)); 1395 if (VarStoreName == NULL) { 1396 goto Done; 1397 } 1398 AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName); 1399 1400 if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) { 1401 FindVarstore = TRUE; 1402 goto Done; 1403 } 1404 break; 1405 1406 case EFI_IFR_VARSTORE_EFI_OP: 1407 IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; 1408 VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16)); 1409 if (VarStoreName == NULL) { 1410 goto Done; 1411 } 1412 AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName); 1413 1414 if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) { 1415 FindVarstore = TRUE; 1416 goto Done; 1417 } 1418 break; 1419 1420 case EFI_IFR_VARSTORE_NAME_VALUE_OP: 1421 IfrNameValueVarStore = (EFI_IFR_VARSTORE_NAME_VALUE *) IfrOpHdr; 1422 1423 if (IsThisVarstore (&IfrNameValueVarStore->Guid, NULL, ConfigHdr)) { 1424 FindVarstore = TRUE; 1425 goto Done; 1426 } 1427 break; 1428 1429 case EFI_IFR_FORM_OP: 1430 case EFI_IFR_FORM_MAP_OP: 1431 // 1432 // No matched varstore is found and directly return. 1433 // 1434 goto Done; 1435 1436 default: 1437 break; 1438 } 1439 } 1440 Done: 1441 if (HiiFormPackage != NULL) { 1442 FreePool (HiiFormPackage); 1443 } 1444 1445 if (VarStoreName != NULL) { 1446 FreePool (VarStoreName); 1447 } 1448 1449 return FindVarstore; 1450 } 1451 1452 /** 1453 Check whether the this op code is required. 1454 1455 @param RequestBlockArray The array includes all the request info or NULL. 1456 @param HiiHandle The hii handle for this form package. 1457 @param VarStorageData The varstore data strucure. 1458 @param IfrOpHdr Ifr opcode header for this opcode. 1459 @param VarWidth The buffer width for this opcode. 1460 @param ReturnData The data block added for this opcode. 1461 1462 @retval EFI_SUCCESS This opcode is required. 1463 @retval Others This opcode is not required or error occur. 1464 1465 **/ 1466 EFI_STATUS 1467 IsThisOpcodeRequired ( 1468 IN IFR_BLOCK_DATA *RequestBlockArray, 1469 IN EFI_HII_HANDLE HiiHandle, 1470 IN OUT IFR_VARSTORAGE_DATA *VarStorageData, 1471 IN EFI_IFR_OP_HEADER *IfrOpHdr, 1472 IN UINT16 VarWidth, 1473 OUT IFR_BLOCK_DATA **ReturnData 1474 ) 1475 { 1476 IFR_BLOCK_DATA *BlockData; 1477 UINT16 VarOffset; 1478 EFI_STRING_ID NameId; 1479 EFI_IFR_QUESTION_HEADER *IfrQuestionHdr; 1480 1481 NameId = 0; 1482 VarOffset = 0; 1483 IfrQuestionHdr = (EFI_IFR_QUESTION_HEADER *)((CHAR8 *) IfrOpHdr + sizeof (EFI_IFR_OP_HEADER)); 1484 1485 if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) { 1486 NameId = IfrQuestionHdr->VarStoreInfo.VarName; 1487 1488 // 1489 // Check whether this question is in requested block array. 1490 // 1491 if (!BlockArrayCheck (RequestBlockArray, NameId, 0, TRUE, HiiHandle)) { 1492 // 1493 // This question is not in the requested string. Skip it. 1494 // 1495 return EFI_SUCCESS; 1496 } 1497 } else { 1498 VarOffset = IfrQuestionHdr->VarStoreInfo.VarOffset; 1499 1500 // 1501 // Check whether this question is in requested block array. 1502 // 1503 if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth, FALSE, HiiHandle)) { 1504 // 1505 // This question is not in the requested string. Skip it. 1506 // 1507 return EFI_SUCCESS; 1508 } 1509 1510 // 1511 // Check this var question is in the var storage 1512 // 1513 if (((VarOffset + VarWidth) > VarStorageData->Size)) { 1514 return EFI_INVALID_PARAMETER; 1515 } 1516 } 1517 1518 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 1519 if (BlockData == NULL) { 1520 return EFI_OUT_OF_RESOURCES; 1521 } 1522 1523 if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) { 1524 BlockData->Name = InternalGetString(HiiHandle, NameId); 1525 } else { 1526 BlockData->Offset = VarOffset; 1527 } 1528 1529 BlockData->Width = VarWidth; 1530 BlockData->QuestionId = IfrQuestionHdr->QuestionId; 1531 BlockData->OpCode = IfrOpHdr->OpCode; 1532 BlockData->Scope = IfrOpHdr->Scope; 1533 InitializeListHead (&BlockData->DefaultValueEntry); 1534 // 1535 // Add Block Data into VarStorageData BlockEntry 1536 // 1537 InsertBlockData (&VarStorageData->BlockEntry, &BlockData); 1538 *ReturnData = BlockData; 1539 1540 return EFI_SUCCESS; 1541 } 1542 1543 /** 960 1544 This function parses Form Package to get the block array and the default 961 1545 value array according to the request ConfigHdr. 962 1546 1547 @param HiiHandle Hii Handle for this hii package. 963 1548 @param Package Pointer to the form package data. 964 1549 @param PackageLength Length of the pacakge. … … 967 1552 @param RequestBlockArray The block array is retrieved from the request string. 968 1553 @param VarStorageData VarStorage structure contains the got block and default value. 969 @param PIfrDefaultIdArrayPoint to the got default id and default name array.1554 @param DefaultIdArray Point to the got default id and default name array. 970 1555 971 1556 @retval EFI_SUCCESS The block array and the default value array are got. … … 977 1562 EFIAPI 978 1563 ParseIfrData ( 1564 IN EFI_HII_HANDLE HiiHandle, 979 1565 IN UINT8 *Package, 980 1566 IN UINT32 PackageLength, … … 987 1573 EFI_STATUS Status; 988 1574 UINTN IfrOffset; 1575 UINTN PackageOffset; 989 1576 EFI_IFR_VARSTORE *IfrVarStore; 990 1577 EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; … … 998 1585 EFI_IFR_PASSWORD *IfrPassword; 999 1586 EFI_IFR_STRING *IfrString; 1587 EFI_IFR_DATE *IfrDate; 1588 EFI_IFR_TIME *IfrTime; 1000 1589 IFR_DEFAULT_DATA DefaultData; 1001 1590 IFR_DEFAULT_DATA *DefaultDataPtr; 1002 1591 IFR_BLOCK_DATA *BlockData; 1003 1592 CHAR16 *VarStoreName; 1004 UINT16 VarOffset;1005 1593 UINT16 VarWidth; 1006 1594 UINT16 VarDefaultId; 1007 EFI_STRING GuidStr;1008 EFI_STRING NameStr;1009 EFI_STRING TempStr;1010 UINTN LengthString;1011 1595 BOOLEAN FirstOneOfOption; 1012 1596 LIST_ENTRY *LinkData; 1013 1597 LIST_ENTRY *LinkDefault; 1014 1015 LengthString = 0; 1598 EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore; 1599 EFI_HII_PACKAGE_HEADER *PackageHeader; 1600 EFI_VARSTORE_ID VarStoreId; 1601 1016 1602 Status = EFI_SUCCESS; 1017 GuidStr = NULL;1018 NameStr = NULL;1019 TempStr = NULL;1020 1603 BlockData = NULL; 1021 1604 DefaultDataPtr = NULL; 1022 1605 FirstOneOfOption = FALSE; 1606 VarStoreId = 0; 1023 1607 ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); 1024 1608 … … 1026 1610 // Go through the form package to parse OpCode one by one. 1027 1611 // 1028 IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1612 PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1613 PackageHeader = (EFI_HII_PACKAGE_HEADER *) Package; 1614 IfrOffset = PackageOffset; 1029 1615 while (IfrOffset < PackageLength) { 1616 1617 // 1618 // More than one form package found. 1619 // 1620 if (PackageOffset >= PackageHeader->Length) { 1621 // 1622 // Already found varstore for this request, break; 1623 // 1624 if (VarStoreId != 0) { 1625 VarStoreId = 0; 1626 } 1627 1628 // 1629 // Get next package header info. 1630 // 1631 IfrOffset += sizeof (EFI_HII_PACKAGE_HEADER); 1632 PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER); 1633 PackageHeader = (EFI_HII_PACKAGE_HEADER *) (Package + IfrOffset); 1634 } 1635 1030 1636 IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset); 1031 1032 1637 switch (IfrOpHdr->OpCode) { 1033 1638 case EFI_IFR_VARSTORE_OP: … … 1035 1640 // VarStore is found. Don't need to search any more. 1036 1641 // 1037 if (VarStor ageData->Size!= 0) {1642 if (VarStoreId != 0) { 1038 1643 break; 1039 1644 } 1040 1645 1041 //1042 // Get the requied varstore information1043 // Add varstore by Guid and Name in ConfigHdr1044 // Make sure Offset is in varstore size and varstoreid1045 //1046 1646 IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr; 1647 1047 1648 VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16)); 1048 1649 if (VarStoreName == NULL) { … … 1050 1651 goto Done; 1051 1652 } 1052 AsciiStrToUnicodeStr ((CHAR8 *) IfrVarStore->Name, VarStoreName); 1053 1054 GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &IfrVarStore->Guid, 1, &GuidStr); 1055 GenerateSubStr (L"NAME=", StrLen (VarStoreName) * sizeof (CHAR16), (VOID *) VarStoreName, 2, &NameStr); 1056 LengthString = StrLen (GuidStr); 1057 LengthString = LengthString + StrLen (NameStr) + 1; 1058 TempStr = AllocateZeroPool (LengthString * sizeof (CHAR16)); 1059 if (TempStr == NULL) { 1060 FreePool (GuidStr); 1061 FreePool (NameStr); 1062 FreePool (VarStoreName); 1063 Status = EFI_OUT_OF_RESOURCES; 1064 goto Done; 1065 } 1066 StrCpy (TempStr, GuidStr); 1067 StrCat (TempStr, NameStr); 1068 if (ConfigHdr == NULL || StrnCmp (ConfigHdr, TempStr, StrLen (TempStr)) == 0) { 1653 AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName); 1654 1655 if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) { 1069 1656 // 1070 1657 // Find the matched VarStore 1071 1658 // 1072 1659 CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrVarStore->Guid); 1073 VarStorageData->VarStoreId = IfrVarStore->VarStoreId;1074 1660 VarStorageData->Size = IfrVarStore->Size; 1075 1661 VarStorageData->Name = VarStoreName; 1076 } else { 1077 // 1078 // No found, free the allocated memory 1079 // 1080 FreePool (VarStoreName); 1081 } 1082 // 1083 // Free alllocated temp string. 1084 // 1085 FreePool (GuidStr); 1086 FreePool (NameStr); 1087 FreePool (TempStr); 1662 VarStorageData->Type = EFI_HII_VARSTORE_BUFFER; 1663 VarStoreId = IfrVarStore->VarStoreId; 1664 } 1088 1665 break; 1089 1666 … … 1092 1669 // VarStore is found. Don't need to search any more. 1093 1670 // 1094 if (VarStor ageData->Size!= 0) {1671 if (VarStoreId != 0) { 1095 1672 break; 1096 1673 } 1097 1674 1098 //1099 // Get the requied varstore information1100 // Add varstore by Guid and Name in ConfigHdr1101 // Make sure Offset is in varstore size and varstoreid1102 //1103 1675 IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; 1104 1676 … … 1117 1689 goto Done; 1118 1690 } 1119 AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName); 1120 1121 GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &IfrEfiVarStore->Guid, 1, &GuidStr); 1122 GenerateSubStr (L"NAME=", StrLen (VarStoreName) * sizeof (CHAR16), (VOID *) VarStoreName, 2, &NameStr); 1123 LengthString = StrLen (GuidStr); 1124 LengthString = LengthString + StrLen (NameStr) + 1; 1125 TempStr = AllocateZeroPool (LengthString * sizeof (CHAR16)); 1126 if (TempStr == NULL) { 1127 FreePool (GuidStr); 1128 FreePool (NameStr); 1129 FreePool (VarStoreName); 1130 Status = EFI_OUT_OF_RESOURCES; 1131 goto Done; 1132 } 1133 StrCpy (TempStr, GuidStr); 1134 StrCat (TempStr, NameStr); 1135 if (ConfigHdr == NULL || StrnCmp (ConfigHdr, TempStr, StrLen (TempStr)) == 0) { 1691 AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName); 1692 1693 if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) { 1136 1694 // 1137 1695 // Find the matched VarStore 1138 1696 // 1139 1697 CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid); 1140 VarStorageData->VarStoreId = IfrEfiVarStore->VarStoreId;1141 1698 VarStorageData->Size = IfrEfiVarStore->Size; 1142 1699 VarStorageData->Name = VarStoreName; 1143 } else { 1144 // 1145 // No found, free the allocated memory 1146 // 1147 FreePool (VarStoreName); 1148 } 1149 // 1150 // Free alllocated temp string. 1151 // 1152 FreePool (GuidStr); 1153 FreePool (NameStr); 1154 FreePool (TempStr); 1700 VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER; 1701 VarStoreId = IfrEfiVarStore->VarStoreId; 1702 } 1703 break; 1704 1705 case EFI_IFR_VARSTORE_NAME_VALUE_OP: 1706 // 1707 // VarStore is found. Don't need to search any more. 1708 // 1709 if (VarStoreId != 0) { 1710 break; 1711 } 1712 1713 IfrNameValueVarStore = (EFI_IFR_VARSTORE_NAME_VALUE *) IfrOpHdr; 1714 1715 if (IsThisVarstore (&IfrNameValueVarStore->Guid, NULL, ConfigHdr)) { 1716 // 1717 // Find the matched VarStore 1718 // 1719 CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrNameValueVarStore->Guid); 1720 VarStorageData->Type = EFI_HII_VARSTORE_NAME_VALUE; 1721 VarStoreId = IfrNameValueVarStore->VarStoreId; 1722 } 1155 1723 break; 1156 1724 … … 1174 1742 // No matched varstore is found and directly return. 1175 1743 // 1176 if ( VarStorageData->Size== 0) {1744 if ( VarStoreId == 0) { 1177 1745 Status = EFI_SUCCESS; 1178 1746 goto Done; … … 1184 1752 // Ref question is not in IFR Form. This IFR form is not valid. 1185 1753 // 1186 if ( VarStorageData->Size== 0) {1754 if ( VarStoreId == 0) { 1187 1755 Status = EFI_INVALID_PARAMETER; 1188 1756 goto Done; … … 1192 1760 // 1193 1761 IfrRef = (EFI_IFR_REF4 *) IfrOpHdr; 1194 if (IfrRef->Question.VarStoreId != VarStor ageData->VarStoreId) {1762 if (IfrRef->Question.VarStoreId != VarStoreId) { 1195 1763 break; 1196 1764 } 1197 1198 //1199 // Get Offset/Width by Question header.1200 //1201 VarOffset = IfrRef->Question.VarStoreInfo.VarOffset;1202 1765 VarWidth = (UINT16) (sizeof (EFI_HII_REF)); 1203 // 1204 // Check whether this question is in requested block array. 1205 // 1206 if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) { 1207 // 1208 // This question is not in the requested string. Skip it. 1209 // 1210 break; 1211 } 1212 1213 // 1214 // Check this var question is in the var storage 1215 // 1216 if ((VarOffset + VarWidth) > VarStorageData->Size) { 1766 1767 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 1768 if (EFI_ERROR (Status)) { 1769 goto Done; 1770 } 1771 break; 1772 1773 case EFI_IFR_ONE_OF_OP: 1774 case EFI_IFR_NUMERIC_OP: 1775 // 1776 // Numeric and OneOf has the same opcode structure. 1777 // 1778 1779 // 1780 // Numeric and OneOf question is not in IFR Form. This IFR form is not valid. 1781 // 1782 if (VarStoreId == 0) { 1217 1783 Status = EFI_INVALID_PARAMETER; 1218 1784 goto Done; 1219 1785 } 1220 1221 // 1222 // Set Block Data 1223 // 1224 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 1786 // 1787 // Check whether this question is for the requested varstore. 1788 // 1789 IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr; 1790 if (IfrOneOf->Question.VarStoreId != VarStoreId) { 1791 break; 1792 } 1793 VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); 1794 1795 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 1796 if (EFI_ERROR (Status)) { 1797 goto Done; 1798 } 1799 1225 1800 if (BlockData == NULL) { 1226 Status = EFI_OUT_OF_RESOURCES; 1227 goto Done; 1228 } 1229 BlockData->Offset = VarOffset; 1230 BlockData->Width = VarWidth; 1231 BlockData->QuestionId = IfrRef->Question.QuestionId; 1232 BlockData->OpCode = IfrOpHdr->OpCode; 1233 BlockData->Scope = IfrOpHdr->Scope; 1234 InitializeListHead (&BlockData->DefaultValueEntry); 1235 // 1236 // Add Block Data into VarStorageData BlockEntry 1237 // 1238 InsertBlockData (&VarStorageData->BlockEntry, &BlockData); 1239 break; 1240 1241 case EFI_IFR_ONE_OF_OP: 1242 case EFI_IFR_NUMERIC_OP: 1243 // 1244 // Numeric and OneOf has the same opcode structure. 1245 // 1246 1247 // 1248 // Numeric and OneOf question is not in IFR Form. This IFR form is not valid. 1249 // 1250 if (VarStorageData->Size == 0) { 1251 Status = EFI_INVALID_PARAMETER; 1252 goto Done; 1253 } 1254 // 1255 // Check whether this question is for the requested varstore. 1256 // 1257 IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr; 1258 if (IfrOneOf->Question.VarStoreId != VarStorageData->VarStoreId) { 1801 // 1802 // BlockData == NULL means this opcode is not in the requst array. 1803 // 1259 1804 break; 1260 1805 } 1261 1262 // 1263 // Get Offset/Width by Question header and OneOf Flags 1264 // 1265 VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset; 1266 VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); 1267 // 1268 // Check whether this question is in requested block array. 1269 // 1270 if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) { 1271 // 1272 // This question is not in the requested string. Skip it. 1273 // 1274 break; 1275 } 1276 1277 // 1278 // Check this var question is in the var storage 1279 // 1280 if ((VarOffset + VarWidth) > VarStorageData->Size) { 1281 Status = EFI_INVALID_PARAMETER; 1282 goto Done; 1283 } 1284 1285 // 1286 // Set Block Data 1287 // 1288 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 1289 if (BlockData == NULL) { 1290 Status = EFI_OUT_OF_RESOURCES; 1291 goto Done; 1292 } 1293 BlockData->Offset = VarOffset; 1294 BlockData->Width = VarWidth; 1295 BlockData->QuestionId = IfrOneOf->Question.QuestionId; 1296 BlockData->OpCode = IfrOpHdr->OpCode; 1297 BlockData->Scope = IfrOpHdr->Scope; 1298 InitializeListHead (&BlockData->DefaultValueEntry); 1299 // 1300 // Add Block Data into VarStorageData BlockEntry 1301 // 1302 InsertBlockData (&VarStorageData->BlockEntry, &BlockData); 1303 1806 1304 1807 if (IfrOpHdr->OpCode == EFI_IFR_ONE_OF_OP) { 1305 1808 // … … 1316 1819 DefaultData.Value.u8 = IfrOneOf->data.u8.MinValue; 1317 1820 break; 1318 1821 1319 1822 case EFI_IFR_NUMERIC_SIZE_2: 1320 1823 CopyMem (&DefaultData.Value.u16, &IfrOneOf->data.u16.MinValue, sizeof (UINT16)); 1321 1824 break; 1322 1825 1323 1826 case EFI_IFR_NUMERIC_SIZE_4: 1324 1827 CopyMem (&DefaultData.Value.u32, &IfrOneOf->data.u32.MinValue, sizeof (UINT32)); 1325 1828 break; 1326 1829 1327 1830 case EFI_IFR_NUMERIC_SIZE_8: 1328 1831 CopyMem (&DefaultData.Value.u64, &IfrOneOf->data.u64.MinValue, sizeof (UINT64)); 1329 1832 break; 1833 1834 default: 1835 Status = EFI_INVALID_PARAMETER; 1836 goto Done; 1330 1837 } 1331 1838 // … … 1333 1840 // 1334 1841 for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) { 1335 DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); 1842 DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); 1336 1843 DefaultData.DefaultId = DefaultDataPtr->DefaultId; 1337 1844 InsertDefaultValue (BlockData, &DefaultData); … … 1350 1857 // OrderedList question is not in IFR Form. This IFR form is not valid. 1351 1858 // 1352 if (VarStor ageData->Size== 0) {1859 if (VarStoreId == 0) { 1353 1860 Status = EFI_INVALID_PARAMETER; 1354 1861 goto Done; … … 1358 1865 // 1359 1866 IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpHdr; 1360 if (IfrOrderedList->Question.VarStoreId != VarStor ageData->VarStoreId) {1867 if (IfrOrderedList->Question.VarStoreId != VarStoreId) { 1361 1868 BlockData = NULL; 1362 1869 break; 1363 1870 } 1364 1365 //1366 // Get Offset/Width by Question header and OneOf Flags1367 //1368 VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset;1369 1871 VarWidth = IfrOrderedList->MaxContainers; 1370 1371 // 1372 // Set Block Data 1373 // 1374 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 1375 if (BlockData == NULL) { 1376 Status = EFI_OUT_OF_RESOURCES; 1872 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 1873 if (EFI_ERROR (Status)) { 1377 1874 goto Done; 1378 1875 } 1379 BlockData->Offset = VarOffset;1380 BlockData->Width = VarWidth;1381 BlockData->QuestionId = IfrOrderedList->Question.QuestionId;1382 BlockData->OpCode = IfrOpHdr->OpCode;1383 BlockData->Scope = IfrOpHdr->Scope;1384 InitializeListHead (&BlockData->DefaultValueEntry);1385 1876 break; 1386 1877 … … 1398 1889 // CheckBox question is not in IFR Form. This IFR form is not valid. 1399 1890 // 1400 if (VarStor ageData->Size== 0) {1891 if (VarStoreId == 0) { 1401 1892 Status = EFI_INVALID_PARAMETER; 1402 1893 goto Done; … … 1406 1897 // 1407 1898 IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr; 1408 if (IfrCheckBox->Question.VarStoreId != VarStor ageData->VarStoreId) {1899 if (IfrCheckBox->Question.VarStoreId != VarStoreId) { 1409 1900 break; 1410 1901 } 1411 1412 //1413 // Get Offset/Width by Question header and OneOf Flags1414 //1415 VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;1416 1902 VarWidth = (UINT16) sizeof (BOOLEAN); 1417 1418 // 1419 // Check whether this question is in requested block array. 1420 // 1421 if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) { 1422 // 1423 // This question is not in the requested string. Skip it. 1903 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 1904 if (EFI_ERROR (Status)) { 1905 goto Done; 1906 } 1907 1908 if (BlockData == NULL) { 1909 // 1910 // BlockData == NULL means this opcode is not in the requst array. 1424 1911 // 1425 1912 break; 1426 1913 } 1427 1914 1428 //1429 // Check this var question is in the var storage1430 //1431 if ((VarOffset + VarWidth) > VarStorageData->Size) {1432 Status = EFI_INVALID_PARAMETER;1433 goto Done;1434 }1435 1436 //1437 // Set Block Data1438 //1439 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA));1440 if (BlockData == NULL) {1441 Status = EFI_OUT_OF_RESOURCES;1442 goto Done;1443 }1444 BlockData->Offset = VarOffset;1445 BlockData->Width = VarWidth;1446 BlockData->QuestionId = IfrCheckBox->Question.QuestionId;1447 BlockData->OpCode = IfrOpHdr->OpCode;1448 BlockData->Scope = IfrOpHdr->Scope;1449 InitializeListHead (&BlockData->DefaultValueEntry);1450 //1451 // Add Block Data into VarStorageData BlockEntry1452 //1453 InsertBlockData (&VarStorageData->BlockEntry, &BlockData);1454 1455 1915 // 1456 1916 // Add default value for standard ID by CheckBox Flag … … 1497 1957 // When flag is not set, defautl value is FASLE. 1498 1958 // 1499 DefaultData.Type = DefaultValueFromDefault; 1959 DefaultData.Type = DefaultValueFromDefault; 1500 1960 DefaultData.Value.b = FALSE; 1501 1961 } … … 1506 1966 break; 1507 1967 1508 case EFI_IFR_ STRING_OP:1968 case EFI_IFR_DATE_OP: 1509 1969 // 1510 1970 // offset by question header … … 1514 1974 1515 1975 // 1516 // Stringquestion is not in IFR Form. This IFR form is not valid.1517 // 1518 if (VarStor ageData->Size== 0) {1976 // Date question is not in IFR Form. This IFR form is not valid. 1977 // 1978 if (VarStoreId == 0) { 1519 1979 Status = EFI_INVALID_PARAMETER; 1520 1980 goto Done; … … 1523 1983 // Check whether this question is for the requested varstore. 1524 1984 // 1525 Ifr String = (EFI_IFR_STRING*) IfrOpHdr;1526 if (Ifr String->Question.VarStoreId != VarStorageData->VarStoreId) {1985 IfrDate = (EFI_IFR_DATE *) IfrOpHdr; 1986 if (IfrDate->Question.VarStoreId != VarStoreId) { 1527 1987 break; 1528 1988 } 1529 1530 // 1531 // Get Offset/Width by Question header and OneOf Flags 1532 // 1533 VarOffset = IfrString->Question.VarStoreInfo.VarOffset; 1534 VarWidth = (UINT16) (IfrString->MaxSize * sizeof (UINT16)); 1535 1536 // 1537 // Check whether this question is in requested block array. 1538 // 1539 if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) { 1540 // 1541 // This question is not in the requested string. Skip it. 1542 // 1543 break; 1544 } 1545 1546 // 1547 // Check this var question is in the var storage 1548 // 1549 if ((VarOffset + VarWidth) > VarStorageData->Size) { 1550 Status = EFI_INVALID_PARAMETER; 1989 1990 VarWidth = (UINT16) sizeof (EFI_HII_DATE); 1991 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 1992 if (EFI_ERROR (Status)) { 1551 1993 goto Done; 1552 1994 } 1553 1554 //1555 // Set Block Data1556 //1557 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA));1558 if (BlockData == NULL) {1559 Status = EFI_OUT_OF_RESOURCES;1560 goto Done;1561 }1562 BlockData->Offset = VarOffset;1563 BlockData->Width = VarWidth;1564 BlockData->QuestionId = IfrString->Question.QuestionId;1565 BlockData->OpCode = IfrOpHdr->OpCode;1566 InitializeListHead (&BlockData->DefaultValueEntry);1567 1568 //1569 // Add Block Data into VarStorageData BlockEntry1570 //1571 InsertBlockData (&VarStorageData->BlockEntry, &BlockData);1572 1573 //1574 // No default value for string.1575 //1576 BlockData = NULL;1577 1995 break; 1578 1996 1579 case EFI_IFR_ PASSWORD_OP:1997 case EFI_IFR_TIME_OP: 1580 1998 // 1581 1999 // offset by question header … … 1585 2003 1586 2004 // 1587 // Passwordquestion is not in IFR Form. This IFR form is not valid.1588 // 1589 if (VarStor ageData->Size== 0) {2005 // Time question is not in IFR Form. This IFR form is not valid. 2006 // 2007 if (VarStoreId == 0) { 1590 2008 Status = EFI_INVALID_PARAMETER; 1591 2009 goto Done; … … 1594 2012 // Check whether this question is for the requested varstore. 1595 2013 // 1596 Ifr Password = (EFI_IFR_PASSWORD*) IfrOpHdr;1597 if (Ifr Password->Question.VarStoreId != VarStorageData->VarStoreId) {2014 IfrTime = (EFI_IFR_TIME *) IfrOpHdr; 2015 if (IfrTime->Question.VarStoreId != VarStoreId) { 1598 2016 break; 1599 2017 } 1600 1601 // 1602 // Get Offset/Width by Question header and OneOf Flags 1603 // 1604 VarOffset = IfrPassword->Question.VarStoreInfo.VarOffset; 1605 VarWidth = (UINT16) (IfrPassword->MaxSize * sizeof (UINT16)); 1606 1607 // 1608 // Check whether this question is in requested block array. 1609 // 1610 if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) { 1611 // 1612 // This question is not in the requested string. Skip it. 1613 // 1614 break; 1615 } 1616 1617 // 1618 // Check this var question is in the var storage 1619 // 1620 if ((VarOffset + VarWidth) > VarStorageData->Size) { 2018 2019 VarWidth = (UINT16) sizeof (EFI_HII_TIME); 2020 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 2021 if (EFI_ERROR (Status)) { 2022 goto Done; 2023 } 2024 break; 2025 2026 case EFI_IFR_STRING_OP: 2027 // 2028 // offset by question header 2029 // width MaxSize * sizeof (CHAR16) 2030 // no default value, only block array 2031 // 2032 2033 // 2034 // String question is not in IFR Form. This IFR form is not valid. 2035 // 2036 if (VarStoreId == 0) { 1621 2037 Status = EFI_INVALID_PARAMETER; 1622 2038 goto Done; 1623 2039 } 1624 1625 // 1626 // Set Block Data 1627 // 1628 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 1629 if (BlockData == NULL) { 1630 Status = EFI_OUT_OF_RESOURCES; 2040 // 2041 // Check whether this question is for the requested varstore. 2042 // 2043 IfrString = (EFI_IFR_STRING *) IfrOpHdr; 2044 if (IfrString->Question.VarStoreId != VarStoreId) { 2045 break; 2046 } 2047 2048 VarWidth = (UINT16) (IfrString->MaxSize * sizeof (UINT16)); 2049 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 2050 if (EFI_ERROR (Status)) { 1631 2051 goto Done; 1632 2052 } 1633 BlockData->Offset = VarOffset; 1634 BlockData->Width = VarWidth; 1635 BlockData->QuestionId = IfrPassword->Question.QuestionId; 1636 BlockData->OpCode = IfrOpHdr->OpCode; 1637 InitializeListHead (&BlockData->DefaultValueEntry); 1638 1639 // 1640 // Add Block Data into VarStorageData BlockEntry 1641 // 1642 InsertBlockData (&VarStorageData->BlockEntry, &BlockData); 1643 2053 1644 2054 // 1645 2055 // No default value for string. … … 1648 2058 break; 1649 2059 2060 case EFI_IFR_PASSWORD_OP: 2061 // 2062 // offset by question header 2063 // width MaxSize * sizeof (CHAR16) 2064 // no default value, only block array 2065 // 2066 2067 // 2068 // Password question is not in IFR Form. This IFR form is not valid. 2069 // 2070 if (VarStoreId == 0) { 2071 Status = EFI_INVALID_PARAMETER; 2072 goto Done; 2073 } 2074 // 2075 // Check whether this question is for the requested varstore. 2076 // 2077 IfrPassword = (EFI_IFR_PASSWORD *) IfrOpHdr; 2078 if (IfrPassword->Question.VarStoreId != VarStoreId) { 2079 break; 2080 } 2081 2082 VarWidth = (UINT16) (IfrPassword->MaxSize * sizeof (UINT16)); 2083 Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData); 2084 if (EFI_ERROR (Status)) { 2085 goto Done; 2086 } 2087 2088 // 2089 // No default value for string. 2090 // 2091 BlockData = NULL; 2092 break; 2093 1650 2094 case EFI_IFR_ONE_OF_OPTION_OP: 1651 2095 // … … 1655 2099 break; 1656 2100 } 1657 2101 1658 2102 IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) IfrOpHdr; 1659 2103 if (BlockData->OpCode == EFI_IFR_ORDERED_LIST_OP) { … … 1674 2118 // 1675 2119 Status = EFI_INVALID_PARAMETER; 2120 if (BlockData->Name != NULL) { 2121 FreePool (BlockData->Name); 2122 } 1676 2123 FreePool (BlockData); 1677 2124 goto Done; … … 1685 2132 // Check whether this question is in requested block array. 1686 2133 // 1687 if (!BlockArrayCheck (RequestBlockArray, BlockData->Offset, BlockData->Width )) {2134 if (!BlockArrayCheck (RequestBlockArray, BlockData->Offset, BlockData->Width, (BOOLEAN)(BlockData->Name != NULL), HiiHandle)) { 1688 2135 // 1689 2136 // This question is not in the requested string. Skip it. 1690 2137 // 2138 if (BlockData->Name != NULL) { 2139 FreePool (BlockData->Name); 2140 } 1691 2141 FreePool (BlockData); 1692 2142 BlockData = NULL; … … 1696 2146 // Check this var question is in the var storage 1697 2147 // 1698 if ((BlockData-> Offset + BlockData->Width) > VarStorageData->Size) {2148 if ((BlockData->Name == NULL) && ((BlockData->Offset + BlockData->Width) > VarStorageData->Size)) { 1699 2149 Status = EFI_INVALID_PARAMETER; 2150 if (BlockData->Name != NULL) { 2151 FreePool (BlockData->Name); 2152 } 1700 2153 FreePool (BlockData); 1701 2154 goto Done; … … 1725 2178 // Prepare new DefaultValue 1726 2179 // 1727 DefaultData.Type = DefaultValueFromFlag;1728 CopyMem (&DefaultData.Value .u64, &IfrOneOfOption->Value.u64, sizeof (UINT64));2180 DefaultData.Type = DefaultValueFromFlag; 2181 CopyMem (&DefaultData.Value, &IfrOneOfOption->Value, IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value)); 1729 2182 if ((IfrOneOfOption->Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT) { 1730 2183 DefaultData.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; … … 1735 2188 InsertDefaultValue (BlockData, &DefaultData); 1736 2189 } 1737 1738 1739 } 1740 2190 } 2191 1741 2192 // 1742 2193 // 2. Set as the default value when this is the first option. … … 1750 2201 // Prepare new DefaultValue 1751 2202 // 1752 DefaultData.Type 1753 CopyMem (&DefaultData.Value .u64, &IfrOneOfOption->Value.u64, sizeof (UINT64));2203 DefaultData.Type = DefaultValueFromDefault; 2204 CopyMem (&DefaultData.Value, &IfrOneOfOption->Value, IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value)); 1754 2205 for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) { 1755 2206 DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry); 1756 2207 DefaultData.DefaultId = DefaultDataPtr->DefaultId; 1757 2208 InsertDefaultValue (BlockData, &DefaultData); 1758 } 2209 } 1759 2210 } 1760 2211 break; … … 1766 2217 if (BlockData == NULL || BlockData->Scope == 0) { 1767 2218 // 1768 // No matched block data is ignored. 2219 // No matched block data is ignored. 1769 2220 // 1770 2221 break; … … 1787 2238 DefaultData.Type = DefaultValueFromOpcode; 1788 2239 DefaultData.DefaultId = VarDefaultId; 1789 CopyMem (&DefaultData.Value, &IfrDefault->Value, sizeof (EFI_IFR_TYPE_VALUE));1790 2240 CopyMem (&DefaultData.Value, &IfrDefault->Value, IfrDefault->Header.Length - OFFSET_OF (EFI_IFR_DEFAULT, Value)); 2241 1791 2242 // If the value field is expression, set the cleaned flag. 1792 2243 if (IfrDefault->Type == EFI_IFR_TYPE_OTHER) { … … 1797 2248 // 1798 2249 InsertDefaultValue (BlockData, &DefaultData); 1799 2250 1800 2251 // 1801 2252 // After insert the default value, reset the cleaned value for next … … 1805 2256 DefaultData.Cleaned = FALSE; 1806 2257 break; 2258 1807 2259 case EFI_IFR_END_OP: 1808 2260 // 1809 2261 // End Opcode is for Var question. 1810 2262 // 1811 if (BlockData != NULL && BlockData->Scope > 0) { 1812 BlockData->Scope--; 1813 } 2263 if (BlockData != NULL) { 2264 if (BlockData->Scope > 0) { 2265 BlockData->Scope--; 2266 } 2267 if (BlockData->Scope == 0) { 2268 BlockData = NULL; 2269 } 2270 } 2271 1814 2272 break; 2273 1815 2274 default: 1816 if (BlockData != NULL && BlockData->Scope > 0) { 1817 BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope); 2275 if (BlockData != NULL) { 2276 if (BlockData->Scope > 0) { 2277 BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope); 2278 } 2279 2280 if (BlockData->Scope == 0) { 2281 BlockData = NULL; 2282 } 1818 2283 } 1819 2284 break; 1820 2285 } 1821 2286 1822 IfrOffset += IfrOpHdr->Length; 2287 IfrOffset += IfrOpHdr->Length; 2288 PackageOffset += IfrOpHdr->Length; 1823 2289 } 1824 2290 … … 1836 2302 } 1837 2303 1838 return Status; 2304 return Status; 2305 } 2306 2307 /** 2308 parse the configrequest string, get the elements. 2309 2310 @param ConfigRequest The input configrequest string. 2311 @param Progress Return the progress data. 2312 2313 @retval Block data pointer. 2314 **/ 2315 IFR_BLOCK_DATA * 2316 GetBlockElement ( 2317 IN EFI_STRING ConfigRequest, 2318 OUT EFI_STRING *Progress 2319 ) 2320 { 2321 EFI_STRING StringPtr; 2322 IFR_BLOCK_DATA *BlockData; 2323 IFR_BLOCK_DATA *RequestBlockArray; 2324 EFI_STATUS Status; 2325 UINT8 *TmpBuffer; 2326 UINT16 Offset; 2327 UINT16 Width; 2328 LIST_ENTRY *Link; 2329 IFR_BLOCK_DATA *NextBlockData; 2330 UINTN Length; 2331 2332 TmpBuffer = NULL; 2333 2334 // 2335 // Init RequestBlockArray 2336 // 2337 RequestBlockArray = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 2338 if (RequestBlockArray == NULL) { 2339 goto Done; 2340 } 2341 InitializeListHead (&RequestBlockArray->Entry); 2342 2343 // 2344 // Get the request Block array from the request string 2345 // Offset and Width 2346 // 2347 2348 // 2349 // Parse each <RequestElement> if exists 2350 // Only <BlockName> format is supported by this help function. 2351 // <BlockName> ::= &'OFFSET='<Number>&'WIDTH='<Number> 2352 // 2353 StringPtr = ConfigRequest; 2354 while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) { 2355 // 2356 // Skip the OFFSET string 2357 // 2358 *Progress = StringPtr; 2359 StringPtr += StrLen (L"&OFFSET="); 2360 // 2361 // Get Offset 2362 // 2363 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 2364 if (EFI_ERROR (Status)) { 2365 goto Done; 2366 } 2367 Offset = 0; 2368 CopyMem ( 2369 &Offset, 2370 TmpBuffer, 2371 (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) 2372 ); 2373 FreePool (TmpBuffer); 2374 2375 StringPtr += Length; 2376 if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { 2377 goto Done; 2378 } 2379 StringPtr += StrLen (L"&WIDTH="); 2380 2381 // 2382 // Get Width 2383 // 2384 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 2385 if (EFI_ERROR (Status)) { 2386 goto Done; 2387 } 2388 Width = 0; 2389 CopyMem ( 2390 &Width, 2391 TmpBuffer, 2392 (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) 2393 ); 2394 FreePool (TmpBuffer); 2395 2396 StringPtr += Length; 2397 if (*StringPtr != 0 && *StringPtr != L'&') { 2398 goto Done; 2399 } 2400 2401 // 2402 // Set Block Data 2403 // 2404 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 2405 if (BlockData == NULL) { 2406 goto Done; 2407 } 2408 BlockData->Offset = Offset; 2409 BlockData->Width = Width; 2410 InsertBlockData (&RequestBlockArray->Entry, &BlockData); 2411 2412 // 2413 // Skip &VALUE string if &VALUE does exists. 2414 // 2415 if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) == 0) { 2416 StringPtr += StrLen (L"&VALUE="); 2417 2418 // 2419 // Get Value 2420 // 2421 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 2422 if (EFI_ERROR (Status)) { 2423 goto Done; 2424 } 2425 2426 StringPtr += Length; 2427 if (*StringPtr != 0 && *StringPtr != L'&') { 2428 goto Done; 2429 } 2430 } 2431 // 2432 // If '\0', parsing is finished. 2433 // 2434 if (*StringPtr == 0) { 2435 break; 2436 } 2437 } 2438 2439 // 2440 // Merge the requested block data. 2441 // 2442 Link = RequestBlockArray->Entry.ForwardLink; 2443 while ((Link != &RequestBlockArray->Entry) && (Link->ForwardLink != &RequestBlockArray->Entry)) { 2444 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); 2445 NextBlockData = BASE_CR (Link->ForwardLink, IFR_BLOCK_DATA, Entry); 2446 if ((NextBlockData->Offset >= BlockData->Offset) && (NextBlockData->Offset <= (BlockData->Offset + BlockData->Width))) { 2447 if ((NextBlockData->Offset + NextBlockData->Width) > (BlockData->Offset + BlockData->Width)) { 2448 BlockData->Width = (UINT16) (NextBlockData->Offset + NextBlockData->Width - BlockData->Offset); 2449 } 2450 RemoveEntryList (Link->ForwardLink); 2451 FreePool (NextBlockData); 2452 continue; 2453 } 2454 Link = Link->ForwardLink; 2455 } 2456 2457 return RequestBlockArray; 2458 2459 Done: 2460 if (RequestBlockArray != NULL) { 2461 // 2462 // Free Link Array RequestBlockArray 2463 // 2464 while (!IsListEmpty (&RequestBlockArray->Entry)) { 2465 BlockData = BASE_CR (RequestBlockArray->Entry.ForwardLink, IFR_BLOCK_DATA, Entry); 2466 RemoveEntryList (&BlockData->Entry); 2467 FreePool (BlockData); 2468 } 2469 2470 FreePool (RequestBlockArray); 2471 } 2472 2473 return NULL; 2474 } 2475 2476 /** 2477 parse the configrequest string, get the elements. 2478 2479 @param ConfigRequest The input config request string. 2480 @param Progress Return the progress data. 2481 2482 @retval return data block array. 2483 **/ 2484 IFR_BLOCK_DATA * 2485 GetNameElement ( 2486 IN EFI_STRING ConfigRequest, 2487 OUT EFI_STRING *Progress 2488 ) 2489 { 2490 EFI_STRING StringPtr; 2491 EFI_STRING NextTag; 2492 IFR_BLOCK_DATA *BlockData; 2493 IFR_BLOCK_DATA *RequestBlockArray; 2494 BOOLEAN HasValue; 2495 2496 StringPtr = ConfigRequest; 2497 2498 // 2499 // Init RequestBlockArray 2500 // 2501 RequestBlockArray = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 2502 if (RequestBlockArray == NULL) { 2503 goto Done; 2504 } 2505 InitializeListHead (&RequestBlockArray->Entry); 2506 2507 // 2508 // Get the request Block array from the request string 2509 // 2510 2511 // 2512 // Parse each <RequestElement> if exists 2513 // Only <BlockName> format is supported by this help function. 2514 // <BlockName> ::= &'Name***=*** 2515 // 2516 while (StringPtr != NULL && *StringPtr == L'&') { 2517 2518 *Progress = StringPtr; 2519 // 2520 // Skip the L"&" string 2521 // 2522 StringPtr += 1; 2523 2524 HasValue = FALSE; 2525 if ((NextTag = StrStr (StringPtr, L"=")) != NULL) { 2526 *NextTag = L'\0'; 2527 HasValue = TRUE; 2528 } else if ((NextTag = StrStr (StringPtr, L"&")) != NULL) { 2529 *NextTag = L'\0'; 2530 } 2531 2532 // 2533 // Set Block Data 2534 // 2535 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 2536 if (BlockData == NULL) { 2537 goto Done; 2538 } 2539 2540 // 2541 // Get Name 2542 // 2543 BlockData->Name = AllocateCopyPool(StrSize (StringPtr), StringPtr); 2544 InsertBlockData (&RequestBlockArray->Entry, &BlockData); 2545 2546 if (HasValue) { 2547 // 2548 // If has value, skip the value. 2549 // 2550 StringPtr = NextTag + 1; 2551 *NextTag = L'='; 2552 StringPtr = StrStr (StringPtr, L"&"); 2553 } else if (NextTag != NULL) { 2554 // 2555 // restore the '&' text. 2556 // 2557 StringPtr = NextTag; 2558 *NextTag = L'&'; 2559 } 2560 } 2561 2562 return RequestBlockArray; 2563 2564 Done: 2565 if (RequestBlockArray != NULL) { 2566 // 2567 // Free Link Array RequestBlockArray 2568 // 2569 while (!IsListEmpty (&RequestBlockArray->Entry)) { 2570 BlockData = BASE_CR (RequestBlockArray->Entry.ForwardLink, IFR_BLOCK_DATA, Entry); 2571 RemoveEntryList (&BlockData->Entry); 2572 if (BlockData->Name != NULL) { 2573 FreePool (BlockData->Name); 2574 } 2575 FreePool (BlockData); 2576 } 2577 2578 FreePool (RequestBlockArray); 2579 } 2580 2581 return NULL; 2582 } 2583 2584 /** 2585 Generate ConfigRequest string base on the varstore info. 2586 2587 @param ConfigHdr The config header for this varstore. 2588 @param VarStorageData The varstore info. 2589 @param Status Return Status. 2590 @param ConfigRequest The ConfigRequest info may be return. 2591 2592 @retval TRUE Need to continue 2593 @retval Others NO need to continue or error occur. 2594 **/ 2595 BOOLEAN 2596 GenerateConfigRequest ( 2597 IN CHAR16 *ConfigHdr, 2598 IN IFR_VARSTORAGE_DATA *VarStorageData, 2599 OUT EFI_STATUS *Status, 2600 IN OUT EFI_STRING *ConfigRequest 2601 ) 2602 { 2603 BOOLEAN DataExist; 2604 UINTN Length; 2605 LIST_ENTRY *Link; 2606 CHAR16 *FullConfigRequest; 2607 CHAR16 *StringPtr; 2608 IFR_BLOCK_DATA *BlockData; 2609 2610 // 2611 // Append VarStorageData BlockEntry into *Request string 2612 // Now support only one varstore in a form package. 2613 // 2614 2615 // 2616 // Go through all VarStorageData Entry and get BlockEntry for each one for the multiple varstore in a single form package 2617 // Then construct them all to return MultiRequest string : ConfigHdr BlockConfig 2618 // 2619 2620 // 2621 // Compute the length of the entire request starting with <ConfigHdr> and a 2622 // Null-terminator 2623 // 2624 DataExist = FALSE; 2625 Length = StrLen (ConfigHdr) + 1; 2626 2627 for (Link = VarStorageData->BlockEntry.ForwardLink; Link != &VarStorageData->BlockEntry; Link = Link->ForwardLink) { 2628 DataExist = TRUE; 2629 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); 2630 if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) { 2631 // 2632 // Add <BlockName> length for each Name 2633 // 2634 // <BlockName> ::= &Name1&Name2&... 2635 // |1| StrLen(Name1) 2636 // 2637 Length = Length + (1 + StrLen (BlockData->Name)); 2638 } else { 2639 // 2640 // Add <BlockName> length for each Offset/Width pair 2641 // 2642 // <BlockName> ::= &OFFSET=1234&WIDTH=1234 2643 // | 8 | 4 | 7 | 4 | 2644 // 2645 Length = Length + (8 + 4 + 7 + 4); 2646 } 2647 } 2648 // 2649 // No any request block data is found. The request string can't be constructed. 2650 // 2651 if (!DataExist) { 2652 *Status = EFI_SUCCESS; 2653 return FALSE; 2654 } 2655 2656 // 2657 // Allocate buffer for the entire <ConfigRequest> 2658 // 2659 FullConfigRequest = AllocateZeroPool (Length * sizeof (CHAR16)); 2660 if (FullConfigRequest == NULL) { 2661 *Status = EFI_OUT_OF_RESOURCES; 2662 return FALSE; 2663 } 2664 StringPtr = FullConfigRequest; 2665 2666 // 2667 // Start with <ConfigHdr> 2668 // 2669 StrCpy (StringPtr, ConfigHdr); 2670 StringPtr += StrLen (StringPtr); 2671 2672 // 2673 // Loop through all the Offset/Width pairs and append them to ConfigRequest 2674 // 2675 for (Link = VarStorageData->BlockEntry.ForwardLink; Link != &VarStorageData->BlockEntry; Link = Link->ForwardLink) { 2676 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); 2677 if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) { 2678 // 2679 // Append &Name1\0 2680 // 2681 UnicodeSPrint ( 2682 StringPtr, 2683 (1 + StrLen (BlockData->Name) + 1) * sizeof (CHAR16), 2684 L"&%s", 2685 BlockData->Name 2686 ); 2687 } else { 2688 // 2689 // Append &OFFSET=XXXX&WIDTH=YYYY\0 2690 // 2691 UnicodeSPrint ( 2692 StringPtr, 2693 (8 + 4 + 7 + 4 + 1) * sizeof (CHAR16), 2694 L"&OFFSET=%04X&WIDTH=%04X", 2695 BlockData->Offset, 2696 BlockData->Width 2697 ); 2698 } 2699 StringPtr += StrLen (StringPtr); 2700 } 2701 // 2702 // Set to the got full request string. 2703 // 2704 HiiToLower (FullConfigRequest); 2705 2706 if (*ConfigRequest != NULL) { 2707 FreePool (*ConfigRequest); 2708 } 2709 *ConfigRequest = FullConfigRequest; 2710 2711 return TRUE; 2712 } 2713 2714 /** 2715 Generate ConfigRequest Header base on the varstore info. 2716 2717 @param VarStorageData The varstore info. 2718 @param DevicePath Device path for this varstore. 2719 @param ConfigHdr The config header for this varstore. 2720 2721 @retval EFI_SUCCESS Generate the header success. 2722 @retval EFI_OUT_OF_RESOURCES Allocate buffer fail. 2723 **/ 2724 EFI_STATUS 2725 GenerateHdr ( 2726 IN IFR_VARSTORAGE_DATA *VarStorageData, 2727 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, 2728 OUT EFI_STRING *ConfigHdr 2729 ) 2730 { 2731 EFI_STRING GuidStr; 2732 EFI_STRING NameStr; 2733 EFI_STRING PathStr; 2734 UINTN Length; 2735 EFI_STATUS Status; 2736 2737 Status = EFI_SUCCESS; 2738 NameStr = NULL; 2739 GuidStr = NULL; 2740 PathStr = NULL; 2741 2742 // 2743 // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..." by VarStorageData Guid, Name and DriverHandle 2744 // 2745 GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &VarStorageData->Guid, 1, &GuidStr); 2746 if (VarStorageData->Name != NULL) { 2747 GenerateSubStr (L"NAME=", StrLen (VarStorageData->Name) * sizeof (CHAR16), (VOID *) VarStorageData->Name, 2, &NameStr); 2748 } else { 2749 GenerateSubStr (L"NAME=", 0, NULL, 2, &NameStr); 2750 } 2751 GenerateSubStr ( 2752 L"PATH=", 2753 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath), 2754 (VOID *) DevicePath, 2755 1, 2756 &PathStr 2757 ); 2758 Length = StrLen (GuidStr) + StrLen (NameStr) + StrLen (PathStr) + 1; 2759 if (VarStorageData->Name == NULL) { 2760 Length += 1; 2761 } 2762 2763 *ConfigHdr = AllocateZeroPool (Length * sizeof (CHAR16)); 2764 if (*ConfigHdr == NULL) { 2765 Status = EFI_OUT_OF_RESOURCES; 2766 goto Done; 2767 } 2768 StrCpy (*ConfigHdr, GuidStr); 2769 StrCat (*ConfigHdr, NameStr); 2770 if (VarStorageData->Name == NULL) { 2771 StrCat (*ConfigHdr, L"&"); 2772 } 2773 StrCat (*ConfigHdr, PathStr); 2774 2775 // 2776 // Remove the last character L'&' 2777 // 2778 *(*ConfigHdr + StrLen (*ConfigHdr) - 1) = L'\0'; 2779 2780 Done: 2781 if (GuidStr != NULL) { 2782 FreePool (GuidStr); 2783 } 2784 2785 if (NameStr != NULL) { 2786 FreePool (NameStr); 2787 } 2788 2789 if (PathStr != NULL) { 2790 FreePool (PathStr); 2791 } 2792 2793 return Status; 2794 } 2795 2796 /** 2797 Get Data buffer size based on data type. 2798 2799 @param ValueType The input data type. 2800 2801 @retval The data buffer size for the input type. 2802 **/ 2803 UINT16 2804 GetStorageWidth ( 2805 IN UINT8 ValueType 2806 ) 2807 { 2808 UINT16 StorageWidth; 2809 2810 switch (ValueType) { 2811 case EFI_IFR_NUMERIC_SIZE_1: 2812 case EFI_IFR_TYPE_BOOLEAN: 2813 StorageWidth = (UINT16) sizeof (UINT8); 2814 break; 2815 2816 case EFI_IFR_NUMERIC_SIZE_2: 2817 StorageWidth = (UINT16) sizeof (UINT16); 2818 break; 2819 2820 case EFI_IFR_NUMERIC_SIZE_4: 2821 StorageWidth = (UINT16) sizeof (UINT32); 2822 break; 2823 2824 case EFI_IFR_NUMERIC_SIZE_8: 2825 StorageWidth = (UINT16) sizeof (UINT64); 2826 break; 2827 2828 case EFI_IFR_TYPE_TIME: 2829 StorageWidth = (UINT16) sizeof (EFI_IFR_TIME); 2830 break; 2831 2832 case EFI_IFR_TYPE_DATE: 2833 StorageWidth = (UINT16) sizeof (EFI_IFR_DATE); 2834 break; 2835 2836 default: 2837 StorageWidth = 0; 2838 break; 2839 } 2840 2841 return StorageWidth; 2842 } 2843 2844 /** 2845 Generate ConfigAltResp string base on the varstore info. 2846 2847 @param ConfigHdr The config header for this varstore. 2848 @param VarStorageData The varstore info. 2849 @param DefaultIdArray The Default id array. 2850 @param DefaultAltCfgResp The DefaultAltCfgResp info may be return. 2851 2852 @retval TRUE Need to continue 2853 @retval Others NO need to continue or error occur. 2854 **/ 2855 EFI_STATUS 2856 GenerateAltConfigResp ( 2857 IN CHAR16 *ConfigHdr, 2858 IN IFR_VARSTORAGE_DATA *VarStorageData, 2859 IN IFR_DEFAULT_DATA *DefaultIdArray, 2860 IN OUT EFI_STRING *DefaultAltCfgResp 2861 ) 2862 { 2863 BOOLEAN DataExist; 2864 UINTN Length; 2865 LIST_ENTRY *Link; 2866 LIST_ENTRY *LinkData; 2867 LIST_ENTRY *LinkDefault; 2868 LIST_ENTRY *ListEntry; 2869 CHAR16 *StringPtr; 2870 IFR_BLOCK_DATA *BlockData; 2871 IFR_DEFAULT_DATA *DefaultId; 2872 IFR_DEFAULT_DATA *DefaultValueData; 2873 UINTN Width; 2874 UINT8 *TmpBuffer; 2875 2876 BlockData = NULL; 2877 DataExist = FALSE; 2878 2879 // 2880 // Add length for <ConfigHdr> + '\0' 2881 // 2882 Length = StrLen (ConfigHdr) + 1; 2883 2884 for (Link = DefaultIdArray->Entry.ForwardLink; Link != &DefaultIdArray->Entry; Link = Link->ForwardLink) { 2885 DefaultId = BASE_CR (Link, IFR_DEFAULT_DATA, Entry); 2886 // 2887 // Add length for "&<ConfigHdr>&ALTCFG=XXXX" 2888 // |1| StrLen (ConfigHdr) | 8 | 4 | 2889 // 2890 Length += (1 + StrLen (ConfigHdr) + 8 + 4); 2891 2892 for (LinkData = VarStorageData->BlockEntry.ForwardLink; LinkData != &VarStorageData->BlockEntry; LinkData = LinkData->ForwardLink) { 2893 BlockData = BASE_CR (LinkData, IFR_BLOCK_DATA, Entry); 2894 ListEntry = &BlockData->DefaultValueEntry; 2895 for (LinkDefault = ListEntry->ForwardLink; LinkDefault != ListEntry; LinkDefault = LinkDefault->ForwardLink) { 2896 DefaultValueData = BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry); 2897 if (DefaultValueData->DefaultId != DefaultId->DefaultId) { 2898 continue; 2899 } 2900 if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) { 2901 // 2902 // Add length for "&Name1=zzzzzzzzzzzz" 2903 // |1|Name|1|Value| 2904 // 2905 Length += (1 + StrLen (BlockData->Name) + 1 + BlockData->Width * 2); 2906 } else { 2907 // 2908 // Add length for "&OFFSET=XXXX&WIDTH=YYYY&VALUE=zzzzzzzzzzzz" 2909 // | 8 | 4 | 7 | 4 | 7 | Width * 2 | 2910 // 2911 Length += (8 + 4 + 7 + 4 + 7 + BlockData->Width * 2); 2912 } 2913 DataExist = TRUE; 2914 } 2915 } 2916 } 2917 2918 // 2919 // No default value is found. The default string doesn't exist. 2920 // 2921 if (!DataExist) { 2922 return EFI_SUCCESS; 2923 } 2924 2925 // 2926 // Allocate buffer for the entire <DefaultAltCfgResp> 2927 // 2928 *DefaultAltCfgResp = AllocateZeroPool (Length * sizeof (CHAR16)); 2929 if (*DefaultAltCfgResp == NULL) { 2930 return EFI_OUT_OF_RESOURCES; 2931 } 2932 StringPtr = *DefaultAltCfgResp; 2933 2934 // 2935 // Start with <ConfigHdr> 2936 // 2937 StrCpy (StringPtr, ConfigHdr); 2938 StringPtr += StrLen (StringPtr); 2939 2940 for (Link = DefaultIdArray->Entry.ForwardLink; Link != &DefaultIdArray->Entry; Link = Link->ForwardLink) { 2941 DefaultId = BASE_CR (Link, IFR_DEFAULT_DATA, Entry); 2942 // 2943 // Add <AltConfigHdr> of the form "&<ConfigHdr>&ALTCFG=XXXX\0" 2944 // |1| StrLen (ConfigHdr) | 8 | 4 | 2945 // 2946 UnicodeSPrint ( 2947 StringPtr, 2948 (1 + StrLen (ConfigHdr) + 8 + 4 + 1) * sizeof (CHAR16), 2949 L"&%s&ALTCFG=%04X", 2950 ConfigHdr, 2951 DefaultId->DefaultId 2952 ); 2953 StringPtr += StrLen (StringPtr); 2954 2955 for (LinkData = VarStorageData->BlockEntry.ForwardLink; LinkData != &VarStorageData->BlockEntry; LinkData = LinkData->ForwardLink) { 2956 BlockData = BASE_CR (LinkData, IFR_BLOCK_DATA, Entry); 2957 ListEntry = &BlockData->DefaultValueEntry; 2958 for (LinkDefault = ListEntry->ForwardLink; LinkDefault != ListEntry; LinkDefault = LinkDefault->ForwardLink) { 2959 DefaultValueData = BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry); 2960 if (DefaultValueData->DefaultId != DefaultId->DefaultId) { 2961 continue; 2962 } 2963 if (VarStorageData->Type == EFI_HII_VARSTORE_NAME_VALUE) { 2964 UnicodeSPrint ( 2965 StringPtr, 2966 (1 + StrLen (ConfigHdr) + 1) * sizeof (CHAR16), 2967 L"&%s=", 2968 BlockData->Name 2969 ); 2970 StringPtr += StrLen (StringPtr); 2971 } else { 2972 // 2973 // Add <BlockConfig> 2974 // <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE'=<Number> 2975 // 2976 UnicodeSPrint ( 2977 StringPtr, 2978 (8 + 4 + 7 + 4 + 7 + 1) * sizeof (CHAR16), 2979 L"&OFFSET=%04X&WIDTH=%04X&VALUE=", 2980 BlockData->Offset, 2981 BlockData->Width 2982 ); 2983 StringPtr += StrLen (StringPtr); 2984 } 2985 Width = BlockData->Width; 2986 // 2987 // Convert Value to a hex string in "%x" format 2988 // NOTE: This is in the opposite byte that GUID and PATH use 2989 // 2990 TmpBuffer = (UINT8 *) &(DefaultValueData->Value); 2991 for (; Width > 0; Width--) { 2992 StringPtr += UnicodeValueToString (StringPtr, PREFIX_ZERO | RADIX_HEX, TmpBuffer[Width - 1], 2); 2993 } 2994 } 2995 } 2996 } 2997 2998 HiiToLower (*DefaultAltCfgResp); 2999 3000 return EFI_SUCCESS; 1839 3001 } 1840 3002 … … 1897 3059 IFR_BLOCK_DATA *RequestBlockArray; 1898 3060 IFR_BLOCK_DATA *BlockData; 1899 IFR_BLOCK_DATA *NextBlockData;1900 3061 IFR_DEFAULT_DATA *DefaultValueData; 1901 3062 IFR_DEFAULT_DATA *DefaultId; … … 1903 3064 IFR_VARSTORAGE_DATA *VarStorageData; 1904 3065 EFI_STRING DefaultAltCfgResp; 1905 EFI_STRING FullConfigRequest;1906 3066 EFI_STRING ConfigHdr; 1907 EFI_STRING GuidStr;1908 EFI_STRING NameStr;1909 EFI_STRING PathStr;1910 3067 EFI_STRING StringPtr; 1911 3068 EFI_STRING Progress; 1912 UINTN Length;1913 UINT8 *TmpBuffer;1914 UINT16 Offset;1915 UINT16 Width;1916 LIST_ENTRY *Link;1917 LIST_ENTRY *LinkData;1918 LIST_ENTRY *LinkDefault;1919 BOOLEAN DataExist;1920 3069 1921 3070 if (DataBaseRecord == NULL || DevicePath == NULL || Request == NULL || AltCfgResp == NULL) { … … 1930 3079 VarStorageData = NULL; 1931 3080 DefaultAltCfgResp = NULL; 1932 FullConfigRequest = NULL;1933 3081 ConfigHdr = NULL; 1934 GuidStr = NULL;1935 NameStr = NULL;1936 PathStr = NULL;1937 3082 HiiFormPackage = NULL; 1938 3083 PackageSize = 0; 1939 DataExist = FALSE;1940 3084 Progress = *Request; 1941 3085 1942 3086 Status = GetFormPackageData (DataBaseRecord, &HiiFormPackage, &PackageSize); 1943 3087 if (EFI_ERROR (Status)) { 1944 return Status;3088 goto Done; 1945 3089 } 1946 3090 … … 1978 3122 StringPtr ++; 1979 3123 } 1980 // 1981 // Check the following string &OFFSET= 1982 // 1983 if (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) != 0) { 1984 Progress = StringPtr; 1985 Status = EFI_INVALID_PARAMETER; 3124 3125 if (*StringPtr == L'\0') { 3126 // 3127 // No request block is found. 3128 // 3129 StringPtr = NULL; 3130 } 3131 } 3132 3133 // 3134 // If StringPtr != NULL, get the request elements. 3135 // 3136 if (StringPtr != NULL) { 3137 if (StrStr (StringPtr, L"&OFFSET=") != NULL) { 3138 RequestBlockArray = GetBlockElement(StringPtr, &Progress); 3139 } else { 3140 RequestBlockArray = GetNameElement(StringPtr, &Progress); 3141 } 3142 3143 if (RequestBlockArray == NULL) { 3144 Status = EFI_INVALID_PARAMETER; 1986 3145 goto Done; 1987 } else if (*StringPtr == L'\0') { 1988 // 1989 // No request block is found. 1990 // 1991 StringPtr = NULL; 1992 } 1993 } 1994 if (StringPtr != NULL) { 1995 // 1996 // Init RequestBlockArray 1997 // 1998 RequestBlockArray = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 1999 if (RequestBlockArray == NULL) { 2000 Status = EFI_OUT_OF_RESOURCES; 2001 goto Done; 2002 } 2003 InitializeListHead (&RequestBlockArray->Entry); 2004 2005 // 2006 // Get the request Block array from the request string 2007 // Offset and Width 2008 // 2009 2010 // 2011 // Parse each <RequestElement> if exists 2012 // Only <BlockName> format is supported by this help function. 2013 // <BlockName> ::= &'OFFSET='<Number>&'WIDTH='<Number> 2014 // 2015 while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) { 2016 // 2017 // Skip the OFFSET string 2018 // 2019 Progress = StringPtr; 2020 StringPtr += StrLen (L"&OFFSET="); 2021 // 2022 // Get Offset 2023 // 2024 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 2025 if (EFI_ERROR (Status)) { 2026 goto Done; 2027 } 2028 Offset = 0; 2029 CopyMem ( 2030 &Offset, 2031 TmpBuffer, 2032 (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) 2033 ); 2034 FreePool (TmpBuffer); 2035 2036 StringPtr += Length; 2037 if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { 2038 Status = EFI_INVALID_PARAMETER; 2039 goto Done; 2040 } 2041 StringPtr += StrLen (L"&WIDTH="); 2042 2043 // 2044 // Get Width 2045 // 2046 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 2047 if (EFI_ERROR (Status)) { 2048 goto Done; 2049 } 2050 Width = 0; 2051 CopyMem ( 2052 &Width, 2053 TmpBuffer, 2054 (((Length + 1) / 2) < sizeof (UINT16)) ? ((Length + 1) / 2) : sizeof (UINT16) 2055 ); 2056 FreePool (TmpBuffer); 2057 2058 StringPtr += Length; 2059 if (*StringPtr != 0 && *StringPtr != L'&') { 2060 Status = EFI_INVALID_PARAMETER; 2061 goto Done; 2062 } 2063 2064 // 2065 // Set Block Data 2066 // 2067 BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); 2068 if (BlockData == NULL) { 2069 Status = EFI_OUT_OF_RESOURCES; 2070 goto Done; 2071 } 2072 BlockData->Offset = Offset; 2073 BlockData->Width = Width; 2074 InsertBlockData (&RequestBlockArray->Entry, &BlockData); 2075 2076 // 2077 // Skip &VALUE string if &VALUE does exists. 2078 // 2079 if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) == 0) { 2080 StringPtr += StrLen (L"&VALUE="); 2081 2082 // 2083 // Get Value 2084 // 2085 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 2086 if (EFI_ERROR (Status)) { 2087 Status = EFI_INVALID_PARAMETER; 2088 goto Done; 2089 } 2090 2091 StringPtr += Length; 2092 if (*StringPtr != 0 && *StringPtr != L'&') { 2093 Status = EFI_INVALID_PARAMETER; 2094 goto Done; 2095 } 2096 } 2097 // 2098 // If '\0', parsing is finished. 2099 // 2100 if (*StringPtr == 0) { 2101 break; 2102 } 2103 } 2104 2105 // 2106 // Merge the requested block data. 2107 // 2108 Link = RequestBlockArray->Entry.ForwardLink; 2109 while ((Link != &RequestBlockArray->Entry) && (Link->ForwardLink != &RequestBlockArray->Entry)) { 2110 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); 2111 NextBlockData = BASE_CR (Link->ForwardLink, IFR_BLOCK_DATA, Entry); 2112 if ((NextBlockData->Offset >= BlockData->Offset) && (NextBlockData->Offset <= (BlockData->Offset + BlockData->Width))) { 2113 if ((NextBlockData->Offset + NextBlockData->Width) > (BlockData->Offset + BlockData->Width)) { 2114 BlockData->Width = (UINT16) (NextBlockData->Offset + NextBlockData->Width - BlockData->Offset); 2115 } 2116 RemoveEntryList (Link->ForwardLink); 2117 FreePool (NextBlockData); 2118 continue; 2119 } 2120 Link = Link->ForwardLink; 2121 } 2122 } 2123 2124 // 2125 // 2. Parse FormPackage to get BlockArray and DefaultId Array for the request BlockArray. 2126 // 3146 } 3147 } 2127 3148 2128 3149 // … … 2148 3169 2149 3170 // 3171 // 2. Parse FormPackage to get BlockArray and DefaultId Array for the request BlockArray. 3172 // 3173 3174 // 2150 3175 // Parse the opcode in form pacakge to get the default setting. 2151 3176 // 2152 Status = ParseIfrData (HiiFormPackage, (UINT32) PackageSize, *Request, RequestBlockArray, VarStorageData, DefaultIdArray); 3177 Status = ParseIfrData (DataBaseRecord->Handle, 3178 HiiFormPackage, 3179 (UINT32) PackageSize, 3180 *Request, 3181 RequestBlockArray, 3182 VarStorageData, 3183 DefaultIdArray); 2153 3184 if (EFI_ERROR (Status)) { 2154 3185 goto Done; 2155 3186 } 2156 3187 2157 3188 // 2158 3189 // No requested varstore in IFR data and directly return 2159 3190 // 2160 if (VarStorageData-> Size == 0) {3191 if (VarStorageData->Type == 0 && VarStorageData->Name == NULL) { 2161 3192 Status = EFI_SUCCESS; 2162 3193 goto Done; … … 2166 3197 // 3. Construct Request Element (Block Name) for 2.1 and 2.2 case. 2167 3198 // 2168 2169 // 2170 // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..." by VarStorageData Guid, Name and DriverHandle 2171 // 2172 GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &VarStorageData->Guid, 1, &GuidStr); 2173 GenerateSubStr (L"NAME=", StrLen (VarStorageData->Name) * sizeof (CHAR16), (VOID *) VarStorageData->Name, 2, &NameStr); 2174 GenerateSubStr ( 2175 L"PATH=", 2176 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath), 2177 (VOID *) DevicePath, 2178 1, 2179 &PathStr 2180 ); 2181 Length = StrLen (GuidStr); 2182 Length = Length + StrLen (NameStr); 2183 Length = Length + StrLen (PathStr) + 1; 2184 ConfigHdr = AllocateZeroPool (Length * sizeof (CHAR16)); 2185 if (ConfigHdr == NULL) { 2186 Status = EFI_OUT_OF_RESOURCES; 2187 goto Done; 2188 } 2189 StrCpy (ConfigHdr, GuidStr); 2190 StrCat (ConfigHdr, NameStr); 2191 StrCat (ConfigHdr, PathStr); 2192 2193 // 2194 // Remove the last character L'&' 2195 // 2196 *(ConfigHdr + StrLen (ConfigHdr) - 1) = L'\0'; 3199 Status = GenerateHdr (VarStorageData, DevicePath, &ConfigHdr); 3200 if (EFI_ERROR (Status)) { 3201 goto Done; 3202 } 2197 3203 2198 3204 if (RequestBlockArray == NULL) { 2199 // 2200 // Append VarStorageData BlockEntry into *Request string 2201 // Now support only one varstore in a form package. 2202 // 2203 2204 // 2205 // Go through all VarStorageData Entry and get BlockEntry for each one for the multiple varstore in a single form package 2206 // Then construct them all to return MultiRequest string : ConfigHdr BlockConfig 2207 // 2208 2209 // 2210 // Compute the length of the entire request starting with <ConfigHdr> and a 2211 // Null-terminator 2212 // 2213 DataExist = FALSE; 2214 Length = StrLen (ConfigHdr) + 1; 2215 2216 for (Link = VarStorageData->BlockEntry.ForwardLink; Link != &VarStorageData->BlockEntry; Link = Link->ForwardLink) { 2217 // 2218 // Add <BlockName> length for each Offset/Width pair 2219 // 2220 // <BlockName> ::= &OFFSET=1234&WIDTH=1234 2221 // | 8 | 4 | 7 | 4 | 2222 // 2223 DataExist = TRUE; 2224 Length = Length + (8 + 4 + 7 + 4); 2225 } 2226 2227 // 2228 // No any request block data is found. The request string can't be constructed. 2229 // 2230 if (!DataExist) { 2231 Status = EFI_SUCCESS; 3205 if (!GenerateConfigRequest(ConfigHdr, VarStorageData, &Status, Request)) { 2232 3206 goto Done; 2233 3207 } 2234 2235 // 2236 // Allocate buffer for the entire <ConfigRequest> 2237 // 2238 FullConfigRequest = AllocateZeroPool (Length * sizeof (CHAR16)); 2239 if (FullConfigRequest == NULL) { 2240 Status = EFI_OUT_OF_RESOURCES; 2241 goto Done; 2242 } 2243 StringPtr = FullConfigRequest; 2244 2245 // 2246 // Start with <ConfigHdr> 2247 // 2248 StrCpy (StringPtr, ConfigHdr); 2249 StringPtr += StrLen (StringPtr); 2250 2251 // 2252 // Loop through all the Offset/Width pairs and append them to ConfigRequest 2253 // 2254 for (Link = VarStorageData->BlockEntry.ForwardLink; Link != &VarStorageData->BlockEntry; Link = Link->ForwardLink) { 2255 BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry); 2256 // 2257 // Append &OFFSET=XXXX&WIDTH=YYYY\0 2258 // 2259 UnicodeSPrint ( 2260 StringPtr, 2261 (8 + 4 + 7 + 4 + 1) * sizeof (CHAR16), 2262 L"&OFFSET=%04X&WIDTH=%04X", 2263 BlockData->Offset, 2264 BlockData->Width 2265 ); 2266 StringPtr += StrLen (StringPtr); 2267 } 2268 // 2269 // Set to the got full request string. 2270 // 2271 HiiToLower (FullConfigRequest); 2272 if (*Request != NULL) { 2273 FreePool (*Request); 2274 } 2275 *Request = FullConfigRequest; 2276 } 2277 3208 } 3209 2278 3210 // 2279 3211 // 4. Construct Default Value string in AltResp according to request element. … … 2281 3213 // Then construct them all to : ConfigHdr AltConfigHdr ConfigBody AltConfigHdr ConfigBody 2282 3214 // 2283 DataExist = FALSE; 2284 // 2285 // Add length for <ConfigHdr> + '\0' 2286 // 2287 Length = StrLen (ConfigHdr) + 1; 2288 2289 for (Link = DefaultIdArray->Entry.ForwardLink; Link != &DefaultIdArray->Entry; Link = Link->ForwardLink) { 2290 DefaultId = BASE_CR (Link, IFR_DEFAULT_DATA, Entry); 2291 // 2292 // Add length for "&<ConfigHdr>&ALTCFG=XXXX" 2293 // |1| StrLen (ConfigHdr) | 8 | 4 | 2294 // 2295 Length += (1 + StrLen (ConfigHdr) + 8 + 4); 2296 2297 for (LinkData = VarStorageData->BlockEntry.ForwardLink; LinkData != &VarStorageData->BlockEntry; LinkData = LinkData->ForwardLink) { 2298 BlockData = BASE_CR (LinkData, IFR_BLOCK_DATA, Entry); 2299 for (LinkDefault = BlockData->DefaultValueEntry.ForwardLink; LinkDefault != &BlockData->DefaultValueEntry; LinkDefault = LinkDefault->ForwardLink) { 2300 DefaultValueData = BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry); 2301 if (DefaultValueData->DefaultId == DefaultId->DefaultId) { 2302 // 2303 // Add length for "&OFFSET=XXXX&WIDTH=YYYY&VALUE=zzzzzzzzzzzz" 2304 // | 8 | 4 | 7 | 4 | 7 | Width * 2 | 2305 // 2306 Length += (8 + 4 + 7 + 4 + 7 + BlockData->Width * 2); 2307 DataExist = TRUE; 2308 } 2309 } 2310 } 2311 } 2312 2313 // 2314 // No default value is found. The default string doesn't exist. 2315 // 2316 if (!DataExist) { 2317 Status = EFI_SUCCESS; 3215 Status = GenerateAltConfigResp (ConfigHdr, VarStorageData, DefaultIdArray, &DefaultAltCfgResp); 3216 if (EFI_ERROR (Status)) { 2318 3217 goto Done; 2319 3218 } 2320 2321 //2322 // Allocate buffer for the entire <DefaultAltCfgResp>2323 //2324 DefaultAltCfgResp = AllocateZeroPool (Length * sizeof (CHAR16));2325 if (DefaultAltCfgResp == NULL) {2326 Status = EFI_OUT_OF_RESOURCES;2327 goto Done;2328 }2329 StringPtr = DefaultAltCfgResp;2330 2331 //2332 // Start with <ConfigHdr>2333 //2334 StrCpy (StringPtr, ConfigHdr);2335 StringPtr += StrLen (StringPtr);2336 2337 for (Link = DefaultIdArray->Entry.ForwardLink; Link != &DefaultIdArray->Entry; Link = Link->ForwardLink) {2338 DefaultId = BASE_CR (Link, IFR_DEFAULT_DATA, Entry);2339 //2340 // Add <AltConfigHdr> of the form "&<ConfigHdr>&ALTCFG=XXXX\0"2341 // |1| StrLen (ConfigHdr) | 8 | 4 |2342 //2343 UnicodeSPrint (2344 StringPtr,2345 (1 + StrLen (ConfigHdr) + 8 + 4 + 1) * sizeof (CHAR16),2346 L"&%s&ALTCFG=%04X",2347 ConfigHdr,2348 DefaultId->DefaultId2349 );2350 StringPtr += StrLen (StringPtr);2351 2352 for (LinkData = VarStorageData->BlockEntry.ForwardLink; LinkData != &VarStorageData->BlockEntry; LinkData = LinkData->ForwardLink) {2353 BlockData = BASE_CR (LinkData, IFR_BLOCK_DATA, Entry);2354 for (LinkDefault = BlockData->DefaultValueEntry.ForwardLink; LinkDefault != &BlockData->DefaultValueEntry; LinkDefault = LinkDefault->ForwardLink) {2355 DefaultValueData = BASE_CR (LinkDefault, IFR_DEFAULT_DATA, Entry);2356 if (DefaultValueData->DefaultId == DefaultId->DefaultId) {2357 //2358 // Add <BlockConfig>2359 // <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE'=<Number>2360 //2361 UnicodeSPrint (2362 StringPtr,2363 (8 + 4 + 7 + 4 + 7 + 1) * sizeof (CHAR16),2364 L"&OFFSET=%04X&WIDTH=%04X&VALUE=",2365 BlockData->Offset,2366 BlockData->Width2367 );2368 StringPtr += StrLen (StringPtr);2369 2370 //2371 // Convert Value to a hex string in "%x" format2372 // NOTE: This is in the opposite byte that GUID and PATH use2373 //2374 Width = BlockData->Width;2375 TmpBuffer = (UINT8 *) &(DefaultValueData->Value);2376 for (; Width > 0; Width--) {2377 StringPtr += UnicodeValueToString (StringPtr, PREFIX_ZERO | RADIX_HEX, TmpBuffer[Width - 1], 2);2378 }2379 }2380 }2381 }2382 }2383 HiiToLower (DefaultAltCfgResp);2384 3219 2385 3220 // … … 2401 3236 BlockData = BASE_CR (RequestBlockArray->Entry.ForwardLink, IFR_BLOCK_DATA, Entry); 2402 3237 RemoveEntryList (&BlockData->Entry); 3238 if (BlockData->Name != NULL) { 3239 FreePool (BlockData->Name); 3240 } 2403 3241 FreePool (BlockData); 2404 3242 } … … 2406 3244 FreePool (RequestBlockArray); 2407 3245 } 2408 3246 2409 3247 if (VarStorageData != NULL) { 2410 3248 // … … 2414 3252 BlockData = BASE_CR (VarStorageData->BlockEntry.ForwardLink, IFR_BLOCK_DATA, Entry); 2415 3253 RemoveEntryList (&BlockData->Entry); 3254 if (BlockData->Name != NULL) { 3255 FreePool (BlockData->Name); 3256 } 2416 3257 // 2417 3258 // Free default value link array … … 2438 3279 FreePool (DefaultIdArray); 2439 3280 } 2440 3281 2441 3282 // 2442 3283 // Free the allocated string 2443 3284 // 2444 if (GuidStr != NULL) {2445 FreePool (GuidStr);2446 }2447 if (NameStr != NULL) {2448 FreePool (NameStr);2449 }2450 if (PathStr != NULL) {2451 FreePool (PathStr);2452 }2453 3285 if (ConfigHdr != NULL) { 2454 3286 FreePool (ConfigHdr); … … 2466 3298 *PointerProgress = NULL; 2467 3299 } else if (EFI_ERROR (Status)) { 2468 *PointerProgress = Progress;3300 *PointerProgress = *Request; 2469 3301 } else { 2470 3302 *PointerProgress = *Request + StrLen (*Request); … … 2515 3347 UINTN BufferSize; 2516 3348 2517 Status = EFI_SUCCESS; 2518 BufferSize = 0; 2519 VarStore = NULL; 2520 VarStoreName = NULL; 3349 Status = EFI_SUCCESS; 3350 BufferSize = 0; 3351 VarStore = NULL; 3352 VarStoreName = NULL; 3353 *AccessProgress = Request; 2521 3354 2522 3355 VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16)); … … 2635 3468 2636 3469 return Status; 3470 } 3471 3472 /** 3473 Validate the config request elements. 3474 3475 @param ConfigElements A null-terminated Unicode string in <ConfigRequest> format, 3476 without configHdr field. 3477 3478 @retval CHAR16 * THE first Name/value pair not correct. 3479 @retval NULL Success parse the name/value pair 3480 **/ 3481 CHAR16 * 3482 OffsetWidthValidate ( 3483 CHAR16 *ConfigElements 3484 ) 3485 { 3486 CHAR16 *StringPtr; 3487 CHAR16 *RetVal; 3488 3489 StringPtr = ConfigElements; 3490 3491 while (1) { 3492 RetVal = StringPtr; 3493 if (StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) != 0) { 3494 return RetVal; 3495 } 3496 3497 while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { 3498 StringPtr++; 3499 } 3500 if (*StringPtr == L'\0') { 3501 return RetVal; 3502 } 3503 3504 StringPtr += StrLen (L"&WIDTH="); 3505 while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) != 0) { 3506 StringPtr ++; 3507 } 3508 3509 if (*StringPtr == L'\0') { 3510 return NULL; 3511 } 3512 } 3513 } 3514 3515 /** 3516 Validate the config request elements. 3517 3518 @param ConfigElements A null-terminated Unicode string in <ConfigRequest> format, 3519 without configHdr field. 3520 3521 @retval CHAR16 * THE first Name/value pair not correct. 3522 @retval NULL Success parse the name/value pair 3523 3524 **/ 3525 CHAR16 * 3526 NameValueValidate ( 3527 CHAR16 *ConfigElements 3528 ) 3529 { 3530 CHAR16 *StringPtr; 3531 CHAR16 *RetVal; 3532 3533 StringPtr = ConfigElements; 3534 3535 while (1) { 3536 RetVal = StringPtr; 3537 if (*StringPtr != L'&') { 3538 return RetVal; 3539 } 3540 StringPtr += 1; 3541 3542 StringPtr = StrStr (StringPtr, L"&"); 3543 3544 if (StringPtr == NULL) { 3545 return NULL; 3546 } 3547 } 3548 } 3549 3550 /** 3551 Validate the config request string. 3552 3553 @param ConfigRequest A null-terminated Unicode string in <ConfigRequest> format. 3554 3555 @retval CHAR16 * THE first element not correct. 3556 @retval NULL Success parse the name/value pair 3557 3558 **/ 3559 CHAR16 * 3560 ConfigRequestValidate ( 3561 CHAR16 *ConfigRequest 3562 ) 3563 { 3564 BOOLEAN HasNameField; 3565 CHAR16 *StringPtr; 3566 3567 HasNameField = TRUE; 3568 StringPtr = ConfigRequest; 3569 3570 // 3571 // Check <ConfigHdr> 3572 // 3573 if (StrnCmp (StringPtr, L"GUID=", StrLen (L"GUID=")) != 0) { 3574 return ConfigRequest; 3575 } 3576 StringPtr += StrLen (L"GUID="); 3577 while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&NAME=", StrLen (L"&NAME=")) != 0) { 3578 StringPtr++; 3579 } 3580 if (*StringPtr == L'\0') { 3581 return ConfigRequest; 3582 } 3583 StringPtr += StrLen (L"&NAME="); 3584 if (*StringPtr == L'&') { 3585 HasNameField = FALSE; 3586 } 3587 while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&PATH=", StrLen (L"&PATH=")) != 0) { 3588 StringPtr++; 3589 } 3590 if (*StringPtr == L'\0') { 3591 return ConfigRequest; 3592 } 3593 StringPtr += StrLen (L"&PATH="); 3594 while (*StringPtr != L'\0' && *StringPtr != L'&') { 3595 StringPtr ++; 3596 } 3597 3598 if (*StringPtr == L'\0') { 3599 return NULL; 3600 } 3601 3602 if (HasNameField) { 3603 // 3604 // Should be Buffer varstore, config request should be "OFFSET/Width" pairs. 3605 // 3606 return OffsetWidthValidate(StringPtr); 3607 } else { 3608 // 3609 // Should be Name/Value varstore, config request should be "&name1&name2..." pairs. 3610 // 3611 return NameValueValidate(StringPtr); 3612 } 2637 3613 } 2638 3614 … … 2672 3648 @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set to most recent & 2673 3649 before the error or the beginning of the string. 2674 @retval EFI_INVALID_PARAMETER Unknown name. Progress points to the & before the 2675 name in question. 3650 @retval EFI_INVALID_PARAMETER The ExtractConfig function of the underlying HII 3651 Configuration Access Protocol returned 3652 EFI_INVALID_PARAMETER. Progress set to most recent 3653 & before the error or the beginning of the string. 2676 3654 2677 3655 **/ … … 2705 3683 BOOLEAN IfrDataParsedFlag; 2706 3684 BOOLEAN IsEfiVarStore; 2707 EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo; 3685 EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo; 3686 EFI_STRING ErrorPtr; 3687 UINTN DevicePathSize; 2708 3688 2709 3689 if (This == NULL || Progress == NULL || Results == NULL) { … … 2791 3771 if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) { 2792 3772 CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER); 2793 if (CompareMem ( 2794 DevicePath, 2795 CurrentDevicePath, 2796 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath) 2797 ) == 0) { 3773 DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath); 3774 if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, ConfigRequest)) { 2798 3775 DriverHandle = Database->DriverHandle; 2799 3776 HiiHandle = Database->Handle; … … 2823 3800 } 2824 3801 } 2825 2826 // 2827 // Check whether ConfigRequest contains request string OFFSET/WIDTH 3802 3803 // 3804 // Validate ConfigRequest String. 3805 // 3806 ErrorPtr = ConfigRequestValidate(ConfigRequest); 3807 if (ErrorPtr != NULL) { 3808 *Progress = StrStr (StringPtr, ErrorPtr); 3809 Status = EFI_INVALID_PARAMETER; 3810 goto Done; 3811 } 3812 3813 // 3814 // Check whether ConfigRequest contains request string. 2828 3815 // 2829 3816 IfrDataParsedFlag = FALSE; 2830 if ((HiiHandle != NULL) && (StrStr (ConfigRequest, L"&OFFSET=") == NULL)) {3817 if ((HiiHandle != NULL) && !GetElementsFromRequest(ConfigRequest)) { 2831 3818 // 2832 3819 // Get the full request string from IFR when HiiPackage is registered to HiiHandle … … 2839 3826 // Map it to the progress on <MultiConfigRequest> then return it. 2840 3827 // 3828 ASSERT (AccessProgress != NULL); 2841 3829 *Progress = StrStr (StringPtr, AccessProgress); 2842 3830 goto Done; … … 2845 3833 // Not any request block is found. 2846 3834 // 2847 if ( StrStr (ConfigRequest, L"&OFFSET=") == NULL) {3835 if (!GetElementsFromRequest(ConfigRequest)) { 2848 3836 AccessResults = AllocateCopyPool (StrSize (ConfigRequest), ConfigRequest); 2849 3837 goto NextConfigString; … … 2864 3852 // 2865 3853 Status = GetConfigRespFromEfiVarStore(This, EfiVarStoreInfo, ConfigRequest, &AccessResults, &AccessProgress); 2866 FreePool (EfiVarStoreInfo); 3854 FreePool (EfiVarStoreInfo); 2867 3855 } else { 2868 3856 // … … 2916 3904 } 2917 3905 2918 NextConfigString: 3906 NextConfigString: 2919 3907 if (!FirstElement) { 2920 3908 Status = AppendToMultiString (Results, L"&"); … … 2979 3967 @param Results Null-terminated Unicode string in 2980 3968 <MultiConfigAltResp> format which has all values 2981 filled in for the names in the Request string.2982 String to be allocated by the called function.2983 De-allocation is up to the caller.3969 filled in for the entirety of the current HII 3970 database. String to be allocated by the called 3971 function. De-allocation is up to the caller. 2984 3972 2985 3973 @retval EFI_SUCCESS The Results string is filled with the values … … 3127 4115 *StringPtr = 0; 3128 4116 } 3129 if ( StrStr (AccessResults, L"&OFFSET=") != NULL) {4117 if (GetElementsFromRequest (AccessResults)) { 3130 4118 Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &AccessResults, &DefaultResults, NULL); 3131 4119 ASSERT_EFI_ERROR (Status); … … 3218 4206 EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo; 3219 4207 BOOLEAN IsEfiVarstore; 4208 UINTN DevicePathSize; 3220 4209 3221 4210 if (This == NULL || Progress == NULL) { … … 3289 4278 if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) { 3290 4279 CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER); 3291 if (CompareMem ( 3292 DevicePath, 3293 CurrentDevicePath, 3294 GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath) 3295 ) == 0) { 4280 DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath); 4281 if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, ConfigResp)) { 3296 4282 DriverHandle = Database->DriverHandle; 3297 4283 break; … … 3356 4342 } 3357 4343 if (EFI_ERROR (Status)) { 4344 ASSERT (AccessProgress != NULL); 3358 4345 // 3359 4346 // AccessProgress indicates the parsing progress on <ConfigResp>. … … 3448 4435 CHAR16 TemChar; 3449 4436 4437 TmpBuffer = NULL; 4438 3450 4439 if (This == NULL || Progress == NULL || Config == NULL) { 3451 4440 return EFI_INVALID_PARAMETER; … … 3497 4486 if (*StringPtr == 0) { 3498 4487 *Progress = StringPtr; 3499 Status = EFI_SUCCESS;3500 4488 3501 4489 AppendToMultiString(Config, ConfigRequest); 3502 4490 HiiToLower (*Config); 3503 4491 3504 goto Exit;4492 return EFI_SUCCESS; 3505 4493 } 3506 4494 // … … 3534 4522 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 3535 4523 if (EFI_ERROR (Status)) { 3536 *Progress = ConfigRequest;4524 *Progress = TmpPtr - 1; 3537 4525 goto Exit; 3538 4526 } … … 3547 4535 StringPtr += Length; 3548 4536 if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { 3549 *Progress = StringPtr - Length - StrLen (L"OFFSET=")- 1;4537 *Progress = TmpPtr - 1; 3550 4538 Status = EFI_INVALID_PARAMETER; 3551 4539 goto Exit; … … 3558 4546 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 3559 4547 if (EFI_ERROR (Status)) { 3560 *Progress = ConfigRequest;4548 *Progress = TmpPtr - 1; 3561 4549 goto Exit; 3562 4550 } … … 3571 4559 StringPtr += Length; 3572 4560 if (*StringPtr != 0 && *StringPtr != L'&') { 3573 *Progress = StringPtr - Length - StrLen (L"&WIDTH=");4561 *Progress = TmpPtr - 1; 3574 4562 Status = EFI_INVALID_PARAMETER; 3575 4563 goto Exit; … … 3694 4682 @param BlockSize The length of the Block in units of UINT8. On 3695 4683 input, this is the size of the Block. On output, 3696 if successful, contains the index of the last 3697 modified byte in the Block. 4684 if successful, contains the largest index of the 4685 modified byte in the Block, or the required buffer 4686 size if the Block is not large enough. 3698 4687 @param Progress On return, points to an element of the ConfigResp 3699 4688 string filled in with the offset of the most … … 3715 4704 Progress points at the '&' preceding the first 3716 4705 non-<BlockName>. 3717 @retval EFI_DEVICE_ERROR Block not large enough. Progress undefined. 4706 @retval EFI_BUFFER_TOO_SMALL Block not large enough. Progress undefined. 4707 BlockSize is updated with the required buffer size. 3718 4708 @retval EFI_NOT_FOUND Target for the specified routing data was not found. 3719 4709 Progress points to the "G" in "GUID" of the errant … … 3733 4723 HII_DATABASE_PRIVATE_DATA *Private; 3734 4724 EFI_STRING StringPtr; 4725 EFI_STRING TmpPtr; 3735 4726 UINTN Length; 3736 4727 EFI_STATUS Status; … … 3742 4733 UINTN MaxBlockSize; 3743 4734 4735 TmpBuffer = NULL; 4736 3744 4737 if (This == NULL || BlockSize == NULL || Progress == NULL) { 3745 4738 return EFI_INVALID_PARAMETER; … … 3784 4777 goto Exit; 3785 4778 } 3786 //3787 // Skip '&'3788 //3789 StringPtr++;3790 4779 3791 4780 // 3792 4781 // Parse each <ConfigElement> if exists 3793 // Only <BlockConfig> format is supported by this help function.4782 // Only '&'<BlockConfig> format is supported by this help function. 3794 4783 // <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE='<Number> 3795 4784 // 3796 while (*StringPtr != 0 && StrnCmp (StringPtr, L"OFFSET=", StrLen (L"OFFSET=")) == 0) { 3797 StringPtr += StrLen (L"OFFSET="); 4785 while (*StringPtr != 0 && StrnCmp (StringPtr, L"&OFFSET=", StrLen (L"&OFFSET=")) == 0) { 4786 TmpPtr = StringPtr; 4787 StringPtr += StrLen (L"&OFFSET="); 3798 4788 // 3799 4789 // Get Offset … … 3801 4791 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 3802 4792 if (EFI_ERROR (Status)) { 3803 *Progress = ConfigResp;4793 *Progress = TmpPtr; 3804 4794 goto Exit; 3805 4795 } … … 3814 4804 StringPtr += Length; 3815 4805 if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { 3816 *Progress = StringPtr - Length - StrLen (L"OFFSET=") - 1;4806 *Progress = TmpPtr; 3817 4807 Status = EFI_INVALID_PARAMETER; 3818 4808 goto Exit; … … 3825 4815 Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 3826 4816 if (EFI_ERROR (Status)) { 3827 *Progress = ConfigResp;4817 *Progress = TmpPtr; 3828 4818 goto Exit; 3829 4819 } … … 3838 4828 StringPtr += Length; 3839 4829 if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) { 3840 *Progress = StringPtr - Length - StrLen (L"&WIDTH=");4830 *Progress = TmpPtr; 3841 4831 Status = EFI_INVALID_PARAMETER; 3842 4832 goto Exit; … … 3849 4839 Status = GetValueOfNumber (StringPtr, &Value, &Length); 3850 4840 if (EFI_ERROR (Status)) { 3851 *Progress = ConfigResp;4841 *Progress = TmpPtr; 3852 4842 goto Exit; 3853 4843 } … … 3855 4845 StringPtr += Length; 3856 4846 if (*StringPtr != 0 && *StringPtr != L'&') { 3857 *Progress = StringPtr - Length - 7;4847 *Progress = TmpPtr; 3858 4848 Status = EFI_INVALID_PARAMETER; 3859 4849 goto Exit; … … 3874 4864 3875 4865 // 3876 // If '\0', parsing is finished. Otherwise skip '&' to continue4866 // If '\0', parsing is finished. 3877 4867 // 3878 4868 if (*StringPtr == 0) { 3879 4869 break; 3880 4870 } 3881 3882 StringPtr++;3883 4871 } 3884 4872 3885 4873 // 3886 // The input string is ConfigAltResp format.3887 // 3888 if ( (*StringPtr != 0) && (StrnCmp (StringPtr, L"&GUID=", StrLen (L"&GUID=")) != 0)) {3889 *Progress = StringPtr - 1;4874 // The input string is not ConfigResp format, return error. 4875 // 4876 if (*StringPtr != 0) { 4877 *Progress = StringPtr; 3890 4878 Status = EFI_INVALID_PARAMETER; 3891 4879 goto Exit; … … 3898 4886 *BlockSize = MaxBlockSize; 3899 4887 if (Block != NULL) { 3900 return EFI_ DEVICE_ERROR;4888 return EFI_BUFFER_TOO_SMALL; 3901 4889 } 3902 4890 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
r48674 r58459 2 2 Implementation for EFI_HII_DATABASE_PROTOCOL. 3 3 4 Copyright (c) 2007 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 2418 2418 // Initialize Variables 2419 2419 // 2420 StringPkgIsAdd = FALSE; 2421 FontPackage = NULL; 2420 StringPkgIsAdd = FALSE; 2421 FontPackage = NULL; 2422 StringPackage = NULL; 2423 GuidPackage = NULL; 2424 FormPackage = NULL; 2425 ImagePackage = NULL; 2426 SimpleFontPackage = NULL; 2427 KeyboardLayoutPackage = NULL; 2422 2428 2423 2429 // … … 2506 2512 return Status; 2507 2513 } 2514 ASSERT (StringPackage != NULL); 2508 2515 Status = InvokeRegisteredFunction ( 2509 2516 Private, … … 3101 3108 3102 3109 @retval EFI_SUCCESS The matching handles are outputed successfully. 3103 3110 HandleBufferLength is updated with the actual length. 3104 3111 @retval EFI_BUFFER_TO_SMALL The HandleBufferLength parameter indicates that 3105 3112 Handle is too small to support the number of … … 3107 3114 value that will enable the data to fit. 3108 3115 @retval EFI_NOT_FOUND No matching handle could not be found in database. 3109 @retval EFI_INVALID_PARAMETER Handle or HandleBufferLength was NULL. 3110 3116 @retval EFI_INVALID_PARAMETER HandleBufferLength was NULL. 3117 @retval EFI_INVALID_PARAMETER The value referenced by HandleBufferLength was not 3118 zero and Handle was NULL. 3111 3119 @retval EFI_INVALID_PARAMETER PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but 3112 3113 3120 PackageGuid is not NULL, PackageType is a EFI_HII_ 3121 PACKAGE_TYPE_GUID but PackageGuid is NULL. 3114 3122 3115 3123 **/ … … 3264 3272 @retval EFI_NOT_FOUND The specifiecd Handle could not be found in the 3265 3273 current database. 3266 @retval EFI_INVALID_PARAMETER Handle or Buffer or BufferSize was NULL. 3274 @retval EFI_INVALID_PARAMETER BufferSize was NULL. 3275 @retval EFI_INVALID_PARAMETER The value referenced by BufferSize was not zero 3276 and Buffer was NULL. 3267 3277 3268 3278 **/ … … 3526 3536 updated with a value that will enable the data to 3527 3537 fit. 3528 @retval EFI_INVALID_PARAMETER The KeyGuidBuffer or KeyGuidBufferLength was NULL. 3538 @retval EFI_INVALID_PARAMETER The KeyGuidBufferLength is NULL. 3539 @retval EFI_INVALID_PARAMETER The value referenced by KeyGuidBufferLength is not 3540 zero and KeyGuidBuffer is NULL. 3529 3541 @retval EFI_NOT_FOUND There was no keyboard layout. 3530 3542 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
r48674 r58459 3 3 4 4 5 Copyright (c) 2007 - 201 2, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 6 This program and the accompanying materials 7 7 are licensed and made available under the terms and conditions of the BSD License … … 758 758 759 759 case EFI_HII_GIBT_EXT1: 760 BlockPtr += *( BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8));760 BlockPtr += *(UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)); 761 761 break; 762 762 case EFI_HII_GIBT_EXT2: 763 763 CopyMem ( 764 764 &Length16, 765 BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8),765 (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)), 766 766 sizeof (UINT16) 767 767 ); … … 771 771 CopyMem ( 772 772 &Length32, 773 BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8),773 (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)), 774 774 sizeof (UINT32) 775 775 ); … … 794 794 if (CharCurrent == CharValue) { 795 795 return WriteOutputParam ( 796 BlockPtr + sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8),796 (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8)), 797 797 BufferLen, 798 798 &LocalCell, … … 1041 1041 } 1042 1042 1043 SystemDefault = NULL; 1044 DefaultLen = 0; 1045 1043 1046 Status = GetSystemFont (Private, &SystemDefault, &DefaultLen); 1044 1047 ASSERT_EFI_ERROR (Status); 1048 ASSERT ((SystemDefault != NULL) && (DefaultLen != 0)); 1045 1049 1046 1050 // … … 1688 1692 1689 1693 if (SysFontFlag) { 1694 ASSERT (SystemDefault != NULL); 1690 1695 FontInfo = NULL; 1691 1696 Height = SystemDefault->FontInfo.FontSize; … … 2369 2374 Language = ""; 2370 2375 } 2371 CurrentLanguage = GetEfiGlobalVariable (L"PlatformLang");2376 GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLanguage, NULL); 2372 2377 BestLanguage = GetBestLanguage ( 2373 2378 SupportedLanguages, … … 2581 2586 Background = StringInfoOut->BackgroundColor; 2582 2587 } else { 2588 ASSERT (SystemDefault != NULL); 2583 2589 Foreground = SystemDefault->ForegroundColor; 2584 2590 Background = SystemDefault->BackgroundColor; … … 2680 2686 returned font handle or points to NULL if there 2681 2687 are no more matching fonts. 2682 @param StringInfoIn Upon entry, points to the font to return 2683 information about. 2684 If NULL, then the information about the system default 2685 font will be returned. 2686 @param StringInfoOut Upon return, contains the matching font's 2687 information. If NULL, then no information is 2688 returned. It's caller's responsibility to free 2689 this buffer. 2688 @param StringInfoIn Upon entry, points to the font to return information 2689 about. If NULL, then the information about the system 2690 default font will be returned. 2691 @param StringInfoOut Upon return, contains the matching font's information. 2692 If NULL, then no information is returned. This buffer 2693 is allocated with a call to the Boot Service AllocatePool(). 2694 It is the caller's responsibility to call the Boot 2695 Service FreePool() when the caller no longer requires 2696 the contents of StringInfoOut. 2690 2697 @param String Points to the string which will be tested to 2691 2698 determine if all characters are available. If … … 2723 2730 } 2724 2731 2732 StringInfoOutLen = 0; 2725 2733 FontInfo = NULL; 2726 2734 SystemDefault = NULL; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
r48674 r58459 66 66 EFI_GUID Guid; 67 67 CHAR16 *Name; 68 EFI_VARSTORE_ID VarStoreId;69 68 UINT16 Size; 69 UINT8 Type; 70 70 LIST_ENTRY BlockEntry; // Link to its Block array 71 71 } IFR_VARSTORAGE_DATA; … … 79 79 UINT8 Scope; 80 80 LIST_ENTRY DefaultValueEntry; // Link to its default value array 81 CHAR16 *Name; 81 82 } IFR_BLOCK_DATA; 82 83 … … 103 104 // Storage types 104 105 // 105 #define EFI_HII_VARSTORE_BUFFER 0 106 #define EFI_HII_VARSTORE_NAME_VALUE 1 107 #define EFI_HII_VARSTORE_EFI_VARIABLE 2 106 #define EFI_HII_VARSTORE_BUFFER 0 107 #define EFI_HII_VARSTORE_NAME_VALUE 1 108 #define EFI_HII_VARSTORE_EFI_VARIABLE 2 109 #define EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER 3 108 110 109 111 #define HII_FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('H', 'S', 'T', 'G') … … 723 725 returned font handle or points to NULL if there 724 726 are no more matching fonts. 725 @param StringInfoIn Upon entry, points to the font to return 726 information about. If NULL, then the information about the system default 727 font will be returned. 728 @param StringInfoOut Upon return, contains the matching font's 729 information. If NULL, then no information is 730 returned. It's caller's responsibility to free 731 this buffer. 727 @param StringInfoIn Upon entry, points to the font to return information 728 about. If NULL, then the information about the system 729 default font will be returned. 730 @param StringInfoOut Upon return, contains the matching font's information. 731 If NULL, then no information is returned. This buffer 732 is allocated with a call to the Boot Service AllocatePool(). 733 It is the caller's responsibility to call the Boot 734 Service FreePool() when the caller no longer requires 735 the contents of StringInfoOut. 732 736 @param String Points to the string which will be tested to 733 737 determine if all characters are available. If … … 737 741 @retval EFI_NOT_FOUND No matching font was found. 738 742 @retval EFI_INVALID_PARAMETER StringInfoIn is NULL. 739 @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.743 @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination. 740 744 @retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the 741 745 request. … … 1002 1006 @retval EFI_NOT_FOUND The string specified by StringId is not 1003 1007 available. 1004 @retval EFI_NOT_FOUND The string specified by StringId is available but 1005 not in the specified language. 1006 The specified PackageList is not in the database. 1007 @retval EFI_INVALID_LANGUAGE - The string specified by StringId is available but 1008 The specified PackageList is not in the database. 1009 @retval EFI_INVALID_LANGUAGE The string specified by StringId is available but 1010 not in the specified language. 1008 1011 @retval EFI_BUFFER_TOO_SMALL The buffer specified by StringSize is too small 1009 1012 to hold the string. 1010 @retval EFI_INVALID_PARAMETER The String or Language or StringSize was NULL. 1013 @retval EFI_INVALID_PARAMETER The Language or StringSize was NULL. 1014 @retval EFI_INVALID_PARAMETER The value referenced by StringSize was not zero 1015 and String was NULL. 1011 1016 @retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the 1012 1017 request. … … 1074 1079 1075 1080 @retval EFI_SUCCESS The languages were returned successfully. 1076 @retval EFI_INVALID_PARAMETER The Languages or LanguagesSize was NULL. 1081 @retval EFI_INVALID_PARAMETER The LanguagesSize was NULL. 1082 @retval EFI_INVALID_PARAMETER The value referenced by LanguagesSize is not zero and Languages is NULL. 1077 1083 @retval EFI_BUFFER_TOO_SMALL The LanguagesSize is too small to hold the list 1078 1084 of supported languages. LanguageSize is updated … … 1115 1121 1116 1122 @retval EFI_SUCCESS Secondary languages were correctly returned. 1117 @retval EFI_INVALID_PARAMETER PrimaryLanguage or SecondaryLanguages or 1118 SecondaryLanguagesSize was NULL. 1123 @retval EFI_INVALID_PARAMETER PrimaryLanguage or SecondaryLanguagesSize was NULL. 1124 @retval EFI_INVALID_PARAMETER The value referenced by SecondaryLanguagesSize is not 1125 zero and SecondaryLanguages is NULL. 1119 1126 @retval EFI_BUFFER_TOO_SMALL The buffer specified by SecondaryLanguagesSize is 1120 1127 too small to hold the returned information. … … 1123 1130 @retval EFI_INVALID_LANGUAGE The language specified by PrimaryLanguage is not 1124 1131 present in the specified package list. 1125 @retval EFI_NOT_FOUND The specified PackageList is not in the Database.1132 @retval EFI_NOT_FOUND The specified PackageList is not in the Database. 1126 1133 1127 1134 **/ … … 1242 1249 1243 1250 @retval EFI_SUCCESS The matching handles are outputed successfully. 1244 1251 HandleBufferLength is updated with the actual length. 1245 1252 @retval EFI_BUFFER_TO_SMALL The HandleBufferLength parameter indicates that 1246 1253 Handle is too small to support the number of … … 1249 1256 @retval EFI_NOT_FOUND No matching handle could not be found in 1250 1257 database. 1251 @retval EFI_INVALID_PARAMETER Handle or HandleBufferLength was NULL. 1252 @retval EFI_INVALID_PARAMETER PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but 1253 PackageGuid is not NULL, PackageType is a EFI_HII_ 1254 PACKAGE_TYPE_GUID but PackageGuid is NULL. 1255 1258 @retval EFI_INVALID_PARAMETER HandleBufferLength was NULL. 1259 @retval EFI_INVALID_PARAMETER The value referenced by HandleBufferLength was not 1260 zero and Handle was NULL. 1261 @retval EFI_INVALID_PARAMETER PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but 1262 PackageGuid is not NULL, PackageType is a EFI_HII_ 1263 PACKAGE_TYPE_GUID but PackageGuid is NULL. 1256 1264 1257 1265 **/ … … 1291 1299 @retval EFI_NOT_FOUND The specifiecd Handle could not be found in the 1292 1300 current database. 1293 @retval EFI_INVALID_PARAMETER Handle or Buffer or BufferSize was NULL. 1301 @retval EFI_INVALID_PARAMETER BufferSize was NULL. 1302 @retval EFI_INVALID_PARAMETER The value referenced by BufferSize was not zero 1303 and Buffer was NULL. 1294 1304 1295 1305 **/ … … 1391 1401 updated with a value that will enable the data to 1392 1402 fit. 1393 @retval EFI_INVALID_PARAMETER The KeyGuidBuffer or KeyGuidBufferLength was 1394 NULL. 1403 @retval EFI_INVALID_PARAMETER The KeyGuidBufferLength is NULL. 1404 @retval EFI_INVALID_PARAMETER The value referenced by KeyGuidBufferLength is not 1405 zero and KeyGuidBuffer is NULL. 1395 1406 @retval EFI_NOT_FOUND There was no keyboard layout. 1396 1407 … … 1547 1558 @param Results Null-terminated Unicode string in 1548 1559 <MultiConfigAltResp> format which has all values 1549 filled in for the names in the Request string.1550 String to be allocated by the called function.1551 De-allocation is up to the caller.1560 filled in for the entirety of the current HII 1561 database. String to be allocated by the called 1562 function. De-allocation is up to the caller. 1552 1563 1553 1564 @retval EFI_SUCCESS The Results string is filled with the values … … 1672 1683 @param BlockSize The length of the Block in units of UINT8. On 1673 1684 input, this is the size of the Block. On output, 1674 if successful, contains the index of the last 1675 modified byte in the Block. 1685 if successful, contains the largest index of the 1686 modified byte in the Block, or the required buffer 1687 size if the Block is not large enough. 1676 1688 @param Progress On return, points to an element of the ConfigResp 1677 1689 string filled in with the offset of the most … … 1698 1710 Progress points at the '&' preceding the first 1699 1711 non-<BlockName>. 1712 @retval EFI_BUFFER_TOO_SMALL Block not large enough. Progress undefined. 1713 BlockSize is updated with the required buffer size. 1700 1714 1701 1715 **/ -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
r48674 r58459 1 1 ## @file 2 # The DXE driver produces HII protocols defined in UEFI HII 2.1 specificatin.2 # The DXE driver produces HII protocols defined in UEFI specification. 3 3 # 4 # Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR> 4 # This driver produces all required HII serivces that includes HiiDataBase, HiiString, 5 # HiiFont, HiiConfigRouting. To support UEFI HII, this driver is required. 6 # 7 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 5 8 # 6 9 # This program and the accompanying materials … … 18 21 INF_VERSION = 0x00010005 19 22 BASE_NAME = HiiDatabase 23 MODULE_UNI_FILE = HiiDatabase.uni 20 24 FILE_GUID = 348C4D62-BFBD-4882-9ECE-C80BB1C4783B 21 25 MODULE_TYPE = DXE_DRIVER … … 59 63 gEfiDevicePathProtocolGuid ## SOMETIMES_CONSUMES 60 64 gEfiHiiStringProtocolGuid ## PRODUCES 61 gEfiHiiImageProtocolGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ##PRODUCES65 gEfiHiiImageProtocolGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_PRODUCES 62 66 gEfiHiiConfigRoutingProtocolGuid ## PRODUCES 63 67 gEfiHiiDatabaseProtocolGuid ## PRODUCES 64 68 gEfiHiiFontProtocolGuid ## PRODUCES 65 gEfiHiiConfigAccessProtocolGuid ## CONSUMES69 gEfiHiiConfigAccessProtocolGuid ## SOMETIMES_CONSUMES 66 70 67 71 [FeaturePcd] 68 gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol 72 gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## CONSUMES 69 73 70 74 [Pcd] 71 gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang 75 gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang ## CONSUMES 72 76 73 77 [Guids] 74 gEfiGlobalVariableGuid ## SOMETIMES_CONSUMES ## Variable:"PlatformLang" 75 ## 78 # 76 79 # Event registered to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group, 77 80 # which will be triggered by EFI_HII_DATABASE_PROTOCOL.SetKeyboardLayout(). 78 ## 79 gEfiHiiKeyBoardLayoutGuid ## SOMETIME_CONSUMES ## Event 81 # 82 ## CONSUMES ## Event 83 ## PRODUCES ## Event 84 gEfiHiiKeyBoardLayoutGuid 80 85 81 86 [Depex] 82 87 TRUE 83 88 89 [UserExtensions.TianoCore."ExtraFiles"] 90 HiiDatabaseExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
r48674 r58459 3 3 4 4 5 Copyright (c) 2007 - 20 08, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 6 This program and the accompanying materials 7 7 are licensed and made available under the terms and conditions of the BSD License … … 80 80 switch (((EFI_HII_IMAGE_BLOCK *) ImageBlock)->BlockType) { 81 81 case EFI_HII_IIBT_EXT1: 82 Length8 = *( ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8));82 Length8 = *(UINT8*)((UINTN)ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8)); 83 83 ImageBlock += Length8; 84 ImageIdCurrent++;85 84 break; 86 85 case EFI_HII_IIBT_EXT2: 87 86 CopyMem ( 88 87 &Length16, 89 ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8),88 (UINT8*)((UINTN)ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8)), 90 89 sizeof (UINT16) 91 90 ); 92 91 ImageBlock += Length16; 93 ImageIdCurrent++;94 92 break; 95 93 case EFI_HII_IIBT_EXT4: 96 94 CopyMem ( 97 95 &Length32, 98 ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8),96 (UINT8*)((UINTN)ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8)), 99 97 sizeof (UINT32) 100 98 ); 101 99 ImageBlock += Length32; 102 ImageIdCurrent++;103 100 break; 104 101 … … 883 880 // 884 881 return EFI_UNSUPPORTED; 885 break;886 882 887 883 case EFI_HII_IIBT_IMAGE_1BIT_TRANS: … … 925 921 Output1bitPixel ( 926 922 Image, 927 (UINT8 *) ( ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK) - sizeof (UINT8)),923 (UINT8 *) ((UINTN)ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK) - sizeof (UINT8)), 928 924 (EFI_HII_IMAGE_PALETTE_INFO *) PaletteInfo 929 925 ); … … 931 927 Output4bitPixel ( 932 928 Image, 933 (UINT8 *) ( ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK) - sizeof (UINT8)),929 (UINT8 *) ((UINTN)ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK) - sizeof (UINT8)), 934 930 (EFI_HII_IMAGE_PALETTE_INFO *) PaletteInfo 935 931 ); … … 937 933 Output8bitPixel ( 938 934 Image, 939 (UINT8 *) ( ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK) - sizeof (UINT8)),935 (UINT8 *) ((UINTN)ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK) - sizeof (UINT8)), 940 936 (EFI_HII_IMAGE_PALETTE_INFO *) PaletteInfo 941 937 ); … … 943 939 944 940 return EFI_SUCCESS; 945 break;946 941 947 942 case EFI_HII_IIBT_IMAGE_24BIT_TRANS: … … 977 972 ); 978 973 return EFI_SUCCESS; 979 break;980 974 981 975 default: 982 976 return EFI_NOT_FOUND; 983 break;984 977 } 985 978 } … … 1088 1081 // 1089 1082 return EFI_UNSUPPORTED; 1090 break;1091 1083 1092 1084 case EFI_HII_IIBT_IMAGE_1BIT: … … 1121 1113 default: 1122 1114 return EFI_NOT_FOUND; 1123 break;1124 1115 } 1125 1116 … … 1247 1238 } 1248 1239 1240 FontInfo = NULL; 1249 1241 ImageIn = (EFI_IMAGE_INPUT *) Image; 1250 1242 … … 1393 1385 return Status; 1394 1386 } 1387 ASSERT (FontInfo != NULL); 1395 1388 for (Index = 0; Index < Width * Height; Index++) { 1396 1389 BltBuffer[Index] = FontInfo->BackgroundColor; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/HiiDatabaseDxe/String.c
r48674 r58459 3 3 4 4 5 Copyright (c) 2007 - 201 1, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 6 This program and the accompanying materials 7 7 are licensed and made available under the terms and conditions of the BSD License … … 336 336 case EFI_HII_SIBT_STRINGS_SCSU: 337 337 CopyMem (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16)); 338 StringTextPtr = BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_BLOCK) - sizeof (UINT8);338 StringTextPtr = (UINT8*)((UINTN)BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_BLOCK) - sizeof (UINT8)); 339 339 BlockSize += StringTextPtr - BlockHdr; 340 340 … … 356 356 CopyMem ( 357 357 &StringCount, 358 BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),358 (UINT8*)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 359 359 sizeof (UINT16) 360 360 ); 361 StringTextPtr = BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK) - sizeof (UINT8);361 StringTextPtr = (UINT8*)((UINTN)BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK) - sizeof (UINT8)); 362 362 BlockSize += StringTextPtr - BlockHdr; 363 363 … … 426 426 CopyMem ( 427 427 &StringCount, 428 BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),428 (UINT8*)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 429 429 sizeof (UINT16) 430 430 ); … … 466 466 467 467 case EFI_HII_SIBT_SKIP1: 468 SkipCount = (UINT16) (*( BlockHdr + sizeof (EFI_HII_STRING_BLOCK)));468 SkipCount = (UINT16) (*(UINT8*)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK))); 469 469 CurrentStringId = (UINT16) (CurrentStringId + SkipCount); 470 470 BlockSize += sizeof (EFI_HII_SIBT_SKIP1_BLOCK); … … 480 480 CopyMem ( 481 481 &Length8, 482 BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),482 (UINT8*)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 483 483 sizeof (UINT8) 484 484 ); … … 495 495 BlockHdr += sizeof (EFI_HII_SIBT_EXT2_BLOCK); 496 496 CopyMem (&FontId, BlockHdr, sizeof (UINT8)); 497 BlockHdr + = sizeof (UINT8);497 BlockHdr ++; 498 498 CopyMem (&FontSize, BlockHdr, sizeof (UINT16)); 499 499 BlockHdr += sizeof (UINT16); … … 536 536 CopyMem ( 537 537 &Length32, 538 BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8),538 (UINT8*)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 539 539 sizeof (UINT32) 540 540 ); … … 900 900 901 901 StartStringId = 0; 902 StringSize = 0; 902 903 ASSERT (Private != NULL && StringPackage != NULL && String != NULL); 903 904 ASSERT (Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE); … … 1080 1081 1081 1082 *BlockPtr = LocalFont->FontId; 1082 BlockPtr + = sizeof (UINT8);1083 BlockPtr ++; 1083 1084 CopyMem (BlockPtr, &GlobalFont->FontInfo->FontSize, sizeof (UINT16)); 1084 1085 BlockPtr += sizeof (UINT16); … … 1442 1443 BlockPtr += sizeof (EFI_HII_STRING_BLOCK); 1443 1444 *BlockPtr = LocalFont->FontId; 1444 BlockPtr += sizeof (UINT8);1445 BlockPtr ++; 1445 1446 CopyMem (BlockPtr, (EFI_STRING) String, StrSize ((EFI_STRING) String)); 1446 1447 BlockPtr += StrSize ((EFI_STRING) String); … … 1486 1487 1487 1488 *BlockPtr = LocalFont->FontId; 1488 BlockPtr + = sizeof (UINT8);1489 BlockPtr ++; 1489 1490 CopyMem (BlockPtr, &((EFI_FONT_INFO *) StringFontInfo)->FontSize, sizeof (UINT16)); 1490 1491 BlockPtr += sizeof (UINT16); … … 1503 1504 BlockPtr += sizeof (EFI_HII_STRING_BLOCK); 1504 1505 *BlockPtr = LocalFont->FontId; 1505 BlockPtr + = sizeof (UINT8);1506 BlockPtr ++; 1506 1507 CopyMem (BlockPtr, (EFI_STRING) String, StrSize ((EFI_STRING) String)); 1507 1508 BlockPtr += StrSize ((EFI_STRING) String); … … 1590 1591 @retval EFI_BUFFER_TOO_SMALL The buffer specified by StringSize is too small to 1591 1592 hold the string. 1592 @retval EFI_INVALID_PARAMETER The String or Language or StringSize was NULL. 1593 @retval EFI_INVALID_PARAMETER The Language or StringSize was NULL. 1594 @retval EFI_INVALID_PARAMETER The value referenced by StringSize was not zero and String was NULL. 1593 1595 @retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the 1594 1596 request. … … 1775 1777 1776 1778 @retval EFI_SUCCESS The languages were returned successfully. 1777 @retval EFI_INVALID_PARAMETER The Languages or LanguagesSize was NULL. 1779 @retval EFI_INVALID_PARAMETER The LanguagesSize was NULL. 1780 @retval EFI_INVALID_PARAMETER The value referenced by LanguagesSize is not zero and Languages is NULL. 1778 1781 @retval EFI_BUFFER_TOO_SMALL The LanguagesSize is too small to hold the list of 1779 1782 supported languages. LanguageSize is updated to … … 1799 1802 UINTN ResultSize; 1800 1803 1801 if (This == NULL || Languages == NULL || LanguagesSize == NULL || PackageList == NULL) { 1804 if (This == NULL || LanguagesSize == NULL || PackageList == NULL) { 1805 return EFI_INVALID_PARAMETER; 1806 } 1807 if (*LanguagesSize != 0 && Languages == NULL) { 1802 1808 return EFI_INVALID_PARAMETER; 1803 1809 } … … 1871 1877 1872 1878 @retval EFI_SUCCESS Secondary languages were correctly returned. 1873 @retval EFI_INVALID_PARAMETER PrimaryLanguage or SecondaryLanguages or 1874 SecondaryLanguagesSize was NULL. 1879 @retval EFI_INVALID_PARAMETER PrimaryLanguage or SecondaryLanguagesSize was NULL. 1880 @retval EFI_INVALID_PARAMETER The value referenced by SecondaryLanguagesSize is not 1881 zero and SecondaryLanguages is NULL. 1875 1882 @retval EFI_BUFFER_TOO_SMALL The buffer specified by SecondaryLanguagesSize is 1876 1883 too small to hold the returned information. … … 1879 1886 @retval EFI_INVALID_LANGUAGE The language specified by PrimaryLanguage is not 1880 1887 present in the specified package list. 1881 @retval EFI_NOT_FOUND The specified PackageList is not in the Database. 1888 @retval EFI_NOT_FOUND The specified PackageList is not in the Database. 1882 1889 1883 1890 **/ … … 1901 1908 UINTN ResultSize; 1902 1909 1903 if (This == NULL || PackageList == NULL || PrimaryLanguage == NULL ) {1910 if (This == NULL || PackageList == NULL || PrimaryLanguage == NULL || SecondaryLanguagesSize == NULL) { 1904 1911 return EFI_INVALID_PARAMETER; 1905 1912 } 1906 if (SecondaryLanguages == NULL || SecondaryLanguagesSize == NULL) {1913 if (SecondaryLanguages == NULL && *SecondaryLanguagesSize != 0) { 1907 1914 return EFI_INVALID_PARAMETER; 1908 1915 }
Note:
See TracChangeset
for help on using the changeset viewer.