MdeModulePkg Pcd DXE: Handle the case gPcdDataBaseHobGuid HOB is not present.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15027 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Star Zeng 2013-12-29 07:14:57 +00:00 committed by lzeng14
parent b8b86ec6e0
commit efd6b412c6
2 changed files with 24 additions and 17 deletions

View File

@ -231,7 +231,7 @@ DxeGetPcdInfoGetSku (
VOID VOID
) )
{ {
return mPcdDatabase.PeiDb->SystemSkuId; return mPcdDatabase.DxeDb->SystemSkuId;
} }
/** /**
@ -261,7 +261,7 @@ DxePcdSetSku (
IN UINTN SkuId IN UINTN SkuId
) )
{ {
mPcdDatabase.PeiDb->SystemSkuId = (SKU_ID) SkuId; mPcdDatabase.DxeDb->SystemSkuId = (SKU_ID) SkuId;
return; return;
} }

View File

@ -774,6 +774,18 @@ BuildPcdDxeDataBase (
UINT32 PcdDxeDbLen; UINT32 PcdDxeDbLen;
VOID *PcdDxeDb; VOID *PcdDxeDb;
//
// Assign PCD Entries with default value to PCD DATABASE
//
mPcdDatabase.DxeDb = LocateExPcdBinary ();
ASSERT(mPcdDatabase.DxeDb != NULL);
PcdDxeDbLen = mPcdDatabase.DxeDb->Length + mPcdDatabase.DxeDb->UninitDataBaseSize;
PcdDxeDb = AllocateZeroPool (PcdDxeDbLen);
ASSERT (PcdDxeDb != NULL);
CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length);
FreePool (mPcdDatabase.DxeDb);
mPcdDatabase.DxeDb = PcdDxeDb;
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
if (GuidHob != NULL) { if (GuidHob != NULL) {
@ -789,20 +801,15 @@ BuildPcdDxeDataBase (
// Assign PCD Entries refereneced in PEI phase to PCD DATABASE // Assign PCD Entries refereneced in PEI phase to PCD DATABASE
// //
mPcdDatabase.PeiDb = PeiDatabase; mPcdDatabase.PeiDb = PeiDatabase;
//
// Inherit the SystemSkuId from PEI phase.
//
mPcdDatabase.DxeDb->SystemSkuId = mPcdDatabase.PeiDb->SystemSkuId;
} else {
mPcdDatabase.PeiDb = AllocateZeroPool (sizeof (PEI_PCD_DATABASE));
ASSERT(mPcdDatabase.PeiDb != NULL);
} }
//
// Assign PCD Entries with default value to PCD DATABASE
//
mPcdDatabase.DxeDb = LocateExPcdBinary ();
ASSERT(mPcdDatabase.DxeDb != NULL);
PcdDxeDbLen = mPcdDatabase.DxeDb->Length + mPcdDatabase.DxeDb->UninitDataBaseSize;
PcdDxeDb = AllocateZeroPool (PcdDxeDbLen);
ASSERT (PcdDxeDb != NULL);
CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length);
FreePool (mPcdDatabase.DxeDb);
mPcdDatabase.DxeDb = PcdDxeDb;
// //
// Initialized the external PCD database local variables // Initialized the external PCD database local variables
// //
@ -945,7 +952,7 @@ GetSkuEnabledTokenNumber (
// //
FoundSku = FALSE; FoundSku = FALSE;
for (Index = 0; Index < SkuIdTable[0]; Index++) { for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (mPcdDatabase.PeiDb->SystemSkuId == SkuIdTable[Index + 1]) { if (mPcdDatabase.DxeDb->SystemSkuId == SkuIdTable[Index + 1]) {
FoundSku = TRUE; FoundSku = TRUE;
break; break;
} }
@ -1704,7 +1711,7 @@ GetPtrTypeSize (
// //
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb); SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
for (Index = 0; Index < SkuIdTable[0]; Index++) { for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuIdTable[1 + Index] == mPcdDatabase.PeiDb->SystemSkuId) { if (SkuIdTable[1 + Index] == mPcdDatabase.DxeDb->SystemSkuId) {
return SizeTable[SizeTableIdx + 1 + Index]; return SizeTable[SizeTableIdx + 1 + Index];
} }
} }
@ -1794,7 +1801,7 @@ SetPtrTypeSize (
// //
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb); SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
for (Index = 0; Index < SkuIdTable[0]; Index++) { for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuIdTable[1 + Index] == mPcdDatabase.PeiDb->SystemSkuId) { if (SkuIdTable[1 + Index] == mPcdDatabase.DxeDb->SystemSkuId) {
SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize; SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;
return TRUE; return TRUE;
} }