diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-05-29 01:48:32 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-05-29 01:48:32 +0000 |
commit | 4c114006de95489973d33a5415bb451bcd6cd62a (patch) | |
tree | 233fbe6da43a9351f328c2e88ffc93ae6b091b44 /EdkModulePkg/Universal/PCD | |
parent | eebf7983a926007d2634708f76f7c972882ab9b6 (diff) | |
download | edk2-4c114006de95489973d33a5415bb451bcd6cd62a.zip edk2-4c114006de95489973d33a5415bb451bcd6cd62a.tar.gz edk2-4c114006de95489973d33a5415bb451bcd6cd62a.tar.bz2 |
Add in GetNextToken and Register Callback Function funtionality for DXE Driver.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@309 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal/PCD')
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Pcd.c | 153 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Service.c | 234 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Service.h | 45 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Pei/Pcd.c | 10 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Pei/Service.h | 2 |
5 files changed, 338 insertions, 106 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c index 5340ef5..5563314 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c +++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c @@ -51,8 +51,8 @@ PCD_PROTOCOL mPcdInstance = { DxePcdSetPtrEx,
DxePcdSetBoolEx,
- PcdRegisterCallBackOnSet,
- PcdUnRegisterCallBackOnSet,
+ DxeRegisterCallBackOnSet,
+ DxeUnRegisterCallBackOnSet,
DxePcdGetNextToken
};
@@ -103,7 +103,7 @@ DxePcdSetSku ( IN SKU_ID SkuId
)
{
- gPcdDatabase->PeiDb.Init.SystemSkuId = SkuId;
+ mPcdDatabase->PeiDb.Init.SystemSkuId = SkuId;
return;
}
@@ -113,7 +113,7 @@ DxePcdSetSku ( UINT8
EFIAPI
DxePcdGet8 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
ASSERT (sizeof (UINT8) == DxePcdGetSize (TokenNumber));
@@ -126,7 +126,7 @@ DxePcdGet8 ( UINT16
EFIAPI
DxePcdGet16 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
ASSERT (sizeof (UINT16) == DxePcdGetSize (TokenNumber));
@@ -139,7 +139,7 @@ DxePcdGet16 ( UINT32
EFIAPI
DxePcdGet32 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
ASSERT (sizeof (UINT32) == DxePcdGetSize (TokenNumber));
@@ -152,7 +152,7 @@ DxePcdGet32 ( UINT64
EFIAPI
DxePcdGet64 (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
ASSERT (sizeof (UINT64) == DxePcdGetSize (TokenNumber));
@@ -165,7 +165,7 @@ DxePcdGet64 ( VOID *
EFIAPI
DxePcdGetPtr (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
return GetWorker (TokenNumber);
@@ -176,7 +176,7 @@ DxePcdGetPtr ( BOOLEAN
EFIAPI
DxePcdGetBool (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
ASSERT (sizeof (BOOLEAN) == DxePcdGetSize (TokenNumber));
@@ -189,13 +189,13 @@ DxePcdGetBool ( UINTN
EFIAPI
DxePcdGetSize (
- IN UINTN TokenNumber
+ IN PCD_TOKEN_NUMBER TokenNumber
)
{
UINT16 * SizeTable;
- SizeTable = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? gPcdDatabase->PeiDb.Init.SizeTable :
- gPcdDatabase->DxeDb.Init.SizeTable;
+ SizeTable = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? mPcdDatabase->PeiDb.Init.SizeTable :
+ mPcdDatabase->DxeDb.Init.SizeTable;
TokenNumber = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TokenNumber : (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);
@@ -209,7 +209,7 @@ UINT8 EFIAPI
DxePcdGet8Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT8)));
@@ -221,7 +221,7 @@ UINT16 EFIAPI
DxePcdGet16Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return *((UINT16 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));
@@ -233,7 +233,7 @@ UINT32 EFIAPI
DxePcdGet32Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return *((UINT32 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));
@@ -245,7 +245,7 @@ UINT64 EFIAPI
DxePcdGet64Ex (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
//
@@ -260,7 +260,7 @@ VOID * EFIAPI
DxePcdGetPtrEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return ExGetWorker (Guid, ExTokenNumber, 0);
@@ -272,7 +272,7 @@ BOOLEAN EFIAPI
DxePcdGetBoolEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof(BOOLEAN)));
@@ -284,7 +284,7 @@ UINTN EFIAPI
DxePcdGetSizeEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
EX_PCD_ENTRY_ATTRIBUTE Attr;
@@ -299,7 +299,7 @@ DxePcdGetSizeEx ( EFI_STATUS
EFIAPI
DxePcdSet8 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT8 Value
)
{
@@ -311,7 +311,7 @@ DxePcdSet8 ( EFI_STATUS
EFIAPI
DxePcdSet16 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT16 Value
)
{
@@ -323,7 +323,7 @@ DxePcdSet16 ( EFI_STATUS
EFIAPI
DxePcdSet32 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT32 Value
)
{
@@ -335,7 +335,7 @@ DxePcdSet32 ( EFI_STATUS
EFIAPI
DxePcdSet64 (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINT64 Value
)
{
@@ -347,7 +347,7 @@ DxePcdSet64 ( EFI_STATUS
EFIAPI
DxePcdSetPtr (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN UINTN SizeOfBuffer,
IN VOID *Buffer
)
@@ -360,7 +360,7 @@ DxePcdSetPtr ( EFI_STATUS
EFIAPI
DxePcdSetBool (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER TokenNumber,
IN BOOLEAN Value
)
{
@@ -372,8 +372,8 @@ DxePcdSetBool ( EFI_STATUS
EFIAPI
DxePcdSet8Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT8 Value
)
{
@@ -391,8 +391,8 @@ DxePcdSet8Ex ( EFI_STATUS
EFIAPI
DxePcdSet16Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT16 Value
)
{
@@ -410,8 +410,8 @@ DxePcdSet16Ex ( EFI_STATUS
EFIAPI
DxePcdSet32Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT32 Value
)
{
@@ -429,8 +429,8 @@ DxePcdSet32Ex ( EFI_STATUS
EFIAPI
DxePcdSet64Ex (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINT64 Value
)
{
@@ -449,7 +449,7 @@ EFI_STATUS EFIAPI
DxePcdSetPtrEx (
IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN UINTN SizeOfBuffer,
IN VOID *Buffer
)
@@ -468,8 +468,8 @@ DxePcdSetPtrEx ( EFI_STATUS
EFIAPI
DxePcdSetBoolEx (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER ExTokenNumber,
IN BOOLEAN Value
)
{
@@ -487,26 +487,30 @@ DxePcdSetBoolEx ( EFI_STATUS
EFIAPI
-PcdRegisterCallBackOnSet (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
+DxeRegisterCallBackOnSet (
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
{
- return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, TRUE);
+ ASSERT (CallBackFunction != NULL);
+
+ return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);
}
EFI_STATUS
EFIAPI
-PcdUnRegisterCallBackOnSet (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
+DxeUnRegisterCallBackOnSet (
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
{
- return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, FALSE);
+ ASSERT (CallBackFunction != NULL);
+
+ return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);
}
@@ -514,10 +518,65 @@ PcdUnRegisterCallBackOnSet ( EFI_STATUS
EFIAPI
DxePcdGetNextToken (
- IN CONST EFI_GUID *Guid, OPTIONAL
- IN OUT UINTN *TokenNumber
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN OUT PCD_TOKEN_NUMBER *TokenNumber
)
{
- return DxeGetNextTokenWorker (TokenNumber, Guid);
+ PCD_TOKEN_NUMBER ExTokenNumber;
+
+ //
+ // Scan the local token space
+ //
+ if (Guid == NULL) {
+ *TokenNumber++;
+ if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
+ return EFI_SUCCESS;
+ } else {
+ if (*TokenNumber >= PEI_NEX_TOKEN_NUMBER &&
+ *TokenNumber < PEI_LOCAL_TOKEN_NUMBER) {
+ //
+ // The first Non-Ex type Token Number for DXE PCD
+ // database is PEI_LOCAL_TOKEN_NUMBER
+ //
+ *TokenNumber = PEI_LOCAL_TOKEN_NUMBER;
+ return EFI_SUCCESS;
+ } else if (*TokenNumber >= DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER) {
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_SUCCESS;
+ }
+ }
+ }
+
+ if (PEI_EXMAP_TABLE_EMPTY && PEI_EXMAP_TABLE_EMPTY) {
+ *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
+ }
+
+ ExTokenNumber = *TokenNumber;
+ if (!PEI_EXMAP_TABLE_EMPTY) {
+ ExTokenNumber = ExGetNextTokeNumber (
+ Guid,
+ ExTokenNumber,
+ mPcdDatabase->PeiDb.Init.GuidTable,
+ sizeof(mPcdDatabase->PeiDb.Init.GuidTable),
+ mPcdDatabase->PeiDb.Init.ExMapTable,
+ sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)
+ );
+ }
+
+ if (!DXE_EXMAP_TABLE_EMPTY) {
+ ExTokenNumber = ExGetNextTokeNumber (
+ Guid,
+ ExTokenNumber,
+ mPcdDatabase->PeiDb.Init.GuidTable,
+ sizeof(mPcdDatabase->PeiDb.Init.GuidTable),
+ mPcdDatabase->PeiDb.Init.ExMapTable,
+ sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)
+ );
+ }
+
+ *TokenNumber = ExTokenNumber;
+
+ return EFI_SUCCESS;
}
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.c b/EdkModulePkg/Universal/PCD/Dxe/Service.c index 52097ad..ebef595 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Service.c +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.c @@ -22,13 +22,9 @@ Module Name: Service.c // Compression Algorithm will take care of the size optimization.
//
-/*
-DXE_PCD_DATABASE_INIT gDXEPcdDbInit = {
- DXE_PCD_DB_INIT_VALUE
-};
-*/
+PCD_DATABASE * mPcdDatabase;
-PCD_DATABASE * gPcdDatabase;
+LIST_ENTRY mCallbackFnTable[PCD_TOTAL_TOKEN_NUMBER];
VOID *
GetWorkerByLocalTokenNumber (
@@ -54,9 +50,9 @@ GetWorkerByLocalTokenNumber ( LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
}
- PcdDb = IsPeiDb ? ((UINT8 *) &gPcdDatabase->PeiDb) : ((UINT8 *) &gPcdDatabase->DxeDb);
- StringTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.StringTable :
- gPcdDatabase->DxeDb.Init.StringTable;
+ PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
+ StringTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.StringTable :
+ mPcdDatabase->DxeDb.Init.StringTable;
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
@@ -66,8 +62,8 @@ GetWorkerByLocalTokenNumber ( return (VOID *) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
case PCD_TYPE_HII:
- GuidTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.GuidTable :
- gPcdDatabase->DxeDb.Init.GuidTable;
+ GuidTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.GuidTable :
+ mPcdDatabase->DxeDb.Init.GuidTable;
VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
@@ -112,11 +108,11 @@ GetWorker ( IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
- LocalTokenNumberTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
- gPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
+ LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
+ mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
- SizeTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.SizeTable:
- gPcdDatabase->DxeDb.Init.SizeTable;
+ SizeTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SizeTable:
+ mPcdDatabase->DxeDb.Init.SizeTable;
TokenNumber = IsPeiDb ? TokenNumber :
TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
@@ -129,23 +125,150 @@ EFI_STATUS DxeRegisterCallBackWorker (
IN UINTN TokenNumber,
IN CONST GUID *Guid, OPTIONAL
- IN PCD_PROTOCOL_CALLBACK CallBackFunction,
- IN BOOLEAN Register
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
{
+ CALLBACK_FN_ENTRY *FnTableEntry;
+ EX_PCD_ENTRY_ATTRIBUTE ExAttr;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *ListNode;
+
+ if (Guid != NULL) {
+ GetExPcdTokenAttributes (Guid, TokenNumber, &ExAttr);
+ TokenNumber = ExAttr.LocalTokenNumberAlias;
+ }
+
+ ListHead = &mCallbackFnTable[TokenNumber];
+ ListNode = GetFirstNode (ListHead);
+
+ while (ListNode != ListHead) {
+ FnTableEntry = CR_FNENTRY_FROM_LISTNODE(ListNode, CALLBACK_FN_ENTRY, Node);
+
+ if (FnTableEntry->CallbackFn == CallBackFunction) {
+ //
+ // We only allow a Callback function to be register once
+ // for a TokenNumber. So just return EFI_SUCCESS
+ //
+ return EFI_SUCCESS;
+ }
+ ListNode = GetNextNode (ListHead, ListNode);
+ }
+
+ FnTableEntry = AllocatePool (sizeof(CALLBACK_FN_ENTRY));
+ ASSERT (FnTableEntry != NULL);
+
+ FnTableEntry->CallbackFn = CallBackFunction;
+ InsertTailList (ListHead, &FnTableEntry->Node);
return EFI_SUCCESS;
}
+
+
EFI_STATUS
-DxeGetNextTokenWorker (
- IN OUT UINTN *TokenNumber,
- IN CONST GUID *Guid OPTIONAL
+DxeUnRegisterCallBackWorker (
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+)
+{
+ CALLBACK_FN_ENTRY *FnTableEntry;
+ EX_PCD_ENTRY_ATTRIBUTE ExAttr;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *ListNode;
+
+ if (Guid != NULL) {
+ GetExPcdTokenAttributes (Guid, TokenNumber, &ExAttr);
+ TokenNumber = ExAttr.LocalTokenNumberAlias;
+ }
+
+ ListHead = &mCallbackFnTable[TokenNumber];
+ ListNode = GetFirstNode (ListHead);
+
+ while (ListNode != ListHead) {
+ FnTableEntry = CR_FNENTRY_FROM_LISTNODE(ListNode, CALLBACK_FN_ENTRY, Node);
+
+ if (FnTableEntry->CallbackFn == CallBackFunction) {
+ //
+ // We only allow a Callback function to be register once
+ // for a TokenNumber. So we can safely remove the Node from
+ // the Link List and return EFI_SUCCESS.
+ //
+ RemoveEntryList (ListNode);
+ FreePool (FnTableEntry);
+
+ return EFI_SUCCESS;
+ }
+ ListNode = GetNextNode (ListHead, ListNode);
+ }
+
+ return EFI_INVALID_PARAMETER;
+}
+
+
+
+PCD_TOKEN_NUMBER
+ExGetNextTokeNumber (
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN EFI_GUID *GuidTable,
+ IN UINTN SizeOfGuidTable,
+ IN DYNAMICEX_MAPPING *ExMapTable,
+ IN UINTN SizeOfExMapTable
)
{
- return EFI_SUCCESS;
+ EFI_GUID *MatchGuid;
+ UINTN Idx;
+ UINTN GuidTableIdx;
+ BOOLEAN Found;
+
+ MatchGuid = ScanGuid (GuidTable, SizeOfGuidTable, Guid);
+ if (MatchGuid == NULL) {
+ return PCD_INVALID_TOKEN_NUMBER;
+ }
+
+ Found = FALSE;
+ GuidTableIdx = MatchGuid - GuidTable;
+ for (Idx = 0; Idx < SizeOfExMapTable; Idx++) {
+ if (ExMapTable[Idx].ExGuidIndex == GuidTableIdx) {
+ Found = TRUE;
+ break;
+ }
+ }
+
+ if (Found) {
+ if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
+ return ExMapTable[Idx].ExTokenNumber;
+ }
+
+ for ( ; Idx < SizeOfExMapTable; Idx++) {
+ if (ExMapTable[Idx].ExTokenNumber == TokenNumber) {
+ Idx++;
+ if (Idx == SizeOfExMapTable) {
+ //
+ // Exceed the length of ExMap Table
+ //
+ return PCD_INVALID_TOKEN_NUMBER;
+ } else if (ExMapTable[Idx].ExGuidIndex == GuidTableIdx) {
+ //
+ // Found the next match
+ //
+ return ExMapTable[Idx].ExTokenNumber;
+ } else {
+ //
+ // Guid has been changed. It is the next Token Space Guid.
+ // We should flag no more TokenNumber.
+ //
+ return PCD_INVALID_TOKEN_NUMBER;
+ }
+ }
+ }
+ }
+
+ return PCD_INVALID_TOKEN_NUMBER;
}
+
@@ -156,9 +279,10 @@ BuildPcdDxeDataBase ( {
PEI_PCD_DATABASE *PeiDatabase;
EFI_HOB_GUID_TYPE *GuidHob;
+ UINTN Idx;
- gPcdDatabase = AllocateZeroPool (sizeof(PCD_DATABASE));
- ASSERT (gPcdDatabase != NULL);
+ mPcdDatabase = AllocateZeroPool (sizeof(PCD_DATABASE));
+ ASSERT (mPcdDatabase != NULL);
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
ASSERT (GuidHob != NULL);
@@ -167,12 +291,20 @@ BuildPcdDxeDataBase ( //
// Copy PCD Entries refereneced in PEI phase to PCD DATABASE
//
- CopyMem (&gPcdDatabase->PeiDb, PeiDatabase, sizeof (PEI_PCD_DATABASE));
+ CopyMem (&mPcdDatabase->PeiDb, PeiDatabase, sizeof (PEI_PCD_DATABASE));
//
// Copy PCD Entries with default value to PCD DATABASE
//
- CopyMem (&gPcdDatabase->DxeDb.Init, &gDXEPcdDbInit, sizeof(DXE_PCD_DATABASE_INIT));
+ CopyMem (&mPcdDatabase->DxeDb.Init, &gDXEPcdDbInit, sizeof(DXE_PCD_DATABASE_INIT));
+
+
+ //
+ // Initialized the Callback Function Table
+ //
+ for (Idx = 0; Idx < PCD_TOTAL_TOKEN_NUMBER; Idx++) {
+ InitializeListHead (&mCallbackFnTable[Idx]);
+ }
return;
}
@@ -233,18 +365,18 @@ GetSkuEnabledTokenNumber ( ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);
- PcdDb = IsPeiDb ? (UINT8 *) &gPcdDatabase->PeiDb : (UINT8 *) &gPcdDatabase->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 ? gPcdDatabase->PeiDb.Init.SkuIdTable :
- gPcdDatabase->DxeDb.Init.SkuIdTable;
+ PhaseSkuIdTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SkuIdTable :
+ mPcdDatabase->DxeDb.Init.SkuIdTable;
SkuIdTable = &PhaseSkuIdTable[SkuHead->SkuIdTableOffset];
for (i = 0; i < SkuIdTable[0]; i++) {
- if (gPcdDatabase->PeiDb.Init.SystemSkuId == SkuIdTable[i + 1]) {
+ if (mPcdDatabase->PeiDb.Init.SystemSkuId == SkuIdTable[i + 1]) {
break;
}
}
@@ -286,6 +418,24 @@ InvokeCallbackOnSet ( UINTN Size
)
{
+ CALLBACK_FN_ENTRY *FnTableEntry;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *ListNode;
+
+ ListHead = &mCallbackFnTable[TokenNumber];
+ ListNode = GetFirstNode (ListHead);
+
+ while (ListNode != ListHead) {
+ FnTableEntry = CR_FNENTRY_FROM_LISTNODE(ListNode, CALLBACK_FN_ENTRY, Node);
+
+ FnTableEntry->CallbackFn(Guid,
+ (Guid == NULL) ? TokenNumber : ExTokenNumber,
+ Data,
+ Size);
+
+ ListNode = GetNextNode (ListHead, ListNode);
+ }
+
return;
}
@@ -314,8 +464,8 @@ SetWorker ( IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
- LocalTokenNumberTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
- gPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
+ LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
+ mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
TokenNumber = IsPeiDb ? TokenNumber
: TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
@@ -406,10 +556,10 @@ SetWorkerByLocalTokenNumber ( Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
- PcdDb = IsPeiDb ? ((UINT8 *) &gPcdDatabase->PeiDb) : ((UINT8 *) &gPcdDatabase->DxeDb);
+ PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
- StringTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.StringTable :
- gPcdDatabase->DxeDb.Init.StringTable;
+ StringTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.StringTable :
+ mPcdDatabase->DxeDb.Init.StringTable;
InternalData = PcdDb + Offset;
@@ -426,8 +576,8 @@ SetWorkerByLocalTokenNumber ( //
// Bug Bug: Please implement this
//
- GuidTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.GuidTable :
- gPcdDatabase->DxeDb.Init.GuidTable;
+ GuidTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.GuidTable :
+ mPcdDatabase->DxeDb.Init.GuidTable;
VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
@@ -542,9 +692,9 @@ GetExPcdTokenAttributes ( EFI_GUID *GuidTable;
UINT16 *SizeTable;
- ExMap = gPcdDatabase->PeiDb.Init.ExMapTable;
- GuidTable = gPcdDatabase->PeiDb.Init.GuidTable;
- SizeTable = gPcdDatabase->PeiDb.Init.SizeTable;
+ ExMap = mPcdDatabase->PeiDb.Init.ExMapTable;
+ GuidTable = mPcdDatabase->PeiDb.Init.GuidTable;
+ SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
@@ -560,9 +710,9 @@ GetExPcdTokenAttributes ( }
}
- ExMap = gPcdDatabase->DxeDb.Init.ExMapTable;
- GuidTable = gPcdDatabase->DxeDb.Init.GuidTable;
- SizeTable = gPcdDatabase->DxeDb.Init.SizeTable;
+ ExMap = mPcdDatabase->DxeDb.Init.ExMapTable;
+ GuidTable = mPcdDatabase->DxeDb.Init.GuidTable;
+ SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;
for (i = 0; i < DXE_EXMAPPING_TABLE_SIZE; i++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h index 54ab1b6..d33a891 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Service.h +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h @@ -32,6 +32,14 @@ Module Name: Service.h #error "Please make sure the version of PCD Service DXE Driver and PCD DXE Database Generation Tool matches"
#endif
+
+typedef struct {
+ LIST_ENTRY Node;
+ PCD_PROTOCOL_CALLBACK CallbackFn;
+} CALLBACK_FN_ENTRY;
+
+#define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) _CR(Record, Type, Field)
+
//
// Internal Functions
//
@@ -89,17 +97,17 @@ GetHiiVariable ( EFI_STATUS
DxeRegisterCallBackWorker (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
- IN PCD_PROTOCOL_CALLBACK CallBackFunction,
- IN BOOLEAN Reigster
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
);
EFI_STATUS
-DxeGetNextTokenWorker (
- IN OUT UINTN *Token,
- IN CONST EFI_GUID *Guid OPTIONAL
- );
+DxeUnRegisterCallBackWorker (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+);
VOID
BuildPcdDxeDataBase (
@@ -363,7 +371,7 @@ DxePcdSetPtrEx ( EFI_STATUS
EFIAPI
DxePcdSetBoolEx (
- IN CONST EFI_GUID *Guid,
+ IN CONST EFI_GUID *Guid,
IN PCD_TOKEN_NUMBER TokenNumber,
IN BOOLEAN Value
)
@@ -373,9 +381,9 @@ DxePcdSetBoolEx ( EFI_STATUS
EFIAPI
-PcdRegisterCallBackOnSet (
+DxeRegisterCallBackOnSet (
IN PCD_TOKEN_NUMBER TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
+ IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
;
@@ -383,7 +391,7 @@ PcdRegisterCallBackOnSet ( EFI_STATUS
EFIAPI
-PcdUnRegisterCallBackOnSet (
+DxeUnRegisterCallBackOnSet (
IN PCD_TOKEN_NUMBER TokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction
@@ -409,9 +417,20 @@ SetWorkerByLocalTokenNumber ( )
;
+PCD_TOKEN_NUMBER
+ExGetNextTokeNumber (
+ IN CONST EFI_GUID *Guid,
+ IN PCD_TOKEN_NUMBER TokenNumber,
+ IN EFI_GUID *GuidTable,
+ IN UINTN SizeOfGuidTable,
+ IN DYNAMICEX_MAPPING *ExMapTable,
+ IN UINTN SizeOfExMapTable
+ )
+;
+
extern EFI_GUID gPcdDataBaseHobGuid;
-extern PCD_DATABASE * gPcdDatabase;
+extern PCD_DATABASE * mPcdDatabase;
extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;
diff --git a/EdkModulePkg/Universal/PCD/Pei/Pcd.c b/EdkModulePkg/Universal/PCD/Pei/Pcd.c index 1f6db7a..031259b 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Pcd.c +++ b/EdkModulePkg/Universal/PCD/Pei/Pcd.c @@ -50,7 +50,7 @@ PCD_PPI mPcdPpiInstance = { PeiPcdSetPtrEx,
PeiPcdSetBoolEx,
- PcdRegisterCallBackOnSet,
+ PeiRegisterCallBackOnSet,
PcdUnRegisterCallBackOnSet,
PeiPcdGetNextToken
};
@@ -454,12 +454,14 @@ PeiPcdSetBoolEx ( EFI_STATUS
EFIAPI
-PcdRegisterCallBackOnSet (
+PeiRegisterCallBackOnSet (
IN PCD_TOKEN_NUMBER ExTokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction
)
{
+ ASSERT (CallBackFunction != NULL);
+
return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);
}
@@ -473,6 +475,8 @@ PcdUnRegisterCallBackOnSet ( IN PCD_PPI_CALLBACK CallBackFunction
)
{
+ ASSERT (CallBackFunction != NULL);
+
return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);
}
@@ -482,7 +486,7 @@ EFI_STATUS EFIAPI
PeiPcdGetNextToken (
IN CONST EFI_GUID *Guid, OPTIONAL
- IN OUT PCD_TOKEN_NUMBER *TokenNumber
+ IN OUT PCD_TOKEN_NUMBER *TokenNumber
)
{
UINTN GuidTableIdx;
diff --git a/EdkModulePkg/Universal/PCD/Pei/Service.h b/EdkModulePkg/Universal/PCD/Pei/Service.h index 5f334e1..611427b 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Service.h +++ b/EdkModulePkg/Universal/PCD/Pei/Service.h @@ -358,7 +358,7 @@ PeiPcdSetBoolEx ( EFI_STATUS
EFIAPI
-PcdRegisterCallBackOnSet (
+PeiRegisterCallBackOnSet (
IN PCD_TOKEN_NUMBER TokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction
|