Refine some internal functions of PCD Driver.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@314 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2006-05-29 12:56:03 +00:00
parent 0653eb895d
commit 9d6d8b24f3
6 changed files with 221 additions and 329 deletions

View File

@ -116,9 +116,7 @@ DxePcdGet8 (
IN PCD_TOKEN_NUMBER TokenNumber IN PCD_TOKEN_NUMBER TokenNumber
) )
{ {
ASSERT (sizeof (UINT8) == DxePcdGetSize (TokenNumber)); return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));
return *((UINT8 *) GetWorker (TokenNumber));
} }
@ -129,9 +127,7 @@ DxePcdGet16 (
IN PCD_TOKEN_NUMBER TokenNumber IN PCD_TOKEN_NUMBER TokenNumber
) )
{ {
ASSERT (sizeof (UINT16) == DxePcdGetSize (TokenNumber)); return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));
return ReadUnaligned16 (GetWorker (TokenNumber));
} }
@ -142,9 +138,7 @@ DxePcdGet32 (
IN PCD_TOKEN_NUMBER TokenNumber IN PCD_TOKEN_NUMBER TokenNumber
) )
{ {
ASSERT (sizeof (UINT32) == DxePcdGetSize (TokenNumber)); return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));
return ReadUnaligned32 (GetWorker (TokenNumber));
} }
@ -155,9 +149,7 @@ DxePcdGet64 (
IN PCD_TOKEN_NUMBER TokenNumber IN PCD_TOKEN_NUMBER TokenNumber
) )
{ {
ASSERT (sizeof (UINT64) == DxePcdGetSize (TokenNumber)); return ReadUnaligned64(GetWorker (TokenNumber, sizeof (UINT64)));
return ReadUnaligned64(GetWorker (TokenNumber));
} }
@ -168,7 +160,7 @@ DxePcdGetPtr (
IN PCD_TOKEN_NUMBER TokenNumber IN PCD_TOKEN_NUMBER TokenNumber
) )
{ {
return GetWorker (TokenNumber); return GetWorker (TokenNumber, 0);
} }
@ -179,9 +171,7 @@ DxePcdGetBool (
IN PCD_TOKEN_NUMBER TokenNumber IN PCD_TOKEN_NUMBER TokenNumber
) )
{ {
ASSERT (sizeof (BOOLEAN) == DxePcdGetSize (TokenNumber)); return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));
return *((BOOLEAN *) GetWorker (TokenNumber));
} }
@ -224,7 +214,7 @@ DxePcdGet16Ex (
IN PCD_TOKEN_NUMBER ExTokenNumber IN PCD_TOKEN_NUMBER ExTokenNumber
) )
{ {
return *((UINT16 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16))); return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));
} }
@ -236,7 +226,7 @@ DxePcdGet32Ex (
IN PCD_TOKEN_NUMBER ExTokenNumber IN PCD_TOKEN_NUMBER ExTokenNumber
) )
{ {
return *((UINT32 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32))); return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));
} }
@ -248,10 +238,7 @@ DxePcdGet64Ex (
IN PCD_TOKEN_NUMBER ExTokenNumber IN PCD_TOKEN_NUMBER ExTokenNumber
) )
{ {
// return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));
// BugBug: Must be changed to ReadUnaligned64
//
return *((UINT64 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));
} }
@ -287,11 +274,7 @@ DxePcdGetSizeEx (
IN PCD_TOKEN_NUMBER ExTokenNumber IN PCD_TOKEN_NUMBER ExTokenNumber
) )
{ {
EX_PCD_ENTRY_ATTRIBUTE Attr; return DxePcdGetSize(GetExPcdTokenNumber (Guid, ExTokenNumber));
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
return Attr.Size;
} }

View File

@ -27,12 +27,15 @@ PCD_DATABASE * mPcdDatabase;
LIST_ENTRY mCallbackFnTable[PCD_TOTAL_TOKEN_NUMBER]; LIST_ENTRY mCallbackFnTable[PCD_TOTAL_TOKEN_NUMBER];
VOID * VOID *
GetWorkerByLocalTokenNumber ( GetWorker (
UINT32 LocalTokenNumber, PCD_TOKEN_NUMBER TokenNumber,
BOOLEAN IsPeiDb, UINTN GetSize
UINTN Size
) )
{ {
UINT32 *LocalTokenNumberTable;
UINT16 *SizeTable;
BOOLEAN IsPeiDb;
UINTN Size;
UINT32 Offset; UINT32 Offset;
EFI_GUID *GuidTable; EFI_GUID *GuidTable;
UINT16 *StringTable; UINT16 *StringTable;
@ -45,6 +48,27 @@ GetWorkerByLocalTokenNumber (
VPD_HEAD *VpdHead; VPD_HEAD *VpdHead;
UINT8 *PcdDb; UINT8 *PcdDb;
UINT16 StringTableIdx; UINT16 StringTableIdx;
UINT32 LocalTokenNumber;
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
Size = DxePcdGetSize (TokenNumber);
ASSERT (GetSize == Size || GetSize == 0);
IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
SizeTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SizeTable:
mPcdDatabase->DxeDb.Init.SizeTable;
TokenNumber = IsPeiDb ? TokenNumber :
TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) { if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb); LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
@ -93,49 +117,24 @@ GetWorkerByLocalTokenNumber (
ASSERT (FALSE); ASSERT (FALSE);
return NULL; return NULL;
}
VOID *
GetWorker (
UINTN TokenNumber
)
{
UINT32 *LocalTokenNumberTable;
UINT16 *SizeTable;
BOOLEAN IsPeiDb;
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
SizeTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SizeTable:
mPcdDatabase->DxeDb.Init.SizeTable;
TokenNumber = IsPeiDb ? TokenNumber :
TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
return GetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], IsPeiDb, SizeTable[TokenNumber]);
} }
EFI_STATUS EFI_STATUS
DxeRegisterCallBackWorker ( DxeRegisterCallBackWorker (
IN UINTN TokenNumber, IN PCD_TOKEN_NUMBER TokenNumber,
IN CONST GUID *Guid, OPTIONAL IN CONST GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction IN PCD_PROTOCOL_CALLBACK CallBackFunction
) )
{ {
CALLBACK_FN_ENTRY *FnTableEntry; CALLBACK_FN_ENTRY *FnTableEntry;
EX_PCD_ENTRY_ATTRIBUTE ExAttr;
LIST_ENTRY *ListHead; LIST_ENTRY *ListHead;
LIST_ENTRY *ListNode; LIST_ENTRY *ListNode;
if (Guid != NULL) { if (Guid != NULL) {
GetExPcdTokenAttributes (Guid, TokenNumber, &ExAttr); TokenNumber = GetExPcdTokenNumber (Guid, TokenNumber);
TokenNumber = ExAttr.LocalTokenNumberAlias;
} }
ListHead = &mCallbackFnTable[TokenNumber]; ListHead = &mCallbackFnTable[TokenNumber];
@ -168,19 +167,17 @@ DxeRegisterCallBackWorker (
EFI_STATUS EFI_STATUS
DxeUnRegisterCallBackWorker ( DxeUnRegisterCallBackWorker (
IN UINTN TokenNumber, IN PCD_TOKEN_NUMBER TokenNumber,
IN CONST GUID *Guid, OPTIONAL IN CONST GUID *Guid, OPTIONAL
IN PCD_PROTOCOL_CALLBACK CallBackFunction IN PCD_PROTOCOL_CALLBACK CallBackFunction
) )
{ {
CALLBACK_FN_ENTRY *FnTableEntry; CALLBACK_FN_ENTRY *FnTableEntry;
EX_PCD_ENTRY_ATTRIBUTE ExAttr;
LIST_ENTRY *ListHead; LIST_ENTRY *ListHead;
LIST_ENTRY *ListNode; LIST_ENTRY *ListNode;
if (Guid != NULL) { if (Guid != NULL) {
GetExPcdTokenAttributes (Guid, TokenNumber, &ExAttr); TokenNumber = GetExPcdTokenNumber (Guid, TokenNumber);
TokenNumber = ExAttr.LocalTokenNumberAlias;
} }
ListHead = &mCallbackFnTable[TokenNumber]; ListHead = &mCallbackFnTable[TokenNumber];
@ -452,6 +449,15 @@ SetWorker (
{ {
UINT32 *LocalTokenNumberTable; UINT32 *LocalTokenNumberTable;
BOOLEAN IsPeiDb; BOOLEAN IsPeiDb;
UINT32 LocalTokenNumber;
EFI_GUID *GuidTable;
UINT16 *StringTable;
EFI_GUID *Guid;
UINT16 *Name;
VOID *InternalData;
VARIABLE_HEAD *VariableHead;
UINTN Offset;
UINT8 *PcdDb;
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER); ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
@ -467,88 +473,15 @@ SetWorker (
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable : LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
mPcdDatabase->DxeDb.Init.LocalTokenNumberTable; mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
InvokeCallbackOnSet (0, NULL, TokenNumber, Data, Size); if ((TokenNumber < PEI_NEX_TOKEN_NUMBER) ||
(TokenNumber >= PEI_LOCAL_TOKEN_NUMBER || TokenNumber < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER))) {
InvokeCallbackOnSet (0, NULL, TokenNumber, Data, Size);
}
TokenNumber = IsPeiDb ? TokenNumber TokenNumber = IsPeiDb ? TokenNumber
: TokenNumber - PEI_LOCAL_TOKEN_NUMBER; : TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
return SetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], Data, Size, PtrType, IsPeiDb); LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
}
VOID *
ExGetWorker (
IN CONST EFI_GUID *Guid,
IN UINTN ExTokenNumber,
IN UINTN GetSize
)
{
EX_PCD_ENTRY_ATTRIBUTE Attr;
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
ASSERT ((GetSize == Attr.Size) || (GetSize == 0));
return GetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias,
Attr.IsPeiDb,
Attr.Size
);
}
EFI_STATUS
ExSetWorker (
IN PCD_TOKEN_NUMBER ExTokenNumber,
IN CONST EFI_GUID *Guid,
VOID *Data,
UINTN SetSize,
BOOLEAN PtrType
)
{
EX_PCD_ENTRY_ATTRIBUTE Attr;
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
ASSERT (!PtrType && (SetSize == Attr.Size));
ASSERT (PtrType && (SetSize <= Attr.Size));
InvokeCallbackOnSet (ExTokenNumber, Guid, Attr.TokenNumber, Data, Attr.Size);
SetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias, Data, Attr.Size, PtrType, Attr.IsPeiDb);
return EFI_SUCCESS;
}
EFI_STATUS
SetWorkerByLocalTokenNumber (
UINT32 LocalTokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType,
BOOLEAN IsPeiDb
)
{
EFI_GUID *GuidTable;
UINT16 *StringTable;
EFI_GUID *Guid;
UINT16 *Name;
VOID *InternalData;
VARIABLE_HEAD *VariableHead;
UINTN Offset;
UINT8 *PcdDb;
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) { if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb); LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
@ -625,6 +558,46 @@ SetWorkerByLocalTokenNumber (
VOID *
ExGetWorker (
IN CONST EFI_GUID *Guid,
IN UINTN ExTokenNumber,
IN UINTN GetSize
)
{
return GetWorker(GetExPcdTokenNumber (Guid, ExTokenNumber), GetSize);
}
EFI_STATUS
ExSetWorker (
IN PCD_TOKEN_NUMBER ExTokenNumber,
IN CONST EFI_GUID *Guid,
VOID *Data,
UINTN SetSize,
BOOLEAN PtrType
)
{
PCD_TOKEN_NUMBER TokenNumber;
TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
InvokeCallbackOnSet (ExTokenNumber, Guid, TokenNumber, Data, SetSize);
SetWorker (TokenNumber, Data, SetSize, PtrType);
return EFI_SUCCESS;
}
EFI_STATUS EFI_STATUS
SetHiiVariable ( SetHiiVariable (
IN EFI_GUID *VariableGuid, IN EFI_GUID *VariableGuid,
@ -680,56 +653,51 @@ SetHiiVariable (
VOID PCD_TOKEN_NUMBER
GetExPcdTokenAttributes ( GetExPcdTokenNumber (
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
IN PCD_TOKEN_NUMBER ExTokenNumber, IN PCD_TOKEN_NUMBER ExTokenNumber
OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
) )
{ {
UINT32 i; UINT32 i;
DYNAMICEX_MAPPING *ExMap; DYNAMICEX_MAPPING *ExMap;
EFI_GUID *GuidTable; EFI_GUID *GuidTable;
UINT16 *SizeTable; EFI_GUID *MatchGuid;
UINTN MatchGuidIdx;
ExMap = mPcdDatabase->PeiDb.Init.ExMapTable; ExMap = mPcdDatabase->PeiDb.Init.ExMapTable;
GuidTable = mPcdDatabase->PeiDb.Init.GuidTable; GuidTable = mPcdDatabase->PeiDb.Init.GuidTable;
SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;
MatchGuid = ScanGuid (GuidTable, sizeof(mPcdDatabase->PeiDb.Init.GuidTable), Guid);
ASSERT (MatchGuid != NULL);
MatchGuidIdx = MatchGuid - GuidTable;
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) { for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) && if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex]) (MatchGuidIdx == ExMap[i].ExGuidIndex)) {
) { return ExMap[i].LocalTokenNumber;
ExAttr->IsPeiDb = TRUE;
ExAttr->Size = SizeTable[i + PEI_NEX_TOKEN_NUMBER];
ExAttr->TokenNumber = i + PEI_NEX_TOKEN_NUMBER;
ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
return;
} }
} }
ExMap = mPcdDatabase->DxeDb.Init.ExMapTable; ExMap = mPcdDatabase->DxeDb.Init.ExMapTable;
GuidTable = mPcdDatabase->DxeDb.Init.GuidTable; GuidTable = mPcdDatabase->DxeDb.Init.GuidTable;
SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;
MatchGuid = ScanGuid (GuidTable, sizeof(mPcdDatabase->DxeDb.Init.GuidTable), Guid);
ASSERT (MatchGuid != NULL);
MatchGuidIdx = MatchGuid - GuidTable;
for (i = 0; i < DXE_EXMAPPING_TABLE_SIZE; i++) { for (i = 0; i < DXE_EXMAPPING_TABLE_SIZE; i++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) && if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex]) (MatchGuidIdx == ExMap[i].ExGuidIndex)) {
) { return ExMap[i].LocalTokenNumber + PEI_LOCAL_TOKEN_NUMBER;
ExAttr->IsPeiDb = FALSE;
ExAttr->Size = SizeTable[i + DXE_NEX_TOKEN_NUMBER];
ExAttr->TokenNumber = i + PEI_LOCAL_TOKEN_NUMBER;
ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
return;
} }
} }
ASSERT (FALSE); ASSERT (FALSE);
return; return 0;
} }

View File

@ -66,7 +66,8 @@ ExSetWorker (
VOID * VOID *
GetWorker ( GetWorker (
PCD_TOKEN_NUMBER TokenNumber PCD_TOKEN_NUMBER TokenNumber,
UINTN GetSize
) )
; ;
@ -115,21 +116,12 @@ BuildPcdDxeDataBase (
); );
typedef struct { PCD_TOKEN_NUMBER
UINTN TokenNumber; GetExPcdTokenNumber (
UINTN Size;
UINT32 LocalTokenNumberAlias;
BOOLEAN IsPeiDb;
} EX_PCD_ENTRY_ATTRIBUTE;
VOID
GetExPcdTokenAttributes (
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
IN PCD_TOKEN_NUMBER ExTokenNumber, IN PCD_TOKEN_NUMBER ExTokenNumber
OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
) )
; ;
// //
// Protocol Interface function declaration. // Protocol Interface function declaration.
// //
@ -407,16 +399,6 @@ DxePcdGetNextToken (
) )
; ;
EFI_STATUS
SetWorkerByLocalTokenNumber (
UINT32 LocalTokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType,
BOOLEAN IsPeiDb
)
;
PCD_TOKEN_NUMBER PCD_TOKEN_NUMBER
ExGetNextTokeNumber ( ExGetNextTokeNumber (
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,

View File

@ -255,11 +255,7 @@ PeiPcdGetSizeEx (
IN PCD_TOKEN_NUMBER ExTokenNumber IN PCD_TOKEN_NUMBER ExTokenNumber
) )
{ {
EX_PCD_ENTRY_ATTRIBUTE Attr; return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
return Attr.Size;
} }

View File

@ -30,7 +30,7 @@ Module Name: Service.c
--*/ --*/
EFI_STATUS EFI_STATUS
PeiRegisterCallBackWorker ( PeiRegisterCallBackWorker (
IN UINTN ExTokenNumber, IN PCD_TOKEN_NUMBER ExTokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction, IN PCD_PPI_CALLBACK CallBackFunction,
IN BOOLEAN Register IN BOOLEAN Register
@ -41,20 +41,19 @@ PeiRegisterCallBackWorker (
PCD_PPI_CALLBACK Compare; PCD_PPI_CALLBACK Compare;
PCD_PPI_CALLBACK Assign; PCD_PPI_CALLBACK Assign;
UINT32 LocalTokenNumber; UINT32 LocalTokenNumber;
UINTN TokenNumber; PCD_TOKEN_NUMBER TokenNumber;
UINTN Idx; UINTN Idx;
EX_PCD_ENTRY_ATTRIBUTE Attr;
if (Guid == NULL) { if (Guid == NULL) {
TokenNumber = ExTokenNumber; TokenNumber = ExTokenNumber;
ASSERT (TokenNumber < PEI_NEX_TOKEN_NUMBER); ASSERT (TokenNumber < PEI_NEX_TOKEN_NUMBER);
LocalTokenNumber = GetPcdDatabase()->Init.LocalTokenNumberTable[TokenNumber];
} else { } else {
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr); TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
TokenNumber = Attr.TokenNumber; ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
LocalTokenNumber = Attr.LocalTokenNumberAlias;
} }
LocalTokenNumber = GetPcdDatabase()->Init.LocalTokenNumberTable[TokenNumber];
ASSERT ((LocalTokenNumber & PCD_TYPE_HII) == 0); ASSERT ((LocalTokenNumber & PCD_TYPE_HII) == 0);
ASSERT ((LocalTokenNumber & PCD_TYPE_VPD) == 0); ASSERT ((LocalTokenNumber & PCD_TYPE_VPD) == 0);
@ -267,16 +266,22 @@ InvokeCallbackOnSet (
} }
EFI_STATUS EFI_STATUS
SetWorker ( SetWorker (
UINTN TokenNumber, PCD_TOKEN_NUMBER TokenNumber,
VOID *Data, VOID *Data,
UINTN Size, UINTN Size,
BOOLEAN PtrType BOOLEAN PtrType
) )
{ {
UINT32 LocalTokenNumber; UINT32 LocalTokenNumber;
PEI_PCD_DATABASE *PeiPcdDb; PEI_PCD_DATABASE *PeiPcdDb;
UINT16 StringTableIdx;
UINTN Offset;
VOID *InternalData;
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER); ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
@ -290,71 +295,21 @@ SetWorker (
ASSERT (PeiPcdDb->Init.SizeTable[TokenNumber] == Size); ASSERT (PeiPcdDb->Init.SizeTable[TokenNumber] == Size);
} }
InvokeCallbackOnSet (0, NULL, TokenNumber, Data, Size); //
// We only invoke the callback function for Dynamic Type PCD Entry.
return SetWorkerByLocalTokenNumber (LocalTokenNumber, Data, Size, PtrType); // For Dynamic EX PCD entry, we have invoked the callback function for Dynamic EX
// type PCD entry in ExSetWorker.
} //
if (TokenNumber < PEI_NEX_TOKEN_NUMBER) {
InvokeCallbackOnSet (0, NULL, TokenNumber, Data, Size);
}
EFI_STATUS
ExSetWorker (
IN UINT32 ExTokenNumber,
IN CONST EFI_GUID *Guid,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
{
PEI_PCD_DATABASE *PeiPcdDb;
EX_PCD_ENTRY_ATTRIBUTE Attr;
PeiPcdDb = GetPcdDatabase ();
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
ASSERT (!PtrType && Attr.Size);
ASSERT (PtrType && Attr.Size >= Size);
InvokeCallbackOnSet (ExTokenNumber, Guid, Attr.TokenNumber, Data, Size);
SetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias, Data, Size, PtrType);
return EFI_SUCCESS;
}
EFI_STATUS
SetWorkerByLocalTokenNumber (
UINT32 LocalTokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
{
PEI_PCD_DATABASE *PeiPcdDb;
UINT8 *PeiPcdDbRaw;
UINT16 StringTableIdx;
UINTN Offset;
VOID *InternalData;
PeiPcdDb = GetPcdDatabase ();
PeiPcdDbRaw = (UINT8 *) PeiPcdDb;
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) { if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size); LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size);
} }
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK; Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
InternalData = (VOID *) (PeiPcdDbRaw + Offset); InternalData = (VOID *) ((UINT8 *) PeiPcdDb + Offset);
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) { switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
case PCD_TYPE_VPD: case PCD_TYPE_VPD:
@ -404,14 +359,53 @@ SetWorkerByLocalTokenNumber (
ASSERT (FALSE); ASSERT (FALSE);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
EFI_STATUS
ExSetWorker (
IN PCD_TOKEN_NUMBER ExTokenNumber,
IN CONST EFI_GUID *Guid,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
{
PCD_TOKEN_NUMBER TokenNumber;
TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
InvokeCallbackOnSet (ExTokenNumber, Guid, TokenNumber, Data, Size);
SetWorker (TokenNumber, Data, Size, PtrType);
return EFI_SUCCESS;
}
VOID * VOID *
GetWorkerByLocalTokenNumber ( ExGetWorker (
PEI_PCD_DATABASE *PeiPcdDb, IN CONST EFI_GUID *Guid,
UINT32 LocalTokenNumber, IN PCD_TOKEN_NUMBER ExTokenNumber,
UINTN Size IN UINTN GetSize
)
{
return GetWorker (GetExPcdTokenNumber (Guid, ExTokenNumber), GetSize);
}
VOID *
GetWorker (
PCD_TOKEN_NUMBER TokenNumber,
UINTN GetSize
) )
{ {
UINT32 Offset; UINT32 Offset;
@ -423,9 +417,20 @@ GetWorkerByLocalTokenNumber (
VOID *Data; VOID *Data;
UINT16 *StringTable; UINT16 *StringTable;
UINT16 StringTableIdx; UINT16 StringTableIdx;
PEI_PCD_DATABASE *PeiPcdDb;
UINT32 LocalTokenNumber;
UINTN Size;
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
Size = PeiPcdGetSize(TokenNumber);
ASSERT (GetSize == Size || GetSize == 0);
PeiPcdDb = GetPcdDatabase (); PeiPcdDb = GetPcdDatabase ();
LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) { if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size); LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size);
} }
@ -476,53 +481,17 @@ GetWorkerByLocalTokenNumber (
} }
VOID * PCD_TOKEN_NUMBER
ExGetWorker ( GetExPcdTokenNumber (
IN CONST EFI_GUID *Guid,
IN UINT32 ExTokenNumber,
IN UINTN GetSize
)
{
EX_PCD_ENTRY_ATTRIBUTE Attr;
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
ASSERT ((GetSize == Attr.Size) || (GetSize == 0));
return GetWorkerByLocalTokenNumber (GetPcdDatabase(),
Attr.LocalTokenNumberAlias,
Attr.Size
);
}
VOID *
GetWorker (
UINTN TokenNumber,
UINTN GetSize
)
{
PEI_PCD_DATABASE *PeiPcdDb;
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
ASSERT (GetSize == PeiPcdGetSize (TokenNumber) || GetSize == 0);
PeiPcdDb = GetPcdDatabase ();
return GetWorkerByLocalTokenNumber (PeiPcdDb, PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber], GetSize);
}
VOID
GetExPcdTokenAttributes (
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
IN UINT32 ExTokenNumber, IN UINT32 ExTokenNumber
OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
) )
{ {
UINT32 i; UINT32 i;
DYNAMICEX_MAPPING *ExMap; DYNAMICEX_MAPPING *ExMap;
EFI_GUID *GuidTable; EFI_GUID *GuidTable;
EFI_GUID *MatchGuid;
UINTN MatchGuidIdx;
PEI_PCD_DATABASE *PeiPcdDb; PEI_PCD_DATABASE *PeiPcdDb;
PeiPcdDb = GetPcdDatabase(); PeiPcdDb = GetPcdDatabase();
@ -530,18 +499,21 @@ GetExPcdTokenAttributes (
ExMap = PeiPcdDb->Init.ExMapTable; ExMap = PeiPcdDb->Init.ExMapTable;
GuidTable = PeiPcdDb->Init.GuidTable; GuidTable = PeiPcdDb->Init.GuidTable;
MatchGuid = ScanGuid (GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);
ASSERT (MatchGuid != NULL);
MatchGuidIdx = MatchGuid - GuidTable;
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) { for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) && if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex])) { (MatchGuidIdx == ExMap[i].ExGuidIndex)) {
ExAttr->TokenNumber = i + PEI_NEX_TOKEN_NUMBER; return ExMap[i].LocalTokenNumber;
ExAttr->Size = PeiPcdDb->Init.SizeTable[i + PEI_NEX_TOKEN_NUMBER];
ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
} }
} }
ASSERT (FALSE); ASSERT (FALSE);
return; return 0;
} }

View File

@ -49,15 +49,6 @@ SetWorker (
) )
; ;
EFI_STATUS
SetWorkerByLocalTokenNumber (
IN UINT32 LocalTokenNumber,
IN VOID *Data,
IN UINTN Size,
IN BOOLEAN PtrType
)
;
EFI_STATUS EFI_STATUS
ExSetWorker ( ExSetWorker (
IN PCD_TOKEN_NUMBER ExTokenNumber, IN PCD_TOKEN_NUMBER ExTokenNumber,
@ -89,11 +80,11 @@ typedef struct {
UINT32 LocalTokenNumberAlias; UINT32 LocalTokenNumberAlias;
} EX_PCD_ENTRY_ATTRIBUTE; } EX_PCD_ENTRY_ATTRIBUTE;
VOID
GetExPcdTokenAttributes ( PCD_TOKEN_NUMBER
GetExPcdTokenNumber (
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
IN PCD_TOKEN_NUMBER ExTokenNumber, IN PCD_TOKEN_NUMBER ExTokenNumber
OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
) )
; ;