2 Private functions used by PCD DXE driver.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _PCD_DXE_SERVICE_H_
10 #define _PCD_DXE_SERVICE_H_
13 #include <Guid/PcdDataBaseHobGuid.h>
14 #include <Guid/PcdDataBaseSignatureGuid.h>
15 #include <Protocol/Pcd.h>
16 #include <Protocol/PiPcd.h>
17 #include <Protocol/PcdInfo.h>
18 #include <Protocol/PiPcdInfo.h>
19 #include <Protocol/VarCheck.h>
20 #include <Protocol/VariableLock.h>
21 #include <Library/BaseLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiLib.h>
24 #include <Library/UefiDriverEntryPoint.h>
25 #include <Library/PcdLib.h>
26 #include <Library/HobLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/UefiRuntimeServicesTableLib.h>
33 // Please make sure the PCD Serivce DXE Version is consistent with
34 // the version of the generated DXE PCD Database by build tool.
36 #define PCD_SERVICE_DXE_VERSION 7
39 // PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
41 #if (PCD_SERVICE_DXE_VERSION != PCD_DXE_SERVICE_DRIVER_VERSION)
42 #error "Please make sure the version of PCD DXE Service and the generated PCD DXE Database match."
45 extern UINTN mVpdBaseAddress
;
48 Retrieve additional information associated with a PCD token in the default token space.
50 This includes information such as the type of value the TokenNumber is associated with as well as possible
51 human readable name that is associated with the token.
53 @param[in] TokenNumber The PCD token number.
54 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
55 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
57 @retval EFI_SUCCESS The PCD information was returned successfully.
58 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
62 DxeGetPcdInfoGetInfo (
64 OUT EFI_PCD_INFO
*PcdInfo
68 Retrieve additional information associated with a PCD token.
70 This includes information such as the type of value the TokenNumber is associated with as well as possible
71 human readable name that is associated with the token.
73 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
74 @param[in] TokenNumber The PCD token number.
75 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
76 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
78 @retval EFI_SUCCESS The PCD information was returned successfully.
79 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
83 DxeGetPcdInfoGetInfoEx (
84 IN CONST EFI_GUID
*Guid
,
86 OUT EFI_PCD_INFO
*PcdInfo
90 Retrieve the currently set SKU Id.
92 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
93 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
103 // Protocol Interface function declaration.
107 Sets the SKU value for subsequent calls to set or get PCD token values.
109 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
110 SetSku() is normally called only once by the system.
112 For each item (token), the database can hold a single value that applies to all SKUs,
113 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
114 SKU-specific values are called SKU enabled.
116 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
117 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
118 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
119 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
120 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
121 set for that Id, the results are unpredictable.
123 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
124 set values associated with a PCD token.
134 Retrieves an 8-bit value for a given PCD token.
136 Retrieves the current byte-sized value for a PCD token number.
137 If the TokenNumber is invalid, the results are unpredictable.
139 @param[in] TokenNumber The PCD token number.
141 @return The UINT8 value.
151 Retrieves an 16-bit value for a given PCD token.
153 Retrieves the current 16-bits value for a PCD token number.
154 If the TokenNumber is invalid, the results are unpredictable.
156 @param[in] TokenNumber The PCD token number.
158 @return The UINT16 value.
168 Retrieves an 32-bit value for a given PCD token.
170 Retrieves the current 32-bits value for a PCD token number.
171 If the TokenNumber is invalid, the results are unpredictable.
173 @param[in] TokenNumber The PCD token number.
175 @return The UINT32 value.
185 Retrieves an 64-bit value for a given PCD token.
187 Retrieves the current 64-bits value for a PCD token number.
188 If the TokenNumber is invalid, the results are unpredictable.
190 @param[in] TokenNumber The PCD token number.
192 @return The UINT64 value.
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 retrieved.
221 Retrieves a Boolean value for a given PCD token.
223 Retrieves the current boolean value for a PCD token number.
224 Do not make any assumptions about the alignment of the pointer that
225 is returned by this function call. If the TokenNumber is invalid,
226 the results are unpredictable.
228 @param[in] TokenNumber The PCD token number.
230 @return The Boolean value.
240 Retrieves the size of the value for a given PCD token.
242 Retrieves the current size of a particular PCD token.
243 If the TokenNumber is invalid, the results are unpredictable.
245 @param[in] TokenNumber The PCD token number.
247 @return The size of the value for the PCD token.
257 Retrieves an 8-bit value for a given PCD token.
259 Retrieves the 8-bit value of a particular PCD token.
260 If the TokenNumber is invalid or the token space
261 specified by Guid does not exist, the results are
264 @param[in] Guid The token space for the token number.
265 @param[in] TokenNumber The PCD token number.
267 @return The size 8-bit value for the PCD token.
273 IN CONST EFI_GUID
*Guid
,
278 Retrieves an 16-bit value for a given PCD token.
280 Retrieves the 16-bit value of a particular PCD token.
281 If the TokenNumber is invalid or the token space
282 specified by Guid does not exist, the results are
285 @param[in] Guid The token space for the token number.
286 @param[in] TokenNumber The PCD token number.
288 @return The size 16-bit value for the PCD token.
294 IN CONST EFI_GUID
*Guid
,
299 Retrieves an 32-bit value for a given PCD token.
301 Retrieves the 32-bit value of a particular PCD token.
302 If the TokenNumber is invalid or the token space
303 specified by Guid does not exist, the results are
306 @param[in] Guid The token space for the token number.
307 @param[in] TokenNumber The PCD token number.
309 @return The size 32-bit value for the PCD token.
315 IN CONST EFI_GUID
*Guid
,
320 Retrieves an 64-bit value for a given PCD token.
322 Retrieves the 64-bit value of a particular PCD token.
323 If the TokenNumber is invalid or the token space
324 specified by Guid does not exist, the results are
327 @param[in] Guid The token space for the token number.
328 @param[in] TokenNumber The PCD token number.
330 @return The size 64-bit value for the PCD token.
336 IN CONST EFI_GUID
*Guid
,
341 Retrieves a pointer to a value for a given PCD token.
343 Retrieves the current pointer to the buffer for a PCD token number.
344 Do not make any assumptions about the alignment of the pointer that
345 is returned by this function call. If the TokenNumber is invalid,
346 the results are unpredictable.
348 @param[in] Guid The token space for the token number.
349 @param[in] TokenNumber The PCD token number.
351 @return The pointer to the buffer to be retrieved.
357 IN CONST EFI_GUID
*Guid
,
362 Retrieves an Boolean value for a given PCD token.
364 Retrieves the Boolean value of a particular PCD token.
365 If the TokenNumber is invalid or the token space
366 specified by Guid does not exist, the results are
369 @param[in] Guid The token space for the token number.
370 @param[in] TokenNumber The PCD token number.
372 @return The size Boolean value for the PCD token.
378 IN CONST EFI_GUID
*Guid
,
383 Retrieves the size of the value for a given PCD token.
385 Retrieves the current size of a particular PCD token.
386 If the TokenNumber is invalid, the results are unpredictable.
388 @param[in] Guid The token space for the token number.
389 @param[in] TokenNumber The PCD token number.
391 @return The size of the value for the PCD token.
397 IN CONST EFI_GUID
*Guid
,
402 Sets an 8-bit value for a given PCD token.
404 When the PCD service sets a value, it will check to ensure that the
405 size of the value being set is compatible with the Token's existing definition.
406 If it is not, an error will be returned.
408 @param[in] TokenNumber The PCD token number.
409 @param[in] Value The value to set for the PCD token.
411 @retval EFI_SUCCESS Procedure returned successfully.
412 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
413 being set was incompatible with a call to this function.
414 Use GetSize() to retrieve the size of the target data.
415 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
421 IN UINTN TokenNumber
,
426 Sets an 16-bit value for a given PCD token.
428 When the PCD service sets a value, it will check to ensure that the
429 size of the value being set is compatible with the Token's existing definition.
430 If it is not, an error will be returned.
432 @param[in] TokenNumber The PCD token number.
433 @param[in] Value The value to set for the PCD token.
435 @retval EFI_SUCCESS Procedure returned successfully.
436 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
437 being set was incompatible with a call to this function.
438 Use GetSize() to retrieve the size of the target data.
439 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
445 IN UINTN TokenNumber
,
450 Sets an 32-bit value for a given PCD token.
452 When the PCD service sets a value, it will check to ensure that the
453 size of the value being set is compatible with the Token's existing definition.
454 If it is not, an error will be returned.
456 @param[in] TokenNumber The PCD token number.
457 @param[in] Value The value to set for the PCD token.
459 @retval EFI_SUCCESS Procedure returned successfully.
460 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
461 being set was incompatible with a call to this function.
462 Use GetSize() to retrieve the size of the target data.
463 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
469 IN UINTN TokenNumber
,
474 Sets an 64-bit value for a given PCD token.
476 When the PCD service sets a value, it will check to ensure that the
477 size of the value being set is compatible with the Token's existing definition.
478 If it is not, an error will be returned.
480 @param[in] TokenNumber The PCD token number.
481 @param[in] Value The value to set for the PCD token.
483 @retval EFI_SUCCESS Procedure returned successfully.
484 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
485 being set was incompatible with a call to this function.
486 Use GetSize() to retrieve the size of the target data.
487 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
493 IN UINTN TokenNumber
,
498 Sets a value of a specified size for a given PCD token.
500 When the PCD service sets a value, it will check to ensure that the
501 size of the value being set is compatible with the Token's existing definition.
502 If it is not, an error will be returned.
504 @param[in] TokenNumber The PCD token number.
505 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
506 On input, if the SizeOfValue is greater than the maximum size supported
507 for this TokenNumber then the output value of SizeOfValue will reflect
508 the maximum size supported for this TokenNumber.
509 @param[in] Buffer The buffer to set for the PCD token.
511 @retval EFI_SUCCESS Procedure returned successfully.
512 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
513 being set was incompatible with a call to this function.
514 Use GetSize() to retrieve the size of the target data.
515 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
521 IN UINTN TokenNumber
,
522 IN OUT UINTN
*SizeOfBuffer
,
527 Sets an Boolean value for a given PCD token.
529 When the PCD service sets a value, it will check to ensure that the
530 size of the value being set is compatible with the Token's existing definition.
531 If it is not, an error will be returned.
533 @param[in] TokenNumber The PCD token number.
534 @param[in] Value The value to set for the PCD token.
536 @retval EFI_SUCCESS Procedure returned successfully.
537 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
538 being set was incompatible with a call to this function.
539 Use GetSize() to retrieve the size of the target data.
540 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
546 IN UINTN TokenNumber
,
551 Sets an 8-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] Guid The 128-bit unique value that designates the namespace from which to extract the value.
558 @param[in] TokenNumber The PCD token number.
559 @param[in] Value The value to set for the PCD token.
561 @retval EFI_SUCCESS Procedure returned successfully.
562 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
563 being set was incompatible with a call to this function.
564 Use GetSize() to retrieve the size of the target data.
565 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
571 IN CONST EFI_GUID
*Guid
,
572 IN UINTN TokenNumber
,
577 Sets an 16-bit value for a given PCD token.
579 When the PCD service sets a value, it will check to ensure that the
580 size of the value being set is compatible with the Token's existing definition.
581 If it is not, an error will be returned.
583 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
584 @param[in] TokenNumber The PCD token number.
585 @param[in] Value The value to set for the PCD token.
587 @retval EFI_SUCCESS Procedure returned successfully.
588 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
589 being set was incompatible with a call to this function.
590 Use GetSize() to retrieve the size of the target data.
591 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
597 IN CONST EFI_GUID
*Guid
,
598 IN UINTN TokenNumber
,
603 Sets an 32-bit value for a given PCD token.
605 When the PCD service sets a value, it will check to ensure that the
606 size of the value being set is compatible with the Token's existing definition.
607 If it is not, an error will be returned.
609 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
610 @param[in] TokenNumber The PCD token number.
611 @param[in] Value The value to set for the PCD token.
613 @retval EFI_SUCCESS Procedure returned successfully.
614 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
615 being set was incompatible with a call to this function.
616 Use GetSize() to retrieve the size of the target data.
617 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
623 IN CONST EFI_GUID
*Guid
,
624 IN UINTN TokenNumber
,
629 Sets an 64-bit value for a given PCD token.
631 When the PCD service sets a value, it will check to ensure that the
632 size of the value being set is compatible with the Token's existing definition.
633 If it is not, an error will be returned.
635 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
636 @param[in] TokenNumber The PCD token number.
637 @param[in] Value The value to set for the PCD token.
639 @retval EFI_SUCCESS Procedure returned successfully.
640 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
641 being set was incompatible with a call to this function.
642 Use GetSize() to retrieve the size of the target data.
643 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
649 IN CONST EFI_GUID
*Guid
,
650 IN UINTN TokenNumber
,
655 Sets a value of a specified size for a given PCD token.
657 When the PCD service sets a value, it will check to ensure that the
658 size of the value being set is compatible with the Token's existing definition.
659 If it is not, an error will be returned.
661 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
662 @param[in] TokenNumber The PCD token number.
663 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
664 On input, if the SizeOfValue is greater than the maximum size supported
665 for this TokenNumber then the output value of SizeOfValue will reflect
666 the maximum size supported for this TokenNumber.
667 @param[in] Buffer The buffer to set for the PCD token.
669 @retval EFI_SUCCESS Procedure returned successfully.
670 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
671 being set was incompatible with a call to this function.
672 Use GetSize() to retrieve the size of the target data.
673 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
679 IN CONST EFI_GUID
*Guid
,
680 IN UINTN TokenNumber
,
681 IN OUT UINTN
*SizeOfBuffer
,
686 Sets an Boolean value for a given PCD token.
688 When the PCD service sets a value, it will check to ensure that the
689 size of the value being set is compatible with the Token's existing definition.
690 If it is not, an error will be returned.
692 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
693 @param[in] TokenNumber The PCD token number.
694 @param[in] Value The value to set for the PCD token.
696 @retval EFI_SUCCESS Procedure returned successfully.
697 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
698 being set was incompatible with a call to this function.
699 Use GetSize() to retrieve the size of the target data.
700 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
706 IN CONST EFI_GUID
*Guid
,
707 IN UINTN TokenNumber
,
712 Specifies a function to be called anytime the value of a designated token is changed.
714 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
715 @param[in] TokenNumber The PCD token number.
716 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
718 @retval EFI_SUCCESS The PCD service has successfully established a call event
719 for the CallBackToken requested.
720 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
725 DxeRegisterCallBackOnSet (
726 IN CONST EFI_GUID
*Guid OPTIONAL
,
727 IN UINTN TokenNumber
,
728 IN PCD_PROTOCOL_CALLBACK CallBackFunction
732 Cancels a previously set callback function for a particular PCD token number.
734 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
735 @param[in] TokenNumber The PCD token number.
736 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
738 @retval EFI_SUCCESS The PCD service has successfully established a call event
739 for the CallBackToken requested.
740 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
745 DxeUnRegisterCallBackOnSet (
746 IN CONST EFI_GUID
*Guid OPTIONAL
,
747 IN UINTN TokenNumber
,
748 IN PCD_PROTOCOL_CALLBACK CallBackFunction
752 Retrieves the next valid token number in a given namespace.
754 This is useful since the PCD infrastructure contains a sparse list of token numbers,
755 and one cannot a priori know what token numbers are valid in the database.
757 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
758 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
759 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
760 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
761 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
762 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
763 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
764 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
767 @param[in] Guid The 128-bit unique value that designates the namespace from which to retrieve the next token.
768 This is an optional parameter that may be NULL. If this parameter is NULL, then a request is
769 being made to retrieve tokens from the default token space.
770 @param[in, out] TokenNumber
771 A pointer to the PCD token number to use to find the subsequent token number.
773 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
774 is already the last valid token number in the PCD database.
775 In the later case, *TokenNumber is updated with the value of 0.
776 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
782 IN CONST EFI_GUID
*Guid OPTIONAL
,
783 IN OUT UINTN
*TokenNumber
787 Get next token space in PCD database according to given token space guid.
789 @param Guid Given token space guid. If NULL, then Guid will be set to
790 the first PCD token space in PCD database, If not NULL, then
791 Guid will be set to next PCD token space.
793 @retval EFI_NOT_FOUND If PCD database has no token space table or can not find given
794 token space in PCD database.
795 @retval EFI_SUCCESS Success to get next token space guid.
799 DxePcdGetNextTokenSpace (
800 IN OUT CONST EFI_GUID
**Guid
805 PCD_PROTOCOL_CALLBACK CallbackFn
;
808 #define CR_FNENTRY_FROM_LISTNODE(Record, Type, Field) BASE_CR(Record, Type, Field)
811 // Internal Functions
815 Retrieve additional information associated with a PCD token.
817 This includes information such as the type of value the TokenNumber is associated with as well as possible
818 human readable name that is associated with the token.
820 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
821 @param[in] TokenNumber The PCD token number.
822 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
823 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
825 @retval EFI_SUCCESS The PCD information was returned successfully
826 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
830 IN CONST EFI_GUID
*Guid
,
831 IN UINTN TokenNumber
,
832 OUT EFI_PCD_INFO
*PcdInfo
836 Wrapper function for setting non-pointer type value for a PCD entry.
838 @param TokenNumber Pcd token number autogenerated by build tools.
839 @param Data Value want to be set for PCD entry
840 @param Size Size of value.
842 @return status of SetWorker.
847 IN UINTN TokenNumber
,
853 Set value for an PCD entry
855 @param TokenNumber Pcd token number autogenerated by build tools.
856 @param Data Value want to be set for PCD entry
857 @param Size Size of value.
858 @param PtrType If TRUE, the type of PCD entry's value is Pointer.
859 If False, the type of PCD entry's value is not Pointer.
861 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.
862 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.
863 @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database.
864 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in
865 range of UINT8, UINT16, UINT32, UINT64
866 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.
870 IN UINTN TokenNumber
,
877 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.
879 @param ExTokenNumber Token number for dynamic-ex PCD.
880 @param Guid Token space guid for dynamic-ex PCD.
881 @param Data Value want to be set.
882 @param SetSize The size of value.
884 @return status of ExSetWorker().
889 IN UINTN ExTokenNumber
,
890 IN CONST EFI_GUID
*Guid
,
896 Set value for a dynamic PCD entry.
898 This routine find the local token number according to dynamic-ex PCD's token
899 space guid and token number firstly, and invoke callback function if this PCD
900 entry registered callback function. Finally, invoken general SetWorker to set
903 @param ExTokenNumber Dynamic-ex PCD token number.
904 @param Guid Token space guid for dynamic-ex PCD.
905 @param Data PCD value want to be set
906 @param SetSize Size of value.
907 @param PtrType If TRUE, this PCD entry is pointer type.
908 If FALSE, this PCD entry is not pointer type.
910 @return status of SetWorker().
915 IN UINTN ExTokenNumber
,
916 IN CONST EFI_GUID
*Guid
,
923 Get the PCD entry pointer in PCD database.
925 This routine will visit PCD database to find the PCD entry according to given
926 token number. The given token number is autogened by build tools and it will be
927 translated to local token number. Local token number contains PCD's type and
928 offset of PCD entry in PCD database.
930 @param TokenNumber Token's number, it is autogened by build tools
931 @param GetSize The size of token's value
933 @return PCD entry pointer in PCD database
938 IN UINTN TokenNumber
,
943 Wrapper function for get PCD value for dynamic-ex PCD.
945 @param Guid Token space guid for dynamic-ex PCD.
946 @param ExTokenNumber Token number for dynamic-ex PCD.
947 @param GetSize The size of dynamic-ex PCD value.
949 @return PCD entry in PCD database.
954 IN CONST EFI_GUID
*Guid
,
955 IN UINTN ExTokenNumber
,
960 Get Variable which contains HII type PCD entry.
962 @param VariableGuid Variable's guid
963 @param VariableName Variable's unicode name string
964 @param VariableData Variable's data pointer,
965 @param VariableSize Variable's size.
967 @return the status of gRT->GetVariable
971 IN EFI_GUID
*VariableGuid
,
972 IN UINT16
*VariableName
,
973 OUT UINT8
**VariableData
,
974 OUT UINTN
*VariableSize
978 Set value for HII-type PCD.
980 A HII-type PCD's value is stored in a variable. Setting/Getting the value of
981 HII-type PCD is to visit this variable.
983 @param VariableGuid Guid of variable which stored value of a HII-type PCD.
984 @param VariableName Unicode name of variable which stored value of a HII-type PCD.
985 @param SetAttributes Attributes bitmask to set for the variable.
986 @param Data Value want to be set.
987 @param DataSize Size of value
988 @param Offset Value offset of HII-type PCD in variable.
990 @return status of GetVariable()/SetVariable().
995 IN EFI_GUID
*VariableGuid
,
996 IN UINT16
*VariableName
,
997 IN UINT32 SetAttributes
,
1004 Register the callback function for a PCD entry.
1006 This routine will register a callback function to a PCD entry by given token number
1007 and token space guid.
1009 @param TokenNumber PCD token's number, it is autogened by build tools.
1010 @param Guid PCD token space's guid,
1011 if not NULL, this PCD is dynamicEx type PCD.
1012 @param CallBackFunction Callback function pointer
1014 @return EFI_SUCCESS Always success for registering callback function.
1018 DxeRegisterCallBackWorker (
1019 IN UINTN TokenNumber
,
1020 IN CONST EFI_GUID
*Guid OPTIONAL
,
1021 IN PCD_PROTOCOL_CALLBACK CallBackFunction
1025 UnRegister the callback function for a PCD entry.
1027 This routine will unregister a callback function to a PCD entry by given token number
1028 and token space guid.
1030 @param TokenNumber PCD token's number, it is autogened by build tools.
1031 @param Guid PCD token space's guid.
1032 if not NULL, this PCD is dynamicEx type PCD.
1033 @param CallBackFunction Callback function pointer
1035 @retval EFI_SUCCESS Callback function is success to be unregister.
1036 @retval EFI_INVALID_PARAMETER Can not find the PCD entry by given token number.
1039 DxeUnRegisterCallBackWorker (
1040 IN UINTN TokenNumber
,
1041 IN CONST EFI_GUID
*Guid OPTIONAL
,
1042 IN PCD_PROTOCOL_CALLBACK CallBackFunction
1046 Initialize the PCD database in DXE phase.
1048 PCD database in DXE phase also contains PCD database in PEI phase which is copied
1053 BuildPcdDxeDataBase (
1058 Get Token Number according to dynamic-ex PCD's {token space guid:token number}
1060 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
1061 in DEC file. PCD database maintain a mapping table that translate pair of {token
1062 space guid: token number} to Token Number.
1064 @param Guid Token space guid for dynamic-ex PCD entry.
1065 @param ExTokenNumber Dynamic-ex PCD token number.
1067 @return Token Number for dynamic-ex PCD.
1071 GetExPcdTokenNumber (
1072 IN CONST EFI_GUID
*Guid
,
1073 IN UINT32 ExTokenNumber
1077 Get next token number in given token space.
1079 This routine is used for dynamicEx type PCD. It will firstly scan token space
1080 table to get token space according to given token space guid. Then scan given
1081 token number in found token space, if found, then return next token number in
1084 @param Guid Token space guid. Next token number will be scaned in
1086 @param TokenNumber Token number.
1087 If PCD_INVALID_TOKEN_NUMBER, return first token number in
1089 If not PCD_INVALID_TOKEN_NUMBER, return next token number
1090 in token space table.
1091 @param GuidTable Token space guid table. It will be used for scan token space
1092 by given token space guid.
1093 @param SizeOfGuidTable The size of guid table.
1094 @param ExMapTable DynamicEx token number mapping table.
1095 @param SizeOfExMapTable The size of dynamicEx token number mapping table.
1097 @retval EFI_NOT_FOUND Can not given token space or token number.
1098 @retval EFI_SUCCESS Success to get next token number.
1102 ExGetNextTokeNumber (
1103 IN CONST EFI_GUID
*Guid
,
1104 IN OUT UINTN
*TokenNumber
,
1105 IN EFI_GUID
*GuidTable
,
1106 IN UINTN SizeOfGuidTable
,
1107 IN DYNAMICEX_MAPPING
*ExMapTable
,
1108 IN UINTN SizeOfExMapTable
1112 Get size of POINTER type PCD value.
1114 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1115 @param MaxSize Maximum size of POINTER type PCD value.
1117 @return size of POINTER type PCD value.
1122 IN UINTN LocalTokenNumberTableIdx
,
1127 Set size of POINTER type PCD value. The size should not exceed the maximum size
1130 @param LocalTokenNumberTableIdx Index of local token number in local token number table.
1131 @param CurrentSize Size of POINTER type PCD value.
1133 @retval TRUE Success to set size of PCD value.
1134 @retval FALSE Fail to set size of PCD value.
1138 IN UINTN LocalTokenNumberTableIdx
,
1139 IN OUT UINTN
*CurrentSize
1143 VariableLockProtocol callback
1144 to lock the variables referenced by DynamicHii PCDs with RO property set in *.dsc.
1146 @param[in] Event Event whose notification function is being invoked.
1147 @param[in] Context Pointer to the notification function's context.
1152 VariableLockCallBack (
1158 Update PCD database base on current SkuId
1160 @param SkuId Current SkuId
1161 @param IsPeiDb Whether to update PEI PCD database.
1163 @retval EFI_SUCCESS Update PCD database successfully.
1164 @retval EFI_NOT_FOUND Not found PCD database for current SkuId.
1172 extern PCD_DATABASE mPcdDatabase
;
1174 extern UINT32 mPcdTotalTokenCount
;
1175 extern UINT32 mPeiLocalTokenCount
;
1176 extern UINT32 mDxeLocalTokenCount
;
1177 extern UINT32 mPeiNexTokenCount
;
1178 extern UINT32 mDxeNexTokenCount
;
1179 extern UINT32 mPeiExMapppingTableSize
;
1180 extern UINT32 mDxeExMapppingTableSize
;
1181 extern UINT32 mPeiGuidTableSize
;
1182 extern UINT32 mDxeGuidTableSize
;
1184 extern BOOLEAN mPeiExMapTableEmpty
;
1185 extern BOOLEAN mDxeExMapTableEmpty
;
1186 extern BOOLEAN mPeiDatabaseEmpty
;
1188 extern EFI_GUID
**TmpTokenSpaceBuffer
;
1189 extern UINTN TmpTokenSpaceBufferCount
;
1191 extern EFI_LOCK mPcdDatabaseLock
;