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 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 /// Instance of PCD_PPI protocol is EDKII native implementation.
20 /// This protocol instance support dynamic and dynamicEx type PCDs.
22 PCD_PPI mPcdPpiInstance
= {
55 PeiRegisterCallBackOnSet
,
56 PcdUnRegisterCallBackOnSet
,
58 PeiPcdGetNextTokenSpace
62 /// Instance of EFI_PEI_PCD_PPI which is defined in PI 1.2 Vol 3.
63 /// This PPI instance only support dyanmicEx type PCD.
65 EFI_PEI_PCD_PPI mEfiPcdPpiInstance
= {
81 (EFI_PEI_PCD_PPI_CALLBACK_ON_SET
) PeiRegisterCallBackOnSet
,
82 (EFI_PEI_PCD_PPI_CANCEL_CALLBACK
) PcdUnRegisterCallBackOnSet
,
84 PeiPcdGetNextTokenSpace
88 /// Instance of GET_PCD_INFO_PPI protocol is EDKII native implementation.
89 /// This protocol instance support dynamic and dynamicEx type PCDs.
91 GET_PCD_INFO_PPI mGetPcdInfoInstance
= {
93 PeiGetPcdInfoGetInfoEx
,
98 /// Instance of EFI_GET_PCD_INFO_PPI which is defined in PI 1.2.1 Vol 3.
99 /// This PPI instance only support dyanmicEx type PCD.
101 EFI_GET_PCD_INFO_PPI mEfiGetPcdInfoInstance
= {
102 PeiGetPcdInfoGetInfoEx
,
106 EFI_PEI_PPI_DESCRIPTOR mPpiList
[] = {
108 EFI_PEI_PPI_DESCRIPTOR_PPI
,
113 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
119 EFI_PEI_PPI_DESCRIPTOR mPpiList2
[] = {
121 EFI_PEI_PPI_DESCRIPTOR_PPI
,
126 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
127 &gEfiGetPcdInfoPpiGuid
,
128 &mEfiGetPcdInfoInstance
133 Callback on SET PcdSetNvStoreDefaultId
135 Once PcdSetNvStoreDefaultId is set, the default NV storage will be found from
136 PcdNvStoreDefaultValueBuffer, and built into VariableHob.
138 @param[in] CallBackGuid The PCD token GUID being set.
139 @param[in] CallBackToken The PCD token number being set.
140 @param[in, out] TokenData A pointer to the token data being set.
141 @param[in] TokenDataSize The size, in bytes, of the data being set.
146 PcdSetNvStoreDefaultIdCallBack (
147 IN CONST EFI_GUID
*CallBackGuid
, OPTIONAL
148 IN UINTN CallBackToken
,
149 IN OUT VOID
*TokenData
,
150 IN UINTN TokenDataSize
159 UINT8
*VarStoreHobData
;
162 VARIABLE_STORE_HEADER
*NvStoreBuffer
;
163 PCD_DEFAULT_DATA
*DataHeader
;
164 PCD_DEFAULT_INFO
*DefaultInfo
;
165 PCD_DATA_DELTA
*DeltaData
;
167 DefaultId
= *(UINT16
*) TokenData
;
168 SkuId
= GetPcdDatabase()->SystemSkuId
;
171 if (PeiPcdGetSizeEx (&gEfiMdeModulePkgTokenSpaceGuid
, PcdToken (PcdNvStoreDefaultValueBuffer
)) > sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER
)) {
172 DataBuffer
= (UINT8
*) PeiPcdGetPtrEx (&gEfiMdeModulePkgTokenSpaceGuid
, PcdToken (PcdNvStoreDefaultValueBuffer
));
173 FullSize
= ((PCD_NV_STORE_DEFAULT_BUFFER_HEADER
*) DataBuffer
)->Length
;
174 DataHeader
= (PCD_DEFAULT_DATA
*) (DataBuffer
+ sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER
));
176 // The first section data includes NV storage default setting.
178 NvStoreBuffer
= (VARIABLE_STORE_HEADER
*) ((UINT8
*) DataHeader
+ sizeof (DataHeader
->DataSize
) + DataHeader
->HeaderSize
);
179 VarStoreHobData
= (UINT8
*) BuildGuidHob (&NvStoreBuffer
->Signature
, NvStoreBuffer
->Size
);
180 ASSERT (VarStoreHobData
!= NULL
);
181 CopyMem (VarStoreHobData
, NvStoreBuffer
, NvStoreBuffer
->Size
);
183 // Find the matched SkuId and DefaultId in the first section
185 DefaultInfo
= &(DataHeader
->DefaultInfo
[0]);
186 BufferEnd
= (UINT8
*) DataHeader
+ sizeof (DataHeader
->DataSize
) + DataHeader
->HeaderSize
;
187 while ((UINT8
*) DefaultInfo
< BufferEnd
) {
188 if (DefaultInfo
->DefaultId
== DefaultId
&& DefaultInfo
->SkuId
== SkuId
) {
195 // Find the matched SkuId and DefaultId in the remaining section
197 Index
= sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER
) + ((DataHeader
->DataSize
+ 7) & (~7));
198 DataHeader
= (PCD_DEFAULT_DATA
*) (DataBuffer
+ Index
);
199 while (!IsFound
&& Index
< FullSize
&& DataHeader
->DataSize
!= 0xFFFFFFFF) {
200 DefaultInfo
= &(DataHeader
->DefaultInfo
[0]);
201 BufferEnd
= (UINT8
*) DataHeader
+ sizeof (DataHeader
->DataSize
) + DataHeader
->HeaderSize
;
202 while ((UINT8
*) DefaultInfo
< BufferEnd
) {
203 if (DefaultInfo
->DefaultId
== DefaultId
&& DefaultInfo
->SkuId
== SkuId
) {
210 DeltaData
= (PCD_DATA_DELTA
*) BufferEnd
;
211 BufferEnd
= (UINT8
*) DataHeader
+ DataHeader
->DataSize
;
212 while ((UINT8
*) DeltaData
< BufferEnd
) {
213 *(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
303 // We cannot find PcdPeim in this firmware volume, then search the next volume.
309 // Find PEI PcdDb and Build second PcdDB GuidHob
311 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
312 ASSERT_EFI_ERROR (Status
);
313 Length
= PeiPcdDb
->LengthForAllSkus
;
314 Database
= BuildGuidHob (&gPcdDataBaseHobGuid
, Length
);
315 CopyMem (Database
, PcdDb
, Length
);
320 EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiSignalPpiNotifyList
[] = {
322 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
323 &gEfiEndOfPeiSignalPpiGuid
,
324 EndOfPeiSignalPpiNotifyCallback
329 Main entry for PCD PEIM driver.
331 This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.
333 @param FileHandle Handle of the file being invoked.
334 @param PeiServices Describes the list of possible PEI Services.
336 @return Status of install PCD_PPI
342 IN EFI_PEI_FILE_HANDLE FileHandle
,
343 IN CONST EFI_PEI_SERVICES
**PeiServices
348 BuildPcdDatabase (FileHandle
);
351 // Install PCD_PPI and EFI_PEI_PCD_PPI.
353 Status
= PeiServicesInstallPpi (&mPpiList
[0]);
354 ASSERT_EFI_ERROR (Status
);
357 // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
359 Status
= PeiServicesInstallPpi (&mPpiList2
[0]);
360 ASSERT_EFI_ERROR (Status
);
362 Status
= PeiServicesNotifyPpi (&mEndOfPeiSignalPpiNotifyList
[0]);
363 ASSERT_EFI_ERROR (Status
);
365 Status
= PeiRegisterCallBackOnSet (
366 &gEfiMdeModulePkgTokenSpaceGuid
,
367 PcdToken(PcdSetNvStoreDefaultId
),
368 PcdSetNvStoreDefaultIdCallBack
370 ASSERT_EFI_ERROR (Status
);
376 Retrieve additional information associated with a PCD token in the default token space.
378 This includes information such as the type of value the TokenNumber is associated with as well as possible
379 human readable name that is associated with the token.
381 @param[in] TokenNumber The PCD token number.
382 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
383 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
385 @retval EFI_SUCCESS The PCD information was returned successfully.
386 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
390 PeiGetPcdInfoGetInfo (
391 IN UINTN TokenNumber
,
392 OUT EFI_PCD_INFO
*PcdInfo
395 return PeiGetPcdInfo (NULL
, TokenNumber
, PcdInfo
);
399 Retrieve additional information associated with a PCD token.
401 This includes information such as the type of value the TokenNumber is associated with as well as possible
402 human readable name that is associated with the token.
404 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
405 @param[in] TokenNumber The PCD token number.
406 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
407 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
409 @retval EFI_SUCCESS The PCD information was returned successfully.
410 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
414 PeiGetPcdInfoGetInfoEx (
415 IN CONST EFI_GUID
*Guid
,
416 IN UINTN TokenNumber
,
417 OUT EFI_PCD_INFO
*PcdInfo
420 return PeiGetPcdInfo (Guid
, TokenNumber
, PcdInfo
);
424 Retrieve the currently set SKU Id.
426 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
427 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
432 PeiGetPcdInfoGetSku (
436 return (UINTN
) GetPcdDatabase()->SystemSkuId
;
440 Sets the SKU value for subsequent calls to set or get PCD token values.
442 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
443 SetSku() is normally called only once by the system.
445 For each item (token), the database can hold a single value that applies to all SKUs,
446 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
447 SKU-specific values are called SKU enabled.
449 The SKU Id of zero is reserved as a default.
450 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
451 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
452 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
453 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
454 set for that Id, the results are unpredictable.
456 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
457 set values associated with a PCD token.
466 PEI_PCD_DATABASE
*PeiPcdDb
;
471 EFI_PEI_FV_HANDLE VolumeHandle
;
472 EFI_PEI_FILE_HANDLE FileHandle
;
475 PCD_DATABASE_SKU_DELTA
*SkuDelta
;
476 PCD_DATA_DELTA
*SkuDeltaData
;
478 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId 0x%lx is to be set.\n", (SKU_ID
) SkuId
));
480 PeiPcdDb
= GetPcdDatabase();
482 if (SkuId
== PeiPcdDb
->SystemSkuId
) {
484 // The input SKU Id is equal to current SKU Id, return directly.
486 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is same to current system Sku.\n"));
490 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
) 0) {
491 DEBUG ((DEBUG_ERROR
, "PcdPei - The SKU Id could be changed only once."));
494 "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
495 PeiPcdDb
->SystemSkuId
,
502 SkuIdTable
= (SKU_ID
*) ((UINT8
*) PeiPcdDb
+ PeiPcdDb
->SkuIdTableOffset
);
503 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
504 if (SkuId
== SkuIdTable
[Index
+ 1]) {
505 DEBUG ((DEBUG_INFO
, "PcdPei - SkuId is found in SkuId table.\n"));
510 if (Index
< SkuIdTable
[0]) {
512 // Get full PCD database from PcdPeim FileHandle
518 // Traverse all firmware volume instances
520 Status
= PeiServicesFfsFindNextVolume (Instance
, &VolumeHandle
);
522 // Error should not happen
524 ASSERT_EFI_ERROR (Status
);
527 // Find PcdDb file from the beginning in this firmware volume.
530 Status
= PeiServicesFfsFindFileByName (&gEfiCallerIdGuid
, VolumeHandle
, &FileHandle
);
531 if (!EFI_ERROR (Status
)) {
533 // Find PcdPeim FileHandle in this volume
538 // We cannot find PcdPeim in this firmware volume, then search the next volume.
544 // Find the delta data between the different Skus
546 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
547 ASSERT_EFI_ERROR (Status
);
548 Length
= PeiPcdDb
->LengthForAllSkus
;
549 Index
= (PeiPcdDb
->Length
+ 7) & (~7);
551 while (Index
< Length
) {
552 SkuDelta
= (PCD_DATABASE_SKU_DELTA
*) ((UINT8
*) PcdDb
+ Index
);
553 if (SkuDelta
->SkuId
== SkuId
&& SkuDelta
->SkuIdCompared
== 0) {
556 Index
= (Index
+ SkuDelta
->Length
+ 7) & (~7);
560 // Patch the delta data into current PCD database
562 if (Index
< Length
&& SkuDelta
!= NULL
) {
563 SkuDeltaData
= (PCD_DATA_DELTA
*) (SkuDelta
+ 1);
564 while ((UINT8
*) SkuDeltaData
< (UINT8
*) SkuDelta
+ SkuDelta
->Length
) {
565 *((UINT8
*) PeiPcdDb
+ SkuDeltaData
->Offset
) = (UINT8
) SkuDeltaData
->Value
;
568 PeiPcdDb
->SystemSkuId
= (SKU_ID
) SkuId
;
569 DEBUG ((DEBUG_INFO
, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID
) SkuId
));
575 // Invalid input SkuId, the default SKU Id will be still used for the system.
577 DEBUG ((DEBUG_ERROR
, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
583 Retrieves an 8-bit value for a given PCD token.
585 Retrieves the current byte-sized value for a PCD token number.
586 If the TokenNumber is invalid, the results are unpredictable.
588 @param[in] TokenNumber The PCD token number.
590 @return The UINT8 value.
599 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
603 Retrieves an 16-bit value for a given PCD token.
605 Retrieves the current 16-bits value for a PCD token number.
606 If the TokenNumber is invalid, the results are unpredictable.
608 @param[in] TokenNumber The PCD token number.
610 @return The UINT16 value.
619 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
623 Retrieves an 32-bit value for a given PCD token.
625 Retrieves the current 32-bits value for a PCD token number.
626 If the TokenNumber is invalid, the results are unpredictable.
628 @param[in] TokenNumber The PCD token number.
630 @return The UINT32 value.
639 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
643 Retrieves an 64-bit value for a given PCD token.
645 Retrieves the current 64-bits value for a PCD token number.
646 If the TokenNumber is invalid, the results are unpredictable.
648 @param[in] TokenNumber The PCD token number.
650 @return The UINT64 value.
659 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
663 Retrieves a pointer to a value for a given PCD token.
665 Retrieves the current pointer to the buffer for a PCD token number.
666 Do not make any assumptions about the alignment of the pointer that
667 is returned by this function call. If the TokenNumber is invalid,
668 the results are unpredictable.
670 @param[in] TokenNumber The PCD token number.
672 @return The pointer to the buffer to be retrieved.
681 return GetWorker (TokenNumber
, 0);
685 Retrieves a Boolean value for a given PCD token.
687 Retrieves the current boolean value for a PCD token number.
688 Do not make any assumptions about the alignment of the pointer that
689 is returned by this function call. If the TokenNumber is invalid,
690 the results are unpredictable.
692 @param[in] TokenNumber The PCD token number.
694 @return The Boolean value.
703 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
707 Retrieves the size of the value for a given PCD token.
709 Retrieves the current size of a particular PCD token.
710 If the TokenNumber is invalid, the results are unpredictable.
712 @param[in] TokenNumber The PCD token number.
714 @return The size of the value for the PCD token.
723 PEI_PCD_DATABASE
*PeiPcdDb
;
726 UINT32 LocalTokenCount
;
728 PeiPcdDb
= GetPcdDatabase ();
729 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
731 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
732 // We have to decrement TokenNumber by 1 to make it usable
733 // as the array index.
737 // EBC compiler is very choosy. It may report warning about comparison
738 // between UINTN and 0 . So we add 1 in each size of the
740 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
742 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
746 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
748 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
756 Retrieves an 8-bit value for a given PCD token.
758 Retrieves the 8-bit value of a particular PCD token.
759 If the TokenNumber is invalid or the token space
760 specified by Guid does not exist, the results are
763 @param[in] Guid The token space for the token number.
764 @param[in] ExTokenNumber The PCD token number.
766 @return The size 8-bit value for the PCD token.
772 IN CONST EFI_GUID
*Guid
,
773 IN UINTN ExTokenNumber
776 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
780 Retrieves an 16-bit value for a given PCD token.
782 Retrieves the 16-bit value of a particular PCD token.
783 If the TokenNumber is invalid or the token space
784 specified by Guid does not exist, the results are
787 @param[in] Guid The token space for the token number.
788 @param[in] ExTokenNumber The PCD token number.
790 @return The size 16-bit value for the PCD token.
796 IN CONST EFI_GUID
*Guid
,
797 IN UINTN ExTokenNumber
800 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
804 Retrieves an 32-bit value for a given PCD token.
806 Retrieves the 32-bit value of a particular PCD token.
807 If the TokenNumber is invalid or the token space
808 specified by Guid does not exist, the results are
811 @param[in] Guid The token space for the token number.
812 @param[in] ExTokenNumber The PCD token number.
814 @return The size 32-bit value for the PCD token.
820 IN CONST EFI_GUID
*Guid
,
821 IN UINTN ExTokenNumber
824 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
828 Retrieves an 64-bit value for a given PCD token.
830 Retrieves the 64-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 64-bit value for the PCD token.
844 IN CONST EFI_GUID
*Guid
,
845 IN UINTN ExTokenNumber
848 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
852 Retrieves a pointer to a value for a given PCD token.
854 Retrieves the current pointer to the buffer for a PCD token number.
855 Do not make any assumptions about the alignment of the pointer that
856 is returned by this function call. If the TokenNumber is invalid,
857 the results are unpredictable.
859 @param[in] Guid The token space for the token number.
860 @param[in] ExTokenNumber The PCD token number.
862 @return The pointer to the buffer to be retrieved.
868 IN CONST EFI_GUID
*Guid
,
869 IN UINTN ExTokenNumber
872 return ExGetWorker (Guid
, ExTokenNumber
, 0);
876 Retrieves an Boolean value for a given PCD token.
878 Retrieves the Boolean 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 Boolean value for the PCD token.
892 IN CONST EFI_GUID
*Guid
,
893 IN UINTN ExTokenNumber
896 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
900 Retrieves the size of the value for a given PCD token.
902 Retrieves the current size of a particular PCD token.
903 If the TokenNumber is invalid, the results are unpredictable.
905 @param[in] Guid The token space for the token number.
906 @param[in] ExTokenNumber The PCD token number.
908 @return The size of the value for the PCD token.
914 IN CONST EFI_GUID
*Guid
,
915 IN UINTN ExTokenNumber
918 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
922 Sets an 8-bit value for a given PCD token.
924 When the PCD service sets a value, it will check to ensure that the
925 size of the value being set is compatible with the Token's existing definition.
926 If it is not, an error will be returned.
928 @param[in] TokenNumber The PCD token number.
929 @param[in] Value The value to set for the PCD token.
931 @retval EFI_SUCCESS Procedure returned successfully.
932 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
933 being set was incompatible with a call to this function.
934 Use GetSize() to retrieve the size of the target data.
935 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
941 IN UINTN TokenNumber
,
945 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
949 Sets an 16-bit value for a given PCD token.
951 When the PCD service sets a value, it will check to ensure that the
952 size of the value being set is compatible with the Token's existing definition.
953 If it is not, an error will be returned.
955 @param[in] TokenNumber The PCD token number.
956 @param[in] Value The value to set for the PCD token.
958 @retval EFI_SUCCESS Procedure returned successfully.
959 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
960 being set was incompatible with a call to this function.
961 Use GetSize() to retrieve the size of the target data.
962 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
968 IN UINTN TokenNumber
,
972 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
976 Sets an 32-bit value for a given PCD token.
978 When the PCD service sets a value, it will check to ensure that the
979 size of the value being set is compatible with the Token's existing definition.
980 If it is not, an error will be returned.
982 @param[in] TokenNumber The PCD token number.
983 @param[in] Value The value to set for the PCD token.
985 @retval EFI_SUCCESS Procedure returned successfully.
986 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
987 being set was incompatible with a call to this function.
988 Use GetSize() to retrieve the size of the target data.
989 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
995 IN UINTN TokenNumber
,
999 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1003 Sets an 64-bit value for a given PCD token.
1005 When the PCD service sets a value, it will check to ensure that the
1006 size of the value being set is compatible with the Token's existing definition.
1007 If it is not, an error will be returned.
1009 @param[in] TokenNumber The PCD token number.
1010 @param[in] Value The value to set for the PCD token.
1012 @retval EFI_SUCCESS Procedure returned successfully.
1013 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1014 being set was incompatible with a call to this function.
1015 Use GetSize() to retrieve the size of the target data.
1016 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1022 IN UINTN TokenNumber
,
1026 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1030 Sets a value of a specified size for a given PCD token.
1032 When the PCD service sets a value, it will check to ensure that the
1033 size of the value being set is compatible with the Token's existing definition.
1034 If it is not, an error will be returned.
1036 @param[in] TokenNumber The PCD token number.
1037 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1038 On input, if the SizeOfValue is greater than the maximum size supported
1039 for this TokenNumber then the output value of SizeOfValue will reflect
1040 the maximum size supported for this TokenNumber.
1041 @param[in] Buffer The buffer to set for the PCD token.
1043 @retval EFI_SUCCESS Procedure returned successfully.
1044 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1045 being set was incompatible with a call to this function.
1046 Use GetSize() to retrieve the size of the target data.
1047 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1053 IN UINTN TokenNumber
,
1054 IN OUT UINTN
*SizeOfBuffer
,
1058 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
1062 Sets an Boolean value for a given PCD token.
1064 When the PCD service sets a value, it will check to ensure that the
1065 size of the value being set is compatible with the Token's existing definition.
1066 If it is not, an error will be returned.
1068 @param[in] TokenNumber The PCD token number.
1069 @param[in] Value The value to set for the PCD token.
1071 @retval EFI_SUCCESS Procedure returned successfully.
1072 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1073 being set was incompatible with a call to this function.
1074 Use GetSize() to retrieve the size of the target data.
1075 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1081 IN UINTN TokenNumber
,
1085 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1089 Sets an 8-bit value for a given PCD token.
1091 When the PCD service sets a value, it will check to ensure that the
1092 size of the value being set is compatible with the Token's existing definition.
1093 If it is not, an error will be returned.
1095 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1096 @param[in] ExTokenNumber The PCD token number.
1097 @param[in] Value The value to set for the PCD token.
1099 @retval EFI_SUCCESS Procedure returned successfully.
1100 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1101 being set was incompatible with a call to this function.
1102 Use GetSize() to retrieve the size of the target data.
1103 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1109 IN CONST EFI_GUID
*Guid
,
1110 IN UINTN ExTokenNumber
,
1114 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1118 Sets an 16-bit value for a given PCD token.
1120 When the PCD service sets a value, it will check to ensure that the
1121 size of the value being set is compatible with the Token's existing definition.
1122 If it is not, an error will be returned.
1124 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1125 @param[in] ExTokenNumber The PCD token number.
1126 @param[in] Value The value to set for the PCD token.
1128 @retval EFI_SUCCESS Procedure returned successfully.
1129 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1130 being set was incompatible with a call to this function.
1131 Use GetSize() to retrieve the size of the target data.
1132 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1138 IN CONST EFI_GUID
*Guid
,
1139 IN UINTN ExTokenNumber
,
1143 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1147 Sets an 32-bit value for a given PCD token.
1149 When the PCD service sets a value, it will check to ensure that the
1150 size of the value being set is compatible with the Token's existing definition.
1151 If it is not, an error will be returned.
1153 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1154 @param[in] ExTokenNumber The PCD token number.
1155 @param[in] Value The value to set for the PCD token.
1157 @retval EFI_SUCCESS Procedure returned successfully.
1158 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1159 being set was incompatible with a call to this function.
1160 Use GetSize() to retrieve the size of the target data.
1161 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1167 IN CONST EFI_GUID
*Guid
,
1168 IN UINTN ExTokenNumber
,
1172 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1176 Sets an 64-bit value for a given PCD token.
1178 When the PCD service sets a value, it will check to ensure that the
1179 size of the value being set is compatible with the Token's existing definition.
1180 If it is not, an error will be returned.
1182 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1183 @param[in] ExTokenNumber The PCD token number.
1184 @param[in] Value The value to set for the PCD token.
1186 @retval EFI_SUCCESS Procedure returned successfully.
1187 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1188 being set was incompatible with a call to this function.
1189 Use GetSize() to retrieve the size of the target data.
1190 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1196 IN CONST EFI_GUID
*Guid
,
1197 IN UINTN ExTokenNumber
,
1201 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1205 Sets a value of a specified size for a given PCD token.
1207 When the PCD service sets a value, it will check to ensure that the
1208 size of the value being set is compatible with the Token's existing definition.
1209 If it is not, an error will be returned.
1211 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1212 @param[in] ExTokenNumber The PCD token number.
1213 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1214 On input, if the SizeOfValue is greater than the maximum size supported
1215 for this TokenNumber then the output value of SizeOfValue will reflect
1216 the maximum size supported for this TokenNumber.
1217 @param[in] Value The buffer to set for the PCD token.
1219 @retval EFI_SUCCESS Procedure returned successfully.
1220 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1221 being set was incompatible with a call to this function.
1222 Use GetSize() to retrieve the size of the target data.
1223 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1229 IN CONST EFI_GUID
*Guid
,
1230 IN UINTN ExTokenNumber
,
1231 IN OUT UINTN
*SizeOfBuffer
,
1235 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
1239 Sets an Boolean 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 Specifies a function to be called anytime the value of a designated token is changed.
1270 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1271 @param[in] ExTokenNumber The PCD token number.
1272 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1274 @retval EFI_SUCCESS The PCD service has successfully established a call event
1275 for the CallBackToken requested.
1276 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1281 PeiRegisterCallBackOnSet (
1282 IN CONST EFI_GUID
*Guid
, OPTIONAL
1283 IN UINTN ExTokenNumber
,
1284 IN PCD_PPI_CALLBACK CallBackFunction
1287 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1288 return EFI_UNSUPPORTED
;
1291 if (CallBackFunction
== NULL
) {
1292 return EFI_INVALID_PARAMETER
;
1295 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
1299 Cancels a previously set callback function for a particular PCD token number.
1301 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1302 @param[in] ExTokenNumber The PCD token number.
1303 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1305 @retval EFI_SUCCESS The PCD service has successfully established a call event
1306 for the CallBackToken requested.
1307 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1312 PcdUnRegisterCallBackOnSet (
1313 IN CONST EFI_GUID
*Guid
, OPTIONAL
1314 IN UINTN ExTokenNumber
,
1315 IN PCD_PPI_CALLBACK CallBackFunction
1318 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1319 return EFI_UNSUPPORTED
;
1322 if (CallBackFunction
== NULL
) {
1323 return EFI_INVALID_PARAMETER
;
1326 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1330 Retrieves the next valid token number in a given namespace.
1332 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1333 and one cannot a priori know what token numbers are valid in the database.
1335 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1336 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1337 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1338 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1339 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1340 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1341 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1342 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1345 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1346 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1347 is being made to retrieve tokens from the default token space.
1348 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1350 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1351 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1356 PeiPcdGetNextToken (
1357 IN CONST EFI_GUID
*Guid
, OPTIONAL
1358 IN OUT UINTN
*TokenNumber
1362 PEI_PCD_DATABASE
*PeiPcdDb
;
1363 EFI_GUID
*MatchGuid
;
1364 EFI_GUID
*GuidTable
;
1365 DYNAMICEX_MAPPING
*ExMapTable
;
1368 BOOLEAN PeiExMapTableEmpty
;
1369 UINTN PeiNexTokenNumber
;
1371 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1372 return EFI_UNSUPPORTED
;
1375 PeiPcdDb
= GetPcdDatabase ();
1376 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1377 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1379 if (PeiPcdDb
->ExTokenCount
== 0) {
1380 PeiExMapTableEmpty
= TRUE
;
1382 PeiExMapTableEmpty
= FALSE
;
1385 if (*TokenNumber
> PeiNexTokenNumber
) {
1386 return EFI_NOT_FOUND
;
1389 if (*TokenNumber
> PeiNexTokenNumber
) {
1390 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1391 return EFI_NOT_FOUND
;
1395 if (PeiExMapTableEmpty
) {
1396 return EFI_NOT_FOUND
;
1399 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(EFI_GUID
), Guid
);
1401 if (MatchGuid
== NULL
) {
1402 return EFI_NOT_FOUND
;
1405 GuidTableIdx
= MatchGuid
- GuidTable
;
1407 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1411 // Locate the GUID in ExMapTable first.
1413 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1414 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1422 // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first
1423 // token number in found token space.
1425 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1426 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1430 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1431 if ((ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) && (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
)) {
1436 while (Index
< PeiPcdDb
->ExTokenCount
) {
1438 if (Index
== PeiPcdDb
->ExTokenCount
) {
1440 // Exceed the length of ExMap Table
1442 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1443 return EFI_NOT_FOUND
;
1444 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1446 // Found the next match
1448 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1455 return EFI_NOT_FOUND
;
1459 Retrieves the next valid PCD token namespace for a given namespace.
1461 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1462 token namespaces on a platform.
1464 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1465 namespace from which the search will start. On output, it designates the next valid
1466 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1467 space of the current platform is returned. If the search cannot locate the next valid
1468 token namespace, an error is returned and the value of *Guid is undefined.
1470 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1471 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1476 PeiPcdGetNextTokenSpace (
1477 IN OUT CONST EFI_GUID
**Guid
1481 EFI_GUID
*MatchGuid
;
1482 PEI_PCD_DATABASE
*PeiPcdDb
;
1483 DYNAMICEX_MAPPING
*ExMapTable
;
1487 BOOLEAN PeiExMapTableEmpty
;
1488 EFI_GUID
*GuidTable
;
1490 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1491 return EFI_UNSUPPORTED
;
1494 ASSERT (Guid
!= NULL
);
1496 PeiPcdDb
= GetPcdDatabase ();
1498 if (PeiPcdDb
->ExTokenCount
== 0) {
1499 PeiExMapTableEmpty
= TRUE
;
1501 PeiExMapTableEmpty
= FALSE
;
1504 if (PeiExMapTableEmpty
) {
1505 return EFI_NOT_FOUND
;
1508 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1509 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1511 if (*Guid
== NULL
) {
1513 // return the first Token Space Guid.
1515 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1519 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(GuidTable
[0]), *Guid
);
1521 if (MatchGuid
== NULL
) {
1522 return EFI_NOT_FOUND
;
1525 GuidTableIdx
= MatchGuid
- GuidTable
;
1528 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1529 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1537 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1538 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1540 for (Index2
= 0 ; Index2
< Index
; Index2
++) {
1541 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1543 // This token namespace should have been found and output at preceding getting.
1550 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1558 return EFI_NOT_FOUND
;
1563 Get PCD value's size for POINTER type PCD.
1565 The POINTER type PCD's value will be stored into a buffer in specified size.
1566 The max size of this PCD's value is described in PCD's definition in DEC file.
1568 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1569 @param MaxSize Maximum size of PCD's value
1570 @param Database Pcd database in PEI phase.
1572 @return PCD value's size for POINTER type PCD.
1577 IN UINTN LocalTokenNumberTableIdx
,
1579 IN PEI_PCD_DATABASE
*Database
1583 UINTN LocalTokenNumber
;
1584 SIZE_INFO
*SizeTable
;
1586 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1588 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1590 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1592 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1594 *MaxSize
= SizeTable
[SizeTableIdx
];
1596 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1599 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1601 // We have only two entry for VPD enabled PCD entry:
1604 // We consider current size is equal to MAX size.
1609 // We have only two entry for Non-Sku enabled PCD entry:
1613 return SizeTable
[SizeTableIdx
+ 1];
1618 Set PCD value's size for POINTER type PCD.
1620 The POINTER type PCD's value will be stored into a buffer in specified size.
1621 The max size of this PCD's value is described in PCD's definition in DEC file.
1623 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1624 @param CurrentSize Maximum size of PCD's value
1625 @param Database Pcd database in PEI phase.
1627 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1628 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1633 IN UINTN LocalTokenNumberTableIdx
,
1634 IN OUT UINTN
*CurrentSize
,
1635 IN PEI_PCD_DATABASE
*Database
1639 UINTN LocalTokenNumber
;
1640 SIZE_INFO
*SizeTable
;
1643 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1645 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1647 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1649 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1651 MaxSize
= SizeTable
[SizeTableIdx
];
1653 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1656 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1658 // We shouldn't come here as we don't support SET for VPD
1663 if ((*CurrentSize
> MaxSize
) ||
1664 (*CurrentSize
== MAX_ADDRESS
)) {
1665 *CurrentSize
= MaxSize
;
1670 // We have only two entry for Non-Sku enabled PCD entry:
1674 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;