diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-06 11:42:25 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-06 11:42:25 +0000 |
commit | c24ba2f612d89d6dd15871cdb8a66080859d9ab3 (patch) | |
tree | 5ae9c7c77246ae8f97aa7ce0b9395b704c4248a9 /EdkModulePkg | |
parent | 9c2aaac08e0565eb4634fe261dac1ba58d0738a8 (diff) | |
download | edk2-platforms-c24ba2f612d89d6dd15871cdb8a66080859d9ab3.tar.xz |
Fix bugs in GetNextTokenSpace and GetNextToken
Fix bugs in Pcd Build tool generation for ExMap
Fix a few other bugs.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@800 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg')
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Pcd.c | 60 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Service.h | 287 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Pei/Pcd.c | 30 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Pei/Service.h | 249 |
4 files changed, 325 insertions, 301 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c index 3e35363a3b..b78752df29 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c +++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c @@ -53,7 +53,8 @@ PCD_PROTOCOL mPcdInstance = { DxeRegisterCallBackOnSet,
DxeUnRegisterCallBackOnSet,
- DxePcdGetNextToken
+ DxePcdGetNextToken,
+ DxePcdGetNextTokenSpace
};
@@ -505,31 +506,26 @@ DxePcdGetNextToken ( //
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 (*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;
+ } 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;
+ if (PEI_EXMAP_TABLE_EMPTY && DXE_EXMAP_TABLE_EMPTY) {
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
return EFI_NOT_FOUND;
}
- ExTokenNumber = *TokenNumber;
if (!PEI_EXMAP_TABLE_EMPTY) {
+ ExTokenNumber = *TokenNumber;
ExTokenNumber = ExGetNextTokeNumber (
Guid,
ExTokenNumber,
@@ -543,13 +539,14 @@ DxePcdGetNextToken ( if ((ExTokenNumber == PCD_INVALID_TOKEN_NUMBER) &&
!DXE_EXMAP_TABLE_EMPTY
) {
+ ExTokenNumber = *TokenNumber;
ExTokenNumber = ExGetNextTokeNumber (
Guid,
ExTokenNumber,
- mPcdDatabase->PeiDb.Init.GuidTable,
- sizeof(mPcdDatabase->PeiDb.Init.GuidTable),
- mPcdDatabase->PeiDb.Init.ExMapTable,
- sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)
+ mPcdDatabase->DxeDb.Init.GuidTable,
+ sizeof(mPcdDatabase->DxeDb.Init.GuidTable),
+ mPcdDatabase->DxeDb.Init.ExMapTable,
+ sizeof(mPcdDatabase->DxeDb.Init.ExMapTable)
);
}
@@ -578,19 +575,28 @@ GetDistinctTokenSpace ( TsIdx = 0;
OldGuidIndex = ExMapTable[0].ExGuidIndex;
DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];
- for (Idx = 1; Idx < PEI_EXMAPPING_TABLE_SIZE; Idx++) {
+ for (Idx = 1; Idx < *ExMapTableSize; Idx++) {
if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {
OldGuidIndex = ExMapTable[Idx].ExGuidIndex;
DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];
}
}
- *ExMapTableSize = TsIdx;
+ //
+ // The total number of Distinct Token Space
+ // is TsIdx + 1 because we use TsIdx as a index
+ // to the DistinctTokenSpace[]
+ //
+ *ExMapTableSize = TsIdx + 1;
return DistinctTokenSpace;
}
-
+//
+// Just pre-allocate a memory buffer that is big enough to
+// host all distinct TokenSpace guid in both
+// PEI ExMap and DXE ExMap.
+//
STATIC EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };
EFI_STATUS
@@ -619,7 +625,7 @@ DxePcdGetNextTokenSpace ( }
- if (TmpTokenSpaceBuffer[0] != NULL) {
+ if (TmpTokenSpaceBuffer[0] == NULL) {
PeiTokenSpaceTableSize = 0;
if (!PEI_EXMAP_TABLE_EMPTY) {
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h index 7628900596..ff90fa5479 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Service.h +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h @@ -32,144 +32,6 @@ 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
-//
-
-EFI_STATUS
-SetValueWorker (
- IN UINTN TokenNumber,
- IN VOID *Data,
- IN UINTN Size
- )
-;
-
-EFI_STATUS
-SetWorker (
- IN UINTN TokenNumber,
- IN VOID *Data,
- IN OUT UINTN *Size,
- IN BOOLEAN PtrType
- )
-;
-
-
-EFI_STATUS
-ExSetValueWorker (
- IN UINTN ExTokenNumber,
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN UINTN SetSize
- )
-;
-
-
-
-EFI_STATUS
-ExSetWorker (
- IN UINTN ExTokenNumber,
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN OUT UINTN *Size,
- IN BOOLEAN PtrType
- )
-;
-
-
-VOID *
-GetWorker (
- IN UINTN TokenNumber,
- IN UINTN GetSize
- )
-;
-
-VOID *
-ExGetWorker (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
- IN UINTN GetSize
- )
-;
-
-UINT32
-GetSkuEnabledTokenNumber (
- UINT32 LocalTokenNumber,
- UINTN Size,
- BOOLEAN IsPeiDb
- )
-;
-
-EFI_STATUS
-GetHiiVariable (
- IN EFI_GUID *VariableGuid,
- IN UINT16 *VariableName,
- OUT VOID **VariableData,
- OUT UINTN *VariableSize
- )
-;
-
-EFI_STATUS
-SetHiiVariable (
- IN EFI_GUID *VariableGuid,
- IN UINT16 *VariableName,
- IN CONST VOID *Data,
- IN UINTN DataSize,
- IN UINTN Offset
- )
-;
-
-EFI_STATUS
-DxeRegisterCallBackWorker (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
- IN PCD_PROTOCOL_CALLBACK CallBackFunction
-);
-
-EFI_STATUS
-DxeUnRegisterCallBackWorker (
- IN UINTN TokenNumber,
- IN CONST EFI_GUID *Guid, OPTIONAL
- IN PCD_PROTOCOL_CALLBACK CallBackFunction
-);
-
-VOID
-BuildPcdDxeDataBase (
- VOID
-);
-
-
-UINTN
-GetExPcdTokenNumber (
- IN CONST EFI_GUID *Guid,
- IN UINT32 ExTokenNumber
- )
-;
-
-
-UINTN
-GetPtrTypeSize (
- IN UINTN LocalTokenNumberTableIdx,
- OUT UINTN *MaxSize
- )
-;
-
-
-
-BOOLEAN
-SetPtrTypeSize (
- IN UINTN LocalTokenNumberTableIdx,
- IN OUT UINTN *CurrentSize
- )
-;
-
//
// Protocol Interface function declaration.
//
@@ -447,6 +309,138 @@ DxePcdGetNextToken ( )
;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdGetNextTokenSpace (
+ IN OUT CONST EFI_GUID **Guid
+ )
+;
+
+
+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
+//
+
+EFI_STATUS
+SetValueWorker (
+ IN UINTN TokenNumber,
+ IN VOID *Data,
+ IN UINTN Size
+ )
+;
+
+EFI_STATUS
+SetWorker (
+ IN UINTN TokenNumber,
+ IN VOID *Data,
+ IN OUT UINTN *Size,
+ IN BOOLEAN PtrType
+ )
+;
+
+
+EFI_STATUS
+ExSetValueWorker (
+ IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN SetSize
+ )
+;
+
+
+
+EFI_STATUS
+ExSetWorker (
+ IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN OUT UINTN *Size,
+ IN BOOLEAN PtrType
+ )
+;
+
+
+VOID *
+GetWorker (
+ IN UINTN TokenNumber,
+ IN UINTN GetSize
+ )
+;
+
+VOID *
+ExGetWorker (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN ExTokenNumber,
+ IN UINTN GetSize
+ )
+;
+
+UINT32
+GetSkuEnabledTokenNumber (
+ UINT32 LocalTokenNumber,
+ UINTN Size,
+ BOOLEAN IsPeiDb
+ )
+;
+
+EFI_STATUS
+GetHiiVariable (
+ IN EFI_GUID *VariableGuid,
+ IN UINT16 *VariableName,
+ OUT VOID **VariableData,
+ OUT UINTN *VariableSize
+ )
+;
+
+EFI_STATUS
+SetHiiVariable (
+ IN EFI_GUID *VariableGuid,
+ IN UINT16 *VariableName,
+ IN CONST VOID *Data,
+ IN UINTN DataSize,
+ IN UINTN Offset
+ )
+;
+
+EFI_STATUS
+DxeRegisterCallBackWorker (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+);
+
+EFI_STATUS
+DxeUnRegisterCallBackWorker (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+);
+
+VOID
+BuildPcdDxeDataBase (
+ VOID
+);
+
+
+UINTN
+GetExPcdTokenNumber (
+ IN CONST EFI_GUID *Guid,
+ IN UINT32 ExTokenNumber
+ )
+;
+
+
+
UINTN
ExGetNextTokeNumber (
IN CONST EFI_GUID *Guid,
@@ -458,6 +452,23 @@ ExGetNextTokeNumber ( )
;
+
+UINTN
+GetPtrTypeSize (
+ IN UINTN LocalTokenNumberTableIdx,
+ OUT UINTN *MaxSize
+ )
+;
+
+
+
+BOOLEAN
+SetPtrTypeSize (
+ IN UINTN LocalTokenNumberTableIdx,
+ IN OUT UINTN *CurrentSize
+ )
+;
+
extern EFI_GUID gPcdDataBaseHobGuid;
extern PCD_DATABASE * mPcdDatabase;
diff --git a/EdkModulePkg/Universal/PCD/Pei/Pcd.c b/EdkModulePkg/Universal/PCD/Pei/Pcd.c index a2b5701f13..6d90671852 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Pcd.c +++ b/EdkModulePkg/Universal/PCD/Pei/Pcd.c @@ -481,16 +481,14 @@ PeiPcdGetNextToken ( if (Guid == NULL) {
(*TokenNumber)++;
-
- if (*TokenNumber >= PEI_NEX_TOKEN_NUMBER) {
+ if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;
}
-
+ return EFI_SUCCESS;
} else {
-
if (PEI_EXMAP_TABLE_EMPTY) {
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;
- return EFI_NOT_FOUND;
+ return EFI_SUCCESS;
}
//
@@ -503,7 +501,7 @@ PeiPcdGetNextToken ( MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);
if (MatchGuid == NULL) {
- *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
return EFI_NOT_FOUND;
}
@@ -512,6 +510,9 @@ PeiPcdGetNextToken ( ExMapTable = PeiPcdDb->Init.ExMapTable;
Found = FALSE;
+ //
+ // Locate the GUID in ExMapTable first.
+ //
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {
Found = TRUE;
@@ -524,26 +525,31 @@ PeiPcdGetNextToken ( *TokenNumber = ExMapTable[i].ExTokenNumber;
return EFI_SUCCESS;
}
-
- for ( ; ExMapTable[i].ExGuidIndex == GuidTableIdx; i++) {
+
+ for ( ; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
if (ExMapTable[i].ExTokenNumber == *TokenNumber) {
i++;
+ if (i == PEI_EXMAPPING_TABLE_SIZE) {
+ //
+ // Exceed the length of ExMap Table
+ //
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_SUCCESS;
+ }
if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {
*TokenNumber = ExMapTable[i].ExTokenNumber;
return EFI_SUCCESS;
} else {
- *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
return EFI_SUCCESS;
}
}
}
-
return EFI_NOT_FOUND;
}
-
}
- return EFI_SUCCESS;
+ return EFI_NOT_FOUND;
}
diff --git a/EdkModulePkg/Universal/PCD/Pei/Service.h b/EdkModulePkg/Universal/PCD/Pei/Service.h index 4dbf7610ba..71a3d7b38f 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Service.h +++ b/EdkModulePkg/Universal/PCD/Pei/Service.h @@ -32,130 +32,6 @@ Module Name: Service.h #error "Please make sure the version of PCD Service PEIM and PCD PEI Database Generation Tool matches"
#endif
-/* Internal Function definitions */
-
-PEI_PCD_DATABASE *
-GetPcdDatabase (
- VOID
- )
-;
-
-
-EFI_STATUS
-SetValueWorker (
- IN UINTN TokenNumber,
- IN VOID *Data,
- IN UINTN Size
- )
-;
-
-
-EFI_STATUS
-SetWorker (
- IN UINTN TokenNumber,
- IN VOID *Data,
- IN OUT UINTN *Size,
- IN BOOLEAN PtrType
- )
-;
-
-
-EFI_STATUS
-ExSetValueWorker (
- IN UINTN ExTokenNumber,
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN UINTN Size
- )
-;
-
-
-
-EFI_STATUS
-ExSetWorker (
- IN UINTN ExTokenNumber,
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN OUT UINTN *Size,
- IN BOOLEAN PtrType
- )
-;
-
-
-
-VOID *
-GetWorker (
- IN UINTN TokenNumber,
- IN UINTN GetSize
- )
-;
-
-
-
-VOID *
-ExGetWorker (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber,
- IN UINTN GetSize
- )
-;
-
-typedef struct {
- UINTN TokenNumber;
- UINTN Size;
- UINT32 LocalTokenNumberAlias;
-} EX_PCD_ENTRY_ATTRIBUTE;
-
-
-UINTN
-GetExPcdTokenNumber (
- IN CONST EFI_GUID *Guid,
- IN UINTN ExTokenNumber
- )
-;
-
-
-
-
-EFI_STATUS
-PeiRegisterCallBackWorker (
- IN UINTN TokenNumber,
- IN CONST GUID *Guid, OPTIONAL
- IN PCD_PPI_CALLBACK CallBackFunction,
- IN BOOLEAN Register
-);
-
-
-
-
-VOID
-BuildPcdDatabase (
- VOID
- )
-;
-
-
-
-
-UINTN
-GetPtrTypeSize (
- IN UINTN LocalTokenNumberTableIdx,
- OUT UINTN *MaxSize,
- IN PEI_PCD_DATABASE *Database
- )
-;
-
-
-
-BOOLEAN
-SetPtrTypeSize (
- IN UINTN LocalTokenNumberTableIdx,
- IN OUT UINTN *CurrentSize,
- IN PEI_PCD_DATABASE *Database
- )
-;
-
-
//
// PPI Interface Implementation Declaration.
//
@@ -436,6 +312,131 @@ PeiPcdGetNextTokenSpace ( )
;
+
+/* Internal Function definitions */
+
+PEI_PCD_DATABASE *
+GetPcdDatabase (
+ VOID
+ )
+;
+
+
+EFI_STATUS
+SetValueWorker (
+ IN UINTN TokenNumber,
+ IN VOID *Data,
+ IN UINTN Size
+ )
+;
+
+
+EFI_STATUS
+SetWorker (
+ IN UINTN TokenNumber,
+ IN VOID *Data,
+ IN OUT UINTN *Size,
+ IN BOOLEAN PtrType
+ )
+;
+
+
+EFI_STATUS
+ExSetValueWorker (
+ IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN Size
+ )
+;
+
+
+
+EFI_STATUS
+ExSetWorker (
+ IN UINTN ExTokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN OUT UINTN *Size,
+ IN BOOLEAN PtrType
+ )
+;
+
+
+
+VOID *
+GetWorker (
+ IN UINTN TokenNumber,
+ IN UINTN GetSize
+ )
+;
+
+
+
+VOID *
+ExGetWorker (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN ExTokenNumber,
+ IN UINTN GetSize
+ )
+;
+
+typedef struct {
+ UINTN TokenNumber;
+ UINTN Size;
+ UINT32 LocalTokenNumberAlias;
+} EX_PCD_ENTRY_ATTRIBUTE;
+
+
+UINTN
+GetExPcdTokenNumber (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN ExTokenNumber
+ )
+;
+
+
+
+
+EFI_STATUS
+PeiRegisterCallBackWorker (
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid, OPTIONAL
+ IN PCD_PPI_CALLBACK CallBackFunction,
+ IN BOOLEAN Register
+);
+
+
+
+
+VOID
+BuildPcdDatabase (
+ VOID
+ )
+;
+
+
+
+
+UINTN
+GetPtrTypeSize (
+ IN UINTN LocalTokenNumberTableIdx,
+ OUT UINTN *MaxSize,
+ IN PEI_PCD_DATABASE *Database
+ )
+;
+
+
+
+BOOLEAN
+SetPtrTypeSize (
+ IN UINTN LocalTokenNumberTableIdx,
+ IN OUT UINTN *CurrentSize,
+ IN PEI_PCD_DATABASE *Database
+ )
+;
+
+
extern EFI_GUID gPcdDataBaseHobGuid;
extern EFI_GUID gPcdPeiCallbackFnTableHobGuid;
|