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.
114 GetPcdDatabase()->Init
.SystemSkuId
= (SKU_ID
) SkuId
;
120 Retrieves an 8-bit value for a given PCD token.
122 Retrieves the current byte-sized value for a PCD token number.
123 If the TokenNumber is invalid, the results are unpredictable.
125 @param[in] TokenNumber The PCD token number.
127 @return The UINT8 value.
136 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
140 Retrieves an 16-bit value for a given PCD token.
142 Retrieves the current 16-bits value for a PCD token number.
143 If the TokenNumber is invalid, the results are unpredictable.
145 @param[in] TokenNumber The PCD token number.
147 @return The UINT16 value.
156 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
160 Retrieves an 32-bit value for a given PCD token.
162 Retrieves the current 32-bits value for a PCD token number.
163 If the TokenNumber is invalid, the results are unpredictable.
165 @param[in] TokenNumber The PCD token number.
167 @return The UINT32 value.
176 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
180 Retrieves an 64-bit value for a given PCD token.
182 Retrieves the current 64-bits value for a PCD token number.
183 If the TokenNumber is invalid, the results are unpredictable.
185 @param[in] TokenNumber The PCD token number.
187 @return The UINT64 value.
196 return ReadUnaligned64 (GetWorker (TokenNumber
, sizeof (UINT64
)));
200 Retrieves a pointer to a value for a given PCD token.
202 Retrieves the current pointer to the buffer for a PCD token number.
203 Do not make any assumptions about the alignment of the pointer that
204 is returned by this function call. If the TokenNumber is invalid,
205 the results are unpredictable.
207 @param[in] TokenNumber The PCD token number.
209 @return The pointer to the buffer to be retrived.
218 return GetWorker (TokenNumber
, 0);
222 Retrieves a Boolean value for a given PCD token.
224 Retrieves the current boolean value for a PCD token number.
225 Do not make any assumptions about the alignment of the pointer that
226 is returned by this function call. If the TokenNumber is invalid,
227 the results are unpredictable.
229 @param[in] TokenNumber The PCD token number.
231 @return The Boolean value.
240 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
244 Retrieves the size of the value for a given PCD token.
246 Retrieves the current size of a particular PCD token.
247 If the TokenNumber is invalid, the results are unpredictable.
249 @param[in] TokenNumber The PCD token number.
251 @return The size of the value for the PCD token.
260 PEI_PCD_DATABASE
*PeiPcdDb
;
265 // If DebugAssertEnabled is TRUE, we still need to provide the GET size
266 // function as GetWorker and SetWoker need this function to do ASSERT.
268 if ((!FeaturePcdGet(PcdPeiPcdDatabaseGetSizeEnabled
)) &&
269 (!DebugAssertEnabled ())) {
273 PeiPcdDb
= GetPcdDatabase ();
275 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
276 // We have to decrement TokenNumber by 1 to make it usable
277 // as the array index.
281 // EBC compiler is very choosy. It may report warning about comparison
282 // between UINTN and 0 . So we add 1 in each size of the
284 ASSERT (TokenNumber
+ 1 < PEI_LOCAL_TOKEN_NUMBER
+ 1);
286 Size
= (PeiPcdDb
->Init
.LocalTokenNumberTable
[TokenNumber
] & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
290 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
292 return GetPtrTypeSize (TokenNumber
, &MaxSize
, PeiPcdDb
);
300 Retrieves an 8-bit value for a given PCD token.
302 Retrieves the 8-bit value of a particular PCD token.
303 If the TokenNumber is invalid or the token space
304 specified by Guid does not exist, the results are
307 @param[in] Guid The token space for the token number.
308 @param[in] ExTokenNumber The PCD token number.
310 @return The size 8-bit value for the PCD token.
316 IN CONST EFI_GUID
*Guid
,
317 IN UINTN ExTokenNumber
320 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT8
)));
324 Retrieves an 16-bit value for a given PCD token.
326 Retrieves the 16-bit value of a particular PCD token.
327 If the TokenNumber is invalid or the token space
328 specified by Guid does not exist, the results are
331 @param[in] Guid The token space for the token number.
332 @param[in] ExTokenNumber The PCD token number.
334 @return The size 16-bit value for the PCD token.
340 IN CONST EFI_GUID
*Guid
,
341 IN UINTN ExTokenNumber
344 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT16
)));
348 Retrieves an 32-bit value for a given PCD token.
350 Retrieves the 32-bit value of a particular PCD token.
351 If the TokenNumber is invalid or the token space
352 specified by Guid does not exist, the results are
355 @param[in] Guid The token space for the token number.
356 @param[in] ExTokenNumber The PCD token number.
358 @return The size 32-bit value for the PCD token.
364 IN CONST EFI_GUID
*Guid
,
365 IN UINTN ExTokenNumber
368 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT32
)));
372 Retrieves an 64-bit value for a given PCD token.
374 Retrieves the 64-bit value of a particular PCD token.
375 If the TokenNumber is invalid or the token space
376 specified by Guid does not exist, the results are
379 @param[in] Guid The token space for the token number.
380 @param[in] ExTokenNumber The PCD token number.
382 @return The size 64-bit value for the PCD token.
388 IN CONST EFI_GUID
*Guid
,
389 IN UINTN ExTokenNumber
392 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof (UINT64
)));
396 Retrieves a pointer to a value for a given PCD token.
398 Retrieves the current pointer to the buffer for a PCD token number.
399 Do not make any assumptions about the alignment of the pointer that
400 is returned by this function call. If the TokenNumber is invalid,
401 the results are unpredictable.
403 @param[in] Guid The token space for the token number.
404 @param[in] ExTokenNumber The PCD token number.
406 @return The pointer to the buffer to be retrived.
412 IN CONST EFI_GUID
*Guid
,
413 IN UINTN ExTokenNumber
416 return ExGetWorker (Guid
, ExTokenNumber
, 0);
420 Retrieves an Boolean value for a given PCD token.
422 Retrieves the Boolean value of a particular PCD token.
423 If the TokenNumber is invalid or the token space
424 specified by Guid does not exist, the results are
427 @param[in] Guid The token space for the token number.
428 @param[in] ExTokenNumber The PCD token number.
430 @return The size Boolean value for the PCD token.
436 IN CONST EFI_GUID
*Guid
,
437 IN UINTN ExTokenNumber
440 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof (BOOLEAN
)));
444 Retrieves the size of the value for a given PCD token.
446 Retrieves the current size of a particular PCD token.
447 If the TokenNumber is invalid, the results are unpredictable.
449 @param[in] Guid The token space for the token number.
450 @param[in] ExTokenNumber The PCD token number.
452 @return The size of the value for the PCD token.
458 IN CONST EFI_GUID
*Guid
,
459 IN UINTN ExTokenNumber
462 if ((!FeaturePcdGet (PcdPeiPcdDatabaseGetSizeEnabled
)) || !FeaturePcdGet (PcdPeiPcdDatabaseExEnabled
)) {
466 return PeiPcdGetSize (GetExPcdTokenNumber (Guid
, ExTokenNumber
));
470 Sets an 8-bit value for a given PCD token.
472 When the PCD service sets a value, it will check to ensure that the
473 size of the value being set is compatible with the Token's existing definition.
474 If it is not, an error will be returned.
476 @param[in] TokenNumber The PCD token number.
477 @param[in] Value The value to set for the PCD token.
479 @retval EFI_SUCCESS Procedure returned successfully.
480 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
481 being set was incompatible with a call to this function.
482 Use GetSize() to retrieve the size of the target data.
483 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
489 IN UINTN TokenNumber
,
493 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
497 Sets an 16-bit value for a given PCD token.
499 When the PCD service sets a value, it will check to ensure that the
500 size of the value being set is compatible with the Token's existing definition.
501 If it is not, an error will be returned.
503 @param[in] TokenNumber The PCD token number.
504 @param[in] Value The value to set for the PCD token.
506 @retval EFI_SUCCESS Procedure returned successfully.
507 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
508 being set was incompatible with a call to this function.
509 Use GetSize() to retrieve the size of the target data.
510 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
516 IN UINTN TokenNumber
,
520 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
524 Sets an 32-bit value for a given PCD token.
526 When the PCD service sets a value, it will check to ensure that the
527 size of the value being set is compatible with the Token's existing definition.
528 If it is not, an error will be returned.
530 @param[in] TokenNumber The PCD token number.
531 @param[in] Value The value to set for the PCD token.
533 @retval EFI_SUCCESS Procedure returned successfully.
534 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
535 being set was incompatible with a call to this function.
536 Use GetSize() to retrieve the size of the target data.
537 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
543 IN UINTN TokenNumber
,
547 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
551 Sets an 64-bit value for a given PCD token.
553 When the PCD service sets a value, it will check to ensure that the
554 size of the value being set is compatible with the Token's existing definition.
555 If it is not, an error will be returned.
557 @param[in] TokenNumber The PCD token number.
558 @param[in] Value The value to set for the PCD token.
560 @retval EFI_SUCCESS Procedure returned successfully.
561 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
562 being set was incompatible with a call to this function.
563 Use GetSize() to retrieve the size of the target data.
564 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
570 IN UINTN TokenNumber
,
574 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
578 Sets a value of a specified size for a given PCD token.
580 When the PCD service sets a value, it will check to ensure that the
581 size of the value being set is compatible with the Token's existing definition.
582 If it is not, an error will be returned.
584 @param[in] TokenNumber The PCD token number.
585 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
586 On input, if the SizeOfValue is greater than the maximum size supported
587 for this TokenNumber then the output value of SizeOfValue will reflect
588 the maximum size supported for this TokenNumber.
589 @param[in] Buffer The buffer to set for the PCD token.
591 @retval EFI_SUCCESS Procedure returned successfully.
592 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
593 being set was incompatible with a call to this function.
594 Use GetSize() to retrieve the size of the target data.
595 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
601 IN UINTN TokenNumber
,
602 IN OUT UINTN
*SizeOfBuffer
,
606 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
610 Sets an Boolean value for a given PCD token.
612 When the PCD service sets a value, it will check to ensure that the
613 size of the value being set is compatible with the Token's existing definition.
614 If it is not, an error will be returned.
616 @param[in] TokenNumber The PCD token number.
617 @param[in] Value The value to set for the PCD token.
619 @retval EFI_SUCCESS Procedure returned successfully.
620 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
621 being set was incompatible with a call to this function.
622 Use GetSize() to retrieve the size of the target data.
623 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
629 IN UINTN TokenNumber
,
633 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
637 Sets an 8-bit value for a given PCD token.
639 When the PCD service sets a value, it will check to ensure that the
640 size of the value being set is compatible with the Token's existing definition.
641 If it is not, an error will be returned.
643 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
644 @param[in] ExTokenNumber The PCD token number.
645 @param[in] Value The value to set for the PCD token.
647 @retval EFI_SUCCESS Procedure returned successfully.
648 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
649 being set was incompatible with a call to this function.
650 Use GetSize() to retrieve the size of the target data.
651 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
657 IN CONST EFI_GUID
*Guid
,
658 IN UINTN ExTokenNumber
,
662 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
666 Sets an 16-bit value for a given PCD token.
668 When the PCD service sets a value, it will check to ensure that the
669 size of the value being set is compatible with the Token's existing definition.
670 If it is not, an error will be returned.
672 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
673 @param[in] ExTokenNumber The PCD token number.
674 @param[in] Value The value to set for the PCD token.
676 @retval EFI_SUCCESS Procedure returned successfully.
677 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
678 being set was incompatible with a call to this function.
679 Use GetSize() to retrieve the size of the target data.
680 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
686 IN CONST EFI_GUID
*Guid
,
687 IN UINTN ExTokenNumber
,
691 return ExSetValueWorker (ExTokenNumber
, Guid
, &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] Guid The 128-bit unique value that designates the namespace from which to extract the value.
702 @param[in] ExTokenNumber The PCD token number.
703 @param[in] Value The value to set for the PCD token.
705 @retval EFI_SUCCESS Procedure returned successfully.
706 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
707 being set was incompatible with a call to this function.
708 Use GetSize() to retrieve the size of the target data.
709 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
715 IN CONST EFI_GUID
*Guid
,
716 IN UINTN ExTokenNumber
,
720 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
724 Sets an 64-bit value for a given PCD token.
726 When the PCD service sets a value, it will check to ensure that the
727 size of the value being set is compatible with the Token's existing definition.
728 If it is not, an error will be returned.
730 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
731 @param[in] ExTokenNumber The PCD token number.
732 @param[in] Value The value to set for the PCD token.
734 @retval EFI_SUCCESS Procedure returned successfully.
735 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
736 being set was incompatible with a call to this function.
737 Use GetSize() to retrieve the size of the target data.
738 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
744 IN CONST EFI_GUID
*Guid
,
745 IN UINTN ExTokenNumber
,
749 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
753 Sets a value of a specified size for a given PCD token.
755 When the PCD service sets a value, it will check to ensure that the
756 size of the value being set is compatible with the Token's existing definition.
757 If it is not, an error will be returned.
759 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
760 @param[in] ExTokenNumber The PCD token number.
761 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
762 On input, if the SizeOfValue is greater than the maximum size supported
763 for this TokenNumber then the output value of SizeOfValue will reflect
764 the maximum size supported for this TokenNumber.
765 @param[in] Value The buffer to set for the PCD token.
767 @retval EFI_SUCCESS Procedure returned successfully.
768 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
769 being set was incompatible with a call to this function.
770 Use GetSize() to retrieve the size of the target data.
771 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
777 IN CONST EFI_GUID
*Guid
,
778 IN UINTN ExTokenNumber
,
779 IN OUT UINTN
*SizeOfBuffer
,
783 return ExSetWorker (ExTokenNumber
, Guid
, Value
, SizeOfBuffer
, TRUE
);
787 Sets an Boolean value for a given PCD token.
789 When the PCD service sets a value, it will check to ensure that the
790 size of the value being set is compatible with the Token's existing definition.
791 If it is not, an error will be returned.
793 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
794 @param [in] ExTokenNumber The PCD token number.
795 @param [in] Value The value to set for the PCD token.
797 @retval EFI_SUCCESS Procedure returned successfully.
798 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
799 being set was incompatible with a call to this function.
800 Use GetSize() to retrieve the size of the target data.
801 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
807 IN CONST EFI_GUID
*Guid
,
808 IN UINTN ExTokenNumber
,
812 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
816 Specifies a function to be called anytime the value of a designated token is changed.
818 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
819 @param[in] ExTokenNumber The PCD token number.
820 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
822 @retval EFI_SUCCESS The PCD service has successfully established a call event
823 for the CallBackToken requested.
824 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
829 PeiRegisterCallBackOnSet (
830 IN CONST EFI_GUID
*Guid
, OPTIONAL
831 IN UINTN ExTokenNumber
,
832 IN PCD_PPI_CALLBACK CallBackFunction
835 if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled
)) {
836 return EFI_UNSUPPORTED
;
839 ASSERT (CallBackFunction
!= NULL
);
841 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, TRUE
);
845 Cancels a previously set callback function for a particular PCD token number.
847 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
848 @param[in] ExTokenNumber The PCD token number.
849 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
851 @retval EFI_SUCCESS The PCD service has successfully established a call event
852 for the CallBackToken requested.
853 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
858 PcdUnRegisterCallBackOnSet (
859 IN CONST EFI_GUID
*Guid
, OPTIONAL
860 IN UINTN ExTokenNumber
,
861 IN PCD_PPI_CALLBACK CallBackFunction
864 if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled
)) {
865 return EFI_UNSUPPORTED
;
868 ASSERT (CallBackFunction
!= NULL
);
870 return PeiRegisterCallBackWorker (ExTokenNumber
, Guid
, CallBackFunction
, FALSE
);
874 Retrieves the next valid PCD token for a given namespace.
876 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
877 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
878 If the input token namespace or token number does not exist on the platform,
879 an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token,
880 have the pointer reference a TokenNumber value of 0. If the input token number is 0 and
881 there is no valid token number for this token namespace, *TokenNumber will be assigned to
882 0 and the function return EFI_SUCCESS. If the token number is the last valid token number,
883 *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.
885 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
886 is already the last valid token number in the PCD database.
887 In the later case, *TokenNumber is updated with the value of 0.
888 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
894 IN CONST EFI_GUID
*Guid
, OPTIONAL
895 IN OUT UINTN
*TokenNumber
899 PEI_PCD_DATABASE
*PeiPcdDb
;
901 DYNAMICEX_MAPPING
*ExMapTable
;
904 BOOLEAN PeiExMapTableEmpty
;
906 if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled
)) {
907 return EFI_UNSUPPORTED
;
910 PeiExMapTableEmpty
= PEI_EXMAP_TABLE_EMPTY
;
913 if (*TokenNumber
> PEI_NEX_TOKEN_NUMBER
) {
914 return EFI_NOT_FOUND
;
917 if (*TokenNumber
> PEI_NEX_TOKEN_NUMBER
) {
918 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
922 if (PeiExMapTableEmpty
) {
923 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
928 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
932 PeiPcdDb
= GetPcdDatabase ();
934 MatchGuid
= ScanGuid (PeiPcdDb
->Init
.GuidTable
, sizeof(PeiPcdDb
->Init
.GuidTable
), Guid
);
936 if (MatchGuid
== NULL
) {
937 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
938 return EFI_NOT_FOUND
;
941 GuidTableIdx
= MatchGuid
- PeiPcdDb
->Init
.GuidTable
;
943 ExMapTable
= PeiPcdDb
->Init
.ExMapTable
;
947 // Locate the GUID in ExMapTable first.
949 for (Index
= 0; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
950 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
957 if (*TokenNumber
== PCD_INVALID_TOKEN_NUMBER
) {
958 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
962 for ( ; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
963 if (ExMapTable
[Index
].ExTokenNumber
== *TokenNumber
) {
965 if (Index
== PEI_EXMAPPING_TABLE_SIZE
) {
967 // Exceed the length of ExMap Table
969 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
972 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
973 *TokenNumber
= ExMapTable
[Index
].ExTokenNumber
;
976 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
981 return EFI_NOT_FOUND
;
985 return EFI_NOT_FOUND
;
989 Retrieves the next valid PCD token namespace for a given namespace.
991 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates
992 a known token namespace from which the search will start. On output,
993 it designates the next valid token namespace on the platform. If the input
994 token namespace does not exist on the platform, an error is returned and
995 the value of *Guid is undefined. If *Guid is NULL, then the GUID of the
996 first token space of the current platform is assigned to *Guid the function
997 return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in
998 the platform other than the default (NULL) tokennamespace, *Guid is unchanged
999 and the function return EFI_SUCCESS. If this input token namespace is the last
1000 namespace on the platform, *Guid will be assigned to NULL and the function return
1003 @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid.
1004 Or the input token space Guid is already the last valid token space Guid
1005 in the PCD database. In the later case, *Guid is updated with the value of NULL.
1006 @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.
1011 PeiPcdGetNextTokenSpace (
1012 IN OUT CONST EFI_GUID
**Guid
1016 EFI_GUID
*MatchGuid
;
1017 PEI_PCD_DATABASE
*PeiPcdDb
;
1018 DYNAMICEX_MAPPING
*ExMapTable
;
1021 BOOLEAN PeiExMapTableEmpty
;
1023 if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled
)) {
1024 return EFI_UNSUPPORTED
;
1027 ASSERT (Guid
!= NULL
);
1029 PeiExMapTableEmpty
= PEI_EXMAP_TABLE_EMPTY
;
1031 if (PeiExMapTableEmpty
) {
1032 if (*Guid
!= NULL
) {
1033 return EFI_NOT_FOUND
;
1040 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order
1044 PeiPcdDb
= GetPcdDatabase ();
1046 ExMapTable
= PeiPcdDb
->Init
.ExMapTable
;
1048 if (*Guid
== NULL
) {
1050 // return the first Token Space Guid.
1052 *Guid
= &PeiPcdDb
->Init
.GuidTable
[ExMapTable
[0].ExGuidIndex
];
1056 MatchGuid
= ScanGuid (PeiPcdDb
->Init
.GuidTable
, sizeof(PeiPcdDb
->Init
.GuidTable
), *Guid
);
1058 if (MatchGuid
== NULL
) {
1059 return EFI_NOT_FOUND
;
1062 GuidTableIdx
= MatchGuid
- PeiPcdDb
->Init
.GuidTable
;
1065 for (Index
= 0; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++) {
1066 if (ExMapTable
[Index
].ExGuidIndex
== GuidTableIdx
) {
1074 for ( ; Index
< PEI_EXMAPPING_TABLE_SIZE
; Index
++ ) {
1075 if (ExMapTable
[Index
].ExGuidIndex
!= GuidTableIdx
) {
1076 *Guid
= &PeiPcdDb
->Init
.GuidTable
[ExMapTable
[Index
].ExGuidIndex
];
1084 return EFI_NOT_FOUND
;
1089 Get PCD value's size for POINTER type PCD.
1091 The POINTER type PCD's value will be stored into a buffer in specificed size.
1092 The max size of this PCD's value is described in PCD's definition in DEC file.
1094 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1095 @param MaxSize Maxmium size of PCD's value
1096 @param Database Pcd database in PEI phase.
1098 @return PCD value's size for POINTER type PCD.
1103 IN UINTN LocalTokenNumberTableIdx
,
1105 IN PEI_PCD_DATABASE
*Database
1109 UINTN LocalTokenNumber
;
1111 SIZE_INFO
*SizeTable
;
1114 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1116 LocalTokenNumber
= Database
->Init
.LocalTokenNumberTable
[LocalTokenNumberTableIdx
];
1118 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1120 SizeTable
= Database
->Init
.SizeTable
;
1122 *MaxSize
= SizeTable
[SizeTableIdx
];
1124 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1127 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1129 // We have only one entry for VPD enabled PCD entry:
1131 // We consider current size is equal to MAX size.
1135 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1137 // We have only two entry for Non-Sku enabled PCD entry:
1141 return SizeTable
[SizeTableIdx
+ 1];
1144 // We have these entry for SKU enabled PCD entry
1146 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1148 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1149 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1150 if (SkuIdTable
[1 + Index
] == Database
->Init
.SystemSkuId
) {
1151 return SizeTable
[SizeTableIdx
+ 1 + Index
];
1154 return SizeTable
[SizeTableIdx
+ 1];
1160 Set PCD value's size for POINTER type PCD.
1162 The POINTER type PCD's value will be stored into a buffer in specificed size.
1163 The max size of this PCD's value is described in PCD's definition in DEC file.
1165 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1166 @param CurrentSize Maxmium size of PCD's value
1167 @param Database Pcd database in PEI phase.
1169 @retval TRUE Success to set PCD's value size, which is not exceed maxmium size
1170 @retval FALSE Fail to set PCD's value size, which maybe exceed maxmium size
1175 IN UINTN LocalTokenNumberTableIdx
,
1176 IN OUT UINTN
*CurrentSize
,
1177 IN PEI_PCD_DATABASE
*Database
1181 UINTN LocalTokenNumber
;
1183 SIZE_INFO
*SizeTable
;
1187 SizeTableIdx
= GetSizeTableIndex (LocalTokenNumberTableIdx
, Database
);
1189 LocalTokenNumber
= Database
->Init
.LocalTokenNumberTable
[LocalTokenNumberTableIdx
];
1191 ASSERT ((LocalTokenNumber
& PCD_DATUM_TYPE_ALL_SET
) == PCD_DATUM_TYPE_POINTER
);
1193 SizeTable
= Database
->Init
.SizeTable
;
1195 MaxSize
= SizeTable
[SizeTableIdx
];
1197 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1200 if ((LocalTokenNumber
& PCD_TYPE_VPD
) != 0) {
1202 // We shouldn't come here as we don't support SET for VPD
1207 if ((*CurrentSize
> MaxSize
) ||
1208 (*CurrentSize
== MAX_ADDRESS
)) {
1209 *CurrentSize
= MaxSize
;
1213 if ((LocalTokenNumber
& PCD_TYPE_SKU_ENABLED
) == 0) {
1215 // We have only two entry for Non-Sku enabled PCD entry:
1219 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;
1223 // We have these entry for SKU enabled PCD entry
1225 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1227 SkuIdTable
= GetSkuIdArray (LocalTokenNumberTableIdx
, Database
);
1228 for (Index
= 0; Index
< SkuIdTable
[0]; Index
++) {
1229 if (SkuIdTable
[1 + Index
] == Database
->Init
.SystemSkuId
) {
1230 SizeTable
[SizeTableIdx
+ 1 + Index
] = (SIZE_INFO
) *CurrentSize
;
1234 SizeTable
[SizeTableIdx
+ 1] = (SIZE_INFO
) *CurrentSize
;