summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Universal
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-26 01:09:00 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-26 01:09:00 +0000
commit00b7af13f226afbbe9432a9a7bcaef3d8a1651e8 (patch)
treea54d5a9df7ad71d60787243ec74181a41e6f6a15 /EdkModulePkg/Universal
parentb16ef8055698bbbf96270f5787557c0c6a4b34e3 (diff)
downloadedk2-platforms-00b7af13f226afbbe9432a9a7bcaef3d8a1651e8.tar.xz
Sync up Pcd Library Instances and PCD Driver/PEIM with Pcd spec 0.51 and Mde 0.51
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@286 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal')
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Pcd.c29
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Service.h72
-rw-r--r--EdkModulePkg/Universal/PCD/Pei/Pcd.c207
-rw-r--r--EdkModulePkg/Universal/PCD/Pei/Service.c18
-rw-r--r--EdkModulePkg/Universal/PCD/Pei/Service.h255
5 files changed, 269 insertions, 312 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
index 20fd4a15b5..5340ef5471 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
+++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
@@ -97,13 +97,15 @@ PcdDxeInit (
}
-EFI_STATUS
+VOID
EFIAPI
DxePcdSetSku (
- IN UINTN SkuId
+ IN SKU_ID SkuId
)
{
- return gPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;
+ gPcdDatabase->PeiDb.Init.SystemSkuId = SkuId;
+
+ return;
}
@@ -346,15 +348,11 @@ EFI_STATUS
EFIAPI
DxePcdSetPtr (
IN UINTN TokenNumber,
- IN CONST VOID *Value
+ IN UINTN SizeOfBuffer,
+ IN VOID *Buffer
)
{
- //
- // BugBug, please change the Size to Input size when sync with spec
- //
- //ASSERT (sizeof (Value) == DxePcdGetSize (TokenNumber));
-
- return SetWorker (TokenNumber, (VOID *)Value, DxePcdGetSize (TokenNumber), TRUE);
+ return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
}
@@ -450,16 +448,17 @@ DxePcdSet64Ex (
EFI_STATUS
EFIAPI
DxePcdSetPtrEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
- IN CONST VOID *Value
+ IN CONST EFI_GUID *Guid,
+ IN UINTN ExTokenNumber,
+ IN UINTN SizeOfBuffer,
+ IN VOID *Buffer
)
{
return ExSetWorker(
ExTokenNumber,
Guid,
- (VOID *) Value,
- sizeof (Value),
+ Buffer,
+ SizeOfBuffer,
TRUE
);
}
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h
index fd2087146e..d5918f2693 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Service.h
+++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h
@@ -302,10 +302,10 @@ GetExPcdTokenAttributes (
//
// Protocol Interface function declaration.
//
-EFI_STATUS
+VOID
EFIAPI
DxePcdSetSku (
- IN UINTN SkuId
+ IN SKU_ID SkuId
)
;
@@ -313,7 +313,7 @@ DxePcdSetSku (
UINT8
EFIAPI
DxePcdGet8 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -321,7 +321,7 @@ DxePcdGet8 (
UINT16
EFIAPI
DxePcdGet16 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -329,7 +329,7 @@ DxePcdGet16 (
UINT32
EFIAPI
DxePcdGet32 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -337,7 +337,7 @@ DxePcdGet32 (
UINT64
EFIAPI
DxePcdGet64 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -345,7 +345,7 @@ DxePcdGet64 (
VOID *
EFIAPI
DxePcdGetPtr (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -353,7 +353,7 @@ DxePcdGetPtr (
BOOLEAN
EFIAPI
DxePcdGetBool (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -361,7 +361,7 @@ DxePcdGetBool (
UINTN
EFIAPI
DxePcdGetSize (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -370,7 +370,7 @@ UINT8
EFIAPI
DxePcdGet8Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -379,7 +379,7 @@ UINT16
EFIAPI
DxePcdGet16Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -388,7 +388,7 @@ UINT32
EFIAPI
DxePcdGet32Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -398,7 +398,7 @@ UINT64
EFIAPI
DxePcdGet64Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -408,7 +408,7 @@ VOID *
EFIAPI
DxePcdGetPtrEx (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -417,7 +417,7 @@ BOOLEAN
EFIAPI
DxePcdGetBoolEx (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -426,7 +426,7 @@ UINTN
EFIAPI
DxePcdGetSizeEx (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -434,7 +434,7 @@ DxePcdGetSizeEx (
EFI_STATUS
EFIAPI
DxePcdSet8 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT8 Value
)
;
@@ -443,7 +443,7 @@ DxePcdSet8 (
EFI_STATUS
EFIAPI
DxePcdSet16 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT16 Value
)
;
@@ -452,7 +452,7 @@ DxePcdSet16 (
EFI_STATUS
EFIAPI
DxePcdSet32 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT32 Value
)
;
@@ -461,7 +461,7 @@ DxePcdSet32 (
EFI_STATUS
EFIAPI
DxePcdSet64 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT64 Value
)
;
@@ -470,8 +470,9 @@ DxePcdSet64 (
EFI_STATUS
EFIAPI
DxePcdSetPtr (
- IN UINTN TokenNumber,
- IN CONST VOID *Value
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN UINTN SizeOfBuffer,
+ IN VOID *Buffer
)
;
@@ -479,7 +480,7 @@ DxePcdSetPtr (
EFI_STATUS
EFIAPI
DxePcdSetBool (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN BOOLEAN Value
)
;
@@ -489,7 +490,7 @@ EFI_STATUS
EFIAPI
DxePcdSet8Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT8 Value
)
;
@@ -499,7 +500,7 @@ EFI_STATUS
EFIAPI
DxePcdSet16Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT16 Value
)
;
@@ -509,7 +510,7 @@ EFI_STATUS
EFIAPI
DxePcdSet32Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT32 Value
)
;
@@ -519,7 +520,7 @@ EFI_STATUS
EFIAPI
DxePcdSet64Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT64 Value
)
;
@@ -528,9 +529,10 @@ DxePcdSet64Ex (
EFI_STATUS
EFIAPI
DxePcdSetPtrEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
- IN CONST VOID *Value
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN UINTN SizeOfBuffer,
+ IN VOID *Buffer
)
;
@@ -539,7 +541,7 @@ EFI_STATUS
EFIAPI
DxePcdSetBoolEx (
IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN BOOLEAN Value
)
;
@@ -549,7 +551,7 @@ DxePcdSetBoolEx (
EFI_STATUS
EFIAPI
PcdRegisterCallBackOnSet (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
@@ -559,8 +561,8 @@ PcdRegisterCallBackOnSet (
EFI_STATUS
EFIAPI
PcdUnRegisterCallBackOnSet (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
;
@@ -570,7 +572,7 @@ EFI_STATUS
EFIAPI
DxePcdGetNextToken (
IN CONST EFI_GUID *Guid, OPTIONAL
- IN OUT UINTN *TokenNumber
+ IN OUT PCD_TOKEN_NUMBER *TokenNumber
)
;
diff --git a/EdkModulePkg/Universal/PCD/Pei/Pcd.c b/EdkModulePkg/Universal/PCD/Pei/Pcd.c
index 2663be159d..974095f284 100644
--- a/EdkModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/EdkModulePkg/Universal/PCD/Pei/Pcd.c
@@ -83,16 +83,16 @@ PcdPeimInit (
return EFI_SUCCESS;
}
-EFI_STATUS
+VOID
EFIAPI
PeiPcdSetSku (
- IN UINTN SkuId
+ IN SKU_ID SkuId
)
{
- GetPcdDatabase()->Init.SystemSkuId = (SKU_ID) SkuId;
+ GetPcdDatabase()->Init.SystemSkuId = SkuId;
- return EFI_SUCCESS;
+ return;
}
@@ -100,7 +100,7 @@ PeiPcdSetSku (
UINT8
EFIAPI
PeiPcdGet8 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));
@@ -111,7 +111,7 @@ PeiPcdGet8 (
UINT16
EFIAPI
PeiPcdGet16 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));
@@ -122,7 +122,7 @@ PeiPcdGet16 (
UINT32
EFIAPI
PeiPcdGet32 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));
@@ -133,7 +133,7 @@ PeiPcdGet32 (
UINT64
EFIAPI
PeiPcdGet64 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));
@@ -144,7 +144,7 @@ PeiPcdGet64 (
VOID *
EFIAPI
PeiPcdGetPtr (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
return GetWorker (TokenNumber, 0);
@@ -155,7 +155,7 @@ PeiPcdGetPtr (
BOOLEAN
EFIAPI
PeiPcdGetBool (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));
@@ -166,7 +166,7 @@ PeiPcdGetBool (
UINTN
EFIAPI
PeiPcdGetSize (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
@@ -180,7 +180,7 @@ UINT8
EFIAPI
PeiPcdGet8Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));
@@ -192,7 +192,7 @@ UINT16
EFIAPI
PeiPcdGet16Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));
@@ -204,7 +204,7 @@ UINT32
EFIAPI
PeiPcdGet32Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));
@@ -216,7 +216,7 @@ UINT64
EFIAPI
PeiPcdGet64Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));
@@ -228,7 +228,7 @@ VOID *
EFIAPI
PeiPcdGetPtrEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return ExGetWorker (Guid, ExTokenNumber, 0);
@@ -240,7 +240,7 @@ BOOLEAN
EFIAPI
PeiPcdGetBoolEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));
@@ -252,7 +252,7 @@ UINTN
EFIAPI
PeiPcdGetSizeEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
EX_PCD_ENTRY_ATTRIBUTE Attr;
@@ -267,7 +267,7 @@ PeiPcdGetSizeEx (
EFI_STATUS
EFIAPI
PeiPcdSet8 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT8 Value
)
{
@@ -279,7 +279,7 @@ PeiPcdSet8 (
EFI_STATUS
EFIAPI
PeiPcdSet16 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT16 Value
)
{
@@ -291,7 +291,7 @@ PeiPcdSet16 (
EFI_STATUS
EFIAPI
PeiPcdSet32 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT32 Value
)
{
@@ -303,7 +303,7 @@ PeiPcdSet32 (
EFI_STATUS
EFIAPI
PeiPcdSet64 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT64 Value
)
{
@@ -314,16 +314,12 @@ PeiPcdSet64 (
EFI_STATUS
EFIAPI
PeiPcdSetPtr (
- IN UINTN TokenNumber,
- IN CONST VOID *Value
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN UINTN SizeOfBuffer,
+ IN VOID *Buffer
)
{
- //
- // BugBug, please change the Size to Input size when sync with spec
- //
- //ASSERT (sizeof (Value) == GetPcdDatabase()->Init.SizeTable[TokenNumber]);
-
- return SetWorker (TokenNumber, (VOID *) Value, GetPcdDatabase()->Init.SizeTable[TokenNumber], TRUE);
+ return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
}
@@ -331,7 +327,7 @@ PeiPcdSetPtr (
EFI_STATUS
EFIAPI
PeiPcdSetBool (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN BOOLEAN Value
)
{
@@ -344,7 +340,7 @@ EFI_STATUS
EFIAPI
PeiPcdSet8Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT8 Value
)
{
@@ -363,7 +359,7 @@ EFI_STATUS
EFIAPI
PeiPcdSet16Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT16 Value
)
{
@@ -382,7 +378,7 @@ EFI_STATUS
EFIAPI
PeiPcdSet32Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT32 Value
)
{
@@ -401,7 +397,7 @@ EFI_STATUS
EFIAPI
PeiPcdSet64Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT64 Value
)
{
@@ -420,15 +416,16 @@ EFI_STATUS
EFIAPI
PeiPcdSetPtrEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
- IN CONST VOID *Value
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
+ IN UINTN SizeOfBuffer,
+ IN VOID *Value
)
{
return ExSetWorker(
ExTokenNumber,
Guid,
- (VOID *) Value,
- sizeof (Value),
+ Value,
+ SizeOfBuffer,
TRUE
);
}
@@ -439,7 +436,7 @@ EFI_STATUS
EFIAPI
PeiPcdSetBoolEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN BOOLEAN Value
)
{
@@ -458,7 +455,7 @@ PeiPcdSetBoolEx (
EFI_STATUS
EFIAPI
PcdRegisterCallBackOnSet (
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction
)
@@ -471,7 +468,7 @@ PcdRegisterCallBackOnSet (
EFI_STATUS
EFIAPI
PcdUnRegisterCallBackOnSet (
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction
)
@@ -485,22 +482,138 @@ EFI_STATUS
EFIAPI
PeiPcdGetNextToken (
IN CONST EFI_GUID *Guid, OPTIONAL
- IN OUT UINTN *TokenNumber
+ IN OUT PCD_TOKEN_NUMBER *TokenNumber
)
{
+ UINTN GuidTableIdx;
+ PEI_PCD_DATABASE *PeiPcdDb;
+ EFI_GUID *MatchGuid;
+ DYNAMICEX_MAPPING *ExMapTable;
+ UINTN i;
+ BOOLEAN Found;
+
if (Guid == NULL) {
*TokenNumber++;
- if (*TokenNumber >= PEI_LOCAL_TOKEN_NUMBER) {
+ if (*TokenNumber >= PEI_NEX_TOKEN_NUMBER) {
*TokenNumber = 0;
}
+
+ } else {
+
+ if (PEI_EXMAP_TABLE_EMPTY) {
+ *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;
+ 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);
+
+ if (MatchGuid == NULL) {
+ *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
+ }
+
+ GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;
+
+ ExMapTable = PeiPcdDb->Init.ExMapTable;
+
+ Found = FALSE;
+ for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
+ if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {
+ Found = TRUE;
+ break;
+ }
+ }
+
+ if (Found) {
+ if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
+ *TokenNumber = ExMapTable[i].ExTokenNumber;
+ return EFI_SUCCESS;
+ }
+
+ for ( ; ExMapTable[i].ExGuidIndex == GuidTableIdx; i++) {
+ if (ExMapTable[i].ExTokenNumber == *TokenNumber) {
+ i++;
+ if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {
+ *TokenNumber = ExMapTable[i].ExTokenNumber;
+ return EFI_SUCCESS;
+ } else {
+ *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;
+ return EFI_SUCCESS;
+ }
+ }
+ }
+
+ return EFI_NOT_FOUND;
+ }
+
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_GUID *
+EFIAPI
+PeiPcdGetNextTokenSpaceGuid (
+ IN CONST EFI_GUID *Guid
+ )
+{
+ UINTN GuidTableIdx;
+ EFI_GUID *MatchGuid;
+ PEI_PCD_DATABASE *PeiPcdDb;
+ DYNAMICEX_MAPPING *ExMapTable;
+ UINTN i;
+ BOOLEAN Found;
+
+ if (PEI_EXMAP_TABLE_EMPTY) {
+ return NULL;
}
//
- // BugBug: Haven't implemented the portion to get Next Token for GuidSpace is not Local GuidSpace.
+ // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
+ // 1) ExGuid
+ // 2) ExTokenNumber
//
+ PeiPcdDb = GetPcdDatabase ();
- return EFI_SUCCESS;
-}
+ MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);
+
+ if (MatchGuid == NULL) {
+ return NULL;
+ }
+
+ GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;
+ ExMapTable = PeiPcdDb->Init.ExMapTable;
+
+ Found = FALSE;
+ for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
+ if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {
+ Found = TRUE;
+ break;
+ }
+ }
+
+ if (Found) {
+ for ( ; i < PEI_EXMAPPING_TABLE_SIZE; i++ ) {
+ if (ExMapTable[i].ExGuidIndex != GuidTableIdx ) {
+ if (i < PEI_EXMAPPING_TABLE_SIZE) {
+ return &PeiPcdDb->Init.GuidTable[ExMapTable[i].ExGuidIndex];
+ } else {
+ return NULL;
+ }
+ }
+ }
+ }
+
+ return NULL;
+
+}
diff --git a/EdkModulePkg/Universal/PCD/Pei/Service.c b/EdkModulePkg/Universal/PCD/Pei/Service.c
index 052ff9e91f..54d1250fb2 100644
--- a/EdkModulePkg/Universal/PCD/Pei/Service.c
+++ b/EdkModulePkg/Universal/PCD/Pei/Service.c
@@ -17,18 +17,6 @@ Module Name: Service.c
#include "Service.h"
-//
-// Build Tool will generate PEI_PCD_DB_INIT_VALUE in Autogen.h
-//
-/* PEI_PCD_DATABASE_INIT
-gPEIPcdDbInit = {
- PEI_PCD_DB_INIT_VALUE
-};
-*/
-
-
-
-
/**
The function registers the CallBackOnSet fucntion
according to TokenNumber and EFI_GUID space.
@@ -59,7 +47,7 @@ PeiRegisterCallBackWorker (
if (Guid == NULL) {
TokenNumber = ExTokenNumber;
- ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
+ ASSERT (TokenNumber < PEI_NEX_TOKEN_NUMBER);
LocalTokenNumber = GetPcdDatabase()->Init.LocalTokenNumberTable[TokenNumber];
} else {
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
@@ -173,8 +161,6 @@ GetHiiVariable (
Status = PeiCoreAllocatePool (Size, &Buffer);
ASSERT_EFI_ERROR (Status);
- // declare a local for STP.
- //
Status = VariablePpi->PeiGetVariable (
GetPeiServicesTablePointer (),
(UINT16 *) VariableName,
@@ -227,7 +213,7 @@ GetSkuEnabledTokenNumber (
Value += sizeof(VARIABLE_HEAD) * i;
return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);
- case 0: //Change to a MACRO PCD_TYPE_DATA
+ case PCD_TYPE_DATA:
Value += Size * i;
return (Value - (UINT8 *) PeiPcdDb);
diff --git a/EdkModulePkg/Universal/PCD/Pei/Service.h b/EdkModulePkg/Universal/PCD/Pei/Service.h
index 647a0068e1..0059b2365e 100644
--- a/EdkModulePkg/Universal/PCD/Pei/Service.h
+++ b/EdkModulePkg/Universal/PCD/Pei/Service.h
@@ -18,149 +18,6 @@ Module Name: Service.h
#ifndef _SERVICE_H
#define _SERVICE_H
-#define USE_AUTOGEN
-
-#ifndef USE_AUTOGEN
-//
-// The following definition will be generated by build tool
-//
-
-//
-// Common definitions that is shared by PEI and DXE PCD database
-//
-#define PCD_TYPE_SHIFT 24
-
-
-#define PCD_TYPE_DATA (0x00 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_HII (0x80 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_VPD (0x40 << PCD_TYPE_SHIFT)
-#define PCD_TYPE_SKU_ENABLED (0x20 << PCD_TYPE_SHIFT)
-
-
-#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED))
-
-typedef struct {
- UINT32 ExTokenNumber;
- UINT32 LocalTokenNumber; // PCD Number of this particular platform build
- UINT16 ExGuidIndex; // Index of GuidTable
-} DYNAMICEX_MAPPING;
-
-
-typedef struct {
- UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler
- UINT32 SkuIdTableOffset; //Offset from the PCD_DB
-} SKU_HEAD;
-
-
-typedef struct {
- UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
- UINT16 StringIndex; // Offset in String Table in units of UINT16.
- UINT16 Offset; // Offset in Variable
-} VARIABLE_HEAD ;
-
-
-typedef struct {
- UINT32 Offset;
-} VPD_HEAD;
-
-typedef struct {
- UINT32 LocalTokenNumber;
- UINT16 TokenNumber;
- UINT16 Size;
-} SIZEINFO;
-
-#define offsetof(s,m) (UINT32)&(((s *)0)->m)
-
-
-
-
-
-//
-// C Structure generate for PEI PCD Database
-//
-#define PEI_EXMAPPING_TABLE_SIZE 1
-#define PEI_GUID_TABLE_SIZE 1
-#define PEI_LOCAL_TOKEN_NUMBER 1
-#define PEI_STRING_TABLE_SIZE 2
-#define PEI_SKUID_TABLE_SIZE 3
-
-
-#define PEI_DATABASE_EMPTRY FALSE
-#define PEI_EXMAP_TABLE_EMPTY FALSE
-#define PEI_GUID_TABLE_EMPTY FALSE
-#define PEI_STRINGTABLE_EMPTY FALSE
-#define PEI_SIZETABLE_EMPTY FALSE
-#define PEI_SKUID_TABLE_EMPTY FALSE
-
-
-typedef struct {
-
- DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];
- EFI_GUID GuidTable[PEI_GUID_TABLE_SIZE];
-
- UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER];
-
-
- UINT16 StringTable[PEI_STRING_TABLE_SIZE];
- UINT16 SizeTable[PEI_LOCAL_TOKEN_NUMBER];
-
- UINT8 SkuIdTable[PEI_SKUID_TABLE_SIZE];
-
- SKU_ID SystemSkuId;
-
-} PEI_PCD_DATABASE_INIT;
-
-typedef struct {
- UINT8 Dummy;
-} PEI_PCD_DATABASE_UNINIT;
-
-#define PEI_PCD_DB_INIT_VALUE \
- /* ExMapTable */ \
- { \
- { /* ExTokenNumber */ 0x00000001, /* LocalTokenNumberIndex */ 0, /* ExGuidIndex */ 0} \
- }, \
- \
- /* GuidTable */ \
- { \
- { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD }} \
- }, \
- \
- /* LocalTokenNumberTable */ \
- { \
- 0 \
- }, \
- \
- /* StringTable */ \
- { \
- L"\0" \
- }, \
- \
- /* SizeTable */ \
- { \
- 4 \
- }, \
- \
- /* SkuIdTable */ \
- { \
- /*MaxSku*/ 2, /*SkuId*/ 100, /*SkuId*/200 \
- },\
- \
- /* SystemSkuId */ \
- 0 \
-
-
-//
-// End of Autogen Code
-//
-#endif
-
-/*
-typedef struct {
- PEI_PCD_DATABASE_INIT Init;
- PEI_PCD_DATABASE_UNINIT Uninit;
-} PEI_PCD_DATABASE;
-*/
-
/* Internal Function definitions */
PEI_PCD_DATABASE *
@@ -228,10 +85,10 @@ GetExPcdTokenAttributes (
EFI_STATUS
PeiRegisterCallBackWorker (
- IN UINTN TokenNumber,
- IN CONST GUID *Guid, OPTIONAL
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction,
- IN BOOLEAN Register
+ IN BOOLEAN Register
);
VOID
@@ -241,15 +98,13 @@ BuildPcdDatabase (
;
-extern EFI_GUID gPcdImageFileGuid;
-
//
// PPI Interface Implementation Declaration.
//
-EFI_STATUS
+VOID
EFIAPI
PeiPcdSetSku (
- IN UINTN SkuId
+ IN SKU_ID SkuId
)
;
@@ -257,7 +112,7 @@ PeiPcdSetSku (
UINT8
EFIAPI
PeiPcdGet8 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -265,7 +120,7 @@ PeiPcdGet8 (
UINT16
EFIAPI
PeiPcdGet16 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -273,7 +128,7 @@ PeiPcdGet16 (
UINT32
EFIAPI
PeiPcdGet32 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -281,7 +136,7 @@ PeiPcdGet32 (
UINT64
EFIAPI
PeiPcdGet64 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -289,7 +144,7 @@ PeiPcdGet64 (
VOID *
EFIAPI
PeiPcdGetPtr (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -297,7 +152,7 @@ PeiPcdGetPtr (
BOOLEAN
EFIAPI
PeiPcdGetBool (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -305,7 +160,7 @@ PeiPcdGetBool (
UINTN
EFIAPI
PeiPcdGetSize (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -313,8 +168,8 @@ PeiPcdGetSize (
UINT8
EFIAPI
PeiPcdGet8Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -322,16 +177,16 @@ PeiPcdGet8Ex (
UINT16
EFIAPI
PeiPcdGet16Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
UINT32
EFIAPI
PeiPcdGet32Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -339,8 +194,8 @@ PeiPcdGet32Ex (
UINT64
EFIAPI
PeiPcdGet64Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -348,8 +203,8 @@ PeiPcdGet64Ex (
VOID *
EFIAPI
PeiPcdGetPtrEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -357,8 +212,8 @@ PeiPcdGetPtrEx (
BOOLEAN
EFIAPI
PeiPcdGetBoolEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -366,8 +221,8 @@ PeiPcdGetBoolEx (
UINTN
EFIAPI
PeiPcdGetSizeEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber
)
;
@@ -375,7 +230,7 @@ PeiPcdGetSizeEx (
EFI_STATUS
EFIAPI
PeiPcdSet8 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT8 Value
)
;
@@ -384,7 +239,7 @@ PeiPcdSet8 (
EFI_STATUS
EFIAPI
PeiPcdSet16 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT16 Value
)
;
@@ -393,7 +248,7 @@ PeiPcdSet16 (
EFI_STATUS
EFIAPI
PeiPcdSet32 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT32 Value
)
;
@@ -402,7 +257,7 @@ PeiPcdSet32 (
EFI_STATUS
EFIAPI
PeiPcdSet64 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT64 Value
)
;
@@ -410,8 +265,9 @@ PeiPcdSet64 (
EFI_STATUS
EFIAPI
PeiPcdSetPtr (
- IN UINTN TokenNumber,
- IN CONST VOID *Value
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN UINTN SizeOfBuffer,
+ IN VOID *Buffer
)
;
@@ -419,7 +275,7 @@ PeiPcdSetPtr (
EFI_STATUS
EFIAPI
PeiPcdSetBool (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN BOOLEAN Value
)
;
@@ -428,8 +284,8 @@ PeiPcdSetBool (
EFI_STATUS
EFIAPI
PeiPcdSet8Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT8 Value
)
;
@@ -437,8 +293,8 @@ PeiPcdSet8Ex (
EFI_STATUS
EFIAPI
PeiPcdSet16Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT16 Value
)
;
@@ -447,8 +303,8 @@ PeiPcdSet16Ex (
EFI_STATUS
EFIAPI
PeiPcdSet32Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT32 Value
)
;
@@ -457,8 +313,8 @@ PeiPcdSet32Ex (
EFI_STATUS
EFIAPI
PeiPcdSet64Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT64 Value
)
;
@@ -467,9 +323,10 @@ PeiPcdSet64Ex (
EFI_STATUS
EFIAPI
PeiPcdSetPtrEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
- IN CONST VOID *Value
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN UINTN SizeOfBuffer,
+ IN VOID *Buffer
)
;
@@ -477,8 +334,8 @@ PeiPcdSetPtrEx (
EFI_STATUS
EFIAPI
PeiPcdSetBoolEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN BOOLEAN Value
)
;
@@ -488,9 +345,9 @@ PeiPcdSetBoolEx (
EFI_STATUS
EFIAPI
PcdRegisterCallBackOnSet (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
- IN PCD_PPI_CALLBACK CallBackFunction
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PPI_CALLBACK CallBackFunction
)
;
@@ -498,9 +355,9 @@ PcdRegisterCallBackOnSet (
EFI_STATUS
EFIAPI
PcdUnRegisterCallBackOnSet (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
- IN PCD_PPI_CALLBACK CallBackFunction
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PPI_CALLBACK CallBackFunction
)
;
@@ -508,8 +365,8 @@ PcdUnRegisterCallBackOnSet (
EFI_STATUS
EFIAPI
PeiPcdGetNextToken (
- IN CONST EFI_GUID *Guid, OPTIONAL
- IN OUT UINTN *TokenNumber
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN OUT PCD_TOKEN_NUMBER *TokenNumber
)
;