mirror of https://github.com/acidanthera/audk.git
Add in support for MaxSize and CurrentSize for PCD entry.
Change the behavior for PcdSET for Variable_Enabled Pcd entry. If a Variable does not exist, we will only save the value to a volatile space. We save it to variable ONLY when the variable exist. Fix a few bugs in Pcd Build tool when generated Pcd database for Pcd entry with Unicode String type. Support PcdSet to return MaxSize if the input SizeOfBuffer is greater than the Max Size declared in FPD file. Add SetValueWorker and GetValueWoker for each PcdSET and PcdGET function to reduce code size. Sync function prototype definition for PCD_PPI_SET_POINTER, PCD_PPI_SET_EX_POINTER, PCD_PROTOCOL_SET_POINTER and PCD_PROTOCOL_SET_EX_POINTER with PCD arch spec 0.52. Add ASSERTION in LibPcdSetPtr. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@789 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
71baa24b69
commit
1de04b4f83
|
@ -182,21 +182,44 @@ DxePcdGetSize (
|
||||||
IN UINTN TokenNumber
|
IN UINTN TokenNumber
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT16 * SizeTable;
|
UINTN Size;
|
||||||
|
UINT32 *LocalTokenNumberTable;
|
||||||
|
BOOLEAN IsPeiDb;
|
||||||
|
UINTN MaxSize;
|
||||||
|
UINTN TmpTokenNumber;
|
||||||
//
|
//
|
||||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||||
// We have to decrement TokenNumber by 1 to make it usable
|
// We have to decrement TokenNumber by 1 to make it usable
|
||||||
// as the array index.
|
// as the array index.
|
||||||
//
|
//
|
||||||
TokenNumber--;
|
TokenNumber--;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Backup the TokenNumber passed in as GetPtrTypeSize need the original TokenNumber
|
||||||
|
//
|
||||||
|
TmpTokenNumber = TokenNumber;
|
||||||
|
|
||||||
|
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
|
IsPeiDb = (BOOLEAN) (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
SizeTable = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? mPcdDatabase->PeiDb.Init.SizeTable :
|
TokenNumber = IsPeiDb ? TokenNumber :
|
||||||
mPcdDatabase->DxeDb.Init.SizeTable;
|
(TokenNumber - PEI_LOCAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
|
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable
|
||||||
|
: mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
||||||
|
|
||||||
TokenNumber = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TokenNumber : (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);
|
Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
|
||||||
|
|
||||||
|
if (Size == 0) {
|
||||||
|
//
|
||||||
|
// For pointer type, we need to scan the SIZE_TABLE to get the current size.
|
||||||
|
//
|
||||||
|
return GetPtrTypeSize (TmpTokenNumber, &MaxSize);
|
||||||
|
} else {
|
||||||
|
return Size;
|
||||||
|
}
|
||||||
|
|
||||||
return SizeTable[TokenNumber];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,7 +279,7 @@ DxePcdGetPtrEx (
|
||||||
IN UINTN ExTokenNumber
|
IN UINTN ExTokenNumber
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExGetWorker (Guid, ExTokenNumber, 0);
|
return ExGetWorker (Guid, ExTokenNumber, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,7 +315,7 @@ DxePcdSet8 (
|
||||||
IN UINT8 Value
|
IN UINT8 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,7 +327,7 @@ DxePcdSet16 (
|
||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -316,7 +339,7 @@ DxePcdSet32 (
|
||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,7 +351,7 @@ DxePcdSet64 (
|
||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -336,9 +359,9 @@ DxePcdSet64 (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DxePcdSetPtr (
|
DxePcdSetPtr (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
|
return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
|
||||||
|
@ -353,7 +376,7 @@ DxePcdSetBool (
|
||||||
IN BOOLEAN Value
|
IN BOOLEAN Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,13 +389,7 @@ DxePcdSet8Ex (
|
||||||
IN UINT8 Value
|
IN UINT8 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,13 +402,7 @@ DxePcdSet16Ex (
|
||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -404,13 +415,7 @@ DxePcdSet32Ex (
|
||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -423,13 +428,7 @@ DxePcdSet64Ex (
|
||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -437,19 +436,13 @@ DxePcdSet64Ex (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DxePcdSetPtrEx (
|
DxePcdSetPtrEx (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN UINTN ExTokenNumber,
|
IN UINTN ExTokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetWorker(ExTokenNumber, Guid, Buffer, SizeOfBuffer, TRUE);
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
Buffer,
|
|
||||||
SizeOfBuffer,
|
|
||||||
TRUE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,13 +455,7 @@ DxePcdSetBoolEx (
|
||||||
IN BOOLEAN Value
|
IN BOOLEAN Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
TRUE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,20 +35,22 @@ GetWorker (
|
||||||
UINT32 *LocalTokenNumberTable;
|
UINT32 *LocalTokenNumberTable;
|
||||||
UINT16 *SizeTable;
|
UINT16 *SizeTable;
|
||||||
BOOLEAN IsPeiDb;
|
BOOLEAN IsPeiDb;
|
||||||
UINTN Size;
|
|
||||||
UINT32 Offset;
|
UINT32 Offset;
|
||||||
EFI_GUID *GuidTable;
|
EFI_GUID *GuidTable;
|
||||||
UINT16 *StringTable;
|
UINT16 *StringTable;
|
||||||
EFI_GUID *Guid;
|
EFI_GUID *Guid;
|
||||||
UINT16 *Name;
|
UINT16 *Name;
|
||||||
VARIABLE_HEAD *VariableHead;
|
VARIABLE_HEAD *VariableHead;
|
||||||
|
UINT8 *VaraiableDefaultBuffer;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN DataSize;
|
UINTN DataSize;
|
||||||
VOID *Data;
|
UINT8 *Data;
|
||||||
VPD_HEAD *VpdHead;
|
VPD_HEAD *VpdHead;
|
||||||
UINT8 *PcdDb;
|
UINT8 *PcdDb;
|
||||||
UINT16 StringTableIdx;
|
UINT16 StringTableIdx;
|
||||||
UINT32 LocalTokenNumber;
|
UINT32 LocalTokenNumber;
|
||||||
|
UINTN MaxSize;
|
||||||
|
UINTN TmpTokenNumber;
|
||||||
|
|
||||||
//
|
//
|
||||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||||
|
@ -56,11 +58,12 @@ GetWorker (
|
||||||
// as the array index.
|
// as the array index.
|
||||||
//
|
//
|
||||||
TokenNumber--;
|
TokenNumber--;
|
||||||
|
|
||||||
|
TmpTokenNumber = TokenNumber;
|
||||||
|
|
||||||
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
|
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
Size = DxePcdGetSize (TokenNumber + 1);
|
ASSERT ((GetSize == DxePcdGetSize (TokenNumber + 1)) || (GetSize == 0));
|
||||||
ASSERT (GetSize == Size || GetSize == 0);
|
|
||||||
|
|
||||||
|
|
||||||
IsPeiDb = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
|
IsPeiDb = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
|
||||||
|
@ -77,7 +80,12 @@ GetWorker (
|
||||||
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
|
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);
|
if (GetSize == 0) {
|
||||||
|
GetPtrTypeSize (TmpTokenNumber, &MaxSize);
|
||||||
|
} else {
|
||||||
|
MaxSize = GetSize;
|
||||||
|
}
|
||||||
|
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
|
PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
|
||||||
|
@ -86,7 +94,7 @@ GetWorker (
|
||||||
|
|
||||||
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
||||||
|
|
||||||
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
|
||||||
case PCD_TYPE_VPD:
|
case PCD_TYPE_VPD:
|
||||||
VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
|
VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
|
||||||
return (VOID *) (UINTN) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
|
return (VOID *) (UINTN) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
|
||||||
|
@ -99,16 +107,31 @@ GetWorker (
|
||||||
|
|
||||||
Guid = &(GuidTable[VariableHead->GuidTableIndex]);
|
Guid = &(GuidTable[VariableHead->GuidTableIndex]);
|
||||||
Name = &(StringTable[VariableHead->StringIndex]);
|
Name = &(StringTable[VariableHead->StringIndex]);
|
||||||
|
VaraiableDefaultBuffer = (UINT8 *) PcdDb + VariableHead->DefaultValueOffset;
|
||||||
|
|
||||||
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
|
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
return (UINT8 *) Data + VariableHead->Offset;
|
if (GetSize == 0) {
|
||||||
} else {
|
//
|
||||||
//
|
// It is a pointer type. So get the MaxSize reserved for
|
||||||
// Return the default value specified by Platform Integrator
|
// this PCD entry.
|
||||||
//
|
//
|
||||||
return (VOID *) ((UINT8 *) PcdDb + VariableHead->DefaultValueOffset);
|
GetPtrTypeSize (TokenNumber, &GetSize);
|
||||||
}
|
}
|
||||||
|
CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);
|
||||||
|
FreePool (Data);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// If the operation is successful, we copy the data
|
||||||
|
// to the default value buffer in the PCD Database.
|
||||||
|
// So that we can free the Data allocated in GetHiiVariable.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// If the operation is not successful,
|
||||||
|
// Return 1) either the default value specified by Platform Integrator
|
||||||
|
// 2) Or the value Set by a PCD set operation.
|
||||||
|
//
|
||||||
|
return (VOID *) VaraiableDefaultBuffer;
|
||||||
|
|
||||||
case PCD_TYPE_STRING:
|
case PCD_TYPE_STRING:
|
||||||
StringTableIdx = (UINT16) *((UINT8 *) PcdDb + Offset);
|
StringTableIdx = (UINT16) *((UINT8 *) PcdDb + Offset);
|
||||||
|
@ -352,7 +375,7 @@ EFI_STATUS
|
||||||
GetHiiVariable (
|
GetHiiVariable (
|
||||||
IN EFI_GUID *VariableGuid,
|
IN EFI_GUID *VariableGuid,
|
||||||
IN UINT16 *VariableName,
|
IN UINT16 *VariableName,
|
||||||
OUT VOID ** VariableData,
|
OUT VOID **VariableData,
|
||||||
OUT UINTN *VariableSize
|
OUT UINTN *VariableSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -372,7 +395,6 @@ GetHiiVariable (
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
|
||||||
Buffer = AllocatePool (Size);
|
Buffer = AllocatePool (Size);
|
||||||
|
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
|
@ -386,13 +408,11 @@ GetHiiVariable (
|
||||||
);
|
);
|
||||||
|
|
||||||
ASSERT (Status == EFI_SUCCESS);
|
ASSERT (Status == EFI_SUCCESS);
|
||||||
|
*VariableData = Buffer;
|
||||||
|
*VariableSize = Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
*VariableData = Buffer;
|
|
||||||
*VariableSize = Size;
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -429,7 +449,7 @@ GetSkuEnabledTokenNumber (
|
||||||
}
|
}
|
||||||
ASSERT (i < SkuIdTable[0]);
|
ASSERT (i < SkuIdTable[0]);
|
||||||
|
|
||||||
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
|
||||||
case PCD_TYPE_VPD:
|
case PCD_TYPE_VPD:
|
||||||
Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);
|
Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);
|
||||||
return (UINT32) ((Value - PcdDb) | PCD_TYPE_VPD);
|
return (UINT32) ((Value - PcdDb) | PCD_TYPE_VPD);
|
||||||
|
@ -437,11 +457,15 @@ GetSkuEnabledTokenNumber (
|
||||||
case PCD_TYPE_HII:
|
case PCD_TYPE_HII:
|
||||||
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[i]);
|
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[i]);
|
||||||
return (UINT32) ((Value - PcdDb) | PCD_TYPE_HII);
|
return (UINT32) ((Value - PcdDb) | PCD_TYPE_HII);
|
||||||
|
|
||||||
|
case PCD_TYPE_STRING:
|
||||||
|
Value = (UINT8 *) &(((STRING_HEAD *) Value)[i]);
|
||||||
|
return (UINT32) ((Value - PcdDb) | PCD_TYPE_STRING);
|
||||||
|
|
||||||
case PCD_TYPE_DATA:
|
case PCD_TYPE_DATA:
|
||||||
Value += Size * i;
|
Value += Size * i;
|
||||||
return (UINT32) (Value - PcdDb);
|
return (UINT32) (Value - PcdDb);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
}
|
}
|
||||||
|
@ -494,14 +518,23 @@ InvokeCallbackOnSet (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
SetValueWorker (
|
||||||
|
IN UINTN TokenNumber,
|
||||||
|
IN VOID *Data,
|
||||||
|
IN UINTN Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return SetWorker (TokenNumber, Data, &Size, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SetWorker (
|
SetWorker (
|
||||||
UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
VOID *Data,
|
IN VOID *Data,
|
||||||
UINTN Size,
|
IN OUT UINTN *Size,
|
||||||
BOOLEAN PtrType
|
IN BOOLEAN PtrType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 *LocalTokenNumberTable;
|
UINT32 *LocalTokenNumberTable;
|
||||||
|
@ -516,6 +549,9 @@ SetWorker (
|
||||||
VARIABLE_HEAD *VariableHead;
|
VARIABLE_HEAD *VariableHead;
|
||||||
UINTN Offset;
|
UINTN Offset;
|
||||||
UINT8 *PcdDb;
|
UINT8 *PcdDb;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN MaxSize;
|
||||||
|
UINTN TmpTokenNumber;
|
||||||
|
|
||||||
//
|
//
|
||||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||||
|
@ -523,13 +559,13 @@ SetWorker (
|
||||||
// as the array index.
|
// as the array index.
|
||||||
//
|
//
|
||||||
TokenNumber--;
|
TokenNumber--;
|
||||||
|
|
||||||
|
TmpTokenNumber = TokenNumber;
|
||||||
|
|
||||||
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
|
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
if (PtrType) {
|
if (!PtrType) {
|
||||||
ASSERT (Size <= DxePcdGetSize (TokenNumber + 1));
|
ASSERT (*Size == DxePcdGetSize (TokenNumber + 1));
|
||||||
} else {
|
|
||||||
ASSERT (Size == DxePcdGetSize (TokenNumber + 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IsPeiDb = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
|
IsPeiDb = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
|
||||||
|
@ -539,7 +575,7 @@ SetWorker (
|
||||||
|
|
||||||
if ((TokenNumber < PEI_NEX_TOKEN_NUMBER) ||
|
if ((TokenNumber < PEI_NEX_TOKEN_NUMBER) ||
|
||||||
(TokenNumber >= PEI_LOCAL_TOKEN_NUMBER || TokenNumber < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER))) {
|
(TokenNumber >= PEI_LOCAL_TOKEN_NUMBER || TokenNumber < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER))) {
|
||||||
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, Size);
|
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenNumber = IsPeiDb ? TokenNumber
|
TokenNumber = IsPeiDb ? TokenNumber
|
||||||
|
@ -548,7 +584,12 @@ SetWorker (
|
||||||
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
|
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);
|
if (PtrType) {
|
||||||
|
GetPtrTypeSize (TmpTokenNumber, &MaxSize);
|
||||||
|
} else {
|
||||||
|
MaxSize = *Size;
|
||||||
|
}
|
||||||
|
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
||||||
|
@ -560,19 +601,26 @@ SetWorker (
|
||||||
|
|
||||||
InternalData = PcdDb + Offset;
|
InternalData = PcdDb + Offset;
|
||||||
|
|
||||||
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
|
||||||
case PCD_TYPE_VPD:
|
case PCD_TYPE_VPD:
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
case PCD_TYPE_STRING:
|
case PCD_TYPE_STRING:
|
||||||
CopyMem (&StringTable[*((UINT16 *)InternalData)], Data, Size);
|
if (SetPtrTypeSize (TokenNumber, Size)) {
|
||||||
return EFI_SUCCESS;
|
CopyMem (&StringTable[*((UINT16 *)InternalData)], Data, *Size);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
case PCD_TYPE_HII:
|
case PCD_TYPE_HII:
|
||||||
//
|
if (PtrType) {
|
||||||
// Bug Bug: Please implement this
|
if (!SetPtrTypeSize (TokenNumber, Size)) {
|
||||||
//
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GuidTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.GuidTable :
|
GuidTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.GuidTable :
|
||||||
mPcdDatabase->DxeDb.Init.GuidTable;
|
mPcdDatabase->DxeDb.Init.GuidTable;
|
||||||
|
|
||||||
|
@ -582,15 +630,30 @@ SetWorker (
|
||||||
Name = &(StringTable[VariableHead->StringIndex]);
|
Name = &(StringTable[VariableHead->StringIndex]);
|
||||||
VariableOffset = VariableHead->Offset;
|
VariableOffset = VariableHead->Offset;
|
||||||
|
|
||||||
return SetHiiVariable (Guid, Name, Data, Size, VariableOffset);
|
Status = SetHiiVariable (Guid, Name, Data, *Size, VariableOffset);
|
||||||
|
|
||||||
|
if (EFI_NOT_FOUND == Status) {
|
||||||
|
CopyMem (PcdDb + VariableHead->DefaultValueOffset, Data, *Size);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bug Bug: Please implement this
|
||||||
|
//
|
||||||
|
|
||||||
case PCD_TYPE_DATA:
|
case PCD_TYPE_DATA:
|
||||||
if (PtrType) {
|
if (PtrType) {
|
||||||
CopyMem (InternalData, Data, Size);
|
if (SetPtrTypeSize (TokenNumber, Size)) {
|
||||||
return EFI_SUCCESS;
|
CopyMem (InternalData, Data, *Size);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Size) {
|
switch (*Size) {
|
||||||
case sizeof(UINT8):
|
case sizeof(UINT8):
|
||||||
*((UINT8 *) InternalData) = *((UINT8 *) Data);
|
*((UINT8 *) InternalData) = *((UINT8 *) Data);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -638,26 +701,35 @@ ExGetWorker (
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
ExSetValueWorker (
|
||||||
|
IN UINTN ExTokenNumber,
|
||||||
|
IN CONST EFI_GUID *Guid,
|
||||||
|
IN VOID *Data,
|
||||||
|
IN UINTN SetSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ExSetWorker (ExTokenNumber, Guid, Data, &SetSize, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ExSetWorker (
|
ExSetWorker (
|
||||||
IN UINTN ExTokenNumber,
|
IN UINTN ExTokenNumber,
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
VOID *Data,
|
IN VOID *Data,
|
||||||
UINTN SetSize,
|
IN OUT UINTN *SetSize,
|
||||||
BOOLEAN PtrType
|
IN BOOLEAN PtrType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN TokenNumber;
|
UINTN TokenNumber;
|
||||||
|
|
||||||
TokenNumber = GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber);
|
TokenNumber = GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber);
|
||||||
|
|
||||||
InvokeCallbackOnSet ((UINT32) ExTokenNumber, Guid, TokenNumber, Data, SetSize);
|
InvokeCallbackOnSet ((UINT32) ExTokenNumber, Guid, TokenNumber, Data, *SetSize);
|
||||||
|
|
||||||
SetWorker (TokenNumber, Data, SetSize, PtrType);
|
return SetWorker (TokenNumber, Data, SetSize, PtrType);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -705,24 +777,25 @@ SetHiiVariable (
|
||||||
|
|
||||||
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
||||||
|
|
||||||
} else {
|
Status = EfiSetVariable (
|
||||||
|
VariableName,
|
||||||
|
VariableGuid,
|
||||||
|
Attribute,
|
||||||
|
Size,
|
||||||
|
Buffer
|
||||||
|
);
|
||||||
|
|
||||||
Attribute = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
FreePool (Buffer);
|
||||||
Size = DataSize + Offset;
|
return Status;
|
||||||
Buffer = AllocateZeroPool (Size);
|
|
||||||
ASSERT (Buffer != NULL);
|
|
||||||
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return EfiSetVariable (
|
|
||||||
VariableName,
|
|
||||||
VariableGuid,
|
|
||||||
Attribute,
|
|
||||||
Size,
|
|
||||||
Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If we drop to here, we don't have a Variable entry in
|
||||||
|
// the variable service yet. So, we will save the data
|
||||||
|
// in the PCD Database's volatile area.
|
||||||
|
//
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -785,3 +858,258 @@ GetExPcdTokenNumber (
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SKU_ID *
|
||||||
|
GetSkuIdArray (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN BOOLEAN IsPeiPcd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SKU_HEAD *SkuHead;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
UINT8 *Database;
|
||||||
|
|
||||||
|
if (IsPeiPcd) {
|
||||||
|
LocalTokenNumber = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
|
||||||
|
Database = (UINT8 *) &mPcdDatabase->PeiDb;
|
||||||
|
} else {
|
||||||
|
LocalTokenNumber = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable[LocalTokenNumberTableIdx - PEI_LOCAL_TOKEN_NUMBER];
|
||||||
|
Database = (UINT8 *) &mPcdDatabase->DxeDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);
|
||||||
|
|
||||||
|
SkuHead = (SKU_HEAD *) ((UINT8 *)Database + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
|
||||||
|
|
||||||
|
return (SKU_ID *) (Database + SkuHead->SkuIdTableOffset);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
GetSizeTableIndexA (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN UINT32 *LocalTokenNumberTable,
|
||||||
|
IN BOOLEAN IsPeiDb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN i;
|
||||||
|
UINTN SizeTableIdx;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
SKU_ID *SkuIdTable;
|
||||||
|
|
||||||
|
SizeTableIdx = 0;
|
||||||
|
|
||||||
|
for (i=0; i<LocalTokenNumberTableIdx; i++) {
|
||||||
|
LocalTokenNumber = LocalTokenNumberTable[i];
|
||||||
|
|
||||||
|
if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) {
|
||||||
|
//
|
||||||
|
// SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
|
||||||
|
// PCD entry.
|
||||||
|
//
|
||||||
|
if (LocalTokenNumber & PCD_TYPE_VPD) {
|
||||||
|
//
|
||||||
|
// We have only one entry for VPD enabled PCD entry:
|
||||||
|
// 1) MAX Size.
|
||||||
|
// We consider current size is equal to MAX size.
|
||||||
|
//
|
||||||
|
SizeTableIdx++;
|
||||||
|
} else {
|
||||||
|
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
|
||||||
|
//
|
||||||
|
// We have only two entry for Non-Sku enabled PCD entry:
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size
|
||||||
|
//
|
||||||
|
SizeTableIdx += 2;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// We have these entry for SKU enabled PCD entry
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
|
||||||
|
//
|
||||||
|
SkuIdTable = GetSkuIdArray (i, IsPeiDb);
|
||||||
|
SizeTableIdx += (UINTN)*SkuIdTable + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return SizeTableIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
GetSizeTableIndex (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN BOOLEAN IsPeiDb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 *LocalTokenNumberTable;
|
||||||
|
|
||||||
|
if (IsPeiDb) {
|
||||||
|
LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;
|
||||||
|
} else {
|
||||||
|
LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
||||||
|
}
|
||||||
|
return GetSizeTableIndexA (LocalTokenNumberTableIdx,
|
||||||
|
LocalTokenNumberTable,
|
||||||
|
IsPeiDb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
GetPtrTypeSize (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
OUT UINTN *MaxSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
INTN SizeTableIdx;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
SKU_ID *SkuIdTable;
|
||||||
|
SIZE_INFO *SizeTable;
|
||||||
|
UINTN i;
|
||||||
|
BOOLEAN IsPeiDb;
|
||||||
|
UINT32 *LocalTokenNumberTable;
|
||||||
|
|
||||||
|
IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx < PEI_LOCAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
|
|
||||||
|
if (IsPeiDb) {
|
||||||
|
LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;
|
||||||
|
SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;
|
||||||
|
} else {
|
||||||
|
LocalTokenNumberTableIdx -= PEI_LOCAL_TOKEN_NUMBER;
|
||||||
|
LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
||||||
|
SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];
|
||||||
|
|
||||||
|
ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
|
||||||
|
|
||||||
|
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, IsPeiDb);
|
||||||
|
|
||||||
|
*MaxSize = SizeTable[SizeTableIdx];
|
||||||
|
//
|
||||||
|
// SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
|
||||||
|
// PCD entry.
|
||||||
|
//
|
||||||
|
if (LocalTokenNumber & PCD_TYPE_VPD) {
|
||||||
|
//
|
||||||
|
// We have only one entry for VPD enabled PCD entry:
|
||||||
|
// 1) MAX Size.
|
||||||
|
// We consider current size is equal to MAX size.
|
||||||
|
//
|
||||||
|
return *MaxSize;
|
||||||
|
} else {
|
||||||
|
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
|
||||||
|
//
|
||||||
|
// We have only two entry for Non-Sku enabled PCD entry:
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size
|
||||||
|
//
|
||||||
|
return SizeTable[SizeTableIdx + 1];
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// We have these entry for SKU enabled PCD entry
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
|
||||||
|
//
|
||||||
|
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
|
||||||
|
for (i = 0; i < SkuIdTable[0]; i++) {
|
||||||
|
if (SkuIdTable[1 + i] == mPcdDatabase->PeiDb.Init.SystemSkuId) {
|
||||||
|
return SizeTable[SizeTableIdx + 1 + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SizeTable[SizeTableIdx + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
SetPtrTypeSize (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN OUT UINTN *CurrentSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
INTN SizeTableIdx;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
SKU_ID *SkuIdTable;
|
||||||
|
SIZE_INFO *SizeTable;
|
||||||
|
UINTN i;
|
||||||
|
UINTN MaxSize;
|
||||||
|
BOOLEAN IsPeiDb;
|
||||||
|
UINT32 *LocalTokenNumberTable;
|
||||||
|
|
||||||
|
IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx < PEI_LOCAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
|
if (IsPeiDb) {
|
||||||
|
LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;
|
||||||
|
SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;
|
||||||
|
} else {
|
||||||
|
LocalTokenNumberTableIdx -= PEI_LOCAL_TOKEN_NUMBER;
|
||||||
|
LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
||||||
|
SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];
|
||||||
|
|
||||||
|
ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
|
||||||
|
|
||||||
|
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, IsPeiDb);
|
||||||
|
|
||||||
|
MaxSize = SizeTable[SizeTableIdx];
|
||||||
|
//
|
||||||
|
// SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
|
||||||
|
// PCD entry.
|
||||||
|
//
|
||||||
|
if (LocalTokenNumber & PCD_TYPE_VPD) {
|
||||||
|
//
|
||||||
|
// We shouldn't come here as we don't support SET for VPD
|
||||||
|
//
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
if ((*CurrentSize > MaxSize) ||
|
||||||
|
(*CurrentSize == MAX_ADDRESS)) {
|
||||||
|
*CurrentSize = MaxSize;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
|
||||||
|
//
|
||||||
|
// We have only two entry for Non-Sku enabled PCD entry:
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size
|
||||||
|
//
|
||||||
|
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// We have these entry for SKU enabled PCD entry
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
|
||||||
|
//
|
||||||
|
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);
|
||||||
|
for (i = 0; i < SkuIdTable[0]; i++) {
|
||||||
|
if (SkuIdTable[1 + i] == mPcdDatabase->PeiDb.Init.SystemSkuId) {
|
||||||
|
SizeTable[SizeTableIdx + 1 + i] = (SIZE_INFO) *CurrentSize;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,29 +45,49 @@ typedef struct {
|
||||||
//
|
//
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SetWorker (
|
SetValueWorker (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN VOID *Data,
|
IN VOID *Data,
|
||||||
IN UINTN Size,
|
IN UINTN Size
|
||||||
IN BOOLEAN PtrType
|
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
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
|
EFI_STATUS
|
||||||
ExSetWorker (
|
ExSetWorker (
|
||||||
IN UINTN ExTokenNumber,
|
IN UINTN ExTokenNumber,
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
VOID *Data,
|
IN VOID *Data,
|
||||||
UINTN Size,
|
IN OUT UINTN *Size,
|
||||||
BOOLEAN PtrType
|
IN BOOLEAN PtrType
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
VOID *
|
VOID *
|
||||||
GetWorker (
|
GetWorker (
|
||||||
UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
UINTN GetSize
|
IN UINTN GetSize
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -132,6 +152,24 @@ GetExPcdTokenNumber (
|
||||||
IN UINT32 ExTokenNumber
|
IN UINT32 ExTokenNumber
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
GetPtrTypeSize (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
OUT UINTN *MaxSize
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
SetPtrTypeSize (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN OUT UINTN *CurrentSize
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Protocol Interface function declaration.
|
// Protocol Interface function declaration.
|
||||||
//
|
//
|
||||||
|
@ -303,9 +341,9 @@ DxePcdSet64 (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DxePcdSetPtr (
|
DxePcdSetPtr (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -362,10 +400,10 @@ DxePcdSet64Ex (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DxePcdSetPtrEx (
|
DxePcdSetPtrEx (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,11 @@ PeiPcdGetSize (
|
||||||
IN UINTN TokenNumber
|
IN UINTN TokenNumber
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
PEI_PCD_DATABASE *PeiPcdDb;
|
||||||
|
UINTN Size;
|
||||||
|
UINTN MaxSize;
|
||||||
|
|
||||||
|
PeiPcdDb = GetPcdDatabase ();
|
||||||
//
|
//
|
||||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||||
// We have to decrement TokenNumber by 1 to make it usable
|
// We have to decrement TokenNumber by 1 to make it usable
|
||||||
|
@ -179,7 +184,17 @@ PeiPcdGetSize (
|
||||||
|
|
||||||
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
|
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
return GetPcdDatabase()->Init.SizeTable[TokenNumber];
|
Size = (PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
|
||||||
|
|
||||||
|
if (Size == 0) {
|
||||||
|
//
|
||||||
|
// For pointer type, we need to scan the SIZE_TABLE to get the current size.
|
||||||
|
//
|
||||||
|
return GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
|
||||||
|
} else {
|
||||||
|
return Size;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,10 +287,10 @@ EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSet8 (
|
PeiPcdSet8 (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINT8 Value
|
IN UINT8 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,11 +298,11 @@ PeiPcdSet8 (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSet16 (
|
PeiPcdSet16 (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,11 +310,11 @@ PeiPcdSet16 (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSet32 (
|
PeiPcdSet32 (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -307,20 +322,20 @@ PeiPcdSet32 (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSet64 (
|
PeiPcdSet64 (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSetPtr (
|
PeiPcdSetPtr (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
|
return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
|
||||||
|
@ -331,11 +346,11 @@ PeiPcdSetPtr (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSetBool (
|
PeiPcdSetBool (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN BOOLEAN Value
|
IN BOOLEAN Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -348,13 +363,7 @@ PeiPcdSet8Ex (
|
||||||
IN UINT8 Value
|
IN UINT8 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,13 +376,7 @@ PeiPcdSet16Ex (
|
||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -386,13 +389,7 @@ PeiPcdSet32Ex (
|
||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,13 +402,7 @@ PeiPcdSet64Ex (
|
||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -421,17 +412,11 @@ EFIAPI
|
||||||
PeiPcdSetPtrEx (
|
PeiPcdSetPtrEx (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN UINTN ExTokenNumber,
|
IN UINTN ExTokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN UINTN *SizeOfBuffer,
|
||||||
IN VOID *Value
|
IN VOID *Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetWorker (ExTokenNumber, Guid, Value, SizeOfBuffer, TRUE);
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
Value,
|
|
||||||
SizeOfBuffer,
|
|
||||||
TRUE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -444,13 +429,7 @@ PeiPcdSetBoolEx (
|
||||||
IN BOOLEAN Value
|
IN BOOLEAN Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ExSetWorker(
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
||||||
ExTokenNumber,
|
|
||||||
Guid,
|
|
||||||
&Value,
|
|
||||||
sizeof (Value),
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -567,6 +546,8 @@ PeiPcdGetNextToken (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdGetNextTokenSpace (
|
PeiPcdGetNextTokenSpace (
|
||||||
|
|
|
@ -68,6 +68,10 @@ PeiRegisterCallBackWorker (
|
||||||
|
|
||||||
LocalTokenNumber = GetPcdDatabase()->Init.LocalTokenNumberTable[TokenNumber];
|
LocalTokenNumber = GetPcdDatabase()->Init.LocalTokenNumberTable[TokenNumber];
|
||||||
|
|
||||||
|
//
|
||||||
|
// We don't support SET for HII and VPD type PCD entry in PEI phase.
|
||||||
|
// So we will assert if any register callback for such PCD entry.
|
||||||
|
//
|
||||||
ASSERT ((LocalTokenNumber & PCD_TYPE_HII) == 0);
|
ASSERT ((LocalTokenNumber & PCD_TYPE_HII) == 0);
|
||||||
ASSERT ((LocalTokenNumber & PCD_TYPE_VPD) == 0);
|
ASSERT ((LocalTokenNumber & PCD_TYPE_VPD) == 0);
|
||||||
|
|
||||||
|
@ -223,19 +227,23 @@ GetSkuEnabledTokenNumber (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
|
||||||
case PCD_TYPE_VPD:
|
case PCD_TYPE_VPD:
|
||||||
Value += sizeof(VPD_HEAD) * i;
|
Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);
|
||||||
return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_VPD);
|
return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_VPD);
|
||||||
|
|
||||||
case PCD_TYPE_HII:
|
case PCD_TYPE_HII:
|
||||||
Value += sizeof(VARIABLE_HEAD) * i;
|
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[i]);
|
||||||
return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);
|
return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);
|
||||||
|
|
||||||
|
case PCD_TYPE_STRING:
|
||||||
|
Value = (UINT8 *) &(((STRING_HEAD *) Value)[i]);
|
||||||
|
return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);
|
||||||
|
|
||||||
case PCD_TYPE_DATA:
|
case PCD_TYPE_DATA:
|
||||||
Value += Size * i;
|
Value += Size * i;
|
||||||
return (Value - (UINT8 *) PeiPcdDb);
|
return (Value - (UINT8 *) PeiPcdDb);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
}
|
}
|
||||||
|
@ -293,13 +301,24 @@ InvokeCallbackOnSet (
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
SetValueWorker (
|
||||||
|
IN UINTN TokenNumber,
|
||||||
|
IN VOID *Data,
|
||||||
|
IN UINTN Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return SetWorker (TokenNumber, Data, &Size, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SetWorker (
|
SetWorker (
|
||||||
UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
VOID *Data,
|
IN OUT VOID *Data,
|
||||||
UINTN Size,
|
IN OUT UINTN *Size,
|
||||||
BOOLEAN PtrType
|
IN BOOLEAN PtrType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 LocalTokenNumber;
|
UINT32 LocalTokenNumber;
|
||||||
|
@ -307,6 +326,7 @@ SetWorker (
|
||||||
UINT16 StringTableIdx;
|
UINT16 StringTableIdx;
|
||||||
UINTN Offset;
|
UINTN Offset;
|
||||||
VOID *InternalData;
|
VOID *InternalData;
|
||||||
|
UINTN MaxSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||||
|
@ -321,10 +341,8 @@ SetWorker (
|
||||||
|
|
||||||
LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];
|
LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];
|
||||||
|
|
||||||
if (PtrType) {
|
if (!PtrType) {
|
||||||
ASSERT (PeiPcdDb->Init.SizeTable[TokenNumber] >= Size);
|
ASSERT (PeiPcdGetSize(TokenNumber + 1) == *Size);
|
||||||
} else {
|
|
||||||
ASSERT (PeiPcdDb->Init.SizeTable[TokenNumber] == Size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -333,17 +351,22 @@ SetWorker (
|
||||||
// type PCD entry in ExSetWorker.
|
// type PCD entry in ExSetWorker.
|
||||||
//
|
//
|
||||||
if (TokenNumber < PEI_NEX_TOKEN_NUMBER) {
|
if (TokenNumber < PEI_NEX_TOKEN_NUMBER) {
|
||||||
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, Size);
|
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
if (PtrType) {
|
||||||
|
MaxSize = GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
|
||||||
|
} else {
|
||||||
|
MaxSize = *Size;
|
||||||
|
}
|
||||||
|
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
||||||
InternalData = (VOID *) ((UINT8 *) PeiPcdDb + Offset);
|
InternalData = (VOID *) ((UINT8 *) PeiPcdDb + Offset);
|
||||||
|
|
||||||
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
|
||||||
case PCD_TYPE_VPD:
|
case PCD_TYPE_VPD:
|
||||||
case PCD_TYPE_HII:
|
case PCD_TYPE_HII:
|
||||||
{
|
{
|
||||||
|
@ -352,19 +375,26 @@ SetWorker (
|
||||||
}
|
}
|
||||||
|
|
||||||
case PCD_TYPE_STRING:
|
case PCD_TYPE_STRING:
|
||||||
StringTableIdx = *((UINT16 *)InternalData);
|
if (SetPtrTypeSize (TokenNumber, Size, PeiPcdDb)) {
|
||||||
CopyMem (&PeiPcdDb->Init.StringTable[StringTableIdx], Data, Size);
|
StringTableIdx = *((UINT16 *)InternalData);
|
||||||
return EFI_SUCCESS;
|
CopyMem (&PeiPcdDb->Init.StringTable[StringTableIdx], Data, *Size);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
case PCD_TYPE_DATA:
|
case PCD_TYPE_DATA:
|
||||||
{
|
{
|
||||||
|
|
||||||
if (PtrType) {
|
if (PtrType) {
|
||||||
CopyMem (InternalData, Data, Size);
|
if (SetPtrTypeSize (TokenNumber, Size, PeiPcdDb)) {
|
||||||
return EFI_SUCCESS;
|
CopyMem (InternalData, Data, *Size);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Size) {
|
switch (*Size) {
|
||||||
case sizeof(UINT8):
|
case sizeof(UINT8):
|
||||||
*((UINT8 *) InternalData) = *((UINT8 *) Data);
|
*((UINT8 *) InternalData) = *((UINT8 *) Data);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -396,26 +426,36 @@ SetWorker (
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
ExSetValueWorker (
|
||||||
|
IN UINTN ExTokenNumber,
|
||||||
|
IN CONST EFI_GUID *Guid,
|
||||||
|
IN VOID *Data,
|
||||||
|
IN UINTN Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ExSetWorker (ExTokenNumber, Guid, Data, &Size, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ExSetWorker (
|
ExSetWorker (
|
||||||
IN UINTN ExTokenNumber,
|
IN UINTN ExTokenNumber,
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
VOID *Data,
|
IN VOID *Data,
|
||||||
UINTN Size,
|
IN OUT UINTN *Size,
|
||||||
BOOLEAN PtrType
|
IN BOOLEAN PtrType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN TokenNumber;
|
UINTN TokenNumber;
|
||||||
|
|
||||||
TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
|
TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
|
||||||
|
|
||||||
InvokeCallbackOnSet (ExTokenNumber, Guid, TokenNumber, Data, Size);
|
InvokeCallbackOnSet (ExTokenNumber, Guid, TokenNumber, Data, *Size);
|
||||||
|
|
||||||
SetWorker (TokenNumber, Data, Size, PtrType);
|
return SetWorker (TokenNumber, Data, Size, PtrType);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -451,7 +491,7 @@ GetWorker (
|
||||||
UINT16 StringTableIdx;
|
UINT16 StringTableIdx;
|
||||||
PEI_PCD_DATABASE *PeiPcdDb;
|
PEI_PCD_DATABASE *PeiPcdDb;
|
||||||
UINT32 LocalTokenNumber;
|
UINT32 LocalTokenNumber;
|
||||||
UINTN Size;
|
UINTN MaxSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||||
|
@ -462,22 +502,25 @@ GetWorker (
|
||||||
|
|
||||||
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
|
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
|
||||||
|
|
||||||
Size = PeiPcdGetSize(TokenNumber + 1);
|
ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));
|
||||||
|
|
||||||
ASSERT (GetSize == Size || GetSize == 0);
|
|
||||||
|
|
||||||
PeiPcdDb = GetPcdDatabase ();
|
PeiPcdDb = GetPcdDatabase ();
|
||||||
|
|
||||||
LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];
|
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);
|
if (GetSize == 0) {
|
||||||
|
MaxSize = GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
|
||||||
|
} else {
|
||||||
|
MaxSize = GetSize;
|
||||||
|
}
|
||||||
|
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
||||||
StringTable = PeiPcdDb->Init.StringTable;
|
StringTable = PeiPcdDb->Init.StringTable;
|
||||||
|
|
||||||
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
|
||||||
case PCD_TYPE_VPD:
|
case PCD_TYPE_VPD:
|
||||||
{
|
{
|
||||||
VPD_HEAD *VpdHead;
|
VPD_HEAD *VpdHead;
|
||||||
|
@ -578,3 +621,208 @@ GetPcdDatabase (
|
||||||
return (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
|
return (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SKU_ID *
|
||||||
|
GetSkuIdArray (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN PEI_PCD_DATABASE *Database
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SKU_HEAD *SkuHead;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
|
||||||
|
LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
|
||||||
|
|
||||||
|
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);
|
||||||
|
|
||||||
|
SkuHead = (SKU_HEAD *) ((UINT8 *)Database + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
|
||||||
|
|
||||||
|
return (SKU_ID *) ((UINT8 *)Database + SkuHead->SkuIdTableOffset);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
GetSizeTableIndex (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN PEI_PCD_DATABASE *Database
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN i;
|
||||||
|
UINTN SizeTableIdx;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
SKU_ID *SkuIdTable;
|
||||||
|
|
||||||
|
SizeTableIdx = 0;
|
||||||
|
|
||||||
|
for (i=0; i<LocalTokenNumberTableIdx; i++) {
|
||||||
|
LocalTokenNumber = Database->Init.LocalTokenNumberTable[i];
|
||||||
|
|
||||||
|
if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) {
|
||||||
|
//
|
||||||
|
// SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
|
||||||
|
// PCD entry.
|
||||||
|
//
|
||||||
|
if (LocalTokenNumber & PCD_TYPE_VPD) {
|
||||||
|
//
|
||||||
|
// We have only one entry for VPD enabled PCD entry:
|
||||||
|
// 1) MAX Size.
|
||||||
|
// We consider current size is equal to MAX size.
|
||||||
|
//
|
||||||
|
SizeTableIdx++;
|
||||||
|
} else {
|
||||||
|
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
|
||||||
|
//
|
||||||
|
// We have only two entry for Non-Sku enabled PCD entry:
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size
|
||||||
|
//
|
||||||
|
SizeTableIdx += 2;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// We have these entry for SKU enabled PCD entry
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
|
||||||
|
//
|
||||||
|
SkuIdTable = GetSkuIdArray (i, Database);
|
||||||
|
SizeTableIdx += (UINTN)*SkuIdTable + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return SizeTableIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UINTN
|
||||||
|
GetPtrTypeSize (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
OUT UINTN *MaxSize,
|
||||||
|
IN PEI_PCD_DATABASE *Database
|
||||||
|
)
|
||||||
|
{
|
||||||
|
INTN SizeTableIdx;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
SKU_ID *SkuIdTable;
|
||||||
|
SIZE_INFO *SizeTable;
|
||||||
|
UINTN i;
|
||||||
|
|
||||||
|
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
|
||||||
|
|
||||||
|
LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
|
||||||
|
|
||||||
|
ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
|
||||||
|
|
||||||
|
SizeTable = Database->Init.SizeTable;
|
||||||
|
|
||||||
|
*MaxSize = SizeTable[SizeTableIdx];
|
||||||
|
//
|
||||||
|
// SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
|
||||||
|
// PCD entry.
|
||||||
|
//
|
||||||
|
if (LocalTokenNumber & PCD_TYPE_VPD) {
|
||||||
|
//
|
||||||
|
// We have only one entry for VPD enabled PCD entry:
|
||||||
|
// 1) MAX Size.
|
||||||
|
// We consider current size is equal to MAX size.
|
||||||
|
//
|
||||||
|
return *MaxSize;
|
||||||
|
} else {
|
||||||
|
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
|
||||||
|
//
|
||||||
|
// We have only two entry for Non-Sku enabled PCD entry:
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size
|
||||||
|
//
|
||||||
|
return SizeTable[SizeTableIdx + 1];
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// We have these entry for SKU enabled PCD entry
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
|
||||||
|
//
|
||||||
|
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
|
||||||
|
for (i = 0; i < SkuIdTable[0]; i++) {
|
||||||
|
if (SkuIdTable[1 + i] == Database->Init.SystemSkuId) {
|
||||||
|
return SizeTable[SizeTableIdx + 1 + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SizeTable[SizeTableIdx + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
SetPtrTypeSize (
|
||||||
|
IN UINTN LocalTokenNumberTableIdx,
|
||||||
|
IN OUT UINTN *CurrentSize,
|
||||||
|
IN PEI_PCD_DATABASE *Database
|
||||||
|
)
|
||||||
|
{
|
||||||
|
INTN SizeTableIdx;
|
||||||
|
UINTN LocalTokenNumber;
|
||||||
|
SKU_ID *SkuIdTable;
|
||||||
|
SIZE_INFO *SizeTable;
|
||||||
|
UINTN i;
|
||||||
|
UINTN MaxSize;
|
||||||
|
|
||||||
|
SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
|
||||||
|
|
||||||
|
LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];
|
||||||
|
|
||||||
|
ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
|
||||||
|
|
||||||
|
SizeTable = Database->Init.SizeTable;
|
||||||
|
|
||||||
|
MaxSize = SizeTable[SizeTableIdx];
|
||||||
|
//
|
||||||
|
// SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
|
||||||
|
// PCD entry.
|
||||||
|
//
|
||||||
|
if (LocalTokenNumber & PCD_TYPE_VPD) {
|
||||||
|
//
|
||||||
|
// We shouldn't come here as we don't support SET for VPD
|
||||||
|
//
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
if ((*CurrentSize > MaxSize) ||
|
||||||
|
(*CurrentSize == MAX_ADDRESS)) {
|
||||||
|
*CurrentSize = MaxSize;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
|
||||||
|
//
|
||||||
|
// We have only two entry for Non-Sku enabled PCD entry:
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size
|
||||||
|
//
|
||||||
|
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// We have these entry for SKU enabled PCD entry
|
||||||
|
// 1) MAX SIZE
|
||||||
|
// 2) Current Size for each SKU_ID (It is equal to MaxSku).
|
||||||
|
//
|
||||||
|
SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
|
||||||
|
for (i = 0; i < SkuIdTable[0]; i++) {
|
||||||
|
if (SkuIdTable[1 + i] == Database->Init.SystemSkuId) {
|
||||||
|
SizeTable[SizeTableIdx + 1 + i] = (SIZE_INFO) *CurrentSize;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -40,25 +40,49 @@ GetPcdDatabase (
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SetWorker (
|
SetValueWorker (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN VOID *Data,
|
IN VOID *Data,
|
||||||
IN UINTN Size,
|
IN UINTN Size
|
||||||
IN BOOLEAN PtrType
|
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ExSetWorker (
|
SetWorker (
|
||||||
IN UINTN ExTokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN CONST EFI_GUID *Guid,
|
IN VOID *Data,
|
||||||
IN VOID *Data,
|
IN OUT UINTN *Size,
|
||||||
IN UINTN Size,
|
IN BOOLEAN PtrType
|
||||||
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 *
|
VOID *
|
||||||
GetWorker (
|
GetWorker (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
|
@ -66,6 +90,8 @@ GetWorker (
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID *
|
VOID *
|
||||||
ExGetWorker (
|
ExGetWorker (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
|
@ -109,6 +135,27 @@ BuildPcdDatabase (
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
// PPI Interface Implementation Declaration.
|
||||||
//
|
//
|
||||||
|
@ -276,9 +323,9 @@ PeiPcdSet64 (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSetPtr (
|
PeiPcdSetPtr (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -334,10 +381,10 @@ PeiPcdSet64Ex (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PeiPcdSetPtrEx (
|
PeiPcdSetPtrEx (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -152,9 +152,9 @@ EFI_STATUS
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *PCD_PPI_SET_POINTER) (
|
(EFIAPI *PCD_PPI_SET_POINTER) (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
|
@ -199,10 +199,10 @@ EFI_STATUS
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *PCD_PPI_SET_EX_POINTER) (
|
(EFIAPI *PCD_PPI_SET_EX_POINTER) (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
|
|
|
@ -152,9 +152,9 @@ EFI_STATUS
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *PCD_PROTOCOL_SET_POINTER) (
|
(EFIAPI *PCD_PROTOCOL_SET_POINTER) (
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
|
@ -199,10 +199,10 @@ EFI_STATUS
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *PCD_PROTOCOL_SET_EX_POINTER) (
|
(EFIAPI *PCD_PROTOCOL_SET_EX_POINTER) (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN UINTN TokenNumber,
|
IN UINTN TokenNumber,
|
||||||
IN UINTN SizeOfBuffer,
|
IN OUT UINTN *SizeOfBuffer,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
|
@ -228,7 +228,7 @@ typedef
|
||||||
VOID
|
VOID
|
||||||
(EFIAPI *PCD_PROTOCOL_CALLBACK) (
|
(EFIAPI *PCD_PROTOCOL_CALLBACK) (
|
||||||
IN CONST EFI_GUID *CallBackGuid, OPTIONAL
|
IN CONST EFI_GUID *CallBackGuid, OPTIONAL
|
||||||
IN UINTN CallBackToken,
|
IN UINTN CallBackToken,
|
||||||
IN OUT VOID *TokenData,
|
IN OUT VOID *TokenData,
|
||||||
IN UINTN TokenDataSize
|
IN UINTN TokenDataSize
|
||||||
);
|
);
|
||||||
|
|
|
@ -463,6 +463,8 @@ LibPcdSetPtr (
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
ASSERT (SizeOfBuffer != NULL);
|
||||||
|
|
||||||
if (*SizeOfBuffer > 0) {
|
if (*SizeOfBuffer > 0) {
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -514,23 +514,19 @@ LibPcdSetPtr (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Size;
|
|
||||||
|
ASSERT (SizeOfBuffer != NULL);
|
||||||
|
|
||||||
if (*SizeOfBuffer > 0) {
|
if (*SizeOfBuffer > 0) {
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Size = LibPcdGetSize (TokenNumber);
|
Status = mPcd->SetPtr (TokenNumber, SizeOfBuffer, Buffer);
|
||||||
|
|
||||||
if (*SizeOfBuffer > Size) {
|
if (EFI_ERROR (Status)) {
|
||||||
*SizeOfBuffer = Size;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = mPcd->SetPtr (TokenNumber, *SizeOfBuffer, Buffer);
|
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +724,6 @@ LibPcdSetExPtr (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Size;
|
|
||||||
|
|
||||||
ASSERT (Guid != NULL);
|
ASSERT (Guid != NULL);
|
||||||
|
|
||||||
|
@ -738,17 +733,12 @@ LibPcdSetExPtr (
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = mPcd->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);
|
||||||
|
|
||||||
Size = LibPcdGetExSize (Guid, TokenNumber);
|
if (EFI_ERROR (Status)) {
|
||||||
if (*SizeOfBuffer > Size) {
|
|
||||||
*SizeOfBuffer = Size;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = mPcd->SetPtrEx (Guid, TokenNumber, *SizeOfBuffer, Buffer);
|
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -586,7 +586,6 @@ LibPcdSetPtr (
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PCD_PPI *PcdPpi;
|
PCD_PPI *PcdPpi;
|
||||||
UINTN Size;
|
|
||||||
|
|
||||||
ASSERT (SizeOfBuffer != NULL);
|
ASSERT (SizeOfBuffer != NULL);
|
||||||
|
|
||||||
|
@ -596,17 +595,12 @@ LibPcdSetPtr (
|
||||||
|
|
||||||
PcdPpi = GetPcdPpiPtr ();
|
PcdPpi = GetPcdPpiPtr ();
|
||||||
|
|
||||||
Size = LibPcdGetSize (TokenNumber);
|
Status = PcdPpi->SetPtr (TokenNumber, SizeOfBuffer, Buffer);
|
||||||
|
|
||||||
if (*SizeOfBuffer > Size) {
|
if (EFI_ERROR (Status)) {
|
||||||
*SizeOfBuffer = Size;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PcdPpi->SetPtr (TokenNumber, *SizeOfBuffer, Buffer);
|
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,7 +811,6 @@ LibPcdSetExPtr (
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PCD_PPI *PcdPpi;
|
PCD_PPI *PcdPpi;
|
||||||
UINTN Size;
|
|
||||||
|
|
||||||
if (*SizeOfBuffer > 0) {
|
if (*SizeOfBuffer > 0) {
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
|
@ -825,16 +818,12 @@ LibPcdSetExPtr (
|
||||||
|
|
||||||
PcdPpi = GetPcdPpiPtr ();
|
PcdPpi = GetPcdPpiPtr ();
|
||||||
|
|
||||||
Size = LibPcdGetExSize (Guid, TokenNumber);
|
Status = PcdPpi->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);
|
||||||
if (*SizeOfBuffer > Size) {
|
|
||||||
*SizeOfBuffer = Size;
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PcdPpi->SetPtrEx (Guid, TokenNumber, *SizeOfBuffer, Buffer);
|
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,32 @@
|
||||||
//
|
//
|
||||||
typedef UINT8 SKU_ID;
|
typedef UINT8 SKU_ID;
|
||||||
|
|
||||||
#define PCD_TYPE_SHIFT 24
|
#define PCD_TYPE_SHIFT 28
|
||||||
|
|
||||||
|
#define PCD_TYPE_DATA (0x0 << PCD_TYPE_SHIFT)
|
||||||
|
#define PCD_TYPE_HII (0x8 << PCD_TYPE_SHIFT)
|
||||||
|
#define PCD_TYPE_VPD (0x4 << PCD_TYPE_SHIFT)
|
||||||
|
#define PCD_TYPE_SKU_ENABLED (0x2 << PCD_TYPE_SHIFT)
|
||||||
|
#define PCD_TYPE_STRING (0x1 << PCD_TYPE_SHIFT)
|
||||||
|
|
||||||
|
#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)
|
||||||
|
|
||||||
|
#define PCD_DATUM_TYPE_SHIFT 24
|
||||||
|
|
||||||
|
#define PCD_DATUM_TYPE_POINTER (0x0 << PCD_DATUM_TYPE_SHIFT)
|
||||||
|
#define PCD_DATUM_TYPE_UINT8 (0x1 << PCD_DATUM_TYPE_SHIFT)
|
||||||
|
#define PCD_DATUM_TYPE_UINT16 (0x2 << PCD_DATUM_TYPE_SHIFT)
|
||||||
|
#define PCD_DATUM_TYPE_UINT32 (0x4 << PCD_DATUM_TYPE_SHIFT)
|
||||||
|
#define PCD_DATUM_TYPE_UINT64 (0x8 << PCD_DATUM_TYPE_SHIFT)
|
||||||
|
|
||||||
|
#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \
|
||||||
|
PCD_DATUM_TYPE_UINT8 | \
|
||||||
|
PCD_DATUM_TYPE_UINT16 | \
|
||||||
|
PCD_DATUM_TYPE_UINT32 | \
|
||||||
|
PCD_DATUM_TYPE_UINT64)
|
||||||
|
|
||||||
|
|
||||||
#define PCD_TYPE_DATA (0x00 << PCD_TYPE_SHIFT)
|
#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET))
|
||||||
#define PCD_TYPE_HII (0x80 << PCD_TYPE_SHIFT)
|
|
||||||
#define PCD_TYPE_VPD (0x40 << PCD_TYPE_SHIFT)
|
|
||||||
#define PCD_TYPE_SKU_ENABLED (0x20 << PCD_TYPE_SHIFT)
|
|
||||||
#define PCD_TYPE_STRING (0x10 << PCD_TYPE_SHIFT)
|
|
||||||
|
|
||||||
|
|
||||||
#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING))
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 ExTokenNumber;
|
UINT32 ExTokenNumber;
|
||||||
|
@ -46,11 +61,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef UINT16 STRING_HEAD;
|
typedef UINT16 STRING_HEAD;
|
||||||
|
|
||||||
typedef struct {
|
typedef UINT16 SIZE_INFO;
|
||||||
UINT32 LocalTokenNumber;
|
|
||||||
UINT16 TokenNumber;
|
|
||||||
UINT16 Size;
|
|
||||||
} SIZEINFO;
|
|
||||||
|
|
||||||
#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)
|
#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)
|
||||||
|
|
||||||
|
|
|
@ -229,16 +229,24 @@ class StringTable {
|
||||||
|
|
||||||
**/
|
**/
|
||||||
class SizeTable {
|
class SizeTable {
|
||||||
private ArrayList<Integer> al;
|
private ArrayList<ArrayList<Integer>> al;
|
||||||
private ArrayList<String> alComments;
|
private ArrayList<String> alComments;
|
||||||
private String phase;
|
|
||||||
private int len;
|
private int len;
|
||||||
|
private String phase;
|
||||||
|
|
||||||
public SizeTable (String phase) {
|
public SizeTable (String phase) {
|
||||||
this.phase = phase;
|
al = new ArrayList<ArrayList<Integer>>();
|
||||||
al = new ArrayList<Integer>();
|
|
||||||
alComments = new ArrayList<String>();
|
alComments = new ArrayList<String>();
|
||||||
len = 0;
|
len = 0;
|
||||||
|
this.phase = phase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSizeMacro () {
|
||||||
|
return String.format(PcdDatabase.SizeTableSizeMacro, phase, getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSize() {
|
||||||
|
return len == 0 ? 1 : len;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void genCode (ArrayList<CStructTypeDeclaration> declaList, HashMap<String, String> instTable, String phase) {
|
public void genCode (ArrayList<CStructTypeDeclaration> declaList, HashMap<String, String> instTable, String phase) {
|
||||||
|
@ -262,6 +270,7 @@ class SizeTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<String> getInstantiation () {
|
private ArrayList<String> getInstantiation () {
|
||||||
|
final String comma = ",";
|
||||||
ArrayList<String> Output = new ArrayList<String>();
|
ArrayList<String> Output = new ArrayList<String>();
|
||||||
|
|
||||||
Output.add("/* SizeTable */");
|
Output.add("/* SizeTable */");
|
||||||
|
@ -270,14 +279,23 @@ class SizeTable {
|
||||||
Output.add("\t0");
|
Output.add("\t0");
|
||||||
} else {
|
} else {
|
||||||
for (int index = 0; index < al.size(); index++) {
|
for (int index = 0; index < al.size(); index++) {
|
||||||
Integer n = al.get(index);
|
ArrayList<Integer> ial = al.get(index);
|
||||||
String str = "\t" + n.toString();
|
|
||||||
|
String str = "\t";
|
||||||
if (index != (al.size() - 1)) {
|
|
||||||
str += ",";
|
for (int index2 = 0; index2 < ial.size(); index2++) {
|
||||||
|
str += " " + ial.get(index2).toString();
|
||||||
|
if (index2 != ial.size() - 1) {
|
||||||
|
str += comma;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str += " /* " + alComments.get(index) + " */";
|
str += " /* " + alComments.get(index) + " */";
|
||||||
|
|
||||||
|
if (index != (al.size() - 1)) {
|
||||||
|
str += comma;
|
||||||
|
}
|
||||||
|
|
||||||
Output.add(str);
|
Output.add(str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -287,20 +305,25 @@ class SizeTable {
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int add (Token token) {
|
public void add (Token token) {
|
||||||
int index = len;
|
|
||||||
|
|
||||||
len++;
|
//
|
||||||
al.add(token.datumSize);
|
// We only have size information for POINTER type PCD entry.
|
||||||
|
//
|
||||||
|
if (token.datumType != Token.DATUM_TYPE.POINTER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<Integer> ial = token.getPointerTypeSize();
|
||||||
|
|
||||||
|
len+= ial.size();
|
||||||
|
|
||||||
|
al.add(ial);
|
||||||
alComments.add(token.getPrimaryKeyString());
|
alComments.add(token.getPrimaryKeyString());
|
||||||
|
|
||||||
return index;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTableLen () {
|
|
||||||
return al.size() == 0 ? 1 : al.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -344,7 +367,7 @@ class GuidTable {
|
||||||
cCode += String.format(PcdDatabase.GuidTableDeclaration, phase);
|
cCode += String.format(PcdDatabase.GuidTableDeclaration, phase);
|
||||||
decl = new CStructTypeDeclaration (
|
decl = new CStructTypeDeclaration (
|
||||||
name,
|
name,
|
||||||
8,
|
4,
|
||||||
cCode,
|
cCode,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -674,6 +697,25 @@ class LocalTokenNumberTable {
|
||||||
str += " | PCD_TYPE_VPD";
|
str += " | PCD_TYPE_VPD";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (token.datumType) {
|
||||||
|
case UINT8:
|
||||||
|
case BOOLEAN:
|
||||||
|
str += " | PCD_DATUM_TYPE_UINT8";
|
||||||
|
break;
|
||||||
|
case UINT16:
|
||||||
|
str += " | PCD_DATUM_TYPE_UINT16";
|
||||||
|
break;
|
||||||
|
case UINT32:
|
||||||
|
str += " | PCD_DATUM_TYPE_UINT32";
|
||||||
|
break;
|
||||||
|
case UINT64:
|
||||||
|
str += " | PCD_DATUM_TYPE_UINT64";
|
||||||
|
break;
|
||||||
|
case POINTER:
|
||||||
|
str += " | PCD_DATUM_TYPE_POINTER";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
al.add(str);
|
al.add(str);
|
||||||
alComment.add(token.getPrimaryKeyString());
|
alComment.add(token.getPrimaryKeyString());
|
||||||
|
|
||||||
|
@ -851,7 +893,7 @@ class PcdDatabase {
|
||||||
public final static String GuidTableDeclaration = "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n";
|
public final static String GuidTableDeclaration = "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n";
|
||||||
public final static String LocalTokenNumberTableDeclaration = "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
|
public final static String LocalTokenNumberTableDeclaration = "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
|
||||||
public final static String StringTableDeclaration = "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n";
|
public final static String StringTableDeclaration = "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n";
|
||||||
public final static String SizeTableDeclaration = "UINT16 SizeTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
|
public final static String SizeTableDeclaration = "SIZE_INFO SizeTable[%s_SIZE_TABLE_SIZE];\r\n";
|
||||||
public final static String SkuIdTableDeclaration = "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";
|
public final static String SkuIdTableDeclaration = "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";
|
||||||
|
|
||||||
|
|
||||||
|
@ -860,6 +902,7 @@ class PcdDatabase {
|
||||||
public final static String GuidTableSizeMacro = "#define %s_GUID_TABLE_SIZE %d\r\n";
|
public final static String GuidTableSizeMacro = "#define %s_GUID_TABLE_SIZE %d\r\n";
|
||||||
public final static String LocalTokenNumberTableSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER_TABLE_SIZE %d\r\n";
|
public final static String LocalTokenNumberTableSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER_TABLE_SIZE %d\r\n";
|
||||||
public final static String LocalTokenNumberSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER %d\r\n";
|
public final static String LocalTokenNumberSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER %d\r\n";
|
||||||
|
public final static String SizeTableSizeMacro = "#define %s_SIZE_TABLE_SIZE %d\r\n";
|
||||||
public final static String StringTableSizeMacro = "#define %s_STRING_TABLE_SIZE %d\r\n";
|
public final static String StringTableSizeMacro = "#define %s_STRING_TABLE_SIZE %d\r\n";
|
||||||
public final static String SkuIdTableSizeMacro = "#define %s_SKUID_TABLE_SIZE %d\r\n";
|
public final static String SkuIdTableSizeMacro = "#define %s_SKUID_TABLE_SIZE %d\r\n";
|
||||||
|
|
||||||
|
@ -1144,6 +1187,7 @@ class PcdDatabase {
|
||||||
macroStr += skuIdTable.getSizeMacro();
|
macroStr += skuIdTable.getSizeMacro();
|
||||||
macroStr += localTokenNumberTable.getSizeMacro();
|
macroStr += localTokenNumberTable.getSizeMacro();
|
||||||
macroStr += exMapTable.getSizeMacro();
|
macroStr += exMapTable.getSizeMacro();
|
||||||
|
macroStr += sizeTable.getSizeMacro();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Generate existance info Macro for all Tables
|
// Generate existance info Macro for all Tables
|
||||||
|
@ -1311,6 +1355,9 @@ class PcdDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// privateGlobalName and privateGlobalCCode is used to pass output to caller of getCDeclarationString
|
||||||
|
//
|
||||||
private void getCDeclarationString(Token t)
|
private void getCDeclarationString(Token t)
|
||||||
throws EntityException {
|
throws EntityException {
|
||||||
|
|
||||||
|
@ -1321,7 +1368,7 @@ class PcdDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
String type = getCType(t);
|
String type = getCType(t);
|
||||||
if ((t.datumType == Token.DATUM_TYPE.POINTER) && (!t.isHiiEnable())) {
|
if ((t.datumType == Token.DATUM_TYPE.POINTER) && (!t.isHiiEnable()) && (!t.isUnicodeStringType())) {
|
||||||
int bufferSize;
|
int bufferSize;
|
||||||
if (t.isASCIIStringType()) {
|
if (t.isASCIIStringType()) {
|
||||||
//
|
//
|
||||||
|
@ -3007,14 +3054,16 @@ public class CollectPCDAction {
|
||||||
**/
|
**/
|
||||||
public static void main(String argv[]) throws EntityException {
|
public static void main(String argv[]) throws EntityException {
|
||||||
CollectPCDAction ca = new CollectPCDAction();
|
CollectPCDAction ca = new CollectPCDAction();
|
||||||
ca.setWorkspacePath("m:/tianocore/edk2");
|
String projectDir = "x:/edk2";
|
||||||
ca.setFPDFilePath("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd");
|
ca.setWorkspacePath(projectDir);
|
||||||
|
ca.setFPDFilePath(projectDir + "/EdkNt32Pkg/Nt32.fpd");
|
||||||
ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
|
ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
|
||||||
GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
|
GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
|
||||||
"m:/tianocore/edk2",
|
projectDir,
|
||||||
"tools_def.txt");
|
"tools_def.txt");
|
||||||
|
System.out.println("After initInfo!");
|
||||||
FpdParserTask fpt = new FpdParserTask();
|
FpdParserTask fpt = new FpdParserTask();
|
||||||
fpt.parseFpdFile(new File("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd"));
|
fpt.parseFpdFile(new File(projectDir + "/EdkNt32Pkg/Nt32.fpd"));
|
||||||
ca.execute();
|
ca.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,7 +574,78 @@ public class Token {
|
||||||
public int getSkuIdCount () {
|
public int getSkuIdCount () {
|
||||||
return this.skuData.size();
|
return this.skuData.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {
|
||||||
|
if (isValidNullValue(str)) {
|
||||||
|
al.add(new Integer(0));
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// isValidNullValue has already make sure that str here
|
||||||
|
// always contain a valid default value of the following 3
|
||||||
|
// cases:
|
||||||
|
// 1) "Hello world" //Assci string
|
||||||
|
// 2) L"Hello" //Unicode string
|
||||||
|
// 3) {0x01, 0x02, 0x03} //Byte stream
|
||||||
|
//
|
||||||
|
if (str.startsWith("\"")) {
|
||||||
|
al.add(new Integer(str.length() - 2));
|
||||||
|
} else if (str.startsWith("L\"")){
|
||||||
|
//
|
||||||
|
// Unicode is 2 bytes each.
|
||||||
|
//
|
||||||
|
al.add(new Integer((str.length() - 3) * 2));
|
||||||
|
} else if (str.startsWith("{")) {
|
||||||
|
//
|
||||||
|
// We count the number of "," in the string.
|
||||||
|
// The number of byte is one plus the number of
|
||||||
|
// comma.
|
||||||
|
//
|
||||||
|
String str2 = str;
|
||||||
|
|
||||||
|
int cnt = 0;
|
||||||
|
int pos = 0;
|
||||||
|
pos = str2.indexOf(",", 0);
|
||||||
|
while (pos != -1) {
|
||||||
|
cnt++;
|
||||||
|
pos++;
|
||||||
|
pos = str2.indexOf(",", pos);
|
||||||
|
}
|
||||||
|
cnt++;
|
||||||
|
al.add(new Integer(cnt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// This method can be used to get the MAX and current size
|
||||||
|
// for pointer type dynamic(ex) PCD entry
|
||||||
|
//
|
||||||
|
public ArrayList<Integer> getPointerTypeSize () {
|
||||||
|
ArrayList<Integer> al = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
//
|
||||||
|
// For VPD_enabled and HII_enabled, we can only return the MAX size.
|
||||||
|
// For the default DATA type dynamic PCD entry, we will return
|
||||||
|
// the MAX size and current size for each SKU_ID.
|
||||||
|
//
|
||||||
|
al.add(new Integer(this.datumSize));
|
||||||
|
|
||||||
|
if (!this.isVpdEnable()) {
|
||||||
|
int idx;
|
||||||
|
if (this.isHiiEnable()){
|
||||||
|
for (idx = 0; idx < this.skuData.size(); idx++) {
|
||||||
|
String str = this.skuData.get(idx).value.hiiDefaultValue;
|
||||||
|
getCurrentSizeFromDefaultValue(str, al);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (idx = 0; idx < this.skuData.size(); idx++) {
|
||||||
|
String str = this.skuData.get(idx).value.value;
|
||||||
|
getCurrentSizeFromDefaultValue(str, al);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return al;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get default value for a token, For HII type, HiiDefaultValue of default
|
Get default value for a token, For HII type, HiiDefaultValue of default
|
||||||
|
|
Loading…
Reference in New Issue