VirtualBox

Ignore:
Timestamp:
Mar 31, 2025 11:31:09 AM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168237
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c

    r99404 r108794  
    13701370  //
    13711371  return SupportedLanguages;
     1372}
     1373
     1374/**
     1375  This function create a new string in String Package or updates an existing
     1376  string in a String Package.  If StringId is 0, then a new string is added to
     1377  a String Package.  If StringId is not zero, then a string in String Package is
     1378  updated.  If SupportedLanguages is NULL, then the string is added or updated
     1379  for all the languages that the String Package supports.  If SupportedLanguages
     1380  is not NULL, then the string is added or updated for the set of languages
     1381  specified by SupportedLanguages.
     1382
     1383  If HiiHandle is NULL, then ASSERT().
     1384  If String is NULL, then ASSERT().
     1385
     1386  @param[in]  HiiHandle           A handle that was previously registered in the
     1387                                  HII Database.
     1388  @param[in]  StringId            If zero, then a new string is created in the
     1389                                  String Package associated with HiiHandle.  If
     1390                                  non-zero, then the string specified by StringId
     1391                                  is updated in the String Package  associated
     1392                                  with HiiHandle.
     1393  @param[in]  String              A pointer to the Null-terminated Unicode string
     1394                                  to add or update in the String Package associated
     1395                                  with HiiHandle.
     1396  @param[in]  SupportedLanguages  A pointer to a Null-terminated ASCII string of
     1397                                  language codes.  If this parameter is NULL, then
     1398                                  String is added or updated in the String Package
     1399                                  associated with HiiHandle for all the languages
     1400                                  that the String Package supports.  If this
     1401                                  parameter is not NULL, then then String is added
     1402                                  or updated in the String Package associated with
     1403                                  HiiHandle for the set oflanguages specified by
     1404                                  SupportedLanguages.  The format of
     1405                                  SupportedLanguages must follow the language
     1406                                  format assumed the HII Database.
     1407
     1408  @retval 0      The string could not be added or updated in the String Package.
     1409  @retval Other  The EFI_STRING_ID of the newly added or updated string.
     1410
     1411**/
     1412EFI_STRING_ID
     1413InternalHiiSetString (
     1414  IN EFI_HII_HANDLE    HiiHandle,
     1415  IN EFI_STRING_ID     StringId             OPTIONAL,
     1416  IN CONST EFI_STRING  String,
     1417  IN CONST CHAR8       *SupportedLanguages  OPTIONAL
     1418  )
     1419{
     1420  EFI_STATUS  Status;
     1421  CHAR8       *AllocatedLanguages;
     1422  CHAR8       *Supported;
     1423  CHAR8       *Language;
     1424
     1425  ASSERT (HiiHandle != NULL);
     1426
     1427  if (SupportedLanguages == NULL) {
     1428    //
     1429    // Retrieve the languages that the package specified by HiiHandle supports
     1430    //
     1431    AllocatedLanguages = GetSupportedLanguages (HiiHandle);
     1432  } else {
     1433    //
     1434    // Allocate a copy of the SupportLanguages string that passed in
     1435    //
     1436    AllocatedLanguages = AllocateCopyPool (AsciiStrSize (SupportedLanguages), SupportedLanguages);
     1437  }
     1438
     1439  //
     1440  // If there are not enough resources for the supported languages string, then return a StringId of 0
     1441  //
     1442  if (AllocatedLanguages == NULL) {
     1443    return (EFI_STRING_ID)(0);
     1444  }
     1445
     1446  Status = EFI_INVALID_PARAMETER;
     1447  //
     1448  // Loop through each language that the string supports
     1449  //
     1450  for (Supported = AllocatedLanguages; *Supported != '\0'; ) {
     1451    //
     1452    // Cache a pointer to the beginning of the current language in the list of languages
     1453    //
     1454    Language = Supported;
     1455
     1456    //
     1457    // Search for the next language separator and replace it with a Null-terminator
     1458    //
     1459    for ( ; *Supported != 0 && *Supported != ';'; Supported++) {
     1460    }
     1461
     1462    if (*Supported != 0) {
     1463      *(Supported++) = '\0';
     1464    }
     1465
     1466    if ((SupportedLanguages == NULL) && (AsciiStrnCmp (Language, UEFI_CONFIG_LANG, AsciiStrLen (UEFI_CONFIG_LANG)) == 0)) {
     1467      //
     1468      // Skip string package used for keyword protocol.
     1469      //
     1470      continue;
     1471    }
     1472
     1473    //
     1474    // If StringId is 0, then call NewString().  Otherwise, call SetString()
     1475    //
     1476    if (StringId == (EFI_STRING_ID)(0)) {
     1477      Status = mPrivate.HiiString.NewString (
     1478                                    &mPrivate.HiiString,
     1479                                    HiiHandle,
     1480                                    &StringId,
     1481                                    Language,
     1482                                    NULL,
     1483                                    String,
     1484                                    NULL
     1485                                    );
     1486    } else {
     1487      Status = mPrivate.HiiString.SetString (
     1488                                    &mPrivate.HiiString,
     1489                                    HiiHandle,
     1490                                    StringId,
     1491                                    Language,
     1492                                    String,
     1493                                    NULL
     1494                                    );
     1495    }
     1496
     1497    //
     1498    // If there was an error, then break out of the loop and return a StringId of 0
     1499    //
     1500    if (EFI_ERROR (Status)) {
     1501      break;
     1502    }
     1503  }
     1504
     1505  //
     1506  // Free the buffer of supported languages
     1507  //
     1508  FreePool (AllocatedLanguages);
     1509
     1510  if (EFI_ERROR (Status)) {
     1511    return (EFI_STRING_ID)(0);
     1512  } else {
     1513    return StringId;
     1514  }
    13721515}
    13731516
     
    22032346  BOOLEAN                      FromOtherDefaultOpcode;
    22042347  BOOLEAN                      QuestionReferBitField;
     2348  UINT16                       *StringData;
    22052349
    22062350  Status           = EFI_SUCCESS;
     
    22162360  QuestionReferBitField  = FALSE;
    22172361  IfrEfiVarStoreTmp      = NULL;
     2362  StringData             = NULL;
    22182363
    22192364  //
     
    28703015
    28713016          goto Done;
     3017        }
     3018
     3019        if (IfrEfiVarStoreTmp == NULL) {
     3020          break;
     3021        }
     3022
     3023        //
     3024        // Set default value base on the DefaultId list get from IFR data.
     3025        //
     3026        NvDefaultStoreSize = PcdGetSize (PcdNvStoreDefaultValueBuffer);
     3027        for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) {
     3028          DefaultDataPtr        = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry);
     3029          DefaultData.DefaultId = DefaultDataPtr->DefaultId;
     3030          if (NvDefaultStoreSize > sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER)) {
     3031            StringData = AllocateZeroPool (VarWidth*2);
     3032            if (StringData == NULL) {
     3033              Status = EFI_OUT_OF_RESOURCES;
     3034              goto Done;
     3035            }
     3036
     3037            FindQuestionDefaultSetting (DefaultData.DefaultId, IfrEfiVarStoreTmp, &(IfrString->Question), (VOID *)StringData, VarWidth, QuestionReferBitField);
     3038            if ((DefaultData.Value.string != 0) && (StringData != NULL)) {
     3039              DefaultData.Value.string = InternalHiiSetString (HiiHandle, 0, StringData, NULL);
     3040              InsertDefaultValue (BlockData, &DefaultData);
     3041              FreePool (StringData);
     3042            }
     3043          }
    28723044        }
    28733045
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette