2 All Pcd Ppi services are implemented here.
4 Copyright (c) 2006 - 2017, 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 PeiPcdDb
= GetPcdDatabase();
480 if (SkuId
== PeiPcdDb
->SystemSkuId
) {
482 // The input SKU Id is equal to current SKU Id, return directly.
487 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
) 0) {
488 DEBUG ((DEBUG_ERROR
, "PcdPei - The SKU Id could be changed only once."));
491 "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
492 PeiPcdDb
->SystemSkuId
,
499 SkuIdTable
= (SKU_ID
*) ((UINT8
*) PeiPcdDb
+ PeiPcdDb
->SkuIdTableOffset
);
500 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
501 if (SkuId
== SkuIdTable
[Index
+ 1]) {
506 if (Index
< SkuIdTable
[0]) {
508 // Get full PCD database from PcdPeim FileHandle
514 // Traverse all firmware volume instances
516 Status
= PeiServicesFfsFindNextVolume (Instance
, &VolumeHandle
);
518 // Error should not happen
520 ASSERT_EFI_ERROR (Status
);
523 // Find PcdDb file from the beginning in this firmware volume.
526 Status
= PeiServicesFfsFindFileByName (&gEfiCallerIdGuid
, VolumeHandle
, &FileHandle
);
527 if (!EFI_ERROR (Status
)) {
529 // Find PcdPeim FileHandle in this volume
534 // We cannot find PcdPeim in this firmware volume, then search the next volume.
540 // Find the delta data between the different Skus
542 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, FileHandle
, &PcdDb
);
543 ASSERT_EFI_ERROR (Status
);
544 Length
= PeiPcdDb
->LengthForAllSkus
;
545 Index
= (PeiPcdDb
->Length
+ 7) & (~7);
547 while (Index
< Length
) {
548 SkuDelta
= (PCD_DATABASE_SKU_DELTA
*) ((UINT8
*) PcdDb
+ Index
);
549 if (SkuDelta
->SkuId
== SkuId
&& SkuDelta
->SkuIdCompared
== 0) {
552 Index
= (Index
+ SkuDelta
->Length
+ 7) & (~7);
556 // Patch the delta data into current PCD database
558 if (Index
< Length
&& SkuDelta
!= NULL
) {
559 SkuDeltaData
= (PCD_DATA_DELTA
*) (SkuDelta
+ 1);
560 while ((UINT8
*) SkuDeltaData
< (UINT8
*) SkuDelta
+ SkuDelta
->Length
) {
561 *((UINT8
*) PeiPcdDb
+ SkuDeltaData
->Offset
) = (UINT8
) SkuDeltaData
->Value
;
564 PeiPcdDb
->SystemSkuId
= (SKU_ID
) SkuId
;
565 DEBUG ((DEBUG_INFO
, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID
) SkuId
));
571 // Invalid input SkuId, the default SKU Id will be still used for the system.
573 DEBUG ((EFI_D_INFO
, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
579 Retrieves an 8-bit value for a given PCD token.
581 Retrieves the current byte-sized value for a PCD token number.
582 If the TokenNumber is invalid, the results are unpredictable.
584 @param[in] TokenNumber The PCD token number.
586 @return The UINT8 value.
595 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
599 Retrieves an 16-bit value for a given PCD token.
601 Retrieves the current 16-bits value for a PCD token number.
602 If the TokenNumber is invalid, the results are unpredictable.
604 @param[in] TokenNumber The PCD token number.
606 @return The UINT16 value.
615 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
619 Retrieves an 32-bit value for a given PCD token.
621 Retrieves the current 32-bits value for a PCD token number.
622 If the TokenNumber is invalid, the results are unpredictable.
624 @param[in] TokenNumber The PCD token number.
626 @return The UINT32 value.
635 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
639 Retrieves an 64-bit value for a given PCD token.
641 Retrieves the current 64-bits value for a PCD token number.
642 If the TokenNumber is invalid, the results are unpredictable.
644 @param[in] TokenNumber The PCD token number.
646 @return The UINT64 value.
655 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
659 Retrieves a pointer to a value for a given PCD token.
661 Retrieves the current pointer to the buffer for a PCD token number.
662 Do not make any assumptions about the alignment of the pointer that
663 is returned by this function call. If the TokenNumber is invalid,
664 the results are unpredictable.
666 @param[in] TokenNumber The PCD token number.
668 @return The pointer to the buffer to be retrieved.
677 return GetWorker (TokenNumber
, 0);
681 Retrieves a Boolean value for a given PCD token.
683 Retrieves the current boolean value for a PCD token number.
684 Do not make any assumptions about the alignment of the pointer that
685 is returned by this function call. If the TokenNumber is invalid,
686 the results are unpredictable.
688 @param[in] TokenNumber The PCD token number.
690 @return The Boolean value.
699 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
703 Retrieves the size of the value for a given PCD token.
705 Retrieves the current size of a particular PCD token.
706 If the TokenNumber is invalid, the results are unpredictable.
708 @param[in] TokenNumber The PCD token number.
710 @return The size of the value for the PCD token.
719 PEI_PCD_DATABASE
*PeiPcdDb
;
722 UINT32 LocalTokenCount
;
724 PeiPcdDb
= GetPcdDatabase ();
725 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
727 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
728 // We have to decrement TokenNumber by 1 to make it usable
729 // as the array index.
733 // EBC compiler is very choosy. It may report warning about comparison
734 // between UINTN and 0 . So we add 1 in each size of the
736 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
738 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
742 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
744 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
752 Retrieves an 8-bit value for a given PCD token.
754 Retrieves the 8-bit value of a particular PCD token.
755 If the TokenNumber is invalid or the token space
756 specified by Guid does not exist, the results are
759 @param[in] Guid The token space for the token number.
760 @param[in] ExTokenNumber The PCD token number.
762 @return The size 8-bit value for the PCD token.
768 IN CONST EFI_GUID
*Guid
,
769 IN UINTN ExTokenNumber
772 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
776 Retrieves an 16-bit value for a given PCD token.
778 Retrieves the 16-bit value of a particular PCD token.
779 If the TokenNumber is invalid or the token space
780 specified by Guid does not exist, the results are
783 @param[in] Guid The token space for the token number.
784 @param[in] ExTokenNumber The PCD token number.
786 @return The size 16-bit value for the PCD token.
792 IN CONST EFI_GUID
*Guid
,
793 IN UINTN ExTokenNumber
796 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
800 Retrieves an 32-bit value for a given PCD token.
802 Retrieves the 32-bit value of a particular PCD token.
803 If the TokenNumber is invalid or the token space
804 specified by Guid does not exist, the results are
807 @param[in] Guid The token space for the token number.
808 @param[in] ExTokenNumber The PCD token number.
810 @return The size 32-bit value for the PCD token.
816 IN CONST EFI_GUID
*Guid
,
817 IN UINTN ExTokenNumber
820 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
824 Retrieves an 64-bit value for a given PCD token.
826 Retrieves the 64-bit value of a particular PCD token.
827 If the TokenNumber is invalid or the token space
828 specified by Guid does not exist, the results are
831 @param[in] Guid The token space for the token number.
832 @param[in] ExTokenNumber The PCD token number.
834 @return The size 64-bit value for the PCD token.
840 IN CONST EFI_GUID
*Guid
,
841 IN UINTN ExTokenNumber
844 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
848 Retrieves a pointer to a value for a given PCD token.
850 Retrieves the current pointer to the buffer for a PCD token number.
851 Do not make any assumptions about the alignment of the pointer that
852 is returned by this function call. If the TokenNumber is invalid,
853 the results are unpredictable.
855 @param[in] Guid The token space for the token number.
856 @param[in] ExTokenNumber The PCD token number.
858 @return The pointer to the buffer to be retrieved.
864 IN CONST EFI_GUID
*Guid
,
865 IN UINTN ExTokenNumber
868 return ExGetWorker (Guid
, ExTokenNumber
, 0);
872 Retrieves an Boolean value for a given PCD token.
874 Retrieves the Boolean value of a particular PCD token.
875 If the TokenNumber is invalid or the token space
876 specified by Guid does not exist, the results are
879 @param[in] Guid The token space for the token number.
880 @param[in] ExTokenNumber The PCD token number.
882 @return The size Boolean value for the PCD token.
888 IN CONST EFI_GUID
*Guid
,
889 IN UINTN ExTokenNumber
892 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
896 Retrieves the size of the value for a given PCD token.
898 Retrieves the current size of a particular PCD token.
899 If the TokenNumber is invalid, the results are unpredictable.
901 @param[in] Guid The token space for the token number.
902 @param[in] ExTokenNumber The PCD token number.
904 @return The size of the value for the PCD token.
910 IN CONST EFI_GUID
*Guid
,
911 IN UINTN ExTokenNumber
914 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
918 Sets an 8-bit value for a given PCD token.
920 When the PCD service sets a value, it will check to ensure that the
921 size of the value being set is compatible with the Token's existing definition.
922 If it is not, an error will be returned.
924 @param[in] TokenNumber The PCD token number.
925 @param[in] Value The value to set for the PCD token.
927 @retval EFI_SUCCESS Procedure returned successfully.
928 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
929 being set was incompatible with a call to this function.
930 Use GetSize() to retrieve the size of the target data.
931 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
937 IN UINTN TokenNumber
,
941 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
945 Sets an 16-bit value for a given PCD token.
947 When the PCD service sets a value, it will check to ensure that the
948 size of the value being set is compatible with the Token's existing definition.
949 If it is not, an error will be returned.
951 @param[in] TokenNumber The PCD token number.
952 @param[in] Value The value to set for the PCD token.
954 @retval EFI_SUCCESS Procedure returned successfully.
955 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
956 being set was incompatible with a call to this function.
957 Use GetSize() to retrieve the size of the target data.
958 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
964 IN UINTN TokenNumber
,
968 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
972 Sets an 32-bit value for a given PCD token.
974 When the PCD service sets a value, it will check to ensure that the
975 size of the value being set is compatible with the Token's existing definition.
976 If it is not, an error will be returned.
978 @param[in] TokenNumber The PCD token number.
979 @param[in] Value The value to set for the PCD token.
981 @retval EFI_SUCCESS Procedure returned successfully.
982 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
983 being set was incompatible with a call to this function.
984 Use GetSize() to retrieve the size of the target data.
985 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
991 IN UINTN TokenNumber
,
995 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
999 Sets an 64-bit value for a given PCD token.
1001 When the PCD service sets a value, it will check to ensure that the
1002 size of the value being set is compatible with the Token's existing definition.
1003 If it is not, an error will be returned.
1005 @param[in] TokenNumber The PCD token number.
1006 @param[in] Value The value to set for the PCD token.
1008 @retval EFI_SUCCESS Procedure returned successfully.
1009 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1010 being set was incompatible with a call to this function.
1011 Use GetSize() to retrieve the size of the target data.
1012 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1018 IN UINTN TokenNumber
,
1022 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1026 Sets a value of a specified size for a given PCD token.
1028 When the PCD service sets a value, it will check to ensure that the
1029 size of the value being set is compatible with the Token's existing definition.
1030 If it is not, an error will be returned.
1032 @param[in] TokenNumber The PCD token number.
1033 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1034 On input, if the SizeOfValue is greater than the maximum size supported
1035 for this TokenNumber then the output value of SizeOfValue will reflect
1036 the maximum size supported for this TokenNumber.
1037 @param[in] Buffer The buffer to set for the PCD token.
1039 @retval EFI_SUCCESS Procedure returned successfully.
1040 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1041 being set was incompatible with a call to this function.
1042 Use GetSize() to retrieve the size of the target data.
1043 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1049 IN UINTN TokenNumber
,
1050 IN OUT UINTN
*SizeOfBuffer
,
1054 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
1058 Sets an Boolean value for a given PCD token.
1060 When the PCD service sets a value, it will check to ensure that the
1061 size of the value being set is compatible with the Token's existing definition.
1062 If it is not, an error will be returned.
1064 @param[in] TokenNumber The PCD token number.
1065 @param[in] Value The value to set for the PCD token.
1067 @retval EFI_SUCCESS Procedure returned successfully.
1068 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1069 being set was incompatible with a call to this function.
1070 Use GetSize() to retrieve the size of the target data.
1071 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1077 IN UINTN TokenNumber
,
1081 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
1085 Sets an 8-bit value for a given PCD token.
1087 When the PCD service sets a value, it will check to ensure that the
1088 size of the value being set is compatible with the Token's existing definition.
1089 If it is not, an error will be returned.
1091 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1092 @param[in] ExTokenNumber The PCD token number.
1093 @param[in] Value The value to set for the PCD token.
1095 @retval EFI_SUCCESS Procedure returned successfully.
1096 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1097 being set was incompatible with a call to this function.
1098 Use GetSize() to retrieve the size of the target data.
1099 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1105 IN CONST EFI_GUID
*Guid
,
1106 IN UINTN ExTokenNumber
,
1110 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1114 Sets an 16-bit value for a given PCD token.
1116 When the PCD service sets a value, it will check to ensure that the
1117 size of the value being set is compatible with the Token's existing definition.
1118 If it is not, an error will be returned.
1120 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1121 @param[in] ExTokenNumber The PCD token number.
1122 @param[in] Value The value to set for the PCD token.
1124 @retval EFI_SUCCESS Procedure returned successfully.
1125 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1126 being set was incompatible with a call to this function.
1127 Use GetSize() to retrieve the size of the target data.
1128 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1134 IN CONST EFI_GUID
*Guid
,
1135 IN UINTN ExTokenNumber
,
1139 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1143 Sets an 32-bit value for a given PCD token.
1145 When the PCD service sets a value, it will check to ensure that the
1146 size of the value being set is compatible with the Token's existing definition.
1147 If it is not, an error will be returned.
1149 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1150 @param[in] ExTokenNumber The PCD token number.
1151 @param[in] Value The value to set for the PCD token.
1153 @retval EFI_SUCCESS Procedure returned successfully.
1154 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1155 being set was incompatible with a call to this function.
1156 Use GetSize() to retrieve the size of the target data.
1157 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1163 IN CONST EFI_GUID
*Guid
,
1164 IN UINTN ExTokenNumber
,
1168 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1172 Sets an 64-bit value for a given PCD token.
1174 When the PCD service sets a value, it will check to ensure that the
1175 size of the value being set is compatible with the Token's existing definition.
1176 If it is not, an error will be returned.
1178 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1179 @param[in] ExTokenNumber The PCD token number.
1180 @param[in] Value The value to set for the PCD token.
1182 @retval EFI_SUCCESS Procedure returned successfully.
1183 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1184 being set was incompatible with a call to this function.
1185 Use GetSize() to retrieve the size of the target data.
1186 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1192 IN CONST EFI_GUID
*Guid
,
1193 IN UINTN ExTokenNumber
,
1197 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1201 Sets a value of a specified size for a given PCD token.
1203 When the PCD service sets a value, it will check to ensure that the
1204 size of the value being set is compatible with the Token's existing definition.
1205 If it is not, an error will be returned.
1207 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1208 @param[in] ExTokenNumber The PCD token number.
1209 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
1210 On input, if the SizeOfValue is greater than the maximum size supported
1211 for this TokenNumber then the output value of SizeOfValue will reflect
1212 the maximum size supported for this TokenNumber.
1213 @param[in] Value The buffer to set for the PCD token.
1215 @retval EFI_SUCCESS Procedure returned successfully.
1216 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1217 being set was incompatible with a call to this function.
1218 Use GetSize() to retrieve the size of the target data.
1219 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1225 IN CONST EFI_GUID
*Guid
,
1226 IN UINTN ExTokenNumber
,
1227 IN OUT UINTN
*SizeOfBuffer
,
1231 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
1235 Sets an Boolean value for a given PCD token.
1237 When the PCD service sets a value, it will check to ensure that the
1238 size of the value being set is compatible with the Token's existing definition.
1239 If it is not, an error will be returned.
1241 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1242 @param [in] ExTokenNumber The PCD token number.
1243 @param [in] Value The value to set for the PCD token.
1245 @retval EFI_SUCCESS Procedure returned successfully.
1246 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
1247 being set was incompatible with a call to this function.
1248 Use GetSize() to retrieve the size of the target data.
1249 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
1255 IN CONST EFI_GUID
*Guid
,
1256 IN UINTN ExTokenNumber
,
1260 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
1264 Specifies a function to be called anytime the value of a designated token is changed.
1266 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1267 @param[in] ExTokenNumber The PCD token number.
1268 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1270 @retval EFI_SUCCESS The PCD service has successfully established a call event
1271 for the CallBackToken requested.
1272 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1277 PeiRegisterCallBackOnSet (
1278 IN CONST EFI_GUID
*Guid
, OPTIONAL
1279 IN UINTN ExTokenNumber
,
1280 IN PCD_PPI_CALLBACK CallBackFunction
1283 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1284 return EFI_UNSUPPORTED
;
1287 if (CallBackFunction
== NULL
) {
1288 return EFI_INVALID_PARAMETER
;
1291 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
1295 Cancels a previously set callback function for a particular PCD token number.
1297 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1298 @param[in] ExTokenNumber The PCD token number.
1299 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1301 @retval EFI_SUCCESS The PCD service has successfully established a call event
1302 for the CallBackToken requested.
1303 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1308 PcdUnRegisterCallBackOnSet (
1309 IN CONST EFI_GUID
*Guid
, OPTIONAL
1310 IN UINTN ExTokenNumber
,
1311 IN PCD_PPI_CALLBACK CallBackFunction
1314 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1315 return EFI_UNSUPPORTED
;
1318 if (CallBackFunction
== NULL
) {
1319 return EFI_INVALID_PARAMETER
;
1322 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1326 Retrieves the next valid token number in a given namespace.
1328 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1329 and one cannot a priori know what token numbers are valid in the database.
1331 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1332 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1333 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1334 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1335 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1336 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1337 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1338 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1341 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1342 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1343 is being made to retrieve tokens from the default token space.
1344 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1346 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1347 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1352 PeiPcdGetNextToken (
1353 IN CONST EFI_GUID
*Guid
, OPTIONAL
1354 IN OUT UINTN
*TokenNumber
1358 PEI_PCD_DATABASE
*PeiPcdDb
;
1359 EFI_GUID
*MatchGuid
;
1360 EFI_GUID
*GuidTable
;
1361 DYNAMICEX_MAPPING
*ExMapTable
;
1364 BOOLEAN PeiExMapTableEmpty
;
1365 UINTN PeiNexTokenNumber
;
1367 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1368 return EFI_UNSUPPORTED
;
1371 PeiPcdDb
= GetPcdDatabase ();
1372 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1373 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1375 if (PeiPcdDb
->ExTokenCount
== 0) {
1376 PeiExMapTableEmpty
= TRUE
;
1378 PeiExMapTableEmpty
= FALSE
;
1381 if (*TokenNumber
> PeiNexTokenNumber
) {
1382 return EFI_NOT_FOUND
;
1385 if (*TokenNumber
> PeiNexTokenNumber
) {
1386 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1387 return EFI_NOT_FOUND
;
1391 if (PeiExMapTableEmpty
) {
1392 return EFI_NOT_FOUND
;
1395 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(EFI_GUID
), Guid
);
1397 if (MatchGuid
== NULL
) {
1398 return EFI_NOT_FOUND
;
1401 GuidTableIdx
= MatchGuid
- GuidTable
;
1403 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1407 // Locate the GUID in ExMapTable first.
1409 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1410 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1418 // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first
1419 // token number in found token space.
1421 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1422 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1426 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1427 if ((ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) && (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
)) {
1432 while (Index
< PeiPcdDb
->ExTokenCount
) {
1434 if (Index
== PeiPcdDb
->ExTokenCount
) {
1436 // Exceed the length of ExMap Table
1438 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1439 return EFI_NOT_FOUND
;
1440 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1442 // Found the next match
1444 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1451 return EFI_NOT_FOUND
;
1455 Retrieves the next valid PCD token namespace for a given namespace.
1457 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1458 token namespaces on a platform.
1460 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1461 namespace from which the search will start. On output, it designates the next valid
1462 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1463 space of the current platform is returned. If the search cannot locate the next valid
1464 token namespace, an error is returned and the value of *Guid is undefined.
1466 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1467 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1472 PeiPcdGetNextTokenSpace (
1473 IN OUT CONST EFI_GUID
**Guid
1477 EFI_GUID
*MatchGuid
;
1478 PEI_PCD_DATABASE
*PeiPcdDb
;
1479 DYNAMICEX_MAPPING
*ExMapTable
;
1483 BOOLEAN PeiExMapTableEmpty
;
1484 EFI_GUID
*GuidTable
;
1486 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1487 return EFI_UNSUPPORTED
;
1490 ASSERT (Guid
!= NULL
);
1492 PeiPcdDb
= GetPcdDatabase ();
1494 if (PeiPcdDb
->ExTokenCount
== 0) {
1495 PeiExMapTableEmpty
= TRUE
;
1497 PeiExMapTableEmpty
= FALSE
;
1500 if (PeiExMapTableEmpty
) {
1501 return EFI_NOT_FOUND
;
1504 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1505 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1507 if (*Guid
== NULL
) {
1509 // return the first Token Space Guid.
1511 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1515 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(GuidTable
[0]), *Guid
);
1517 if (MatchGuid
== NULL
) {
1518 return EFI_NOT_FOUND
;
1521 GuidTableIdx
= MatchGuid
- GuidTable
;
1524 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1525 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1533 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1534 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1536 for (Index2
= 0 ; Index2
< Index
; Index2
++) {
1537 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1539 // This token namespace should have been found and output at preceding getting.
1546 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1554 return EFI_NOT_FOUND
;
1559 Get PCD value's size for POINTER type PCD.
1561 The POINTER type PCD's value will be stored into a buffer in specified size.
1562 The max size of this PCD's value is described in PCD's definition in DEC file.
1564 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1565 @param MaxSize Maximum size of PCD's value
1566 @param Database Pcd database in PEI phase.
1568 @return PCD value's size for POINTER type PCD.
1573 IN UINTN LocalTokenNumberTableIdx
,
1575 IN PEI_PCD_DATABASE
*Database
1579 UINTN LocalTokenNumber
;
1580 SIZE_INFO
*SizeTable
;
1582 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1584 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1586 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1588 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1590 *MaxSize
= SizeTable
[SizeTableIdx
];
1592 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1595 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1597 // We have only two entry for VPD enabled PCD entry:
1600 // We consider current size is equal to MAX size.
1605 // We have only two entry for Non-Sku enabled PCD entry:
1609 return SizeTable
[SizeTableIdx
+ 1];
1614 Set PCD value's size for POINTER type PCD.
1616 The POINTER type PCD's value will be stored into a buffer in specified size.
1617 The max size of this PCD's value is described in PCD's definition in DEC file.
1619 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1620 @param CurrentSize Maximum size of PCD's value
1621 @param Database Pcd database in PEI phase.
1623 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1624 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1629 IN UINTN LocalTokenNumberTableIdx
,
1630 IN OUT UINTN
*CurrentSize
,
1631 IN PEI_PCD_DATABASE
*Database
1635 UINTN LocalTokenNumber
;
1636 SIZE_INFO
*SizeTable
;
1639 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1641 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1643 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1645 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1647 MaxSize
= SizeTable
[SizeTableIdx
];
1649 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1652 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1654 // We shouldn't come here as we don't support SET for VPD
1659 if ((*CurrentSize
> MaxSize
) ||
1660 (*CurrentSize
== MAX_ADDRESS
)) {
1661 *CurrentSize
= MaxSize
;
1666 // We have only two entry for Non-Sku enabled PCD entry:
1670 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;