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
This commit is contained in:
qwang12 2006-07-06 11:42:25 +00:00
parent 9c2aaac08e
commit c24ba2f612
5 changed files with 334 additions and 308 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -430,7 +430,7 @@ class GuidTable {
// If so, return the GuidTable index.
//
for (int i = 0; i < al.size(); i++) {
if (al.get(i).equals(uuid)) {
if (al.get(i).compareTo(uuid) == 0) {
return i;
}
}
@ -752,7 +752,7 @@ class ExMapTable {
}
private ArrayList<ExTriplet> al;
private ArrayList<String> alComment;
private Map<ExTriplet, String> alComment;
private String phase;
private int len;
private int bodyLineNum;
@ -760,7 +760,7 @@ class ExMapTable {
public ExMapTable (String phase) {
this.phase = phase;
al = new ArrayList<ExTriplet>();
alComment = new ArrayList<String>();
alComment = new HashMap<ExTriplet, String>();
bodyLineNum = 0;
len = 0;
}
@ -815,7 +815,7 @@ class ExMapTable {
str += e.localTokenIdx.toString() + ", ";
str += e.guidTableIdx.toString();
str += "}" + " /* " + alComment.get(index) + " */" ;
str += "}" + " /* " + alComment.get(e) + " */" ;
if (index != al.size() - 1) {
str += ",";
@ -834,9 +834,11 @@ class ExMapTable {
public int add (int localTokenIdx, long exTokenNum, int guidTableIdx, String name) {
int index = len;
len++;
al.add(new ExTriplet(guidTableIdx, exTokenNum, localTokenIdx));
alComment.add(name);
len++;
ExTriplet et = new ExTriplet(guidTableIdx, exTokenNum, localTokenIdx);
al.add(et);
alComment.put(et, name);
return index;
}