2 PCD DXE driver manage all PCD entry initialized in PEI phase and DXE phase, and
3 produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in
6 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 /// PCD database lock.
22 EFI_LOCK mPcdDatabaseLock
= EFI_INITIALIZE_LOCK_VARIABLE(TPL_NOTIFY
);
25 /// PCD_PROTOCOL the EDKII native implementation which support dynamic
26 /// type and dynamicEx type PCDs.
28 PCD_PROTOCOL mPcdInstance
= {
61 DxeRegisterCallBackOnSet
,
62 DxeUnRegisterCallBackOnSet
,
64 DxePcdGetNextTokenSpace
68 /// EFI_PCD_PROTOCOL is defined in PI 1.2 Vol 3 which only support dynamicEx type
71 EFI_PCD_PROTOCOL mEfiPcdInstance
= {
86 (EFI_PCD_PROTOCOL_CALLBACK_ON_SET
) DxeRegisterCallBackOnSet
,
87 (EFI_PCD_PROTOCOL_CANCEL_CALLBACK
) DxeUnRegisterCallBackOnSet
,
89 DxePcdGetNextTokenSpace
93 /// Instance of GET_PCD_INFO_PROTOCOL protocol is EDKII native implementation.
94 /// This protocol instance support dynamic and dynamicEx type PCDs.
96 GET_PCD_INFO_PROTOCOL mGetPcdInfoInstance
= {
98 DxeGetPcdInfoGetInfoEx
,
103 /// Instance of EFI_GET_PCD_INFO_PROTOCOL which is defined in PI 1.2.1 Vol 3.
104 /// This PPI instance only support dyanmicEx type PCD.
106 EFI_GET_PCD_INFO_PROTOCOL mEfiGetPcdInfoInstance
= {
107 DxeGetPcdInfoGetInfoEx
,
111 EFI_HANDLE mPcdHandle
= NULL
;
114 Main entry for PCD DXE driver.
116 This routine initialize the PCD database and install PCD_PROTOCOL.
118 @param ImageHandle Image handle for PCD DXE driver.
119 @param SystemTable Pointer to SystemTable.
121 @return Status of gBS->InstallProtocolInterface()
127 IN EFI_HANDLE ImageHandle
,
128 IN EFI_SYSTEM_TABLE
*SystemTable
134 // Make sure the Pcd Protocol is not already installed in the system
137 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gPcdProtocolGuid
);
139 BuildPcdDxeDataBase ();
142 // Install PCD_PROTOCOL to handle dynamic type PCD
143 // Install EFI_PCD_PROTOCOL to handle dynamicEx type PCD
145 Status
= gBS
->InstallMultipleProtocolInterfaces (
147 &gPcdProtocolGuid
, &mPcdInstance
,
148 &gEfiPcdProtocolGuid
, &mEfiPcdInstance
,
151 ASSERT_EFI_ERROR (Status
);
153 if (FeaturePcdGet (PcdPcdInfoGeneration
) && mPcdDatabase
.DxeDb
->PcdNameTableOffset
!= 0) {
155 // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD
156 // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD
158 Status
= gBS
->InstallMultipleProtocolInterfaces (
160 &gGetPcdInfoProtocolGuid
, &mGetPcdInfoInstance
,
161 &gEfiGetPcdInfoProtocolGuid
, &mEfiGetPcdInfoInstance
,
164 ASSERT_EFI_ERROR (Status
);
171 Retrieve additional information associated with a PCD token in the default token space.
173 This includes information such as the type of value the TokenNumber is associated with as well as possible
174 human readable name that is associated with the token.
176 @param[in] TokenNumber The PCD token number.
177 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
178 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
180 @retval EFI_SUCCESS The PCD information was returned successfully.
181 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
185 DxeGetPcdInfoGetInfo (
186 IN UINTN TokenNumber
,
187 OUT EFI_PCD_INFO
*PcdInfo
190 return DxeGetPcdInfo (NULL
, TokenNumber
, PcdInfo
);
194 Retrieve additional information associated with a PCD token.
196 This includes information such as the type of value the TokenNumber is associated with as well as possible
197 human readable name that is associated with the token.
199 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
200 @param[in] TokenNumber The PCD token number.
201 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
202 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
204 @retval EFI_SUCCESS The PCD information was returned successfully.
205 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
209 DxeGetPcdInfoGetInfoEx (
210 IN CONST EFI_GUID
*Guid
,
211 IN UINTN TokenNumber
,
212 OUT EFI_PCD_INFO
*PcdInfo
215 return DxeGetPcdInfo (Guid
, TokenNumber
, PcdInfo
);
219 Retrieve the currently set SKU Id.
221 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
222 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
227 DxeGetPcdInfoGetSku (
231 if (!FeaturePcdGet (PcdPcdInfoGeneration
)) {
232 return EFI_UNSUPPORTED
;
234 return mPcdDatabase
.PeiDb
->SystemSkuId
;
238 Sets the SKU value for subsequent calls to set or get PCD token values.
240 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
241 SetSku() is normally called only once by the system.
243 For each item (token), the database can hold a single value that applies to all SKUs,
244 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
245 SKU-specific values are called SKU enabled.
247 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
248 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
249 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
250 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
251 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
252 set for that Id, the results are unpredictable.
254 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
255 set values associated with a PCD token.
264 mPcdDatabase
.PeiDb
->SystemSkuId
= (SKU_ID
) SkuId
;
270 Retrieves an 8-bit value for a given PCD token.
272 Retrieves the current byte-sized value for a PCD token number.
273 If the TokenNumber is invalid, the results are unpredictable.
275 @param[in] TokenNumber The PCD token number.
277 @return The UINT8 value.
286 return *((UINT8
*) GetWorker (TokenNumber
, sizeof (UINT8
)));
290 Retrieves an 16-bit value for a given PCD token.
292 Retrieves the current 16-bits value for a PCD token number.
293 If the TokenNumber is invalid, the results are unpredictable.
295 @param[in] TokenNumber The PCD token number.
297 @return The UINT16 value.
306 return ReadUnaligned16 (GetWorker (TokenNumber
, sizeof (UINT16
)));
310 Retrieves an 32-bit value for a given PCD token.
312 Retrieves the current 32-bits value for a PCD token number.
313 If the TokenNumber is invalid, the results are unpredictable.
315 @param[in] TokenNumber The PCD token number.
317 @return The UINT32 value.
326 return ReadUnaligned32 (GetWorker (TokenNumber
, sizeof (UINT32
)));
330 Retrieves an 64-bit value for a given PCD token.
332 Retrieves the current 64-bits value for a PCD token number.
333 If the TokenNumber is invalid, the results are unpredictable.
335 @param[in] TokenNumber The PCD token number.
337 @return The UINT64 value.
346 return ReadUnaligned64(GetWorker (TokenNumber
, sizeof (UINT64
)));
350 Retrieves a pointer to a value for a given PCD token.
352 Retrieves the current pointer to the buffer for a PCD token number.
353 Do not make any assumptions about the alignment of the pointer that
354 is returned by this function call. If the TokenNumber is invalid,
355 the results are unpredictable.
357 @param[in] TokenNumber The PCD token number.
359 @return The pointer to the buffer to be retrived.
368 return GetWorker (TokenNumber
, 0);
372 Retrieves a Boolean value for a given PCD token.
374 Retrieves the current boolean value for a PCD token number.
375 Do not make any assumptions about the alignment of the pointer that
376 is returned by this function call. If the TokenNumber is invalid,
377 the results are unpredictable.
379 @param[in] TokenNumber The PCD token number.
381 @return The Boolean value.
390 return *((BOOLEAN
*) GetWorker (TokenNumber
, sizeof (BOOLEAN
)));
394 Retrieves the size of the value for a given PCD token.
396 Retrieves the current size of a particular PCD token.
397 If the TokenNumber is invalid, the results are unpredictable.
399 @param[in] TokenNumber The PCD token number.
401 @return The size of the value for the PCD token.
411 UINT32
*LocalTokenNumberTable
;
414 UINTN TmpTokenNumber
;
416 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
417 // We have to decrement TokenNumber by 1 to make it usable
418 // as the array index.
423 // Backup the TokenNumber passed in as GetPtrTypeSize need the original TokenNumber
425 TmpTokenNumber
= TokenNumber
;
427 // EBC compiler is very choosy. It may report warning about comparison
428 // between UINTN and 0 . So we add 1 in each size of the
430 ASSERT (TokenNumber
+ 1 < mPcdTotalTokenCount
+ 1);
432 // EBC compiler is very choosy. It may report warning about comparison
433 // between UINTN and 0 . So we add 1 in each size of the
435 IsPeiDb
= (BOOLEAN
) (TokenNumber
+ 1 < mPeiLocalTokenCount
+ 1);
437 TokenNumber
= IsPeiDb
? TokenNumber
:
438 (TokenNumber
- mPeiLocalTokenCount
);
440 LocalTokenNumberTable
= IsPeiDb
? (UINT32
*)((UINT8
*)mPcdDatabase
.PeiDb
+ mPcdDatabase
.PeiDb
->LocalTokenNumberTableOffset
)
441 : (UINT32
*)((UINT8
*)mPcdDatabase
.DxeDb
+ mPcdDatabase
.DxeDb
->LocalTokenNumberTableOffset
);
443 Size
= (LocalTokenNumberTable
[TokenNumber
] & PCD_DATUM_TYPE_ALL_SET
) >> PCD_DATUM_TYPE_SHIFT
;
447 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
449 return GetPtrTypeSize (TmpTokenNumber
, &MaxSize
);
457 Retrieves an 8-bit value for a given PCD token.
459 Retrieves the 8-bit value of a particular PCD token.
460 If the TokenNumber is invalid or the token space
461 specified by Guid does not exist, the results are
464 @param[in] Guid The token space for the token number.
465 @param[in] ExTokenNumber The PCD token number.
467 @return The size 8-bit value for the PCD token.
473 IN CONST EFI_GUID
*Guid
,
474 IN UINTN ExTokenNumber
477 return *((UINT8
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof(UINT8
)));
481 Retrieves an 16-bit value for a given PCD token.
483 Retrieves the 16-bit value of a particular PCD token.
484 If the TokenNumber is invalid or the token space
485 specified by Guid does not exist, the results are
488 @param[in] Guid The token space for the token number.
489 @param[in] ExTokenNumber The PCD token number.
491 @return The size 16-bit value for the PCD token.
497 IN CONST EFI_GUID
*Guid
,
498 IN UINTN ExTokenNumber
501 return ReadUnaligned16 (ExGetWorker (Guid
, ExTokenNumber
, sizeof(UINT16
)));
505 Retrieves an 32-bit value for a given PCD token.
507 Retrieves the 32-bit value of a particular PCD token.
508 If the TokenNumber is invalid or the token space
509 specified by Guid does not exist, the results are
512 @param[in] Guid The token space for the token number.
513 @param[in] ExTokenNumber The PCD token number.
515 @return The size 32-bit value for the PCD token.
521 IN CONST EFI_GUID
*Guid
,
522 IN UINTN ExTokenNumber
525 return ReadUnaligned32 (ExGetWorker (Guid
, ExTokenNumber
, sizeof(UINT32
)));
529 Retrieves an 64-bit value for a given PCD token.
531 Retrieves the 64-bit value of a particular PCD token.
532 If the TokenNumber is invalid or the token space
533 specified by Guid does not exist, the results are
536 @param[in] Guid The token space for the token number.
537 @param[in] ExTokenNumber The PCD token number.
539 @return The size 64-bit value for the PCD token.
545 IN CONST EFI_GUID
*Guid
,
546 IN UINTN ExTokenNumber
549 return ReadUnaligned64 (ExGetWorker (Guid
, ExTokenNumber
, sizeof(UINT64
)));
553 Retrieves a pointer to a value for a given PCD token.
555 Retrieves the current pointer to the buffer for a PCD token number.
556 Do not make any assumptions about the alignment of the pointer that
557 is returned by this function call. If the TokenNumber is invalid,
558 the results are unpredictable.
560 @param[in] Guid The token space for the token number.
561 @param[in] ExTokenNumber The PCD token number.
563 @return The pointer to the buffer to be retrived.
569 IN CONST EFI_GUID
*Guid
,
570 IN UINTN ExTokenNumber
573 return ExGetWorker (Guid
, ExTokenNumber
, 0);
577 Retrieves an Boolean value for a given PCD token.
579 Retrieves the Boolean value of a particular PCD token.
580 If the TokenNumber is invalid or the token space
581 specified by Guid does not exist, the results are
584 @param[in] Guid The token space for the token number.
585 @param[in] ExTokenNumber The PCD token number.
587 @return The size Boolean value for the PCD token.
593 IN CONST EFI_GUID
*Guid
,
594 IN UINTN ExTokenNumber
597 return *((BOOLEAN
*) ExGetWorker (Guid
, ExTokenNumber
, sizeof(BOOLEAN
)));
601 Retrieves the size of the value for a given PCD token.
603 Retrieves the current size of a particular PCD token.
604 If the TokenNumber is invalid, the results are unpredictable.
606 @param[in] Guid The token space for the token number.
607 @param[in] ExTokenNumber The PCD token number.
609 @return The size of the value for the PCD token.
615 IN CONST EFI_GUID
*Guid
,
616 IN UINTN ExTokenNumber
619 return DxePcdGetSize(GetExPcdTokenNumber (Guid
, (UINT32
) ExTokenNumber
));
623 Sets an 8-bit value for a given PCD token.
625 When the PCD service sets a value, it will check to ensure that the
626 size of the value being set is compatible with the Token's existing definition.
627 If it is not, an error will be returned.
629 @param[in] TokenNumber The PCD token number.
630 @param[in] Value The value to set for the PCD token.
632 @retval EFI_SUCCESS Procedure returned successfully.
633 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
634 being set was incompatible with a call to this function.
635 Use GetSize() to retrieve the size of the target data.
636 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
642 IN UINTN TokenNumber
,
646 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
650 Sets an 16-bit value for a given PCD token.
652 When the PCD service sets a value, it will check to ensure that the
653 size of the value being set is compatible with the Token's existing definition.
654 If it is not, an error will be returned.
656 @param[in] TokenNumber The PCD token number.
657 @param[in] Value The value to set for the PCD token.
659 @retval EFI_SUCCESS Procedure returned successfully.
660 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
661 being set was incompatible with a call to this function.
662 Use GetSize() to retrieve the size of the target data.
663 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
669 IN UINTN TokenNumber
,
673 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
677 Sets an 32-bit value for a given PCD token.
679 When the PCD service sets a value, it will check to ensure that the
680 size of the value being set is compatible with the Token's existing definition.
681 If it is not, an error will be returned.
683 @param[in] TokenNumber The PCD token number.
684 @param[in] Value The value to set for the PCD token.
686 @retval EFI_SUCCESS Procedure returned successfully.
687 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
688 being set was incompatible with a call to this function.
689 Use GetSize() to retrieve the size of the target data.
690 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
696 IN UINTN TokenNumber
,
700 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
704 Sets an 64-bit value for a given PCD token.
706 When the PCD service sets a value, it will check to ensure that the
707 size of the value being set is compatible with the Token's existing definition.
708 If it is not, an error will be returned.
710 @param[in] TokenNumber The PCD token number.
711 @param[in] Value The value to set for the PCD token.
713 @retval EFI_SUCCESS Procedure returned successfully.
714 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
715 being set was incompatible with a call to this function.
716 Use GetSize() to retrieve the size of the target data.
717 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
723 IN UINTN TokenNumber
,
727 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
731 Sets a value of a specified size for a given PCD token.
733 When the PCD service sets a value, it will check to ensure that the
734 size of the value being set is compatible with the Token's existing definition.
735 If it is not, an error will be returned.
737 @param[in] TokenNumber The PCD token number.
738 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
739 On input, if the SizeOfValue is greater than the maximum size supported
740 for this TokenNumber then the output value of SizeOfValue will reflect
741 the maximum size supported for this TokenNumber.
742 @param[in] Buffer The buffer to set for the PCD token.
744 @retval EFI_SUCCESS Procedure returned successfully.
745 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
746 being set was incompatible with a call to this function.
747 Use GetSize() to retrieve the size of the target data.
748 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
754 IN UINTN TokenNumber
,
755 IN OUT UINTN
*SizeOfBuffer
,
759 return SetWorker (TokenNumber
, Buffer
, SizeOfBuffer
, TRUE
);
763 Sets an Boolean value for a given PCD token.
765 When the PCD service sets a value, it will check to ensure that the
766 size of the value being set is compatible with the Token's existing definition.
767 If it is not, an error will be returned.
769 @param[in] TokenNumber The PCD token number.
770 @param[in] Value The value to set for the PCD token.
772 @retval EFI_SUCCESS Procedure returned successfully.
773 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
774 being set was incompatible with a call to this function.
775 Use GetSize() to retrieve the size of the target data.
776 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
782 IN UINTN TokenNumber
,
786 return SetValueWorker (TokenNumber
, &Value
, sizeof (Value
));
790 Sets an 8-bit value for a given PCD token.
792 When the PCD service sets a value, it will check to ensure that the
793 size of the value being set is compatible with the Token's existing definition.
794 If it is not, an error will be returned.
796 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
797 @param[in] ExTokenNumber The PCD token number.
798 @param[in] Value The value to set for the PCD token.
800 @retval EFI_SUCCESS Procedure returned successfully.
801 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
802 being set was incompatible with a call to this function.
803 Use GetSize() to retrieve the size of the target data.
804 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
810 IN CONST EFI_GUID
*Guid
,
811 IN UINTN ExTokenNumber
,
815 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
819 Sets an 16-bit value for a given PCD token.
821 When the PCD service sets a value, it will check to ensure that the
822 size of the value being set is compatible with the Token's existing definition.
823 If it is not, an error will be returned.
825 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
826 @param[in] ExTokenNumber The PCD token number.
827 @param[in] Value The value to set for the PCD token.
829 @retval EFI_SUCCESS Procedure returned successfully.
830 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
831 being set was incompatible with a call to this function.
832 Use GetSize() to retrieve the size of the target data.
833 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
839 IN CONST EFI_GUID
*Guid
,
840 IN UINTN ExTokenNumber
,
844 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
848 Sets an 32-bit value for a given PCD token.
850 When the PCD service sets a value, it will check to ensure that the
851 size of the value being set is compatible with the Token's existing definition.
852 If it is not, an error will be returned.
854 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
855 @param[in] ExTokenNumber The PCD token number.
856 @param[in] Value The value to set for the PCD token.
858 @retval EFI_SUCCESS Procedure returned successfully.
859 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
860 being set was incompatible with a call to this function.
861 Use GetSize() to retrieve the size of the target data.
862 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
868 IN CONST EFI_GUID
*Guid
,
869 IN UINTN ExTokenNumber
,
873 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
877 Sets an 64-bit value for a given PCD token.
879 When the PCD service sets a value, it will check to ensure that the
880 size of the value being set is compatible with the Token's existing definition.
881 If it is not, an error will be returned.
883 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
884 @param[in] ExTokenNumber The PCD token number.
885 @param[in] Value The value to set for the PCD token.
887 @retval EFI_SUCCESS Procedure returned successfully.
888 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
889 being set was incompatible with a call to this function.
890 Use GetSize() to retrieve the size of the target data.
891 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
897 IN CONST EFI_GUID
*Guid
,
898 IN UINTN ExTokenNumber
,
902 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
906 Sets a value of a specified size for a given PCD token.
908 When the PCD service sets a value, it will check to ensure that the
909 size of the value being set is compatible with the Token's existing definition.
910 If it is not, an error will be returned.
912 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
913 @param[in] ExTokenNumber The PCD token number.
914 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
915 On input, if the SizeOfValue is greater than the maximum size supported
916 for this TokenNumber then the output value of SizeOfValue will reflect
917 the maximum size supported for this TokenNumber.
918 @param[in] Buffer The buffer to set for the PCD token.
920 @retval EFI_SUCCESS Procedure returned successfully.
921 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
922 being set was incompatible with a call to this function.
923 Use GetSize() to retrieve the size of the target data.
924 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
930 IN CONST EFI_GUID
*Guid
,
931 IN UINTN ExTokenNumber
,
932 IN OUT UINTN
*SizeOfBuffer
,
936 return ExSetWorker(ExTokenNumber
, Guid
, Buffer
, SizeOfBuffer
, TRUE
);
940 Sets an Boolean value for a given PCD token.
942 When the PCD service sets a value, it will check to ensure that the
943 size of the value being set is compatible with the Token's existing definition.
944 If it is not, an error will be returned.
946 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
947 @param[in] ExTokenNumber The PCD token number.
948 @param[in] Value The value to set for the PCD token.
950 @retval EFI_SUCCESS Procedure returned successfully.
951 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
952 being set was incompatible with a call to this function.
953 Use GetSize() to retrieve the size of the target data.
954 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
960 IN CONST EFI_GUID
*Guid
,
961 IN UINTN ExTokenNumber
,
965 return ExSetValueWorker (ExTokenNumber
, Guid
, &Value
, sizeof (Value
));
969 Specifies a function to be called anytime the value of a designated token is changed.
971 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
972 @param[in] TokenNumber The PCD token number.
973 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
975 @retval EFI_SUCCESS The PCD service has successfully established a call event
976 for the CallBackToken requested.
977 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
982 DxeRegisterCallBackOnSet (
983 IN CONST EFI_GUID
*Guid
, OPTIONAL
984 IN UINTN TokenNumber
,
985 IN PCD_PROTOCOL_CALLBACK CallBackFunction
990 if (CallBackFunction
== NULL
) {
991 return EFI_INVALID_PARAMETER
;
994 // Aquire lock to prevent reentrance from TPL_CALLBACK level
996 EfiAcquireLock (&mPcdDatabaseLock
);
998 Status
= DxeRegisterCallBackWorker (TokenNumber
, Guid
, CallBackFunction
);
1000 EfiReleaseLock (&mPcdDatabaseLock
);
1006 Cancels a previously set callback function for a particular PCD token number.
1008 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1009 @param[in] TokenNumber The PCD token number.
1010 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
1012 @retval EFI_SUCCESS The PCD service has successfully established a call event
1013 for the CallBackToken requested.
1014 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
1019 DxeUnRegisterCallBackOnSet (
1020 IN CONST EFI_GUID
*Guid
, OPTIONAL
1021 IN UINTN TokenNumber
,
1022 IN PCD_PROTOCOL_CALLBACK CallBackFunction
1027 if (CallBackFunction
== NULL
) {
1028 return EFI_INVALID_PARAMETER
;
1032 // Aquire lock to prevent reentrance from TPL_CALLBACK level
1034 EfiAcquireLock (&mPcdDatabaseLock
);
1036 Status
= DxeUnRegisterCallBackWorker (TokenNumber
, Guid
, CallBackFunction
);
1038 EfiReleaseLock (&mPcdDatabaseLock
);
1044 Retrieves the next valid token number in a given namespace.
1046 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1047 and one cannot a priori know what token numbers are valid in the database.
1049 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1050 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1051 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1052 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1053 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1054 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1055 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1056 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1059 @param[in] Guid The 128-bit unique value that designates the namespace from which to retrieve the next token.
1060 This is an optional parameter that may be NULL. If this parameter is NULL, then a request is
1061 being made to retrieve tokens from the default token space.
1062 @param[in, out] TokenNumber
1063 A pointer to the PCD token number to use to find the subsequent token number.
1065 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1066 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1071 DxePcdGetNextToken (
1072 IN CONST EFI_GUID
*Guid
, OPTIONAL
1073 IN OUT UINTN
*TokenNumber
1077 BOOLEAN PeiExMapTableEmpty
;
1078 BOOLEAN DxeExMapTableEmpty
;
1080 Status
= EFI_NOT_FOUND
;
1081 PeiExMapTableEmpty
= mPeiExMapTableEmpty
;
1082 DxeExMapTableEmpty
= mDxeExMapTableEmpty
;
1085 // Scan the local token space
1088 // EBC compiler is very choosy. It may report warning about comparison
1089 // between UINTN and 0 . So we add 1 in each size of the
1091 if (((*TokenNumber
+ 1 > mPeiNexTokenCount
+ 1) && (*TokenNumber
+ 1 <= mPeiLocalTokenCount
+ 1)) ||
1092 ((*TokenNumber
+ 1 > (mPeiLocalTokenCount
+ mDxeNexTokenCount
+ 1)))) {
1093 return EFI_NOT_FOUND
;
1097 if ((*TokenNumber
+ 1 > mPeiNexTokenCount
+ 1) &&
1098 (*TokenNumber
+ 1 <= mPeiLocalTokenCount
+ 1)) {
1100 // The first Non-Ex type Token Number for DXE PCD
1101 // database is mPeiLocalTokenCount + 1
1103 if (mDxeNexTokenCount
> 0) {
1104 *TokenNumber
= mPeiLocalTokenCount
+ 1;
1106 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1107 return EFI_NOT_FOUND
;
1109 } else if (*TokenNumber
+ 1 > mDxeNexTokenCount
+ mPeiLocalTokenCount
+ 1) {
1110 *TokenNumber
= PCD_INVALID_TOKEN_NUMBER
;
1111 return EFI_NOT_FOUND
;
1116 if (PeiExMapTableEmpty
&& DxeExMapTableEmpty
) {
1117 return EFI_NOT_FOUND
;
1120 if (!PeiExMapTableEmpty
) {
1121 Status
= ExGetNextTokeNumber (
1124 (EFI_GUID
*)((UINT8
*)mPcdDatabase
.PeiDb
+ mPcdDatabase
.PeiDb
->GuidTableOffset
),
1126 (DYNAMICEX_MAPPING
*)((UINT8
*) mPcdDatabase
.PeiDb
+ mPcdDatabase
.PeiDb
->ExMapTableOffset
),
1127 mPeiExMapppingTableSize
1131 if (Status
== EFI_SUCCESS
) {
1135 if (!DxeExMapTableEmpty
) {
1136 Status
= ExGetNextTokeNumber (
1139 (EFI_GUID
*)((UINT8
*)mPcdDatabase
.DxeDb
+ mPcdDatabase
.DxeDb
->GuidTableOffset
),
1141 (DYNAMICEX_MAPPING
*)((UINT8
*) mPcdDatabase
.DxeDb
+ mPcdDatabase
.DxeDb
->ExMapTableOffset
),
1142 mDxeExMapppingTableSize
1150 Get all token space guid table which is different with given token space guid.
1152 @param ExMapTableSize The size of ExMapTable in item
1153 @param ExMapTable Token space guid table that want to be scaned.
1154 @param GuidTable Guid table
1156 @return all token space guid table which is different with given token space guid.
1160 GetDistinctTokenSpace (
1161 IN OUT UINTN
*ExMapTableSize
,
1162 IN DYNAMICEX_MAPPING
*ExMapTable
,
1163 IN EFI_GUID
*GuidTable
1166 EFI_GUID
**DistinctTokenSpace
;
1173 DistinctTokenSpace
= AllocateZeroPool (*ExMapTableSize
* sizeof (EFI_GUID
*));
1174 ASSERT (DistinctTokenSpace
!= NULL
);
1177 OldGuidIndex
= ExMapTable
[0].ExGuidIndex
;
1178 DistinctTokenSpace
[TsIdx
] = &GuidTable
[OldGuidIndex
];
1179 for (Idx
= 1; Idx
< *ExMapTableSize
; Idx
++) {
1181 OldGuidIndex
= ExMapTable
[Idx
].ExGuidIndex
;
1182 for (TempTsIdx
= 0; TempTsIdx
<= TsIdx
; TempTsIdx
++) {
1183 if (&GuidTable
[OldGuidIndex
] == DistinctTokenSpace
[TempTsIdx
]) {
1185 // Have recorded this GUID.
1192 DistinctTokenSpace
[++TsIdx
] = &GuidTable
[OldGuidIndex
];
1197 // The total number of Distinct Token Space
1198 // is TsIdx + 1 because we use TsIdx as a index
1199 // to the DistinctTokenSpace[]
1201 *ExMapTableSize
= TsIdx
+ 1;
1202 return DistinctTokenSpace
;
1207 Retrieves the next valid PCD token namespace for a given namespace.
1209 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1210 token namespaces on a platform.
1212 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1213 namespace from which the search will start. On output, it designates the next valid
1214 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1215 space of the current platform is returned. If the search cannot locate the next valid
1216 token namespace, an error is returned and the value of *Guid is undefined.
1218 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1219 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1224 DxePcdGetNextTokenSpace (
1225 IN OUT CONST EFI_GUID
**Guid
1231 UINTN PeiTokenSpaceTableSize
;
1232 UINTN DxeTokenSpaceTableSize
;
1233 EFI_GUID
**PeiTokenSpaceTable
;
1234 EFI_GUID
**DxeTokenSpaceTable
;
1236 BOOLEAN PeiExMapTableEmpty
;
1237 BOOLEAN DxeExMapTableEmpty
;
1239 ASSERT (Guid
!= NULL
);
1241 PeiExMapTableEmpty
= mPeiExMapTableEmpty
;
1242 DxeExMapTableEmpty
= mDxeExMapTableEmpty
;
1244 if (PeiExMapTableEmpty
&& DxeExMapTableEmpty
) {
1245 return EFI_NOT_FOUND
;
1248 if (TmpTokenSpaceBuffer
[0] == NULL
) {
1249 PeiTokenSpaceTableSize
= 0;
1251 if (!PeiExMapTableEmpty
) {
1252 PeiTokenSpaceTableSize
= mPeiExMapppingTableSize
/ sizeof(DYNAMICEX_MAPPING
);
1253 PeiTokenSpaceTable
= GetDistinctTokenSpace (&PeiTokenSpaceTableSize
,
1254 (DYNAMICEX_MAPPING
*)((UINT8
*)mPcdDatabase
.PeiDb
+ mPcdDatabase
.PeiDb
->ExMapTableOffset
),
1255 (EFI_GUID
*)((UINT8
*)mPcdDatabase
.PeiDb
+ mPcdDatabase
.PeiDb
->GuidTableOffset
)
1257 CopyMem (TmpTokenSpaceBuffer
, PeiTokenSpaceTable
, sizeof (EFI_GUID
*) * PeiTokenSpaceTableSize
);
1258 FreePool (PeiTokenSpaceTable
);
1261 if (!DxeExMapTableEmpty
) {
1262 DxeTokenSpaceTableSize
= mDxeExMapppingTableSize
/ sizeof(DYNAMICEX_MAPPING
);
1263 DxeTokenSpaceTable
= GetDistinctTokenSpace (&DxeTokenSpaceTableSize
,
1264 (DYNAMICEX_MAPPING
*)((UINT8
*)mPcdDatabase
.DxeDb
+ mPcdDatabase
.DxeDb
->ExMapTableOffset
),
1265 (EFI_GUID
*)((UINT8
*)mPcdDatabase
.DxeDb
+ mPcdDatabase
.DxeDb
->GuidTableOffset
)
1269 // Make sure EFI_GUID in DxeTokenSpaceTable does not exist in PeiTokenSpaceTable
1271 for (Idx2
= 0, Idx3
= PeiTokenSpaceTableSize
; Idx2
< DxeTokenSpaceTableSize
; Idx2
++) {
1273 for (Idx
= 0; Idx
< PeiTokenSpaceTableSize
; Idx
++) {
1274 if (CompareGuid (TmpTokenSpaceBuffer
[Idx
], DxeTokenSpaceTable
[Idx2
])) {
1280 TmpTokenSpaceBuffer
[Idx3
++] = DxeTokenSpaceTable
[Idx2
];
1284 TmpTokenSpaceBufferCount
= Idx3
;
1285 FreePool (DxeTokenSpaceTable
);
1289 if (*Guid
== NULL
) {
1290 *Guid
= TmpTokenSpaceBuffer
[0];
1294 for (Idx
= 0; Idx
< TmpTokenSpaceBufferCount
; Idx
++) {
1295 if (CompareGuid (*Guid
, TmpTokenSpaceBuffer
[Idx
])) {
1296 if (Idx
== TmpTokenSpaceBufferCount
- 1) {
1298 // It has been the last token namespace.
1301 return EFI_NOT_FOUND
;
1304 *Guid
= TmpTokenSpaceBuffer
[Idx
];
1310 return EFI_NOT_FOUND
;