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
)) {
191 // Find the matched SkuId and DefaultId in the remaining section
193 Index
= sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER
) + ((DataHeader
->DataSize
+ 7) & (~7));
194 DataHeader
= (PCD_DEFAULT_DATA
*)(DataBuffer
+ Index
);
195 while (!IsFound
&& Index
< FullSize
&& DataHeader
->DataSize
!= 0xFFFFFFFF) {
196 DefaultInfo
= &(DataHeader
->DefaultInfo
[0]);
197 BufferEnd
= (UINT8
*)DataHeader
+ sizeof (DataHeader
->DataSize
) + DataHeader
->HeaderSize
;
198 while ((UINT8
*)DefaultInfo
< BufferEnd
) {
199 if ((DefaultInfo
->DefaultId
== DefaultId
) && (DefaultInfo
->SkuId
== SkuId
)) {
208 DeltaData
= (PCD_DATA_DELTA
*)BufferEnd
;
209 BufferEnd
= (UINT8
*)DataHeader
+ DataHeader
->DataSize
;
210 while ((UINT8
*)DeltaData
< BufferEnd
) {
211 *(VarStoreHobData
+ DeltaData
->Offset
) = (UINT8
)DeltaData
->Value
;
218 Index
= (Index
+ DataHeader
->DataSize
+ 7) & (~7);
219 DataHeader
= (PCD_DEFAULT_DATA
*)(DataBuffer
+ Index
);
223 Status
= PcdUnRegisterCallBackOnSet (
224 &gEfiMdeModulePkgTokenSpaceGuid
,
225 PcdToken (PcdSetNvStoreDefaultId
),
226 PcdSetNvStoreDefaultIdCallBack
228 ASSERT_EFI_ERROR (Status
);
232 Report Pei PCD database of all SKUs as Guid HOB so that DxePcd can access it.
234 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
235 @param NotifyDescriptor Address of the notification descriptor data structure.
236 @param Ppi Address of the PPI that was installed.
238 @retval EFI_SUCCESS Successfully update the Boot records.
242 EndOfPeiSignalPpiNotifyCallback (
243 IN EFI_PEI_SERVICES
**PeiServices
,
244 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
248 PEI_PCD_DATABASE
*Database
;
249 EFI_BOOT_MODE BootMode
;
252 EFI_PEI_FV_HANDLE VolumeHandle
;
253 EFI_PEI_FILE_HANDLE FileHandle
;
256 PEI_PCD_DATABASE
*PeiPcdDb
;
258 Status
= PeiServicesGetBootMode (&BootMode
);
259 ASSERT_EFI_ERROR (Status
);
262 // Don't need to report it on S3 boot.
264 if (BootMode
== BOOT_ON_S3_RESUME
) {
268 PeiPcdDb
= GetPcdDatabase ();
269 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
)0) {
271 // SkuId has been set. Don't need to report it to DXE phase.
277 // Get full PCD database from PcdPeim FileHandle
283 // Traverse all firmware volume instances
285 Status
= PeiServicesFfsFindNextVolume (Instance
, &VolumeHandle
);
287 // Error should not happen
289 ASSERT_EFI_ERROR (Status
);
292 // Find PcdDb file from the beginning in this firmware volume.
295 Status
= PeiServicesFfsFindFileByName (&gEfiCallerIdGuid
, VolumeHandle
, &FileHandle
);
296 if (!EFI_ERROR (Status
)) {
298 // Find PcdPeim FileHandle in this volume
304 // We cannot find PcdPeim in this firmware volume, then search the next volume.
310 // Find PEI PcdDb and Build second PcdDB GuidHob
312 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
313 ASSERT_EFI_ERROR (Status
);
314 Length
= PeiPcdDb
->LengthForAllSkus
;
315 Database
= BuildGuidHob (&gPcdDataBaseHobGuid
, Length
);
316 CopyMem (Database
, PcdDb
, Length
);
321 EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiSignalPpiNotifyList
[] = {
323 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
324 &gEfiEndOfPeiSignalPpiGuid
,
325 EndOfPeiSignalPpiNotifyCallback
330 Main entry for PCD PEIM driver.
332 This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.
334 @param FileHandle Handle of the file being invoked.
335 @param PeiServices Describes the list of possible PEI Services.
337 @return Status of install PCD_PPI
343 IN EFI_PEI_FILE_HANDLE FileHandle
,
344 IN CONST EFI_PEI_SERVICES
**PeiServices
349 Status
= PeiServicesRegisterForShadow (FileHandle
);
350 if (Status
== EFI_ALREADY_STARTED
) {
352 // This is now starting in memory, the second time starting.
354 EFI_PEI_PPI_DESCRIPTOR
*OldPpiList
;
355 EFI_PEI_PPI_DESCRIPTOR
*OldPpiList2
;
360 Status
= PeiServicesLocatePpi (
366 ASSERT_EFI_ERROR (Status
);
368 if (OldPpiList
!= NULL
) {
369 Status
= PeiServicesReInstallPpi (OldPpiList
, &mPpiList
[0]);
370 ASSERT_EFI_ERROR (Status
);
374 Status
= PeiServicesLocatePpi (
380 ASSERT_EFI_ERROR (Status
);
382 if (OldPpiList2
!= NULL
) {
383 Status
= PeiServicesReInstallPpi (OldPpiList2
, &mPpiList2
[0]);
384 ASSERT_EFI_ERROR (Status
);
388 Status
= PeiServicesLocatePpi (
394 ASSERT_EFI_ERROR (Status
);
396 if (OldPpiList
!= NULL
) {
397 Status
= PeiServicesReInstallPpi (OldPpiList
, &mPpiList
[1]);
398 ASSERT_EFI_ERROR (Status
);
402 Status
= PeiServicesLocatePpi (
403 &gEfiGetPcdInfoPpiGuid
,
408 ASSERT_EFI_ERROR (Status
);
410 if (OldPpiList2
!= NULL
) {
411 Status
= PeiServicesReInstallPpi (OldPpiList2
, &mPpiList2
[1]);
412 ASSERT_EFI_ERROR (Status
);
418 BuildPcdDatabase (FileHandle
);
421 // Install PCD_PPI and EFI_PEI_PCD_PPI.
423 Status
= PeiServicesInstallPpi (&mPpiList
[0]);
424 ASSERT_EFI_ERROR (Status
);
427 // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
429 Status
= PeiServicesInstallPpi (&mPpiList2
[0]);
430 ASSERT_EFI_ERROR (Status
);
432 Status
= PeiServicesNotifyPpi (&mEndOfPeiSignalPpiNotifyList
[0]);
433 ASSERT_EFI_ERROR (Status
);
435 Status
= PeiRegisterCallBackOnSet (
436 &gEfiMdeModulePkgTokenSpaceGuid
,
437 PcdToken (PcdSetNvStoreDefaultId
),
438 PcdSetNvStoreDefaultIdCallBack
440 ASSERT_EFI_ERROR (Status
);
446 Retrieve additional information associated with a PCD token in the default token space.
448 This includes information such as the type of value the TokenNumber is associated with as well as possible
449 human readable name that is associated with the token.
451 @param[in] TokenNumber The PCD token number.
452 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
453 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
455 @retval EFI_SUCCESS The PCD information was returned successfully.
456 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
460 PeiGetPcdInfoGetInfo (
461 IN UINTN TokenNumber
,
462 OUT EFI_PCD_INFO
*PcdInfo
465 return PeiGetPcdInfo (NULL
, TokenNumber
, PcdInfo
);
469 Retrieve additional information associated with a PCD token.
471 This includes information such as the type of value the TokenNumber is associated with as well as possible
472 human readable name that is associated with the token.
474 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
475 @param[in] TokenNumber The PCD token number.
476 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
477 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
479 @retval EFI_SUCCESS The PCD information was returned successfully.
480 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
484 PeiGetPcdInfoGetInfoEx (
485 IN CONST EFI_GUID
*Guid
,
486 IN UINTN TokenNumber
,
487 OUT EFI_PCD_INFO
*PcdInfo
490 return PeiGetPcdInfo (Guid
, TokenNumber
, PcdInfo
);
494 Retrieve the currently set SKU Id.
496 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
497 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
502 PeiGetPcdInfoGetSku (
506 return (UINTN
)GetPcdDatabase ()->SystemSkuId
;
510 Sets the SKU value for subsequent calls to set or get PCD token values.
512 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
513 SetSku() is normally called only once by the system.
515 For each item (token), the database can hold a single value that applies to all SKUs,
516 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
517 SKU-specific values are called SKU enabled.
519 The SKU Id of zero is reserved as a default.
520 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
521 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
522 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
523 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
524 set for that Id, the results are unpredictable.
526 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
527 set values associated with a PCD token.
536 PEI_PCD_DATABASE
*PeiPcdDb
;
541 EFI_PEI_FV_HANDLE VolumeHandle
;
542 EFI_PEI_FILE_HANDLE FileHandle
;
545 PCD_DATABASE_SKU_DELTA
*SkuDelta
;
546 PCD_DATA_DELTA
*SkuDeltaData
;
548 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId 0x%lx is to be set.\n", (SKU_ID
)SkuId
));
550 PeiPcdDb
= GetPcdDatabase ();
552 if (SkuId
== PeiPcdDb
->SystemSkuId
) {
554 // The input SKU Id is equal to current SKU Id, return directly.
556 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is same to current system Sku.\n"));
560 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
)0) {
561 DEBUG ((DEBUG_ERROR
, "PcdPei - The SKU Id could be changed only once."));
564 "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
565 PeiPcdDb
->SystemSkuId
,
572 SkuIdTable
= (SKU_ID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->SkuIdTableOffset
);
573 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
574 if (SkuId
== SkuIdTable
[Index
+ 1]) {
575 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is found in SkuId table.\n"));
580 if (Index
< SkuIdTable
[0]) {
582 // Get full PCD database from PcdPeim FileHandle
588 // Traverse all firmware volume instances
590 Status
= PeiServicesFfsFindNextVolume (Instance
, &VolumeHandle
);
592 // Error should not happen
594 ASSERT_EFI_ERROR (Status
);
597 // Find PcdDb file from the beginning in this firmware volume.
600 Status
= PeiServicesFfsFindFileByName (&gEfiCallerIdGuid
, VolumeHandle
, &FileHandle
);
601 if (!EFI_ERROR (Status
)) {
603 // Find PcdPeim FileHandle in this volume
609 // We cannot find PcdPeim in this firmware volume, then search the next volume.
615 // Find the delta data between the different Skus
617 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
618 ASSERT_EFI_ERROR (Status
);
619 Length
= PeiPcdDb
->LengthForAllSkus
;
620 Index
= (PeiPcdDb
->Length
+ 7) & (~7);
622 while (Index
< Length
) {
623 SkuDelta
= (PCD_DATABASE_SKU_DELTA
*)((UINT8
*)PcdDb
+ Index
);
624 if ((SkuDelta
->SkuId
== SkuId
) && (SkuDelta
->SkuIdCompared
== 0)) {
628 Index
= (Index
+ SkuDelta
->Length
+ 7) & (~7);
632 // Patch the delta data into current PCD database
634 if ((Index
< Length
) && (SkuDelta
!= NULL
)) {
635 SkuDeltaData
= (PCD_DATA_DELTA
*)(SkuDelta
+ 1);
636 while ((UINT8
*)SkuDeltaData
< (UINT8
*)SkuDelta
+ SkuDelta
->Length
) {
637 *((UINT8
*)PeiPcdDb
+ SkuDeltaData
->Offset
) = (UINT8
)SkuDeltaData
->Value
;
641 PeiPcdDb
->SystemSkuId
= (SKU_ID
)SkuId
;
642 DEBUG ((DEBUG_INFO
, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID
)SkuId
));
648 // Invalid input SkuId, the default SKU Id will be still used for the system.
650 DEBUG ((DEBUG_ERROR
, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
656 Retrieves an 8-bit value for a given PCD token.
658 Retrieves the current byte-sized value for a PCD token number.
659 If the TokenNumber is invalid, the results are unpredictable.
661 @param[in] TokenNumber The PCD token number.
663 @return The UINT8 value.
672 return *((UINT8
*)GetWorker (TokenNumber
, sizeof (UINT8
)));
676 Retrieves an 16-bit value for a given PCD token.
678 Retrieves the current 16-bits value for a PCD token number.
679 If the TokenNumber is invalid, the results are unpredictable.
681 @param[in] TokenNumber The PCD token number.
683 @return The UINT16 value.
692 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
696 Retrieves an 32-bit value for a given PCD token.
698 Retrieves the current 32-bits value for a PCD token number.
699 If the TokenNumber is invalid, the results are unpredictable.
701 @param[in] TokenNumber The PCD token number.
703 @return The UINT32 value.
712 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
716 Retrieves an 64-bit value for a given PCD token.
718 Retrieves the current 64-bits value for a PCD token number.
719 If the TokenNumber is invalid, the results are unpredictable.
721 @param[in] TokenNumber The PCD token number.
723 @return The UINT64 value.
732 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
736 Retrieves a pointer to a value for a given PCD token.
738 Retrieves the current pointer to the buffer for a PCD token number.
739 Do not make any assumptions about the alignment of the pointer that
740 is returned by this function call. If the TokenNumber is invalid,
741 the results are unpredictable.
743 @param[in] TokenNumber The PCD token number.
745 @return The pointer to the buffer to be retrieved.
754 return GetWorker (TokenNumber
, 0);
758 Retrieves a Boolean value for a given PCD token.
760 Retrieves the current boolean value for a PCD token number.
761 Do not make any assumptions about the alignment of the pointer that
762 is returned by this function call. If the TokenNumber is invalid,
763 the results are unpredictable.
765 @param[in] TokenNumber The PCD token number.
767 @return The Boolean value.
776 return *((BOOLEAN
*)GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
780 Retrieves the size of the value for a given PCD token.
782 Retrieves the current size of a particular PCD token.
783 If the TokenNumber is invalid, the results are unpredictable.
785 @param[in] TokenNumber The PCD token number.
787 @return The size of the value for the PCD token.
796 PEI_PCD_DATABASE
*PeiPcdDb
;
799 UINT32 LocalTokenCount
;
801 PeiPcdDb
= GetPcdDatabase ();
802 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
804 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
805 // We have to decrement TokenNumber by 1 to make it usable
806 // as the array index.
810 // EBC compiler is very choosy. It may report warning about comparison
811 // between UINTN and 0 . So we add 1 in each size of the
813 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
815 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
819 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
821 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
828 Retrieves an 8-bit value for a given PCD token.
830 Retrieves the 8-bit value of a particular PCD token.
831 If the TokenNumber is invalid or the token space
832 specified by Guid does not exist, the results are
835 @param[in] Guid The token space for the token number.
836 @param[in] ExTokenNumber The PCD token number.
838 @return The size 8-bit value for the PCD token.
844 IN CONST EFI_GUID
*Guid
,
845 IN UINTN ExTokenNumber
848 return *((UINT8
*)ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
852 Retrieves an 16-bit value for a given PCD token.
854 Retrieves the 16-bit value of a particular PCD token.
855 If the TokenNumber is invalid or the token space
856 specified by Guid does not exist, the results are
859 @param[in] Guid The token space for the token number.
860 @param[in] ExTokenNumber The PCD token number.
862 @return The size 16-bit value for the PCD token.
868 IN CONST EFI_GUID
*Guid
,
869 IN UINTN ExTokenNumber
872 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
876 Retrieves an 32-bit value for a given PCD token.
878 Retrieves the 32-bit value of a particular PCD token.
879 If the TokenNumber is invalid or the token space
880 specified by Guid does not exist, the results are
883 @param[in] Guid The token space for the token number.
884 @param[in] ExTokenNumber The PCD token number.
886 @return The size 32-bit value for the PCD token.
892 IN CONST EFI_GUID
*Guid
,
893 IN UINTN ExTokenNumber
896 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
900 Retrieves an 64-bit value for a given PCD token.
902 Retrieves the 64-bit value of a particular PCD token.
903 If the TokenNumber is invalid or the token space
904 specified by Guid does not exist, the results are
907 @param[in] Guid The token space for the token number.
908 @param[in] ExTokenNumber The PCD token number.
910 @return The size 64-bit value for the PCD token.
916 IN CONST EFI_GUID
*Guid
,
917 IN UINTN ExTokenNumber
920 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
924 Retrieves a pointer to a value for a given PCD token.
926 Retrieves the current pointer to the buffer for a PCD token number.
927 Do not make any assumptions about the alignment of the pointer that
928 is returned by this function call. If the TokenNumber is invalid,
929 the results are unpredictable.
931 @param[in] Guid The token space for the token number.
932 @param[in] ExTokenNumber The PCD token number.
934 @return The pointer to the buffer to be retrieved.
940 IN CONST EFI_GUID
*Guid
,
941 IN UINTN ExTokenNumber
944 return ExGetWorker (Guid
, ExTokenNumber
, 0);
948 Retrieves an Boolean value for a given PCD token.
950 Retrieves the Boolean value of a particular PCD token.
951 If the TokenNumber is invalid or the token space
952 specified by Guid does not exist, the results are
955 @param[in] Guid The token space for the token number.
956 @param[in] ExTokenNumber The PCD token number.
958 @return The size Boolean value for the PCD token.
964 IN CONST EFI_GUID
*Guid
,
965 IN UINTN ExTokenNumber
968 return *((BOOLEAN
*)ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
972 Retrieves the size of the value for a given PCD token.
974 Retrieves the current size of a particular PCD token.
975 If the TokenNumber is invalid, the results are unpredictable.
977 @param[in] Guid The token space for the token number.
978 @param[in] ExTokenNumber The PCD token number.
980 @return The size of the value for the PCD token.
986 IN CONST EFI_GUID
*Guid
,
987 IN UINTN ExTokenNumber
990 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
994 Sets an 8-bit value for a given PCD token.
996 When the PCD service sets a value, it will check to ensure that the
997 size of the value being set is compatible with the Token's existing definition.
998 If it is not, an error will be returned.
1000 @param[in] TokenNumber The PCD token number.
1001 @param[in] Value The value to set for the PCD token.
1003 @retval EFI_SUCCESS Procedure returned successfully.
1004 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1005 being set was incompatible with a call to this function.
1006 Use GetSize() to retrieve the size of the target data.
1007 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1013 IN UINTN TokenNumber
,
1017 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1021 Sets an 16-bit value for a given PCD token.
1023 When the PCD service sets a value, it will check to ensure that the
1024 size of the value being set is compatible with the Token's existing definition.
1025 If it is not, an error will be returned.
1027 @param[in] TokenNumber The PCD token number.
1028 @param[in] Value The value to set for the PCD token.
1030 @retval EFI_SUCCESS Procedure returned successfully.
1031 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1032 being set was incompatible with a call to this function.
1033 Use GetSize() to retrieve the size of the target data.
1034 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1040 IN UINTN TokenNumber
,
1044 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1048 Sets an 32-bit value for a given PCD token.
1050 When the PCD service sets a value, it will check to ensure that the
1051 size of the value being set is compatible with the Token's existing definition.
1052 If it is not, an error will be returned.
1054 @param[in] TokenNumber The PCD token number.
1055 @param[in] Value The value to set for the PCD token.
1057 @retval EFI_SUCCESS Procedure returned successfully.
1058 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1059 being set was incompatible with a call to this function.
1060 Use GetSize() to retrieve the size of the target data.
1061 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1067 IN UINTN TokenNumber
,
1071 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1075 Sets an 64-bit value for a given PCD token.
1077 When the PCD service sets a value, it will check to ensure that the
1078 size of the value being set is compatible with the Token's existing definition.
1079 If it is not, an error will be returned.
1081 @param[in] TokenNumber The PCD token number.
1082 @param[in] Value The value to set for the PCD token.
1084 @retval EFI_SUCCESS Procedure returned successfully.
1085 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1086 being set was incompatible with a call to this function.
1087 Use GetSize() to retrieve the size of the target data.
1088 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1094 IN UINTN TokenNumber
,
1098 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1102 Sets a value of a specified size for a given PCD token.
1104 When the PCD service sets a value, it will check to ensure that the
1105 size of the value being set is compatible with the Token's existing definition.
1106 If it is not, an error will be returned.
1108 @param[in] TokenNumber The PCD token number.
1109 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1110 On input, if the SizeOfValue is greater than the maximum size supported
1111 for this TokenNumber then the output value of SizeOfValue will reflect
1112 the maximum size supported for this TokenNumber.
1113 @param[in] Buffer The buffer to set for the PCD token.
1115 @retval EFI_SUCCESS Procedure returned successfully.
1116 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1117 being set was incompatible with a call to this function.
1118 Use GetSize() to retrieve the size of the target data.
1119 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1125 IN UINTN TokenNumber
,
1126 IN OUT UINTN
*SizeOfBuffer
,
1130 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
1134 Sets an Boolean value for a given PCD token.
1136 When the PCD service sets a value, it will check to ensure that the
1137 size of the value being set is compatible with the Token's existing definition.
1138 If it is not, an error will be returned.
1140 @param[in] TokenNumber The PCD token number.
1141 @param[in] Value The value to set for the PCD token.
1143 @retval EFI_SUCCESS Procedure returned successfully.
1144 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1145 being set was incompatible with a call to this function.
1146 Use GetSize() to retrieve the size of the target data.
1147 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1153 IN UINTN TokenNumber
,
1157 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1161 Sets an 8-bit value for a given PCD token.
1163 When the PCD service sets a value, it will check to ensure that the
1164 size of the value being set is compatible with the Token's existing definition.
1165 If it is not, an error will be returned.
1167 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1168 @param[in] ExTokenNumber The PCD token number.
1169 @param[in] Value The value to set for the PCD token.
1171 @retval EFI_SUCCESS Procedure returned successfully.
1172 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1173 being set was incompatible with a call to this function.
1174 Use GetSize() to retrieve the size of the target data.
1175 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1181 IN CONST EFI_GUID
*Guid
,
1182 IN UINTN ExTokenNumber
,
1186 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1190 Sets an 16-bit value for a given PCD token.
1192 When the PCD service sets a value, it will check to ensure that the
1193 size of the value being set is compatible with the Token's existing definition.
1194 If it is not, an error will be returned.
1196 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1197 @param[in] ExTokenNumber The PCD token number.
1198 @param[in] Value The value to set for the PCD token.
1200 @retval EFI_SUCCESS Procedure returned successfully.
1201 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1202 being set was incompatible with a call to this function.
1203 Use GetSize() to retrieve the size of the target data.
1204 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1210 IN CONST EFI_GUID
*Guid
,
1211 IN UINTN ExTokenNumber
,
1215 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1219 Sets an 32-bit value for a given PCD token.
1221 When the PCD service sets a value, it will check to ensure that the
1222 size of the value being set is compatible with the Token's existing definition.
1223 If it is not, an error will be returned.
1225 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1226 @param[in] ExTokenNumber The PCD token number.
1227 @param[in] Value The value to set for the PCD token.
1229 @retval EFI_SUCCESS Procedure returned successfully.
1230 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1231 being set was incompatible with a call to this function.
1232 Use GetSize() to retrieve the size of the target data.
1233 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1239 IN CONST EFI_GUID
*Guid
,
1240 IN UINTN ExTokenNumber
,
1244 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1248 Sets an 64-bit value for a given PCD token.
1250 When the PCD service sets a value, it will check to ensure that the
1251 size of the value being set is compatible with the Token's existing definition.
1252 If it is not, an error will be returned.
1254 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1255 @param[in] ExTokenNumber The PCD token number.
1256 @param[in] Value The value to set for the PCD token.
1258 @retval EFI_SUCCESS Procedure returned successfully.
1259 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1260 being set was incompatible with a call to this function.
1261 Use GetSize() to retrieve the size of the target data.
1262 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1268 IN CONST EFI_GUID
*Guid
,
1269 IN UINTN ExTokenNumber
,
1273 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1277 Sets a value of a specified size for a given PCD token.
1279 When the PCD service sets a value, it will check to ensure that the
1280 size of the value being set is compatible with the Token's existing definition.
1281 If it is not, an error will be returned.
1283 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1284 @param[in] ExTokenNumber The PCD token number.
1285 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1286 On input, if the SizeOfValue is greater than the maximum size supported
1287 for this TokenNumber then the output value of SizeOfValue will reflect
1288 the maximum size supported for this TokenNumber.
1289 @param[in] Value The buffer to set for the PCD token.
1291 @retval EFI_SUCCESS Procedure returned successfully.
1292 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1293 being set was incompatible with a call to this function.
1294 Use GetSize() to retrieve the size of the target data.
1295 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1301 IN CONST EFI_GUID
*Guid
,
1302 IN UINTN ExTokenNumber
,
1303 IN OUT UINTN
*SizeOfBuffer
,
1307 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
1311 Sets an Boolean value for a given PCD token.
1313 When the PCD service sets a value, it will check to ensure that the
1314 size of the value being set is compatible with the Token's existing definition.
1315 If it is not, an error will be returned.
1317 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1318 @param [in] ExTokenNumber The PCD token number.
1319 @param [in] Value The value to set for the PCD token.
1321 @retval EFI_SUCCESS Procedure returned successfully.
1322 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1323 being set was incompatible with a call to this function.
1324 Use GetSize() to retrieve the size of the target data.
1325 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1331 IN CONST EFI_GUID
*Guid
,
1332 IN UINTN ExTokenNumber
,
1336 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1340 Specifies a function to be called anytime the value of a designated token is changed.
1342 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1343 @param[in] ExTokenNumber The PCD token number.
1344 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1346 @retval EFI_SUCCESS The PCD service has successfully established a call event
1347 for the CallBackToken requested.
1348 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1353 PeiRegisterCallBackOnSet (
1354 IN CONST EFI_GUID
*Guid OPTIONAL
,
1355 IN UINTN ExTokenNumber
,
1356 IN PCD_PPI_CALLBACK CallBackFunction
1359 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1360 return EFI_UNSUPPORTED
;
1363 if (CallBackFunction
== NULL
) {
1364 return EFI_INVALID_PARAMETER
;
1367 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
1371 Cancels a previously set callback function for a particular PCD token number.
1373 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1374 @param[in] ExTokenNumber The PCD token number.
1375 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1377 @retval EFI_SUCCESS The PCD service has successfully established a call event
1378 for the CallBackToken requested.
1379 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1384 PcdUnRegisterCallBackOnSet (
1385 IN CONST EFI_GUID
*Guid OPTIONAL
,
1386 IN UINTN ExTokenNumber
,
1387 IN PCD_PPI_CALLBACK CallBackFunction
1390 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1391 return EFI_UNSUPPORTED
;
1394 if (CallBackFunction
== NULL
) {
1395 return EFI_INVALID_PARAMETER
;
1398 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1402 Retrieves the next valid token number in a given namespace.
1404 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1405 and one cannot a priori know what token numbers are valid in the database.
1407 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1408 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1409 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1410 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1411 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1412 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1413 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1414 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1417 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1418 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1419 is being made to retrieve tokens from the default token space.
1420 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1422 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1423 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1428 PeiPcdGetNextToken (
1429 IN CONST EFI_GUID
*Guid OPTIONAL
,
1430 IN OUT UINTN
*TokenNumber
1434 PEI_PCD_DATABASE
*PeiPcdDb
;
1435 EFI_GUID
*MatchGuid
;
1436 EFI_GUID
*GuidTable
;
1437 DYNAMICEX_MAPPING
*ExMapTable
;
1440 BOOLEAN PeiExMapTableEmpty
;
1441 UINTN PeiNexTokenNumber
;
1443 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1444 return EFI_UNSUPPORTED
;
1447 PeiPcdDb
= GetPcdDatabase ();
1448 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1449 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1451 if (PeiPcdDb
->ExTokenCount
== 0) {
1452 PeiExMapTableEmpty
= TRUE
;
1454 PeiExMapTableEmpty
= FALSE
;
1458 if (*TokenNumber
> PeiNexTokenNumber
) {
1459 return EFI_NOT_FOUND
;
1463 if (*TokenNumber
> PeiNexTokenNumber
) {
1464 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1465 return EFI_NOT_FOUND
;
1470 if (PeiExMapTableEmpty
) {
1471 return EFI_NOT_FOUND
;
1474 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof (EFI_GUID
), Guid
);
1476 if (MatchGuid
== NULL
) {
1477 return EFI_NOT_FOUND
;
1480 GuidTableIdx
= MatchGuid
- GuidTable
;
1482 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1486 // Locate the GUID in ExMapTable first.
1488 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1489 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1497 // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first
1498 // token number in found token space.
1500 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1501 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1505 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1506 if ((ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) && (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
)) {
1511 while (Index
< PeiPcdDb
->ExTokenCount
) {
1513 if (Index
== PeiPcdDb
->ExTokenCount
) {
1515 // Exceed the length of ExMap Table
1517 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1518 return EFI_NOT_FOUND
;
1519 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1521 // Found the next match
1523 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1530 return EFI_NOT_FOUND
;
1534 Retrieves the next valid PCD token namespace for a given namespace.
1536 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1537 token namespaces on a platform.
1539 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1540 namespace from which the search will start. On output, it designates the next valid
1541 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1542 space of the current platform is returned. If the search cannot locate the next valid
1543 token namespace, an error is returned and the value of *Guid is undefined.
1545 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1546 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1551 PeiPcdGetNextTokenSpace (
1552 IN OUT CONST EFI_GUID
**Guid
1556 EFI_GUID
*MatchGuid
;
1557 PEI_PCD_DATABASE
*PeiPcdDb
;
1558 DYNAMICEX_MAPPING
*ExMapTable
;
1562 BOOLEAN PeiExMapTableEmpty
;
1563 EFI_GUID
*GuidTable
;
1565 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1566 return EFI_UNSUPPORTED
;
1569 ASSERT (Guid
!= NULL
);
1571 PeiPcdDb
= GetPcdDatabase ();
1573 if (PeiPcdDb
->ExTokenCount
== 0) {
1574 PeiExMapTableEmpty
= TRUE
;
1576 PeiExMapTableEmpty
= FALSE
;
1579 if (PeiExMapTableEmpty
) {
1580 return EFI_NOT_FOUND
;
1583 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1584 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1586 if (*Guid
== NULL
) {
1588 // return the first Token Space Guid.
1590 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1594 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof (GuidTable
[0]), *Guid
);
1596 if (MatchGuid
== NULL
) {
1597 return EFI_NOT_FOUND
;
1600 GuidTableIdx
= MatchGuid
- GuidTable
;
1603 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1604 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1612 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1613 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1615 for (Index2
= 0; Index2
< Index
; Index2
++) {
1616 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1618 // This token namespace should have been found and output at preceding getting.
1626 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1635 return EFI_NOT_FOUND
;
1639 Get PCD value's size for POINTER type PCD.
1641 The POINTER type PCD's value will be stored into a buffer in specified size.
1642 The max size of this PCD's value is described in PCD's definition in DEC file.
1644 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1645 @param MaxSize Maximum size of PCD's value
1646 @param Database Pcd database in PEI phase.
1648 @return PCD value's size for POINTER type PCD.
1653 IN UINTN LocalTokenNumberTableIdx
,
1655 IN PEI_PCD_DATABASE
*Database
1659 UINTN LocalTokenNumber
;
1660 SIZE_INFO
*SizeTable
;
1662 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1664 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1666 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1668 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1670 *MaxSize
= SizeTable
[SizeTableIdx
];
1672 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1675 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1677 // We have only two entry for VPD enabled PCD entry:
1680 // We consider current size is equal to MAX size.
1685 // We have only two entry for Non-Sku enabled PCD entry:
1689 return SizeTable
[SizeTableIdx
+ 1];
1694 Set PCD value's size for POINTER type PCD.
1696 The POINTER type PCD's value will be stored into a buffer in specified size.
1697 The max size of this PCD's value is described in PCD's definition in DEC file.
1699 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1700 @param CurrentSize Maximum size of PCD's value
1701 @param Database Pcd database in PEI phase.
1703 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1704 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1709 IN UINTN LocalTokenNumberTableIdx
,
1710 IN OUT UINTN
*CurrentSize
,
1711 IN PEI_PCD_DATABASE
*Database
1715 UINTN LocalTokenNumber
;
1716 SIZE_INFO
*SizeTable
;
1719 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1721 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1723 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1725 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1727 MaxSize
= SizeTable
[SizeTableIdx
];
1729 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1732 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1734 // We shouldn't come here as we don't support SET for VPD
1739 if ((*CurrentSize
> MaxSize
) ||
1740 (*CurrentSize
== MAX_ADDRESS
))
1742 *CurrentSize
= MaxSize
;
1747 // We have only two entry for Non-Sku enabled PCD entry:
1751 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
)*CurrentSize
;