2 All Pcd Ppi services are implemented here.
4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 /// Instance of PCD_PPI protocol is EDKII native implementation.
19 /// This protocol instance support dynamic and dynamicEx type PCDs.
21 PCD_PPI mPcdPpiInstance
= {
54 PeiRegisterCallBackOnSet
,
55 PcdUnRegisterCallBackOnSet
,
57 PeiPcdGetNextTokenSpace
61 /// Instance of EFI_PEI_PCD_PPI which is defined in PI 1.2 Vol 3.
62 /// This PPI instance only support dyanmicEx type PCD.
64 EFI_PEI_PCD_PPI mEfiPcdPpiInstance
= {
80 (EFI_PEI_PCD_PPI_CALLBACK_ON_SET
) PeiRegisterCallBackOnSet
,
81 (EFI_PEI_PCD_PPI_CANCEL_CALLBACK
) PcdUnRegisterCallBackOnSet
,
83 PeiPcdGetNextTokenSpace
87 /// Instance of GET_PCD_INFO_PPI protocol is EDKII native implementation.
88 /// This protocol instance support dynamic and dynamicEx type PCDs.
90 GET_PCD_INFO_PPI mGetPcdInfoInstance
= {
92 PeiGetPcdInfoGetInfoEx
,
97 /// Instance of EFI_GET_PCD_INFO_PPI which is defined in PI 1.2.1 Vol 3.
98 /// This PPI instance only support dyanmicEx type PCD.
100 EFI_GET_PCD_INFO_PPI mEfiGetPcdInfoInstance
= {
101 PeiGetPcdInfoGetInfoEx
,
105 EFI_PEI_PPI_DESCRIPTOR mPpiList
[] = {
107 EFI_PEI_PPI_DESCRIPTOR_PPI
,
112 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
118 EFI_PEI_PPI_DESCRIPTOR mPpiList2
[] = {
120 EFI_PEI_PPI_DESCRIPTOR_PPI
,
125 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
126 &gEfiGetPcdInfoPpiGuid
,
127 &mEfiGetPcdInfoInstance
132 Main entry for PCD PEIM driver.
134 This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.
136 @param FileHandle Handle of the file being invoked.
137 @param PeiServices Describes the list of possible PEI Services.
139 @return Status of install PCD_PPI
145 IN EFI_PEI_FILE_HANDLE FileHandle
,
146 IN CONST EFI_PEI_SERVICES
**PeiServices
150 PEI_PCD_DATABASE
*DataBase
;
152 DataBase
= BuildPcdDatabase (FileHandle
);
155 // Install PCD_PPI and EFI_PEI_PCD_PPI.
157 Status
= PeiServicesInstallPpi (&mPpiList
[0]);
158 ASSERT_EFI_ERROR (Status
);
161 // Only install PcdInfo PPI when PCD info content is present.
163 if (DataBase
->PcdNameTableOffset
!= 0) {
165 // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
167 Status
= PeiServicesInstallPpi (&mPpiList2
[0]);
168 ASSERT_EFI_ERROR (Status
);
175 Retrieve additional information associated with a PCD token in the default token space.
177 This includes information such as the type of value the TokenNumber is associated with as well as possible
178 human readable name that is associated with the token.
180 @param[in] TokenNumber The PCD token number.
181 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
182 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
184 @retval EFI_SUCCESS The PCD information was returned successfully.
185 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
189 PeiGetPcdInfoGetInfo (
190 IN UINTN TokenNumber
,
191 OUT EFI_PCD_INFO
*PcdInfo
194 return PeiGetPcdInfo (NULL
, TokenNumber
, PcdInfo
);
198 Retrieve additional information associated with a PCD token.
200 This includes information such as the type of value the TokenNumber is associated with as well as possible
201 human readable name that is associated with the token.
203 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
204 @param[in] TokenNumber The PCD token number.
205 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
206 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
208 @retval EFI_SUCCESS The PCD information was returned successfully.
209 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
213 PeiGetPcdInfoGetInfoEx (
214 IN CONST EFI_GUID
*Guid
,
215 IN UINTN TokenNumber
,
216 OUT EFI_PCD_INFO
*PcdInfo
219 return PeiGetPcdInfo (Guid
, TokenNumber
, PcdInfo
);
223 Retrieve the currently set SKU Id.
225 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
226 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
231 PeiGetPcdInfoGetSku (
235 return GetPcdDatabase()->SystemSkuId
;
239 Sets the SKU value for subsequent calls to set or get PCD token values.
241 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
242 SetSku() is normally called only once by the system.
244 For each item (token), the database can hold a single value that applies to all SKUs,
245 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
246 SKU-specific values are called SKU enabled.
248 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
249 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
250 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
251 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
252 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
253 set for that Id, the results are unpredictable.
255 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
256 set values associated with a PCD token.
266 GetPcdDatabase()->SystemSkuId
= (SKU_ID
) SkuId
;
272 Retrieves an 8-bit value for a given PCD token.
274 Retrieves the current byte-sized value for a PCD token number.
275 If the TokenNumber is invalid, the results are unpredictable.
277 @param[in] TokenNumber The PCD token number.
279 @return The UINT8 value.
288 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
292 Retrieves an 16-bit value for a given PCD token.
294 Retrieves the current 16-bits value for a PCD token number.
295 If the TokenNumber is invalid, the results are unpredictable.
297 @param[in] TokenNumber The PCD token number.
299 @return The UINT16 value.
308 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
312 Retrieves an 32-bit value for a given PCD token.
314 Retrieves the current 32-bits value for a PCD token number.
315 If the TokenNumber is invalid, the results are unpredictable.
317 @param[in] TokenNumber The PCD token number.
319 @return The UINT32 value.
328 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
332 Retrieves an 64-bit value for a given PCD token.
334 Retrieves the current 64-bits value for a PCD token number.
335 If the TokenNumber is invalid, the results are unpredictable.
337 @param[in] TokenNumber The PCD token number.
339 @return The UINT64 value.
348 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
352 Retrieves a pointer to a value for a given PCD token.
354 Retrieves the current pointer to the buffer for a PCD token number.
355 Do not make any assumptions about the alignment of the pointer that
356 is returned by this function call. If the TokenNumber is invalid,
357 the results are unpredictable.
359 @param[in] TokenNumber The PCD token number.
361 @return The pointer to the buffer to be retrieved.
370 return GetWorker (TokenNumber
, 0);
374 Retrieves a Boolean value for a given PCD token.
376 Retrieves the current boolean value for a PCD token number.
377 Do not make any assumptions about the alignment of the pointer that
378 is returned by this function call. If the TokenNumber is invalid,
379 the results are unpredictable.
381 @param[in] TokenNumber The PCD token number.
383 @return The Boolean value.
392 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
396 Retrieves the size of the value for a given PCD token.
398 Retrieves the current size of a particular PCD token.
399 If the TokenNumber is invalid, the results are unpredictable.
401 @param[in] TokenNumber The PCD token number.
403 @return The size of the value for the PCD token.
412 PEI_PCD_DATABASE
*PeiPcdDb
;
415 UINT32 LocalTokenCount
;
417 PeiPcdDb
= GetPcdDatabase ();
418 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
420 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
421 // We have to decrement TokenNumber by 1 to make it usable
422 // as the array index.
426 // EBC compiler is very choosy. It may report warning about comparison
427 // between UINTN and 0 . So we add 1 in each size of the
429 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
431 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
435 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
437 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
445 Retrieves an 8-bit value for a given PCD token.
447 Retrieves the 8-bit value of a particular PCD token.
448 If the TokenNumber is invalid or the token space
449 specified by Guid does not exist, the results are
452 @param[in] Guid The token space for the token number.
453 @param[in] ExTokenNumber The PCD token number.
455 @return The size 8-bit value for the PCD token.
461 IN CONST EFI_GUID
*Guid
,
462 IN UINTN ExTokenNumber
465 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
469 Retrieves an 16-bit value for a given PCD token.
471 Retrieves the 16-bit value of a particular PCD token.
472 If the TokenNumber is invalid or the token space
473 specified by Guid does not exist, the results are
476 @param[in] Guid The token space for the token number.
477 @param[in] ExTokenNumber The PCD token number.
479 @return The size 16-bit value for the PCD token.
485 IN CONST EFI_GUID
*Guid
,
486 IN UINTN ExTokenNumber
489 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
493 Retrieves an 32-bit value for a given PCD token.
495 Retrieves the 32-bit value of a particular PCD token.
496 If the TokenNumber is invalid or the token space
497 specified by Guid does not exist, the results are
500 @param[in] Guid The token space for the token number.
501 @param[in] ExTokenNumber The PCD token number.
503 @return The size 32-bit value for the PCD token.
509 IN CONST EFI_GUID
*Guid
,
510 IN UINTN ExTokenNumber
513 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
517 Retrieves an 64-bit value for a given PCD token.
519 Retrieves the 64-bit value of a particular PCD token.
520 If the TokenNumber is invalid or the token space
521 specified by Guid does not exist, the results are
524 @param[in] Guid The token space for the token number.
525 @param[in] ExTokenNumber The PCD token number.
527 @return The size 64-bit value for the PCD token.
533 IN CONST EFI_GUID
*Guid
,
534 IN UINTN ExTokenNumber
537 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
541 Retrieves a pointer to a value for a given PCD token.
543 Retrieves the current pointer to the buffer for a PCD token number.
544 Do not make any assumptions about the alignment of the pointer that
545 is returned by this function call. If the TokenNumber is invalid,
546 the results are unpredictable.
548 @param[in] Guid The token space for the token number.
549 @param[in] ExTokenNumber The PCD token number.
551 @return The pointer to the buffer to be retrieved.
557 IN CONST EFI_GUID
*Guid
,
558 IN UINTN ExTokenNumber
561 return ExGetWorker (Guid
, ExTokenNumber
, 0);
565 Retrieves an Boolean value for a given PCD token.
567 Retrieves the Boolean value of a particular PCD token.
568 If the TokenNumber is invalid or the token space
569 specified by Guid does not exist, the results are
572 @param[in] Guid The token space for the token number.
573 @param[in] ExTokenNumber The PCD token number.
575 @return The size Boolean value for the PCD token.
581 IN CONST EFI_GUID
*Guid
,
582 IN UINTN ExTokenNumber
585 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
589 Retrieves the size of the value for a given PCD token.
591 Retrieves the current size of a particular PCD token.
592 If the TokenNumber is invalid, the results are unpredictable.
594 @param[in] Guid The token space for the token number.
595 @param[in] ExTokenNumber The PCD token number.
597 @return The size of the value for the PCD token.
603 IN CONST EFI_GUID
*Guid
,
604 IN UINTN ExTokenNumber
607 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
611 Sets an 8-bit value for a given PCD token.
613 When the PCD service sets a value, it will check to ensure that the
614 size of the value being set is compatible with the Token's existing definition.
615 If it is not, an error will be returned.
617 @param[in] TokenNumber The PCD token number.
618 @param[in] Value The value to set for the PCD token.
620 @retval EFI_SUCCESS Procedure returned successfully.
621 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
622 being set was incompatible with a call to this function.
623 Use GetSize() to retrieve the size of the target data.
624 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
630 IN UINTN TokenNumber
,
634 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
638 Sets an 16-bit value for a given PCD token.
640 When the PCD service sets a value, it will check to ensure that the
641 size of the value being set is compatible with the Token's existing definition.
642 If it is not, an error will be returned.
644 @param[in] TokenNumber The PCD token number.
645 @param[in] Value The value to set for the PCD token.
647 @retval EFI_SUCCESS Procedure returned successfully.
648 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
649 being set was incompatible with a call to this function.
650 Use GetSize() to retrieve the size of the target data.
651 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
657 IN UINTN TokenNumber
,
661 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
665 Sets an 32-bit value for a given PCD token.
667 When the PCD service sets a value, it will check to ensure that the
668 size of the value being set is compatible with the Token's existing definition.
669 If it is not, an error will be returned.
671 @param[in] TokenNumber The PCD token number.
672 @param[in] Value The value to set for the PCD token.
674 @retval EFI_SUCCESS Procedure returned successfully.
675 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
676 being set was incompatible with a call to this function.
677 Use GetSize() to retrieve the size of the target data.
678 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
684 IN UINTN TokenNumber
,
688 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
692 Sets an 64-bit value for a given PCD token.
694 When the PCD service sets a value, it will check to ensure that the
695 size of the value being set is compatible with the Token's existing definition.
696 If it is not, an error will be returned.
698 @param[in] TokenNumber The PCD token number.
699 @param[in] Value The value to set for the PCD token.
701 @retval EFI_SUCCESS Procedure returned successfully.
702 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
703 being set was incompatible with a call to this function.
704 Use GetSize() to retrieve the size of the target data.
705 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
711 IN UINTN TokenNumber
,
715 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
719 Sets a value of a specified size for a given PCD token.
721 When the PCD service sets a value, it will check to ensure that the
722 size of the value being set is compatible with the Token's existing definition.
723 If it is not, an error will be returned.
725 @param[in] TokenNumber The PCD token number.
726 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
727 On input, if the SizeOfValue is greater than the maximum size supported
728 for this TokenNumber then the output value of SizeOfValue will reflect
729 the maximum size supported for this TokenNumber.
730 @param[in] Buffer The buffer to set for the PCD token.
732 @retval EFI_SUCCESS Procedure returned successfully.
733 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
734 being set was incompatible with a call to this function.
735 Use GetSize() to retrieve the size of the target data.
736 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
742 IN UINTN TokenNumber
,
743 IN OUT UINTN
*SizeOfBuffer
,
747 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
751 Sets an Boolean value for a given PCD token.
753 When the PCD service sets a value, it will check to ensure that the
754 size of the value being set is compatible with the Token's existing definition.
755 If it is not, an error will be returned.
757 @param[in] TokenNumber The PCD token number.
758 @param[in] Value The value to set for the PCD token.
760 @retval EFI_SUCCESS Procedure returned successfully.
761 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
762 being set was incompatible with a call to this function.
763 Use GetSize() to retrieve the size of the target data.
764 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
770 IN UINTN TokenNumber
,
774 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
778 Sets an 8-bit value for a given PCD token.
780 When the PCD service sets a value, it will check to ensure that the
781 size of the value being set is compatible with the Token's existing definition.
782 If it is not, an error will be returned.
784 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
785 @param[in] ExTokenNumber The PCD token number.
786 @param[in] Value The value to set for the PCD token.
788 @retval EFI_SUCCESS Procedure returned successfully.
789 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
790 being set was incompatible with a call to this function.
791 Use GetSize() to retrieve the size of the target data.
792 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
798 IN CONST EFI_GUID
*Guid
,
799 IN UINTN ExTokenNumber
,
803 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
807 Sets an 16-bit value for a given PCD token.
809 When the PCD service sets a value, it will check to ensure that the
810 size of the value being set is compatible with the Token's existing definition.
811 If it is not, an error will be returned.
813 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
814 @param[in] ExTokenNumber The PCD token number.
815 @param[in] Value The value to set for the PCD token.
817 @retval EFI_SUCCESS Procedure returned successfully.
818 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
819 being set was incompatible with a call to this function.
820 Use GetSize() to retrieve the size of the target data.
821 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
827 IN CONST EFI_GUID
*Guid
,
828 IN UINTN ExTokenNumber
,
832 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
836 Sets an 32-bit value for a given PCD token.
838 When the PCD service sets a value, it will check to ensure that the
839 size of the value being set is compatible with the Token's existing definition.
840 If it is not, an error will be returned.
842 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
843 @param[in] ExTokenNumber The PCD token number.
844 @param[in] Value The value to set for the PCD token.
846 @retval EFI_SUCCESS Procedure returned successfully.
847 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
848 being set was incompatible with a call to this function.
849 Use GetSize() to retrieve the size of the target data.
850 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
856 IN CONST EFI_GUID
*Guid
,
857 IN UINTN ExTokenNumber
,
861 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
865 Sets an 64-bit value for a given PCD token.
867 When the PCD service sets a value, it will check to ensure that the
868 size of the value being set is compatible with the Token's existing definition.
869 If it is not, an error will be returned.
871 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
872 @param[in] ExTokenNumber The PCD token number.
873 @param[in] Value The value to set for the PCD token.
875 @retval EFI_SUCCESS Procedure returned successfully.
876 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
877 being set was incompatible with a call to this function.
878 Use GetSize() to retrieve the size of the target data.
879 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
885 IN CONST EFI_GUID
*Guid
,
886 IN UINTN ExTokenNumber
,
890 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
894 Sets a value of a specified size for a given PCD token.
896 When the PCD service sets a value, it will check to ensure that the
897 size of the value being set is compatible with the Token's existing definition.
898 If it is not, an error will be returned.
900 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
901 @param[in] ExTokenNumber The PCD token number.
902 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
903 On input, if the SizeOfValue is greater than the maximum size supported
904 for this TokenNumber then the output value of SizeOfValue will reflect
905 the maximum size supported for this TokenNumber.
906 @param[in] Value The buffer to set for the PCD token.
908 @retval EFI_SUCCESS Procedure returned successfully.
909 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
910 being set was incompatible with a call to this function.
911 Use GetSize() to retrieve the size of the target data.
912 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
918 IN CONST EFI_GUID
*Guid
,
919 IN UINTN ExTokenNumber
,
920 IN OUT UINTN
*SizeOfBuffer
,
924 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
928 Sets an Boolean value for a given PCD token.
930 When the PCD service sets a value, it will check to ensure that the
931 size of the value being set is compatible with the Token's existing definition.
932 If it is not, an error will be returned.
934 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
935 @param [in] ExTokenNumber The PCD token number.
936 @param [in] Value The value to set for the PCD token.
938 @retval EFI_SUCCESS Procedure returned successfully.
939 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
940 being set was incompatible with a call to this function.
941 Use GetSize() to retrieve the size of the target data.
942 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
948 IN CONST EFI_GUID
*Guid
,
949 IN UINTN ExTokenNumber
,
953 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
957 Specifies a function to be called anytime the value of a designated token is changed.
959 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
960 @param[in] ExTokenNumber The PCD token number.
961 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
963 @retval EFI_SUCCESS The PCD service has successfully established a call event
964 for the CallBackToken requested.
965 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
970 PeiRegisterCallBackOnSet (
971 IN CONST EFI_GUID
*Guid
, OPTIONAL
972 IN UINTN ExTokenNumber
,
973 IN PCD_PPI_CALLBACK CallBackFunction
976 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
977 return EFI_UNSUPPORTED
;
980 if (CallBackFunction
== NULL
) {
981 return EFI_INVALID_PARAMETER
;
984 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
988 Cancels a previously set callback function for a particular PCD token number.
990 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
991 @param[in] ExTokenNumber The PCD token number.
992 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
994 @retval EFI_SUCCESS The PCD service has successfully established a call event
995 for the CallBackToken requested.
996 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1001 PcdUnRegisterCallBackOnSet (
1002 IN CONST EFI_GUID
*Guid
, OPTIONAL
1003 IN UINTN ExTokenNumber
,
1004 IN PCD_PPI_CALLBACK CallBackFunction
1007 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1008 return EFI_UNSUPPORTED
;
1011 if (CallBackFunction
== NULL
) {
1012 return EFI_INVALID_PARAMETER
;
1015 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1019 Retrieves the next valid token number in a given namespace.
1021 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1022 and one cannot a priori know what token numbers are valid in the database.
1024 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1025 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1026 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1027 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1028 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1029 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1030 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1031 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1034 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1035 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1036 is being made to retrieve tokens from the default token space.
1037 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1039 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1040 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1045 PeiPcdGetNextToken (
1046 IN CONST EFI_GUID
*Guid
, OPTIONAL
1047 IN OUT UINTN
*TokenNumber
1051 PEI_PCD_DATABASE
*PeiPcdDb
;
1052 EFI_GUID
*MatchGuid
;
1053 EFI_GUID
*GuidTable
;
1054 DYNAMICEX_MAPPING
*ExMapTable
;
1057 BOOLEAN PeiExMapTableEmpty
;
1058 UINTN PeiNexTokenNumber
;
1060 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1061 return EFI_UNSUPPORTED
;
1064 PeiPcdDb
= GetPcdDatabase ();
1065 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1066 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1068 if (PeiPcdDb
->ExTokenCount
== 0) {
1069 PeiExMapTableEmpty
= TRUE
;
1071 PeiExMapTableEmpty
= FALSE
;
1074 if (*TokenNumber
> PeiNexTokenNumber
) {
1075 return EFI_NOT_FOUND
;
1078 if (*TokenNumber
> PeiNexTokenNumber
) {
1079 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1080 return EFI_NOT_FOUND
;
1084 if (PeiExMapTableEmpty
) {
1085 return EFI_NOT_FOUND
;
1088 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(EFI_GUID
), Guid
);
1090 if (MatchGuid
== NULL
) {
1091 return EFI_NOT_FOUND
;
1094 GuidTableIdx
= MatchGuid
- GuidTable
;
1096 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1100 // Locate the GUID in ExMapTable first.
1102 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1103 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1110 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1111 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1115 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1116 if (ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) {
1121 while (Index
< PeiPcdDb
->ExTokenCount
) {
1123 if (Index
== PeiPcdDb
->ExTokenCount
) {
1125 // Exceed the length of ExMap Table
1127 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1128 return EFI_NOT_FOUND
;
1129 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1131 // Found the next match
1133 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1140 return EFI_NOT_FOUND
;
1144 Retrieves the next valid PCD token namespace for a given namespace.
1146 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1147 token namespaces on a platform.
1149 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1150 namespace from which the search will start. On output, it designates the next valid
1151 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1152 space of the current platform is returned. If the search cannot locate the next valid
1153 token namespace, an error is returned and the value of *Guid is undefined.
1155 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1156 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1161 PeiPcdGetNextTokenSpace (
1162 IN OUT CONST EFI_GUID
**Guid
1166 EFI_GUID
*MatchGuid
;
1167 PEI_PCD_DATABASE
*PeiPcdDb
;
1168 DYNAMICEX_MAPPING
*ExMapTable
;
1172 BOOLEAN PeiExMapTableEmpty
;
1173 EFI_GUID
*GuidTable
;
1175 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1176 return EFI_UNSUPPORTED
;
1179 ASSERT (Guid
!= NULL
);
1181 PeiPcdDb
= GetPcdDatabase ();
1183 if (PeiPcdDb
->ExTokenCount
== 0) {
1184 PeiExMapTableEmpty
= TRUE
;
1186 PeiExMapTableEmpty
= FALSE
;
1189 if (PeiExMapTableEmpty
) {
1190 return EFI_NOT_FOUND
;
1193 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1194 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1196 if (*Guid
== NULL
) {
1198 // return the first Token Space Guid.
1200 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1204 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(GuidTable
[0]), *Guid
);
1206 if (MatchGuid
== NULL
) {
1207 return EFI_NOT_FOUND
;
1210 GuidTableIdx
= MatchGuid
- GuidTable
;
1213 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1214 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1222 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1223 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1225 for (Index2
= 0 ; Index2
< Index
; Index2
++) {
1226 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1228 // This token namespace should have been found and output at preceding getting.
1235 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1243 return EFI_NOT_FOUND
;
1248 Get PCD value's size for POINTER type PCD.
1250 The POINTER type PCD's value will be stored into a buffer in specified size.
1251 The max size of this PCD's value is described in PCD's definition in DEC file.
1253 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1254 @param MaxSize Maximum size of PCD's value
1255 @param Database Pcd database in PEI phase.
1257 @return PCD value's size for POINTER type PCD.
1262 IN UINTN LocalTokenNumberTableIdx
,
1264 IN PEI_PCD_DATABASE
*Database
1268 UINTN LocalTokenNumber
;
1270 SIZE_INFO
*SizeTable
;
1273 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1275 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1277 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1279 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1281 *MaxSize
= SizeTable
[SizeTableIdx
];
1283 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1286 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1288 // We have only two entry for VPD enabled PCD entry:
1291 // We consider current size is equal to MAX size.
1295 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1297 // We have only two entry for Non-Sku enabled PCD entry:
1301 return SizeTable
[SizeTableIdx
+ 1];
1304 // We have these entry for SKU enabled PCD entry
1306 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1308 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1309 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1310 if (SkuIdTable
[1 + Index
] == Database
->SystemSkuId
) {
1311 return SizeTable
[SizeTableIdx
+ 1 + Index
];
1314 return SizeTable
[SizeTableIdx
+ 1];
1320 Set PCD value's size for POINTER type PCD.
1322 The POINTER type PCD's value will be stored into a buffer in specified size.
1323 The max size of this PCD's value is described in PCD's definition in DEC file.
1325 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1326 @param CurrentSize Maximum size of PCD's value
1327 @param Database Pcd database in PEI phase.
1329 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1330 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1335 IN UINTN LocalTokenNumberTableIdx
,
1336 IN OUT UINTN
*CurrentSize
,
1337 IN PEI_PCD_DATABASE
*Database
1341 UINTN LocalTokenNumber
;
1343 SIZE_INFO
*SizeTable
;
1347 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1349 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1351 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1353 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1355 MaxSize
= SizeTable
[SizeTableIdx
];
1357 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1360 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1362 // We shouldn't come here as we don't support SET for VPD
1367 if ((*CurrentSize
> MaxSize
) ||
1368 (*CurrentSize
== MAX_ADDRESS
)) {
1369 *CurrentSize
= MaxSize
;
1373 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1375 // We have only two entry for Non-Sku enabled PCD entry:
1379 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;
1383 // We have these entry for SKU enabled PCD entry
1385 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1387 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1388 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1389 if (SkuIdTable
[1 + Index
] == Database
->SystemSkuId
) {
1390 SizeTable
[SizeTableIdx
+ 1 + Index
] = (SIZE_INFO
) *CurrentSize
;
1394 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;