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 Main entry for PCD PEIM driver.
135 This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.
137 @param FileHandle Handle of the file being invoked.
138 @param PeiServices Describes the list of possible PEI Services.
140 @return Status of install PCD_PPI
146 IN EFI_PEI_FILE_HANDLE FileHandle
,
147 IN CONST EFI_PEI_SERVICES
**PeiServices
152 BuildPcdDatabase (FileHandle
);
155 // Install PCD_PPI and EFI_PEI_PCD_PPI.
157 Status
= PeiServicesInstallPpi (&mPpiList
[0]);
158 ASSERT_EFI_ERROR (Status
);
161 // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
163 Status
= PeiServicesInstallPpi (&mPpiList2
[0]);
164 ASSERT_EFI_ERROR (Status
);
170 Retrieve additional information associated with a PCD token in the default token space.
172 This includes information such as the type of value the TokenNumber is associated with as well as possible
173 human readable name that is associated with the token.
175 @param[in] TokenNumber The PCD token number.
176 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
177 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
179 @retval EFI_SUCCESS The PCD information was returned successfully.
180 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
184 PeiGetPcdInfoGetInfo (
185 IN UINTN TokenNumber
,
186 OUT EFI_PCD_INFO
*PcdInfo
189 return PeiGetPcdInfo (NULL
, TokenNumber
, PcdInfo
);
193 Retrieve additional information associated with a PCD token.
195 This includes information such as the type of value the TokenNumber is associated with as well as possible
196 human readable name that is associated with the token.
198 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
199 @param[in] TokenNumber The PCD token number.
200 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
201 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
203 @retval EFI_SUCCESS The PCD information was returned successfully.
204 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
208 PeiGetPcdInfoGetInfoEx (
209 IN CONST EFI_GUID
*Guid
,
210 IN UINTN TokenNumber
,
211 OUT EFI_PCD_INFO
*PcdInfo
214 return PeiGetPcdInfo (Guid
, TokenNumber
, PcdInfo
);
218 Retrieve the currently set SKU Id.
220 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
221 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
226 PeiGetPcdInfoGetSku (
230 return (UINTN
) GetPcdDatabase()->SystemSkuId
;
234 Sets the SKU value for subsequent calls to set or get PCD token values.
236 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
237 SetSku() is normally called only once by the system.
239 For each item (token), the database can hold a single value that applies to all SKUs,
240 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
241 SKU-specific values are called SKU enabled.
243 The SKU Id of zero is reserved as a default.
244 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
245 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
246 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
247 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
248 set for that Id, the results are unpredictable.
250 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
251 set values associated with a PCD token.
260 PEI_PCD_DATABASE
*PeiPcdDb
;
264 PeiPcdDb
= GetPcdDatabase();
266 if (SkuId
== PeiPcdDb
->SystemSkuId
) {
268 // The input SKU Id is equal to current SKU Id, return directly.
273 if (PeiPcdDb
->SystemSkuId
!= (SKU_ID
) 0) {
274 DEBUG ((DEBUG_ERROR
, "PcdPei - The SKU Id could be changed only once."));
277 "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",
278 PeiPcdDb
->SystemSkuId
,
285 SkuIdTable
= (SKU_ID
*) ((UINT8
*) PeiPcdDb
+ PeiPcdDb
->SkuIdTableOffset
);
286 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
287 if (SkuId
== SkuIdTable
[Index
+ 1]) {
288 DEBUG ((EFI_D_INFO
, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID
) SkuId
));
289 PeiPcdDb
->SystemSkuId
= (SKU_ID
) SkuId
;
295 // Invalid input SkuId, the default SKU Id will be still used for the system.
297 DEBUG ((EFI_D_INFO
, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));
302 Retrieves an 8-bit value for a given PCD token.
304 Retrieves the current byte-sized value for a PCD token number.
305 If the TokenNumber is invalid, the results are unpredictable.
307 @param[in] TokenNumber The PCD token number.
309 @return The UINT8 value.
318 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
322 Retrieves an 16-bit value for a given PCD token.
324 Retrieves the current 16-bits value for a PCD token number.
325 If the TokenNumber is invalid, the results are unpredictable.
327 @param[in] TokenNumber The PCD token number.
329 @return The UINT16 value.
338 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
342 Retrieves an 32-bit value for a given PCD token.
344 Retrieves the current 32-bits value for a PCD token number.
345 If the TokenNumber is invalid, the results are unpredictable.
347 @param[in] TokenNumber The PCD token number.
349 @return The UINT32 value.
358 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
362 Retrieves an 64-bit value for a given PCD token.
364 Retrieves the current 64-bits value for a PCD token number.
365 If the TokenNumber is invalid, the results are unpredictable.
367 @param[in] TokenNumber The PCD token number.
369 @return The UINT64 value.
378 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
382 Retrieves a pointer to a value for a given PCD token.
384 Retrieves the current pointer to the buffer for a PCD token number.
385 Do not make any assumptions about the alignment of the pointer that
386 is returned by this function call. If the TokenNumber is invalid,
387 the results are unpredictable.
389 @param[in] TokenNumber The PCD token number.
391 @return The pointer to the buffer to be retrieved.
400 return GetWorker (TokenNumber
, 0);
404 Retrieves a Boolean value for a given PCD token.
406 Retrieves the current boolean value for a PCD token number.
407 Do not make any assumptions about the alignment of the pointer that
408 is returned by this function call. If the TokenNumber is invalid,
409 the results are unpredictable.
411 @param[in] TokenNumber The PCD token number.
413 @return The Boolean value.
422 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
426 Retrieves the size of the value for a given PCD token.
428 Retrieves the current size of a particular PCD token.
429 If the TokenNumber is invalid, the results are unpredictable.
431 @param[in] TokenNumber The PCD token number.
433 @return The size of the value for the PCD token.
442 PEI_PCD_DATABASE
*PeiPcdDb
;
445 UINT32 LocalTokenCount
;
447 PeiPcdDb
= GetPcdDatabase ();
448 LocalTokenCount
= PeiPcdDb
->LocalTokenCount
;
450 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
451 // We have to decrement TokenNumber by 1 to make it usable
452 // as the array index.
456 // EBC compiler is very choosy. It may report warning about comparison
457 // between UINTN and 0 . So we add 1 in each size of the
459 ASSERT (TokenNumber
+ 1 < (LocalTokenCount
+ 1));
461 Size
= (*((UINT32
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->LocalTokenNumberTableOffset
) + TokenNumber
) & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
465 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
467 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
475 Retrieves an 8-bit value for a given PCD token.
477 Retrieves the 8-bit value of a particular PCD token.
478 If the TokenNumber is invalid or the token space
479 specified by Guid does not exist, the results are
482 @param[in] Guid The token space for the token number.
483 @param[in] ExTokenNumber The PCD token number.
485 @return The size 8-bit value for the PCD token.
491 IN CONST EFI_GUID
*Guid
,
492 IN UINTN ExTokenNumber
495 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
499 Retrieves an 16-bit value for a given PCD token.
501 Retrieves the 16-bit value of a particular PCD token.
502 If the TokenNumber is invalid or the token space
503 specified by Guid does not exist, the results are
506 @param[in] Guid The token space for the token number.
507 @param[in] ExTokenNumber The PCD token number.
509 @return The size 16-bit value for the PCD token.
515 IN CONST EFI_GUID
*Guid
,
516 IN UINTN ExTokenNumber
519 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
523 Retrieves an 32-bit value for a given PCD token.
525 Retrieves the 32-bit value of a particular PCD token.
526 If the TokenNumber is invalid or the token space
527 specified by Guid does not exist, the results are
530 @param[in] Guid The token space for the token number.
531 @param[in] ExTokenNumber The PCD token number.
533 @return The size 32-bit value for the PCD token.
539 IN CONST EFI_GUID
*Guid
,
540 IN UINTN ExTokenNumber
543 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
547 Retrieves an 64-bit value for a given PCD token.
549 Retrieves the 64-bit value of a particular PCD token.
550 If the TokenNumber is invalid or the token space
551 specified by Guid does not exist, the results are
554 @param[in] Guid The token space for the token number.
555 @param[in] ExTokenNumber The PCD token number.
557 @return The size 64-bit value for the PCD token.
563 IN CONST EFI_GUID
*Guid
,
564 IN UINTN ExTokenNumber
567 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
571 Retrieves a pointer to a value for a given PCD token.
573 Retrieves the current pointer to the buffer for a PCD token number.
574 Do not make any assumptions about the alignment of the pointer that
575 is returned by this function call. If the TokenNumber is invalid,
576 the results are unpredictable.
578 @param[in] Guid The token space for the token number.
579 @param[in] ExTokenNumber The PCD token number.
581 @return The pointer to the buffer to be retrieved.
587 IN CONST EFI_GUID
*Guid
,
588 IN UINTN ExTokenNumber
591 return ExGetWorker (Guid
, ExTokenNumber
, 0);
595 Retrieves an Boolean value for a given PCD token.
597 Retrieves the Boolean value of a particular PCD token.
598 If the TokenNumber is invalid or the token space
599 specified by Guid does not exist, the results are
602 @param[in] Guid The token space for the token number.
603 @param[in] ExTokenNumber The PCD token number.
605 @return The size Boolean value for the PCD token.
611 IN CONST EFI_GUID
*Guid
,
612 IN UINTN ExTokenNumber
615 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
619 Retrieves the size of the value for a given PCD token.
621 Retrieves the current size of a particular PCD token.
622 If the TokenNumber is invalid, the results are unpredictable.
624 @param[in] Guid The token space for the token number.
625 @param[in] ExTokenNumber The PCD token number.
627 @return The size of the value for the PCD token.
633 IN CONST EFI_GUID
*Guid
,
634 IN UINTN ExTokenNumber
637 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
641 Sets an 8-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 16-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 32-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 an 64-bit value 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] Value The value to set for the PCD token.
731 @retval EFI_SUCCESS Procedure returned successfully.
732 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
733 being set was incompatible with a call to this function.
734 Use GetSize() to retrieve the size of the target data.
735 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
741 IN UINTN TokenNumber
,
745 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
749 Sets a value of a specified size for a given PCD token.
751 When the PCD service sets a value, it will check to ensure that the
752 size of the value being set is compatible with the Token's existing definition.
753 If it is not, an error will be returned.
755 @param[in] TokenNumber The PCD token number.
756 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
757 On input, if the SizeOfValue is greater than the maximum size supported
758 for this TokenNumber then the output value of SizeOfValue will reflect
759 the maximum size supported for this TokenNumber.
760 @param[in] Buffer The buffer to set for the PCD token.
762 @retval EFI_SUCCESS Procedure returned successfully.
763 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
764 being set was incompatible with a call to this function.
765 Use GetSize() to retrieve the size of the target data.
766 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
772 IN UINTN TokenNumber
,
773 IN OUT UINTN
*SizeOfBuffer
,
777 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
781 Sets an Boolean 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] TokenNumber The PCD token number.
788 @param[in] Value The value to set for the PCD token.
790 @retval EFI_SUCCESS Procedure returned successfully.
791 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
792 being set was incompatible with a call to this function.
793 Use GetSize() to retrieve the size of the target data.
794 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
800 IN UINTN TokenNumber
,
804 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
808 Sets an 8-bit value for a given PCD token.
810 When the PCD service sets a value, it will check to ensure that the
811 size of the value being set is compatible with the Token's existing definition.
812 If it is not, an error will be returned.
814 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
815 @param[in] ExTokenNumber The PCD token number.
816 @param[in] Value The value to set for the PCD token.
818 @retval EFI_SUCCESS Procedure returned successfully.
819 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
820 being set was incompatible with a call to this function.
821 Use GetSize() to retrieve the size of the target data.
822 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
828 IN CONST EFI_GUID
*Guid
,
829 IN UINTN ExTokenNumber
,
833 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
837 Sets an 16-bit value for a given PCD token.
839 When the PCD service sets a value, it will check to ensure that the
840 size of the value being set is compatible with the Token's existing definition.
841 If it is not, an error will be returned.
843 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
844 @param[in] ExTokenNumber The PCD token number.
845 @param[in] Value The value to set for the PCD token.
847 @retval EFI_SUCCESS Procedure returned successfully.
848 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
849 being set was incompatible with a call to this function.
850 Use GetSize() to retrieve the size of the target data.
851 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
857 IN CONST EFI_GUID
*Guid
,
858 IN UINTN ExTokenNumber
,
862 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
866 Sets an 32-bit value for a given PCD token.
868 When the PCD service sets a value, it will check to ensure that the
869 size of the value being set is compatible with the Token's existing definition.
870 If it is not, an error will be returned.
872 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
873 @param[in] ExTokenNumber The PCD token number.
874 @param[in] Value The value to set for the PCD token.
876 @retval EFI_SUCCESS Procedure returned successfully.
877 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
878 being set was incompatible with a call to this function.
879 Use GetSize() to retrieve the size of the target data.
880 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
886 IN CONST EFI_GUID
*Guid
,
887 IN UINTN ExTokenNumber
,
891 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
895 Sets an 64-bit value for a given PCD token.
897 When the PCD service sets a value, it will check to ensure that the
898 size of the value being set is compatible with the Token's existing definition.
899 If it is not, an error will be returned.
901 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
902 @param[in] ExTokenNumber The PCD token number.
903 @param[in] Value The value to set for the PCD token.
905 @retval EFI_SUCCESS Procedure returned successfully.
906 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
907 being set was incompatible with a call to this function.
908 Use GetSize() to retrieve the size of the target data.
909 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
915 IN CONST EFI_GUID
*Guid
,
916 IN UINTN ExTokenNumber
,
920 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
924 Sets a value of a specified size for a given PCD token.
926 When the PCD service sets a value, it will check to ensure that the
927 size of the value being set is compatible with the Token's existing definition.
928 If it is not, an error will be returned.
930 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
931 @param[in] ExTokenNumber The PCD token number.
932 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
933 On input, if the SizeOfValue is greater than the maximum size supported
934 for this TokenNumber then the output value of SizeOfValue will reflect
935 the maximum size supported for this TokenNumber.
936 @param[in] Value The buffer 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
,
950 IN OUT UINTN
*SizeOfBuffer
,
954 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
958 Sets an Boolean value for a given PCD token.
960 When the PCD service sets a value, it will check to ensure that the
961 size of the value being set is compatible with the Token's existing definition.
962 If it is not, an error will be returned.
964 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
965 @param [in] ExTokenNumber The PCD token number.
966 @param [in] Value The value to set for the PCD token.
968 @retval EFI_SUCCESS Procedure returned successfully.
969 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
970 being set was incompatible with a call to this function.
971 Use GetSize() to retrieve the size of the target data.
972 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
978 IN CONST EFI_GUID
*Guid
,
979 IN UINTN ExTokenNumber
,
983 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
987 Specifies a function to be called anytime the value of a designated token is changed.
989 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
990 @param[in] ExTokenNumber The PCD token number.
991 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
993 @retval EFI_SUCCESS The PCD service has successfully established a call event
994 for the CallBackToken requested.
995 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1000 PeiRegisterCallBackOnSet (
1001 IN CONST EFI_GUID
*Guid
, OPTIONAL
1002 IN UINTN ExTokenNumber
,
1003 IN PCD_PPI_CALLBACK CallBackFunction
1006 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1007 return EFI_UNSUPPORTED
;
1010 if (CallBackFunction
== NULL
) {
1011 return EFI_INVALID_PARAMETER
;
1014 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
1018 Cancels a previously set callback function for a particular PCD token number.
1020 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1021 @param[in] ExTokenNumber The PCD token number.
1022 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1024 @retval EFI_SUCCESS The PCD service has successfully established a call event
1025 for the CallBackToken requested.
1026 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1031 PcdUnRegisterCallBackOnSet (
1032 IN CONST EFI_GUID
*Guid
, OPTIONAL
1033 IN UINTN ExTokenNumber
,
1034 IN PCD_PPI_CALLBACK CallBackFunction
1037 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
1038 return EFI_UNSUPPORTED
;
1041 if (CallBackFunction
== NULL
) {
1042 return EFI_INVALID_PARAMETER
;
1045 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
1049 Retrieves the next valid token number in a given namespace.
1051 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1052 and one cannot a priori know what token numbers are valid in the database.
1054 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1055 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1056 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1057 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1058 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1059 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1060 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1061 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1064 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1065 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1066 is being made to retrieve tokens from the default token space.
1067 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1069 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1070 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1075 PeiPcdGetNextToken (
1076 IN CONST EFI_GUID
*Guid
, OPTIONAL
1077 IN OUT UINTN
*TokenNumber
1081 PEI_PCD_DATABASE
*PeiPcdDb
;
1082 EFI_GUID
*MatchGuid
;
1083 EFI_GUID
*GuidTable
;
1084 DYNAMICEX_MAPPING
*ExMapTable
;
1087 BOOLEAN PeiExMapTableEmpty
;
1088 UINTN PeiNexTokenNumber
;
1090 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1091 return EFI_UNSUPPORTED
;
1094 PeiPcdDb
= GetPcdDatabase ();
1095 PeiNexTokenNumber
= PeiPcdDb
->LocalTokenCount
- PeiPcdDb
->ExTokenCount
;
1096 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1098 if (PeiPcdDb
->ExTokenCount
== 0) {
1099 PeiExMapTableEmpty
= TRUE
;
1101 PeiExMapTableEmpty
= FALSE
;
1104 if (*TokenNumber
> PeiNexTokenNumber
) {
1105 return EFI_NOT_FOUND
;
1108 if (*TokenNumber
> PeiNexTokenNumber
) {
1109 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1110 return EFI_NOT_FOUND
;
1114 if (PeiExMapTableEmpty
) {
1115 return EFI_NOT_FOUND
;
1118 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(EFI_GUID
), Guid
);
1120 if (MatchGuid
== NULL
) {
1121 return EFI_NOT_FOUND
;
1124 GuidTableIdx
= MatchGuid
- GuidTable
;
1126 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1130 // Locate the GUID in ExMapTable first.
1132 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1133 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1141 // If given token number is PCD_INVALID_TOKEN_NUMBER, then return the first
1142 // token number in found token space.
1144 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
1145 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1149 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1150 if ((ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) && (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
)) {
1155 while (Index
< PeiPcdDb
->ExTokenCount
) {
1157 if (Index
== PeiPcdDb
->ExTokenCount
) {
1159 // Exceed the length of ExMap Table
1161 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1162 return EFI_NOT_FOUND
;
1163 } else if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1165 // Found the next match
1167 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1174 return EFI_NOT_FOUND
;
1178 Retrieves the next valid PCD token namespace for a given namespace.
1180 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1181 token namespaces on a platform.
1183 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1184 namespace from which the search will start. On output, it designates the next valid
1185 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1186 space of the current platform is returned. If the search cannot locate the next valid
1187 token namespace, an error is returned and the value of *Guid is undefined.
1189 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1190 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1195 PeiPcdGetNextTokenSpace (
1196 IN OUT CONST EFI_GUID
**Guid
1200 EFI_GUID
*MatchGuid
;
1201 PEI_PCD_DATABASE
*PeiPcdDb
;
1202 DYNAMICEX_MAPPING
*ExMapTable
;
1206 BOOLEAN PeiExMapTableEmpty
;
1207 EFI_GUID
*GuidTable
;
1209 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1210 return EFI_UNSUPPORTED
;
1213 ASSERT (Guid
!= NULL
);
1215 PeiPcdDb
= GetPcdDatabase ();
1217 if (PeiPcdDb
->ExTokenCount
== 0) {
1218 PeiExMapTableEmpty
= TRUE
;
1220 PeiExMapTableEmpty
= FALSE
;
1223 if (PeiExMapTableEmpty
) {
1224 return EFI_NOT_FOUND
;
1227 ExMapTable
= (DYNAMICEX_MAPPING
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->ExMapTableOffset
);
1228 GuidTable
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
);
1230 if (*Guid
== NULL
) {
1232 // return the first Token Space Guid.
1234 *Guid
= GuidTable
+ ExMapTable
[0].ExGuidIndex
;
1238 MatchGuid
= ScanGuid (GuidTable
, PeiPcdDb
->GuidTableCount
* sizeof(GuidTable
[0]), *Guid
);
1240 if (MatchGuid
== NULL
) {
1241 return EFI_NOT_FOUND
;
1244 GuidTableIdx
= MatchGuid
- GuidTable
;
1247 for (Index
= 0; Index
< PeiPcdDb
->ExTokenCount
; Index
++) {
1248 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1256 for ( ; Index
< PeiPcdDb
->ExTokenCount
; Index
++ ) {
1257 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1259 for (Index2
= 0 ; Index2
< Index
; Index2
++) {
1260 if (ExMapTable
[Index2
].ExGuidIndex
== ExMapTable
[Index
].ExGuidIndex
) {
1262 // This token namespace should have been found and output at preceding getting.
1269 *Guid
= (EFI_GUID
*)((UINT8
*)PeiPcdDb
+ PeiPcdDb
->GuidTableOffset
) + ExMapTable
[Index
].ExGuidIndex
;
1277 return EFI_NOT_FOUND
;
1282 Get PCD value's size for POINTER type PCD.
1284 The POINTER type PCD's value will be stored into a buffer in specified size.
1285 The max size of this PCD's value is described in PCD's definition in DEC file.
1287 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1288 @param MaxSize Maximum size of PCD's value
1289 @param Database Pcd database in PEI phase.
1291 @return PCD value's size for POINTER type PCD.
1296 IN UINTN LocalTokenNumberTableIdx
,
1298 IN PEI_PCD_DATABASE
*Database
1302 UINTN LocalTokenNumber
;
1304 SIZE_INFO
*SizeTable
;
1307 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1309 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1311 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1313 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1315 *MaxSize
= SizeTable
[SizeTableIdx
];
1317 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1320 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1322 // We have only two entry for VPD enabled PCD entry:
1325 // We consider current size is equal to MAX size.
1329 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1331 // We have only two entry for Non-Sku enabled PCD entry:
1335 return SizeTable
[SizeTableIdx
+ 1];
1338 // We have these entry for SKU enabled PCD entry
1340 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1342 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1343 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1344 if (SkuIdTable
[1 + Index
] == Database
->SystemSkuId
) {
1345 return SizeTable
[SizeTableIdx
+ 1 + Index
];
1348 return SizeTable
[SizeTableIdx
+ 1];
1354 Set PCD value's size for POINTER type PCD.
1356 The POINTER type PCD's value will be stored into a buffer in specified size.
1357 The max size of this PCD's value is described in PCD's definition in DEC file.
1359 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1360 @param CurrentSize Maximum size of PCD's value
1361 @param Database Pcd database in PEI phase.
1363 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1364 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1369 IN UINTN LocalTokenNumberTableIdx
,
1370 IN OUT UINTN
*CurrentSize
,
1371 IN PEI_PCD_DATABASE
*Database
1375 UINTN LocalTokenNumber
;
1377 SIZE_INFO
*SizeTable
;
1381 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1383 LocalTokenNumber
= *((UINT32
*)((UINT8
*)Database
+ Database
->LocalTokenNumberTableOffset
) + LocalTokenNumberTableIdx
);
1385 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1387 SizeTable
= (SIZE_INFO
*)((UINT8
*)Database
+ Database
->SizeTableOffset
);
1389 MaxSize
= SizeTable
[SizeTableIdx
];
1391 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1394 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1396 // We shouldn't come here as we don't support SET for VPD
1401 if ((*CurrentSize
> MaxSize
) ||
1402 (*CurrentSize
== MAX_ADDRESS
)) {
1403 *CurrentSize
= MaxSize
;
1407 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1409 // We have only two entry for Non-Sku enabled PCD entry:
1413 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;
1417 // We have these entry for SKU enabled PCD entry
1419 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1421 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1422 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1423 if (SkuIdTable
[1 + Index
] == Database
->SystemSkuId
) {
1424 SizeTable
[SizeTableIdx
+ 1 + Index
] = (SIZE_INFO
) *CurrentSize
;
1428 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;