106UINTN mVpdBaseAddress = 0;
141 Status =
gBS->InstallMultipleProtocolInterfaces (
145 &gEfiPcdProtocolGuid,
155 Status =
gBS->InstallMultipleProtocolInterfaces (
157 &gGetPcdInfoProtocolGuid,
159 &gEfiGetPcdInfoProtocolGuid,
170 &gEdkiiVariableLockProtocolGuid,
185 if (mVpdBaseAddress == 0) {
256 return (
UINTN)mPcdDatabase.DxeDb->SystemSkuId;
290 DEBUG ((DEBUG_INFO,
"PcdDxe - SkuId 0x%lx is to be set.\n", (SKU_ID)SkuId));
292 if (SkuId == mPcdDatabase.DxeDb->SystemSkuId) {
296 DEBUG ((DEBUG_INFO,
"PcdDxe - SkuId is same to current system Sku.\n"));
300 if (mPcdDatabase.DxeDb->SystemSkuId != (SKU_ID)0) {
301 DEBUG ((DEBUG_ERROR,
"PcdDxe - The SKU Id could be changed only once."));
304 "PcdDxe - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
305 mPcdDatabase.DxeDb->SystemSkuId,
312 SkuIdTable = (SKU_ID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SkuIdTableOffset);
313 for (Index = 0; Index < SkuIdTable[0]; Index++) {
314 if (SkuId == SkuIdTable[Index + 1]) {
315 DEBUG ((DEBUG_INFO,
"PcdDxe - SkuId is found in SkuId table.\n"));
317 if (!EFI_ERROR (Status)) {
318 mPcdDatabase.DxeDb->SystemSkuId = (SKU_ID)SkuId;
319 DEBUG ((DEBUG_INFO,
"PcdDxe - Set current SKU Id to 0x%lx.\n", (SKU_ID)SkuId));
328 DEBUG ((DEBUG_ERROR,
"PcdDxe - Invalid input SkuId, the default SKU Id will be still used.\n"));
349 return *((UINT8 *)
GetWorker (TokenNumber,
sizeof (UINT8)));
453 return *((BOOLEAN *)
GetWorker (TokenNumber,
sizeof (BOOLEAN)));
474 UINT32 *LocalTokenNumberTable;
477 UINTN TmpTokenNumber;
489 TmpTokenNumber = TokenNumber;
494 ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1);
499 IsPeiDb = (BOOLEAN)(TokenNumber + 1 < mPeiLocalTokenCount + 1);
501 TokenNumber = IsPeiDb ? TokenNumber :
502 (TokenNumber - mPeiLocalTokenCount);
504 LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset)
505 : (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);
507 Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
540 return *((UINT8 *)
ExGetWorker (Guid, ExTokenNumber,
sizeof (UINT8)));
660 return *((BOOLEAN *)
ExGetWorker (Guid, ExTokenNumber,
sizeof (BOOLEAN)));
911 !(
CompareGuid (Guid, &gEfiMdeModulePkgTokenSpaceGuid) &&
912 (ExTokenNumber ==
PcdToken (PcdSetNvStoreDefaultId)))
1060 if (CallBackFunction ==
NULL) {
1061 return EFI_INVALID_PARAMETER;
1098 if (CallBackFunction ==
NULL) {
1099 return EFI_INVALID_PARAMETER;
1148 BOOLEAN PeiExMapTableEmpty;
1149 BOOLEAN DxeExMapTableEmpty;
1151 Status = EFI_NOT_FOUND;
1152 PeiExMapTableEmpty = mPeiExMapTableEmpty;
1153 DxeExMapTableEmpty = mDxeExMapTableEmpty;
1162 if (((*TokenNumber + 1 > mPeiNexTokenCount + 1) && (*TokenNumber + 1 <= mPeiLocalTokenCount + 1)) ||
1163 ((*TokenNumber + 1 > (mPeiLocalTokenCount + mDxeNexTokenCount + 1))))
1165 return EFI_NOT_FOUND;
1169 if ((*TokenNumber + 1 > mPeiNexTokenCount + 1) &&
1170 (*TokenNumber + 1 <= mPeiLocalTokenCount + 1))
1176 if (mDxeNexTokenCount > 0) {
1177 *TokenNumber = mPeiLocalTokenCount + 1;
1179 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
1180 return EFI_NOT_FOUND;
1182 }
else if (*TokenNumber + 1 > mDxeNexTokenCount + mPeiLocalTokenCount + 1) {
1183 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
1184 return EFI_NOT_FOUND;
1190 if (PeiExMapTableEmpty && DxeExMapTableEmpty) {
1191 return EFI_NOT_FOUND;
1194 if (!PeiExMapTableEmpty) {
1198 (
EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset),
1200 (
DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset),
1201 mPeiExMapppingTableSize
1209 if (!DxeExMapTableEmpty) {
1213 (
EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset),
1215 (
DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset),
1216 mDxeExMapppingTableSize
1248 ASSERT (DistinctTokenSpace !=
NULL);
1251 OldGuidIndex = ExMapTable[0].ExGuidIndex;
1252 DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];
1253 for (Idx = 1; Idx < *ExMapTableSize; Idx++) {
1255 OldGuidIndex = ExMapTable[Idx].ExGuidIndex;
1256 for (TempTsIdx = 0; TempTsIdx <= TsIdx; TempTsIdx++) {
1257 if (&GuidTable[OldGuidIndex] == DistinctTokenSpace[TempTsIdx]) {
1267 DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];
1276 *ExMapTableSize = TsIdx + 1;
1277 return DistinctTokenSpace;
1305 UINTN PeiTokenSpaceTableSize;
1306 UINTN DxeTokenSpaceTableSize;
1310 BOOLEAN PeiExMapTableEmpty;
1311 BOOLEAN DxeExMapTableEmpty;
1313 ASSERT (Guid !=
NULL);
1315 PeiExMapTableEmpty = mPeiExMapTableEmpty;
1316 DxeExMapTableEmpty = mDxeExMapTableEmpty;
1318 if (PeiExMapTableEmpty && DxeExMapTableEmpty) {
1319 return EFI_NOT_FOUND;
1322 if (TmpTokenSpaceBuffer[0] ==
NULL) {
1323 PeiTokenSpaceTableSize = 0;
1325 if (!PeiExMapTableEmpty) {
1328 &PeiTokenSpaceTableSize,
1329 (
DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset),
1330 (
EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset)
1332 CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable,
sizeof (
EFI_GUID *) * PeiTokenSpaceTableSize);
1333 TmpTokenSpaceBufferCount = PeiTokenSpaceTableSize;
1337 if (!DxeExMapTableEmpty) {
1340 &DxeTokenSpaceTableSize,
1341 (
DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset),
1342 (
EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset)
1348 for (Idx2 = 0, Idx3 = PeiTokenSpaceTableSize; Idx2 < DxeTokenSpaceTableSize; Idx2++) {
1350 for (Idx = 0; Idx < PeiTokenSpaceTableSize; Idx++) {
1351 if (
CompareGuid (TmpTokenSpaceBuffer[Idx], DxeTokenSpaceTable[Idx2])) {
1358 TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];
1362 TmpTokenSpaceBufferCount = Idx3;
1367 if (*Guid ==
NULL) {
1368 *Guid = TmpTokenSpaceBuffer[0];
1372 for (Idx = 0; Idx < TmpTokenSpaceBufferCount; Idx++) {
1373 if (
CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {
1374 if (Idx == TmpTokenSpaceBufferCount - 1) {
1379 return EFI_NOT_FOUND;
1382 *Guid = TmpTokenSpaceBuffer[Idx];
1388 return EFI_NOT_FOUND;
UINT64 EFIAPI ReadUnaligned64(IN CONST UINT64 *Buffer)
UINT16 EFIAPI ReadUnaligned16(IN CONST UINT16 *Buffer)
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GET_PCD_INFO_PROTOCOL mGetPcdInfoInstance
VOID *EFIAPI DxePcdGetPtrEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
UINTN EFIAPI DxePcdGetSizeEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
BOOLEAN EFIAPI DxePcdGetBool(IN UINTN TokenNumber)
EFI_STATUS EFIAPI DxePcdGetNextToken(IN CONST EFI_GUID *Guid OPTIONAL, IN OUT UINTN *TokenNumber)
UINTN EFIAPI DxePcdGetSize(IN UINTN TokenNumber)
EFI_STATUS EFIAPI DxePcdSet32(IN UINTN TokenNumber, IN UINT32 Value)
UINT32 EFIAPI DxePcdGet32(IN UINTN TokenNumber)
UINT16 EFIAPI DxePcdGet16Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
UINT32 EFIAPI DxePcdGet32Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
EFI_STATUS EFIAPI DxePcdSet16(IN UINTN TokenNumber, IN UINT16 Value)
EFI_LOCK mPcdDatabaseLock
BOOLEAN EFIAPI DxePcdGetBoolEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
EFI_STATUS EFIAPI DxeGetPcdInfoGetInfoEx(IN CONST EFI_GUID *Guid, IN UINTN TokenNumber, OUT EFI_PCD_INFO *PcdInfo)
EFI_STATUS EFIAPI DxePcdSetBoolEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN BOOLEAN Value)
UINTN EFIAPI DxeGetPcdInfoGetSku(VOID)
EFI_STATUS EFIAPI DxePcdSetBool(IN UINTN TokenNumber, IN BOOLEAN Value)
EFI_STATUS EFIAPI DxePcdSet8(IN UINTN TokenNumber, IN UINT8 Value)
EFI_STATUS EFIAPI DxeUnRegisterCallBackOnSet(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN TokenNumber, IN PCD_PROTOCOL_CALLBACK CallBackFunction)
EFI_STATUS EFIAPI DxePcdSet16Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT16 Value)
EFI_STATUS EFIAPI DxePcdSetPtrEx(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN OUT UINTN *SizeOfBuffer, IN VOID *Buffer)
EFI_STATUS EFIAPI DxePcdSet64(IN UINTN TokenNumber, IN UINT64 Value)
EFI_GUID ** GetDistinctTokenSpace(IN OUT UINTN *ExMapTableSize, IN DYNAMICEX_MAPPING *ExMapTable, IN EFI_GUID *GuidTable)
EFI_GET_PCD_INFO_PROTOCOL mEfiGetPcdInfoInstance
EFI_STATUS EFIAPI DxeGetPcdInfoGetInfo(IN UINTN TokenNumber, OUT EFI_PCD_INFO *PcdInfo)
VOID EFIAPI DxePcdSetSku(IN UINTN SkuId)
UINT8 EFIAPI DxePcdGet8Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
UINT8 EFIAPI DxePcdGet8(IN UINTN TokenNumber)
EFI_STATUS EFIAPI DxePcdSet8Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT8 Value)
EFI_STATUS EFIAPI DxePcdSet32Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT32 Value)
UINT64 EFIAPI DxePcdGet64Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber)
VOID *EFIAPI DxePcdGetPtr(IN UINTN TokenNumber)
EFI_STATUS EFIAPI DxePcdSet64Ex(IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINT64 Value)
EFI_STATUS EFIAPI DxePcdGetNextTokenSpace(IN OUT CONST EFI_GUID **Guid)
EFI_STATUS EFIAPI DxeRegisterCallBackOnSet(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN TokenNumber, IN PCD_PROTOCOL_CALLBACK CallBackFunction)
EFI_STATUS EFIAPI DxePcdSetPtr(IN UINTN TokenNumber, IN OUT UINTN *SizeOfBuffer, IN VOID *Buffer)
EFI_STATUS EFIAPI PcdDxeInit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
PCD_PROTOCOL mPcdInstance
EFI_PCD_PROTOCOL mEfiPcdInstance
UINT64 EFIAPI DxePcdGet64(IN UINTN TokenNumber)
UINT16 EFIAPI DxePcdGet16(IN UINTN TokenNumber)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS DxeGetPcdInfo(IN CONST EFI_GUID *Guid, IN UINTN TokenNumber, OUT EFI_PCD_INFO *PcdInfo)
EFI_STATUS DxeRegisterCallBackWorker(IN UINTN TokenNumber, IN CONST EFI_GUID *Guid OPTIONAL, IN PCD_PROTOCOL_CALLBACK CallBackFunction)
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)
EFI_STATUS DxeUnRegisterCallBackWorker(IN UINTN TokenNumber, IN CONST EFI_GUID *Guid OPTIONAL, IN PCD_PROTOCOL_CALLBACK CallBackFunction)
VOID * GetWorker(IN UINTN TokenNumber, IN UINTN GetSize)
VOID BuildPcdDxeDataBase(VOID)
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)
EFI_STATUS ExGetNextTokeNumber(IN CONST EFI_GUID *Guid, IN OUT UINTN *TokenNumber, IN EFI_GUID *GuidTable, IN UINTN SizeOfGuidTable, IN DYNAMICEX_MAPPING *ExMapTable, IN UINTN SizeOfExMapTable)
UINTN GetPtrTypeSize(IN UINTN LocalTokenNumberTableIdx, OUT UINTN *MaxSize)
VOID EFIAPI VariableLockCallBack(IN EFI_EVENT Event, IN VOID *Context)
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)
EFI_STATUS UpdatePcdDatabase(IN SKU_ID SkuId, IN BOOLEAN IsPeiDb)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
#define PcdToken(TokenName)
#define PcdGet32(TokenName)
VOID(EFIAPI * PCD_PROTOCOL_CALLBACK)(IN CONST EFI_GUID *CallBackGuid OPTIONAL, IN UINTN CallBackToken, IN OUT VOID *TokenData, IN UINTN TokenDataSize)
EFI_STATUS(EFIAPI * EFI_PCD_PROTOCOL_CANCEL_CALLBACK)(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN CallBackToken, IN EFI_PCD_PROTOCOL_CALLBACK CallBackFunction)
EFI_STATUS(EFIAPI * EFI_PCD_PROTOCOL_CALLBACK_ON_SET)(IN CONST EFI_GUID *Guid OPTIONAL, IN UINTN CallBackToken, IN EFI_PCD_PROTOCOL_CALLBACK CallBackFunction)
STATIC BOOLEAN Match(IN CONST CHAR16 *Translated, IN UINTN TranslatedLength, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
#define EFI_INITIALIZE_LOCK_VARIABLE(Priority)
VOID EFIAPI EfiReleaseLock(IN EFI_LOCK *Lock)
VOID EFIAPI EfiAcquireLock(IN EFI_LOCK *Lock)
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)