MdeModulePkg: Update PCD driver to support the optimized PcdDataBase

https://bugzilla.tianocore.org/show_bug.cgi?id=546
BaseTools will generate the optimized PCD database to save the image size
at build time for multiple SKUs. The optimized PCD database layout will be like
below, the PCD database will be composed of the full default SKU data
(PCD_DATABASE_INIT) and the non-default SKU delta data(PCD_DATABASE_SKU_DELTA).
PCD driver will build HOB to store the full default SKU data, and patch HOB
data based on non-default SKU delta data for the SKU set by SetSku(),
it can save memory resource at boot time.

//
// PCD database layout:
// +---------------------------------+
// | PCD_DATABASE_INIT (DEFAULT SKU) |
// +---------------------------------+
// | PCD_DATABASE_SKU_DELTA (SKU A)  |
// +---------------------------------+
// | PCD_DATABASE_SKU_DELTA (SKU B)  |
// +---------------------------------+
// | ......                          |
// +---------------------------------+
//

BaseTools, PCD database and driver updates are needed for this proposal.
For single SKU (default) case, this proposal is expected to have no impact.
For multi-SKU case, PCD database format will be changed.
So, PcdDataBase Version is also updated from 6 to 7.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Liming Gao 2017-12-22 13:41:54 +08:00
parent 219247e164
commit 7c73626513
8 changed files with 346 additions and 460 deletions

View File

@ -61,11 +61,6 @@ typedef struct {
UINT16 ExGuidIndex; // Index of GuidTable in units of GUID. UINT16 ExGuidIndex; // Index of GuidTable in units of GUID.
} DYNAMICEX_MAPPING; } DYNAMICEX_MAPPING;
typedef struct {
UINT32 SkuDataStartOffset; // Offset(with DATUM TYPE info) from the PCD_DB.
UINT32 SkuIdTableOffset; // Offset from the PCD_DB.
} SKU_HEAD;
typedef struct { typedef struct {
UINT32 StringIndex; // Offset in String Table in units of UINT8. UINT32 StringIndex; // Offset in String Table in units of UINT8.
UINT32 DefaultValueOffset; // Offset of the Default Value. UINT32 DefaultValueOffset; // Offset of the Default Value.
@ -94,8 +89,9 @@ typedef UINT32 TABLE_OFFSET;
typedef struct { typedef struct {
GUID Signature; // PcdDataBaseGuid. GUID Signature; // PcdDataBaseGuid.
UINT32 BuildVersion; UINT32 BuildVersion;
UINT32 Length; UINT32 Length; // Length of DEFAULT SKU PCD DB
SKU_ID SystemSkuId; // Current SkuId value. SKU_ID SystemSkuId; // Current SkuId value.
UINT32 LengthForAllSkus; // Length of all SKU PCD DB
UINT32 UninitDataBaseSize; // Total size for PCD those default value with 0. UINT32 UninitDataBaseSize; // Total size for PCD those default value with 0.
TABLE_OFFSET LocalTokenNumberTableOffset; TABLE_OFFSET LocalTokenNumberTableOffset;
TABLE_OFFSET ExMapTableOffset; TABLE_OFFSET ExMapTableOffset;
@ -107,7 +103,7 @@ typedef struct {
UINT16 LocalTokenCount; // LOCAL_TOKEN_NUMBER for all. UINT16 LocalTokenCount; // LOCAL_TOKEN_NUMBER for all.
UINT16 ExTokenCount; // EX_TOKEN_NUMBER for DynamicEx. UINT16 ExTokenCount; // EX_TOKEN_NUMBER for DynamicEx.
UINT16 GuidTableCount; // The Number of Guid in GuidTable. UINT16 GuidTableCount; // The Number of Guid in GuidTable.
UINT8 Pad[2]; // Pad bytes to satisfy the alignment. UINT8 Pad[6]; // Pad bytes to satisfy the alignment.
// //
// Default initialized external PCD database binary structure // Default initialized external PCD database binary structure
@ -115,7 +111,6 @@ typedef struct {
// Padding is needed to keep necessary alignment // Padding is needed to keep necessary alignment
// //
//SKU_ID SkuIdTable[]; // SkuIds system supports. //SKU_ID SkuIdTable[]; // SkuIds system supports.
//SKU_ID SkuIndexTable[]; // SkuIds for each PCD with SKU enable.
//UINT64 ValueUint64[]; //UINT64 ValueUint64[];
//UINT32 ValueUint32[]; //UINT32 ValueUint32[];
//VPD_HEAD VpdHead[]; // VPD Offset //VPD_HEAD VpdHead[]; // VPD Offset
@ -125,7 +120,6 @@ typedef struct {
//STRING_HEAD StringHead[]; // String PCD //STRING_HEAD StringHead[]; // String PCD
//PCD_NAME_INDEX PcdNameTable[]; // PCD name index info. It can be accessed by the PcdNameTableOffset. //PCD_NAME_INDEX PcdNameTable[]; // PCD name index info. It can be accessed by the PcdNameTableOffset.
//VARIABLE_HEAD VariableHead[]; // HII PCD //VARIABLE_HEAD VariableHead[]; // HII PCD
//SKU_HEAD SkuHead[]; // Store SKU info for each PCD with SKU enable.
//UINT8 StringTable[]; // String for String PCD value and HII PCD Variable Name. It can be accessed by StringTableOffset. //UINT8 StringTable[]; // String for String PCD value and HII PCD Variable Name. It can be accessed by StringTableOffset.
//SIZE_INFO SizeTable[]; // MaxSize and CurSize for String PCD. It can be accessed by SizeTableOffset. //SIZE_INFO SizeTable[]; // MaxSize and CurSize for String PCD. It can be accessed by SizeTableOffset.
//UINT16 ValueUint16[]; //UINT16 ValueUint16[];
@ -216,4 +210,26 @@ typedef struct {
// +-------------------------------------+ // +-------------------------------------+
// //
#pragma pack(1)
typedef struct {
SKU_ID SkuId;
SKU_ID SkuIdCompared;
UINT32 Length;
// PCD_DATA_DELTA DeltaData[]
} PCD_DATABASE_SKU_DELTA;
//
// PCD database layout:
// +---------------------------------+
// | PCD_DATABASE_INIT (DEFAULT SKU) |
// +---------------------------------+
// | PCD_DATABASE_SKU_DELTA (SKU A) |
// +---------------------------------+
// | PCD_DATABASE_SKU_DELTA (SKU B) |
// +---------------------------------+
// | ...... |
// +---------------------------------+
//
#pragma pack()
#endif #endif

View File

@ -271,6 +271,7 @@ DxePcdSetSku (
{ {
SKU_ID *SkuIdTable; SKU_ID *SkuIdTable;
UINTN Index; UINTN Index;
EFI_STATUS Status;
if (SkuId == mPcdDatabase.DxeDb->SystemSkuId) { if (SkuId == mPcdDatabase.DxeDb->SystemSkuId) {
// //
@ -294,16 +295,19 @@ DxePcdSetSku (
SkuIdTable = (SKU_ID *) ((UINT8 *) mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SkuIdTableOffset); SkuIdTable = (SKU_ID *) ((UINT8 *) mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SkuIdTableOffset);
for (Index = 0; Index < SkuIdTable[0]; Index++) { for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuId == SkuIdTable[Index + 1]) { if (SkuId == SkuIdTable[Index + 1]) {
DEBUG ((EFI_D_INFO, "PcdDxe - Set current SKU Id to 0x%lx.\n", (SKU_ID) SkuId)); Status = UpdatePcdDatabase (SkuId, TRUE);
if (!EFI_ERROR (Status)) {
mPcdDatabase.DxeDb->SystemSkuId = (SKU_ID) SkuId; mPcdDatabase.DxeDb->SystemSkuId = (SKU_ID) SkuId;
DEBUG ((DEBUG_INFO, "PcdDxe - Set current SKU Id to 0x%lx.\n", (SKU_ID) SkuId));
return; return;
} }
} }
}
// //
// Invalid input SkuId, the default SKU Id will be still used for the system. // Invalid input SkuId, the default SKU Id will be still used for the system.
// //
DEBUG ((EFI_D_INFO, "PcdDxe - Invalid input SkuId, the default SKU Id will be still used.\n")); DEBUG ((DEBUG_INFO, "PcdDxe - Invalid input SkuId, the default SKU Id will be still used.\n"));
return; return;
} }

View File

@ -37,6 +37,11 @@ LIST_ENTRY *mCallbackFnTable;
EFI_GUID **TmpTokenSpaceBuffer; EFI_GUID **TmpTokenSpaceBuffer;
UINTN TmpTokenSpaceBufferCount; UINTN TmpTokenSpaceBufferCount;
UINTN mPeiPcdDbSize = 0;
PEI_PCD_DATABASE *mPeiPcdDbBinary = NULL;
UINTN mDxePcdDbSize = 0;
DXE_PCD_DATABASE *mDxePcdDbBinary = NULL;
/** /**
Get Local Token Number by Token Number. Get Local Token Number by Token Number.
@ -52,11 +57,7 @@ GetLocalTokenNumber (
IN UINTN TokenNumber IN UINTN TokenNumber
) )
{ {
UINTN TmpTokenNumber;
UINT32 *LocalTokenNumberTable; UINT32 *LocalTokenNumberTable;
UINT32 LocalTokenNumber;
UINTN Size;
UINTN MaxSize;
// //
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER. // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
@ -65,29 +66,11 @@ GetLocalTokenNumber (
// //
TokenNumber--; TokenNumber--;
//
// Backup the TokenNumber passed in as GetPtrTypeSize need the original TokenNumber
//
TmpTokenNumber = TokenNumber;
LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) :
(UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset); (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
TokenNumber = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount; TokenNumber = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount;
LocalTokenNumber = LocalTokenNumberTable[TokenNumber]; return LocalTokenNumberTable[TokenNumber];
Size = (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (Size == 0) {
GetPtrTypeSize (TmpTokenNumber, &MaxSize);
} else {
MaxSize = Size;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);
}
return LocalTokenNumber;
} }
/** /**
@ -753,11 +736,8 @@ LocateExPcdBinary (
VOID VOID
) )
{ {
DXE_PCD_DATABASE *DxePcdDbBinary;
UINTN DxePcdDbSize;
EFI_STATUS Status; EFI_STATUS Status;
DxePcdDbBinary = NULL;
// //
// Search the External Pcd database from one section of current FFS, // Search the External Pcd database from one section of current FFS,
// and read it to memory // and read it to memory
@ -765,20 +745,95 @@ LocateExPcdBinary (
Status = GetSectionFromFfs ( Status = GetSectionFromFfs (
EFI_SECTION_RAW, EFI_SECTION_RAW,
0, 0,
(VOID **) &DxePcdDbBinary, (VOID **) &mDxePcdDbBinary,
&DxePcdDbSize &mDxePcdDbSize
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Check the first bytes (Header Signature Guid) and build version. // Check the first bytes (Header Signature Guid) and build version.
// //
if (!CompareGuid ((VOID *)DxePcdDbBinary, &gPcdDataBaseSignatureGuid) || if (!CompareGuid ((VOID *)mDxePcdDbBinary, &gPcdDataBaseSignatureGuid) ||
(DxePcdDbBinary->BuildVersion != PCD_SERVICE_DXE_VERSION)) { (mDxePcdDbBinary->BuildVersion != PCD_SERVICE_DXE_VERSION)) {
ASSERT (FALSE); ASSERT (FALSE);
} }
return DxePcdDbBinary; return mDxePcdDbBinary;
}
/**
Update PCD database base on current SkuId
@param SkuId Current SkuId
@param IsPeiDb Whether to update PEI PCD database.
@retval EFI_SUCCESS Update PCD database successfully.
@retval EFI_NOT_FOUND Not found PCD database for current SkuId.
**/
EFI_STATUS
UpdatePcdDatabase (
IN SKU_ID SkuId,
IN BOOLEAN IsPeiDb
)
{
UINTN Index;
PCD_DATABASE_SKU_DELTA *SkuDelta;
PCD_DATA_DELTA *SkuDeltaData;
if (IsPeiDb && mPeiPcdDbBinary != NULL) {
//
// Find the delta data for PEI DB
//
Index = (mPcdDatabase.PeiDb->Length + 7) & (~7);
SkuDelta = NULL;
while (Index < mPeiPcdDbSize) {
SkuDelta = (PCD_DATABASE_SKU_DELTA *) ((UINT8 *) mPeiPcdDbBinary + Index);
if (SkuDelta->SkuId == (UINT16) SkuId && SkuDelta->SkuIdCompared == 0) {
break;
}
Index = (Index + SkuDelta->Length + 7) & (~7);
}
//
// Patch the delta data into current PCD database
//
if (Index < mPeiPcdDbSize && SkuDelta != NULL) {
SkuDeltaData = (PCD_DATA_DELTA *) (SkuDelta + 1);
while ((UINT8 *) SkuDeltaData < (UINT8 *) SkuDelta + SkuDelta->Length) {
*((UINT8 *) mPcdDatabase.PeiDb + SkuDeltaData->Offset) = (UINT8) SkuDeltaData->Value;
SkuDeltaData ++;
}
} else {
return EFI_NOT_FOUND;
}
}
//
// Find the delta data for DXE DB
//
Index = (mPcdDatabase.DxeDb->Length + 7) & (~7);
SkuDelta = NULL;
while (Index < mDxePcdDbSize) {
SkuDelta = (PCD_DATABASE_SKU_DELTA *) ((UINT8 *) mDxePcdDbBinary + Index);
if (SkuDelta->SkuId == SkuId && SkuDelta->SkuIdCompared == 0) {
break;
}
Index = (Index + SkuDelta->Length + 7) & (~7);
}
//
// Patch the delta data into current PCD database
//
if (Index < mDxePcdDbSize && SkuDelta != NULL) {
SkuDeltaData = (PCD_DATA_DELTA *) (SkuDelta + 1);
while ((UINT8 *) SkuDeltaData < (UINT8 *) SkuDelta + SkuDelta->Length) {
*((UINT8 *) mPcdDatabase.DxeDb + SkuDeltaData->Offset) = (UINT8) SkuDeltaData->Value;
SkuDeltaData ++;
}
return EFI_SUCCESS;
}
return EFI_NOT_FOUND;
} }
/** /**
@ -798,6 +853,7 @@ BuildPcdDxeDataBase (
UINTN Index; UINTN Index;
UINT32 PcdDxeDbLen; UINT32 PcdDxeDbLen;
VOID *PcdDxeDb; VOID *PcdDxeDb;
EFI_STATUS Status;
// //
// Assign PCD Entries with default value to PCD DATABASE // Assign PCD Entries with default value to PCD DATABASE
@ -808,7 +864,6 @@ BuildPcdDxeDataBase (
PcdDxeDb = AllocateZeroPool (PcdDxeDbLen); PcdDxeDb = AllocateZeroPool (PcdDxeDbLen);
ASSERT (PcdDxeDb != NULL); ASSERT (PcdDxeDb != NULL);
CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length); CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length);
FreePool (mPcdDatabase.DxeDb);
mPcdDatabase.DxeDb = PcdDxeDb; mPcdDatabase.DxeDb = PcdDxeDb;
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
@ -820,8 +875,17 @@ BuildPcdDxeDataBase (
// be NULL. If it is NULL, we just copy over the DXE Default // be NULL. If it is NULL, we just copy over the DXE Default
// Value to PCD Database. // Value to PCD Database.
// //
PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob); PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
//
// Get next one that stores full PEI data
//
GuidHob = GetNextGuidHob (&gPcdDataBaseHobGuid, GET_NEXT_HOB (GuidHob));
if (GuidHob != NULL) {
mPeiPcdDbBinary = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
mPeiPcdDbSize = (UINTN) GET_GUID_HOB_DATA_SIZE (GuidHob);
}
// //
// Assign PCD Entries refereneced in PEI phase to PCD DATABASE // Assign PCD Entries refereneced in PEI phase to PCD DATABASE
// //
@ -829,6 +893,10 @@ BuildPcdDxeDataBase (
// //
// Inherit the SystemSkuId from PEI phase. // Inherit the SystemSkuId from PEI phase.
// //
if (mPcdDatabase.PeiDb->SystemSkuId != 0) {
Status = UpdatePcdDatabase (mPcdDatabase.PeiDb->SystemSkuId, FALSE);
ASSERT_EFI_ERROR (Status);
}
mPcdDatabase.DxeDb->SystemSkuId = mPcdDatabase.PeiDb->SystemSkuId; mPcdDatabase.DxeDb->SystemSkuId = mPcdDatabase.PeiDb->SystemSkuId;
} else { } else {
mPcdDatabase.PeiDb = AllocateZeroPool (sizeof (PEI_PCD_DATABASE)); mPcdDatabase.PeiDb = AllocateZeroPool (sizeof (PEI_PCD_DATABASE));
@ -939,94 +1007,6 @@ GetHiiVariable (
return Status; return Status;
} }
/**
Find the local token number according to system SKU ID.
@param LocalTokenNumber PCD token number
@param Size The size of PCD entry.
@param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.
If False, the PCD entry is initialized in DXE phase.
@return Token number according to system SKU ID.
**/
UINT32
GetSkuEnabledTokenNumber (
UINT32 LocalTokenNumber,
UINTN Size,
BOOLEAN IsPeiDb
)
{
SKU_HEAD *SkuHead;
SKU_ID *SkuIdTable;
UINTN Index;
UINT8 *Value;
UINT8 *PcdDb;
BOOLEAN FoundSku;
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);
PcdDb = IsPeiDb ? (UINT8 *) mPcdDatabase.PeiDb : (UINT8 *) mPcdDatabase.DxeDb;
SkuHead = (SKU_HEAD *) (PcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
Value = (UINT8 *) (PcdDb + SkuHead->SkuDataStartOffset);
SkuIdTable = (SKU_ID *)(PcdDb + SkuHead->SkuIdTableOffset);
//
// Find the current system's SKU ID entry in SKU ID table.
//
FoundSku = FALSE;
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (mPcdDatabase.DxeDb->SystemSkuId == SkuIdTable[Index + 1]) {
FoundSku = TRUE;
break;
}
}
//
// Find the default SKU ID entry in SKU ID table.
//
if(!FoundSku) {
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (0 == SkuIdTable[Index + 1]) {
break;
}
}
}
ASSERT (Index < SkuIdTable[0]);
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
case PCD_TYPE_VPD:
Value = (UINT8 *) &(((VPD_HEAD *) Value)[Index]);
return (UINT32) ((Value - PcdDb) | PCD_TYPE_VPD);
case PCD_TYPE_HII:
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);
return (UINT32) ((Value - PcdDb) | PCD_TYPE_HII);
case PCD_TYPE_HII|PCD_TYPE_STRING:
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);
return (UINT32) ((Value - PcdDb) | PCD_TYPE_HII | PCD_TYPE_STRING);
case PCD_TYPE_STRING:
Value = (UINT8 *) &(((STRING_HEAD *) Value)[Index]);
return (UINT32) ((Value - PcdDb) | PCD_TYPE_STRING);
case PCD_TYPE_DATA:
Value += Size * Index;
return (UINT32) ((Value - PcdDb) | PCD_TYPE_DATA);
default:
ASSERT (FALSE);
}
ASSERT (FALSE);
return 0;
}
/** /**
Invoke the callback function when dynamic PCD entry was set, if this PCD entry Invoke the callback function when dynamic PCD entry was set, if this PCD entry
has registered callback function. has registered callback function.
@ -1640,41 +1620,6 @@ GetExPcdTokenNumber (
return 0; return 0;
} }
/**
Get SKU ID table from PCD database.
@param LocalTokenNumberTableIdx Index of local token number in token number table.
@param IsPeiDb If TRUE, the pcd entry is initialized in PEI phase,
If FALSE, the pcd entry is initialized in DXE phase.
@return Pointer to SKU ID array table
**/
SKU_ID *
GetSkuIdArray (
IN UINTN LocalTokenNumberTableIdx,
IN BOOLEAN IsPeiDb
)
{
SKU_HEAD *SkuHead;
UINTN LocalTokenNumber;
UINT8 *Database;
if (IsPeiDb) {
LocalTokenNumber = *((UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
Database = (UINT8 *) mPcdDatabase.PeiDb;
} else {
LocalTokenNumber = *((UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
Database = (UINT8 *) mPcdDatabase.DxeDb;
}
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);
SkuHead = (SKU_HEAD *) ((UINT8 *)Database + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
return (SKU_ID *) (Database + SkuHead->SkuIdTableOffset);
}
/** /**
Wrapper function of getting index of PCD entry in size table. Wrapper function of getting index of PCD entry in size table.
@ -1694,7 +1639,6 @@ GetSizeTableIndex (
UINTN LocalTokenNumber; UINTN LocalTokenNumber;
UINTN Index; UINTN Index;
UINTN SizeTableIdx; UINTN SizeTableIdx;
SKU_ID *SkuIdTable;
if (IsPeiDb) { if (IsPeiDb) {
LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset); LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset);
@ -1721,22 +1665,12 @@ GetSizeTableIndex (
// //
SizeTableIdx += 2; SizeTableIdx += 2;
} else { } else {
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
// //
// We have only two entry for Non-Sku enabled PCD entry: // We have only two entry for Non-Sku enabled PCD entry:
// 1) MAX SIZE // 1) MAX SIZE
// 2) Current Size // 2) Current Size
// //
SizeTableIdx += 2; SizeTableIdx += 2;
} else {
//
// We have these entry for SKU enabled PCD entry
// 1) MAX SIZE
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
//
SkuIdTable = GetSkuIdArray (Index, IsPeiDb);
SizeTableIdx += (UINTN)*SkuIdTable + 1;
}
} }
} }
@ -1762,9 +1696,7 @@ GetPtrTypeSize (
{ {
INTN SizeTableIdx; INTN SizeTableIdx;
UINTN LocalTokenNumber; UINTN LocalTokenNumber;
SKU_ID *SkuIdTable;
SIZE_INFO *SizeTable; SIZE_INFO *SizeTable;
UINTN Index;
BOOLEAN IsPeiDb; BOOLEAN IsPeiDb;
UINT32 *LocalTokenNumberTable; UINT32 *LocalTokenNumberTable;
@ -1803,27 +1735,12 @@ GetPtrTypeSize (
// //
return *MaxSize; return *MaxSize;
} else { } else {
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
// //
// We have only two entry for Non-Sku enabled PCD entry: // We have only two entry for Non-Sku enabled PCD entry:
// 1) MAX SIZE // 1) MAX SIZE
// 2) Current Size // 2) Current Size
// //
return SizeTable[SizeTableIdx + 1]; return SizeTable[SizeTableIdx + 1];
} else {
//
// We have these entry for SKU enabled PCD entry
// 1) MAX SIZE
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuIdTable[1 + Index] == mPcdDatabase.DxeDb->SystemSkuId) {
return SizeTable[SizeTableIdx + 1 + Index];
}
}
return SizeTable[SizeTableIdx + 1];
}
} }
} }
@ -1845,9 +1762,7 @@ SetPtrTypeSize (
{ {
INTN SizeTableIdx; INTN SizeTableIdx;
UINTN LocalTokenNumber; UINTN LocalTokenNumber;
SKU_ID *SkuIdTable;
SIZE_INFO *SizeTable; SIZE_INFO *SizeTable;
UINTN Index;
UINTN MaxSize; UINTN MaxSize;
BOOLEAN IsPeiDb; BOOLEAN IsPeiDb;
UINT32 *LocalTokenNumberTable; UINT32 *LocalTokenNumberTable;
@ -1892,7 +1807,6 @@ SetPtrTypeSize (
return FALSE; return FALSE;
} }
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
// //
// We have only two entry for Non-Sku enabled PCD entry: // We have only two entry for Non-Sku enabled PCD entry:
// 1) MAX SIZE // 1) MAX SIZE
@ -1900,22 +1814,6 @@ SetPtrTypeSize (
// //
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize; SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
return TRUE; return TRUE;
} else {
//
// We have these entry for SKU enabled PCD entry
// 1) MAX SIZE
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuIdTable[1 + Index] == mPcdDatabase.DxeDb->SystemSkuId) {
SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;
return TRUE;
}
}
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
return TRUE;
}
} }
} }

View File

@ -39,7 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Please make sure the PCD Serivce DXE Version is consistent with // Please make sure the PCD Serivce DXE Version is consistent with
// the version of the generated DXE PCD Database by build tool. // the version of the generated DXE PCD Database by build tool.
// //
#define PCD_SERVICE_DXE_VERSION 6 #define PCD_SERVICE_DXE_VERSION 7
// //
// PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h. // PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
@ -961,24 +961,6 @@ ExGetWorker (
IN UINTN GetSize IN UINTN GetSize
); );
/**
Find the local token number according to system SKU ID.
@param LocalTokenNumber PCD token number
@param Size The size of PCD entry.
@param IsPeiDb If TRUE, the PCD entry is initialized in PEI phase.
If False, the PCD entry is initialized in DXE phase.
@return Token number according to system SKU ID.
**/
UINT32
GetSkuEnabledTokenNumber (
UINT32 LocalTokenNumber,
UINTN Size,
BOOLEAN IsPeiDb
);
/** /**
Get Variable which contains HII type PCD entry. Get Variable which contains HII type PCD entry.
@ -1177,6 +1159,21 @@ VariableLockCallBack (
IN VOID *Context IN VOID *Context
); );
/**
Update PCD database base on current SkuId
@param SkuId Current SkuId
@param IsPeiDb Whether to update PEI PCD database.
@retval EFI_SUCCESS Update PCD database successfully.
@retval EFI_NOT_FOUND Not found PCD database for current SkuId.
**/
EFI_STATUS
UpdatePcdDatabase (
IN SKU_ID SkuId,
IN BOOLEAN IsPeiDb
);
extern PCD_DATABASE mPcdDatabase; extern PCD_DATABASE mPcdDatabase;
extern UINT32 mPcdTotalTokenCount; extern UINT32 mPcdTotalTokenCount;

View File

@ -228,6 +228,103 @@ PcdSetNvStoreDefaultIdCallBack (
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
/**
Report Pei PCD database of all SKUs as Guid HOB so that DxePcd can access it.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param NotifyDescriptor Address of the notification descriptor data structure.
@param Ppi Address of the PPI that was installed.
@retval EFI_SUCCESS Successfully update the Boot records.
**/
EFI_STATUS
EFIAPI
EndOfPeiSignalPpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
{
PEI_PCD_DATABASE *Database;
EFI_BOOT_MODE BootMode;
EFI_STATUS Status;
UINTN Instance;
EFI_PEI_FV_HANDLE VolumeHandle;
EFI_PEI_FILE_HANDLE FileHandle;
VOID *PcdDb;
UINT32 Length;
PEI_PCD_DATABASE *PeiPcdDb;
Status = PeiServicesGetBootMode(&BootMode);
ASSERT_EFI_ERROR (Status);
//
// Don't need to report it on S3 boot.
//
if (BootMode == BOOT_ON_S3_RESUME) {
return EFI_SUCCESS;
}
PeiPcdDb = GetPcdDatabase();
if (PeiPcdDb->SystemSkuId != (SKU_ID) 0) {
//
// SkuId has been set. Don't need to report it to DXE phase.
//
return EFI_SUCCESS;
}
//
// Get full PCD database from PcdPeim FileHandle
//
Instance = 0;
FileHandle = NULL;
while (TRUE) {
//
// Traverse all firmware volume instances
//
Status = PeiServicesFfsFindNextVolume (Instance, &VolumeHandle);
//
// Error should not happen
//
ASSERT_EFI_ERROR (Status);
//
// Find PcdDb file from the beginning in this firmware volume.
//
FileHandle = NULL;
Status = PeiServicesFfsFindFileByName (&gEfiCallerIdGuid, VolumeHandle, &FileHandle);
if (!EFI_ERROR (Status)) {
//
// Find PcdPeim FileHandle in this volume
//
break;
}
//
// We cannot find PcdPeim in this firmware volume, then search the next volume.
//
Instance++;
}
//
// Find PEI PcdDb and Build second PcdDB GuidHob
//
Status = PeiServicesFfsFindSectionData (EFI_SECTION_RAW, FileHandle, &PcdDb);
ASSERT_EFI_ERROR (Status);
Length = PeiPcdDb->LengthForAllSkus;
Database = BuildGuidHob (&gPcdDataBaseHobGuid, Length);
CopyMem (Database, PcdDb, Length);
return EFI_SUCCESS;
}
EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiSignalPpiNotifyList[] = {
{
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiEndOfPeiSignalPpiGuid,
EndOfPeiSignalPpiNotifyCallback
}
};
/** /**
Main entry for PCD PEIM driver. Main entry for PCD PEIM driver.
@ -262,6 +359,9 @@ PcdPeimInit (
Status = PeiServicesInstallPpi (&mPpiList2[0]); Status = PeiServicesInstallPpi (&mPpiList2[0]);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = PeiServicesNotifyPpi (&mEndOfPeiSignalPpiNotifyList[0]);
ASSERT_EFI_ERROR (Status);
Status = PeiRegisterCallBackOnSet ( Status = PeiRegisterCallBackOnSet (
&gEfiMdeModulePkgTokenSpaceGuid, &gEfiMdeModulePkgTokenSpaceGuid,
PcdToken(PcdSetNvStoreDefaultId), PcdToken(PcdSetNvStoreDefaultId),
@ -366,6 +466,14 @@ PeiPcdSetSku (
PEI_PCD_DATABASE *PeiPcdDb; PEI_PCD_DATABASE *PeiPcdDb;
SKU_ID *SkuIdTable; SKU_ID *SkuIdTable;
UINTN Index; UINTN Index;
EFI_STATUS Status;
UINTN Instance;
EFI_PEI_FV_HANDLE VolumeHandle;
EFI_PEI_FILE_HANDLE FileHandle;
VOID *PcdDb;
UINT32 Length;
PCD_DATABASE_SKU_DELTA *SkuDelta;
PCD_DATA_DELTA *SkuDeltaData;
PeiPcdDb = GetPcdDatabase(); PeiPcdDb = GetPcdDatabase();
@ -391,8 +499,70 @@ PeiPcdSetSku (
SkuIdTable = (SKU_ID *) ((UINT8 *) PeiPcdDb + PeiPcdDb->SkuIdTableOffset); SkuIdTable = (SKU_ID *) ((UINT8 *) PeiPcdDb + PeiPcdDb->SkuIdTableOffset);
for (Index = 0; Index < SkuIdTable[0]; Index++) { for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuId == SkuIdTable[Index + 1]) { if (SkuId == SkuIdTable[Index + 1]) {
DEBUG ((EFI_D_INFO, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID) SkuId)); break;
}
}
if (Index < SkuIdTable[0]) {
//
// Get full PCD database from PcdPeim FileHandle
//
Instance = 0;
FileHandle = NULL;
while (TRUE) {
//
// Traverse all firmware volume instances
//
Status = PeiServicesFfsFindNextVolume (Instance, &VolumeHandle);
//
// Error should not happen
//
ASSERT_EFI_ERROR (Status);
//
// Find PcdDb file from the beginning in this firmware volume.
//
FileHandle = NULL;
Status = PeiServicesFfsFindFileByName (&gEfiCallerIdGuid, VolumeHandle, &FileHandle);
if (!EFI_ERROR (Status)) {
//
// Find PcdPeim FileHandle in this volume
//
break;
}
//
// We cannot find PcdPeim in this firmware volume, then search the next volume.
//
Instance++;
}
//
// Find the delta data between the different Skus
//
Status = PeiServicesFfsFindSectionData (EFI_SECTION_RAW, FileHandle, &PcdDb);
ASSERT_EFI_ERROR (Status);
Length = PeiPcdDb->LengthForAllSkus;
Index = (PeiPcdDb->Length + 7) & (~7);
SkuDelta = NULL;
while (Index < Length) {
SkuDelta = (PCD_DATABASE_SKU_DELTA *) ((UINT8 *) PcdDb + Index);
if (SkuDelta->SkuId == SkuId && SkuDelta->SkuIdCompared == 0) {
break;
}
Index = (Index + SkuDelta->Length + 7) & (~7);
}
//
// Patch the delta data into current PCD database
//
if (Index < Length && SkuDelta != NULL) {
SkuDeltaData = (PCD_DATA_DELTA *) (SkuDelta + 1);
while ((UINT8 *) SkuDeltaData < (UINT8 *) SkuDelta + SkuDelta->Length) {
*((UINT8 *) PeiPcdDb + SkuDeltaData->Offset) = (UINT8) SkuDeltaData->Value;
SkuDeltaData ++;
}
PeiPcdDb->SystemSkuId = (SKU_ID) SkuId; PeiPcdDb->SystemSkuId = (SKU_ID) SkuId;
DEBUG ((DEBUG_INFO, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID) SkuId));
return; return;
} }
} }
@ -401,6 +571,7 @@ PeiPcdSetSku (
// Invalid input SkuId, the default SKU Id will be still used for the system. // Invalid input SkuId, the default SKU Id will be still used for the system.
// //
DEBUG ((EFI_D_INFO, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n")); DEBUG ((EFI_D_INFO, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
return; return;
} }
@ -1406,9 +1577,7 @@ GetPtrTypeSize (
{ {
INTN SizeTableIdx; INTN SizeTableIdx;
UINTN LocalTokenNumber; UINTN LocalTokenNumber;
SKU_ID *SkuIdTable;
SIZE_INFO *SizeTable; SIZE_INFO *SizeTable;
UINTN Index;
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database); SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
@ -1432,27 +1601,12 @@ GetPtrTypeSize (
// //
return *MaxSize; return *MaxSize;
} else { } else {
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
// //
// We have only two entry for Non-Sku enabled PCD entry: // We have only two entry for Non-Sku enabled PCD entry:
// 1) MAX SIZE // 1) MAX SIZE
// 2) Current Size // 2) Current Size
// //
return SizeTable[SizeTableIdx + 1]; return SizeTable[SizeTableIdx + 1];
} else {
//
// We have these entry for SKU enabled PCD entry
// 1) MAX SIZE
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuIdTable[1 + Index] == Database->SystemSkuId) {
return SizeTable[SizeTableIdx + 1 + Index];
}
}
return SizeTable[SizeTableIdx + 1];
}
} }
} }
@ -1479,9 +1633,7 @@ SetPtrTypeSize (
{ {
INTN SizeTableIdx; INTN SizeTableIdx;
UINTN LocalTokenNumber; UINTN LocalTokenNumber;
SKU_ID *SkuIdTable;
SIZE_INFO *SizeTable; SIZE_INFO *SizeTable;
UINTN Index;
UINTN MaxSize; UINTN MaxSize;
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database); SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
@ -1510,7 +1662,6 @@ SetPtrTypeSize (
return FALSE; return FALSE;
} }
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
// //
// We have only two entry for Non-Sku enabled PCD entry: // We have only two entry for Non-Sku enabled PCD entry:
// 1) MAX SIZE // 1) MAX SIZE
@ -1518,22 +1669,6 @@ SetPtrTypeSize (
// //
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize; SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
return TRUE; return TRUE;
} else {
//
// We have these entry for SKU enabled PCD entry
// 1) MAX SIZE
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (SkuIdTable[1 + Index] == Database->SystemSkuId) {
SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;
return TRUE;
}
}
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
return TRUE;
}
} }
} }

View File

@ -338,6 +338,7 @@
gEfiPeiPcdPpiGuid ## PRODUCES gEfiPeiPcdPpiGuid ## PRODUCES
gGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES gGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES
gEfiGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES gEfiGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES
gEfiEndOfPeiSignalPpiGuid ## NOTIFY
[FeaturePcd] [FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## CONSUMES

View File

@ -30,8 +30,6 @@ GetLocalTokenNumber (
) )
{ {
UINT32 LocalTokenNumber; UINT32 LocalTokenNumber;
UINTN Size;
UINTN MaxSize;
// //
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER. // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
@ -42,17 +40,6 @@ GetLocalTokenNumber (
LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + TokenNumber); LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + TokenNumber);
Size = (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (Size == 0) {
GetPtrTypeSize (TokenNumber, &MaxSize, Database);
} else {
MaxSize = Size;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);
}
return LocalTokenNumber; return LocalTokenNumber;
} }
@ -532,89 +519,6 @@ GetHiiVariable (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/**
Find the local token number according to system SKU ID.
@param LocalTokenNumber PCD token number
@param Size The size of PCD entry.
@return Token number according to system SKU ID.
**/
UINT32
GetSkuEnabledTokenNumber (
UINT32 LocalTokenNumber,
UINTN Size
)
{
PEI_PCD_DATABASE *PeiPcdDb;
SKU_HEAD *SkuHead;
SKU_ID *SkuIdTable;
UINTN Index;
UINT8 *Value;
BOOLEAN FoundSku;
PeiPcdDb = GetPcdDatabase ();
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);
SkuHead = (SKU_HEAD *) ((UINT8 *)PeiPcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
Value = (UINT8 *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuDataStartOffset));
SkuIdTable = (SKU_ID *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuIdTableOffset));
//
// Find the current system's SKU ID entry in SKU ID table.
//
FoundSku = FALSE;
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (PeiPcdDb->SystemSkuId == SkuIdTable[Index + 1]) {
FoundSku = TRUE;
break;
}
}
//
// Find the default SKU ID entry in SKU ID table.
//
if(!FoundSku) {
for (Index = 0; Index < SkuIdTable[0]; Index++) {
if (0 == SkuIdTable[Index + 1]) {
break;
}
}
}
ASSERT (Index < SkuIdTable[0]);
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
case PCD_TYPE_VPD:
Value = (UINT8 *) &(((VPD_HEAD *) Value)[Index]);
return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_VPD);
case PCD_TYPE_HII:
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);
return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);
case PCD_TYPE_HII|PCD_TYPE_STRING:
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);
return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII | PCD_TYPE_STRING);
case PCD_TYPE_STRING:
Value = (UINT8 *) &(((STRING_HEAD *) Value)[Index]);
return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);
case PCD_TYPE_DATA:
Value += Size * Index;
return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_DATA);
default:
ASSERT (FALSE);
}
ASSERT (FALSE);
return 0;
}
/** /**
Invoke the callback function when dynamic PCD entry was set, if this PCD entry Invoke the callback function when dynamic PCD entry was set, if this PCD entry
has registered callback function. has registered callback function.
@ -1117,34 +1021,6 @@ GetPcdDatabase (
return (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob); return (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
} }
/**
Get SKU ID table from PCD database.
@param LocalTokenNumberTableIdx Index of local token number in token number table.
@param Database PCD database.
@return Pointer to SKU ID array table
**/
SKU_ID *
GetSkuIdArray (
IN UINTN LocalTokenNumberTableIdx,
IN PEI_PCD_DATABASE *Database
)
{
SKU_HEAD *SkuHead;
UINTN LocalTokenNumber;
LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);
SkuHead = (SKU_HEAD *) ((UINT8 *)Database + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
return (SKU_ID *) ((UINT8 *)Database + SkuHead->SkuIdTableOffset);
}
/** /**
Get index of PCD entry in size table. Get index of PCD entry in size table.
@ -1163,7 +1039,6 @@ GetSizeTableIndex (
UINTN Index; UINTN Index;
UINTN SizeTableIdx; UINTN SizeTableIdx;
UINTN LocalTokenNumber; UINTN LocalTokenNumber;
SKU_ID *SkuIdTable;
SizeTableIdx = 0; SizeTableIdx = 0;
@ -1184,22 +1059,12 @@ GetSizeTableIndex (
// //
SizeTableIdx += 2; SizeTableIdx += 2;
} else { } else {
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
// //
// We have only two entry for Non-Sku enabled PCD entry: // We have only two entry for Non-Sku enabled PCD entry:
// 1) MAX SIZE // 1) MAX SIZE
// 2) Current Size // 2) Current Size
// //
SizeTableIdx += 2; SizeTableIdx += 2;
} else {
//
// We have these entry for SKU enabled PCD entry
// 1) MAX SIZE
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
//
SkuIdTable = GetSkuIdArray (Index, Database);
SizeTableIdx += (UINTN)*SkuIdTable + 1;
}
} }
} }

View File

@ -993,21 +993,6 @@ GetExPcdTokenNumber (
IN UINTN ExTokenNumber IN UINTN ExTokenNumber
); );
/**
Find the local token number according to system SKU ID.
@param LocalTokenNumber PCD token number
@param Size The size of PCD entry.
@return Token number according to system SKU ID.
**/
UINT32
GetSkuEnabledTokenNumber (
UINT32 LocalTokenNumber,
UINTN Size
);
/** /**
The function registers the CallBackOnSet fucntion The function registers the CallBackOnSet fucntion
according to TokenNumber and EFI_GUID space. according to TokenNumber and EFI_GUID space.
@ -1043,21 +1028,6 @@ BuildPcdDatabase (
IN EFI_PEI_FILE_HANDLE FileHandle IN EFI_PEI_FILE_HANDLE FileHandle
); );
/**
Get SKU ID tabble from PCD database.
@param LocalTokenNumberTableIdx Index of local token number in token number table.
@param Database PCD Database in PEI phase
@return Pointer to SKU ID array table
**/
SKU_ID *
GetSkuIdArray (
IN UINTN LocalTokenNumberTableIdx,
IN PEI_PCD_DATABASE *Database
);
/** /**
Get index of PCD entry in size table. Get index of PCD entry in size table.