2 All Pcd Ppi services are implemented here.
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. 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.
17 PCD_PPI mPcdPpiInstance
= {
50 PeiRegisterCallBackOnSet
,
51 PcdUnRegisterCallBackOnSet
,
53 PeiPcdGetNextTokenSpace
56 EFI_PEI_PCD_PPI mEfiPcdPpiInstance
= {
72 (EFI_PEI_PCD_PPI_CALLBACK_ON_SET
) PeiRegisterCallBackOnSet
,
73 (EFI_PEI_PCD_PPI_CANCEL_CALLBACK
) PcdUnRegisterCallBackOnSet
,
75 PeiPcdGetNextTokenSpace
78 EFI_PEI_PPI_DESCRIPTOR mPpiPCD
= {
79 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
84 EFI_PEI_PPI_DESCRIPTOR mEfiPpiPCD
= {
85 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
91 Main entry for PCD PEIM driver.
93 This routine initialize the PCD database for PEI phase and install PCD_PPI.
95 @param FileHandle Handle of the file being invoked.
96 @param PeiServices Describes the list of possible PEI Services.
98 @return Status of install PCD_PPI
104 IN EFI_PEI_FILE_HANDLE FileHandle
,
105 IN CONST EFI_PEI_SERVICES
**PeiServices
110 return PeiServicesInstallPpi (&mPpiPCD
);
114 Sets the SKU value for subsequent calls to set or get PCD token values.
116 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
117 SetSku() is normally called only once by the system.
119 For each item (token), the database can hold a single value that applies to all SKUs,
120 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
121 SKU-specific values are called SKU enabled.
123 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
124 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
125 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
126 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
127 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
128 set for that Id, the results are unpredictable.
130 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
131 set values associated with a PCD token.
141 GetPcdDatabase()->Init
.SystemSkuId
= (SKU_ID
) SkuId
;
147 Retrieves an 8-bit value for a given PCD token.
149 Retrieves the current byte-sized value for a PCD token number.
150 If the TokenNumber is invalid, the results are unpredictable.
152 @param[in] TokenNumber The PCD token number.
154 @return The UINT8 value.
163 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
167 Retrieves an 16-bit value for a given PCD token.
169 Retrieves the current 16-bits value for a PCD token number.
170 If the TokenNumber is invalid, the results are unpredictable.
172 @param[in] TokenNumber The PCD token number.
174 @return The UINT16 value.
183 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
187 Retrieves an 32-bit value for a given PCD token.
189 Retrieves the current 32-bits value for a PCD token number.
190 If the TokenNumber is invalid, the results are unpredictable.
192 @param[in] TokenNumber The PCD token number.
194 @return The UINT32 value.
203 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
207 Retrieves an 64-bit value for a given PCD token.
209 Retrieves the current 64-bits value for a PCD token number.
210 If the TokenNumber is invalid, the results are unpredictable.
212 @param[in] TokenNumber The PCD token number.
214 @return The UINT64 value.
223 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
227 Retrieves a pointer to a value for a given PCD token.
229 Retrieves the current pointer to the buffer for a PCD token number.
230 Do not make any assumptions about the alignment of the pointer that
231 is returned by this function call. If the TokenNumber is invalid,
232 the results are unpredictable.
234 @param[in] TokenNumber The PCD token number.
236 @return The pointer to the buffer to be retrieved.
245 return GetWorker (TokenNumber
, 0);
249 Retrieves a Boolean value for a given PCD token.
251 Retrieves the current boolean value for a PCD token number.
252 Do not make any assumptions about the alignment of the pointer that
253 is returned by this function call. If the TokenNumber is invalid,
254 the results are unpredictable.
256 @param[in] TokenNumber The PCD token number.
258 @return The Boolean value.
267 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
271 Retrieves the size of the value for a given PCD token.
273 Retrieves the current size of a particular PCD token.
274 If the TokenNumber is invalid, the results are unpredictable.
276 @param[in] TokenNumber The PCD token number.
278 @return The size of the value for the PCD token.
287 PEI_PCD_DATABASE
*PeiPcdDb
;
291 PeiPcdDb
= GetPcdDatabase ();
293 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
294 // We have to decrement TokenNumber by 1 to make it usable
295 // as the array index.
299 // EBC compiler is very choosy. It may report warning about comparison
300 // between UINTN and 0 . So we add 1 in each size of the
302 ASSERT (TokenNumber
+ 1 < PEI_LOCAL_TOKEN_NUMBER
+ 1);
304 Size
= (PeiPcdDb
->Init
.LocalTokenNumberTable
[TokenNumber
] & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
308 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
310 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
318 Retrieves an 8-bit value for a given PCD token.
320 Retrieves the 8-bit value of a particular PCD token.
321 If the TokenNumber is invalid or the token space
322 specified by Guid does not exist, the results are
325 @param[in] Guid The token space for the token number.
326 @param[in] ExTokenNumber The PCD token number.
328 @return The size 8-bit value for the PCD token.
334 IN CONST EFI_GUID
*Guid
,
335 IN UINTN ExTokenNumber
338 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
342 Retrieves an 16-bit value for a given PCD token.
344 Retrieves the 16-bit value of a particular PCD token.
345 If the TokenNumber is invalid or the token space
346 specified by Guid does not exist, the results are
349 @param[in] Guid The token space for the token number.
350 @param[in] ExTokenNumber The PCD token number.
352 @return The size 16-bit value for the PCD token.
358 IN CONST EFI_GUID
*Guid
,
359 IN UINTN ExTokenNumber
362 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
366 Retrieves an 32-bit value for a given PCD token.
368 Retrieves the 32-bit value of a particular PCD token.
369 If the TokenNumber is invalid or the token space
370 specified by Guid does not exist, the results are
373 @param[in] Guid The token space for the token number.
374 @param[in] ExTokenNumber The PCD token number.
376 @return The size 32-bit value for the PCD token.
382 IN CONST EFI_GUID
*Guid
,
383 IN UINTN ExTokenNumber
386 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
390 Retrieves an 64-bit value for a given PCD token.
392 Retrieves the 64-bit value of a particular PCD token.
393 If the TokenNumber is invalid or the token space
394 specified by Guid does not exist, the results are
397 @param[in] Guid The token space for the token number.
398 @param[in] ExTokenNumber The PCD token number.
400 @return The size 64-bit value for the PCD token.
406 IN CONST EFI_GUID
*Guid
,
407 IN UINTN ExTokenNumber
410 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
414 Retrieves a pointer to a value for a given PCD token.
416 Retrieves the current pointer to the buffer for a PCD token number.
417 Do not make any assumptions about the alignment of the pointer that
418 is returned by this function call. If the TokenNumber is invalid,
419 the results are unpredictable.
421 @param[in] Guid The token space for the token number.
422 @param[in] ExTokenNumber The PCD token number.
424 @return The pointer to the buffer to be retrieved.
430 IN CONST EFI_GUID
*Guid
,
431 IN UINTN ExTokenNumber
434 return ExGetWorker (Guid
, ExTokenNumber
, 0);
438 Retrieves an Boolean value for a given PCD token.
440 Retrieves the Boolean value of a particular PCD token.
441 If the TokenNumber is invalid or the token space
442 specified by Guid does not exist, the results are
445 @param[in] Guid The token space for the token number.
446 @param[in] ExTokenNumber The PCD token number.
448 @return The size Boolean value for the PCD token.
454 IN CONST EFI_GUID
*Guid
,
455 IN UINTN ExTokenNumber
458 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
462 Retrieves the size of the value for a given PCD token.
464 Retrieves the current size of a particular PCD token.
465 If the TokenNumber is invalid, the results are unpredictable.
467 @param[in] Guid The token space for the token number.
468 @param[in] ExTokenNumber The PCD token number.
470 @return The size of the value for the PCD token.
476 IN CONST EFI_GUID
*Guid
,
477 IN UINTN ExTokenNumber
480 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
484 Sets an 8-bit value for a given PCD token.
486 When the PCD service sets a value, it will check to ensure that the
487 size of the value being set is compatible with the Token's existing definition.
488 If it is not, an error will be returned.
490 @param[in] TokenNumber The PCD token number.
491 @param[in] Value The value to set for the PCD token.
493 @retval EFI_SUCCESS Procedure returned successfully.
494 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
495 being set was incompatible with a call to this function.
496 Use GetSize() to retrieve the size of the target data.
497 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
503 IN UINTN TokenNumber
,
507 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
511 Sets an 16-bit value for a given PCD token.
513 When the PCD service sets a value, it will check to ensure that the
514 size of the value being set is compatible with the Token's existing definition.
515 If it is not, an error will be returned.
517 @param[in] TokenNumber The PCD token number.
518 @param[in] Value The value to set for the PCD token.
520 @retval EFI_SUCCESS Procedure returned successfully.
521 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
522 being set was incompatible with a call to this function.
523 Use GetSize() to retrieve the size of the target data.
524 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
530 IN UINTN TokenNumber
,
534 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
538 Sets an 32-bit value for a given PCD token.
540 When the PCD service sets a value, it will check to ensure that the
541 size of the value being set is compatible with the Token's existing definition.
542 If it is not, an error will be returned.
544 @param[in] TokenNumber The PCD token number.
545 @param[in] Value The value to set for the PCD token.
547 @retval EFI_SUCCESS Procedure returned successfully.
548 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
549 being set was incompatible with a call to this function.
550 Use GetSize() to retrieve the size of the target data.
551 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
557 IN UINTN TokenNumber
,
561 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
565 Sets an 64-bit value for a given PCD token.
567 When the PCD service sets a value, it will check to ensure that the
568 size of the value being set is compatible with the Token's existing definition.
569 If it is not, an error will be returned.
571 @param[in] TokenNumber The PCD token number.
572 @param[in] Value The value to set for the PCD token.
574 @retval EFI_SUCCESS Procedure returned successfully.
575 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
576 being set was incompatible with a call to this function.
577 Use GetSize() to retrieve the size of the target data.
578 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
584 IN UINTN TokenNumber
,
588 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
592 Sets a value of a specified size for a given PCD token.
594 When the PCD service sets a value, it will check to ensure that the
595 size of the value being set is compatible with the Token's existing definition.
596 If it is not, an error will be returned.
598 @param[in] TokenNumber The PCD token number.
599 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
600 On input, if the SizeOfValue is greater than the maximum size supported
601 for this TokenNumber then the output value of SizeOfValue will reflect
602 the maximum size supported for this TokenNumber.
603 @param[in] Buffer The buffer to set for the PCD token.
605 @retval EFI_SUCCESS Procedure returned successfully.
606 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
607 being set was incompatible with a call to this function.
608 Use GetSize() to retrieve the size of the target data.
609 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
615 IN UINTN TokenNumber
,
616 IN OUT UINTN
*SizeOfBuffer
,
620 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
624 Sets an Boolean value for a given PCD token.
626 When the PCD service sets a value, it will check to ensure that the
627 size of the value being set is compatible with the Token's existing definition.
628 If it is not, an error will be returned.
630 @param[in] TokenNumber The PCD token number.
631 @param[in] Value The value to set for the PCD token.
633 @retval EFI_SUCCESS Procedure returned successfully.
634 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
635 being set was incompatible with a call to this function.
636 Use GetSize() to retrieve the size of the target data.
637 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
643 IN UINTN TokenNumber
,
647 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
651 Sets an 8-bit value for a given PCD token.
653 When the PCD service sets a value, it will check to ensure that the
654 size of the value being set is compatible with the Token's existing definition.
655 If it is not, an error will be returned.
657 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
658 @param[in] ExTokenNumber The PCD token number.
659 @param[in] Value The value to set for the PCD token.
661 @retval EFI_SUCCESS Procedure returned successfully.
662 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
663 being set was incompatible with a call to this function.
664 Use GetSize() to retrieve the size of the target data.
665 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
671 IN CONST EFI_GUID
*Guid
,
672 IN UINTN ExTokenNumber
,
676 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
680 Sets an 16-bit value for a given PCD token.
682 When the PCD service sets a value, it will check to ensure that the
683 size of the value being set is compatible with the Token's existing definition.
684 If it is not, an error will be returned.
686 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
687 @param[in] ExTokenNumber The PCD token number.
688 @param[in] Value The value to set for the PCD token.
690 @retval EFI_SUCCESS Procedure returned successfully.
691 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
692 being set was incompatible with a call to this function.
693 Use GetSize() to retrieve the size of the target data.
694 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
700 IN CONST EFI_GUID
*Guid
,
701 IN UINTN ExTokenNumber
,
705 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
709 Sets an 32-bit value for a given PCD token.
711 When the PCD service sets a value, it will check to ensure that the
712 size of the value being set is compatible with the Token's existing definition.
713 If it is not, an error will be returned.
715 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
716 @param[in] ExTokenNumber The PCD token number.
717 @param[in] Value The value to set for the PCD token.
719 @retval EFI_SUCCESS Procedure returned successfully.
720 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
721 being set was incompatible with a call to this function.
722 Use GetSize() to retrieve the size of the target data.
723 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
729 IN CONST EFI_GUID
*Guid
,
730 IN UINTN ExTokenNumber
,
734 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
738 Sets an 64-bit value for a given PCD token.
740 When the PCD service sets a value, it will check to ensure that the
741 size of the value being set is compatible with the Token's existing definition.
742 If it is not, an error will be returned.
744 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
745 @param[in] ExTokenNumber The PCD token number.
746 @param[in] Value The value to set for the PCD token.
748 @retval EFI_SUCCESS Procedure returned successfully.
749 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
750 being set was incompatible with a call to this function.
751 Use GetSize() to retrieve the size of the target data.
752 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
758 IN CONST EFI_GUID
*Guid
,
759 IN UINTN ExTokenNumber
,
763 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
767 Sets a value of a specified size for a given PCD token.
769 When the PCD service sets a value, it will check to ensure that the
770 size of the value being set is compatible with the Token's existing definition.
771 If it is not, an error will be returned.
773 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
774 @param[in] ExTokenNumber The PCD token number.
775 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
776 On input, if the SizeOfValue is greater than the maximum size supported
777 for this TokenNumber then the output value of SizeOfValue will reflect
778 the maximum size supported for this TokenNumber.
779 @param[in] Value The buffer to set for the PCD token.
781 @retval EFI_SUCCESS Procedure returned successfully.
782 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
783 being set was incompatible with a call to this function.
784 Use GetSize() to retrieve the size of the target data.
785 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
791 IN CONST EFI_GUID
*Guid
,
792 IN UINTN ExTokenNumber
,
793 IN OUT UINTN
*SizeOfBuffer
,
797 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
801 Sets an Boolean value for a given PCD token.
803 When the PCD service sets a value, it will check to ensure that the
804 size of the value being set is compatible with the Token's existing definition.
805 If it is not, an error will be returned.
807 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
808 @param [in] ExTokenNumber The PCD token number.
809 @param [in] Value The value to set for the PCD token.
811 @retval EFI_SUCCESS Procedure returned successfully.
812 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
813 being set was incompatible with a call to this function.
814 Use GetSize() to retrieve the size of the target data.
815 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
821 IN CONST EFI_GUID
*Guid
,
822 IN UINTN ExTokenNumber
,
826 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
830 Specifies a function to be called anytime the value of a designated token is changed.
832 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
833 @param[in] ExTokenNumber The PCD token number.
834 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
836 @retval EFI_SUCCESS The PCD service has successfully established a call event
837 for the CallBackToken requested.
838 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
843 PeiRegisterCallBackOnSet (
844 IN CONST EFI_GUID
*Guid
, OPTIONAL
845 IN UINTN ExTokenNumber
,
846 IN PCD_PPI_CALLBACK CallBackFunction
849 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
850 return EFI_UNSUPPORTED
;
853 if (CallBackFunction
== NULL
) {
854 return EFI_INVALID_PARAMETER
;
857 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
861 Cancels a previously set callback function for a particular PCD token number.
863 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
864 @param[in] ExTokenNumber The PCD token number.
865 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
867 @retval EFI_SUCCESS The PCD service has successfully established a call event
868 for the CallBackToken requested.
869 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
874 PcdUnRegisterCallBackOnSet (
875 IN CONST EFI_GUID
*Guid
, OPTIONAL
876 IN UINTN ExTokenNumber
,
877 IN PCD_PPI_CALLBACK CallBackFunction
880 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable
)) {
881 return EFI_UNSUPPORTED
;
884 if (CallBackFunction
== NULL
) {
885 return EFI_INVALID_PARAMETER
;
888 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
892 Retrieves the next valid token number in a given namespace.
894 This is useful since the PCD infrastructure contains a sparse list of token numbers,
895 and one cannot a priori know what token numbers are valid in the database.
897 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
898 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
899 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
900 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
901 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
902 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
903 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
904 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
907 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
908 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
909 is being made to retrieve tokens from the default token space.
910 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
912 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
913 Or the input token number is already the last valid token number in the PCD database.
914 In the later case, *TokenNumber is updated with the value of 0.
915 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
921 IN CONST EFI_GUID
*Guid
, OPTIONAL
922 IN OUT UINTN
*TokenNumber
926 PEI_PCD_DATABASE
*PeiPcdDb
;
928 DYNAMICEX_MAPPING
*ExMapTable
;
931 BOOLEAN PeiExMapTableEmpty
;
933 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
934 return EFI_UNSUPPORTED
;
937 PeiExMapTableEmpty
= PEI_EXMAP_TABLE_EMPTY
;
940 if (*TokenNumber
> PEI_NEX_TOKEN_NUMBER
) {
941 return EFI_NOT_FOUND
;
944 if (*TokenNumber
> PEI_NEX_TOKEN_NUMBER
) {
945 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
949 if (PeiExMapTableEmpty
) {
950 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
955 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
959 PeiPcdDb
= GetPcdDatabase ();
961 MatchGuid
= ScanGuid (PeiPcdDb
->Init
.GuidTable
, sizeof(PeiPcdDb
->Init
.GuidTable
), Guid
);
963 if (MatchGuid
== NULL
) {
964 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
965 return EFI_NOT_FOUND
;
968 GuidTableIdx
= MatchGuid
- PeiPcdDb
->Init
.GuidTable
;
970 ExMapTable
= PeiPcdDb
->Init
.ExMapTable
;
974 // Locate the GUID in ExMapTable first.
976 for (Index
= 0; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
977 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
984 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
985 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
989 for ( ; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
990 if (ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) {
992 if (Index
== PEI_EXMAPPING_TABLE_SIZE
) {
994 // Exceed the length of ExMap Table
996 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
999 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1000 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
1003 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1008 return EFI_NOT_FOUND
;
1012 return EFI_NOT_FOUND
;
1016 Retrieves the next valid PCD token namespace for a given namespace.
1018 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates
1019 a known token namespace from which the search will start. On output,
1020 it designates the next valid token namespace on the platform. If the input
1021 token namespace does not exist on the platform, an error is returned and
1022 the value of *Guid is undefined. If *Guid is NULL, then the GUID of the
1023 first token space of the current platform is assigned to *Guid the function
1024 return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in
1025 the platform other than the default (NULL) tokennamespace, *Guid is unchanged
1026 and the function return EFI_SUCCESS. If this input token namespace is the last
1027 namespace on the platform, *Guid will be assigned to NULL and the function return
1030 @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid.
1031 Or the input token space Guid is already the last valid token space Guid
1032 in the PCD database. In the later case, *Guid is updated with the value of NULL.
1033 @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.
1038 PeiPcdGetNextTokenSpace (
1039 IN OUT CONST EFI_GUID
**Guid
1043 EFI_GUID
*MatchGuid
;
1044 PEI_PCD_DATABASE
*PeiPcdDb
;
1045 DYNAMICEX_MAPPING
*ExMapTable
;
1048 BOOLEAN PeiExMapTableEmpty
;
1050 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable
)) {
1051 return EFI_UNSUPPORTED
;
1054 ASSERT (Guid
!= NULL
);
1056 PeiExMapTableEmpty
= PEI_EXMAP_TABLE_EMPTY
;
1058 if (PeiExMapTableEmpty
) {
1059 if (*Guid
!= NULL
) {
1060 return EFI_NOT_FOUND
;
1067 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
1071 PeiPcdDb
= GetPcdDatabase ();
1073 ExMapTable
= PeiPcdDb
->Init
.ExMapTable
;
1075 if (*Guid
== NULL
) {
1077 // return the first Token Space Guid.
1079 *Guid
= &PeiPcdDb
->Init
.GuidTable
[ExMapTable
[0].ExGuidIndex
];
1083 MatchGuid
= ScanGuid (PeiPcdDb
->Init
.GuidTable
, sizeof(PeiPcdDb
->Init
.GuidTable
), *Guid
);
1085 if (MatchGuid
== NULL
) {
1086 return EFI_NOT_FOUND
;
1089 GuidTableIdx
= MatchGuid
- PeiPcdDb
->Init
.GuidTable
;
1092 for (Index
= 0; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
1093 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1101 for ( ; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++ ) {
1102 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1103 *Guid
= &PeiPcdDb
->Init
.GuidTable
[ExMapTable
[Index
].ExGuidIndex
];
1111 return EFI_NOT_FOUND
;
1116 Get PCD value's size for POINTER type PCD.
1118 The POINTER type PCD's value will be stored into a buffer in specificed size.
1119 The max size of this PCD's value is described in PCD's definition in DEC file.
1121 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1122 @param MaxSize Maximum size of PCD's value
1123 @param Database Pcd database in PEI phase.
1125 @return PCD value's size for POINTER type PCD.
1130 IN UINTN LocalTokenNumberTableIdx
,
1132 IN PEI_PCD_DATABASE
*Database
1136 UINTN LocalTokenNumber
;
1138 SIZE_INFO
*SizeTable
;
1141 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1143 LocalTokenNumber
= Database
->Init
.LocalTokenNumberTable
[LocalTokenNumberTableIdx
];
1145 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1147 SizeTable
= Database
->Init
.SizeTable
;
1149 *MaxSize
= SizeTable
[SizeTableIdx
];
1151 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1154 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1156 // We have only one entry for VPD enabled PCD entry:
1158 // We consider current size is equal to MAX size.
1162 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1164 // We have only two entry for Non-Sku enabled PCD entry:
1168 return SizeTable
[SizeTableIdx
+ 1];
1171 // We have these entry for SKU enabled PCD entry
1173 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1175 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1176 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1177 if (SkuIdTable
[1 + Index
] == Database
->Init
.SystemSkuId
) {
1178 return SizeTable
[SizeTableIdx
+ 1 + Index
];
1181 return SizeTable
[SizeTableIdx
+ 1];
1187 Set PCD value's size for POINTER type PCD.
1189 The POINTER type PCD's value will be stored into a buffer in specificed size.
1190 The max size of this PCD's value is described in PCD's definition in DEC file.
1192 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1193 @param CurrentSize Maximum size of PCD's value
1194 @param Database Pcd database in PEI phase.
1196 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1197 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1202 IN UINTN LocalTokenNumberTableIdx
,
1203 IN OUT UINTN
*CurrentSize
,
1204 IN PEI_PCD_DATABASE
*Database
1208 UINTN LocalTokenNumber
;
1210 SIZE_INFO
*SizeTable
;
1214 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1216 LocalTokenNumber
= Database
->Init
.LocalTokenNumberTable
[LocalTokenNumberTableIdx
];
1218 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1220 SizeTable
= Database
->Init
.SizeTable
;
1222 MaxSize
= SizeTable
[SizeTableIdx
];
1224 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1227 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1229 // We shouldn't come here as we don't support SET for VPD
1234 if ((*CurrentSize
> MaxSize
) ||
1235 (*CurrentSize
== MAX_ADDRESS
)) {
1236 *CurrentSize
= MaxSize
;
1240 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1242 // We have only two entry for Non-Sku enabled PCD entry:
1246 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;
1250 // We have these entry for SKU enabled PCD entry
1252 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1254 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1255 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1256 if (SkuIdTable
[1 + Index
] == Database
->Init
.SystemSkuId
) {
1257 SizeTable
[SizeTableIdx
+ 1 + Index
] = (SIZE_INFO
) *CurrentSize
;
1261 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;