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 the feature is enabled and PCD info content is present.
163 if (FeaturePcdGet (PcdPcdInfoGeneration
) && (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 if (!FeaturePcdGet (PcdPcdInfoGeneration
)) {
236 return EFI_UNSUPPORTED
;
238 return GetPcdDatabase()->SystemSkuId
;
242 Sets the SKU value for subsequent calls to set or get PCD token values.
244 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
245 SetSku() is normally called only once by the system.
247 For each item (token), the database can hold a single value that applies to all SKUs,
248 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
249 SKU-specific values are called SKU enabled.
251 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
252 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
253 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
254 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
255 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
256 set for that Id, the results are unpredictable.
258 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
259 set values associated with a PCD token.
269 GetPcdDatabase()->SystemSkuId
= (SKU_ID
) SkuId
;
275 Retrieves an 8-bit value for a given PCD token.
277 Retrieves the current byte-sized value for a PCD token number.
278 If the TokenNumber is invalid, the results are unpredictable.
280 @param[in] TokenNumber The PCD token number.
282 @return The UINT8 value.
291 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
295 Retrieves an 16-bit value for a given PCD token.
297 Retrieves the current 16-bits value for a PCD token number.
298 If the TokenNumber is invalid, the results are unpredictable.
300 @param[in] TokenNumber The PCD token number.
302 @return The UINT16 value.
311 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
315 Retrieves an 32-bit value for a given PCD token.
317 Retrieves the current 32-bits value for a PCD token number.
318 If the TokenNumber is invalid, the results are unpredictable.
320 @param[in] TokenNumber The PCD token number.
322 @return The UINT32 value.
331 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
335 Retrieves an 64-bit value for a given PCD token.
337 Retrieves the current 64-bits value for a PCD token number.
338 If the TokenNumber is invalid, the results are unpredictable.
340 @param[in] TokenNumber The PCD token number.
342 @return The UINT64 value.
351 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
355 Retrieves a pointer to a value for a given PCD token.
357 Retrieves the current pointer to the buffer for a PCD token number.
358 Do not make any assumptions about the alignment of the pointer that
359 is returned by this function call. If the TokenNumber is invalid,
360 the results are unpredictable.
362 @param[in] TokenNumber The PCD token number.
364 @return The pointer to the buffer to be retrieved.
373 return GetWorker (TokenNumber
, 0);
377 Retrieves a Boolean value for a given PCD token.
379 Retrieves the current boolean value for a PCD token number.
380 Do not make any assumptions about the alignment of the pointer that
381 is returned by this function call. If the TokenNumber is invalid,
382 the results are unpredictable.
384 @param[in] TokenNumber The PCD token number.
386 @return The Boolean value.
395 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
399 Retrieves the size of the value for a given PCD token.
401 Retrieves the current size of a particular PCD token.
402 If the TokenNumber is invalid, the results are unpredictable.
404 @param[in] TokenNumber The PCD token number.
406 @return The size of the value for the PCD token.
415 PEI_PCD_DATABASE
*PeiPcdDb
;
418 UINT32 LocalTokenCount
;
420 PeiPcdDb
= GetPcdDatabase ();
421 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
423 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
424 // We have to decrement TokenNumber by 1 to make it usable
425 // as the array index.
429 // EBC compiler is very choosy. It may report warning about comparison
430 // between UINTN and 0 . So we add 1 in each size of the
432 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
434 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
438 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
440 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
448 Retrieves an 8-bit value for a given PCD token.
450 Retrieves the 8-bit value of a particular PCD token.
451 If the TokenNumber is invalid or the token space
452 specified by Guid does not exist, the results are
455 @param[in] Guid The token space for the token number.
456 @param[in] ExTokenNumber The PCD token number.
458 @return The size 8-bit value for the PCD token.
464 IN CONST EFI_GUID
*Guid
,
465 IN UINTN ExTokenNumber
468 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
472 Retrieves an 16-bit value for a given PCD token.
474 Retrieves the 16-bit value of a particular PCD token.
475 If the TokenNumber is invalid or the token space
476 specified by Guid does not exist, the results are
479 @param[in] Guid The token space for the token number.
480 @param[in] ExTokenNumber The PCD token number.
482 @return The size 16-bit value for the PCD token.
488 IN CONST EFI_GUID
*Guid
,
489 IN UINTN ExTokenNumber
492 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
496 Retrieves an 32-bit value for a given PCD token.
498 Retrieves the 32-bit value of a particular PCD token.
499 If the TokenNumber is invalid or the token space
500 specified by Guid does not exist, the results are
503 @param[in] Guid The token space for the token number.
504 @param[in] ExTokenNumber The PCD token number.
506 @return The size 32-bit value for the PCD token.
512 IN CONST EFI_GUID
*Guid
,
513 IN UINTN ExTokenNumber
516 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
520 Retrieves an 64-bit value for a given PCD token.
522 Retrieves the 64-bit value of a particular PCD token.
523 If the TokenNumber is invalid or the token space
524 specified by Guid does not exist, the results are
527 @param[in] Guid The token space for the token number.
528 @param[in] ExTokenNumber The PCD token number.
530 @return The size 64-bit value for the PCD token.
536 IN CONST EFI_GUID
*Guid
,
537 IN UINTN ExTokenNumber
540 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
544 Retrieves a pointer to a value for a given PCD token.
546 Retrieves the current pointer to the buffer for a PCD token number.
547 Do not make any assumptions about the alignment of the pointer that
548 is returned by this function call. If the TokenNumber is invalid,
549 the results are unpredictable.
551 @param[in] Guid The token space for the token number.
552 @param[in] ExTokenNumber The PCD token number.
554 @return The pointer to the buffer to be retrieved.
560 IN CONST EFI_GUID
*Guid
,
561 IN UINTN ExTokenNumber
564 return ExGetWorker (Guid
, ExTokenNumber
, 0);
568 Retrieves an Boolean value for a given PCD token.
570 Retrieves the Boolean value of a particular PCD token.
571 If the TokenNumber is invalid or the token space
572 specified by Guid does not exist, the results are
575 @param[in] Guid The token space for the token number.
576 @param[in] ExTokenNumber The PCD token number.
578 @return The size Boolean value for the PCD token.
584 IN CONST EFI_GUID
*Guid
,
585 IN UINTN ExTokenNumber
588 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
592 Retrieves the size of the value for a given PCD token.
594 Retrieves the current size of a particular PCD token.
595 If the TokenNumber is invalid, the results are unpredictable.
597 @param[in] Guid The token space for the token number.
598 @param[in] ExTokenNumber The PCD token number.
600 @return The size of the value for the PCD token.
606 IN CONST EFI_GUID
*Guid
,
607 IN UINTN ExTokenNumber
610 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
614 Sets an 8-bit value for a given PCD token.
616 When the PCD service sets a value, it will check to ensure that the
617 size of the value being set is compatible with the Token's existing definition.
618 If it is not, an error will be returned.
620 @param[in] TokenNumber The PCD token number.
621 @param[in] Value The value to set for the PCD token.
623 @retval EFI_SUCCESS Procedure returned successfully.
624 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
625 being set was incompatible with a call to this function.
626 Use GetSize() to retrieve the size of the target data.
627 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
633 IN UINTN TokenNumber
,
637 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
641 Sets an 16-bit value for a given PCD token.
643 When the PCD service sets a value, it will check to ensure that the
644 size of the value being set is compatible with the Token's existing definition.
645 If it is not, an error will be returned.
647 @param[in] TokenNumber The PCD token number.
648 @param[in] Value The value to set for the PCD token.
650 @retval EFI_SUCCESS Procedure returned successfully.
651 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
652 being set was incompatible with a call to this function.
653 Use GetSize() to retrieve the size of the target data.
654 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
660 IN UINTN TokenNumber
,
664 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
668 Sets an 32-bit value for a given PCD token.
670 When the PCD service sets a value, it will check to ensure that the
671 size of the value being set is compatible with the Token's existing definition.
672 If it is not, an error will be returned.
674 @param[in] TokenNumber The PCD token number.
675 @param[in] Value The value to set for the PCD token.
677 @retval EFI_SUCCESS Procedure returned successfully.
678 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
679 being set was incompatible with a call to this function.
680 Use GetSize() to retrieve the size of the target data.
681 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
687 IN UINTN TokenNumber
,
691 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
695 Sets an 64-bit value for a given PCD token.
697 When the PCD service sets a value, it will check to ensure that the
698 size of the value being set is compatible with the Token's existing definition.
699 If it is not, an error will be returned.
701 @param[in] TokenNumber The PCD token number.
702 @param[in] Value The value to set for the PCD token.
704 @retval EFI_SUCCESS Procedure returned successfully.
705 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
706 being set was incompatible with a call to this function.
707 Use GetSize() to retrieve the size of the target data.
708 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
714 IN UINTN TokenNumber
,
718 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
722 Sets a value of a specified size for a given PCD token.
724 When the PCD service sets a value, it will check to ensure that the
725 size of the value being set is compatible with the Token's existing definition.
726 If it is not, an error will be returned.
728 @param[in] TokenNumber The PCD token number.
729 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
730 On input, if the SizeOfValue is greater than the maximum size supported
731 for this TokenNumber then the output value of SizeOfValue will reflect
732 the maximum size supported for this TokenNumber.
733 @param[in] Buffer The buffer to set for the PCD token.
735 @retval EFI_SUCCESS Procedure returned successfully.
736 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
737 being set was incompatible with a call to this function.
738 Use GetSize() to retrieve the size of the target data.
739 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
745 IN UINTN TokenNumber
,
746 IN OUT UINTN
*SizeOfBuffer
,
750 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
754 Sets an Boolean value for a given PCD token.
756 When the PCD service sets a value, it will check to ensure that the
757 size of the value being set is compatible with the Token's existing definition.
758 If it is not, an error will be returned.
760 @param[in] TokenNumber The PCD token number.
761 @param[in] Value The value to set for the PCD token.
763 @retval EFI_SUCCESS Procedure returned successfully.
764 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
765 being set was incompatible with a call to this function.
766 Use GetSize() to retrieve the size of the target data.
767 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
773 IN UINTN TokenNumber
,
777 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
781 Sets an 8-bit value for a given PCD token.
783 When the PCD service sets a value, it will check to ensure that the
784 size of the value being set is compatible with the Token's existing definition.
785 If it is not, an error will be returned.
787 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
788 @param[in] ExTokenNumber The PCD token number.
789 @param[in] Value The value to set for the PCD token.
791 @retval EFI_SUCCESS Procedure returned successfully.
792 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
793 being set was incompatible with a call to this function.
794 Use GetSize() to retrieve the size of the target data.
795 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
801 IN CONST EFI_GUID
*Guid
,
802 IN UINTN ExTokenNumber
,
806 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
810 Sets an 16-bit value for a given PCD token.
812 When the PCD service sets a value, it will check to ensure that the
813 size of the value being set is compatible with the Token's existing definition.
814 If it is not, an error will be returned.
816 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
817 @param[in] ExTokenNumber The PCD token number.
818 @param[in] Value The value to set for the PCD token.
820 @retval EFI_SUCCESS Procedure returned successfully.
821 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
822 being set was incompatible with a call to this function.
823 Use GetSize() to retrieve the size of the target data.
824 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
830 IN CONST EFI_GUID
*Guid
,
831 IN UINTN ExTokenNumber
,
835 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
839 Sets an 32-bit value for a given PCD token.
841 When the PCD service sets a value, it will check to ensure that the
842 size of the value being set is compatible with the Token's existing definition.
843 If it is not, an error will be returned.
845 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
846 @param[in] ExTokenNumber The PCD token number.
847 @param[in] Value The value to set for the PCD token.
849 @retval EFI_SUCCESS Procedure returned successfully.
850 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
851 being set was incompatible with a call to this function.
852 Use GetSize() to retrieve the size of the target data.
853 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
859 IN CONST EFI_GUID
*Guid
,
860 IN UINTN ExTokenNumber
,
864 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
868 Sets an 64-bit value for a given PCD token.
870 When the PCD service sets a value, it will check to ensure that the
871 size of the value being set is compatible with the Token's existing definition.
872 If it is not, an error will be returned.
874 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
875 @param[in] ExTokenNumber The PCD token number.
876 @param[in] Value The value to set for the PCD token.
878 @retval EFI_SUCCESS Procedure returned successfully.
879 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
880 being set was incompatible with a call to this function.
881 Use GetSize() to retrieve the size of the target data.
882 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
888 IN CONST EFI_GUID
*Guid
,
889 IN UINTN ExTokenNumber
,
893 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
897 Sets a value of a specified size for a given PCD token.
899 When the PCD service sets a value, it will check to ensure that the
900 size of the value being set is compatible with the Token's existing definition.
901 If it is not, an error will be returned.
903 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
904 @param[in] ExTokenNumber The PCD token number.
905 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
906 On input, if the SizeOfValue is greater than the maximum size supported
907 for this TokenNumber then the output value of SizeOfValue will reflect
908 the maximum size supported for this TokenNumber.
909 @param[in] Value The buffer to set for the PCD token.
911 @retval EFI_SUCCESS Procedure returned successfully.
912 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
913 being set was incompatible with a call to this function.
914 Use GetSize() to retrieve the size of the target data.
915 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
921 IN CONST EFI_GUID
*Guid
,
922 IN UINTN ExTokenNumber
,
923 IN OUT UINTN
*SizeOfBuffer
,
927 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
931 Sets an Boolean value for a given PCD token.
933 When the PCD service sets a value, it will check to ensure that the
934 size of the value being set is compatible with the Token's existing definition.
935 If it is not, an error will be returned.
937 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
938 @param [in] ExTokenNumber The PCD token number.
939 @param [in] Value The value to set for the PCD token.
941 @retval EFI_SUCCESS Procedure returned successfully.
942 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
943 being set was incompatible with a call to this function.
944 Use GetSize() to retrieve the size of the target data.
945 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
951 IN CONST EFI_GUID
*Guid
,
952 IN UINTN ExTokenNumber
,
956 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
960 Specifies a function to be called anytime the value of a designated token is changed.
962 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
963 @param[in] ExTokenNumber The PCD token number.
964 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
966 @retval EFI_SUCCESS The PCD service has successfully established a call event
967 for the CallBackToken requested.
968 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
973 PeiRegisterCallBackOnSet (
974 IN CONST EFI_GUID
*Guid
, OPTIONAL
975 IN UINTN ExTokenNumber
,
976 IN PCD_PPI_CALLBACK CallBackFunction
979 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
980 return EFI_UNSUPPORTED
;
983 if (CallBackFunction
== NULL
) {
984 return EFI_INVALID_PARAMETER
;
987 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
991 Cancels a previously set callback function for a particular PCD token number.
993 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
994 @param[in] ExTokenNumber The PCD token number.
995 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
997 @retval EFI_SUCCESS The PCD service has successfully established a call event
998 for the CallBackToken requested.
999 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1004 PcdUnRegisterCallBackOnSet (
1005 IN CONST EFI_GUID
*Guid
, OPTIONAL
1006 IN UINTN ExTokenNumber
,
1007 IN PCD_PPI_CALLBACK CallBackFunction
1010 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1011 return EFI_UNSUPPORTED
;
1014 if (CallBackFunction
== NULL
) {
1015 return EFI_INVALID_PARAMETER
;
1018 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1022 Retrieves the next valid token number in a given namespace.
1024 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1025 and one cannot a priori know what token numbers are valid in the database.
1027 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1028 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1029 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1030 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1031 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1032 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1033 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1034 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1037 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1038 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1039 is being made to retrieve tokens from the default token space.
1040 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1042 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1043 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1048 PeiPcdGetNextToken (
1049 IN CONST EFI_GUID
*Guid
, OPTIONAL
1050 IN OUT UINTN
*TokenNumber
1054 PEI_PCD_DATABASE
*PeiPcdDb
;
1055 EFI_GUID
*MatchGuid
;
1056 EFI_GUID
*GuidTable
;
1057 DYNAMICEX_MAPPING
*ExMapTable
;
1060 BOOLEAN PeiExMapTableEmpty
;
1061 UINTN PeiNexTokenNumber
;
1063 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1064 return EFI_UNSUPPORTED
;
1067 PeiPcdDb
= GetPcdDatabase ();
1068 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1069 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1071 if (PeiPcdDb
->ExTokenCount
== 0) {
1072 PeiExMapTableEmpty
= TRUE
;
1074 PeiExMapTableEmpty
= FALSE
;
1077 if (*TokenNumber
> PeiNexTokenNumber
) {
1078 return EFI_NOT_FOUND
;
1081 if (*TokenNumber
> PeiNexTokenNumber
) {
1082 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1083 return EFI_NOT_FOUND
;
1087 if (PeiExMapTableEmpty
) {
1088 return EFI_NOT_FOUND
;
1091 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(EFI_GUID
), Guid
);
1093 if (MatchGuid
== NULL
) {
1094 return EFI_NOT_FOUND
;
1097 GuidTableIdx
= MatchGuid
- GuidTable
;
1099 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1103 // Locate the GUID in ExMapTable first.
1105 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1106 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1113 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1114 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1118 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1119 if (ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) {
1124 while (Index
< PeiPcdDb
->ExTokenCount
) {
1126 if (Index
== PeiPcdDb
->ExTokenCount
) {
1128 // Exceed the length of ExMap Table
1130 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1131 return EFI_NOT_FOUND
;
1132 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1134 // Found the next match
1136 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1143 return EFI_NOT_FOUND
;
1147 Retrieves the next valid PCD token namespace for a given namespace.
1149 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1150 token namespaces on a platform.
1152 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1153 namespace from which the search will start. On output, it designates the next valid
1154 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1155 space of the current platform is returned. If the search cannot locate the next valid
1156 token namespace, an error is returned and the value of *Guid is undefined.
1158 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1159 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1164 PeiPcdGetNextTokenSpace (
1165 IN OUT CONST EFI_GUID
**Guid
1169 EFI_GUID
*MatchGuid
;
1170 PEI_PCD_DATABASE
*PeiPcdDb
;
1171 DYNAMICEX_MAPPING
*ExMapTable
;
1175 BOOLEAN PeiExMapTableEmpty
;
1176 EFI_GUID
*GuidTable
;
1178 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1179 return EFI_UNSUPPORTED
;
1182 ASSERT (Guid
!= NULL
);
1184 PeiPcdDb
= GetPcdDatabase ();
1186 if (PeiPcdDb
->ExTokenCount
== 0) {
1187 PeiExMapTableEmpty
= TRUE
;
1189 PeiExMapTableEmpty
= FALSE
;
1192 if (PeiExMapTableEmpty
) {
1193 return EFI_NOT_FOUND
;
1196 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1197 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1199 if (*Guid
== NULL
) {
1201 // return the first Token Space Guid.
1203 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1207 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(GuidTable
[0]), *Guid
);
1209 if (MatchGuid
== NULL
) {
1210 return EFI_NOT_FOUND
;
1213 GuidTableIdx
= MatchGuid
- GuidTable
;
1216 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1217 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1225 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1226 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1228 for (Index2
= 0 ; Index2
< Index
; Index2
++) {
1229 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1231 // This token namespace should have been found and output at preceding getting.
1238 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1246 return EFI_NOT_FOUND
;
1251 Get PCD value's size for POINTER type PCD.
1253 The POINTER type PCD's value will be stored into a buffer in specified size.
1254 The max size of this PCD's value is described in PCD's definition in DEC file.
1256 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1257 @param MaxSize Maximum size of PCD's value
1258 @param Database Pcd database in PEI phase.
1260 @return PCD value's size for POINTER type PCD.
1265 IN UINTN LocalTokenNumberTableIdx
,
1267 IN PEI_PCD_DATABASE
*Database
1271 UINTN LocalTokenNumber
;
1273 SIZE_INFO
*SizeTable
;
1276 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1278 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1280 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1282 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1284 *MaxSize
= SizeTable
[SizeTableIdx
];
1286 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1289 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1291 // We have only two entry for VPD enabled PCD entry:
1294 // We consider current size is equal to MAX size.
1298 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1300 // We have only two entry for Non-Sku enabled PCD entry:
1304 return SizeTable
[SizeTableIdx
+ 1];
1307 // We have these entry for SKU enabled PCD entry
1309 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1311 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1312 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1313 if (SkuIdTable
[1 + Index
] == Database
->SystemSkuId
) {
1314 return SizeTable
[SizeTableIdx
+ 1 + Index
];
1317 return SizeTable
[SizeTableIdx
+ 1];
1323 Set PCD value's size for POINTER type PCD.
1325 The POINTER type PCD's value will be stored into a buffer in specified size.
1326 The max size of this PCD's value is described in PCD's definition in DEC file.
1328 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1329 @param CurrentSize Maximum size of PCD's value
1330 @param Database Pcd database in PEI phase.
1332 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1333 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1338 IN UINTN LocalTokenNumberTableIdx
,
1339 IN OUT UINTN
*CurrentSize
,
1340 IN PEI_PCD_DATABASE
*Database
1344 UINTN LocalTokenNumber
;
1346 SIZE_INFO
*SizeTable
;
1350 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1352 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1354 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1356 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1358 MaxSize
= SizeTable
[SizeTableIdx
];
1360 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1363 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1365 // We shouldn't come here as we don't support SET for VPD
1370 if ((*CurrentSize
> MaxSize
) ||
1371 (*CurrentSize
== MAX_ADDRESS
)) {
1372 *CurrentSize
= MaxSize
;
1376 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1378 // We have only two entry for Non-Sku enabled PCD entry:
1382 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;
1386 // We have these entry for SKU enabled PCD entry
1388 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1390 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1391 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1392 if (SkuIdTable
[1 + Index
] == Database
->SystemSkuId
) {
1393 SizeTable
[SizeTableIdx
+ 1 + Index
] = (SIZE_INFO
) *CurrentSize
;
1397 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;