2 All Pcd Ppi services are implemented here.
4 Copyright (c) 2006 - 2018, 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 BuildPcdDatabase (FileHandle
);
345 // Install PCD_PPI and EFI_PEI_PCD_PPI.
347 Status
= PeiServicesInstallPpi (&mPpiList
[0]);
348 ASSERT_EFI_ERROR (Status
);
351 // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
353 Status
= PeiServicesInstallPpi (&mPpiList2
[0]);
354 ASSERT_EFI_ERROR (Status
);
356 Status
= PeiServicesNotifyPpi (&mEndOfPeiSignalPpiNotifyList
[0]);
357 ASSERT_EFI_ERROR (Status
);
359 Status
= PeiRegisterCallBackOnSet (
360 &gEfiMdeModulePkgTokenSpaceGuid
,
361 PcdToken(PcdSetNvStoreDefaultId
),
362 PcdSetNvStoreDefaultIdCallBack
364 ASSERT_EFI_ERROR (Status
);
370 Retrieve additional information associated with a PCD token in the default token space.
372 This includes information such as the type of value the TokenNumber is associated with as well as possible
373 human readable name that is associated with the token.
375 @param[in] TokenNumber The PCD token number.
376 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
377 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
379 @retval EFI_SUCCESS The PCD information was returned successfully.
380 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
384 PeiGetPcdInfoGetInfo (
385 IN UINTN TokenNumber
,
386 OUT EFI_PCD_INFO
*PcdInfo
389 return PeiGetPcdInfo (NULL
, TokenNumber
, PcdInfo
);
393 Retrieve additional information associated with a PCD token.
395 This includes information such as the type of value the TokenNumber is associated with as well as possible
396 human readable name that is associated with the token.
398 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
399 @param[in] TokenNumber The PCD token number.
400 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
401 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
403 @retval EFI_SUCCESS The PCD information was returned successfully.
404 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
408 PeiGetPcdInfoGetInfoEx (
409 IN CONST EFI_GUID
*Guid
,
410 IN UINTN TokenNumber
,
411 OUT EFI_PCD_INFO
*PcdInfo
414 return PeiGetPcdInfo (Guid
, TokenNumber
, PcdInfo
);
418 Retrieve the currently set SKU Id.
420 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
421 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
426 PeiGetPcdInfoGetSku (
430 return (UINTN
) GetPcdDatabase()->SystemSkuId
;
434 Sets the SKU value for subsequent calls to set or get PCD token values.
436 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
437 SetSku() is normally called only once by the system.
439 For each item (token), the database can hold a single value that applies to all SKUs,
440 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
441 SKU-specific values are called SKU enabled.
443 The SKU Id of zero is reserved as a default.
444 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
445 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
446 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
447 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
448 set for that Id, the results are unpredictable.
450 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
451 set values associated with a PCD token.
460 PEI_PCD_DATABASE
*PeiPcdDb
;
465 EFI_PEI_FV_HANDLE VolumeHandle
;
466 EFI_PEI_FILE_HANDLE FileHandle
;
469 PCD_DATABASE_SKU_DELTA
*SkuDelta
;
470 PCD_DATA_DELTA
*SkuDeltaData
;
472 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId 0x%lx is to be set.\n", (SKU_ID
) SkuId
));
474 PeiPcdDb
= GetPcdDatabase();
476 if (SkuId
== PeiPcdDb
->SystemSkuId
) {
478 // The input SKU Id is equal to current SKU Id, return directly.
480 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is same to current system Sku.\n"));
484 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
) 0) {
485 DEBUG ((DEBUG_ERROR
, "PcdPei - The SKU Id could be changed only once."));
488 "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
489 PeiPcdDb
->SystemSkuId
,
496 SkuIdTable
= (SKU_ID
*) ((UINT8
*) PeiPcdDb
+ PeiPcdDb
->SkuIdTableOffset
);
497 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
498 if (SkuId
== SkuIdTable
[Index
+ 1]) {
499 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is found in SkuId table.\n"));
504 if (Index
< SkuIdTable
[0]) {
506 // Get full PCD database from PcdPeim FileHandle
512 // Traverse all firmware volume instances
514 Status
= PeiServicesFfsFindNextVolume (Instance
, &VolumeHandle
);
516 // Error should not happen
518 ASSERT_EFI_ERROR (Status
);
521 // Find PcdDb file from the beginning in this firmware volume.
524 Status
= PeiServicesFfsFindFileByName (&gEfiCallerIdGuid
, VolumeHandle
, &FileHandle
);
525 if (!EFI_ERROR (Status
)) {
527 // Find PcdPeim FileHandle in this volume
532 // We cannot find PcdPeim in this firmware volume, then search the next volume.
538 // Find the delta data between the different Skus
540 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
541 ASSERT_EFI_ERROR (Status
);
542 Length
= PeiPcdDb
->LengthForAllSkus
;
543 Index
= (PeiPcdDb
->Length
+ 7) & (~7);
545 while (Index
< Length
) {
546 SkuDelta
= (PCD_DATABASE_SKU_DELTA
*) ((UINT8
*) PcdDb
+ Index
);
547 if (SkuDelta
->SkuId
== SkuId
&& SkuDelta
->SkuIdCompared
== 0) {
550 Index
= (Index
+ SkuDelta
->Length
+ 7) & (~7);
554 // Patch the delta data into current PCD database
556 if (Index
< Length
&& SkuDelta
!= NULL
) {
557 SkuDeltaData
= (PCD_DATA_DELTA
*) (SkuDelta
+ 1);
558 while ((UINT8
*) SkuDeltaData
< (UINT8
*) SkuDelta
+ SkuDelta
->Length
) {
559 *((UINT8
*) PeiPcdDb
+ SkuDeltaData
->Offset
) = (UINT8
) SkuDeltaData
->Value
;
562 PeiPcdDb
->SystemSkuId
= (SKU_ID
) SkuId
;
563 DEBUG ((DEBUG_INFO
, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID
) SkuId
));
569 // Invalid input SkuId, the default SKU Id will be still used for the system.
571 DEBUG ((DEBUG_ERROR
, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
577 Retrieves an 8-bit value for a given PCD token.
579 Retrieves the current byte-sized value for a PCD token number.
580 If the TokenNumber is invalid, the results are unpredictable.
582 @param[in] TokenNumber The PCD token number.
584 @return The UINT8 value.
593 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
597 Retrieves an 16-bit value for a given PCD token.
599 Retrieves the current 16-bits value for a PCD token number.
600 If the TokenNumber is invalid, the results are unpredictable.
602 @param[in] TokenNumber The PCD token number.
604 @return The UINT16 value.
613 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
617 Retrieves an 32-bit value for a given PCD token.
619 Retrieves the current 32-bits value for a PCD token number.
620 If the TokenNumber is invalid, the results are unpredictable.
622 @param[in] TokenNumber The PCD token number.
624 @return The UINT32 value.
633 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
637 Retrieves an 64-bit value for a given PCD token.
639 Retrieves the current 64-bits value for a PCD token number.
640 If the TokenNumber is invalid, the results are unpredictable.
642 @param[in] TokenNumber The PCD token number.
644 @return The UINT64 value.
653 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
657 Retrieves a pointer to a value for a given PCD token.
659 Retrieves the current pointer to the buffer for a PCD token number.
660 Do not make any assumptions about the alignment of the pointer that
661 is returned by this function call. If the TokenNumber is invalid,
662 the results are unpredictable.
664 @param[in] TokenNumber The PCD token number.
666 @return The pointer to the buffer to be retrieved.
675 return GetWorker (TokenNumber
, 0);
679 Retrieves a Boolean value for a given PCD token.
681 Retrieves the current boolean value for a PCD token number.
682 Do not make any assumptions about the alignment of the pointer that
683 is returned by this function call. If the TokenNumber is invalid,
684 the results are unpredictable.
686 @param[in] TokenNumber The PCD token number.
688 @return The Boolean value.
697 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
701 Retrieves the size of the value for a given PCD token.
703 Retrieves the current size of a particular PCD token.
704 If the TokenNumber is invalid, the results are unpredictable.
706 @param[in] TokenNumber The PCD token number.
708 @return The size of the value for the PCD token.
717 PEI_PCD_DATABASE
*PeiPcdDb
;
720 UINT32 LocalTokenCount
;
722 PeiPcdDb
= GetPcdDatabase ();
723 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
725 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
726 // We have to decrement TokenNumber by 1 to make it usable
727 // as the array index.
731 // EBC compiler is very choosy. It may report warning about comparison
732 // between UINTN and 0 . So we add 1 in each size of the
734 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
736 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
740 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
742 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
750 Retrieves an 8-bit value for a given PCD token.
752 Retrieves the 8-bit value of a particular PCD token.
753 If the TokenNumber is invalid or the token space
754 specified by Guid does not exist, the results are
757 @param[in] Guid The token space for the token number.
758 @param[in] ExTokenNumber The PCD token number.
760 @return The size 8-bit value for the PCD token.
766 IN CONST EFI_GUID
*Guid
,
767 IN UINTN ExTokenNumber
770 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
774 Retrieves an 16-bit value for a given PCD token.
776 Retrieves the 16-bit value of a particular PCD token.
777 If the TokenNumber is invalid or the token space
778 specified by Guid does not exist, the results are
781 @param[in] Guid The token space for the token number.
782 @param[in] ExTokenNumber The PCD token number.
784 @return The size 16-bit value for the PCD token.
790 IN CONST EFI_GUID
*Guid
,
791 IN UINTN ExTokenNumber
794 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
798 Retrieves an 32-bit value for a given PCD token.
800 Retrieves the 32-bit value of a particular PCD token.
801 If the TokenNumber is invalid or the token space
802 specified by Guid does not exist, the results are
805 @param[in] Guid The token space for the token number.
806 @param[in] ExTokenNumber The PCD token number.
808 @return The size 32-bit value for the PCD token.
814 IN CONST EFI_GUID
*Guid
,
815 IN UINTN ExTokenNumber
818 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
822 Retrieves an 64-bit value for a given PCD token.
824 Retrieves the 64-bit value of a particular PCD token.
825 If the TokenNumber is invalid or the token space
826 specified by Guid does not exist, the results are
829 @param[in] Guid The token space for the token number.
830 @param[in] ExTokenNumber The PCD token number.
832 @return The size 64-bit value for the PCD token.
838 IN CONST EFI_GUID
*Guid
,
839 IN UINTN ExTokenNumber
842 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
846 Retrieves a pointer to a value for a given PCD token.
848 Retrieves the current pointer to the buffer for a PCD token number.
849 Do not make any assumptions about the alignment of the pointer that
850 is returned by this function call. If the TokenNumber is invalid,
851 the results are unpredictable.
853 @param[in] Guid The token space for the token number.
854 @param[in] ExTokenNumber The PCD token number.
856 @return The pointer to the buffer to be retrieved.
862 IN CONST EFI_GUID
*Guid
,
863 IN UINTN ExTokenNumber
866 return ExGetWorker (Guid
, ExTokenNumber
, 0);
870 Retrieves an Boolean value for a given PCD token.
872 Retrieves the Boolean value of a particular PCD token.
873 If the TokenNumber is invalid or the token space
874 specified by Guid does not exist, the results are
877 @param[in] Guid The token space for the token number.
878 @param[in] ExTokenNumber The PCD token number.
880 @return The size Boolean value for the PCD token.
886 IN CONST EFI_GUID
*Guid
,
887 IN UINTN ExTokenNumber
890 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
894 Retrieves the size of the value for a given PCD token.
896 Retrieves the current size of a particular PCD token.
897 If the TokenNumber is invalid, the results are unpredictable.
899 @param[in] Guid The token space for the token number.
900 @param[in] ExTokenNumber The PCD token number.
902 @return The size of the value for the PCD token.
908 IN CONST EFI_GUID
*Guid
,
909 IN UINTN ExTokenNumber
912 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
916 Sets an 8-bit value for a given PCD token.
918 When the PCD service sets a value, it will check to ensure that the
919 size of the value being set is compatible with the Token's existing definition.
920 If it is not, an error will be returned.
922 @param[in] TokenNumber The PCD token number.
923 @param[in] Value The value to set for the PCD token.
925 @retval EFI_SUCCESS Procedure returned successfully.
926 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
927 being set was incompatible with a call to this function.
928 Use GetSize() to retrieve the size of the target data.
929 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
935 IN UINTN TokenNumber
,
939 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
943 Sets an 16-bit value for a given PCD token.
945 When the PCD service sets a value, it will check to ensure that the
946 size of the value being set is compatible with the Token's existing definition.
947 If it is not, an error will be returned.
949 @param[in] TokenNumber The PCD token number.
950 @param[in] Value The value to set for the PCD token.
952 @retval EFI_SUCCESS Procedure returned successfully.
953 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
954 being set was incompatible with a call to this function.
955 Use GetSize() to retrieve the size of the target data.
956 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
962 IN UINTN TokenNumber
,
966 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
970 Sets an 32-bit value for a given PCD token.
972 When the PCD service sets a value, it will check to ensure that the
973 size of the value being set is compatible with the Token's existing definition.
974 If it is not, an error will be returned.
976 @param[in] TokenNumber The PCD token number.
977 @param[in] Value The value to set for the PCD token.
979 @retval EFI_SUCCESS Procedure returned successfully.
980 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
981 being set was incompatible with a call to this function.
982 Use GetSize() to retrieve the size of the target data.
983 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
989 IN UINTN TokenNumber
,
993 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
997 Sets an 64-bit value for a given PCD token.
999 When the PCD service sets a value, it will check to ensure that the
1000 size of the value being set is compatible with the Token's existing definition.
1001 If it is not, an error will be returned.
1003 @param[in] TokenNumber The PCD token number.
1004 @param[in] Value The value to set for the PCD token.
1006 @retval EFI_SUCCESS Procedure returned successfully.
1007 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1008 being set was incompatible with a call to this function.
1009 Use GetSize() to retrieve the size of the target data.
1010 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1016 IN UINTN TokenNumber
,
1020 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1024 Sets a value of a specified size for a given PCD token.
1026 When the PCD service sets a value, it will check to ensure that the
1027 size of the value being set is compatible with the Token's existing definition.
1028 If it is not, an error will be returned.
1030 @param[in] TokenNumber The PCD token number.
1031 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1032 On input, if the SizeOfValue is greater than the maximum size supported
1033 for this TokenNumber then the output value of SizeOfValue will reflect
1034 the maximum size supported for this TokenNumber.
1035 @param[in] Buffer The buffer to set for the PCD token.
1037 @retval EFI_SUCCESS Procedure returned successfully.
1038 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1039 being set was incompatible with a call to this function.
1040 Use GetSize() to retrieve the size of the target data.
1041 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1047 IN UINTN TokenNumber
,
1048 IN OUT UINTN
*SizeOfBuffer
,
1052 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
1056 Sets an Boolean value for a given PCD token.
1058 When the PCD service sets a value, it will check to ensure that the
1059 size of the value being set is compatible with the Token's existing definition.
1060 If it is not, an error will be returned.
1062 @param[in] TokenNumber The PCD token number.
1063 @param[in] Value The value to set for the PCD token.
1065 @retval EFI_SUCCESS Procedure returned successfully.
1066 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1067 being set was incompatible with a call to this function.
1068 Use GetSize() to retrieve the size of the target data.
1069 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1075 IN UINTN TokenNumber
,
1079 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1083 Sets an 8-bit value for a given PCD token.
1085 When the PCD service sets a value, it will check to ensure that the
1086 size of the value being set is compatible with the Token's existing definition.
1087 If it is not, an error will be returned.
1089 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1090 @param[in] ExTokenNumber The PCD token number.
1091 @param[in] Value The value to set for the PCD token.
1093 @retval EFI_SUCCESS Procedure returned successfully.
1094 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1095 being set was incompatible with a call to this function.
1096 Use GetSize() to retrieve the size of the target data.
1097 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1103 IN CONST EFI_GUID
*Guid
,
1104 IN UINTN ExTokenNumber
,
1108 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1112 Sets an 16-bit value for a given PCD token.
1114 When the PCD service sets a value, it will check to ensure that the
1115 size of the value being set is compatible with the Token's existing definition.
1116 If it is not, an error will be returned.
1118 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1119 @param[in] ExTokenNumber The PCD token number.
1120 @param[in] Value The value to set for the PCD token.
1122 @retval EFI_SUCCESS Procedure returned successfully.
1123 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1124 being set was incompatible with a call to this function.
1125 Use GetSize() to retrieve the size of the target data.
1126 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1132 IN CONST EFI_GUID
*Guid
,
1133 IN UINTN ExTokenNumber
,
1137 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1141 Sets an 32-bit value for a given PCD token.
1143 When the PCD service sets a value, it will check to ensure that the
1144 size of the value being set is compatible with the Token's existing definition.
1145 If it is not, an error will be returned.
1147 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1148 @param[in] ExTokenNumber The PCD token number.
1149 @param[in] Value The value to set for the PCD token.
1151 @retval EFI_SUCCESS Procedure returned successfully.
1152 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1153 being set was incompatible with a call to this function.
1154 Use GetSize() to retrieve the size of the target data.
1155 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1161 IN CONST EFI_GUID
*Guid
,
1162 IN UINTN ExTokenNumber
,
1166 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1170 Sets an 64-bit value for a given PCD token.
1172 When the PCD service sets a value, it will check to ensure that the
1173 size of the value being set is compatible with the Token's existing definition.
1174 If it is not, an error will be returned.
1176 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1177 @param[in] ExTokenNumber The PCD token number.
1178 @param[in] Value The value to set for the PCD token.
1180 @retval EFI_SUCCESS Procedure returned successfully.
1181 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1182 being set was incompatible with a call to this function.
1183 Use GetSize() to retrieve the size of the target data.
1184 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1190 IN CONST EFI_GUID
*Guid
,
1191 IN UINTN ExTokenNumber
,
1195 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1199 Sets a value of a specified size for a given PCD token.
1201 When the PCD service sets a value, it will check to ensure that the
1202 size of the value being set is compatible with the Token's existing definition.
1203 If it is not, an error will be returned.
1205 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1206 @param[in] ExTokenNumber The PCD token number.
1207 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1208 On input, if the SizeOfValue is greater than the maximum size supported
1209 for this TokenNumber then the output value of SizeOfValue will reflect
1210 the maximum size supported for this TokenNumber.
1211 @param[in] Value The buffer to set for the PCD token.
1213 @retval EFI_SUCCESS Procedure returned successfully.
1214 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1215 being set was incompatible with a call to this function.
1216 Use GetSize() to retrieve the size of the target data.
1217 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1223 IN CONST EFI_GUID
*Guid
,
1224 IN UINTN ExTokenNumber
,
1225 IN OUT UINTN
*SizeOfBuffer
,
1229 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
1233 Sets an Boolean value for a given PCD token.
1235 When the PCD service sets a value, it will check to ensure that the
1236 size of the value being set is compatible with the Token's existing definition.
1237 If it is not, an error will be returned.
1239 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1240 @param [in] ExTokenNumber The PCD token number.
1241 @param [in] Value The value to set for the PCD token.
1243 @retval EFI_SUCCESS Procedure returned successfully.
1244 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1245 being set was incompatible with a call to this function.
1246 Use GetSize() to retrieve the size of the target data.
1247 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1253 IN CONST EFI_GUID
*Guid
,
1254 IN UINTN ExTokenNumber
,
1258 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1262 Specifies a function to be called anytime the value of a designated token is changed.
1264 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1265 @param[in] ExTokenNumber The PCD token number.
1266 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1268 @retval EFI_SUCCESS The PCD service has successfully established a call event
1269 for the CallBackToken requested.
1270 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1275 PeiRegisterCallBackOnSet (
1276 IN CONST EFI_GUID
*Guid
, OPTIONAL
1277 IN UINTN ExTokenNumber
,
1278 IN PCD_PPI_CALLBACK CallBackFunction
1281 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1282 return EFI_UNSUPPORTED
;
1285 if (CallBackFunction
== NULL
) {
1286 return EFI_INVALID_PARAMETER
;
1289 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
1293 Cancels a previously set callback function for a particular PCD token number.
1295 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1296 @param[in] ExTokenNumber The PCD token number.
1297 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1299 @retval EFI_SUCCESS The PCD service has successfully established a call event
1300 for the CallBackToken requested.
1301 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1306 PcdUnRegisterCallBackOnSet (
1307 IN CONST EFI_GUID
*Guid
, OPTIONAL
1308 IN UINTN ExTokenNumber
,
1309 IN PCD_PPI_CALLBACK CallBackFunction
1312 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1313 return EFI_UNSUPPORTED
;
1316 if (CallBackFunction
== NULL
) {
1317 return EFI_INVALID_PARAMETER
;
1320 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1324 Retrieves the next valid token number in a given namespace.
1326 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1327 and one cannot a priori know what token numbers are valid in the database.
1329 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1330 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1331 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1332 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1333 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1334 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1335 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1336 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1339 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1340 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1341 is being made to retrieve tokens from the default token space.
1342 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1344 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1345 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1350 PeiPcdGetNextToken (
1351 IN CONST EFI_GUID
*Guid
, OPTIONAL
1352 IN OUT UINTN
*TokenNumber
1356 PEI_PCD_DATABASE
*PeiPcdDb
;
1357 EFI_GUID
*MatchGuid
;
1358 EFI_GUID
*GuidTable
;
1359 DYNAMICEX_MAPPING
*ExMapTable
;
1362 BOOLEAN PeiExMapTableEmpty
;
1363 UINTN PeiNexTokenNumber
;
1365 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1366 return EFI_UNSUPPORTED
;
1369 PeiPcdDb
= GetPcdDatabase ();
1370 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1371 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1373 if (PeiPcdDb
->ExTokenCount
== 0) {
1374 PeiExMapTableEmpty
= TRUE
;
1376 PeiExMapTableEmpty
= FALSE
;
1379 if (*TokenNumber
> PeiNexTokenNumber
) {
1380 return EFI_NOT_FOUND
;
1383 if (*TokenNumber
> PeiNexTokenNumber
) {
1384 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1385 return EFI_NOT_FOUND
;
1389 if (PeiExMapTableEmpty
) {
1390 return EFI_NOT_FOUND
;
1393 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(EFI_GUID
), Guid
);
1395 if (MatchGuid
== NULL
) {
1396 return EFI_NOT_FOUND
;
1399 GuidTableIdx
= MatchGuid
- GuidTable
;
1401 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1405 // Locate the GUID in ExMapTable first.
1407 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1408 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1416 // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first
1417 // token number in found token space.
1419 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1420 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1424 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1425 if ((ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) && (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
)) {
1430 while (Index
< PeiPcdDb
->ExTokenCount
) {
1432 if (Index
== PeiPcdDb
->ExTokenCount
) {
1434 // Exceed the length of ExMap Table
1436 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1437 return EFI_NOT_FOUND
;
1438 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1440 // Found the next match
1442 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1449 return EFI_NOT_FOUND
;
1453 Retrieves the next valid PCD token namespace for a given namespace.
1455 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1456 token namespaces on a platform.
1458 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1459 namespace from which the search will start. On output, it designates the next valid
1460 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1461 space of the current platform is returned. If the search cannot locate the next valid
1462 token namespace, an error is returned and the value of *Guid is undefined.
1464 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1465 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1470 PeiPcdGetNextTokenSpace (
1471 IN OUT CONST EFI_GUID
**Guid
1475 EFI_GUID
*MatchGuid
;
1476 PEI_PCD_DATABASE
*PeiPcdDb
;
1477 DYNAMICEX_MAPPING
*ExMapTable
;
1481 BOOLEAN PeiExMapTableEmpty
;
1482 EFI_GUID
*GuidTable
;
1484 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1485 return EFI_UNSUPPORTED
;
1488 ASSERT (Guid
!= NULL
);
1490 PeiPcdDb
= GetPcdDatabase ();
1492 if (PeiPcdDb
->ExTokenCount
== 0) {
1493 PeiExMapTableEmpty
= TRUE
;
1495 PeiExMapTableEmpty
= FALSE
;
1498 if (PeiExMapTableEmpty
) {
1499 return EFI_NOT_FOUND
;
1502 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1503 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1505 if (*Guid
== NULL
) {
1507 // return the first Token Space Guid.
1509 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1513 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(GuidTable
[0]), *Guid
);
1515 if (MatchGuid
== NULL
) {
1516 return EFI_NOT_FOUND
;
1519 GuidTableIdx
= MatchGuid
- GuidTable
;
1522 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1523 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1531 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1532 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1534 for (Index2
= 0 ; Index2
< Index
; Index2
++) {
1535 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1537 // This token namespace should have been found and output at preceding getting.
1544 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1552 return EFI_NOT_FOUND
;
1557 Get PCD value's size for POINTER type PCD.
1559 The POINTER type PCD's value will be stored into a buffer in specified size.
1560 The max size of this PCD's value is described in PCD's definition in DEC file.
1562 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1563 @param MaxSize Maximum size of PCD's value
1564 @param Database Pcd database in PEI phase.
1566 @return PCD value's size for POINTER type PCD.
1571 IN UINTN LocalTokenNumberTableIdx
,
1573 IN PEI_PCD_DATABASE
*Database
1577 UINTN LocalTokenNumber
;
1578 SIZE_INFO
*SizeTable
;
1580 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1582 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1584 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1586 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1588 *MaxSize
= SizeTable
[SizeTableIdx
];
1590 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1593 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1595 // We have only two entry for VPD enabled PCD entry:
1598 // We consider current size is equal to MAX size.
1603 // We have only two entry for Non-Sku enabled PCD entry:
1607 return SizeTable
[SizeTableIdx
+ 1];
1612 Set PCD value's size for POINTER type PCD.
1614 The POINTER type PCD's value will be stored into a buffer in specified size.
1615 The max size of this PCD's value is described in PCD's definition in DEC file.
1617 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1618 @param CurrentSize Maximum size of PCD's value
1619 @param Database Pcd database in PEI phase.
1621 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1622 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1627 IN UINTN LocalTokenNumberTableIdx
,
1628 IN OUT UINTN
*CurrentSize
,
1629 IN PEI_PCD_DATABASE
*Database
1633 UINTN LocalTokenNumber
;
1634 SIZE_INFO
*SizeTable
;
1637 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1639 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1641 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1643 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1645 MaxSize
= SizeTable
[SizeTableIdx
];
1647 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1650 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1652 // We shouldn't come here as we don't support SET for VPD
1657 if ((*CurrentSize
> MaxSize
) ||
1658 (*CurrentSize
== MAX_ADDRESS
)) {
1659 *CurrentSize
= MaxSize
;
1664 // We have only two entry for Non-Sku enabled PCD entry:
1668 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;