UefiPayloadPkg: Fix up UPL Pcd database
Edk2 bootloader will pass the pei pcd database, and UPL also contain a PCD database. Dxe PCD driver has the assumption that the two PCD database can be catenated and the local token number should be successive。 This patch will manually fix up the UPL PCD database to meet that assumption. Cc: Maurice Ma <maurice.ma@intel.com> Cc: Guo Dong <guo.dong@intel.com> Cc: Benjamin You <benjamin.you@intel.com> Reviewed-by: Guo Dong <guo.dong@intel.com> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
b208d37c73
commit
27cb64fffc
@@ -25,6 +25,62 @@
|
||||
|
||||
extern VOID *mHobList;
|
||||
|
||||
/**
|
||||
Some bootloader may pass a pcd database, and UPL also contain a PCD database.
|
||||
Dxe PCD driver has the assumption that the two PCD database can be catenated and
|
||||
the local token number should be successive。
|
||||
This function will fix up the UPL PCD database to meet that assumption.
|
||||
|
||||
@param[in] DxeFv The FV where to find the Universal PCD database.
|
||||
|
||||
@retval EFI_SUCCESS If it completed successfully.
|
||||
@retval other Failed to fix up.
|
||||
**/
|
||||
EFI_STATUS
|
||||
FixUpPcdDatabase (
|
||||
IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FFS_FILE_HEADER *FileHeader;
|
||||
VOID *PcdRawData;
|
||||
PEI_PCD_DATABASE *PeiDatabase;
|
||||
PEI_PCD_DATABASE *UplDatabase;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
DYNAMICEX_MAPPING *ExMapTable;
|
||||
UINTN Index;
|
||||
|
||||
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
|
||||
if (GuidHob == NULL) {
|
||||
//
|
||||
// No fix-up is needed.
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
|
||||
DEBUG ((DEBUG_INFO, "Find the Pei PCD data base, the total local token number is %d\n", PeiDatabase->LocalTokenCount));
|
||||
|
||||
Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DRIVER, PcdGetPtr (PcdPcdDriverFile), &FileHeader);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
Status = FileFindSection (FileHeader, EFI_SECTION_RAW, &PcdRawData);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
UplDatabase = (PEI_PCD_DATABASE *) PcdRawData;
|
||||
ExMapTable = (DYNAMICEX_MAPPING *) (UINTN) ((UINTN) PcdRawData + UplDatabase->ExMapTableOffset);
|
||||
|
||||
for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) {
|
||||
ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount;
|
||||
}
|
||||
DEBUG ((DEBUG_INFO, "Fix up UPL PCD database successfully\n"));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Add HOB into HOB list
|
||||
|
||||
@@ -327,6 +383,7 @@ _ModuleEntryPoint (
|
||||
Status = BuildHobs (BootloaderParameter, &DxeFv);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
FixUpPcdDatabase (DxeFv);
|
||||
Status = UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
Reference in New Issue
Block a user