summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h147
-rw-r--r--MdeModulePkg/MdeModulePkg.dec4
-rw-r--r--MdeModulePkg/Universal/PCD/Dxe/Pcd.c158
-rw-r--r--MdeModulePkg/Universal/PCD/Dxe/Pcd.inf37
-rw-r--r--MdeModulePkg/Universal/PCD/Dxe/Service.c421
-rw-r--r--MdeModulePkg/Universal/PCD/Dxe/Service.h30
-rw-r--r--MdeModulePkg/Universal/PCD/Pei/Pcd.c198
-rw-r--r--MdeModulePkg/Universal/PCD/Pei/Pcd.inf37
-rw-r--r--MdeModulePkg/Universal/PCD/Pei/Service.c193
-rw-r--r--MdeModulePkg/Universal/PCD/Pei/Service.h21
10 files changed, 807 insertions, 439 deletions
diff --git a/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h b/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h
new file mode 100644
index 0000000000..22c0d95f60
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h
@@ -0,0 +1,147 @@
+/** @file
+ Guid for Pcd DataBase Signature.
+
+Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PCD_DATABASE_SIGNATURE_GUID_H_
+#define _PCD_DATABASE_SIGNATURE_GUID_H_
+
+#define PCD_DATA_BASE_SIGNATURE_GUID \
+{ 0x3c7d193c, 0x682c, 0x4c14, { 0xa6, 0x8f, 0x55, 0x2d, 0xea, 0x4f, 0x43, 0x7e } }
+
+extern EFI_GUID gPcdDataBaseSignatureGuid;
+
+//
+// Common definitions
+//
+typedef UINT8 SKU_ID;
+
+#define PCD_TYPE_SHIFT 28
+
+#define PCD_TYPE_DATA (0x0U << PCD_TYPE_SHIFT)
+#define PCD_TYPE_HII (0x8U << PCD_TYPE_SHIFT)
+#define PCD_TYPE_VPD (0x4U << PCD_TYPE_SHIFT)
+#define PCD_TYPE_SKU_ENABLED (0x2U << PCD_TYPE_SHIFT)
+#define PCD_TYPE_STRING (0x1U << PCD_TYPE_SHIFT)
+
+#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)
+
+#define PCD_DATUM_TYPE_SHIFT 24
+
+#define PCD_DATUM_TYPE_POINTER (0x0U << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT8 (0x1U << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT16 (0x2U << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT32 (0x4U << PCD_DATUM_TYPE_SHIFT)
+#define PCD_DATUM_TYPE_UINT64 (0x8U << PCD_DATUM_TYPE_SHIFT)
+
+#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \
+ PCD_DATUM_TYPE_UINT8 | \
+ PCD_DATUM_TYPE_UINT16 | \
+ PCD_DATUM_TYPE_UINT32 | \
+ PCD_DATUM_TYPE_UINT64)
+
+#define PCD_DATUM_TYPE_SHIFT2 20
+
+#define PCD_DATUM_TYPE_UINT8_BOOLEAN (0x1U << PCD_DATUM_TYPE_SHIFT2)
+
+#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET | PCD_DATUM_TYPE_UINT8_BOOLEAN))
+
+typedef struct {
+ UINT32 ExTokenNumber;
+ UINT16 TokenNumber; // Token Number for Dynamic-Ex PCD.
+ UINT16 ExGuidIndex; // Index of GuidTable in units of GUID.
+} DYNAMICEX_MAPPING;
+
+typedef struct {
+ UINT32 SkuDataStartOffset; // Offset(with TYPE info) from the PCD_DB.
+ UINT32 SkuIdTableOffset; // Offset from the PCD_DB.
+} SKU_HEAD;
+
+typedef struct {
+ UINT32 StringIndex; // Offset in String Table in units of UINT8.
+ UINT32 DefaultValueOffset; // Offset of the Default Value.
+ UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
+ UINT16 Offset; // Offset in Variable.
+} VARIABLE_HEAD;
+
+typedef struct {
+ UINT32 Offset;
+} VPD_HEAD;
+
+typedef UINT32 STRING_HEAD;
+
+typedef UINT16 SIZE_INFO;
+
+typedef struct {
+ UINT32 TokenSpaceCNameIndex; // Offset in String Table in units of UINT8.
+ UINT32 PcdCNameIndex; // Offset in String Table in units of UINT8.
+} PCD_NAME_INDEX;
+
+typedef UINT32 TABLE_OFFSET;
+
+typedef struct {
+ GUID Signature; // PcdDataBaseGuid.
+ UINT32 BuildVersion;
+ UINT32 Length;
+ UINT32 UninitDataBaseSize; // Total size for PCD those default value with 0.
+ TABLE_OFFSET LocalTokenNumberTableOffset;
+ TABLE_OFFSET ExMapTableOffset;
+ TABLE_OFFSET GuidTableOffset;
+ TABLE_OFFSET StringTableOffset;
+ TABLE_OFFSET SizeTableOffset;
+ TABLE_OFFSET SkuIdTableOffset;
+ TABLE_OFFSET PcdNameTableOffset;
+ UINT16 LocalTokenCount; // LOCAL_TOKEN_NUMBER for all.
+ UINT16 ExTokenCount; // EX_TOKEN_NUMBER for DynamicEx.
+ UINT16 GuidTableCount; // The Number of Guid in GuidTable.
+ SKU_ID SystemSkuId; // Current SkuId value.
+ UINT8 Pad; // Pad bytes to satisfy the alignment.
+
+ //
+ // Default initialized external PCD database binary structure
+ //
+ // Padding is needed to keep necessary alignment
+ //
+ //UINT64 ValueUint64[];
+ //UINT32 ValueUint32[];
+ //VPD_HEAD VpdHead[]; // VPD Offset
+ //DYNAMICEX_MAPPING ExMapTable[]; // DynamicEx PCD mapped to LocalIndex in LocalTokenNumberTable. It can be accessed by the ExMapTableOffset.
+ //UINT32 LocalTokenNumberTable[]; // Offset | DataType | PCD Type. It can be accessed by LocalTokenNumberTableOffset.
+ //GUID GuidTable[]; // GUID for DynamicEx and HII PCD variable Guid. It can be accessed by the GuidTableOffset.
+ //STRING_HEAD StringHead[]; // String PCD
+ //PCD_NAME_INDEX PcdNameTable[]; // PCD name index info. It can be accessed by the PcdNameTableOffset.
+ //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.
+ //SIZE_INFO SizeTable[]; // MaxSize and CurSize for String PCD. It can be accessed by SizeTableOffset.
+ //UINT16 ValueUint16[];
+ //UINT8 ValueUint8[];
+ //BOOLEAN ValueBoolean[];
+ //UINT8 SkuIdTable[]; // SkuIds system supports.
+ //UINT8 SkuIndexTable[]; // SkuIds for each PCD with SKU enable.
+
+} PCD_DATABASE_INIT;
+
+//
+// PEI and DXE Pcd driver use the same PCD database
+//
+typedef PCD_DATABASE_INIT PEI_PCD_DATABASE;
+typedef PCD_DATABASE_INIT DXE_PCD_DATABASE;
+
+
+typedef struct {
+ PEI_PCD_DATABASE *PeiDb;
+ DXE_PCD_DATABASE *DxeDb;
+} PCD_DATABASE;
+
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index fc9f9ccd99..b627eb101c 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -111,6 +111,10 @@
# Include/Guid/PcdDataBaseHobGuid.h
gPcdDataBaseHobGuid = { 0xEA296D92, 0x0B69, 0x423C, { 0x8C, 0x28, 0x33, 0xB4, 0xE0, 0xA9, 0x12, 0x68 }}
+ ## Guid for PCD DataBase signature.
+ # Include/Guid/PcdDataBaseSignatureGuid.h
+ gPcdDataBaseSignatureGuid = { 0x3c7d193c, 0x682c, 0x4c14, { 0xa6, 0x8f, 0x55, 0x2d, 0xea, 0x4f, 0x43, 0x7e }}
+
## Guid for EDKII implementation GUIDed opcodes
# Include/Guid/MdeModuleHii.h
gEfiIfrTianoGuid = { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }}
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
index 3cd805a88d..04fcd64306 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c
@@ -3,7 +3,7 @@
produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in
PI 1.2 Vol3.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -16,13 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Service.h"
-//
-// Just pre-allocate a memory buffer that is big enough to
-// host all distinct TokenSpace guid in both
-// PEI ExMap and DXE ExMap.
-//
-EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };
-
///
/// PCD database lock.
///
@@ -170,7 +163,7 @@ DxePcdSetSku (
IN UINTN SkuId
)
{
- mPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;
+ mPcdDatabase.PeiDb->SystemSkuId = (SKU_ID) SkuId;
return;
}
@@ -336,18 +329,18 @@ DxePcdGetSize (
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
+ ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1);
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- IsPeiDb = (BOOLEAN) (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ IsPeiDb = (BOOLEAN) (TokenNumber + 1 < mPeiLocalTokenCount + 1);
TokenNumber = IsPeiDb ? TokenNumber :
- (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);
+ (TokenNumber - mPeiLocalTokenCount);
- LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable
- : mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
+ LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset)
+ : (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
@@ -971,10 +964,8 @@ DxeUnRegisterCallBackOnSet (
@param[in, out] TokenNumber
A pointer to the PCD token number to use to find the subsequent token number.
- @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
- is already the last valid token number in the PCD database.
- In the later case, *TokenNumber is updated with the value of 0.
- @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
+ @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
+ @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
**/
EFI_STATUS
@@ -989,8 +980,8 @@ DxePcdGetNextToken (
BOOLEAN DxeExMapTableEmpty;
Status = EFI_NOT_FOUND;
- PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;
- DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;
+ PeiExMapTableEmpty = mPeiExMapTableEmpty;
+ DxeExMapTableEmpty = mDxeExMapTableEmpty;
//
// Scan the local token space
@@ -999,27 +990,32 @@ DxePcdGetNextToken (
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- if (((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) && (*TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1)) ||
- ((*TokenNumber + 1 > (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1)))) {
- return EFI_NOT_FOUND;
+ if (((*TokenNumber + 1 > mPeiNexTokenCount + 1) && (*TokenNumber + 1 <= mPeiLocalTokenCount + 1)) ||
+ ((*TokenNumber + 1 > (mPeiLocalTokenCount + mDxeNexTokenCount + 1)))) {
+ return EFI_NOT_FOUND;
}
(*TokenNumber)++;
- if ((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) &&
- (*TokenNumber <= PEI_LOCAL_TOKEN_NUMBER)) {
+ if ((*TokenNumber + 1 > mPeiNexTokenCount + 1) &&
+ (*TokenNumber + 1 <= mPeiLocalTokenCount + 1)) {
//
// The first Non-Ex type Token Number for DXE PCD
- // database is PEI_LOCAL_TOKEN_NUMBER
+ // database is mPeiLocalTokenCount + 1
//
- *TokenNumber = PEI_LOCAL_TOKEN_NUMBER;
- } else if (*TokenNumber + 1 > DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER + 1) {
+ if (mDxeNexTokenCount > 0) {
+ *TokenNumber = mPeiLocalTokenCount + 1;
+ } else {
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
+ }
+ } else if (*TokenNumber + 1 > mDxeNexTokenCount + mPeiLocalTokenCount + 1) {
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
if (PeiExMapTableEmpty && DxeExMapTableEmpty) {
- *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
return EFI_NOT_FOUND;
}
@@ -1027,10 +1023,10 @@ DxePcdGetNextToken (
Status = ExGetNextTokeNumber (
Guid,
TokenNumber,
- mPcdDatabase->PeiDb.Init.GuidTable,
- sizeof(mPcdDatabase->PeiDb.Init.GuidTable),
- mPcdDatabase->PeiDb.Init.ExMapTable,
- sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)
+ (EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset),
+ mPeiGuidTableSize,
+ (DYNAMICEX_MAPPING *)((UINT8 *) mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset),
+ mPeiExMapppingTableSize
);
}
@@ -1042,10 +1038,10 @@ DxePcdGetNextToken (
Status = ExGetNextTokeNumber (
Guid,
TokenNumber,
- mPcdDatabase->DxeDb.Init.GuidTable,
- sizeof(mPcdDatabase->DxeDb.Init.GuidTable),
- mPcdDatabase->DxeDb.Init.ExMapTable,
- sizeof(mPcdDatabase->DxeDb.Init.ExMapTable)
+ (EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset),
+ mDxeGuidTableSize,
+ (DYNAMICEX_MAPPING *)((UINT8 *) mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset),
+ mDxeExMapppingTableSize
);
}
@@ -1055,7 +1051,7 @@ DxePcdGetNextToken (
/**
Get all token space guid table which is different with given token space guid.
- @param ExMapTableSize The size of guid table
+ @param ExMapTableSize The size of ExMapTable in item
@param ExMapTable Token space guid table that want to be scaned.
@param GuidTable Guid table
@@ -1072,8 +1068,9 @@ GetDistinctTokenSpace (
EFI_GUID **DistinctTokenSpace;
UINTN OldGuidIndex;
UINTN TsIdx;
+ UINTN TempTsIdx;
UINTN Idx;
-
+ BOOLEAN Match;
DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));
ASSERT (DistinctTokenSpace != NULL);
@@ -1082,8 +1079,18 @@ GetDistinctTokenSpace (
OldGuidIndex = ExMapTable[0].ExGuidIndex;
DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];
for (Idx = 1; Idx < *ExMapTableSize; Idx++) {
- if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {
- OldGuidIndex = ExMapTable[Idx].ExGuidIndex;
+ Match = FALSE;
+ OldGuidIndex = ExMapTable[Idx].ExGuidIndex;
+ for (TempTsIdx = 0; TempTsIdx <= TsIdx; TempTsIdx++) {
+ if (&GuidTable[OldGuidIndex] == DistinctTokenSpace[TempTsIdx]) {
+ //
+ // Have recorded this GUID.
+ //
+ Match = TRUE;
+ break;
+ }
+ }
+ if (!Match) {
DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];
}
}
@@ -1099,16 +1106,20 @@ GetDistinctTokenSpace (
}
/**
- Get next token space in PCD database according to given token space guid.
-
- @param Guid Given token space guid. If NULL, then Guid will be set to
- the first PCD token space in PCD database, If not NULL, then
- Guid will be set to next PCD token space.
-
- @retval EFI_UNSUPPORTED
- @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given
- token space in PCD database.
- @retval EFI_SUCCESS Success to get next token space guid.
+ Retrieves the next valid PCD token namespace for a given namespace.
+
+ Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
+ token namespaces on a platform.
+
+ @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
+ namespace from which the search will start. On output, it designates the next valid
+ token namespace on the platform. If *Guid is NULL, then the GUID of the first token
+ space of the current platform is returned. If the search cannot locate the next valid
+ token namespace, an error is returned and the value of *Guid is undefined.
+
+ @retval EFI_SUCCESS The PCD service retrieved the value requested.
+ @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
+
**/
EFI_STATUS
EFIAPI
@@ -1129,35 +1140,31 @@ DxePcdGetNextTokenSpace (
ASSERT (Guid != NULL);
- PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;
- DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;
+ PeiExMapTableEmpty = mPeiExMapTableEmpty;
+ DxeExMapTableEmpty = mDxeExMapTableEmpty;
if (PeiExMapTableEmpty && DxeExMapTableEmpty) {
- if (*Guid != NULL) {
- return EFI_NOT_FOUND;
- } else {
- return EFI_SUCCESS;
- }
+ return EFI_NOT_FOUND;
}
-
if (TmpTokenSpaceBuffer[0] == NULL) {
PeiTokenSpaceTableSize = 0;
if (!PeiExMapTableEmpty) {
- PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;
+ PeiTokenSpaceTableSize = mPeiExMapppingTableSize / sizeof(DYNAMICEX_MAPPING);
PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,
- mPcdDatabase->PeiDb.Init.ExMapTable,
- mPcdDatabase->PeiDb.Init.GuidTable
+ (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset),
+ (EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset)
);
CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);
+ FreePool (PeiTokenSpaceTable);
}
if (!DxeExMapTableEmpty) {
- DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;
+ DxeTokenSpaceTableSize = mDxeExMapppingTableSize / sizeof(DYNAMICEX_MAPPING);
DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,
- mPcdDatabase->DxeDb.Init.ExMapTable,
- mPcdDatabase->DxeDb.Init.GuidTable
+ (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset),
+ (EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset)
);
//
@@ -1175,6 +1182,9 @@ DxePcdGetNextTokenSpace (
TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];
}
}
+
+ TmpTokenSpaceBufferCount = Idx3;
+ FreePool (DxeTokenSpaceTable);
}
}
@@ -1183,11 +1193,19 @@ DxePcdGetNextTokenSpace (
return EFI_SUCCESS;
}
- for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {
- if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {
- Idx++;
- *Guid = TmpTokenSpaceBuffer[Idx];
- return EFI_SUCCESS;
+ for (Idx = 0; Idx < TmpTokenSpaceBufferCount; Idx++) {
+ if (CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {
+ if (Idx == TmpTokenSpaceBufferCount - 1) {
+ //
+ // It has been the last token namespace.
+ //
+ *Guid = NULL;
+ return EFI_NOT_FOUND;
+ } else {
+ Idx++;
+ *Guid = TmpTokenSpaceBuffer[Idx];
+ return EFI_SUCCESS;
+ }
}
}
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
index 112c91e061..6762bde061 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
+++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
@@ -1,18 +1,19 @@
## @file
-# PCD DXE driver manage database contains all dynamic PCD entries initialized in
-# PEI phase, DXE phase and produce the implementation of PCD protocol.
+# PCD DXE driver manage database contains all dynamic PCD entries and produce the implementation of PCD protocol.
#
+# This version PCD DXE depends on the external PCD database binary file, not built in PCD data base.
# There are two PCD Protocols as follows:
# 1) PCD_PROTOCOL
# It is EDKII implementation which support Dynamic/DynamicEx type Pcds.
-# 2) EFI_PCD_PROTOCOL_PPI
+# 2) EFI_PCD_PROTOCOL
# It is defined by PI specification 1.2, Vol 3 which only support dynamicEx
# type Pcd.
#
-# For dynamicEx type PCD, it is compatible between PCD_PPI and EFI_PEI_PCD_PPI.
+# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL.
# PCD DXE driver will produce above two protocols at same time.
#
-# PCD database structure is generated at autogen.h/autogen.c in build time.
+# PCD database is generated as the separate binary image at build time. The binary image
+# will be intergrated into Firmware volume together with PCD driver.
#
# ////////////////////////////////////////////////////////////////////////////////
# // //
@@ -63,7 +64,7 @@
# b) Variable Storage:
# - The PCD value is stored in variable area.
# - As default storage type, this type PCD could be used for PEI/DXE driver
-# communication. But beside it, this type PCD could alsp be used to store
+# communication. But beside it, this type PCD could also be used to store
# the value associate with a HII setting via variable interface.
# - In PEI phase, the PCD value could only be got but can not be set due
# to variable area is readonly.
@@ -94,12 +95,12 @@
# PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD
# database contains all PCDs used in PEI/DXE phase in memory.
#
-# Build tool will generate PCD database into some C structure and variable for
+# Build tool will generate PCD database into the separate binary file for
# PEI/DXE PCD driver according to dynamic PCD section in platform DSC file.
#
# 3.1 PcdPeim and PcdDxe
# PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver
-# build guid hob in temporary memory and copy auto-generated C structure
+# build guid hob in temporary memory and copy the binary data base from flash
# to temporary memory for PEI PCD database.
# DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,
# a new PCD database is allocated in boot-time memory which including all
@@ -185,8 +186,10 @@
# Based on local token number, PCD driver could fast determine PCD type, value
# type and get PCD entry from PCD database.
#
-# 3.3 PCD Database C structure.
-# PCD Database C structure is generated by build tools in PCD driver's autogen.h/
+# 3.3 PCD Database binary file
+# PCD Database binary file will be created at build time as the standalone binary image.
+# To understand the binary image layout, PCD Database C structure is still generated
+# as comments by build tools in PCD driver's autogen.h/
# autogen.c file. In generated C structure, following information is stored:
# - ExMapTable: This table is used translate a binary dynamicex type PCD's
# "tokenguid + token" to local token number.
@@ -195,7 +198,7 @@
# token number" as array index to get PCD entry's offset fastly.
# - SizeTable: This table stores the size information for all PCD entry.
# - GuidTable: This table stores guid value for DynamicEx's token space,
-# HII type PCD's variable.
+# HII type PCD's variable GUID.
# - SkuIdTable: TBD
# - SystemSkuId: TBD
# - PCD value structure:
@@ -275,8 +278,8 @@
# GuidTable array is used to store all related GUID value in PCD database:
# - Variable GUID for HII type PCD
# - Token space GUID for dynamicex type PCD
-#
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+#
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -293,7 +296,7 @@
BASE_NAME = PcdDxe
FILE_GUID = 80CF7257-87AB-47f9-A3FE-D50B76D89541
MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
+ VERSION_STRING = 4.0
PCD_IS_DRIVER = DXE_PCD_DRIVER
ENTRY_POINT = PcdDxeInit
@@ -323,16 +326,18 @@
DebugLib
BaseLib
PcdLib
+ DxeServicesLib
[Guids]
- gPcdDataBaseHobGuid ## CONSUMES ## Hob: GUID_EXTENSION
+ gPcdDataBaseHobGuid ## SOMETIMES_CONSUMES ## HOB
+ gPcdDataBaseSignatureGuid ## CONSUMES ## UNDEFINED # PCD database signature GUID.
[Protocols]
gPcdProtocolGuid ## PRODUCES
gEfiPcdProtocolGuid ## PRODUCES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES
[Depex]
TRUE
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c
index 6eaadd6cce..513402cad9 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c
@@ -13,10 +13,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Service.h"
+#include <Library/DxeServicesLib.h>
-PCD_DATABASE *mPcdDatabase;
+PCD_DATABASE mPcdDatabase;
+
+UINT32 mPcdTotalTokenCount;
+UINT32 mPeiLocalTokenCount;
+UINT32 mDxeLocalTokenCount;
+UINT32 mPeiNexTokenCount;
+UINT32 mDxeNexTokenCount;
+UINT32 mPeiExMapppingTableSize;
+UINT32 mDxeExMapppingTableSize;
+UINT32 mPeiGuidTableSize;
+UINT32 mDxeGuidTableSize;
+
+BOOLEAN mPeiExMapTableEmpty;
+BOOLEAN mDxeExMapTableEmpty;
+BOOLEAN mPeiDatabaseEmpty;
LIST_ENTRY *mCallbackFnTable;
+EFI_GUID **TmpTokenSpaceBuffer;
+UINTN TmpTokenSpaceBufferCount;
+
/**
Get the PCD entry pointer in PCD database.
@@ -64,6 +82,8 @@ GetWorker (
EfiAcquireLock (&mPcdDatabaseLock);
RetPtr = NULL;
+
+ ASSERT (TokenNumber > 0);
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
@@ -72,27 +92,26 @@ GetWorker (
TokenNumber--;
TmpTokenNumber = TokenNumber;
-
+
//
- // PCD_TOTAL_TOKEN_NUMBER is a auto-generated constant.
- // It could be zero. EBC compiler is very choosy. It may
- // report warning. So we add 1 in each size of the
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
// comparison.
//
- ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
+ ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1);
ASSERT ((GetSize == DxePcdGetSize (TokenNumber + 1)) || (GetSize == 0));
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE);
+ IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);
- LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
- mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
+ LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) :
+ (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
TokenNumber = IsPeiDb ? TokenNumber :
- TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
+ TokenNumber - mPeiLocalTokenCount;
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
@@ -105,82 +124,64 @@ GetWorker (
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);
}
- PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
+ PcdDb = IsPeiDb ? ((UINT8 *) mPcdDatabase.PeiDb) : ((UINT8 *) mPcdDatabase.DxeDb);
if (IsPeiDb) {
- StringTable = (UINT8 *) (&mPcdDatabase->PeiDb.Init.StringTable[0]);
+ StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->StringTableOffset);
} else {
- StringTable = (UINT8 *) (&mPcdDatabase->DxeDb.Init.StringTable[0]);
+ StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->StringTableOffset);
}
-
-
+
+
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
-
+
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
case PCD_TYPE_VPD:
VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
RetPtr = (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
+
break;
-
+
case PCD_TYPE_HII|PCD_TYPE_STRING:
case PCD_TYPE_HII:
if (IsPeiDb) {
- GuidTable = (EFI_GUID *) (&mPcdDatabase->PeiDb.Init.GuidTable[0]);
+ GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset);
} else {
- GuidTable = (EFI_GUID *) (&mPcdDatabase->DxeDb.Init.GuidTable[0]);
+ GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset);
}
-
+
VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
Guid = GuidTable + VariableHead->GuidTableIndex;
Name = (UINT16*)(StringTable + VariableHead->StringIndex);
-
+
if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) {
- //
- // If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of
- // string array in string table.
- //
+ //
+ // If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of
+ // string array in string table.
+ //
StringTableIdx = *(STRING_HEAD*)((UINT8 *) PcdDb + VariableHead->DefaultValueOffset);
VaraiableDefaultBuffer = (VOID *) (StringTable + StringTableIdx);
- Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
- if (Status == EFI_SUCCESS) {
- if (GetSize == 0) {
- //
- // It is a pointer type. So get the MaxSize reserved for
- // this PCD entry.
- //
- GetPtrTypeSize (TmpTokenNumber, &GetSize);
- }
- //
- // If the operation is successful, we copy the data
- // to the default value buffer in the PCD Database.
- // So that we can free the Data allocated in GetHiiVariable.
- //
- CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);
- FreePool (Data);
- }
- RetPtr = (VOID *) VaraiableDefaultBuffer;
} else {
VaraiableDefaultBuffer = (UINT8 *) PcdDb + VariableHead->DefaultValueOffset;
-
- Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
- if (Status == EFI_SUCCESS) {
- if (GetSize == 0) {
- //
- // It is a pointer type. So get the MaxSize reserved for
- // this PCD entry.
- //
- GetPtrTypeSize (TmpTokenNumber, &GetSize);
- }
+ }
+ Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
+ if (Status == EFI_SUCCESS) {
+ if (GetSize == 0) {
//
- // If the operation is successful, we copy the data
- // to the default value buffer in the PCD Database.
- // So that we can free the Data allocated in GetHiiVariable.
+ // It is a pointer type. So get the MaxSize reserved for
+ // this PCD entry.
//
- CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);
- FreePool (Data);
+ GetPtrTypeSize (TmpTokenNumber, &GetSize);
}
- RetPtr = (VOID *) VaraiableDefaultBuffer;
+ //
+ // If the operation is successful, we copy the data
+ // to the default value buffer in the PCD Database.
+ // So that we can free the Data allocated in GetHiiVariable.
+ //
+ CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);
+ FreePool (Data);
}
+ RetPtr = (VOID *) VaraiableDefaultBuffer;
break;
case PCD_TYPE_STRING:
@@ -199,9 +200,9 @@ GetWorker (
}
EfiReleaseLock (&mPcdDatabaseLock);
-
+
return RetPtr;
-
+
}
/**
@@ -359,6 +360,7 @@ ExGetNextTokeNumber (
UINTN Index;
UINTN GuidTableIdx;
BOOLEAN Found;
+ UINTN ExMapTableCount;
//
// Scan token space guid
@@ -373,7 +375,8 @@ ExGetNextTokeNumber (
//
Found = FALSE;
GuidTableIdx = MatchGuid - GuidTable;
- for (Index = 0; Index < SizeOfExMapTable; Index++) {
+ ExMapTableCount = SizeOfExMapTable / sizeof(ExMapTable[0]);
+ for (Index = 0; Index < ExMapTableCount; Index++) {
if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
Found = TRUE;
break;
@@ -390,36 +393,71 @@ ExGetNextTokeNumber (
return EFI_SUCCESS;
}
- for ( ; Index < SizeOfExMapTable; Index++) {
+ for ( ; Index < ExMapTableCount; Index++) {
if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {
- Index ++;
- if (Index == SizeOfExMapTable) {
- //
- // Exceed the length of ExMap Table
- //
- *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
- return EFI_SUCCESS;
- } else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
- //
- // Found the next match
- //
- *TokenNumber = ExMapTable[Index].ExTokenNumber;
- return EFI_SUCCESS;
- } else {
- //
- // Guid has been changed. It is the next Token Space Guid.
- // We should flag no more TokenNumber.
- //
- *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
- return EFI_SUCCESS;
- }
+ break;
+ }
+ }
+
+ while (Index < ExMapTableCount) {
+ Index++;
+ if (Index == ExMapTableCount) {
+ //
+ // Exceed the length of ExMap Table
+ //
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
+ } else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
+ //
+ // Found the next match
+ //
+ *TokenNumber = ExMapTable[Index].ExTokenNumber;
+ return EFI_SUCCESS;
}
}
}
-
+
return EFI_NOT_FOUND;
}
+/**
+ Find the PCD database.
+
+ @retval The base address of external PCD database binary.
+ @retval NULL Return NULL if not find.
+**/
+DXE_PCD_DATABASE *
+LocateExPcdBinary (
+ VOID
+)
+{
+ DXE_PCD_DATABASE *DxePcdDbBinary;
+ UINTN DxePcdDbSize;
+ EFI_STATUS Status;
+
+ DxePcdDbBinary = NULL;
+ //
+ // Search the External Pcd database from one section of current FFS,
+ // and read it to memory
+ //
+ Status = GetSectionFromFfs (
+ EFI_SECTION_RAW,
+ 0,
+ (VOID **) &DxePcdDbBinary,
+ &DxePcdDbSize
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Check the first bytes (Header Signature Guid) and build version.
+ //
+ if (!CompareGuid ((VOID *)DxePcdDbBinary, &gPcdDataBaseSignatureGuid) ||
+ (DxePcdDbBinary->BuildVersion != PCD_SERVICE_DXE_VERSION)) {
+ ASSERT (FALSE);
+ }
+
+ return DxePcdDbBinary;
+}
/**
Initialize the PCD database in DXE phase.
@@ -436,15 +474,12 @@ BuildPcdDxeDataBase (
PEI_PCD_DATABASE *PeiDatabase;
EFI_HOB_GUID_TYPE *GuidHob;
UINTN Index;
-
- mPcdDatabase = AllocateZeroPool (sizeof(PCD_DATABASE));
- ASSERT (mPcdDatabase != NULL);
+ UINT32 PcdDxeDbLen;
+ VOID *PcdDxeDb;
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
if (GuidHob != NULL) {
- //
- // We will copy over the PEI phase's PCD Database.
//
// If no PEIMs use dynamic Pcd Entry, the Pcd Service PEIM
// should not be included at all. So the GuidHob could
@@ -454,28 +489,56 @@ BuildPcdDxeDataBase (
PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
//
- // Copy PCD Entries refereneced in PEI phase to PCD DATABASE
+ // Assign PCD Entries refereneced in PEI phase to PCD DATABASE
//
- CopyMem (&mPcdDatabase->PeiDb, PeiDatabase, sizeof (PEI_PCD_DATABASE));
+ mPcdDatabase.PeiDb = PeiDatabase;
}
//
- // Copy PCD Entries with default value to PCD DATABASE
+ // Assign PCD Entries with default value to PCD DATABASE
//
- CopyMem (&mPcdDatabase->DxeDb.Init, &gDXEPcdDbInit, sizeof(DXE_PCD_DATABASE_INIT));
+ mPcdDatabase.DxeDb = LocateExPcdBinary ();
+ ASSERT(mPcdDatabase.DxeDb != NULL);
+ PcdDxeDbLen = mPcdDatabase.DxeDb->Length + mPcdDatabase.DxeDb->UninitDataBaseSize;
+ PcdDxeDb = AllocateZeroPool (PcdDxeDbLen);
+ CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length);
+ FreePool (mPcdDatabase.DxeDb);
+ mPcdDatabase.DxeDb = PcdDxeDb;
+ //
+ // Initialized the external PCD database local variables
+ //
+ mPeiLocalTokenCount = mPcdDatabase.PeiDb->LocalTokenCount;
+ mDxeLocalTokenCount = mPcdDatabase.DxeDb->LocalTokenCount;
+
+ mPeiExMapppingTableSize = mPcdDatabase.PeiDb->ExTokenCount * sizeof (DYNAMICEX_MAPPING);
+ mDxeExMapppingTableSize = mPcdDatabase.DxeDb->ExTokenCount * sizeof (DYNAMICEX_MAPPING);
+ mPeiGuidTableSize = mPcdDatabase.PeiDb->GuidTableCount * sizeof(GUID);
+ mDxeGuidTableSize = mPcdDatabase.DxeDb->GuidTableCount * sizeof (GUID);
+
+ mPcdTotalTokenCount = mPeiLocalTokenCount + mDxeLocalTokenCount;
+ mPeiNexTokenCount = mPeiLocalTokenCount - mPcdDatabase.PeiDb->ExTokenCount;
+ mDxeNexTokenCount = mDxeLocalTokenCount - mPcdDatabase.DxeDb->ExTokenCount;
+
+ mPeiExMapTableEmpty = (mPcdDatabase.PeiDb->ExTokenCount == 0) ? TRUE : FALSE;
+ mDxeExMapTableEmpty = (mPcdDatabase.DxeDb->ExTokenCount == 0) ? TRUE : FALSE;
+ mPeiDatabaseEmpty = (mPeiLocalTokenCount == 0) ? TRUE : FALSE;
+
+ TmpTokenSpaceBufferCount = mPcdDatabase.PeiDb->ExTokenCount + mPcdDatabase.DxeDb->ExTokenCount;
+ TmpTokenSpaceBuffer = (EFI_GUID **)AllocateZeroPool(TmpTokenSpaceBufferCount * sizeof (EFI_GUID *));
//
// Initialized the Callback Function Table
//
-
- mCallbackFnTable = AllocateZeroPool (PCD_TOTAL_TOKEN_NUMBER * sizeof (LIST_ENTRY));
+ mCallbackFnTable = AllocateZeroPool (mPcdTotalTokenCount * sizeof (LIST_ENTRY));
ASSERT(mCallbackFnTable != NULL);
-
+
+ //
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- for (Index = 0; Index + 1 < PCD_TOTAL_TOKEN_NUMBER + 1; Index++) {
+ //
+ for (Index = 0; Index + 1 < mPcdTotalTokenCount + 1; Index++) {
InitializeListHead (&mCallbackFnTable[Index]);
}
}
@@ -568,29 +631,39 @@ GetSkuEnabledTokenNumber (
SKU_ID *SkuIdTable;
INTN Index;
UINT8 *Value;
- SKU_ID *PhaseSkuIdTable;
UINT8 *PcdDb;
+ BOOLEAN FoundSku;
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);
- PcdDb = IsPeiDb ? (UINT8 *) &mPcdDatabase->PeiDb : (UINT8 *) &mPcdDatabase->DxeDb;
+ PcdDb = IsPeiDb ? (UINT8 *) mPcdDatabase.PeiDb : (UINT8 *) mPcdDatabase.DxeDb;
SkuHead = (SKU_HEAD *) (PcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
Value = (UINT8 *) (PcdDb + SkuHead->SkuDataStartOffset);
- PhaseSkuIdTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SkuIdTable :
- mPcdDatabase->DxeDb.Init.SkuIdTable;
-
- SkuIdTable = &PhaseSkuIdTable[SkuHead->SkuIdTableOffset];
-
+ 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->PeiDb.Init.SystemSkuId == SkuIdTable[Index + 1]) {
+ if (mPcdDatabase.PeiDb->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) {
@@ -602,13 +675,17 @@ GetSkuEnabledTokenNumber (
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);
+ return (UINT32) ((Value - PcdDb) | PCD_TYPE_DATA);
default:
ASSERT (FALSE);
@@ -744,7 +821,7 @@ SetWorker (
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
//
- ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
+ ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1);
if (PtrType) {
//
@@ -766,8 +843,8 @@ SetWorker (
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
//
- if ((TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) ||
- (TokenNumber + 1 >= PEI_LOCAL_TOKEN_NUMBER + 1 || TokenNumber + 1 < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1))) {
+ if ((TokenNumber + 1 < mPeiNexTokenCount + 1) ||
+ (TokenNumber + 1 >= mPeiLocalTokenCount + 1 && TokenNumber + 1 < (mPeiLocalTokenCount + mDxeNexTokenCount + 1))) {
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
}
@@ -781,13 +858,13 @@ SetWorker (
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
//
- IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE);
+ IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);
- LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
- mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
+ LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) :
+ (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset) ;
TokenNumber = IsPeiDb ? TokenNumber
- : TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
+ : TokenNumber - mPeiLocalTokenCount;
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
@@ -802,12 +879,12 @@ SetWorker (
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
- PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
+ PcdDb = IsPeiDb ? ((UINT8 *) mPcdDatabase.PeiDb) : ((UINT8 *) mPcdDatabase.DxeDb);
if (IsPeiDb) {
- StringTable = (UINT8 *) (&mPcdDatabase->PeiDb.Init.StringTable[0]);
+ StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->StringTableOffset);
} else {
- StringTable = (UINT8 *) (&mPcdDatabase->DxeDb.Init.StringTable[0]);
+ StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->StringTableOffset);
}
@@ -836,20 +913,20 @@ SetWorker (
break;
}
}
-
+
if (IsPeiDb) {
- GuidTable = (EFI_GUID *) (&mPcdDatabase->PeiDb.Init.GuidTable[0]);
+ GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset);
} else {
- GuidTable = (EFI_GUID *) (&mPcdDatabase->DxeDb.Init.GuidTable[0]);
+ GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset);
}
-
+
VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
-
+
Guid = GuidTable + VariableHead->GuidTableIndex;
Name = (UINT16*) (StringTable + VariableHead->StringIndex);
VariableOffset = VariableHead->Offset;
Status = SetHiiVariable (Guid, Name, Data, *Size, VariableOffset);
-
+
if (EFI_NOT_FOUND == Status) {
if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) {
CopyMem (
@@ -954,7 +1031,7 @@ ExSetValueWorker (
}
/**
- Set value for a dynamic PCD entry.
+ Set value for a dynamic-ex PCD entry.
This routine find the local token number according to dynamic-ex PCD's token
space guid and token number firstly, and invoke callback function if this PCD
@@ -1100,16 +1177,16 @@ SetHiiVariable (
}
/**
- Get local token number according to dynamic-ex PCD's {token space guid:token number}
+ Get Token Number according to dynamic-ex PCD's {token space guid:token number}
A dynamic-ex type PCD, developer must provide pair of token space guid: token number
in DEC file. PCD database maintain a mapping table that translate pair of {token
- space guid: token number} to local token number.
+ space guid: token number} to Token Number.
@param Guid Token space guid for dynamic-ex PCD entry.
@param ExTokenNumber Dynamic-ex PCD token number.
- @return local token number for dynamic-ex PCD.
+ @return Token Number for dynamic-ex PCD.
**/
UINTN
@@ -1124,29 +1201,29 @@ GetExPcdTokenNumber (
EFI_GUID *MatchGuid;
UINTN MatchGuidIdx;
- if (!PEI_DATABASE_EMPTY) {
- ExMap = mPcdDatabase->PeiDb.Init.ExMapTable;
- GuidTable = mPcdDatabase->PeiDb.Init.GuidTable;
-
- MatchGuid = ScanGuid (GuidTable, sizeof(mPcdDatabase->PeiDb.Init.GuidTable), Guid);
-
+ if (!mPeiDatabaseEmpty) {
+ ExMap = (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset);
+ GuidTable = (EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset);
+
+ MatchGuid = ScanGuid (GuidTable, mPeiGuidTableSize, Guid);
+
if (MatchGuid != NULL) {
MatchGuidIdx = MatchGuid - GuidTable;
-
- for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {
+
+ for (Index = 0; Index < mPeiExMapppingTableSize; Index++) {
if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&
(MatchGuidIdx == ExMap[Index].ExGuidIndex)) {
- return ExMap[Index].LocalTokenNumber;
+ return ExMap[Index].TokenNumber;
}
}
}
}
-
- ExMap = mPcdDatabase->DxeDb.Init.ExMapTable;
- GuidTable = mPcdDatabase->DxeDb.Init.GuidTable;
- MatchGuid = ScanGuid (GuidTable, sizeof(mPcdDatabase->DxeDb.Init.GuidTable), Guid);
+ ExMap = (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset);
+ GuidTable = (EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset);
+
+ MatchGuid = ScanGuid (GuidTable, mDxeGuidTableSize, Guid);
//
// We need to ASSERT here. If GUID can't be found in GuidTable, this is a
// error in the BUILD system.
@@ -1154,11 +1231,11 @@ GetExPcdTokenNumber (
ASSERT (MatchGuid != NULL);
MatchGuidIdx = MatchGuid - GuidTable;
-
- for (Index = 0; Index < DXE_EXMAPPING_TABLE_SIZE; Index++) {
+
+ for (Index = 0; Index < mDxeExMapppingTableSize; Index++) {
if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&
(MatchGuidIdx == ExMap[Index].ExGuidIndex)) {
- return ExMap[Index].LocalTokenNumber;
+ return ExMap[Index].TokenNumber;
}
}
@@ -1171,27 +1248,27 @@ GetExPcdTokenNumber (
Get SKU ID table from PCD database.
@param LocalTokenNumberTableIdx Index of local token number in token number table.
- @param IsPeiPcd If TRUE,
-
+ @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 IsPeiPcd
+ IN BOOLEAN IsPeiDb
)
{
SKU_HEAD *SkuHead;
UINTN LocalTokenNumber;
UINT8 *Database;
- if (IsPeiPcd) {
- LocalTokenNumber = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
- Database = (UINT8 *) &mPcdDatabase->PeiDb;
+ if (IsPeiDb) {
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
+ Database = (UINT8 *) mPcdDatabase.PeiDb;
} else {
- LocalTokenNumber = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable[LocalTokenNumberTableIdx - PEI_LOCAL_TOKEN_NUMBER];
- Database = (UINT8 *) &mPcdDatabase->DxeDb;
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
+ Database = (UINT8 *) mPcdDatabase.DxeDb;
}
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);
@@ -1224,9 +1301,9 @@ GetSizeTableIndex (
SKU_ID *SkuIdTable;
if (IsPeiDb) {
- LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;
+ LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset);
} else {
- LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
+ LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
}
SizeTableIdx = 0;
@@ -1241,11 +1318,12 @@ GetSizeTableIndex (
//
if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
//
- // We have only one entry for VPD enabled PCD entry:
+ // We have only two entry for VPD enabled PCD entry:
// 1) MAX Size.
- // We consider current size is equal to MAX size.
+ // 2) Current Size
+ // Current size is equal to MAX size.
//
- SizeTableIdx++;
+ SizeTableIdx += 2;
} else {
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
//
@@ -1297,16 +1375,16 @@ GetPtrTypeSize (
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < mPeiLocalTokenCount + 1);
if (IsPeiDb) {
- LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;
- SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;
+ LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset);
+ SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->SizeTableOffset);
} else {
- LocalTokenNumberTableIdx -= PEI_LOCAL_TOKEN_NUMBER;
- LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
- SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;
+ LocalTokenNumberTableIdx -= mPeiLocalTokenCount;
+ LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
+ SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SizeTableOffset);
}
LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];
@@ -1322,8 +1400,9 @@ GetPtrTypeSize (
//
if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
//
- // We have only one entry for VPD enabled PCD entry:
+ // We have only two entry for VPD enabled PCD entry:
// 1) MAX Size.
+ // 2) Current Size
// We consider current size is equal to MAX size.
//
return *MaxSize;
@@ -1343,7 +1422,7 @@ GetPtrTypeSize (
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
- if (SkuIdTable[1 + Index] == mPcdDatabase->PeiDb.Init.SystemSkuId) {
+ if (SkuIdTable[1 + Index] == mPcdDatabase.PeiDb->SystemSkuId) {
return SizeTable[SizeTableIdx + 1 + Index];
}
}
@@ -1382,15 +1461,15 @@ SetPtrTypeSize (
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
//
- IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < mPeiLocalTokenCount + 1);
if (IsPeiDb) {
- LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;
- SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;
+ LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset);
+ SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->SizeTableOffset);
} else {
- LocalTokenNumberTableIdx -= PEI_LOCAL_TOKEN_NUMBER;
- LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
- SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;
+ LocalTokenNumberTableIdx -= mPeiLocalTokenCount;
+ LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
+ SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SizeTableOffset);
}
LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];
@@ -1433,7 +1512,7 @@ SetPtrTypeSize (
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
- if (SkuIdTable[1 + Index] == mPcdDatabase->PeiDb.Init.SystemSkuId) {
+ if (SkuIdTable[1 + Index] == mPcdDatabase.PeiDb->SystemSkuId) {
SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;
return TRUE;
}
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.h b/MdeModulePkg/Universal/PCD/Dxe/Service.h
index c15edd3e82..292a74cfb5 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.h
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.h
@@ -1,7 +1,7 @@
/** @file
Private functions used by PCD DXE driver.
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiDxe.h>
#include <Guid/PcdDataBaseHobGuid.h>
+#include <Guid/PcdDataBaseSignatureGuid.h>
#include <Protocol/Pcd.h>
#include <Protocol/PiPcd.h>
#include <Library/BaseLib.h>
@@ -34,7 +35,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Please make sure the PCD Serivce DXE Version is consistent with
// the version of the generated DXE PCD Database by build tool.
//
-#define PCD_SERVICE_DXE_VERSION 2
+#define PCD_SERVICE_DXE_VERSION 4
//
// PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
@@ -995,16 +996,16 @@ BuildPcdDxeDataBase (
);
/**
- Get local token number according to dynamic-ex PCD's {token space guid:token number}
+ Get Token Number according to dynamic-ex PCD's {token space guid:token number}
A dynamic-ex type PCD, developer must provide pair of token space guid: token number
in DEC file. PCD database maintain a mapping table that translate pair of {token
- space guid: token number} to local token number.
+ space guid: token number} to Token Number.
@param Guid Token space guid for dynamic-ex PCD entry.
@param ExTokenNumber Dynamic-ex PCD token number.
- @return local token number for dynamic-ex PCD.
+ @return Token Number for dynamic-ex PCD.
**/
UINTN
@@ -1079,9 +1080,24 @@ SetPtrTypeSize (
IN OUT UINTN *CurrentSize
);
-extern PCD_DATABASE * mPcdDatabase;
+extern PCD_DATABASE mPcdDatabase;
-extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;
+extern UINT32 mPcdTotalTokenCount;
+extern UINT32 mPeiLocalTokenCount;
+extern UINT32 mDxeLocalTokenCount;
+extern UINT32 mPeiNexTokenCount;
+extern UINT32 mDxeNexTokenCount;
+extern UINT32 mPeiExMapppingTableSize;
+extern UINT32 mDxeExMapppingTableSize;
+extern UINT32 mPeiGuidTableSize;
+extern UINT32 mDxeGuidTableSize;
+
+extern BOOLEAN mPeiExMapTableEmpty;
+extern BOOLEAN mDxeExMapTableEmpty;
+extern BOOLEAN mPeiDatabaseEmpty;
+
+extern EFI_GUID **TmpTokenSpaceBuffer;
+extern UINTN TmpTokenSpaceBufferCount;
extern EFI_LOCK mPcdDatabaseLock;
diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
index 5ab8e12874..557b915a12 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -1,7 +1,7 @@
/** @file
All Pcd Ppi services are implemented here.
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -116,7 +116,7 @@ PcdPeimInit (
{
EFI_STATUS Status;
- BuildPcdDatabase ();
+ BuildPcdDatabase (FileHandle);
//
// Install PCD_PPI and EFI_PEI_PCD_PPI.
@@ -155,7 +155,7 @@ PeiPcdSetSku (
)
{
- GetPcdDatabase()->Init.SystemSkuId = (SKU_ID) SkuId;
+ GetPcdDatabase()->SystemSkuId = (SKU_ID) SkuId;
return;
}
@@ -304,8 +304,10 @@ PeiPcdGetSize (
PEI_PCD_DATABASE *PeiPcdDb;
UINTN Size;
UINTN MaxSize;
+ UINT32 LocalTokenCount;
- PeiPcdDb = GetPcdDatabase ();
+ PeiPcdDb = GetPcdDatabase ();
+ LocalTokenCount = PeiPcdDb->LocalTokenCount;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
@@ -316,9 +318,9 @@ PeiPcdGetSize (
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
- Size = (PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
+ Size = (*((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber) & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
if (Size == 0) {
//
@@ -926,10 +928,8 @@ PcdUnRegisterCallBackOnSet (
is being made to retrieve tokens from the default token space.
@param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
- @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
- Or the input token number is already the last valid token number in the PCD database.
- In the later case, *TokenNumber is updated with the value of 0.
- @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
+ @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
+ @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
**/
EFI_STATUS
@@ -942,55 +942,56 @@ PeiPcdGetNextToken (
UINTN GuidTableIdx;
PEI_PCD_DATABASE *PeiPcdDb;
EFI_GUID *MatchGuid;
+ EFI_GUID *GuidTable;
DYNAMICEX_MAPPING *ExMapTable;
UINTN Index;
BOOLEAN Found;
BOOLEAN PeiExMapTableEmpty;
+ UINTN PeiNexTokenNumber;
if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {
return EFI_UNSUPPORTED;
}
- PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;
+ PeiPcdDb = GetPcdDatabase ();
+ PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;
+ GuidTable = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);
+ if (PeiPcdDb->ExTokenCount == 0) {
+ PeiExMapTableEmpty = TRUE;
+ } else {
+ PeiExMapTableEmpty = FALSE;
+ }
if (Guid == NULL) {
- if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {
+ if (*TokenNumber > PeiNexTokenNumber) {
return EFI_NOT_FOUND;
}
(*TokenNumber)++;
- if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {
+ if (*TokenNumber > PeiNexTokenNumber) {
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
} else {
if (PeiExMapTableEmpty) {
- *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
- return EFI_SUCCESS;
+ return EFI_NOT_FOUND;
}
-
- //
- // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
- // 1) ExGuid
- // 2) ExTokenNumber
- //
- PeiPcdDb = GetPcdDatabase ();
-
- MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);
+
+ MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(EFI_GUID), Guid);
if (MatchGuid == NULL) {
- *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
return EFI_NOT_FOUND;
}
- GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;
+ GuidTableIdx = MatchGuid - GuidTable;
- ExMapTable = PeiPcdDb->Init.ExMapTable;
+ ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);
Found = FALSE;
//
// Locate the GUID in ExMapTable first.
//
- for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {
+ for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {
if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
Found = TRUE;
break;
@@ -1003,26 +1004,28 @@ PeiPcdGetNextToken (
return EFI_SUCCESS;
}
- for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {
+ for ( ; Index < PeiPcdDb->ExTokenCount; Index++) {
if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {
- Index++;
- if (Index == PEI_EXMAPPING_TABLE_SIZE) {
- //
- // Exceed the length of ExMap Table
- //
- *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
- return EFI_SUCCESS;
- }
- if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
- *TokenNumber = ExMapTable[Index].ExTokenNumber;
- return EFI_SUCCESS;
- } else {
- *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
- return EFI_SUCCESS;
- }
+ break;
+ }
+ }
+
+ while (Index < PeiPcdDb->ExTokenCount) {
+ Index++;
+ if (Index == PeiPcdDb->ExTokenCount) {
+ //
+ // Exceed the length of ExMap Table
+ //
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
+ } else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
+ //
+ // Found the next match
+ //
+ *TokenNumber = ExMapTable[Index].ExTokenNumber;
+ return EFI_SUCCESS;
}
}
- return EFI_NOT_FOUND;
}
}
@@ -1032,22 +1035,17 @@ PeiPcdGetNextToken (
/**
Retrieves the next valid PCD token namespace for a given namespace.
- @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates
- a known token namespace from which the search will start. On output,
- it designates the next valid token namespace on the platform. If the input
- token namespace does not exist on the platform, an error is returned and
- the value of *Guid is undefined. If *Guid is NULL, then the GUID of the
- first token space of the current platform is assigned to *Guid the function
- return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in
- the platform other than the default (NULL) tokennamespace, *Guid is unchanged
- and the function return EFI_SUCCESS. If this input token namespace is the last
- namespace on the platform, *Guid will be assigned to NULL and the function return
- EFI_SUCCESS.
-
- @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid.
- Or the input token space Guid is already the last valid token space Guid
- in the PCD database. In the later case, *Guid is updated with the value of NULL.
- @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.
+ Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
+ token namespaces on a platform.
+
+ @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
+ namespace from which the search will start. On output, it designates the next valid
+ token namespace on the platform. If *Guid is NULL, then the GUID of the first token
+ space of the current platform is returned. If the search cannot locate the next valid
+ token namespace, an error is returned and the value of *Guid is undefined.
+
+ @retval EFI_SUCCESS The PCD service retrieved the value requested.
+ @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
**/
EFI_STATUS
@@ -1061,8 +1059,10 @@ PeiPcdGetNextTokenSpace (
PEI_PCD_DATABASE *PeiPcdDb;
DYNAMICEX_MAPPING *ExMapTable;
UINTN Index;
+ UINTN Index2;
BOOLEAN Found;
BOOLEAN PeiExMapTableEmpty;
+ EFI_GUID *GuidTable;
if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {
return EFI_UNSUPPORTED;
@@ -1070,43 +1070,39 @@ PeiPcdGetNextTokenSpace (
ASSERT (Guid != NULL);
- PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;
+ PeiPcdDb = GetPcdDatabase ();
+ if (PeiPcdDb->ExTokenCount == 0) {
+ PeiExMapTableEmpty = TRUE;
+ } else {
+ PeiExMapTableEmpty = FALSE;
+ }
+
if (PeiExMapTableEmpty) {
- if (*Guid != NULL) {
- return EFI_NOT_FOUND;
- } else {
- return EFI_SUCCESS;
- }
+ return EFI_NOT_FOUND;
}
- //
- // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
- // 1) ExGuid
- // 2) ExTokenNumber
- //
- PeiPcdDb = GetPcdDatabase ();
-
- ExMapTable = PeiPcdDb->Init.ExMapTable;
-
+ ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);
+ GuidTable = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);
+
if (*Guid == NULL) {
//
// return the first Token Space Guid.
//
- *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[0].ExGuidIndex];
+ *Guid = GuidTable + ExMapTable[0].ExGuidIndex;
return EFI_SUCCESS;
}
- MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), *Guid);
+ MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(GuidTable[0]), *Guid);
if (MatchGuid == NULL) {
return EFI_NOT_FOUND;
}
- GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;
+ GuidTableIdx = MatchGuid - GuidTable;
Found = FALSE;
- for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {
+ for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {
if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
Found = TRUE;
break;
@@ -1115,14 +1111,25 @@ PeiPcdGetNextTokenSpace (
if (Found) {
Index++;
- for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++ ) {
- if (ExMapTable[Index].ExGuidIndex != GuidTableIdx ) {
- *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[Index].ExGuidIndex];
- return EFI_SUCCESS;
+ for ( ; Index < PeiPcdDb->ExTokenCount; Index++ ) {
+ if (ExMapTable[Index].ExGuidIndex != GuidTableIdx) {
+ Found = FALSE;
+ for (Index2 = 0 ; Index2 < Index; Index2++) {
+ if (ExMapTable[Index2].ExGuidIndex == ExMapTable[Index].ExGuidIndex) {
+ //
+ // This token namespace should have been found and output at preceding getting.
+ //
+ Found = TRUE;
+ break;
+ }
+ }
+ if (!Found) {
+ *Guid = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset) + ExMapTable[Index].ExGuidIndex;
+ return EFI_SUCCESS;
+ }
}
}
*Guid = NULL;
- return EFI_SUCCESS;
}
return EFI_NOT_FOUND;
@@ -1132,7 +1139,7 @@ PeiPcdGetNextTokenSpace (
/**
Get PCD value's size for POINTER type PCD.
- The POINTER type PCD's value will be stored into a buffer in specificed size.
+ The POINTER type PCD's value will be stored into a buffer in specified size.
The max size of this PCD's value is described in PCD's definition in DEC file.
@param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
@@ -1157,11 +1164,11 @@ GetPtrTypeSize (
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
- LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
- SizeTable = Database->Init.SizeTable;
+ SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);
*MaxSize = SizeTable[SizeTableIdx];
//
@@ -1170,8 +1177,9 @@ GetPtrTypeSize (
//
if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
//
- // We have only one entry for VPD enabled PCD entry:
+ // We have only two entry for VPD enabled PCD entry:
// 1) MAX Size.
+ // 2) Current Size
// We consider current size is equal to MAX size.
//
return *MaxSize;
@@ -1191,7 +1199,7 @@ GetPtrTypeSize (
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
- if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {
+ if (SkuIdTable[1 + Index] == Database->SystemSkuId) {
return SizeTable[SizeTableIdx + 1 + Index];
}
}
@@ -1203,7 +1211,7 @@ GetPtrTypeSize (
/**
Set PCD value's size for POINTER type PCD.
- The POINTER type PCD's value will be stored into a buffer in specificed size.
+ The POINTER type PCD's value will be stored into a buffer in specified size.
The max size of this PCD's value is described in PCD's definition in DEC file.
@param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
@@ -1230,11 +1238,11 @@ SetPtrTypeSize (
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
- LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
-
- SizeTable = Database->Init.SizeTable;
+
+ SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);
MaxSize = SizeTable[SizeTableIdx];
//
@@ -1270,7 +1278,7 @@ SetPtrTypeSize (
//
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
for (Index = 0; Index < SkuIdTable[0]; Index++) {
- if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {
+ if (SkuIdTable[1 + Index] == Database->SystemSkuId) {
SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;
return TRUE;
}
diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.inf b/MdeModulePkg/Universal/PCD/Pei/Pcd.inf
index 20e442082a..8c2ab190a7 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.inf
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.inf
@@ -1,6 +1,7 @@
## @file
# PCD PEIM produces PCD database to manage all dynamic PCD in PEI phase and install Pcd Ppi service.
#
+# This version PCD PEIM depends on the external PCD database binary file, not built in PCD data base.
# There are two PCD PPIs as follows:
# 1) PCD_PPI
# It is EDKII implementation which support Dynamic/DynamicEx Pcds.
@@ -8,6 +9,10 @@
# It is defined by PI specification 1.2, Vol 3 which only support dynamicEx
# type Pcd.
# For dynamicEx type PCD, it is compatible between PCD_PPI and EFI_PEI_PCD_PPI.
+# PCD PEIM driver will produce above two PPIs at same time.
+#
+# PCD database is generated as the separate binary image at build time. The binary image
+# will be intergrated into Firmware volume together with PCD driver.
#
# ////////////////////////////////////////////////////////////////////////////////
# // //
@@ -58,7 +63,7 @@
# b) Variable Storage:
# - The PCD value is stored in variable area.
# - As default storage type, this type PCD could be used for PEI/DXE driver
-# communication. But beside it, this type PCD could alsp be used to store
+# communication. But beside it, this type PCD could also be used to store
# the value associate with a HII setting via variable interface.
# - In PEI phase, the PCD value could only be got but can not be set due
# to variable area is readonly.
@@ -89,12 +94,12 @@
# PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD
# database contains all PCDs used in PEI/DXE phase in memory.
#
-# Build tool will generate PCD database into some C structure and variable for
+# Build tool will generate PCD database into the separate binary file for
# PEI/DXE PCD driver according to dynamic PCD section in platform DSC file.
#
# 3.1 PcdPeim and PcdDxe
# PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver
-# build guid hob in temporary memory and copy auto-generated C structure
+# build guid hob in temporary memory and copy the binary data base from flash
# to temporary memory for PEI PCD database.
# DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,
# a new PCD database is allocated in boot-time memory which including all
@@ -180,8 +185,10 @@
# Based on local token number, PCD driver could fast determine PCD type, value
# type and get PCD entry from PCD database.
#
-# 3.3 PCD Database C structure.
-# PCD Database C structure is generated by build tools in PCD driver's autogen.h/
+# 3.3 PCD Database binary file
+# PCD Database binary file will be created at build time as the standalone binary image.
+# To understand the binary image layout, PCD Database C structure is still generated
+# as comments by build tools in PCD driver's autogen.h/
# autogen.c file. In generated C structure, following information is stored:
# - ExMapTable: This table is used translate a binary dynamicex type PCD's
# "tokenguid + token" to local token number.
@@ -190,7 +197,7 @@
# token number" as array index to get PCD entry's offset fastly.
# - SizeTable: This table stores the size information for all PCD entry.
# - GuidTable: This table stores guid value for DynamicEx's token space,
-# HII type PCD's variable.
+# HII type PCD's variable GUID.
# - SkuIdTable: TBD
# - SystemSkuId: TBD
# - PCD value structure:
@@ -271,7 +278,7 @@
# - Variable GUID for HII type PCD
# - Token space GUID for dynamicex type PCD
#
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -288,7 +295,7 @@
BASE_NAME = PcdPeim
FILE_GUID = 9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50
MODULE_TYPE = PEIM
- VERSION_STRING = 1.0
+ VERSION_STRING = 4.0
PCD_IS_DRIVER = PEI_PCD_DRIVER
ENTRY_POINT = PcdPeimInit
@@ -317,20 +324,22 @@
DebugLib
[Guids]
- gPcdDataBaseHobGuid ## PRODUCES ## Hob
- gPcdDataBaseHobGuid ## CONSUMES ## Hob
+ ## PRODUCES ## HOB
+ ## SOMETIMES_CONSUMES ## HOB
+ gPcdDataBaseHobGuid
+ gPcdDataBaseSignatureGuid ## CONSUMES ## UNDEFINED # PCD database signature GUID.
[Ppis]
- gEfiPeiReadOnlyVariable2PpiGuid ## CONSUMES
+ gEfiPeiReadOnlyVariable2PpiGuid ## SOMETIMES_CONSUMES
gPcdPpiGuid ## PRODUCES
gEfiPeiPcdPpiGuid ## PRODUCES
[FeaturePcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## CONSUMES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry || gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry || gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## SOMETIMES_CONSUMES
[Depex]
TRUE
diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Universal/PCD/Pei/Service.c
index e5d5f0c208..47e87d3bcd 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Service.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Service.c
@@ -2,7 +2,7 @@
The driver internal functions are implmented here.
They build Pei PCD database, and provide access service to PCD database.
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -43,25 +43,30 @@ PeiRegisterCallBackWorker (
PCD_PPI_CALLBACK Compare;
PCD_PPI_CALLBACK Assign;
UINT32 LocalTokenNumber;
+ UINT32 LocalTokenCount;
+ UINTN PeiNexTokenNumber;
UINTN TokenNumber;
UINTN Idx;
+ PEI_PCD_DATABASE *PeiPcdDb;
+
+ PeiPcdDb = GetPcdDatabase();
+ LocalTokenCount = PeiPcdDb->LocalTokenCount;
+ PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;
if (Guid == NULL) {
TokenNumber = ExTokenNumber;
-
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
- ASSERT (TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1);
+ ASSERT (TokenNumber + 1 < (PeiNexTokenNumber + 1));
} else {
TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
return EFI_NOT_FOUND;
}
-
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
@@ -71,11 +76,11 @@ PeiRegisterCallBackWorker (
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ ASSERT ((TokenNumber + 1) < (LocalTokenCount + 1));
}
- LocalTokenNumber = GetPcdDatabase()->Init.LocalTokenNumberTable[TokenNumber];
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);
//
// We don't support SET for HII and VPD type PCD entry in PEI phase.
@@ -105,29 +110,74 @@ PeiRegisterCallBackWorker (
}
+
+/**
+ Find the Pcd database.
+
+ @param FileHandle Handle of the file the external PCD database binary located.
+
+ @retval The base address of external PCD database binary.
+ @retval NULL Return NULL if not find.
+**/
+VOID *
+LocateExPcdBinary (
+ IN EFI_PEI_FILE_HANDLE FileHandle
+ )
+{
+ EFI_STATUS Status;
+ VOID *PcdDb;
+
+ PcdDb = NULL;
+
+ ASSERT (FileHandle != NULL);
+
+ Status = PeiServicesFfsFindSectionData (EFI_SECTION_RAW, FileHandle, &PcdDb);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Check the first bytes (Header Signature Guid) and build version.
+ //
+ if (!CompareGuid (PcdDb, &gPcdDataBaseSignatureGuid) ||
+ (((PEI_PCD_DATABASE *) PcdDb)->BuildVersion != PCD_SERVICE_PEIM_VERSION)) {
+ ASSERT (FALSE);
+ }
+ return PcdDb;
+}
+
+
/**
The function builds the PCD database.
+
+ @param FileHandle Handle of the file the external PCD database binary located.
+
**/
VOID
BuildPcdDatabase (
- VOID
+ IN EFI_PEI_FILE_HANDLE FileHandle
)
{
- PEI_PCD_DATABASE *Database;
- VOID *CallbackFnTable;
- UINTN SizeOfCallbackFnTable;
-
- Database = BuildGuidHob (&gPcdDataBaseHobGuid, sizeof (PEI_PCD_DATABASE));
+ PEI_PCD_DATABASE *Database;
+ PEI_PCD_DATABASE *PeiPcdDbBinary;
+ VOID *CallbackFnTable;
+ UINTN SizeOfCallbackFnTable;
+
+ //
+ // Locate the external PCD database binary for one section of current FFS
+ //
+ PeiPcdDbBinary = LocateExPcdBinary (FileHandle);
- ZeroMem (Database, sizeof (PEI_PCD_DATABASE));
+ ASSERT(PeiPcdDbBinary != NULL);
+
+ Database = BuildGuidHob (&gPcdDataBaseHobGuid, PeiPcdDbBinary->Length + PeiPcdDbBinary->UninitDataBaseSize);
+
+ ZeroMem (Database, PeiPcdDbBinary->Length + PeiPcdDbBinary->UninitDataBaseSize);
//
- // gPEIPcdDbInit is smaller than PEI_PCD_DATABASE
+ // PeiPcdDbBinary is smaller than Database
//
-
- CopyMem (&Database->Init, &gPEIPcdDbInit, sizeof (gPEIPcdDbInit));
+ CopyMem (Database, PeiPcdDbBinary, PeiPcdDbBinary->Length);
- SizeOfCallbackFnTable = PEI_LOCAL_TOKEN_NUMBER * sizeof (PCD_PPI_CALLBACK) * PcdGet32 (PcdMaxPeiPcdCallBackNumberPerPcdEntry);
+ SizeOfCallbackFnTable = Database->LocalTokenCount * sizeof (PCD_PPI_CALLBACK) * PcdGet32 (PcdMaxPeiPcdCallBackNumberPerPcdEntry);
CallbackFnTable = BuildGuidHob (&gEfiCallerIdGuid, SizeOfCallbackFnTable);
@@ -215,6 +265,7 @@ GetSkuEnabledTokenNumber (
SKU_ID *SkuIdTable;
INTN Index;
UINT8 *Value;
+ BOOLEAN FoundSku;
PeiPcdDb = GetPcdDatabase ();
@@ -223,13 +274,30 @@ GetSkuEnabledTokenNumber (
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->Init.SystemSkuId == SkuIdTable[Index + 1]) {
+ 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]);
@@ -238,14 +306,18 @@ GetSkuEnabledTokenNumber (
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);
+ return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_DATA);
default:
ASSERT (FALSE);
@@ -281,6 +353,8 @@ InvokeCallbackOnSet (
EFI_HOB_GUID_TYPE *GuidHob;
PCD_PPI_CALLBACK *CallbackTable;
UINTN Idx;
+ PEI_PCD_DATABASE *PeiPcdDb;
+ UINT32 LocalTokenCount;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
@@ -288,12 +362,15 @@ InvokeCallbackOnSet (
// as the array index.
//
TokenNumber--;
-
+
+ PeiPcdDb = GetPcdDatabase ();
+ LocalTokenCount = PeiPcdDb->LocalTokenCount;
+
if (Guid == NULL) {
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
}
GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid);
@@ -359,11 +436,13 @@ SetWorker (
)
{
UINT32 LocalTokenNumber;
+ UINTN PeiNexTokenNumber;
PEI_PCD_DATABASE *PeiPcdDb;
STRING_HEAD StringTableIdx;
UINTN Offset;
VOID *InternalData;
UINTN MaxSize;
+ UINT32 LocalTokenCount;
if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) {
return EFI_UNSUPPORTED;
@@ -375,15 +454,15 @@ SetWorker (
// as the array index.
//
TokenNumber--;
+ PeiPcdDb = GetPcdDatabase ();
+ LocalTokenCount = PeiPcdDb->LocalTokenCount;
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
-
- PeiPcdDb = GetPcdDatabase ();
+ ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
- LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);
if (PtrType) {
//
@@ -405,7 +484,8 @@ SetWorker (
// For Dynamic EX PCD entry, we have invoked the callback function for Dynamic EX
// type PCD entry in ExSetWorker.
//
- if (TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) {
+ PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;
+ if (TokenNumber + 1 < PeiNexTokenNumber + 1) {
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
}
@@ -433,7 +513,7 @@ SetWorker (
case PCD_TYPE_STRING:
if (SetPtrTypeSize (TokenNumber, Size, PeiPcdDb)) {
StringTableIdx = *((STRING_HEAD *)InternalData);
- CopyMem (&PeiPcdDb->Init.StringTable[StringTableIdx], Data, *Size);
+ CopyMem ((UINT8 *)PeiPcdDb + PeiPcdDb->StringTableOffset + StringTableIdx, Data, *Size);
return EFI_SUCCESS;
} else {
return EFI_INVALID_PARAMETER;
@@ -503,7 +583,7 @@ ExSetValueWorker (
}
/**
- Set value for a dynamic PCD entry.
+ Set value for a dynamic-ex PCD entry.
This routine find the local token number according to dynamic-ex PCD's token
space guid and token number firstly, and invoke callback function if this PCD
@@ -598,6 +678,7 @@ GetWorker (
PEI_PCD_DATABASE *PeiPcdDb;
UINT32 LocalTokenNumber;
UINTN MaxSize;
+ UINT32 LocalTokenCount;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
@@ -606,16 +687,17 @@ GetWorker (
//
TokenNumber--;
+ PeiPcdDb = GetPcdDatabase ();
+ LocalTokenCount = PeiPcdDb->LocalTokenCount;
+
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
- ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));
- PeiPcdDb = GetPcdDatabase ();
-
- LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (GetSize == 0) {
@@ -627,8 +709,8 @@ GetWorker (
}
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
- StringTable = PeiPcdDb->Init.StringTable;
-
+ StringTable = (UINT8 *)PeiPcdDb + PeiPcdDb->StringTableOffset;
+
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
case PCD_TYPE_VPD:
{
@@ -642,7 +724,7 @@ GetWorker (
{
VariableHead = (VARIABLE_HEAD *) ((UINT8 *)PeiPcdDb + Offset);
- Guid = &(PeiPcdDb->Init.GuidTable[VariableHead->GuidTableIndex]);
+ Guid = (EFI_GUID *) ((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset) + VariableHead->GuidTableIndex;
Name = (UINT16*)&StringTable[VariableHead->StringIndex];
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
@@ -681,16 +763,16 @@ GetWorker (
}
/**
- Get local token number according to dynamic-ex PCD's {token space guid:token number}
+ Get Token Number according to dynamic-ex PCD's {token space guid:token number}
A dynamic-ex type PCD, developer must provide pair of token space guid: token number
in DEC file. PCD database maintain a mapping table that translate pair of {token
- space guid: token number} to local token number.
+ space guid: token number} to Token Number.
@param Guid Token space guid for dynamic-ex PCD entry.
- @param ExTokenNumber EDES_TODO: Add parameter description
+ @param ExTokenNumber Dynamic-ex PCD token number.
- @return local token number for dynamic-ex PCD.
+ @return Token Number for dynamic-ex PCD.
**/
UINTN
@@ -707,11 +789,11 @@ GetExPcdTokenNumber (
PEI_PCD_DATABASE *PeiPcdDb;
PeiPcdDb = GetPcdDatabase();
-
- ExMap = PeiPcdDb->Init.ExMapTable;
- GuidTable = PeiPcdDb->Init.GuidTable;
- MatchGuid = ScanGuid (GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);
+ ExMap = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);
+ GuidTable = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);
+
+ MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(EFI_GUID), Guid);
//
// We need to ASSERT here. If GUID can't be found in GuidTable, this is a
// error in the BUILD system.
@@ -720,10 +802,10 @@ GetExPcdTokenNumber (
MatchGuidIdx = MatchGuid - GuidTable;
- for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {
+ for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {
if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&
(MatchGuidIdx == ExMap[Index].ExGuidIndex)) {
- return ExMap[Index].LocalTokenNumber;
+ return ExMap[Index].TokenNumber;
}
}
@@ -750,7 +832,7 @@ GetPcdDatabase (
}
/**
- Get SKU ID tabble from PCD database.
+ Get SKU ID table from PCD database.
@param LocalTokenNumberTableIdx Index of local token number in token number table.
@param Database PCD database.
@@ -767,7 +849,7 @@ GetSkuIdArray (
SKU_HEAD *SkuHead;
UINTN LocalTokenNumber;
- LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);
@@ -793,14 +875,14 @@ GetSizeTableIndex (
)
{
UINTN Index;
- UINTN SizeTableIdx;
+ UINTN SizeTableIdx;
UINTN LocalTokenNumber;
SKU_ID *SkuIdTable;
SizeTableIdx = 0;
- for (Index=0; Index<LocalTokenNumberTableIdx; Index++) {
- LocalTokenNumber = Database->Init.LocalTokenNumberTable[Index];
+ for (Index = 0; Index < LocalTokenNumberTableIdx; Index++) {
+ LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + Index);
if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) {
//
@@ -809,11 +891,12 @@ GetSizeTableIndex (
//
if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
//
- // We have only one entry for VPD enabled PCD entry:
+ // We have only two entry for VPD enabled PCD entry:
// 1) MAX Size.
- // We consider current size is equal to MAX size.
+ // 2) Current Size
+ // Current size is equal to MAX size.
//
- SizeTableIdx++;
+ SizeTableIdx += 2;
} else {
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
//
diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.h b/MdeModulePkg/Universal/PCD/Pei/Service.h
index 2847686259..1928dcb928 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Service.h
+++ b/MdeModulePkg/Universal/PCD/Pei/Service.h
@@ -1,7 +1,7 @@
/** @file
The internal header file declares the private functions used by PeiPcd driver.
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Ppi/Pcd.h>
#include <Ppi/PiPcd.h>
#include <Guid/PcdDataBaseHobGuid.h>
+#include <Guid/PcdDataBaseSignatureGuid.h>
#include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/BaseLib.h>
@@ -33,7 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Please make sure the PCD Serivce PEIM Version is consistent with
// the version of the generated PEIM PCD Database by build tool.
//
-#define PCD_SERVICE_PEIM_VERSION 2
+#define PCD_SERVICE_PEIM_VERSION 4
//
// PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.
@@ -896,16 +897,16 @@ typedef struct {
} EX_PCD_ENTRY_ATTRIBUTE;
/**
- Get local token number according to dynamic-ex PCD's {token space guid:token number}
+ Get Token Number according to dynamic-ex PCD's {token space guid:token number}
A dynamic-ex type PCD, developer must provide pair of token space guid: token number
in DEC file. PCD database maintain a mapping table that translate pair of {token
- space guid: token number} to local token number.
+ space guid: token number} to Token Number.
@param Guid Token space guid for dynamic-ex PCD entry.
@param ExTokenNumber Token number for dynamic-ex PCD.
- @return local token number for dynamic-ex PCD.
+ @return Token Number for dynamic-ex PCD.
**/
UINTN
@@ -938,10 +939,13 @@ PeiRegisterCallBackWorker (
/**
The function builds the PCD database.
+
+ @param FileHandle Handle of the file the external PCD database binary located.
+
**/
VOID
BuildPcdDatabase (
- VOID
+ IN EFI_PEI_FILE_HANDLE FileHandle
);
/**
@@ -1015,10 +1019,5 @@ SetPtrTypeSize (
IN PEI_PCD_DATABASE *Database
);
-//
-// The init Database created by PCD Database generation tool
-//
-extern PEI_PCD_DATABASE_INIT gPEIPcdDbInit;
-
#endif