summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Universal/PCD/Dxe
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-29 12:56:03 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-29 12:56:03 +0000
commit9d6d8b24f36f782690a918ebabf8da88d54a050e (patch)
treee3d24dddfc8655d6a67f8576bb34bc7dd66bd684 /EdkModulePkg/Universal/PCD/Dxe
parent0653eb895dfb8d059c114120a0779b561c5578ef (diff)
downloadedk2-platforms-9d6d8b24f36f782690a918ebabf8da88d54a050e.tar.xz
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
Diffstat (limited to 'EdkModulePkg/Universal/PCD/Dxe')
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Pcd.c37
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Service.c246
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Service.h28
3 files changed, 122 insertions, 189 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
index 55633148bb..1bde2d8bd4 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
+++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
@@ -116,9 +116,7 @@ DxePcdGet8 (
IN PCD_TOKEN_NUMBER TokenNumber
)
{
- ASSERT (sizeof (UINT8) == DxePcdGetSize (TokenNumber));
-
- return *((UINT8 *) GetWorker (TokenNumber));
+ return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));
}
@@ -129,9 +127,7 @@ DxePcdGet16 (
IN PCD_TOKEN_NUMBER TokenNumber
)
{
- ASSERT (sizeof (UINT16) == DxePcdGetSize (TokenNumber));
-
- return ReadUnaligned16 (GetWorker (TokenNumber));
+ return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));
}
@@ -142,9 +138,7 @@ DxePcdGet32 (
IN PCD_TOKEN_NUMBER TokenNumber
)
{
- ASSERT (sizeof (UINT32) == DxePcdGetSize (TokenNumber));
-
- return ReadUnaligned32 (GetWorker (TokenNumber));
+ return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));
}
@@ -155,9 +149,7 @@ DxePcdGet64 (
IN PCD_TOKEN_NUMBER TokenNumber
)
{
- ASSERT (sizeof (UINT64) == DxePcdGetSize (TokenNumber));
-
- return ReadUnaligned64(GetWorker (TokenNumber));
+ return ReadUnaligned64(GetWorker (TokenNumber, sizeof (UINT64)));
}
@@ -168,7 +160,7 @@ DxePcdGetPtr (
IN PCD_TOKEN_NUMBER TokenNumber
)
{
- return GetWorker (TokenNumber);
+ return GetWorker (TokenNumber, 0);
}
@@ -179,9 +171,7 @@ DxePcdGetBool (
IN PCD_TOKEN_NUMBER TokenNumber
)
{
- ASSERT (sizeof (BOOLEAN) == DxePcdGetSize (TokenNumber));
-
- return *((BOOLEAN *) GetWorker (TokenNumber));
+ return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));
}
@@ -224,7 +214,7 @@ DxePcdGet16Ex (
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
)
{
- return *((UINT32 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));
+ return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));
}
@@ -248,10 +238,7 @@ DxePcdGet64Ex (
IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
- //
- // BugBug: Must be changed to ReadUnaligned64
- //
- return *((UINT64 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));
+ return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));
}
@@ -287,11 +274,7 @@ DxePcdGetSizeEx (
IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
- EX_PCD_ENTRY_ATTRIBUTE Attr;
-
- GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
-
- return Attr.Size;
+ return DxePcdGetSize(GetExPcdTokenNumber (Guid, ExTokenNumber));
}
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.c b/EdkModulePkg/Universal/PCD/Dxe/Service.c
index 53d9621e8c..e1aded74f9 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Service.c
+++ b/EdkModulePkg/Universal/PCD/Dxe/Service.c
@@ -27,12 +27,15 @@ PCD_DATABASE * mPcdDatabase;
LIST_ENTRY mCallbackFnTable[PCD_TOTAL_TOKEN_NUMBER];
VOID *
-GetWorkerByLocalTokenNumber (
- UINT32 LocalTokenNumber,
- BOOLEAN IsPeiDb,
- UINTN Size
- )
+GetWorker (
+ PCD_TOKEN_NUMBER TokenNumber,
+ UINTN GetSize
+ )
{
+ UINT32 *LocalTokenNumberTable;
+ UINT16 *SizeTable;
+ BOOLEAN IsPeiDb;
+ UINTN Size;
UINT32 Offset;
EFI_GUID *GuidTable;
UINT16 *StringTable;
@@ -45,7 +48,28 @@ GetWorkerByLocalTokenNumber (
VPD_HEAD *VpdHead;
UINT8 *PcdDb;
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) {
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
}
@@ -93,49 +117,24 @@ GetWorkerByLocalTokenNumber (
ASSERT (FALSE);
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
DxeRegisterCallBackWorker (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER 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;
+ TokenNumber = GetExPcdTokenNumber (Guid, TokenNumber);
}
ListHead = &mCallbackFnTable[TokenNumber];
@@ -168,19 +167,17 @@ DxeRegisterCallBackWorker (
EFI_STATUS
DxeUnRegisterCallBackWorker (
- IN UINTN TokenNumber,
+ IN PCD_TOKEN_NUMBER 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;
+ TokenNumber = GetExPcdTokenNumber (Guid, TokenNumber);
}
ListHead = &mCallbackFnTable[TokenNumber];
@@ -452,6 +449,15 @@ SetWorker (
{
UINT32 *LocalTokenNumberTable;
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);
@@ -467,89 +473,16 @@ SetWorker (
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.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 - PEI_LOCAL_TOKEN_NUMBER;
-
- return SetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], Data, Size, PtrType, IsPeiDb);
-
-}
-
-
-
-
-
-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;
+ LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
-}
-
-
-
-
-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) {
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
SetHiiVariable (
IN EFI_GUID *VariableGuid,
@@ -680,56 +653,51 @@ SetHiiVariable (
-VOID
-GetExPcdTokenAttributes (
+PCD_TOKEN_NUMBER
+GetExPcdTokenNumber (
IN CONST EFI_GUID *Guid,
- IN PCD_TOKEN_NUMBER ExTokenNumber,
- OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
{
UINT32 i;
DYNAMICEX_MAPPING *ExMap;
EFI_GUID *GuidTable;
- UINT16 *SizeTable;
+ EFI_GUID *MatchGuid;
+ UINTN MatchGuidIdx;
ExMap = mPcdDatabase->PeiDb.Init.ExMapTable;
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++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
- CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex])
- ) {
-
- ExAttr->IsPeiDb = TRUE;
- ExAttr->Size = SizeTable[i + PEI_NEX_TOKEN_NUMBER];
- ExAttr->TokenNumber = i + PEI_NEX_TOKEN_NUMBER;
- ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
- return;
+ (MatchGuidIdx == ExMap[i].ExGuidIndex)) {
+ return ExMap[i].LocalTokenNumber;
}
}
ExMap = mPcdDatabase->DxeDb.Init.ExMapTable;
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++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
- CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex])
- ) {
-
- ExAttr->IsPeiDb = FALSE;
- ExAttr->Size = SizeTable[i + DXE_NEX_TOKEN_NUMBER];
- ExAttr->TokenNumber = i + PEI_LOCAL_TOKEN_NUMBER;
- ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
- return;
-
+ (MatchGuidIdx == ExMap[i].ExGuidIndex)) {
+ return ExMap[i].LocalTokenNumber + PEI_LOCAL_TOKEN_NUMBER;
}
}
ASSERT (FALSE);
- return;
+ return 0;
}
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h
index ec51ebbec8..af9fc420a3 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Service.h
+++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h
@@ -66,7 +66,8 @@ ExSetWorker (
VOID *
GetWorker (
- PCD_TOKEN_NUMBER TokenNumber
+ PCD_TOKEN_NUMBER TokenNumber,
+ UINTN GetSize
)
;
@@ -115,21 +116,12 @@ BuildPcdDxeDataBase (
);
-typedef struct {
- UINTN TokenNumber;
- UINTN Size;
- UINT32 LocalTokenNumberAlias;
- BOOLEAN IsPeiDb;
-} EX_PCD_ENTRY_ATTRIBUTE;
-
-VOID
-GetExPcdTokenAttributes (
+PCD_TOKEN_NUMBER
+GetExPcdTokenNumber (
IN CONST EFI_GUID *Guid,
- IN PCD_TOKEN_NUMBER ExTokenNumber,
- OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
+ IN PCD_TOKEN_NUMBER ExTokenNumber
)
;
-
//
// 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
ExGetNextTokeNumber (
IN CONST EFI_GUID *Guid,