diff options
Diffstat (limited to 'EdkModulePkg/Universal/PCD')
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Pcd.c | 33 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Pcd.msa | 11 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Service.c | 61 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Pei/Pcd.c | 13 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Pei/Pcd.msa | 7 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Pei/Service.c | 41 |
6 files changed, 121 insertions, 45 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c index 115b1ac938..437006f05c 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c +++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c @@ -200,9 +200,15 @@ DxePcdGetSize ( //
TmpTokenNumber = TokenNumber;
- ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
-
- IsPeiDb = (BOOLEAN) (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
+
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ IsPeiDb = (BOOLEAN) (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
TokenNumber = IsPeiDb ? TokenNumber :
(TokenNumber - PEI_LOCAL_TOKEN_NUMBER);
@@ -501,25 +507,32 @@ DxePcdGetNextToken ( {
EFI_STATUS Status;
+ if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {
+ return EFI_UNSUPPORTED;
+ }
+
Status = EFI_NOT_FOUND;
//
// Scan the local token space
//
if (Guid == NULL) {
- if (((*TokenNumber > PEI_NEX_TOKEN_NUMBER) && (*TokenNumber < PEI_LOCAL_TOKEN_NUMBER)) ||
- ((*TokenNumber > (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER)))) {
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ if (((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) && (*TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1)) ||
+ ((*TokenNumber + 1 > (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1)))) {
return EFI_NOT_FOUND;
}
(*TokenNumber)++;
- if (*TokenNumber > PEI_NEX_TOKEN_NUMBER &&
- *TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) {
+ if ((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) &&
+ (*TokenNumber <= PEI_LOCAL_TOKEN_NUMBER)) {
//
// The first Non-Ex type Token Number for DXE PCD
// database is PEI_LOCAL_TOKEN_NUMBER
//
*TokenNumber = PEI_LOCAL_TOKEN_NUMBER;
- } else if (*TokenNumber > DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER) {
+ } else if (*TokenNumber + 1 > DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER + 1) {
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;
}
return EFI_SUCCESS;
@@ -618,6 +631,10 @@ DxePcdGetNextTokenSpace ( EFI_GUID **DxeTokenSpaceTable;
BOOLEAN Match;
+ if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {
+ return EFI_UNSUPPORTED;
+ }
+
ASSERT (Guid != NULL);
if (PEI_EXMAP_TABLE_EMPTY && DXE_EXMAP_TABLE_EMPTY) {
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.msa b/EdkModulePkg/Universal/PCD/Dxe/Pcd.msa index e1549ecac3..559a5c9dfc 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.msa +++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.msa @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -61,7 +61,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.--> <Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>DxeRuntimeDriverLib</Keyword>
+ <Keyword>UefiRuntimeServicesTableLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
@@ -106,5 +106,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.--> <HelpText/>
</PcdEntry>
+ <PcdEntry PcdItemType="FEATURE_FLAG">
+ <C_Name>PcdDxePcdDatabaseTraverseEnabled</C_Name>
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText/>
+ </PcdEntry>
</PcdCoded>
-</ModuleSurfaceArea>
\ No newline at end of file +</ModuleSurfaceArea>
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.c b/EdkModulePkg/Universal/PCD/Dxe/Service.c index 613d8c84d1..a2706d0bd3 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Service.c +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.c @@ -61,12 +61,20 @@ GetWorker ( TmpTokenNumber = TokenNumber;
- ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
+ //
+ // PCD_TOTAL_TOKEN_NUMBER is a auto-generated constant.
+ // It could be zero. EBC compiler is very choosy. It may
+ // report warning. So we add 1 in each size of the
+ // comparison.
+ //
+ ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
ASSERT ((GetSize == DxePcdGetSize (TokenNumber + 1)) || (GetSize == 0));
-
- IsPeiDb = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ IsPeiDb = (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE;
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
@@ -362,11 +370,12 @@ BuildPcdDxeDataBase ( // Initialized the Callback Function Table
//
- if (PCD_TOTAL_TOKEN_NUMBER != 0) {
- mCallbackFnTable = AllocateZeroPool (PCD_TOTAL_TOKEN_NUMBER * sizeof (LIST_ENTRY));
- }
+ mCallbackFnTable = AllocateZeroPool (PCD_TOTAL_TOKEN_NUMBER * sizeof (LIST_ENTRY));
- for (Idx = 0; Idx < PCD_TOTAL_TOKEN_NUMBER; Idx++) {
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ for (Idx = 0; Idx + 1 < PCD_TOTAL_TOKEN_NUMBER + 1; Idx++) {
InitializeListHead (&mCallbackFnTable[Idx]);
}
@@ -390,7 +399,7 @@ GetHiiVariable ( Size = 0;
Buffer = NULL;
- Status = EfiGetVariable (
+ Status = gRT->GetVariable (
(UINT16 *)VariableName,
VariableGuid,
NULL,
@@ -403,7 +412,7 @@ GetHiiVariable ( ASSERT (Buffer != NULL);
- Status = EfiGetVariable (
+ Status = gRT->GetVariable (
VariableName,
VariableGuid,
NULL,
@@ -566,19 +575,29 @@ SetWorker ( TmpTokenNumber = TokenNumber;
- ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+
+ ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
if (!PtrType) {
ASSERT (*Size == DxePcdGetSize (TokenNumber + 1));
}
- IsPeiDb = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ IsPeiDb = (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE;
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
- if ((TokenNumber < PEI_NEX_TOKEN_NUMBER) ||
- (TokenNumber >= PEI_LOCAL_TOKEN_NUMBER || TokenNumber < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER))) {
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ if ((TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) ||
+ (TokenNumber + 1 >= PEI_LOCAL_TOKEN_NUMBER + 1 || TokenNumber + 1 < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1))) {
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
}
@@ -755,7 +774,7 @@ SetHiiVariable ( Size = 0;
- Status = EfiGetVariable (
+ Status = gRT->GetVariable (
(UINT16 *)VariableName,
VariableGuid,
&Attribute,
@@ -769,7 +788,7 @@ SetHiiVariable ( ASSERT (Buffer != NULL);
- Status = EfiGetVariable (
+ Status = gRT->GetVariable (
VariableName,
VariableGuid,
&Attribute,
@@ -781,7 +800,7 @@ SetHiiVariable ( CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
- Status = EfiSetVariable (
+ Status = gRT->SetVariable (
VariableName,
VariableGuid,
Attribute,
@@ -983,7 +1002,10 @@ GetPtrTypeSize ( BOOLEAN IsPeiDb;
UINT32 *LocalTokenNumberTable;
- IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx < PEI_LOCAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
if (IsPeiDb) {
@@ -1055,7 +1077,10 @@ SetPtrTypeSize ( BOOLEAN IsPeiDb;
UINT32 *LocalTokenNumberTable;
- IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx < PEI_LOCAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
if (IsPeiDb) {
LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;
diff --git a/EdkModulePkg/Universal/PCD/Pei/Pcd.c b/EdkModulePkg/Universal/PCD/Pei/Pcd.c index 4ae4b27ef4..fe2fa85f44 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Pcd.c +++ b/EdkModulePkg/Universal/PCD/Pei/Pcd.c @@ -182,7 +182,10 @@ PeiPcdGetSize ( //
TokenNumber--;
- ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
Size = (PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
@@ -479,6 +482,10 @@ PeiPcdGetNextToken ( UINTN i;
BOOLEAN Found;
+ if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled)) {
+ return EFI_UNSUPPORTED;
+ }
+
if (Guid == NULL) {
if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {
return EFI_NOT_FOUND;
@@ -570,6 +577,10 @@ PeiPcdGetNextTokenSpace ( UINTN i;
BOOLEAN Found;
+ if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled)) {
+ return EFI_UNSUPPORTED;
+ }
+
ASSERT (Guid != NULL);
if (PEI_EXMAP_TABLE_EMPTY) {
diff --git a/EdkModulePkg/Universal/PCD/Pei/Pcd.msa b/EdkModulePkg/Universal/PCD/Pei/Pcd.msa index 14454323df..54acd91561 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Pcd.msa +++ b/EdkModulePkg/Universal/PCD/Pei/Pcd.msa @@ -103,5 +103,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.--> <HelpText/>
</PcdEntry>
+ <PcdEntry PcdItemType="FEATURE_FLAG">
+ <C_Name>PcdPeiPcdDatabaseTraverseEnabled</C_Name>
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText/>
+ </PcdEntry>
</PcdCoded>
-</ModuleSurfaceArea>
\ No newline at end of file +</ModuleSurfaceArea>
diff --git a/EdkModulePkg/Universal/PCD/Pei/Service.c b/EdkModulePkg/Universal/PCD/Pei/Service.c index 0004bc6c76..7b13dc2fa0 100644 --- a/EdkModulePkg/Universal/PCD/Pei/Service.c +++ b/EdkModulePkg/Universal/PCD/Pei/Service.c @@ -52,7 +52,7 @@ PeiRegisterCallBackWorker ( // as the array index.
//
TokenNumber--;
- ASSERT (TokenNumber < PEI_NEX_TOKEN_NUMBER);
+ ASSERT (TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1);
} else {
TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
@@ -62,7 +62,10 @@ PeiRegisterCallBackWorker ( // as the array index.
//
TokenNumber--;
- ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
}
@@ -230,19 +233,19 @@ GetSkuEnabledTokenNumber ( switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
case PCD_TYPE_VPD:
Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);
- return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_VPD);
+ return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_VPD);
case PCD_TYPE_HII:
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[i]);
- return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);
+ return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);
case PCD_TYPE_STRING:
Value = (UINT8 *) &(((STRING_HEAD *) Value)[i]);
- return ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);
+ return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);
case PCD_TYPE_DATA:
Value += Size * i;
- return (Value - (UINT8 *) PeiPcdDb);
+ return (UINT32) (Value - (UINT8 *) PeiPcdDb);
default:
ASSERT (FALSE);
@@ -259,7 +262,7 @@ GetSkuEnabledTokenNumber ( VOID
InvokeCallbackOnSet (
- UINT32 ExTokenNumber,
+ UINTN ExTokenNumber,
CONST EFI_GUID *Guid, OPTIONAL
UINTN TokenNumber,
VOID *Data,
@@ -277,8 +280,12 @@ InvokeCallbackOnSet ( //
TokenNumber--;
- if (Guid == NULL)
- ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
+ if (Guid == NULL) {
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
+ }
GuidHob = GetFirstGuidHob (&gPcdPeiCallbackFnTableHobGuid);
ASSERT (GuidHob != NULL);
@@ -335,7 +342,10 @@ SetWorker ( //
TokenNumber--;
- ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
PeiPcdDb = GetPcdDatabase ();
@@ -350,7 +360,7 @@ SetWorker ( // For Dynamic EX PCD entry, we have invoked the callback function for Dynamic EX
// type PCD entry in ExSetWorker.
//
- if (TokenNumber < PEI_NEX_TOKEN_NUMBER) {
+ if (TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) {
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
}
@@ -500,7 +510,10 @@ GetWorker ( //
TokenNumber--;
- ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
+ // EBC compiler is very choosy. It may report warning about comparison
+ // between UINTN and 0 . So we add 1 in each size of the
+ // comparison.
+ ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));
@@ -525,7 +538,7 @@ GetWorker ( {
VPD_HEAD *VpdHead;
VpdHead = (VPD_HEAD *) ((UINT8 *)PeiPcdDb + Offset);
- return (VOID *) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
+ return (VOID *) (UINTN) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
}
case PCD_TYPE_HII:
@@ -570,7 +583,7 @@ GetWorker ( UINTN
GetExPcdTokenNumber (
IN CONST EFI_GUID *Guid,
- IN UINT32 ExTokenNumber
+ IN UINTN ExTokenNumber
)
{
UINT32 i;
|