2 PCD PEIM manage PCD database to manage all dynamic PCD in PEI phase. PCD PEIM
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. 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.
18 PCD_PPI mPcdPpiInstance
= {
51 PeiRegisterCallBackOnSet
,
52 PcdUnRegisterCallBackOnSet
,
54 PeiPcdGetNextTokenSpace
57 EFI_PEI_PPI_DESCRIPTOR mPpiPCD
= {
58 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
64 Main entry for PCD PEIM driver.
66 This routine initialize the PCD database for PEI phase and install PCD_PPI.
68 @param FfsHeader Pointer to PEIM FFS header image
69 @param PeiServices Pointer to EFI_PEI_SERVICES
71 @return Status of install PCD_PPI
77 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
78 IN EFI_PEI_SERVICES
**PeiServices
83 return PeiServicesInstallPpi (&mPpiPCD
);
87 Sets the SKU value for subsequent calls to set or get PCD token values.
89 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
90 SetSku() is normally called only once by the system.
92 For each item (token), the database can hold a single value that applies to all SKUs,
93 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
94 SKU-specific values are called SKU enabled.
96 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
97 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
98 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
99 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
100 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
101 set for that Id, the results are unpredictable.
103 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
104 set values associated with a PCD token.
116 GetPcdDatabase()->Init
.SystemSkuId
= (SKU_ID
) SkuId
;
122 Retrieves an 8-bit value for a given PCD token.
124 Retrieves the current byte-sized value for a PCD token number.
125 If the TokenNumber is invalid, the results are unpredictable.
127 @param[in] TokenNumber The PCD token number.
129 @return The UINT8 value.
138 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
142 Retrieves an 16-bit value for a given PCD token.
144 Retrieves the current 16-bits value for a PCD token number.
145 If the TokenNumber is invalid, the results are unpredictable.
147 @param[in] TokenNumber The PCD token number.
149 @return The UINT16 value.
158 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
162 Retrieves an 32-bit value for a given PCD token.
164 Retrieves the current 32-bits value for a PCD token number.
165 If the TokenNumber is invalid, the results are unpredictable.
167 @param[in] TokenNumber The PCD token number.
169 @return The UINT32 value.
178 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
182 Retrieves an 64-bit value for a given PCD token.
184 Retrieves the current 64-bits value for a PCD token number.
185 If the TokenNumber is invalid, the results are unpredictable.
187 @param[in] TokenNumber The PCD token number.
189 @return The UINT64 value.
198 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
202 Retrieves a pointer to a value for a given PCD token.
204 Retrieves the current pointer to the buffer for a PCD token number.
205 Do not make any assumptions about the alignment of the pointer that
206 is returned by this function call. If the TokenNumber is invalid,
207 the results are unpredictable.
209 @param[in] TokenNumber The PCD token number.
211 @return The pointer to the buffer to be retrived.
220 return GetWorker (TokenNumber
, 0);
224 Retrieves a Boolean value for a given PCD token.
226 Retrieves the current boolean value for a PCD token number.
227 Do not make any assumptions about the alignment of the pointer that
228 is returned by this function call. If the TokenNumber is invalid,
229 the results are unpredictable.
231 @param[in] TokenNumber The PCD token number.
233 @return The Boolean value.
242 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
246 Retrieves the size of the value for a given PCD token.
248 Retrieves the current size of a particular PCD token.
249 If the TokenNumber is invalid, the results are unpredictable.
251 @param[in] TokenNumber The PCD token number.
253 @return The size of the value for the PCD token.
262 PEI_PCD_DATABASE
*PeiPcdDb
;
267 // If DebugAssertEnabled is TRUE, we still need to provide the GET size
268 // function as GetWorker and SetWoker need this function to do ASSERT.
270 if ((!FeaturePcdGet(PcdPeiPcdDatabaseGetSizeEnabled
)) &&
271 (!DebugAssertEnabled ())) {
275 PeiPcdDb
= GetPcdDatabase ();
277 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
278 // We have to decrement TokenNumber by 1 to make it usable
279 // as the array index.
283 // EBC compiler is very choosy. It may report warning about comparison
284 // between UINTN and 0 . So we add 1 in each size of the
286 ASSERT (TokenNumber
+ 1 < PEI_LOCAL_TOKEN_NUMBER
+ 1);
288 Size
= (PeiPcdDb
->Init
.LocalTokenNumberTable
[TokenNumber
] & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
292 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
294 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
302 Retrieves an 8-bit value for a given PCD token.
304 Retrieves the 8-bit value of a particular PCD token.
305 If the TokenNumber is invalid or the token space
306 specified by Guid does not exist, the results are
309 @param[in] Guid The token space for the token number.
310 @param[in] ExTokenNumber The PCD token number.
312 @return The size 8-bit value for the PCD token.
318 IN CONST EFI_GUID
*Guid
,
319 IN UINTN ExTokenNumber
322 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
326 Retrieves an 16-bit value for a given PCD token.
328 Retrieves the 16-bit value of a particular PCD token.
329 If the TokenNumber is invalid or the token space
330 specified by Guid does not exist, the results are
333 @param[in] Guid The token space for the token number.
334 @param[in] ExTokenNumber The PCD token number.
336 @return The size 16-bit value for the PCD token.
342 IN CONST EFI_GUID
*Guid
,
343 IN UINTN ExTokenNumber
346 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
350 Retrieves an 32-bit value for a given PCD token.
352 Retrieves the 32-bit value of a particular PCD token.
353 If the TokenNumber is invalid or the token space
354 specified by Guid does not exist, the results are
357 @param[in] Guid The token space for the token number.
358 @param[in] ExTokenNumber The PCD token number.
360 @return The size 32-bit value for the PCD token.
366 IN CONST EFI_GUID
*Guid
,
367 IN UINTN ExTokenNumber
370 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
374 Retrieves an 64-bit value for a given PCD token.
376 Retrieves the 64-bit value of a particular PCD token.
377 If the TokenNumber is invalid or the token space
378 specified by Guid does not exist, the results are
381 @param[in] Guid The token space for the token number.
382 @param[in] ExTokenNumber The PCD token number.
384 @return The size 64-bit value for the PCD token.
390 IN CONST EFI_GUID
*Guid
,
391 IN UINTN ExTokenNumber
394 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
398 Retrieves a pointer to a value for a given PCD token.
400 Retrieves the current pointer to the buffer for a PCD token number.
401 Do not make any assumptions about the alignment of the pointer that
402 is returned by this function call. If the TokenNumber is invalid,
403 the results are unpredictable.
405 @param[in] Guid The token space for the token number.
406 @param[in] ExTokenNumber The PCD token number.
408 @return The pointer to the buffer to be retrived.
414 IN CONST EFI_GUID
*Guid
,
415 IN UINTN ExTokenNumber
418 return ExGetWorker (Guid
, ExTokenNumber
, 0);
422 Retrieves an Boolean value for a given PCD token.
424 Retrieves the Boolean value of a particular PCD token.
425 If the TokenNumber is invalid or the token space
426 specified by Guid does not exist, the results are
429 @param[in] Guid The token space for the token number.
430 @param[in] ExTokenNumber The PCD token number.
432 @return The size Boolean value for the PCD token.
438 IN CONST EFI_GUID
*Guid
,
439 IN UINTN ExTokenNumber
442 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
446 Retrieves the size of the value for a given PCD token.
448 Retrieves the current size of a particular PCD token.
449 If the TokenNumber is invalid, the results are unpredictable.
451 @param[in] Guid The token space for the token number.
452 @param[in] ExTokenNumber The PCD token number.
454 @return The size of the value for the PCD token.
460 IN CONST EFI_GUID
*Guid
,
461 IN UINTN ExTokenNumber
464 if ((!FeaturePcdGet (PcdPeiPcdDatabaseGetSizeEnabled
)) || !FeaturePcdGet (PcdPeiPcdDatabaseExEnabled
)) {
468 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
472 Sets an 8-bit value for a given PCD token.
474 When the PCD service sets a value, it will check to ensure that the
475 size of the value being set is compatible with the Token's existing definition.
476 If it is not, an error will be returned.
478 @param[in] TokenNumber The PCD token number.
479 @param[in] Value The value to set for the PCD token.
481 @retval EFI_SUCCESS Procedure returned successfully.
482 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
483 being set was incompatible with a call to this function.
484 Use GetSize() to retrieve the size of the target data.
485 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
491 IN UINTN TokenNumber
,
495 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
499 Sets an 16-bit value for a given PCD token.
501 When the PCD service sets a value, it will check to ensure that the
502 size of the value being set is compatible with the Token's existing definition.
503 If it is not, an error will be returned.
505 @param[in] TokenNumber The PCD token number.
506 @param[in] Value The value to set for the PCD token.
508 @retval EFI_SUCCESS Procedure returned successfully.
509 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
510 being set was incompatible with a call to this function.
511 Use GetSize() to retrieve the size of the target data.
512 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
518 IN UINTN TokenNumber
,
522 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
526 Sets an 32-bit value for a given PCD token.
528 When the PCD service sets a value, it will check to ensure that the
529 size of the value being set is compatible with the Token's existing definition.
530 If it is not, an error will be returned.
532 @param[in] TokenNumber The PCD token number.
533 @param[in] Value The value to set for the PCD token.
535 @retval EFI_SUCCESS Procedure returned successfully.
536 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
537 being set was incompatible with a call to this function.
538 Use GetSize() to retrieve the size of the target data.
539 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
545 IN UINTN TokenNumber
,
549 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
553 Sets an 64-bit value for a given PCD token.
555 When the PCD service sets a value, it will check to ensure that the
556 size of the value being set is compatible with the Token's existing definition.
557 If it is not, an error will be returned.
559 @param[in] TokenNumber The PCD token number.
560 @param[in] Value The value to set for the PCD token.
562 @retval EFI_SUCCESS Procedure returned successfully.
563 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
564 being set was incompatible with a call to this function.
565 Use GetSize() to retrieve the size of the target data.
566 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
572 IN UINTN TokenNumber
,
576 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
580 Sets a value of a specified size for a given PCD token.
582 When the PCD service sets a value, it will check to ensure that the
583 size of the value being set is compatible with the Token's existing definition.
584 If it is not, an error will be returned.
586 @param[in] TokenNumber The PCD token number.
587 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
588 On input, if the SizeOfValue is greater than the maximum size supported
589 for this TokenNumber then the output value of SizeOfValue will reflect
590 the maximum size supported for this TokenNumber.
591 @param[in] Buffer The buffer to set for the PCD token.
593 @retval EFI_SUCCESS Procedure returned successfully.
594 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
595 being set was incompatible with a call to this function.
596 Use GetSize() to retrieve the size of the target data.
597 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
603 IN UINTN TokenNumber
,
604 IN OUT UINTN
*SizeOfBuffer
,
608 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
612 Sets an Boolean value for a given PCD token.
614 When the PCD service sets a value, it will check to ensure that the
615 size of the value being set is compatible with the Token's existing definition.
616 If it is not, an error will be returned.
618 @param[in] TokenNumber The PCD token number.
619 @param[in] Value The value to set for the PCD token.
621 @retval EFI_SUCCESS Procedure returned successfully.
622 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
623 being set was incompatible with a call to this function.
624 Use GetSize() to retrieve the size of the target data.
625 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
631 IN UINTN TokenNumber
,
635 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
639 Sets an 8-bit value for a given PCD token.
641 When the PCD service sets a value, it will check to ensure that the
642 size of the value being set is compatible with the Token's existing definition.
643 If it is not, an error will be returned.
645 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
646 @param[in] ExTokenNumber The PCD token number.
647 @param[in] Value The value to set for the PCD token.
649 @retval EFI_SUCCESS Procedure returned successfully.
650 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
651 being set was incompatible with a call to this function.
652 Use GetSize() to retrieve the size of the target data.
653 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
659 IN CONST EFI_GUID
*Guid
,
660 IN UINTN ExTokenNumber
,
664 return ExSetValueWorker (ExTokenNumber
, Guid
, &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] Guid The 128-bit unique value that designates the namespace from which to extract the value.
675 @param[in] ExTokenNumber The PCD token number.
676 @param[in] Value The value to set for the PCD token.
678 @retval EFI_SUCCESS Procedure returned successfully.
679 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
680 being set was incompatible with a call to this function.
681 Use GetSize() to retrieve the size of the target data.
682 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
688 IN CONST EFI_GUID
*Guid
,
689 IN UINTN ExTokenNumber
,
693 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
697 Sets an 32-bit value for a given PCD token.
699 When the PCD service sets a value, it will check to ensure that the
700 size of the value being set is compatible with the Token's existing definition.
701 If it is not, an error will be returned.
703 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
704 @param[in] ExTokenNumber The PCD token number.
705 @param[in] Value The value to set for the PCD token.
707 @retval EFI_SUCCESS Procedure returned successfully.
708 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
709 being set was incompatible with a call to this function.
710 Use GetSize() to retrieve the size of the target data.
711 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
717 IN CONST EFI_GUID
*Guid
,
718 IN UINTN ExTokenNumber
,
722 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
726 Sets an 64-bit value for a given PCD token.
728 When the PCD service sets a value, it will check to ensure that the
729 size of the value being set is compatible with the Token's existing definition.
730 If it is not, an error will be returned.
732 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
733 @param[in] ExTokenNumber The PCD token number.
734 @param[in] Value The value to set for the PCD token.
736 @retval EFI_SUCCESS Procedure returned successfully.
737 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
738 being set was incompatible with a call to this function.
739 Use GetSize() to retrieve the size of the target data.
740 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
746 IN CONST EFI_GUID
*Guid
,
747 IN UINTN ExTokenNumber
,
751 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
755 Sets a value of a specified size for a given PCD token.
757 When the PCD service sets a value, it will check to ensure that the
758 size of the value being set is compatible with the Token's existing definition.
759 If it is not, an error will be returned.
761 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
762 @param[in] ExTokenNumber The PCD token number.
763 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
764 On input, if the SizeOfValue is greater than the maximum size supported
765 for this TokenNumber then the output value of SizeOfValue will reflect
766 the maximum size supported for this TokenNumber.
767 @param[in] Value The buffer to set for the PCD token.
769 @retval EFI_SUCCESS Procedure returned successfully.
770 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
771 being set was incompatible with a call to this function.
772 Use GetSize() to retrieve the size of the target data.
773 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
779 IN CONST EFI_GUID
*Guid
,
780 IN UINTN ExTokenNumber
,
781 IN OUT UINTN
*SizeOfBuffer
,
785 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
789 Sets an Boolean value for a given PCD token.
791 When the PCD service sets a value, it will check to ensure that the
792 size of the value being set is compatible with the Token's existing definition.
793 If it is not, an error will be returned.
795 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
796 @param [in] ExTokenNumber The PCD token number.
797 @param [in] Value The value to set for the PCD token.
799 @retval EFI_SUCCESS Procedure returned successfully.
800 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
801 being set was incompatible with a call to this function.
802 Use GetSize() to retrieve the size of the target data.
803 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
809 IN CONST EFI_GUID
*Guid
,
810 IN UINTN ExTokenNumber
,
814 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
818 Specifies a function to be called anytime the value of a designated token is changed.
820 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
821 @param[in] ExTokenNumber The PCD token number.
822 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
824 @retval EFI_SUCCESS The PCD service has successfully established a call event
825 for the CallBackToken requested.
826 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
831 PeiRegisterCallBackOnSet (
832 IN CONST EFI_GUID
*Guid
, OPTIONAL
833 IN UINTN ExTokenNumber
,
834 IN PCD_PPI_CALLBACK CallBackFunction
837 if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled
)) {
838 return EFI_UNSUPPORTED
;
841 ASSERT (CallBackFunction
!= NULL
);
843 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
847 Cancels a previously set callback function for a particular PCD token number.
849 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
850 @param[in] ExTokenNumber The PCD token number.
851 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
853 @retval EFI_SUCCESS The PCD service has successfully established a call event
854 for the CallBackToken requested.
855 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
860 PcdUnRegisterCallBackOnSet (
861 IN CONST EFI_GUID
*Guid
, OPTIONAL
862 IN UINTN ExTokenNumber
,
863 IN PCD_PPI_CALLBACK CallBackFunction
866 if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled
)) {
867 return EFI_UNSUPPORTED
;
870 ASSERT (CallBackFunction
!= NULL
);
872 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
876 Retrieves the next valid PCD token for a given namespace.
878 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
879 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
880 If the input token namespace or token number does not exist on the platform,
881 an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token,
882 have the pointer reference a TokenNumber value of 0. If the input token number is 0 and
883 there is no valid token number for this token namespace, *TokenNumber will be assigned to
884 0 and the function return EFI_SUCCESS. If the token number is the last valid token number,
885 *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.
887 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
888 is already the last valid token number in the PCD database.
889 In the later case, *TokenNumber is updated with the value of 0.
890 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
896 IN CONST EFI_GUID
*Guid
, OPTIONAL
897 IN OUT UINTN
*TokenNumber
901 PEI_PCD_DATABASE
*PeiPcdDb
;
903 DYNAMICEX_MAPPING
*ExMapTable
;
906 BOOLEAN PeiExMapTableEmpty
;
908 if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled
)) {
909 return EFI_UNSUPPORTED
;
912 PeiExMapTableEmpty
= PEI_EXMAP_TABLE_EMPTY
;
915 if (*TokenNumber
> PEI_NEX_TOKEN_NUMBER
) {
916 return EFI_NOT_FOUND
;
919 if (*TokenNumber
> PEI_NEX_TOKEN_NUMBER
) {
920 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
924 if (PeiExMapTableEmpty
) {
925 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
930 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
934 PeiPcdDb
= GetPcdDatabase ();
936 MatchGuid
= ScanGuid (PeiPcdDb
->Init
.GuidTable
, sizeof(PeiPcdDb
->Init
.GuidTable
), Guid
);
938 if (MatchGuid
== NULL
) {
939 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
940 return EFI_NOT_FOUND
;
943 GuidTableIdx
= MatchGuid
- PeiPcdDb
->Init
.GuidTable
;
945 ExMapTable
= PeiPcdDb
->Init
.ExMapTable
;
949 // Locate the GUID in ExMapTable first.
951 for (Index
= 0; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
952 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
959 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
960 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
964 for ( ; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
965 if (ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) {
967 if (Index
== PEI_EXMAPPING_TABLE_SIZE
) {
969 // Exceed the length of ExMap Table
971 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
974 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
975 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
978 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
983 return EFI_NOT_FOUND
;
987 return EFI_NOT_FOUND
;
991 Retrieves the next valid PCD token namespace for a given namespace.
993 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates
994 a known token namespace from which the search will start. On output,
995 it designates the next valid token namespace on the platform. If the input
996 token namespace does not exist on the platform, an error is returned and
997 the value of *Guid is undefined. If *Guid is NULL, then the GUID of the
998 first token space of the current platform is assigned to *Guid the function
999 return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in
1000 the platform other than the default (NULL) tokennamespace, *Guid is unchanged
1001 and the function return EFI_SUCCESS. If this input token namespace is the last
1002 namespace on the platform, *Guid will be assigned to NULL and the function return
1005 @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid.
1006 Or the input token space Guid is already the last valid token space Guid
1007 in the PCD database. In the later case, *Guid is updated with the value of NULL.
1008 @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.
1013 PeiPcdGetNextTokenSpace (
1014 IN OUT CONST EFI_GUID
**Guid
1018 EFI_GUID
*MatchGuid
;
1019 PEI_PCD_DATABASE
*PeiPcdDb
;
1020 DYNAMICEX_MAPPING
*ExMapTable
;
1023 BOOLEAN PeiExMapTableEmpty
;
1025 if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled
)) {
1026 return EFI_UNSUPPORTED
;
1029 ASSERT (Guid
!= NULL
);
1031 PeiExMapTableEmpty
= PEI_EXMAP_TABLE_EMPTY
;
1033 if (PeiExMapTableEmpty
) {
1034 if (*Guid
!= NULL
) {
1035 return EFI_NOT_FOUND
;
1042 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
1046 PeiPcdDb
= GetPcdDatabase ();
1048 ExMapTable
= PeiPcdDb
->Init
.ExMapTable
;
1050 if (*Guid
== NULL
) {
1052 // return the first Token Space Guid.
1054 *Guid
= &PeiPcdDb
->Init
.GuidTable
[ExMapTable
[0].ExGuidIndex
];
1058 MatchGuid
= ScanGuid (PeiPcdDb
->Init
.GuidTable
, sizeof(PeiPcdDb
->Init
.GuidTable
), *Guid
);
1060 if (MatchGuid
== NULL
) {
1061 return EFI_NOT_FOUND
;
1064 GuidTableIdx
= MatchGuid
- PeiPcdDb
->Init
.GuidTable
;
1067 for (Index
= 0; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
1068 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1076 for ( ; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++ ) {
1077 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1078 *Guid
= &PeiPcdDb
->Init
.GuidTable
[ExMapTable
[Index
].ExGuidIndex
];
1086 return EFI_NOT_FOUND
;
1091 Get PCD value's size for POINTER type PCD.
1093 The POINTER type PCD's value will be stored into a buffer in specificed size.
1094 The max size of this PCD's value is described in PCD's definition in DEC file.
1096 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1097 @param MaxSize Maxmium size of PCD's value
1098 @param Database Pcd database in PEI phase.
1100 @return PCD value's size for POINTER type PCD.
1105 IN UINTN LocalTokenNumberTableIdx
,
1107 IN PEI_PCD_DATABASE
*Database
1111 UINTN LocalTokenNumber
;
1113 SIZE_INFO
*SizeTable
;
1116 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1118 LocalTokenNumber
= Database
->Init
.LocalTokenNumberTable
[LocalTokenNumberTableIdx
];
1120 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1122 SizeTable
= Database
->Init
.SizeTable
;
1124 *MaxSize
= SizeTable
[SizeTableIdx
];
1126 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1129 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1131 // We have only one entry for VPD enabled PCD entry:
1133 // We consider current size is equal to MAX size.
1137 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1139 // We have only two entry for Non-Sku enabled PCD entry:
1143 return SizeTable
[SizeTableIdx
+ 1];
1146 // We have these entry for SKU enabled PCD entry
1148 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1150 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1151 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1152 if (SkuIdTable
[1 + Index
] == Database
->Init
.SystemSkuId
) {
1153 return SizeTable
[SizeTableIdx
+ 1 + Index
];
1156 return SizeTable
[SizeTableIdx
+ 1];
1162 Set PCD value's size for POINTER type PCD.
1164 The POINTER type PCD's value will be stored into a buffer in specificed size.
1165 The max size of this PCD's value is described in PCD's definition in DEC file.
1167 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1168 @param CurrentSize Maxmium size of PCD's value
1169 @param Database Pcd database in PEI phase.
1171 @retval TRUE Success to set PCD's value size, which is not exceed maxmium size
1172 @retval FALSE Fail to set PCD's value size, which maybe exceed maxmium size
1177 IN UINTN LocalTokenNumberTableIdx
,
1178 IN OUT UINTN
*CurrentSize
,
1179 IN PEI_PCD_DATABASE
*Database
1183 UINTN LocalTokenNumber
;
1185 SIZE_INFO
*SizeTable
;
1189 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1191 LocalTokenNumber
= Database
->Init
.LocalTokenNumberTable
[LocalTokenNumberTableIdx
];
1193 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1195 SizeTable
= Database
->Init
.SizeTable
;
1197 MaxSize
= SizeTable
[SizeTableIdx
];
1199 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1202 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1204 // We shouldn't come here as we don't support SET for VPD
1209 if ((*CurrentSize
> MaxSize
) ||
1210 (*CurrentSize
== MAX_ADDRESS
)) {
1211 *CurrentSize
= MaxSize
;
1215 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1217 // We have only two entry for Non-Sku enabled PCD entry:
1221 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;
1225 // We have these entry for SKU enabled PCD entry
1227 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1229 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1230 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1231 if (SkuIdTable
[1 + Index
] == Database
->Init
.SystemSkuId
) {
1232 SizeTable
[SizeTableIdx
+ 1 + Index
] = (SIZE_INFO
) *CurrentSize
;
1236 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;