mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
Add PcdDxe and PcdPEIM to all-arch for EdkModulePkg-All-Archs.fpd
Fix a few bugs in PcdDxe and PcdPEIM git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@722 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
a15bb0d31f
commit
bb5545b663
File diff suppressed because it is too large
Load Diff
@ -742,19 +742,23 @@ GetExPcdTokenNumber (
|
||||
EFI_GUID *MatchGuid;
|
||||
UINTN MatchGuidIdx;
|
||||
|
||||
ExMap = mPcdDatabase->PeiDb.Init.ExMapTable;
|
||||
GuidTable = mPcdDatabase->PeiDb.Init.GuidTable;
|
||||
|
||||
MatchGuid = ScanGuid (GuidTable, sizeof(mPcdDatabase->PeiDb.Init.GuidTable), Guid);
|
||||
ASSERT (MatchGuid != NULL);
|
||||
if (!PEI_DATABASE_EMPTY) {
|
||||
ExMap = mPcdDatabase->PeiDb.Init.ExMapTable;
|
||||
GuidTable = mPcdDatabase->PeiDb.Init.GuidTable;
|
||||
|
||||
MatchGuid = ScanGuid (GuidTable, sizeof(mPcdDatabase->PeiDb.Init.GuidTable), Guid);
|
||||
|
||||
if (MatchGuid != NULL) {
|
||||
|
||||
MatchGuidIdx = MatchGuid - GuidTable;
|
||||
|
||||
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
|
||||
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
|
||||
(MatchGuidIdx == ExMap[i].ExGuidIndex)) {
|
||||
return ExMap[i].LocalTokenNumber;
|
||||
MatchGuidIdx = MatchGuid - GuidTable;
|
||||
|
||||
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
|
||||
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
|
||||
(MatchGuidIdx == ExMap[i].ExGuidIndex)) {
|
||||
return ExMap[i].LocalTokenNumber;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -762,6 +766,10 @@ GetExPcdTokenNumber (
|
||||
GuidTable = mPcdDatabase->DxeDb.Init.GuidTable;
|
||||
|
||||
MatchGuid = ScanGuid (GuidTable, sizeof(mPcdDatabase->DxeDb.Init.GuidTable), Guid);
|
||||
//
|
||||
// We need to ASSERT here. If GUID can't be found in GuidTable, this is a
|
||||
// error in the BUILD system.
|
||||
//
|
||||
ASSERT (MatchGuid != NULL);
|
||||
|
||||
MatchGuidIdx = MatchGuid - GuidTable;
|
||||
@ -769,7 +777,7 @@ GetExPcdTokenNumber (
|
||||
for (i = 0; i < DXE_EXMAPPING_TABLE_SIZE; i++) {
|
||||
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
|
||||
(MatchGuidIdx == ExMap[i].ExGuidIndex)) {
|
||||
return ExMap[i].LocalTokenNumber + PEI_LOCAL_TOKEN_NUMBER;
|
||||
return ExMap[i].LocalTokenNumber;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,6 +545,10 @@ GetExPcdTokenNumber (
|
||||
GuidTable = PeiPcdDb->Init.GuidTable;
|
||||
|
||||
MatchGuid = ScanGuid (GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);
|
||||
//
|
||||
// We need to ASSERT here. If GUID can't be found in GuidTable, this is a
|
||||
// error in the BUILD system.
|
||||
//
|
||||
ASSERT (MatchGuid != NULL);
|
||||
|
||||
MatchGuidIdx = MatchGuid - GuidTable;
|
||||
|
@ -435,17 +435,16 @@ LibPcdSet64 (
|
||||
|
||||
|
||||
/**
|
||||
Sets a buffer for the token specified by TokenNumber to
|
||||
the value specified by Buffer and SizeOfValue. Buffer to
|
||||
be set is returned. The content of the buffer could be
|
||||
overwritten if a Callback on SET is registered with this
|
||||
TokenNumber.
|
||||
|
||||
If SizeOfValue is greater than the maximum
|
||||
size support by TokenNumber, then set SizeOfValue to the
|
||||
maximum size supported by TokenNumber and return NULL to
|
||||
indicate that the set operation was not actually performed.
|
||||
Sets a buffer for the token specified by TokenNumber to the value
|
||||
specified by Buffer and SizeOfValue. Buffer is returned.
|
||||
If SizeOfValue is greater than the maximum size support by TokenNumber,
|
||||
then set SizeOfValue to the maximum size supported by TokenNumber and
|
||||
return NULL to indicate that the set operation was not actually performed.
|
||||
|
||||
If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to the
|
||||
maximum size supported by TokenName and NULL must be returned.
|
||||
|
||||
If SizeOfValue is NULL, then ASSERT().
|
||||
If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
|
||||
|
||||
@param[in] TokenNumber The PCD token number to set a current value for.
|
||||
@ -577,6 +576,8 @@ LibPcdSetEx64 (
|
||||
supported by TokenNumber and return NULL to indicate that the set operation
|
||||
was not actually performed.
|
||||
|
||||
If Guid is NULL, then ASSERT().
|
||||
If SizeOfValue is NULL, then ASSERT().
|
||||
If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
|
||||
|
||||
@param[in] Guid Pointer to a 128-bit unique value that
|
||||
@ -731,7 +732,7 @@ LibPcdGetNextToken (
|
||||
|
||||
**/
|
||||
|
||||
CONST GUID*
|
||||
GUID *
|
||||
EFIAPI
|
||||
LibPcdGetNextTokenSpace (
|
||||
IN CONST GUID *Guid
|
||||
|
@ -31,6 +31,8 @@ LibPcdSetSku (
|
||||
IN UINTN SkuId
|
||||
)
|
||||
{
|
||||
ASSERT (SkuId < 0x100);
|
||||
|
||||
return SkuId;
|
||||
}
|
||||
|
||||
@ -633,6 +635,8 @@ LibPcdSetExPtr (
|
||||
{
|
||||
ASSERT (Guid != NULL);
|
||||
|
||||
ASSERT (SizeOfBuffer != NULL);
|
||||
|
||||
if (*SizeOfBuffer > 0) {
|
||||
ASSERT (Buffer != NULL);
|
||||
}
|
||||
@ -768,7 +772,7 @@ LibPcdGetNextToken (
|
||||
@retval CONST GUID * The next valid token namespace.
|
||||
|
||||
**/
|
||||
CONST GUID*
|
||||
GUID *
|
||||
EFIAPI
|
||||
LibPcdGetNextTokenSpace (
|
||||
IN CONST GUID *Guid
|
||||
|
@ -57,6 +57,8 @@ LibPcdSetSku (
|
||||
IN UINTN SkuId
|
||||
)
|
||||
{
|
||||
ASSERT (SkuId < 0x100);
|
||||
|
||||
mPcd->SetSku (SkuId);
|
||||
|
||||
return SkuId;
|
||||
@ -728,10 +730,15 @@ LibPcdSetExPtr (
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
|
||||
ASSERT (Guid != NULL);
|
||||
|
||||
ASSERT (SizeOfBuffer != NULL);
|
||||
|
||||
if (*SizeOfBuffer > 0) {
|
||||
ASSERT (Buffer != NULL);
|
||||
}
|
||||
|
||||
|
||||
Size = LibPcdGetExSize (Guid, TokenNumber);
|
||||
if (*SizeOfBuffer > Size) {
|
||||
*SizeOfBuffer = Size;
|
||||
@ -901,7 +908,7 @@ LibPcdGetNextToken (
|
||||
@retval CONST GUID * The next valid token namespace.
|
||||
|
||||
**/
|
||||
CONST GUID*
|
||||
GUID *
|
||||
EFIAPI
|
||||
LibPcdGetNextTokenSpace (
|
||||
IN CONST GUID *Guid
|
||||
@ -913,6 +920,6 @@ LibPcdGetNextTokenSpace (
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Guid;
|
||||
return (GUID *) Guid;
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,8 @@ LibPcdSetSku (
|
||||
)
|
||||
{
|
||||
|
||||
ASSERT (SkuId < 0x100);
|
||||
|
||||
GetPcdPpiPtr()->SetSku (SkuId);;
|
||||
|
||||
return SkuId;
|
||||
@ -586,6 +588,8 @@ LibPcdSetPtr (
|
||||
PCD_PPI *PcdPpi;
|
||||
UINTN Size;
|
||||
|
||||
ASSERT (SizeOfBuffer != NULL);
|
||||
|
||||
if (*SizeOfBuffer > 0) {
|
||||
ASSERT (Buffer != NULL);
|
||||
}
|
||||
@ -999,7 +1003,7 @@ LibPcdGetNextToken (
|
||||
@retval CONST GUID * The next valid token namespace.
|
||||
|
||||
**/
|
||||
CONST GUID*
|
||||
GUID *
|
||||
EFIAPI
|
||||
LibPcdGetNextTokenSpace (
|
||||
IN CONST GUID *Guid
|
||||
@ -1015,6 +1019,6 @@ LibPcdGetNextTokenSpace (
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Guid;
|
||||
return (GUID *)Guid;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ typedef UINT8 SKU_ID;
|
||||
|
||||
typedef struct {
|
||||
UINT32 ExTokenNumber;
|
||||
UINT32 LocalTokenNumber; // PCD Number of this particular platform build
|
||||
UINT16 LocalTokenNumber; // PCD Number of this particular platform build
|
||||
UINT16 ExGuidIndex; // Index of GuidTable
|
||||
} DYNAMICEX_MAPPING;
|
||||
|
||||
|
@ -1008,6 +1008,30 @@ class PcdDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
private int getHiiPtrTypeAlignmentSize(Token token) {
|
||||
switch (token.datumType) {
|
||||
case UINT8:
|
||||
return 1;
|
||||
case UINT16:
|
||||
return 2;
|
||||
case UINT32:
|
||||
return 4;
|
||||
case UINT64:
|
||||
return 8;
|
||||
case POINTER:
|
||||
if (token.isHiiEnable()) {
|
||||
if (token.isHiiDefaultValueUnicodeStringType()) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
case BOOLEAN:
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private int getAlignmentSize (Token token) {
|
||||
if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {
|
||||
return 2;
|
||||
@ -1599,28 +1623,25 @@ class PcdDatabase {
|
||||
privateGlobalName = t.getPrimaryKeyString();
|
||||
}
|
||||
|
||||
if (t.isUnicodeStringType()) {
|
||||
privateGlobalCCode = String.format("%-20s%s[%d];\r\n", "STRING_HEAD", t.getPrimaryKeyString(), t.getSkuIdCount());
|
||||
} else {
|
||||
String type = getCType(t);
|
||||
if (t.datumType == Token.DATUM_TYPE.POINTER) {
|
||||
int bufferSize;
|
||||
if (t.isASCIIStringType()) {
|
||||
//
|
||||
// Build tool will add a NULL string at the end of the ASCII string
|
||||
//
|
||||
bufferSize = t.datumSize + 1;
|
||||
} else {
|
||||
bufferSize = t.datumSize;
|
||||
}
|
||||
privateGlobalCCode = String.format("%-20s%s[%d][%d];\r\n", type, privateGlobalName, t.getSkuIdCount(), bufferSize);
|
||||
String type = getCType(t);
|
||||
if ((t.datumType == Token.DATUM_TYPE.POINTER) && (!t.isHiiEnable())) {
|
||||
int bufferSize;
|
||||
if (t.isASCIIStringType()) {
|
||||
//
|
||||
// Build tool will add a NULL string at the end of the ASCII string
|
||||
//
|
||||
bufferSize = t.datumSize + 1;
|
||||
} else {
|
||||
privateGlobalCCode = String.format("%-20s%s[%d];\r\n", type, privateGlobalName, t.getSkuIdCount());
|
||||
bufferSize = t.datumSize;
|
||||
}
|
||||
privateGlobalCCode = String.format("%-20s%s[%d][%d];\r\n", type, privateGlobalName, t.getSkuIdCount(), bufferSize);
|
||||
} else {
|
||||
privateGlobalCCode = String.format("%-20s%s[%d];\r\n", type, privateGlobalName, t.getSkuIdCount());
|
||||
}
|
||||
}
|
||||
|
||||
private String getDataTypeDeclarationForVariableDefault_new (Token token, String cName, int skuId) {
|
||||
private String getDataTypeDeclarationForVariableDefault_new (Token token, String cName, int skuId)
|
||||
throws EntityException {
|
||||
|
||||
String typeStr;
|
||||
|
||||
@ -1635,9 +1656,27 @@ class PcdDatabase {
|
||||
} else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) {
|
||||
typeStr = "BOOLEAN";
|
||||
} else if (token.datumType == Token.DATUM_TYPE.POINTER) {
|
||||
return String.format("%-20s%s[%d];\r\n", cName, token.datumSize);
|
||||
int size;
|
||||
if (token.isHiiDefaultValueUnicodeStringType()) {
|
||||
typeStr = "UINT16";
|
||||
//
|
||||
// Include the NULL charactor
|
||||
//
|
||||
size = token.datumSize / 2 + 1;
|
||||
} else {
|
||||
typeStr = "UINT8";
|
||||
if (token.isHiiDefaultValueASCIIStringType()) {
|
||||
//
|
||||
// Include the NULL charactor
|
||||
//
|
||||
size = token.datumSize + 1;
|
||||
} else {
|
||||
size = token.datumSize;
|
||||
}
|
||||
}
|
||||
return String.format("%-20s%s[%d];\r\n", typeStr, cName, size);
|
||||
} else {
|
||||
typeStr = "";
|
||||
throw new EntityException("Unknown DATUM_TYPE type in when generating code for VARIABLE_ENABLED PCD entry");
|
||||
}
|
||||
|
||||
return String.format("%-20s%s;\r\n", typeStr, cName);
|
||||
@ -1678,7 +1717,7 @@ class PcdDatabase {
|
||||
s += tab + "{" + newLine;
|
||||
|
||||
for (i = 0; i < t.skuData.size(); i++) {
|
||||
if (t.isUnicodeStringType() && !t.isHiiEnable()) {
|
||||
if (t.isUnicodeStringType()) {
|
||||
s += tab + tab + String.format("{ %d }", stringTable.add(t.skuData.get(i).value.value, t));
|
||||
} else if (t.isHiiEnable()) {
|
||||
/* VPD_HEAD definition
|
||||
@ -1686,6 +1725,7 @@ class PcdDatabase {
|
||||
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
|
||||
UINT16 StringIndex; // Offset in String Table in units of UINT16.
|
||||
UINT16 Offset; // Offset in Variable
|
||||
UINT16 DefaultValueOffset; // Offset of the Default Value
|
||||
} VARIABLE_HEAD ;
|
||||
*/
|
||||
String variableDefaultName = String.format("%s_VariableDefault_%d", t.getPrimaryKeyString(), i);
|
||||
@ -1700,7 +1740,7 @@ class PcdDatabase {
|
||||
// the instantiation for the default value.
|
||||
//
|
||||
CStructTypeDeclaration decl = new CStructTypeDeclaration (variableDefaultName,
|
||||
getDataTypeAlignmentSize(t),
|
||||
getHiiPtrTypeAlignmentSize(t),
|
||||
getDataTypeDeclarationForVariableDefault_new(t, variableDefaultName, i),
|
||||
true
|
||||
);
|
||||
|
@ -587,8 +587,6 @@ public class Token {
|
||||
DynamicTokenValue dynamicData = getDefaultSku();
|
||||
if (hasDefaultValue()) {
|
||||
switch (dynamicData.type) {
|
||||
case HII_TYPE:
|
||||
return dynamicData.hiiDefaultValue;
|
||||
case DEFAULT_TYPE:
|
||||
return dynamicData.value;
|
||||
}
|
||||
@ -626,7 +624,6 @@ public class Token {
|
||||
}
|
||||
|
||||
public boolean isValidNullValue(String judgedValue) {
|
||||
int intValue;
|
||||
String subStr;
|
||||
BigInteger bigIntValue;
|
||||
|
||||
@ -687,7 +684,27 @@ public class Token {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isHiiDefaultValueUnicodeStringType() {
|
||||
DynamicTokenValue dynamicData = getDefaultSku();
|
||||
|
||||
if (dynamicData == null)
|
||||
return false;
|
||||
|
||||
return dynamicData.hiiDefaultValue.startsWith("L\"")
|
||||
&& dynamicData.hiiDefaultValue.endsWith("\"");
|
||||
}
|
||||
|
||||
public boolean isHiiDefaultValueASCIIStringType() {
|
||||
DynamicTokenValue dynamicData = getDefaultSku();
|
||||
|
||||
if (dynamicData == null)
|
||||
return false;
|
||||
|
||||
return dynamicData.hiiDefaultValue.startsWith("\"")
|
||||
&& dynamicData.hiiDefaultValue.endsWith("\"");
|
||||
}
|
||||
|
||||
/**
|
||||
Judege whether current value is UNICODE string type.
|
||||
@return boolean
|
||||
|
Loading…
x
Reference in New Issue
Block a user