102 EFI_PEI_PPI_DESCRIPTOR_PPI,
107 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
115 EFI_PEI_PPI_DESCRIPTOR_PPI,
120 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
121 &gEfiGetPcdInfoPpiGuid,
143 IN OUT VOID *TokenData,
153 UINT8 *VarStoreHobData;
161 DefaultId = *(UINT16 *)TokenData;
166 DataBuffer = (UINT8 *)
PeiPcdGetPtrEx (&gEfiMdeModulePkgTokenSpaceGuid,
PcdToken (PcdNvStoreDefaultValueBuffer));
172 NvStoreBuffer = (
VARIABLE_STORE_HEADER *)((UINT8 *)DataHeader +
sizeof (DataHeader->DataSize) + DataHeader->HeaderSize);
174 ASSERT (VarStoreHobData !=
NULL);
175 CopyMem (VarStoreHobData, NvStoreBuffer, NvStoreBuffer->
Size);
179 DefaultInfo = &(DataHeader->DefaultInfo[0]);
180 BufferEnd = (UINT8 *)DataHeader +
sizeof (DataHeader->DataSize) + DataHeader->HeaderSize;
181 while ((UINT8 *)DefaultInfo < BufferEnd) {
182 if ((DefaultInfo->DefaultId == DefaultId) && (DefaultInfo->SkuId == SkuId)) {
195 while (!IsFound && Index < FullSize && DataHeader->DataSize != 0xFFFFFFFF) {
196 DefaultInfo = &(DataHeader->DefaultInfo[0]);
197 BufferEnd = (UINT8 *)DataHeader +
sizeof (DataHeader->DataSize) + DataHeader->HeaderSize;
198 while ((UINT8 *)DefaultInfo < BufferEnd) {
199 if ((DefaultInfo->DefaultId == DefaultId) && (DefaultInfo->SkuId == SkuId)) {
209 BufferEnd = (UINT8 *)DataHeader + DataHeader->DataSize;
210 while ((UINT8 *)DeltaData < BufferEnd) {
211 *(VarStoreHobData + DeltaData->Offset) = (UINT8)DeltaData->Value;
218 Index = (Index + DataHeader->DataSize + 7) & (~7);
224 &gEfiMdeModulePkgTokenSpaceGuid,
264 if (BootMode == BOOT_ON_S3_RESUME) {
269 if (PeiPcdDb->SystemSkuId != (SKU_ID)0) {
296 if (!EFI_ERROR (Status)) {
314 Length = PeiPcdDb->LengthForAllSkus;
316 CopyMem (Database, PcdDb, Length);
323 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
324 &gEfiEndOfPeiSignalPpiGuid,
350 if (Status == EFI_ALREADY_STARTED) {
368 if (OldPpiList !=
NULL) {
382 if (OldPpiList2 !=
NULL) {
396 if (OldPpiList !=
NULL) {
403 &gEfiGetPcdInfoPpiGuid,
410 if (OldPpiList2 !=
NULL) {
436 &gEfiMdeModulePkgTokenSpaceGuid,
548 DEBUG ((DEBUG_INFO,
"PcdPei - SkuId 0x%lx is to be set.\n", (SKU_ID)SkuId));
552 if (SkuId == PeiPcdDb->SystemSkuId) {
556 DEBUG ((DEBUG_INFO,
"PcdPei - SkuId is same to current system Sku.\n"));
560 if (PeiPcdDb->SystemSkuId != (SKU_ID)0) {
561 DEBUG ((DEBUG_ERROR,
"PcdPei - The SKU Id could be changed only once."));
564 "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
565 PeiPcdDb->SystemSkuId,
572 SkuIdTable = (SKU_ID *)((UINT8 *)PeiPcdDb + PeiPcdDb->SkuIdTableOffset);
573 for (Index = 0; Index < SkuIdTable[0]; Index++) {
574 if (SkuId == SkuIdTable[Index + 1]) {
575 DEBUG ((DEBUG_INFO,
"PcdPei - SkuId is found in SkuId table.\n"));
580 if (Index < SkuIdTable[0]) {
601 if (!EFI_ERROR (Status)) {
619 Length = PeiPcdDb->LengthForAllSkus;
620 Index = (PeiPcdDb->Length + 7) & (~7);
622 while (Index < Length) {
624 if ((SkuDelta->SkuId == SkuId) && (SkuDelta->SkuIdCompared == 0)) {
628 Index = (Index + SkuDelta->Length + 7) & (~7);
634 if ((Index < Length) && (SkuDelta !=
NULL)) {
636 while ((UINT8 *)SkuDeltaData < (UINT8 *)SkuDelta + SkuDelta->Length) {
637 *((UINT8 *)PeiPcdDb + SkuDeltaData->Offset) = (UINT8)SkuDeltaData->Value;
641 PeiPcdDb->SystemSkuId = (SKU_ID)SkuId;
642 DEBUG ((DEBUG_INFO,
"PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID)SkuId));
650 DEBUG ((DEBUG_ERROR,
"PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
672 return *((UINT8 *)
GetWorker (TokenNumber,
sizeof (UINT8)));
776 return *((BOOLEAN *)
GetWorker (TokenNumber,
sizeof (BOOLEAN)));
799 UINT32 LocalTokenCount;
802 LocalTokenCount = PeiPcdDb->LocalTokenCount;
813 ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
815 Size = (*((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber) & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
848 return *((UINT8 *)
ExGetWorker (Guid, ExTokenNumber,
sizeof (UINT8)));
968 return *((BOOLEAN *)
ExGetWorker (Guid, ExTokenNumber,
sizeof (BOOLEAN)));
1360 return EFI_UNSUPPORTED;
1363 if (CallBackFunction ==
NULL) {
1364 return EFI_INVALID_PARAMETER;
1391 return EFI_UNSUPPORTED;
1394 if (CallBackFunction ==
NULL) {
1395 return EFI_INVALID_PARAMETER;
1440 BOOLEAN PeiExMapTableEmpty;
1441 UINTN PeiNexTokenNumber;
1444 return EFI_UNSUPPORTED;
1448 PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;
1449 GuidTable = (
EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);
1451 if (PeiPcdDb->ExTokenCount == 0) {
1452 PeiExMapTableEmpty =
TRUE;
1454 PeiExMapTableEmpty =
FALSE;
1458 if (*TokenNumber > PeiNexTokenNumber) {
1459 return EFI_NOT_FOUND;
1463 if (*TokenNumber > PeiNexTokenNumber) {
1464 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
1465 return EFI_NOT_FOUND;
1470 if (PeiExMapTableEmpty) {
1471 return EFI_NOT_FOUND;
1474 MatchGuid =
ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof (
EFI_GUID), Guid);
1476 if (MatchGuid ==
NULL) {
1477 return EFI_NOT_FOUND;
1480 GuidTableIdx = MatchGuid - GuidTable;
1482 ExMapTable = (
DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);
1488 for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {
1489 if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
1500 if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
1501 *TokenNumber = ExMapTable[Index].ExTokenNumber;
1505 for ( ; Index < PeiPcdDb->ExTokenCount; Index++) {
1506 if ((ExMapTable[Index].ExTokenNumber == *TokenNumber) && (ExMapTable[Index].ExGuidIndex == GuidTableIdx)) {
1511 while (Index < PeiPcdDb->ExTokenCount) {
1513 if (Index == PeiPcdDb->ExTokenCount) {
1517 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
1518 return EFI_NOT_FOUND;
1519 }
else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
1523 *TokenNumber = ExMapTable[Index].ExTokenNumber;
1530 return EFI_NOT_FOUND;
1562 BOOLEAN PeiExMapTableEmpty;
1566 return EFI_UNSUPPORTED;
1569 ASSERT (Guid !=
NULL);
1573 if (PeiPcdDb->ExTokenCount == 0) {
1574 PeiExMapTableEmpty =
TRUE;
1576 PeiExMapTableEmpty =
FALSE;
1579 if (PeiExMapTableEmpty) {
1580 return EFI_NOT_FOUND;
1583 ExMapTable = (
DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);
1584 GuidTable = (
EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);
1586 if (*Guid ==
NULL) {
1590 *Guid = GuidTable + ExMapTable[0].ExGuidIndex;
1594 MatchGuid =
ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof (GuidTable[0]), *Guid);
1596 if (MatchGuid ==
NULL) {
1597 return EFI_NOT_FOUND;
1600 GuidTableIdx = MatchGuid - GuidTable;
1603 for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {
1604 if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
1612 for ( ; Index < PeiPcdDb->ExTokenCount; Index++ ) {
1613 if (ExMapTable[Index].ExGuidIndex != GuidTableIdx) {
1615 for (Index2 = 0; Index2 < Index; Index2++) {
1616 if (ExMapTable[Index2].ExGuidIndex == ExMapTable[Index].ExGuidIndex) {
1626 *Guid = (
EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset) + ExMapTable[Index].ExGuidIndex;
1635 return EFI_NOT_FOUND;
1653 IN UINTN LocalTokenNumberTableIdx,
1659 UINTN LocalTokenNumber;
1660 SIZE_INFO *SizeTable;
1664 LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
1666 ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
1668 SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);
1670 *MaxSize = SizeTable[SizeTableIdx];
1675 if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
1689 return SizeTable[SizeTableIdx + 1];
1709 IN UINTN LocalTokenNumberTableIdx,
1715 UINTN LocalTokenNumber;
1716 SIZE_INFO *SizeTable;
1721 LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
1723 ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
1725 SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);
1727 MaxSize = SizeTable[SizeTableIdx];
1732 if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
1739 if ((*CurrentSize > MaxSize) ||
1742 *CurrentSize = MaxSize;
1751 SizeTable[SizeTableIdx + 1] = (SIZE_INFO)*CurrentSize;
VOID *EFIAPI BuildGuidHob(IN CONST EFI_GUID *Guid, IN UINTN DataLength)
UINT64 EFIAPI ReadUnaligned64(IN CONST UINT64 *Buffer)
UINT16 EFIAPI ReadUnaligned16(IN CONST UINT16 *Buffer)
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
VOID *EFIAPI ScanGuid(IN CONST VOID *Buffer, IN UINTN Length, IN CONST GUID *Guid)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GET_PCD_INFO_PROTOCOL mGetPcdInfoInstance
EFI_GET_PCD_INFO_PROTOCOL mEfiGetPcdInfoInstance
EFI_STATUS EFIAPI PeiServicesFfsFindSectionData(IN EFI_SECTION_TYPE SectionType, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData)
EFI_STATUS EFIAPI PeiServicesFfsFindNextVolume(IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle)
EFI_STATUS EFIAPI PeiServicesGetBootMode(OUT EFI_BOOT_MODE *BootMode)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesFfsFindFileByName(IN CONST EFI_GUID *FileName, IN CONST EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI PeiServicesReInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi, IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi)
EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
EFI_STATUS ExSetValueWorker(IN UINTN ExTokenNumber, IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN SetSize)
UINTN GetExPcdTokenNumber(IN CONST EFI_GUID *Guid, IN UINT32 ExTokenNumber)
VOID * GetWorker(IN UINTN TokenNumber, IN UINTN GetSize)
UINTN GetSizeTableIndex(IN UINTN LocalTokenNumberTableIdx, IN BOOLEAN IsPeiDb)
VOID * ExGetWorker(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINTN GetSize)
EFI_STATUS ExSetWorker(IN UINTN ExTokenNumber, IN CONST EFI_GUID *Guid, IN VOID *Data, IN OUT UINTN *SetSize, IN BOOLEAN PtrType)
UINTN GetPtrTypeSize(IN UINTN LocalTokenNumberTableIdx, OUT UINTN *MaxSize)
EFI_STATUS SetValueWorker(IN UINTN TokenNumber, IN VOID *Data, IN UINTN Size)
EFI_STATUS SetWorker(IN UINTN TokenNumber, IN VOID *Data, IN OUT UINTN *Size, IN BOOLEAN PtrType)
PEI_PCD_DATABASE * GetPcdDatabase(VOID)
EFI_STATUS PeiRegisterCallBackWorker(IN UINTN ExTokenNumber, IN CONST EFI_GUID *Guid OPTIONAL, IN PCD_PPI_CALLBACK CallBackFunction, IN BOOLEAN Register)
PEI_PCD_DATABASE * BuildPcdDatabase(IN EFI_PEI_FILE_HANDLE FileHandle)
EFI_STATUS PeiGetPcdInfo(IN CONST EFI_GUID *Guid, IN UINTN TokenNumber, OUT EFI_PCD_INFO *PcdInfo)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdToken(TokenName)
#define FeaturePcdGet(TokenName)
EFI_STATUS EFIAPI PeiPcdSetPtr(IN UINTN TokenNumber, IN OUT UINTN *SizeOfBuffer, IN VOID *Buffer)
VOID EFIAPI PcdSetNvStoreDefaultIdCallBack(IN CONST EFI_GUID *CallBackGuid OPTIONAL, IN UINTN CallBackToken, IN OUT VOID *TokenData, IN UINTN TokenDataSize)
EFI_STATUS EFIAPI PeiPcdGetNextTokenSpace(IN OUT CONST EFI_GUID **Guid)
VOID EFIAPI PeiPcdSetSku(IN UINTN SkuId)
UINT64 EFIAPI PeiPcdGet64(IN UINTN TokenNumber)
EFI_STATUS EFIAPI PeiPcdSet64Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT64 Value)
EFI_STATUS EFIAPI PeiPcdSetBoolEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN BOOLEAN Value)
VOID *EFIAPI PeiPcdGetPtr(IN UINTN TokenNumber)
UINT64 EFIAPI PeiPcdGet64Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
UINTN EFIAPI PeiPcdGetSizeEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
EFI_STATUS EFIAPI PeiPcdGetNextToken(IN CONST EFI_GUID *Guid OPTIONAL, IN OUT UINTN *TokenNumber)
VOID *EFIAPI PeiPcdGetPtrEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
BOOLEAN EFIAPI PeiPcdGetBoolEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
EFI_STATUS EFIAPI PeiPcdSetBool(IN UINTN TokenNumber, IN BOOLEAN Value)
UINT8 EFIAPI PeiPcdGet8(IN UINTN TokenNumber)
EFI_STATUS EFIAPI PeiPcdSet8(IN UINTN TokenNumber, IN UINT8 Value)
EFI_STATUS EFIAPI PcdUnRegisterCallBackOnSet(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN ExTokenNumber, IN PCD_PPI_CALLBACK CallBackFunction)
UINT8 EFIAPI PeiPcdGet8Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
EFI_STATUS EFIAPI PeiPcdSet32(IN UINTN TokenNumber, IN UINT32 Value)
EFI_STATUS EFIAPI PeiPcdSet16(IN UINTN TokenNumber, IN UINT16 Value)
UINT16 EFIAPI PeiPcdGet16Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
EFI_STATUS EFIAPI PeiPcdSet32Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT32 Value)
EFI_STATUS EFIAPI PeiPcdSetPtrEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN OUT UINTN *SizeOfBuffer, IN VOID *Value)
EFI_STATUS EFIAPI PeiPcdSet16Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT16 Value)
EFI_PEI_PCD_PPI mEfiPcdPpiInstance
BOOLEAN EFIAPI PeiPcdGetBool(IN UINTN TokenNumber)
UINTN EFIAPI PeiPcdGetSize(IN UINTN TokenNumber)
UINT32 EFIAPI PeiPcdGet32(IN UINTN TokenNumber)
UINT16 EFIAPI PeiPcdGet16(IN UINTN TokenNumber)
EFI_STATUS EFIAPI EndOfPeiSignalPpiNotifyCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS EFIAPI PeiPcdSet8Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT8 Value)
EFI_STATUS EFIAPI PeiPcdSet64(IN UINTN TokenNumber, IN UINT64 Value)
EFI_STATUS EFIAPI PcdPeimInit(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
UINT32 EFIAPI PeiPcdGet32Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
UINTN EFIAPI PeiGetPcdInfoGetSku(VOID)
EFI_STATUS EFIAPI PeiRegisterCallBackOnSet(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN ExTokenNumber, IN PCD_PPI_CALLBACK CallBackFunction)
EFI_STATUS EFIAPI PeiGetPcdInfoGetInfoEx(IN CONST EFI_GUID *Guid, IN UINTN TokenNumber, OUT EFI_PCD_INFO *PcdInfo)
EFI_STATUS EFIAPI PeiGetPcdInfoGetInfo(IN UINTN TokenNumber, OUT EFI_PCD_INFO *PcdInfo)
BOOLEAN SetPtrTypeSize(IN UINTN LocalTokenNumberTableIdx, IN OUT UINTN *CurrentSize, IN PEI_PCD_DATABASE *Database)
VOID * EFI_PEI_FILE_HANDLE
VOID(EFIAPI * PCD_PPI_CALLBACK)(IN CONST EFI_GUID *CallBackGuid OPTIONAL, IN UINTN CallBackToken, IN OUT VOID *TokenData, IN UINTN TokenDataSize)
EFI_STATUS(EFIAPI * EFI_PEI_PCD_PPI_CANCEL_CALLBACK)(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN CallBackToken, IN EFI_PEI_PCD_PPI_CALLBACK CallBackFunction)
EFI_STATUS(EFIAPI * EFI_PEI_PCD_PPI_CALLBACK_ON_SET)(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN CallBackToken, IN EFI_PEI_PCD_PPI_CALLBACK CallBackFunction)