MdePkg and MdeModulePkg Pcd: Add the new EFI_GET_PCD_INFO_PROTOCOL and EFI_GET_PCD_INFO_PPI support for PI 1.2.1 compliance.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14866 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Star Zeng 2013-11-20 00:44:25 +00:00 committed by lzeng14
parent 14b5e3fd78
commit 96d6d004aa
21 changed files with 1833 additions and 84 deletions

View File

@ -376,6 +376,12 @@
gEdkiiFormBrowserEx2ProtocolGuid = { 0xa770c357, 0xb693, 0x4e6d, { 0xa6, 0xcf, 0xd2, 0x1c, 0x72, 0x8e, 0x55, 0xb } }
[PcdsFeatureFlag]
## Indicates if the Pcd Info Ppi and Protocol should be produced.<BR><BR>
# It can be disabled to save size.<BR><BR>
# TRUE - Pcd Info Ppi and Protocol will be produced.<BR>
# FALSE - Pcd Info Ppi and Protocol will not be produced.<BR>
gEfiMdeModulePkgTokenSpaceGuid.PcdPcdInfoGeneration|TRUE|BOOLEAN|0x0001001C
## Indicate whether platform can support update capsule across a system reset
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|FALSE|BOOLEAN|0x0001001d

View File

@ -89,6 +89,25 @@ EFI_PCD_PROTOCOL mEfiPcdInstance = {
DxePcdGetNextTokenSpace
};
///
/// Instance of GET_PCD_INFO_PROTOCOL protocol is EDKII native implementation.
/// This protocol instance support dynamic and dynamicEx type PCDs.
///
GET_PCD_INFO_PROTOCOL mGetPcdInfoInstance = {
DxeGetPcdInfoGetInfo,
DxeGetPcdInfoGetInfoEx,
DxeGetPcdInfoGetSku
};
///
/// Instance of EFI_GET_PCD_INFO_PROTOCOL which is defined in PI 1.2.1 Vol 3.
/// This PPI instance only support dyanmicEx type PCD.
///
EFI_GET_PCD_INFO_PROTOCOL mEfiGetPcdInfoInstance = {
DxeGetPcdInfoGetInfoEx,
DxeGetPcdInfoGetSku
};
EFI_HANDLE mPcdHandle = NULL;
/**
@ -129,11 +148,90 @@ PcdDxeInit (
&gEfiPcdProtocolGuid, &mEfiPcdInstance,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
if (FeaturePcdGet (PcdPcdInfoGeneration) && mPcdDatabase.DxeDb->PcdNameTableOffset != 0) {
//
// Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD
// Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD
//
Status = gBS->InstallMultipleProtocolInterfaces (
&mPcdHandle,
&gGetPcdInfoProtocolGuid, &mGetPcdInfoInstance,
&gEfiGetPcdInfoProtocolGuid, &mEfiGetPcdInfoInstance,
NULL
);
ASSERT_EFI_ERROR (Status);
}
return Status;
}
/**
Retrieve additional information associated with a PCD token in the default token space.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
DxeGetPcdInfoGetInfo (
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
return DxeGetPcdInfo (NULL, TokenNumber, PcdInfo);
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
DxeGetPcdInfoGetInfoEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
return DxeGetPcdInfo (Guid, TokenNumber, PcdInfo);
}
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
DxeGetPcdInfoGetSku (
VOID
)
{
if (!FeaturePcdGet (PcdPcdInfoGeneration)) {
return EFI_UNSUPPORTED;
}
return mPcdDatabase.PeiDb->SystemSkuId;
}
/**

View File

@ -335,9 +335,12 @@
[Protocols]
gPcdProtocolGuid ## PRODUCES
gEfiPcdProtocolGuid ## PRODUCES
gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES
gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPcdInfoGeneration
[Depex]
TRUE

View File

@ -35,6 +35,317 @@ LIST_ENTRY *mCallbackFnTable;
EFI_GUID **TmpTokenSpaceBuffer;
UINTN TmpTokenSpaceBufferCount;
/**
Get Local Token Number by Token Number.
@param[in] IsPeiDb If TRUE, the pcd entry is initialized in PEI phase,
If FALSE, the pcd entry is initialized in DXE phase.
@param[in] TokenNumber The PCD token number.
@return Local Token Number.
**/
UINT32
GetLocalTokenNumber (
IN BOOLEAN IsPeiDb,
IN UINTN TokenNumber
)
{
UINT32 *LocalTokenNumberTable;
UINT32 LocalTokenNumber;
UINTN Size;
UINTN MaxSize;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) :
(UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
TokenNumber = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount;
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
Size = (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (Size == 0) {
GetPtrTypeSize (TokenNumber, &MaxSize);
} else {
MaxSize = Size;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);
}
return LocalTokenNumber;
}
/**
Get PCD type by Local Token Number.
@param[in] LocalTokenNumber The PCD local token number.
@return PCD type.
**/
EFI_PCD_TYPE
GetPcdType (
IN UINT32 LocalTokenNumber
)
{
switch (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) {
case PCD_DATUM_TYPE_POINTER:
return EFI_PCD_TYPE_PTR;
case PCD_DATUM_TYPE_UINT8:
if (LocalTokenNumber & PCD_DATUM_TYPE_UINT8_BOOLEAN) {
return EFI_PCD_TYPE_BOOL;
} else {
return EFI_PCD_TYPE_8;
}
case PCD_DATUM_TYPE_UINT16:
return EFI_PCD_TYPE_16;
case PCD_DATUM_TYPE_UINT32:
return EFI_PCD_TYPE_32;
case PCD_DATUM_TYPE_UINT64:
return EFI_PCD_TYPE_64;
default:
ASSERT (FALSE);
return EFI_PCD_TYPE_8;
}
}
/**
Get PCD name.
@param[in] OnlyTokenSpaceName If TRUE, only need to get the TokenSpaceCName.
If FALSE, need to get the full PCD name.
@param[in] IsPeiDb If TRUE, the pcd entry is initialized in PEI phase,
If FALSE, the pcd entry is initialized in DXE phase.
@param[in] TokenNumber The PCD token number.
@return The TokenSpaceCName or full PCD name.
**/
CHAR8 *
GetPcdName (
IN BOOLEAN OnlyTokenSpaceName,
IN BOOLEAN IsPeiDb,
IN UINTN TokenNumber
)
{
PCD_DATABASE_INIT *Database;
UINT8 *StringTable;
PCD_NAME_INDEX *PcdNameIndex;
CHAR8 *TokenSpaceName;
CHAR8 *PcdName;
CHAR8 *Name;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
Database = IsPeiDb ? mPcdDatabase.PeiDb: mPcdDatabase.DxeDb;
TokenNumber = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount;
StringTable = (UINT8 *) Database + Database->StringTableOffset;
//
// Get the PCD name index.
//
PcdNameIndex = (PCD_NAME_INDEX *)((UINT8 *) Database + Database->PcdNameTableOffset) + TokenNumber;
TokenSpaceName = (CHAR8 *)&StringTable[PcdNameIndex->TokenSpaceCNameIndex];
PcdName = (CHAR8 *)&StringTable[PcdNameIndex->PcdCNameIndex];
if (OnlyTokenSpaceName) {
//
// Only need to get the TokenSpaceCName.
//
Name = AllocateCopyPool (AsciiStrSize (TokenSpaceName), TokenSpaceName);
} else {
//
// Need to get the full PCD name.
//
Name = AllocateZeroPool (AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName));
//
// Catenate TokenSpaceCName and PcdCName with a '.' to form the full PCD name.
//
AsciiStrCat (Name, TokenSpaceName);
Name[AsciiStrSize (TokenSpaceName) - sizeof (CHAR8)] = '.';
AsciiStrCat (Name, PcdName);
}
return Name;
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] IsPeiDb If TRUE, the pcd entry is initialized in PEI phase,
If FALSE, the pcd entry is initialized in DXE phase.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
ExGetPcdInfo (
IN BOOLEAN IsPeiDb,
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
PCD_DATABASE_INIT *Database;
UINTN GuidTableIdx;
EFI_GUID *MatchGuid;
EFI_GUID *GuidTable;
DYNAMICEX_MAPPING *ExMapTable;
UINTN Index;
UINT32 LocalTokenNumber;
Database = IsPeiDb ? mPcdDatabase.PeiDb: mPcdDatabase.DxeDb;
GuidTable = (EFI_GUID *)((UINT8 *)Database + Database->GuidTableOffset);
MatchGuid = ScanGuid (GuidTable, Database->GuidTableCount * sizeof(EFI_GUID), Guid);
if (MatchGuid == NULL) {
return EFI_NOT_FOUND;
}
GuidTableIdx = MatchGuid - GuidTable;
ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)Database + Database->ExMapTableOffset);
//
// Find the PCD by GuidTableIdx and ExTokenNumber in ExMapTable.
//
for (Index = 0; Index < Database->ExTokenCount; Index++) {
if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
//
// TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,
// PcdSize to 0 and PcdName to the null-terminated ASCII string
// associated with the token's namespace Guid.
//
PcdInfo->PcdType = EFI_PCD_TYPE_8;
PcdInfo->PcdSize = 0;
//
// Here use one representative in the token space to get the TokenSpaceCName.
//
PcdInfo->PcdName = GetPcdName (TRUE, IsPeiDb, ExMapTable[Index].TokenNumber);
return EFI_SUCCESS;
} else if (ExMapTable[Index].ExTokenNumber == TokenNumber) {
PcdInfo->PcdSize = DxePcdGetSize (ExMapTable[Index].TokenNumber);
LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, ExMapTable[Index].TokenNumber);
PcdInfo->PcdType = GetPcdType (LocalTokenNumber);
PcdInfo->PcdName = GetPcdName (FALSE, IsPeiDb, ExMapTable[Index].TokenNumber);
return EFI_SUCCESS;
}
}
}
return EFI_NOT_FOUND;
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
DxeGetPcdInfo (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
EFI_STATUS Status;
BOOLEAN PeiExMapTableEmpty;
BOOLEAN DxeExMapTableEmpty;
UINT32 LocalTokenNumber;
BOOLEAN IsPeiDb;
if (!FeaturePcdGet (PcdPcdInfoGeneration)) {
return EFI_UNSUPPORTED;
}
ASSERT (PcdInfo != NULL);
Status = EFI_NOT_FOUND;
PeiExMapTableEmpty = mPeiExMapTableEmpty;
DxeExMapTableEmpty = mDxeExMapTableEmpty;
if (Guid == NULL) {
if (((TokenNumber + 1 > mPeiNexTokenCount + 1) && (TokenNumber + 1 <= mPeiLocalTokenCount + 1)) ||
((TokenNumber + 1 > (mPeiLocalTokenCount + mDxeNexTokenCount + 1)))) {
return EFI_NOT_FOUND;
} else if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
//
// TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,
// PcdSize to 0 and PcdName to NULL for default Token Space.
//
PcdInfo->PcdType = EFI_PCD_TYPE_8;
PcdInfo->PcdSize = 0;
PcdInfo->PcdName = NULL;
} else {
PcdInfo->PcdSize = DxePcdGetSize (TokenNumber);
IsPeiDb = FALSE;
if ((TokenNumber + 1 <= mPeiNexTokenCount + 1)) {
IsPeiDb = TRUE;
}
LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, TokenNumber);
PcdInfo->PcdType = GetPcdType (LocalTokenNumber);
PcdInfo->PcdName = GetPcdName (FALSE, IsPeiDb, TokenNumber);
}
return EFI_SUCCESS;
}
if (PeiExMapTableEmpty && DxeExMapTableEmpty) {
return EFI_NOT_FOUND;
}
if (!PeiExMapTableEmpty) {
Status = ExGetPcdInfo (
TRUE,
Guid,
TokenNumber,
PcdInfo
);
}
if (Status == EFI_SUCCESS) {
return Status;
}
if (!DxeExMapTableEmpty) {
Status = ExGetPcdInfo (
FALSE,
Guid,
TokenNumber,
PcdInfo
);
}
return Status;
}
/**
Get the PCD entry pointer in PCD database.
@ -56,7 +367,6 @@ GetWorker (
IN UINTN GetSize
)
{
UINT32 *LocalTokenNumberTable;
EFI_GUID *GuidTable;
UINT8 *StringTable;
EFI_GUID *Guid;
@ -67,7 +377,6 @@ GetWorker (
VPD_HEAD *VpdHead;
UINT8 *PcdDb;
VOID *RetPtr;
UINTN MaxSize;
UINTN TmpTokenNumber;
UINTN DataSize;
EFI_STATUS Status;
@ -107,22 +416,7 @@ GetWorker (
// comparison.
IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);
LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) :
(UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
TokenNumber = IsPeiDb ? TokenNumber :
TokenNumber - mPeiLocalTokenCount;
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (GetSize == 0) {
GetPtrTypeSize (TmpTokenNumber, &MaxSize);
} else {
MaxSize = GetSize;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);
}
LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, TokenNumber + 1);
PcdDb = IsPeiDb ? ((UINT8 *) mPcdDatabase.PeiDb) : ((UINT8 *) mPcdDatabase.DxeDb);
@ -792,7 +1086,6 @@ SetWorker (
IN BOOLEAN PtrType
)
{
UINT32 *LocalTokenNumberTable;
BOOLEAN IsPeiDb;
UINT32 LocalTokenNumber;
EFI_GUID *GuidTable;
@ -861,22 +1154,7 @@ SetWorker (
//
IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);
LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) :
(UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset) ;
TokenNumber = IsPeiDb ? TokenNumber
: TokenNumber - mPeiLocalTokenCount;
LocalTokenNumber = LocalTokenNumberTable[TokenNumber];
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (PtrType) {
GetPtrTypeSize (TmpTokenNumber, &MaxSize);
} else {
MaxSize = *Size;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);
}
LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, TokenNumber + 1);
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;

View File

@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/PcdDataBaseSignatureGuid.h>
#include <Protocol/Pcd.h>
#include <Protocol/PiPcd.h>
#include <Protocol/PcdInfo.h>
#include <Protocol/PiPcdInfo.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
@ -44,6 +46,61 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#error "Please make sure the version of PCD DXE Service and the generated PCD DXE Database match."
#endif
/**
Retrieve additional information associated with a PCD token in the default token space.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
DxeGetPcdInfoGetInfo (
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
DxeGetPcdInfoGetInfoEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
DxeGetPcdInfoGetSku (
VOID
);
//
// Protocol Interface function declaration.
//
@ -757,6 +814,27 @@ typedef struct {
// Internal Functions
//
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
DxeGetPcdInfo (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Wrapper function for setting non-pointer type value for a PCD entry.

View File

@ -83,6 +83,25 @@ EFI_PEI_PCD_PPI mEfiPcdPpiInstance = {
PeiPcdGetNextTokenSpace
};
///
/// Instance of GET_PCD_INFO_PPI protocol is EDKII native implementation.
/// This protocol instance support dynamic and dynamicEx type PCDs.
///
GET_PCD_INFO_PPI mGetPcdInfoInstance = {
PeiGetPcdInfoGetInfo,
PeiGetPcdInfoGetInfoEx,
PeiGetPcdInfoGetSku
};
///
/// Instance of EFI_GET_PCD_INFO_PPI which is defined in PI 1.2.1 Vol 3.
/// This PPI instance only support dyanmicEx type PCD.
///
EFI_GET_PCD_INFO_PPI mEfiGetPcdInfoInstance = {
PeiGetPcdInfoGetInfoEx,
PeiGetPcdInfoGetSku
};
EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI,
@ -96,6 +115,19 @@ EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {
}
};
EFI_PEI_PPI_DESCRIPTOR mPpiList2[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI,
&gGetPcdInfoPpiGuid,
&mGetPcdInfoInstance
},
{
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiGetPcdInfoPpiGuid,
&mEfiGetPcdInfoInstance
}
};
/**
Main entry for PCD PEIM driver.
@ -114,19 +146,98 @@ PcdPeimInit (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
BuildPcdDatabase (FileHandle);
EFI_STATUS Status;
PEI_PCD_DATABASE *DataBase;
DataBase = BuildPcdDatabase (FileHandle);
//
// Install PCD_PPI and EFI_PEI_PCD_PPI.
//
Status = PeiServicesInstallPpi (&mPpiList[0]);
ASSERT_EFI_ERROR (Status);
//
// Only install PcdInfo PPI when the feature is enabled and PCD info content is present.
//
if (FeaturePcdGet (PcdPcdInfoGeneration) && (DataBase->PcdNameTableOffset != 0)) {
//
// Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
//
Status = PeiServicesInstallPpi (&mPpiList2[0]);
ASSERT_EFI_ERROR (Status);
}
return Status;
}
/**
Retrieve additional information associated with a PCD token in the default token space.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
PeiGetPcdInfoGetInfo (
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
return PeiGetPcdInfo (NULL, TokenNumber, PcdInfo);
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
PeiGetPcdInfoGetInfoEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
return PeiGetPcdInfo (Guid, TokenNumber, PcdInfo);
}
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
PeiGetPcdInfoGetSku (
VOID
)
{
if (!FeaturePcdGet (PcdPcdInfoGeneration)) {
return EFI_UNSUPPORTED;
}
return GetPcdDatabase()->SystemSkuId;
}
/**
Sets the SKU value for subsequent calls to set or get PCD token values.

View File

@ -322,6 +322,7 @@
BaseLib
PeimEntryPoint
DebugLib
MemoryAllocationLib
[Guids]
## PRODUCES ## HOB
@ -333,13 +334,16 @@
gEfiPeiReadOnlyVariable2PpiGuid ## SOMETIMES_CONSUMES
gPcdPpiGuid ## PRODUCES
gEfiPeiPcdPpiGuid ## PRODUCES
gGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES
gEfiGetPcdInfoPpiGuid ## SOMETIMES_PRODUCES
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry || gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPcdInfoGeneration
[Depex]
TRUE

View File

@ -15,6 +15,284 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Service.h"
/**
Get Local Token Number by Token Number.
@param[in] Database PCD database.
@param[in] TokenNumber The PCD token number.
@return Local Token Number.
**/
UINT32
GetLocalTokenNumber (
IN PEI_PCD_DATABASE *Database,
IN UINTN TokenNumber
)
{
UINT32 LocalTokenNumber;
UINTN Size;
UINTN MaxSize;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + TokenNumber);
Size = (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (Size == 0) {
GetPtrTypeSize (TokenNumber, &MaxSize, Database);
} else {
MaxSize = Size;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);
}
return LocalTokenNumber;
}
/**
Get PCD type by Local Token Number.
@param[in] LocalTokenNumber The PCD local token number.
@return PCD type.
**/
EFI_PCD_TYPE
GetPcdType (
IN UINT32 LocalTokenNumber
)
{
switch (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) {
case PCD_DATUM_TYPE_POINTER:
return EFI_PCD_TYPE_PTR;
case PCD_DATUM_TYPE_UINT8:
if (LocalTokenNumber & PCD_DATUM_TYPE_UINT8_BOOLEAN) {
return EFI_PCD_TYPE_BOOL;
} else {
return EFI_PCD_TYPE_8;
}
case PCD_DATUM_TYPE_UINT16:
return EFI_PCD_TYPE_16;
case PCD_DATUM_TYPE_UINT32:
return EFI_PCD_TYPE_32;
case PCD_DATUM_TYPE_UINT64:
return EFI_PCD_TYPE_64;
default:
ASSERT (FALSE);
return EFI_PCD_TYPE_8;
}
}
/**
Get PCD name.
@param[in] OnlyTokenSpaceName If TRUE, only need to get the TokenSpaceCName.
If FALSE, need to get the full PCD name.
@param[in] Database PCD database.
@param[in] TokenNumber The PCD token number.
@return The TokenSpaceCName or full PCD name.
**/
CHAR8 *
GetPcdName (
IN BOOLEAN OnlyTokenSpaceName,
IN PEI_PCD_DATABASE *Database,
IN UINTN TokenNumber
)
{
UINT8 *StringTable;
PCD_NAME_INDEX *PcdNameIndex;
CHAR8 *TokenSpaceName;
CHAR8 *PcdName;
CHAR8 *Name;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
StringTable = (UINT8 *) Database + Database->StringTableOffset;
//
// Get the PCD name index.
//
PcdNameIndex = (PCD_NAME_INDEX *)((UINT8 *) Database + Database->PcdNameTableOffset) + TokenNumber;
TokenSpaceName = (CHAR8 *)&StringTable[PcdNameIndex->TokenSpaceCNameIndex];
PcdName = (CHAR8 *)&StringTable[PcdNameIndex->PcdCNameIndex];
if (OnlyTokenSpaceName) {
//
// Only need to get the TokenSpaceCName.
//
Name = AllocateCopyPool (AsciiStrSize (TokenSpaceName), TokenSpaceName);
} else {
//
// Need to get the full PCD name.
//
Name = AllocateZeroPool (AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName));
//
// Catenate TokenSpaceCName and PcdCName with a '.' to form the full PCD name.
//
AsciiStrCat (Name, TokenSpaceName);
Name[AsciiStrSize (TokenSpaceName) - sizeof (CHAR8)] = '.';
AsciiStrCat (Name, PcdName);
}
return Name;
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Database PCD database.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
ExGetPcdInfo (
IN PEI_PCD_DATABASE *Database,
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
UINTN GuidTableIdx;
EFI_GUID *MatchGuid;
EFI_GUID *GuidTable;
DYNAMICEX_MAPPING *ExMapTable;
UINTN Index;
UINT32 LocalTokenNumber;
GuidTable = (EFI_GUID *)((UINT8 *)Database + Database->GuidTableOffset);
MatchGuid = ScanGuid (GuidTable, Database->GuidTableCount * sizeof(EFI_GUID), Guid);
if (MatchGuid == NULL) {
return EFI_NOT_FOUND;
}
GuidTableIdx = MatchGuid - GuidTable;
ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)Database + Database->ExMapTableOffset);
//
// Find the PCD by GuidTableIdx and ExTokenNumber in ExMapTable.
//
for (Index = 0; Index < Database->ExTokenCount; Index++) {
if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
//
// TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,
// PcdSize to 0 and PcdName to the null-terminated ASCII string
// associated with the token's namespace Guid.
//
PcdInfo->PcdType = EFI_PCD_TYPE_8;
PcdInfo->PcdSize = 0;
//
// Here use one representative in the token space to get the TokenSpaceCName.
//
PcdInfo->PcdName = GetPcdName (TRUE, Database, ExMapTable[Index].TokenNumber);
return EFI_SUCCESS;
} else if (ExMapTable[Index].ExTokenNumber == TokenNumber) {
PcdInfo->PcdSize = PeiPcdGetSize (ExMapTable[Index].TokenNumber);
LocalTokenNumber = GetLocalTokenNumber (Database, ExMapTable[Index].TokenNumber);
PcdInfo->PcdType = GetPcdType (LocalTokenNumber);
PcdInfo->PcdName = GetPcdName (FALSE, Database, ExMapTable[Index].TokenNumber);
return EFI_SUCCESS;
}
}
}
return EFI_NOT_FOUND;
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
PeiGetPcdInfo (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
)
{
PEI_PCD_DATABASE *PeiPcdDb;
BOOLEAN PeiExMapTableEmpty;
UINTN PeiNexTokenNumber;
UINT32 LocalTokenNumber;
if (!FeaturePcdGet (PcdPcdInfoGeneration)) {
return EFI_UNSUPPORTED;
}
ASSERT (PcdInfo != NULL);
PeiPcdDb = GetPcdDatabase ();
PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;
if (PeiPcdDb->ExTokenCount == 0) {
PeiExMapTableEmpty = TRUE;
} else {
PeiExMapTableEmpty = FALSE;
}
if (Guid == NULL) {
if (TokenNumber > PeiNexTokenNumber) {
return EFI_NOT_FOUND;
} else if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
//
// TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,
// PcdSize to 0 and PcdName to NULL for default Token Space.
//
PcdInfo->PcdType = EFI_PCD_TYPE_8;
PcdInfo->PcdSize = 0;
PcdInfo->PcdName = NULL;
} else {
PcdInfo->PcdSize = PeiPcdGetSize (TokenNumber);
LocalTokenNumber = GetLocalTokenNumber (PeiPcdDb, TokenNumber);
PcdInfo->PcdType = GetPcdType (LocalTokenNumber);
PcdInfo->PcdName = GetPcdName (FALSE, PeiPcdDb, TokenNumber);
}
return EFI_SUCCESS;
} else {
if (PeiExMapTableEmpty) {
return EFI_NOT_FOUND;
}
return ExGetPcdInfo (
PeiPcdDb,
Guid,
TokenNumber,
PcdInfo
);
}
}
/**
The function registers the CallBackOnSet fucntion
according to TokenNumber and EFI_GUID space.
@ -150,8 +428,9 @@ LocateExPcdBinary (
@param FileHandle Handle of the file the external PCD database binary located.
@return Pointer to PCD database.
**/
VOID
PEI_PCD_DATABASE *
BuildPcdDatabase (
IN EFI_PEI_FILE_HANDLE FileHandle
)
@ -182,6 +461,8 @@ BuildPcdDatabase (
CallbackFnTable = BuildGuidHob (&gEfiCallerIdGuid, SizeOfCallbackFnTable);
ZeroMem (CallbackFnTable, SizeOfCallbackFnTable);
return Database;
}
/**
@ -462,8 +743,6 @@ SetWorker (
// comparison.
ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);
if (PtrType) {
//
// Get MaxSize first, then check new size with max buffer size.
@ -489,14 +768,7 @@ SetWorker (
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
}
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (PtrType) {
GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
} else {
MaxSize = *Size;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);
}
LocalTokenNumber = GetLocalTokenNumber (PeiPcdDb, TokenNumber + 1);
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
InternalData = (VOID *) ((UINT8 *) PeiPcdDb + Offset);
@ -677,7 +949,6 @@ GetWorker (
STRING_HEAD StringTableIdx;
PEI_PCD_DATABASE *PeiPcdDb;
UINT32 LocalTokenNumber;
UINTN MaxSize;
UINT32 LocalTokenCount;
//
@ -697,16 +968,7 @@ GetWorker (
ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));
LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
if (GetSize == 0) {
GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
} else {
MaxSize = GetSize;
}
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);
}
LocalTokenNumber = GetLocalTokenNumber (PeiPcdDb, TokenNumber + 1);
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
StringTable = (UINT8 *)PeiPcdDb + PeiPcdDb->StringTableOffset;

View File

@ -19,6 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Ppi/ReadOnlyVariable2.h>
#include <Ppi/Pcd.h>
#include <Ppi/PiPcd.h>
#include <Ppi/PcdInfo.h>
#include <Ppi/PiPcdInfo.h>
#include <Guid/PcdDataBaseHobGuid.h>
#include <Guid/PcdDataBaseSignatureGuid.h>
#include <Library/DebugLib.h>
@ -28,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/PeiServicesLib.h>
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
//
// Please make sure the PCD Serivce PEIM Version is consistent with
@ -43,6 +45,61 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#error "Please make sure the version of PCD PEIM Service and the generated PCD PEI Database match."
#endif
/**
Retrieve additional information associated with a PCD token in the default token space.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
PeiGetPcdInfoGetInfo (
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully.
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
PeiGetPcdInfoGetInfoEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
PeiGetPcdInfoGetSku (
VOID
);
//
// PPI Interface Implementation Declaration.
//
@ -753,6 +810,27 @@ PeiPcdGetNextTokenSpace (
IN OUT CONST EFI_GUID **Guid
);
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
EFI_STATUS
EFIAPI
PeiGetPcdInfo (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/* Internal Function definitions */
/**
@ -915,6 +993,21 @@ GetExPcdTokenNumber (
IN UINTN ExTokenNumber
);
/**
Find the local token number according to system SKU ID.
@param LocalTokenNumber PCD token number
@param Size The size of PCD entry.
@return Token number according to system SKU ID.
**/
UINT32
GetSkuEnabledTokenNumber (
UINT32 LocalTokenNumber,
UINTN Size
);
/**
The function registers the CallBackOnSet fucntion
according to TokenNumber and EFI_GUID space.
@ -942,8 +1035,10 @@ PeiRegisterCallBackWorker (
@param FileHandle Handle of the file the external PCD database binary located.
@return Pointer to PCD database.
**/
VOID
PEI_PCD_DATABASE *
BuildPcdDatabase (
IN EFI_PEI_FILE_HANDLE FileHandle
);

View File

@ -1516,4 +1516,89 @@ LibPatchPcdSetPtr (
IN CONST VOID *Buffer
);
typedef enum {
PCD_TYPE_8,
PCD_TYPE_16,
PCD_TYPE_32,
PCD_TYPE_64,
PCD_TYPE_BOOL,
PCD_TYPE_PTR
} PCD_TYPE;
typedef struct {
///
/// The returned information associated with the requested TokenNumber. If
/// TokenNumber is 0, then PcdType is set to PCD_TYPE_8.
///
PCD_TYPE PcdType;
///
/// The size of the data in bytes associated with the TokenNumber specified. If
/// TokenNumber is 0, then PcdSize is set 0.
///
UINTN PcdSize;
///
/// The null-terminated ASCII string associated with a given token. If the
/// TokenNumber specified was 0, then this field corresponds to the null-terminated
/// ASCII string associated with the token's namespace Guid. If NULL, there is no
/// name associated with this request.
///
CHAR8 *PcdName;
} PCD_INFO;
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the default token space specified, then ASSERT().
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfo (
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
);
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the token space specified by Guid, then ASSERT().
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfoEx (
IN CONST GUID *Guid,
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
);
/**
Retrieve the currently set SKU Id.
If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
LibPcdGetSku (
VOID
);
#endif

View File

@ -1,7 +1,7 @@
/** @file
Include file matches things in PI for multiple module types.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@ -133,4 +133,33 @@ typedef struct {
UINT64 RegionState;
} EFI_SMRAM_DESCRIPTOR;
typedef enum {
EFI_PCD_TYPE_8,
EFI_PCD_TYPE_16,
EFI_PCD_TYPE_32,
EFI_PCD_TYPE_64,
EFI_PCD_TYPE_BOOL,
EFI_PCD_TYPE_PTR
} EFI_PCD_TYPE;
typedef struct {
///
/// The returned information associated with the requested TokenNumber. If
/// TokenNumber is 0, then PcdType is set to EFI_PCD_TYPE_8.
///
EFI_PCD_TYPE PcdType;
///
/// The size of the data in bytes associated with the TokenNumber specified. If
/// TokenNumber is 0, then PcdSize is set 0.
///
UINTN PcdSize;
///
/// The null-terminated ASCII string associated with a given token. If the
/// TokenNumber specified was 0, then this field corresponds to the null-terminated
/// ASCII string associated with the token's namespace Guid. If NULL, there is no
/// name associated with this request.
///
CHAR8 *PcdName;
} EFI_PCD_INFO;
#endif

View File

@ -0,0 +1,105 @@
/** @file
Native Platform Configuration Database (PCD) INFO PPI
The PPI that provides additional information about items that reside in the PCD database.
Different with the EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 specification,
the native PCD INFO PPI provide interfaces for dynamic and dynamic-ex type PCD.
The interfaces for dynamic type PCD do not require the token space guid as parameter,
but interfaces for dynamic-ex type PCD require token space guid as parameter.
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __PCD_INFO_PPI_H__
#define __PCD_INFO_PPI_H__
extern EFI_GUID gGetPcdInfoPpiGuid;
#define GET_PCD_INFO_PPI_GUID \
{ 0x4d8b155b, 0xc059, 0x4c8f, { 0x89, 0x26, 0x6, 0xfd, 0x43, 0x31, 0xdb, 0x8a } }
///
/// The forward declaration for GET_PCD_INFO_PPI.
///
typedef struct _GET_PCD_INFO_PPI GET_PCD_INFO_PPI;
/**
Retrieve additional information associated with a PCD token in the default token space.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
typedef
EFI_STATUS
(EFIAPI *GET_PCD_INFO_PPI_GET_INFO) (
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
typedef
EFI_STATUS
(EFIAPI *GET_PCD_INFO_PPI_GET_INFO_EX) (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
typedef
UINTN
(EFIAPI *GET_PCD_INFO_PPI_GET_SKU) (
VOID
);
///
/// This is the PCD service to use when querying for some additional data that can be contained in the
/// PCD database.
///
struct _GET_PCD_INFO_PPI {
///
/// Retrieve additional information associated with a PCD.
///
GET_PCD_INFO_PPI_GET_INFO GetInfo;
GET_PCD_INFO_PPI_GET_INFO_EX GetInfoEx;
///
/// Retrieve the currently set SKU Id.
///
GET_PCD_INFO_PPI_GET_SKU GetSku;
};
#endif

View File

@ -0,0 +1,82 @@
/** @file
Platform Configuration Database (PCD) Info Ppi defined in PI 1.2.1 Vol3.
The PPI that provides additional information about items that reside in the PCD database.
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
PI Version 1.2.1 Vol 3.
**/
#ifndef __PI_PCD_INFO_PPI_H__
#define __PI_PCD_INFO_PPI_H__
extern EFI_GUID gEfiGetPcdInfoPpiGuid;
#define EFI_GET_PCD_INFO_PPI_GUID \
{ 0xa60c6b59, 0xe459, 0x425d, { 0x9c, 0x69, 0xb, 0xcc, 0x9c, 0xb2, 0x7d, 0x81 } }
///
/// The forward declaration for EFI_GET_PCD_INFO_PPI.
///
typedef struct _EFI_GET_PCD_INFO_PPI EFI_GET_PCD_INFO_PPI;
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_GET_PCD_INFO_PPI_GET_INFO) (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
typedef
UINTN
(EFIAPI *EFI_GET_PCD_INFO_PPI_GET_SKU) (
VOID
);
///
/// This is the PCD service to use when querying for some additional data that can be contained in the
/// PCD database.
///
struct _EFI_GET_PCD_INFO_PPI {
///
/// Retrieve additional information associated with a PCD.
///
EFI_GET_PCD_INFO_PPI_GET_INFO GetInfo;
///
/// Retrieve the currently set SKU Id.
///
EFI_GET_PCD_INFO_PPI_GET_SKU GetSku;
};
#endif

View File

@ -0,0 +1,105 @@
/** @file
Native Platform Configuration Database (PCD) INFO PROTOCOL.
The protocol that provides additional information about items that reside in the PCD database.
Different with the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 specification,
the native PCD INFO PROTOCOL provide interfaces for dynamic and dynamic-ex type PCD.
The interfaces for dynamic type PCD do not require the token space guid as parameter,
but interfaces for dynamic-ex type PCD require token space guid as parameter.
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __PCD_INFO_H__
#define __PCD_INFO_H__
extern EFI_GUID gGetPcdInfoProtocolGuid;
#define GET_PCD_INFO_PROTOCOL_GUID \
{ 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } }
///
/// The forward declaration for GET_PCD_INFO_PROTOCOL.
///
typedef struct _GET_PCD_INFO_PROTOCOL GET_PCD_INFO_PROTOCOL;
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
typedef
EFI_STATUS
(EFIAPI *GET_PCD_INFO_PROTOCOL_GET_INFO) (
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
typedef
EFI_STATUS
(EFIAPI *GET_PCD_INFO_PROTOCOL_GET_INFO_EX) (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
typedef
UINTN
(EFIAPI *GET_PCD_INFO_PROTOCOL_GET_SKU) (
VOID
);
///
/// This is the PCD service to use when querying for some additional data that can be contained in the
/// PCD database.
///
struct _GET_PCD_INFO_PROTOCOL {
///
/// Retrieve additional information associated with a PCD.
///
GET_PCD_INFO_PROTOCOL_GET_INFO GetInfo;
GET_PCD_INFO_PROTOCOL_GET_INFO_EX GetInfoEx;
///
/// Retrieve the currently set SKU Id.
///
GET_PCD_INFO_PROTOCOL_GET_SKU GetSku;
};
#endif

View File

@ -0,0 +1,83 @@
/** @file
Platform Configuration Database (PCD) Info Protocol defined in PI 1.2.1 Vol3.
The protocol that provides additional information about items that reside in the PCD database.
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
PI Version 1.2.1 Vol 3.
**/
#ifndef __PI_PCD_INFO_H__
#define __PI_PCD_INFO_H__
extern EFI_GUID gEfiGetPcdInfoProtocolGuid;
#define EFI_GET_PCD_INFO_PROTOCOL_GUID \
{ 0xfd0f4478, 0xefd, 0x461d, { 0xba, 0x2d, 0xe5, 0x8c, 0x45, 0xfd, 0x5f, 0x5e } }
///
/// The forward declaration for EFI_GET_PCD_INFO_PROTOCOL.
///
typedef struct _EFI_GET_PCD_INFO_PROTOCOL EFI_GET_PCD_INFO_PROTOCOL;
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
@retval EFI_SUCCESS The PCD information was returned successfully
@retval EFI_NOT_FOUND The PCD service could not find the requested token number.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_GET_PCD_INFO_PROTOCOL_GET_INFO) (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
OUT EFI_PCD_INFO *PcdInfo
);
/**
Retrieve the currently set SKU Id.
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
typedef
UINTN
(EFIAPI *EFI_GET_PCD_INFO_PROTOCOL_GET_SKU) (
VOID
);
///
/// Callers to this protocol must be at a TPL_APPLICATION task priority level.
/// This is the PCD service to use when querying for some additional data that can be contained in the
/// PCD database.
///
struct _EFI_GET_PCD_INFO_PROTOCOL {
///
/// Retrieve additional information associated with a PCD.
///
EFI_GET_PCD_INFO_PROTOCOL_GET_INFO GetInfo;
///
/// Retrieve the currently set SKU Id.
///
EFI_GET_PCD_INFO_PROTOCOL_GET_SKU GetSku;
};
#endif

View File

@ -919,3 +919,69 @@ LibPatchPcdSetPtr (
return (VOID *) Buffer;
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the default token space specified, then ASSERT().
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfo (
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
)
{
ASSERT (FALSE);
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the token space specified by Guid, then ASSERT().
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfoEx (
IN CONST GUID *Guid,
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
)
{
ASSERT (FALSE);
}
/**
Retrieve the currently set SKU Id.
If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
LibPcdGetSku (
VOID
)
{
ASSERT (FALSE);
return 0;
}

View File

@ -18,17 +18,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/Pcd.h>
#include <Protocol/PiPcd.h>
#include <Protocol/PcdInfo.h>
#include <Protocol/PiPcdInfo.h>
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
PCD_PROTOCOL *mPcd = NULL;
EFI_PCD_PROTOCOL *mPiPcd = NULL;
PCD_PROTOCOL *mPcd = NULL;
EFI_PCD_PROTOCOL *mPiPcd = NULL;
GET_PCD_INFO_PROTOCOL *mPcdInfo = NULL;
EFI_GET_PCD_INFO_PROTOCOL *mPiPcdInfo = NULL;
/**
Retrieves the PI PCD protocol from the handle database.
@retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.
**/
EFI_PCD_PROTOCOL *
EFIAPI
@ -52,6 +58,8 @@ GetPiPcdProtocol (
/**
Retrieves the PCD protocol from the handle database.
@retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.
**/
PCD_PROTOCOL *
EFIAPI
@ -73,6 +81,45 @@ GetPcdProtocol (
return mPcd;
}
/**
Retrieves the PI PCD info protocol from the handle database.
@retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.
**/
EFI_GET_PCD_INFO_PROTOCOL *
GetPiPcdInfoProtocolPointer (
VOID
)
{
EFI_STATUS Status;
if (mPiPcdInfo == NULL) {
Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo);
ASSERT_EFI_ERROR (Status);
ASSERT (mPiPcdInfo != NULL);
}
return mPiPcdInfo;
}
/**
Retrieves the PCD info protocol from the handle database.
@retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.
**/
GET_PCD_INFO_PROTOCOL *
GetPcdInfoProtocolPointer (
VOID
)
{
EFI_STATUS Status;
if (mPcdInfo == NULL) {
Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo);
ASSERT_EFI_ERROR (Status);
ASSERT (mPcdInfo != NULL);
}
return mPcdInfo;
}
/**
This function provides a means by which SKU support can be established in the PCD infrastructure.
@ -1037,5 +1084,78 @@ LibPatchPcdSetPtr (
return (VOID *) Buffer;
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the default token space specified, then ASSERT().
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfo (
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
)
{
EFI_STATUS Status;
Status = GetPcdInfoProtocolPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);
ASSERT_EFI_ERROR (Status);
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the token space specified by Guid, then ASSERT().
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfoEx (
IN CONST GUID *Guid,
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
)
{
EFI_STATUS Status;
Status = GetPiPcdInfoProtocolPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);
ASSERT_EFI_ERROR (Status);
}
/**
Retrieve the currently set SKU Id.
If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
LibPcdGetSku (
VOID
)
{
UINTN SkuId;
SkuId = GetPiPcdInfoProtocolPointer()->GetSku ();
ASSERT (SkuId < PCD_MAX_SKU_ID);
return SkuId;
}

View File

@ -1,7 +1,7 @@
## @file
# Instance of PCD Library using PCD Protocol.
#
# There are two PCD PPIs as follows:
# There are two PCD PROTOCOLs as follows:
# 1) PCD_PROTOCOL
# It is EDKII implementation which support Dynamic/DynamicEx Pcds.
# 2) EFI_PCD_PROTOCOL
@ -13,7 +13,7 @@
# This library instance uses the PCD_PROTOCOL to handle dynamic PCD request and use
# EFI_PCD_PROTOCOL to handle dynamicEx type PCD.
#
# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -54,6 +54,8 @@
[Protocols]
gPcdProtocolGuid ## CONSUMES
gEfiPcdProtocolGuid ## CONSUMES
gGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES
gEfiGetPcdInfoProtocolGuid ## SOMETIMES_CONSUMES
[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER]
gEfiPcdProtocolGuid

View File

@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Ppi/Pcd.h>
#include <Ppi/PiPcd.h>
#include <Ppi/PcdInfo.h>
#include <Ppi/PiPcdInfo.h>
#include <Library/PeiServicesLib.h>
#include <Library/PcdLib.h>
@ -71,7 +73,53 @@ GetPiPcdPpiPointer (
return PiPcdPpi;
}
/**
Retrieve the GET_PCD_INFO_PPI pointer.
This function is to locate GET_PCD_INFO_PPI PPI via PeiService.
If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
@retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.
**/
GET_PCD_INFO_PPI *
GetPcdInfoPpiPointer (
VOID
)
{
EFI_STATUS Status;
GET_PCD_INFO_PPI *PcdInfoPpi;
Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);
ASSERT_EFI_ERROR (Status);
return PcdInfoPpi;
}
/**
Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.
This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService.
If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().
@retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.
**/
EFI_GET_PCD_INFO_PPI *
GetPiPcdInfoPpiPointer (
VOID
)
{
EFI_STATUS Status;
EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi;
Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);
ASSERT_EFI_ERROR (Status);
return PiPcdInfoPpi;
}
/**
This function provides a means by which SKU support can be established in the PCD infrastructure.
@ -1044,4 +1092,77 @@ LibPatchPcdSetPtr (
return (VOID *) Buffer;
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the default token space specified, then ASSERT().
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfo (
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
)
{
EFI_STATUS Status;
Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);
ASSERT_EFI_ERROR (Status);
}
/**
Retrieve additional information associated with a PCD token.
This includes information such as the type of value the TokenNumber is associated with as well as possible
human readable name that is associated with the token.
If TokenNumber is not in the token space specified by Guid, then ASSERT().
@param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
@param[in] TokenNumber The PCD token number.
@param[out] PcdInfo The returned information associated with the requested TokenNumber.
The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
**/
VOID
EFIAPI
LibPcdGetInfoEx (
IN CONST GUID *Guid,
IN UINTN TokenNumber,
OUT PCD_INFO *PcdInfo
)
{
EFI_STATUS Status;
Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);
ASSERT_EFI_ERROR (Status);
}
/**
Retrieve the currently set SKU Id.
If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().
@return The currently set SKU Id. If the platform has not set at a SKU Id, then the
default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
Id is returned.
**/
UINTN
EFIAPI
LibPcdGetSku (
VOID
)
{
UINTN SkuId;
SkuId = GetPiPcdInfoPpiPointer()->GetSku ();
ASSERT (SkuId < PCD_MAX_SKU_ID);
return SkuId;
}

View File

@ -15,7 +15,7 @@
#
# PCD Library that uses the PCD PPI to access Dynamic and DynamicEx PCD entries
#
# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -57,7 +57,9 @@
[Ppis]
gPcdPpiGuid ## CONSUMES
gEfiPeiPcdPpiGuid ## CONSUMES
gGetPcdInfoPpiGuid ## SOMETIMES_CONSUMES
gEfiGetPcdInfoPpiGuid ## SOMETIMES_CONSUMES
[Depex.common.PEIM]
gEfiPeiPcdPpiGuid

View File

@ -681,6 +681,9 @@
## Include/Ppi/Pcd.h
gPcdPpiGuid = { 0x6e81c58, 0x4ad7, 0x44bc, { 0x83, 0x90, 0xf1, 0x2, 0x65, 0xf7, 0x24, 0x80 } }
## Include/Ppi/PcdInfo.h
gGetPcdInfoPpiGuid = { 0x4d8b155b, 0xc059, 0x4c8f, { 0x89, 0x26, 0x6, 0xfd, 0x43, 0x31, 0xdb, 0x8a } }
#
# PPIs defined in PI 1.2.
#
@ -716,7 +719,21 @@
## Include/Ppi/FirmwareVolumeInfo2.h
gEfiPeiFirmwareVolumeInfo2PpiGuid = { 0xea7ca24b, 0xded5, 0x4dad, { 0xa3, 0x89, 0xbf, 0x82, 0x7e, 0x8f, 0x9b, 0x38 } }
#
# PPIs defined in PI 1.2.1.
#
## Include/Ppi/PiPcdInfo.h
gEfiGetPcdInfoPpiGuid = { 0xa60c6b59, 0xe459, 0x425d, { 0x9c, 0x69, 0xb, 0xcc, 0x9c, 0xb2, 0x7d, 0x81 } }
[Protocols]
## Include/Protocol/Pcd.h
gPcdProtocolGuid = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}
## Include/Protocol/PcdInfo.h
gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } }
#
# Protocols defined in PI1.0.
#
@ -925,19 +942,19 @@
gEfiExtendedSalCacheServicesProtocolGuid = { 0xedc9494, 0x2743, 0x4ba5, { 0x88, 0x18, 0x0a, 0xef, 0x52, 0x13, 0xf1, 0x88 } }
gEfiExtendedSalMcaLogServicesProtocolGuid = { 0xcb3fd86e, 0x38a3, 0x4c03, {0x9a, 0x5c, 0x90, 0xcf, 0xa3, 0xa2, 0xab, 0x7a } }
#
# Protocols defined in PI1.2.1
#
## Include/Protocol/Security2.h
gEfiSecurity2ArchProtocolGuid = { 0x94ab2f58, 0x1438, 0x4ef1, {0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68 } }
#
# Protocols defined in PI 1.2.1
#
## Include/Protocol/Security2.h
gEfiSecurity2ArchProtocolGuid = { 0x94ab2f58, 0x1438, 0x4ef1, {0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68 } }
## Include/Protocol/SmmEndOfDxe.h
gEfiSmmEndOfDxeProtocolGuid = { 0x24e70042, 0xd5c5, 0x4260, { 0x8c, 0x39, 0xa, 0xd3, 0xaa, 0x32, 0xe9, 0x3d }}
## Include/Protocol/PiPcdInfo.h
gEfiGetPcdInfoProtocolGuid = { 0xfd0f4478, 0xefd, 0x461d, { 0xba, 0x2d, 0xe5, 0x8c, 0x45, 0xfd, 0x5f, 0x5e } }
#
# Protocols defined in PI 1.3.
#
@ -1192,9 +1209,6 @@
## Include/Protocol/Hash.h
gEfiHashProtocolGuid = { 0xC5184932, 0xDBA5, 0x46DB, { 0xA5, 0xBA, 0xCC, 0x0B, 0xDA, 0x9C, 0x14, 0x35 }}
## Include/Protocol/Pcd.h
gPcdProtocolGuid = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}
## Include/Protocol/TcgService.h
gEfiTcgProtocolGuid = { 0xf541796d, 0xa62e, 0x4954, { 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd }}