2 All Pcd Ppi services are implemented here.
4 Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 /// Instance of PCD_PPI protocol is EDKII native implementation.
14 /// This protocol instance support dynamic and dynamicEx type PCDs.
16 PCD_PPI mPcdPpiInstance
= {
49 PeiRegisterCallBackOnSet
,
50 PcdUnRegisterCallBackOnSet
,
52 PeiPcdGetNextTokenSpace
56 /// Instance of EFI_PEI_PCD_PPI which is defined in PI 1.2 Vol 3.
57 /// This PPI instance only support dyanmicEx type PCD.
59 EFI_PEI_PCD_PPI mEfiPcdPpiInstance
= {
75 (EFI_PEI_PCD_PPI_CALLBACK_ON_SET
) PeiRegisterCallBackOnSet
,
76 (EFI_PEI_PCD_PPI_CANCEL_CALLBACK
) PcdUnRegisterCallBackOnSet
,
78 PeiPcdGetNextTokenSpace
82 /// Instance of GET_PCD_INFO_PPI protocol is EDKII native implementation.
83 /// This protocol instance support dynamic and dynamicEx type PCDs.
85 GET_PCD_INFO_PPI mGetPcdInfoInstance
= {
87 PeiGetPcdInfoGetInfoEx
,
92 /// Instance of EFI_GET_PCD_INFO_PPI which is defined in PI 1.2.1 Vol 3.
93 /// This PPI instance only support dyanmicEx type PCD.
95 EFI_GET_PCD_INFO_PPI mEfiGetPcdInfoInstance
= {
96 PeiGetPcdInfoGetInfoEx
,
100 EFI_PEI_PPI_DESCRIPTOR mPpiList
[] = {
102 EFI_PEI_PPI_DESCRIPTOR_PPI
,
107 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
113 EFI_PEI_PPI_DESCRIPTOR mPpiList2
[] = {
115 EFI_PEI_PPI_DESCRIPTOR_PPI
,
120 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
121 &gEfiGetPcdInfoPpiGuid
,
122 &mEfiGetPcdInfoInstance
127 Callback on SET PcdSetNvStoreDefaultId
129 Once PcdSetNvStoreDefaultId is set, the default NV storage will be found from
130 PcdNvStoreDefaultValueBuffer, and built into VariableHob.
132 @param[in] CallBackGuid The PCD token GUID being set.
133 @param[in] CallBackToken The PCD token number being set.
134 @param[in, out] TokenData A pointer to the token data being set.
135 @param[in] TokenDataSize The size, in bytes, of the data being set.
140 PcdSetNvStoreDefaultIdCallBack (
141 IN CONST EFI_GUID
*CallBackGuid OPTIONAL
,
142 IN UINTN CallBackToken
,
143 IN OUT VOID
*TokenData
,
144 IN UINTN TokenDataSize
153 UINT8
*VarStoreHobData
;
156 VARIABLE_STORE_HEADER
*NvStoreBuffer
;
157 PCD_DEFAULT_DATA
*DataHeader
;
158 PCD_DEFAULT_INFO
*DefaultInfo
;
159 PCD_DATA_DELTA
*DeltaData
;
161 DefaultId
= *(UINT16
*) TokenData
;
162 SkuId
= GetPcdDatabase()->SystemSkuId
;
165 if (PeiPcdGetSizeEx (&gEfiMdeModulePkgTokenSpaceGuid
, PcdToken (PcdNvStoreDefaultValueBuffer
)) > sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER
)) {
166 DataBuffer
= (UINT8
*) PeiPcdGetPtrEx (&gEfiMdeModulePkgTokenSpaceGuid
, PcdToken (PcdNvStoreDefaultValueBuffer
));
167 FullSize
= ((PCD_NV_STORE_DEFAULT_BUFFER_HEADER
*) DataBuffer
)->Length
;
168 DataHeader
= (PCD_DEFAULT_DATA
*) (DataBuffer
+ sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER
));
170 // The first section data includes NV storage default setting.
172 NvStoreBuffer
= (VARIABLE_STORE_HEADER
*) ((UINT8
*) DataHeader
+ sizeof (DataHeader
->DataSize
) + DataHeader
->HeaderSize
);
173 VarStoreHobData
= (UINT8
*) BuildGuidHob (&NvStoreBuffer
->Signature
, NvStoreBuffer
->Size
);
174 ASSERT (VarStoreHobData
!= NULL
);
175 CopyMem (VarStoreHobData
, NvStoreBuffer
, NvStoreBuffer
->Size
);
177 // Find the matched SkuId and DefaultId in the first section
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
) {
189 // Find the matched SkuId and DefaultId in the remaining section
191 Index
= sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER
) + ((DataHeader
->DataSize
+ 7) & (~7));
192 DataHeader
= (PCD_DEFAULT_DATA
*) (DataBuffer
+ Index
);
193 while (!IsFound
&& Index
< FullSize
&& DataHeader
->DataSize
!= 0xFFFFFFFF) {
194 DefaultInfo
= &(DataHeader
->DefaultInfo
[0]);
195 BufferEnd
= (UINT8
*) DataHeader
+ sizeof (DataHeader
->DataSize
) + DataHeader
->HeaderSize
;
196 while ((UINT8
*) DefaultInfo
< BufferEnd
) {
197 if (DefaultInfo
->DefaultId
== DefaultId
&& DefaultInfo
->SkuId
== SkuId
) {
204 DeltaData
= (PCD_DATA_DELTA
*) BufferEnd
;
205 BufferEnd
= (UINT8
*) DataHeader
+ DataHeader
->DataSize
;
206 while ((UINT8
*) DeltaData
< BufferEnd
) {
207 *(VarStoreHobData
+ DeltaData
->Offset
) = (UINT8
) DeltaData
->Value
;
212 Index
= (Index
+ DataHeader
->DataSize
+ 7) & (~7) ;
213 DataHeader
= (PCD_DEFAULT_DATA
*) (DataBuffer
+ Index
);
217 Status
= PcdUnRegisterCallBackOnSet (
218 &gEfiMdeModulePkgTokenSpaceGuid
,
219 PcdToken(PcdSetNvStoreDefaultId
),
220 PcdSetNvStoreDefaultIdCallBack
222 ASSERT_EFI_ERROR (Status
);
226 Report Pei PCD database of all SKUs as Guid HOB so that DxePcd can access it.
228 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
229 @param NotifyDescriptor Address of the notification descriptor data structure.
230 @param Ppi Address of the PPI that was installed.
232 @retval EFI_SUCCESS Successfully update the Boot records.
236 EndOfPeiSignalPpiNotifyCallback (
237 IN EFI_PEI_SERVICES
**PeiServices
,
238 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
242 PEI_PCD_DATABASE
*Database
;
243 EFI_BOOT_MODE BootMode
;
246 EFI_PEI_FV_HANDLE VolumeHandle
;
247 EFI_PEI_FILE_HANDLE FileHandle
;
250 PEI_PCD_DATABASE
*PeiPcdDb
;
252 Status
= PeiServicesGetBootMode(&BootMode
);
253 ASSERT_EFI_ERROR (Status
);
256 // Don't need to report it on S3 boot.
258 if (BootMode
== BOOT_ON_S3_RESUME
) {
262 PeiPcdDb
= GetPcdDatabase();
263 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
) 0) {
265 // SkuId has been set. Don't need to report it to DXE phase.
271 // Get full PCD database from PcdPeim FileHandle
277 // Traverse all firmware volume instances
279 Status
= PeiServicesFfsFindNextVolume (Instance
, &VolumeHandle
);
281 // Error should not happen
283 ASSERT_EFI_ERROR (Status
);
286 // Find PcdDb file from the beginning in this firmware volume.
289 Status
= PeiServicesFfsFindFileByName (&gEfiCallerIdGuid
, VolumeHandle
, &FileHandle
);
290 if (!EFI_ERROR (Status
)) {
292 // Find PcdPeim FileHandle in this volume
297 // We cannot find PcdPeim in this firmware volume, then search the next volume.
303 // Find PEI PcdDb and Build second PcdDB GuidHob
305 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
306 ASSERT_EFI_ERROR (Status
);
307 Length
= PeiPcdDb
->LengthForAllSkus
;
308 Database
= BuildGuidHob (&gPcdDataBaseHobGuid
, Length
);
309 CopyMem (Database
, PcdDb
, Length
);
314 EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiSignalPpiNotifyList
[] = {
316 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
317 &gEfiEndOfPeiSignalPpiGuid
,
318 EndOfPeiSignalPpiNotifyCallback
323 Main entry for PCD PEIM driver.
325 This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.
327 @param FileHandle Handle of the file being invoked.
328 @param PeiServices Describes the list of possible PEI Services.
330 @return Status of install PCD_PPI
336 IN EFI_PEI_FILE_HANDLE FileHandle
,
337 IN CONST EFI_PEI_SERVICES
**PeiServices
342 Status
= PeiServicesRegisterForShadow (FileHandle
);
343 if (Status
== EFI_ALREADY_STARTED
) {
345 // This is now starting in memory, the second time starting.
347 EFI_PEI_PPI_DESCRIPTOR
*OldPpiList
;
348 EFI_PEI_PPI_DESCRIPTOR
*OldPpiList2
;
353 Status
= PeiServicesLocatePpi (
359 ASSERT_EFI_ERROR (Status
);
361 if (OldPpiList
!= NULL
) {
362 Status
= PeiServicesReInstallPpi (OldPpiList
, &mPpiList
[0]);
363 ASSERT_EFI_ERROR (Status
);
367 Status
= PeiServicesLocatePpi (
373 ASSERT_EFI_ERROR (Status
);
375 if (OldPpiList2
!= NULL
) {
376 Status
= PeiServicesReInstallPpi (OldPpiList2
, &mPpiList2
[0]);
377 ASSERT_EFI_ERROR (Status
);
381 Status
= PeiServicesLocatePpi (
387 ASSERT_EFI_ERROR (Status
);
389 if (OldPpiList
!= NULL
) {
390 Status
= PeiServicesReInstallPpi (OldPpiList
, &mPpiList
[1]);
391 ASSERT_EFI_ERROR (Status
);
395 Status
= PeiServicesLocatePpi (
396 &gEfiGetPcdInfoPpiGuid
,
401 ASSERT_EFI_ERROR (Status
);
403 if (OldPpiList2
!= NULL
) {
404 Status
= PeiServicesReInstallPpi (OldPpiList2
, &mPpiList2
[1]);
405 ASSERT_EFI_ERROR (Status
);
411 BuildPcdDatabase (FileHandle
);
414 // Install PCD_PPI and EFI_PEI_PCD_PPI.
416 Status
= PeiServicesInstallPpi (&mPpiList
[0]);
417 ASSERT_EFI_ERROR (Status
);
420 // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
422 Status
= PeiServicesInstallPpi (&mPpiList2
[0]);
423 ASSERT_EFI_ERROR (Status
);
425 Status
= PeiServicesNotifyPpi (&mEndOfPeiSignalPpiNotifyList
[0]);
426 ASSERT_EFI_ERROR (Status
);
428 Status
= PeiRegisterCallBackOnSet (
429 &gEfiMdeModulePkgTokenSpaceGuid
,
430 PcdToken(PcdSetNvStoreDefaultId
),
431 PcdSetNvStoreDefaultIdCallBack
433 ASSERT_EFI_ERROR (Status
);
439 Retrieve additional information associated with a PCD token in the default token space.
441 This includes information such as the type of value the TokenNumber is associated with as well as possible
442 human readable name that is associated with the token.
444 @param[in] TokenNumber The PCD token number.
445 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
446 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
448 @retval EFI_SUCCESS The PCD information was returned successfully.
449 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
453 PeiGetPcdInfoGetInfo (
454 IN UINTN TokenNumber
,
455 OUT EFI_PCD_INFO
*PcdInfo
458 return PeiGetPcdInfo (NULL
, TokenNumber
, PcdInfo
);
462 Retrieve additional information associated with a PCD token.
464 This includes information such as the type of value the TokenNumber is associated with as well as possible
465 human readable name that is associated with the token.
467 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
468 @param[in] TokenNumber The PCD token number.
469 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
470 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
472 @retval EFI_SUCCESS The PCD information was returned successfully.
473 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
477 PeiGetPcdInfoGetInfoEx (
478 IN CONST EFI_GUID
*Guid
,
479 IN UINTN TokenNumber
,
480 OUT EFI_PCD_INFO
*PcdInfo
483 return PeiGetPcdInfo (Guid
, TokenNumber
, PcdInfo
);
487 Retrieve the currently set SKU Id.
489 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
490 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
495 PeiGetPcdInfoGetSku (
499 return (UINTN
) GetPcdDatabase()->SystemSkuId
;
503 Sets the SKU value for subsequent calls to set or get PCD token values.
505 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
506 SetSku() is normally called only once by the system.
508 For each item (token), the database can hold a single value that applies to all SKUs,
509 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
510 SKU-specific values are called SKU enabled.
512 The SKU Id of zero is reserved as a default.
513 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
514 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
515 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
516 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
517 set for that Id, the results are unpredictable.
519 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
520 set values associated with a PCD token.
529 PEI_PCD_DATABASE
*PeiPcdDb
;
534 EFI_PEI_FV_HANDLE VolumeHandle
;
535 EFI_PEI_FILE_HANDLE FileHandle
;
538 PCD_DATABASE_SKU_DELTA
*SkuDelta
;
539 PCD_DATA_DELTA
*SkuDeltaData
;
541 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId 0x%lx is to be set.\n", (SKU_ID
) SkuId
));
543 PeiPcdDb
= GetPcdDatabase();
545 if (SkuId
== PeiPcdDb
->SystemSkuId
) {
547 // The input SKU Id is equal to current SKU Id, return directly.
549 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is same to current system Sku.\n"));
553 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
) 0) {
554 DEBUG ((DEBUG_ERROR
, "PcdPei - The SKU Id could be changed only once."));
557 "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
558 PeiPcdDb
->SystemSkuId
,
565 SkuIdTable
= (SKU_ID
*) ((UINT8
*) PeiPcdDb
+ PeiPcdDb
->SkuIdTableOffset
);
566 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
567 if (SkuId
== SkuIdTable
[Index
+ 1]) {
568 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is found in SkuId table.\n"));
573 if (Index
< SkuIdTable
[0]) {
575 // Get full PCD database from PcdPeim FileHandle
581 // Traverse all firmware volume instances
583 Status
= PeiServicesFfsFindNextVolume (Instance
, &VolumeHandle
);
585 // Error should not happen
587 ASSERT_EFI_ERROR (Status
);
590 // Find PcdDb file from the beginning in this firmware volume.
593 Status
= PeiServicesFfsFindFileByName (&gEfiCallerIdGuid
, VolumeHandle
, &FileHandle
);
594 if (!EFI_ERROR (Status
)) {
596 // Find PcdPeim FileHandle in this volume
601 // We cannot find PcdPeim in this firmware volume, then search the next volume.
607 // Find the delta data between the different Skus
609 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
610 ASSERT_EFI_ERROR (Status
);
611 Length
= PeiPcdDb
->LengthForAllSkus
;
612 Index
= (PeiPcdDb
->Length
+ 7) & (~7);
614 while (Index
< Length
) {
615 SkuDelta
= (PCD_DATABASE_SKU_DELTA
*) ((UINT8
*) PcdDb
+ Index
);
616 if (SkuDelta
->SkuId
== SkuId
&& SkuDelta
->SkuIdCompared
== 0) {
619 Index
= (Index
+ SkuDelta
->Length
+ 7) & (~7);
623 // Patch the delta data into current PCD database
625 if (Index
< Length
&& SkuDelta
!= NULL
) {
626 SkuDeltaData
= (PCD_DATA_DELTA
*) (SkuDelta
+ 1);
627 while ((UINT8
*) SkuDeltaData
< (UINT8
*) SkuDelta
+ SkuDelta
->Length
) {
628 *((UINT8
*) PeiPcdDb
+ SkuDeltaData
->Offset
) = (UINT8
) SkuDeltaData
->Value
;
631 PeiPcdDb
->SystemSkuId
= (SKU_ID
) SkuId
;
632 DEBUG ((DEBUG_INFO
, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID
) SkuId
));
638 // Invalid input SkuId, the default SKU Id will be still used for the system.
640 DEBUG ((DEBUG_ERROR
, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
646 Retrieves an 8-bit value for a given PCD token.
648 Retrieves the current byte-sized value for a PCD token number.
649 If the TokenNumber is invalid, the results are unpredictable.
651 @param[in] TokenNumber The PCD token number.
653 @return The UINT8 value.
662 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
666 Retrieves an 16-bit value for a given PCD token.
668 Retrieves the current 16-bits value for a PCD token number.
669 If the TokenNumber is invalid, the results are unpredictable.
671 @param[in] TokenNumber The PCD token number.
673 @return The UINT16 value.
682 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
686 Retrieves an 32-bit value for a given PCD token.
688 Retrieves the current 32-bits value for a PCD token number.
689 If the TokenNumber is invalid, the results are unpredictable.
691 @param[in] TokenNumber The PCD token number.
693 @return The UINT32 value.
702 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
706 Retrieves an 64-bit value for a given PCD token.
708 Retrieves the current 64-bits value for a PCD token number.
709 If the TokenNumber is invalid, the results are unpredictable.
711 @param[in] TokenNumber The PCD token number.
713 @return The UINT64 value.
722 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
726 Retrieves a pointer to a value for a given PCD token.
728 Retrieves the current pointer to the buffer for a PCD token number.
729 Do not make any assumptions about the alignment of the pointer that
730 is returned by this function call. If the TokenNumber is invalid,
731 the results are unpredictable.
733 @param[in] TokenNumber The PCD token number.
735 @return The pointer to the buffer to be retrieved.
744 return GetWorker (TokenNumber
, 0);
748 Retrieves a Boolean value for a given PCD token.
750 Retrieves the current boolean value for a PCD token number.
751 Do not make any assumptions about the alignment of the pointer that
752 is returned by this function call. If the TokenNumber is invalid,
753 the results are unpredictable.
755 @param[in] TokenNumber The PCD token number.
757 @return The Boolean value.
766 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
770 Retrieves the size of the value for a given PCD token.
772 Retrieves the current size of a particular PCD token.
773 If the TokenNumber is invalid, the results are unpredictable.
775 @param[in] TokenNumber The PCD token number.
777 @return The size of the value for the PCD token.
786 PEI_PCD_DATABASE
*PeiPcdDb
;
789 UINT32 LocalTokenCount
;
791 PeiPcdDb
= GetPcdDatabase ();
792 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
794 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
795 // We have to decrement TokenNumber by 1 to make it usable
796 // as the array index.
800 // EBC compiler is very choosy. It may report warning about comparison
801 // between UINTN and 0 . So we add 1 in each size of the
803 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
805 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
809 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
811 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
819 Retrieves an 8-bit value for a given PCD token.
821 Retrieves the 8-bit value of a particular PCD token.
822 If the TokenNumber is invalid or the token space
823 specified by Guid does not exist, the results are
826 @param[in] Guid The token space for the token number.
827 @param[in] ExTokenNumber The PCD token number.
829 @return The size 8-bit value for the PCD token.
835 IN CONST EFI_GUID
*Guid
,
836 IN UINTN ExTokenNumber
839 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
843 Retrieves an 16-bit value for a given PCD token.
845 Retrieves the 16-bit value of a particular PCD token.
846 If the TokenNumber is invalid or the token space
847 specified by Guid does not exist, the results are
850 @param[in] Guid The token space for the token number.
851 @param[in] ExTokenNumber The PCD token number.
853 @return The size 16-bit value for the PCD token.
859 IN CONST EFI_GUID
*Guid
,
860 IN UINTN ExTokenNumber
863 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
867 Retrieves an 32-bit value for a given PCD token.
869 Retrieves the 32-bit value of a particular PCD token.
870 If the TokenNumber is invalid or the token space
871 specified by Guid does not exist, the results are
874 @param[in] Guid The token space for the token number.
875 @param[in] ExTokenNumber The PCD token number.
877 @return The size 32-bit value for the PCD token.
883 IN CONST EFI_GUID
*Guid
,
884 IN UINTN ExTokenNumber
887 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
891 Retrieves an 64-bit value for a given PCD token.
893 Retrieves the 64-bit value of a particular PCD token.
894 If the TokenNumber is invalid or the token space
895 specified by Guid does not exist, the results are
898 @param[in] Guid The token space for the token number.
899 @param[in] ExTokenNumber The PCD token number.
901 @return The size 64-bit value for the PCD token.
907 IN CONST EFI_GUID
*Guid
,
908 IN UINTN ExTokenNumber
911 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
915 Retrieves a pointer to a value for a given PCD token.
917 Retrieves the current pointer to the buffer for a PCD token number.
918 Do not make any assumptions about the alignment of the pointer that
919 is returned by this function call. If the TokenNumber is invalid,
920 the results are unpredictable.
922 @param[in] Guid The token space for the token number.
923 @param[in] ExTokenNumber The PCD token number.
925 @return The pointer to the buffer to be retrieved.
931 IN CONST EFI_GUID
*Guid
,
932 IN UINTN ExTokenNumber
935 return ExGetWorker (Guid
, ExTokenNumber
, 0);
939 Retrieves an Boolean value for a given PCD token.
941 Retrieves the Boolean value of a particular PCD token.
942 If the TokenNumber is invalid or the token space
943 specified by Guid does not exist, the results are
946 @param[in] Guid The token space for the token number.
947 @param[in] ExTokenNumber The PCD token number.
949 @return The size Boolean value for the PCD token.
955 IN CONST EFI_GUID
*Guid
,
956 IN UINTN ExTokenNumber
959 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
963 Retrieves the size of the value for a given PCD token.
965 Retrieves the current size of a particular PCD token.
966 If the TokenNumber is invalid, the results are unpredictable.
968 @param[in] Guid The token space for the token number.
969 @param[in] ExTokenNumber The PCD token number.
971 @return The size of the value for the PCD token.
977 IN CONST EFI_GUID
*Guid
,
978 IN UINTN ExTokenNumber
981 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
985 Sets an 8-bit value for a given PCD token.
987 When the PCD service sets a value, it will check to ensure that the
988 size of the value being set is compatible with the Token's existing definition.
989 If it is not, an error will be returned.
991 @param[in] TokenNumber The PCD token number.
992 @param[in] Value The value to set for the PCD token.
994 @retval EFI_SUCCESS Procedure returned successfully.
995 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
996 being set was incompatible with a call to this function.
997 Use GetSize() to retrieve the size of the target data.
998 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1004 IN UINTN TokenNumber
,
1008 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1012 Sets an 16-bit value for a given PCD token.
1014 When the PCD service sets a value, it will check to ensure that the
1015 size of the value being set is compatible with the Token's existing definition.
1016 If it is not, an error will be returned.
1018 @param[in] TokenNumber The PCD token number.
1019 @param[in] Value The value to set for the PCD token.
1021 @retval EFI_SUCCESS Procedure returned successfully.
1022 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1023 being set was incompatible with a call to this function.
1024 Use GetSize() to retrieve the size of the target data.
1025 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1031 IN UINTN TokenNumber
,
1035 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1039 Sets an 32-bit value for a given PCD token.
1041 When the PCD service sets a value, it will check to ensure that the
1042 size of the value being set is compatible with the Token's existing definition.
1043 If it is not, an error will be returned.
1045 @param[in] TokenNumber The PCD token number.
1046 @param[in] Value The value to set for the PCD token.
1048 @retval EFI_SUCCESS Procedure returned successfully.
1049 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1050 being set was incompatible with a call to this function.
1051 Use GetSize() to retrieve the size of the target data.
1052 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1058 IN UINTN TokenNumber
,
1062 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1066 Sets an 64-bit value for a given PCD token.
1068 When the PCD service sets a value, it will check to ensure that the
1069 size of the value being set is compatible with the Token's existing definition.
1070 If it is not, an error will be returned.
1072 @param[in] TokenNumber The PCD token number.
1073 @param[in] Value The value to set for the PCD token.
1075 @retval EFI_SUCCESS Procedure returned successfully.
1076 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1077 being set was incompatible with a call to this function.
1078 Use GetSize() to retrieve the size of the target data.
1079 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1085 IN UINTN TokenNumber
,
1089 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1093 Sets a value of a specified size for a given PCD token.
1095 When the PCD service sets a value, it will check to ensure that the
1096 size of the value being set is compatible with the Token's existing definition.
1097 If it is not, an error will be returned.
1099 @param[in] TokenNumber The PCD token number.
1100 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1101 On input, if the SizeOfValue is greater than the maximum size supported
1102 for this TokenNumber then the output value of SizeOfValue will reflect
1103 the maximum size supported for this TokenNumber.
1104 @param[in] Buffer The buffer to set for the PCD token.
1106 @retval EFI_SUCCESS Procedure returned successfully.
1107 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1108 being set was incompatible with a call to this function.
1109 Use GetSize() to retrieve the size of the target data.
1110 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1116 IN UINTN TokenNumber
,
1117 IN OUT UINTN
*SizeOfBuffer
,
1121 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
1125 Sets an Boolean value for a given PCD token.
1127 When the PCD service sets a value, it will check to ensure that the
1128 size of the value being set is compatible with the Token's existing definition.
1129 If it is not, an error will be returned.
1131 @param[in] TokenNumber The PCD token number.
1132 @param[in] Value The value to set for the PCD token.
1134 @retval EFI_SUCCESS Procedure returned successfully.
1135 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1136 being set was incompatible with a call to this function.
1137 Use GetSize() to retrieve the size of the target data.
1138 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1144 IN UINTN TokenNumber
,
1148 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1152 Sets an 8-bit value for a given PCD token.
1154 When the PCD service sets a value, it will check to ensure that the
1155 size of the value being set is compatible with the Token's existing definition.
1156 If it is not, an error will be returned.
1158 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1159 @param[in] ExTokenNumber The PCD token number.
1160 @param[in] Value The value to set for the PCD token.
1162 @retval EFI_SUCCESS Procedure returned successfully.
1163 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1164 being set was incompatible with a call to this function.
1165 Use GetSize() to retrieve the size of the target data.
1166 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1172 IN CONST EFI_GUID
*Guid
,
1173 IN UINTN ExTokenNumber
,
1177 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1181 Sets an 16-bit value for a given PCD token.
1183 When the PCD service sets a value, it will check to ensure that the
1184 size of the value being set is compatible with the Token's existing definition.
1185 If it is not, an error will be returned.
1187 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1188 @param[in] ExTokenNumber The PCD token number.
1189 @param[in] Value The value to set for the PCD token.
1191 @retval EFI_SUCCESS Procedure returned successfully.
1192 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1193 being set was incompatible with a call to this function.
1194 Use GetSize() to retrieve the size of the target data.
1195 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1201 IN CONST EFI_GUID
*Guid
,
1202 IN UINTN ExTokenNumber
,
1206 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1210 Sets an 32-bit value for a given PCD token.
1212 When the PCD service sets a value, it will check to ensure that the
1213 size of the value being set is compatible with the Token's existing definition.
1214 If it is not, an error will be returned.
1216 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1217 @param[in] ExTokenNumber The PCD token number.
1218 @param[in] Value The value to set for the PCD token.
1220 @retval EFI_SUCCESS Procedure returned successfully.
1221 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1222 being set was incompatible with a call to this function.
1223 Use GetSize() to retrieve the size of the target data.
1224 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1230 IN CONST EFI_GUID
*Guid
,
1231 IN UINTN ExTokenNumber
,
1235 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1239 Sets an 64-bit value for a given PCD token.
1241 When the PCD service sets a value, it will check to ensure that the
1242 size of the value being set is compatible with the Token's existing definition.
1243 If it is not, an error will be returned.
1245 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1246 @param[in] ExTokenNumber The PCD token number.
1247 @param[in] Value The value to set for the PCD token.
1249 @retval EFI_SUCCESS Procedure returned successfully.
1250 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1251 being set was incompatible with a call to this function.
1252 Use GetSize() to retrieve the size of the target data.
1253 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1259 IN CONST EFI_GUID
*Guid
,
1260 IN UINTN ExTokenNumber
,
1264 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1268 Sets a value of a specified size for a given PCD token.
1270 When the PCD service sets a value, it will check to ensure that the
1271 size of the value being set is compatible with the Token's existing definition.
1272 If it is not, an error will be returned.
1274 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1275 @param[in] ExTokenNumber The PCD token number.
1276 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1277 On input, if the SizeOfValue is greater than the maximum size supported
1278 for this TokenNumber then the output value of SizeOfValue will reflect
1279 the maximum size supported for this TokenNumber.
1280 @param[in] Value The buffer to set for the PCD token.
1282 @retval EFI_SUCCESS Procedure returned successfully.
1283 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1284 being set was incompatible with a call to this function.
1285 Use GetSize() to retrieve the size of the target data.
1286 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1292 IN CONST EFI_GUID
*Guid
,
1293 IN UINTN ExTokenNumber
,
1294 IN OUT UINTN
*SizeOfBuffer
,
1298 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
1302 Sets an Boolean value for a given PCD token.
1304 When the PCD service sets a value, it will check to ensure that the
1305 size of the value being set is compatible with the Token's existing definition.
1306 If it is not, an error will be returned.
1308 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1309 @param [in] ExTokenNumber The PCD token number.
1310 @param [in] Value The value to set for the PCD token.
1312 @retval EFI_SUCCESS Procedure returned successfully.
1313 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1314 being set was incompatible with a call to this function.
1315 Use GetSize() to retrieve the size of the target data.
1316 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1322 IN CONST EFI_GUID
*Guid
,
1323 IN UINTN ExTokenNumber
,
1327 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1331 Specifies a function to be called anytime the value of a designated token is changed.
1333 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1334 @param[in] ExTokenNumber The PCD token number.
1335 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1337 @retval EFI_SUCCESS The PCD service has successfully established a call event
1338 for the CallBackToken requested.
1339 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1344 PeiRegisterCallBackOnSet (
1345 IN CONST EFI_GUID
*Guid OPTIONAL
,
1346 IN UINTN ExTokenNumber
,
1347 IN PCD_PPI_CALLBACK CallBackFunction
1350 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1351 return EFI_UNSUPPORTED
;
1354 if (CallBackFunction
== NULL
) {
1355 return EFI_INVALID_PARAMETER
;
1358 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
1362 Cancels a previously set callback function for a particular PCD token number.
1364 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1365 @param[in] ExTokenNumber The PCD token number.
1366 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1368 @retval EFI_SUCCESS The PCD service has successfully established a call event
1369 for the CallBackToken requested.
1370 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1375 PcdUnRegisterCallBackOnSet (
1376 IN CONST EFI_GUID
*Guid OPTIONAL
,
1377 IN UINTN ExTokenNumber
,
1378 IN PCD_PPI_CALLBACK CallBackFunction
1381 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1382 return EFI_UNSUPPORTED
;
1385 if (CallBackFunction
== NULL
) {
1386 return EFI_INVALID_PARAMETER
;
1389 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1393 Retrieves the next valid token number in a given namespace.
1395 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1396 and one cannot a priori know what token numbers are valid in the database.
1398 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1399 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1400 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1401 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1402 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1403 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1404 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1405 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1408 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1409 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1410 is being made to retrieve tokens from the default token space.
1411 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1413 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1414 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1419 PeiPcdGetNextToken (
1420 IN CONST EFI_GUID
*Guid OPTIONAL
,
1421 IN OUT UINTN
*TokenNumber
1425 PEI_PCD_DATABASE
*PeiPcdDb
;
1426 EFI_GUID
*MatchGuid
;
1427 EFI_GUID
*GuidTable
;
1428 DYNAMICEX_MAPPING
*ExMapTable
;
1431 BOOLEAN PeiExMapTableEmpty
;
1432 UINTN PeiNexTokenNumber
;
1434 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1435 return EFI_UNSUPPORTED
;
1438 PeiPcdDb
= GetPcdDatabase ();
1439 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1440 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1442 if (PeiPcdDb
->ExTokenCount
== 0) {
1443 PeiExMapTableEmpty
= TRUE
;
1445 PeiExMapTableEmpty
= FALSE
;
1448 if (*TokenNumber
> PeiNexTokenNumber
) {
1449 return EFI_NOT_FOUND
;
1452 if (*TokenNumber
> PeiNexTokenNumber
) {
1453 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1454 return EFI_NOT_FOUND
;
1458 if (PeiExMapTableEmpty
) {
1459 return EFI_NOT_FOUND
;
1462 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(EFI_GUID
), Guid
);
1464 if (MatchGuid
== NULL
) {
1465 return EFI_NOT_FOUND
;
1468 GuidTableIdx
= MatchGuid
- GuidTable
;
1470 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1474 // Locate the GUID in ExMapTable first.
1476 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1477 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1485 // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first
1486 // token number in found token space.
1488 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1489 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1493 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1494 if ((ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) && (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
)) {
1499 while (Index
< PeiPcdDb
->ExTokenCount
) {
1501 if (Index
== PeiPcdDb
->ExTokenCount
) {
1503 // Exceed the length of ExMap Table
1505 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1506 return EFI_NOT_FOUND
;
1507 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1509 // Found the next match
1511 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1518 return EFI_NOT_FOUND
;
1522 Retrieves the next valid PCD token namespace for a given namespace.
1524 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1525 token namespaces on a platform.
1527 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1528 namespace from which the search will start. On output, it designates the next valid
1529 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1530 space of the current platform is returned. If the search cannot locate the next valid
1531 token namespace, an error is returned and the value of *Guid is undefined.
1533 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1534 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1539 PeiPcdGetNextTokenSpace (
1540 IN OUT CONST EFI_GUID
**Guid
1544 EFI_GUID
*MatchGuid
;
1545 PEI_PCD_DATABASE
*PeiPcdDb
;
1546 DYNAMICEX_MAPPING
*ExMapTable
;
1550 BOOLEAN PeiExMapTableEmpty
;
1551 EFI_GUID
*GuidTable
;
1553 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1554 return EFI_UNSUPPORTED
;
1557 ASSERT (Guid
!= NULL
);
1559 PeiPcdDb
= GetPcdDatabase ();
1561 if (PeiPcdDb
->ExTokenCount
== 0) {
1562 PeiExMapTableEmpty
= TRUE
;
1564 PeiExMapTableEmpty
= FALSE
;
1567 if (PeiExMapTableEmpty
) {
1568 return EFI_NOT_FOUND
;
1571 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1572 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1574 if (*Guid
== NULL
) {
1576 // return the first Token Space Guid.
1578 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1582 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(GuidTable
[0]), *Guid
);
1584 if (MatchGuid
== NULL
) {
1585 return EFI_NOT_FOUND
;
1588 GuidTableIdx
= MatchGuid
- GuidTable
;
1591 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1592 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1600 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1601 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1603 for (Index2
= 0 ; Index2
< Index
; Index2
++) {
1604 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1606 // This token namespace should have been found and output at preceding getting.
1613 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1621 return EFI_NOT_FOUND
;
1626 Get PCD value's size for POINTER type PCD.
1628 The POINTER type PCD's value will be stored into a buffer in specified size.
1629 The max size of this PCD's value is described in PCD's definition in DEC file.
1631 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1632 @param MaxSize Maximum size of PCD's value
1633 @param Database Pcd database in PEI phase.
1635 @return PCD value's size for POINTER type PCD.
1640 IN UINTN LocalTokenNumberTableIdx
,
1642 IN PEI_PCD_DATABASE
*Database
1646 UINTN LocalTokenNumber
;
1647 SIZE_INFO
*SizeTable
;
1649 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1651 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1653 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1655 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1657 *MaxSize
= SizeTable
[SizeTableIdx
];
1659 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1662 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1664 // We have only two entry for VPD enabled PCD entry:
1667 // We consider current size is equal to MAX size.
1672 // We have only two entry for Non-Sku enabled PCD entry:
1676 return SizeTable
[SizeTableIdx
+ 1];
1681 Set PCD value's size for POINTER type PCD.
1683 The POINTER type PCD's value will be stored into a buffer in specified size.
1684 The max size of this PCD's value is described in PCD's definition in DEC file.
1686 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1687 @param CurrentSize Maximum size of PCD's value
1688 @param Database Pcd database in PEI phase.
1690 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1691 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1696 IN UINTN LocalTokenNumberTableIdx
,
1697 IN OUT UINTN
*CurrentSize
,
1698 IN PEI_PCD_DATABASE
*Database
1702 UINTN LocalTokenNumber
;
1703 SIZE_INFO
*SizeTable
;
1706 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1708 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1710 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1712 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1714 MaxSize
= SizeTable
[SizeTableIdx
];
1716 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1719 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1721 // We shouldn't come here as we don't support SET for VPD
1726 if ((*CurrentSize
> MaxSize
) ||
1727 (*CurrentSize
== MAX_ADDRESS
)) {
1728 *CurrentSize
= MaxSize
;
1733 // We have only two entry for Non-Sku enabled PCD entry:
1737 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;