2 The internal header file declares the private functions used by PeiPcd driver.
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _PEI_PCD_SERVICE_H_
16 #define _PEI_PCD_SERVICE_H_
19 #include <Ppi/ReadOnlyVariable2.h>
21 #include <Guid/PcdDataBaseHobGuid.h>
22 #include <Library/DebugLib.h>
23 #include <Library/PeimEntryPoint.h>
24 #include <Library/BaseLib.h>
25 #include <Library/HobLib.h>
26 #include <Library/PeiServicesLib.h>
27 #include <Library/PcdLib.h>
28 #include <Library/BaseMemoryLib.h>
32 // Please make sure the PCD Serivce PEIM Version is consistent with
33 // the version of PCD Database generation tool
35 #define PCD_SERVICE_PEIM_VERSION 2
38 // PCD_PEI_DATABASE_GENTOOL_VERSION is defined in Autogen.h
39 // and generated by PCD Database generation tool.
41 //#if (PCD_SERVICE_PEIM_VERSION != PCD_PEI_SERVICE_DRIVER_AUTOGEN_VERSION )
42 // #error "Please make sure the version of PCD Service PEIM and PCD PEI Database Generation Tool matches"
46 // PPI Interface Implementation Declaration.
50 Sets the SKU value for subsequent calls to set or get PCD token values.
52 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
53 SetSku() is normally called only once by the system.
55 For each item (token), the database can hold a single value that applies to all SKUs,
56 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
57 SKU-specific values are called SKU enabled.
59 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
60 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
61 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
62 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
63 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
64 set for that Id, the results are unpredictable.
66 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
67 set values associated with a PCD token.
77 Retrieves an 8-bit value for a given PCD token.
79 Retrieves the current byte-sized value for a PCD token number.
80 If the TokenNumber is invalid, the results are unpredictable.
82 @param[in] TokenNumber The PCD token number.
84 @return The UINT8 value.
94 Retrieves an 16-bit value for a given PCD token.
96 Retrieves the current 16-bits value for a PCD token number.
97 If the TokenNumber is invalid, the results are unpredictable.
99 @param[in] TokenNumber The PCD token number.
101 @return The UINT16 value.
111 Retrieves an 32-bit value for a given PCD token.
113 Retrieves the current 32-bits value for a PCD token number.
114 If the TokenNumber is invalid, the results are unpredictable.
116 @param[in] TokenNumber The PCD token number.
118 @return The UINT32 value.
128 Retrieves an 64-bit value for a given PCD token.
130 Retrieves the current 64-bits value for a PCD token number.
131 If the TokenNumber is invalid, the results are unpredictable.
133 @param[in] TokenNumber The PCD token number.
135 @return The UINT64 value.
145 Retrieves a pointer to a value for a given PCD token.
147 Retrieves the current pointer to the buffer for a PCD token number.
148 Do not make any assumptions about the alignment of the pointer that
149 is returned by this function call. If the TokenNumber is invalid,
150 the results are unpredictable.
152 @param[in] TokenNumber The PCD token number.
154 @return The pointer to the buffer to be retrived.
164 Retrieves a Boolean value for a given PCD token.
166 Retrieves the current boolean value for a PCD token number.
167 Do not make any assumptions about the alignment of the pointer that
168 is returned by this function call. If the TokenNumber is invalid,
169 the results are unpredictable.
171 @param[in] TokenNumber The PCD token number.
173 @return The Boolean value.
183 Retrieves the size of the value for a given PCD token.
185 Retrieves the current size of a particular PCD token.
186 If the TokenNumber is invalid, the results are unpredictable.
188 @param[in] TokenNumber The PCD token number.
190 @return The size of the value for the PCD token.
200 Retrieves an 8-bit value for a given PCD token.
202 Retrieves the 8-bit value of a particular PCD token.
203 If the TokenNumber is invalid or the token space
204 specified by Guid does not exist, the results are
207 @param[in] Guid The token space for the token number.
208 @param[in] TokenNumber The PCD token number.
210 @return The size 8-bit value for the PCD token.
216 IN CONST EFI_GUID
*Guid
,
221 Retrieves an 16-bit value for a given PCD token.
223 Retrieves the 16-bit value of a particular PCD token.
224 If the TokenNumber is invalid or the token space
225 specified by Guid does not exist, the results are
228 @param[in] Guid The token space for the token number.
229 @param[in] TokenNumber The PCD token number.
231 @return The size 16-bit value for the PCD token.
237 IN CONST EFI_GUID
*Guid
,
242 Retrieves an 32-bit value for a given PCD token.
244 Retrieves the 32-bit value of a particular PCD token.
245 If the TokenNumber is invalid or the token space
246 specified by Guid does not exist, the results are
249 @param[in] Guid The token space for the token number.
250 @param[in] TokenNumber The PCD token number.
252 @return The size 32-bit value for the PCD token.
258 IN CONST EFI_GUID
*Guid
,
263 Retrieves an 64-bit value for a given PCD token.
265 Retrieves the 64-bit value of a particular PCD token.
266 If the TokenNumber is invalid or the token space
267 specified by Guid does not exist, the results are
270 @param[in] Guid The token space for the token number.
271 @param[in] TokenNumber The PCD token number.
273 @return The size 64-bit value for the PCD token.
279 IN CONST EFI_GUID
*Guid
,
284 Retrieves a pointer to a value for a given PCD token.
286 Retrieves the current pointer to the buffer for a PCD token number.
287 Do not make any assumptions about the alignment of the pointer that
288 is returned by this function call. If the TokenNumber is invalid,
289 the results are unpredictable.
291 @param[in] Guid The token space for the token number.
292 @param[in] TokenNumber The PCD token number.
294 @return The pointer to the buffer to be retrived.
300 IN CONST EFI_GUID
*Guid
,
305 Retrieves an Boolean value for a given PCD token.
307 Retrieves the Boolean value of a particular PCD token.
308 If the TokenNumber is invalid or the token space
309 specified by Guid does not exist, the results are
312 @param[in] Guid The token space for the token number.
313 @param[in] TokenNumber The PCD token number.
315 @return The size Boolean value for the PCD token.
321 IN CONST EFI_GUID
*Guid
,
326 Retrieves the size of the value for a given PCD token.
328 Retrieves the current size of a particular PCD token.
329 If the TokenNumber is invalid, the results are unpredictable.
331 @param[in] Guid The token space for the token number.
332 @param[in] TokenNumber The PCD token number.
334 @return The size of the value for the PCD token.
340 IN CONST EFI_GUID
*Guid
,
345 Sets an 8-bit value for a given PCD token.
347 When the PCD service sets a value, it will check to ensure that the
348 size of the value being set is compatible with the Token's existing definition.
349 If it is not, an error will be returned.
351 @param[in] TokenNumber The PCD token number.
352 @param[in] Value The value to set for the PCD token.
354 @retval EFI_SUCCESS Procedure returned successfully.
355 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
356 being set was incompatible with a call to this function.
357 Use GetSize() to retrieve the size of the target data.
358 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
364 IN UINTN TokenNumber
,
369 Sets an 16-bit value for a given PCD token.
371 When the PCD service sets a value, it will check to ensure that the
372 size of the value being set is compatible with the Token's existing definition.
373 If it is not, an error will be returned.
375 @param[in] TokenNumber The PCD token number.
376 @param[in] Value The value to set for the PCD token.
378 @retval EFI_SUCCESS Procedure returned successfully.
379 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
380 being set was incompatible with a call to this function.
381 Use GetSize() to retrieve the size of the target data.
382 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
388 IN UINTN TokenNumber
,
393 Sets an 32-bit value for a given PCD token.
395 When the PCD service sets a value, it will check to ensure that the
396 size of the value being set is compatible with the Token's existing definition.
397 If it is not, an error will be returned.
399 @param[in] TokenNumber The PCD token number.
400 @param[in] Value The value to set for the PCD token.
402 @retval EFI_SUCCESS Procedure returned successfully.
403 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
404 being set was incompatible with a call to this function.
405 Use GetSize() to retrieve the size of the target data.
406 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
412 IN UINTN TokenNumber
,
417 Sets an 64-bit value for a given PCD token.
419 When the PCD service sets a value, it will check to ensure that the
420 size of the value being set is compatible with the Token's existing definition.
421 If it is not, an error will be returned.
423 @param[in] TokenNumber The PCD token number.
424 @param[in] Value The value to set for the PCD token.
426 @retval EFI_SUCCESS Procedure returned successfully.
427 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
428 being set was incompatible with a call to this function.
429 Use GetSize() to retrieve the size of the target data.
430 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
436 IN UINTN TokenNumber
,
441 Sets a value of a specified size for a given PCD token.
443 When the PCD service sets a value, it will check to ensure that the
444 size of the value being set is compatible with the Token's existing definition.
445 If it is not, an error will be returned.
447 @param[in] TokenNumber The PCD token number.
448 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
449 On input, if the SizeOfValue is greater than the maximum size supported
450 for this TokenNumber then the output value of SizeOfValue will reflect
451 the maximum size supported for this TokenNumber.
452 @param[in] Buffer The buffer to set for the PCD token.
454 @retval EFI_SUCCESS Procedure returned successfully.
455 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
456 being set was incompatible with a call to this function.
457 Use GetSize() to retrieve the size of the target data.
458 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
464 IN UINTN TokenNumber
,
465 IN OUT UINTN
*SizeOfBuffer
,
470 Sets an Boolean 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
,
494 Sets an 8-bit value for a given PCD token.
496 When the PCD service sets a value, it will check to ensure that the
497 size of the value being set is compatible with the Token's existing definition.
498 If it is not, an error will be returned.
500 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
501 @param[in] TokenNumber The PCD token number.
502 @param[in] Value The value to set for the PCD token.
504 @retval EFI_SUCCESS Procedure returned successfully.
505 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
506 being set was incompatible with a call to this function.
507 Use GetSize() to retrieve the size of the target data.
508 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
514 IN CONST EFI_GUID
*Guid
,
515 IN UINTN TokenNumber
,
520 Sets an 16-bit value for a given PCD token.
522 When the PCD service sets a value, it will check to ensure that the
523 size of the value being set is compatible with the Token's existing definition.
524 If it is not, an error will be returned.
526 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
527 @param[in] TokenNumber The PCD token number.
528 @param[in] Value The value to set for the PCD token.
530 @retval EFI_SUCCESS Procedure returned successfully.
531 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
532 being set was incompatible with a call to this function.
533 Use GetSize() to retrieve the size of the target data.
534 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
540 IN CONST EFI_GUID
*Guid
,
541 IN UINTN TokenNumber
,
546 Sets an 32-bit value for a given PCD token.
548 When the PCD service sets a value, it will check to ensure that the
549 size of the value being set is compatible with the Token's existing definition.
550 If it is not, an error will be returned.
552 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
553 @param[in] TokenNumber The PCD token number.
554 @param[in] Value The value to set for the PCD token.
556 @retval EFI_SUCCESS Procedure returned successfully.
557 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
558 being set was incompatible with a call to this function.
559 Use GetSize() to retrieve the size of the target data.
560 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
566 IN CONST EFI_GUID
*Guid
,
567 IN UINTN TokenNumber
,
572 Sets an 64-bit value for a given PCD token.
574 When the PCD service sets a value, it will check to ensure that the
575 size of the value being set is compatible with the Token's existing definition.
576 If it is not, an error will be returned.
578 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
579 @param[in] TokenNumber The PCD token number.
580 @param[in] Value The value to set for the PCD token.
582 @retval EFI_SUCCESS Procedure returned successfully.
583 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
584 being set was incompatible with a call to this function.
585 Use GetSize() to retrieve the size of the target data.
586 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
592 IN CONST EFI_GUID
*Guid
,
593 IN UINTN TokenNumber
,
598 Sets a value of a specified size for a given PCD token.
600 When the PCD service sets a value, it will check to ensure that the
601 size of the value being set is compatible with the Token's existing definition.
602 If it is not, an error will be returned.
604 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
605 @param[in] TokenNumber The PCD token number.
606 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
607 On input, if the SizeOfValue is greater than the maximum size supported
608 for this TokenNumber then the output value of SizeOfValue will reflect
609 the maximum size supported for this TokenNumber.
610 @param[in] Buffer The buffer to set for the PCD token.
612 @retval EFI_SUCCESS Procedure returned successfully.
613 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
614 being set was incompatible with a call to this function.
615 Use GetSize() to retrieve the size of the target data.
616 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
622 IN CONST EFI_GUID
*Guid
,
623 IN UINTN TokenNumber
,
624 IN OUT UINTN
*SizeOfBuffer
,
629 Sets an Boolean 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 Specifies a function to be called anytime the value of a designated token is changed.
657 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
658 @param[in] TokenNumber The PCD token number.
659 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
661 @retval EFI_SUCCESS The PCD service has successfully established a call event
662 for the CallBackToken requested.
663 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
668 PeiRegisterCallBackOnSet (
669 IN CONST EFI_GUID
*Guid
, OPTIONAL
670 IN UINTN TokenNumber
,
671 IN PCD_PPI_CALLBACK CallBackFunction
675 Cancels a previously set callback function for a particular PCD token number.
677 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
678 @param [in] TokenNumber The PCD token number.
679 @param [in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
681 @retval EFI_SUCCESS The PCD service has successfully established a call event
682 for the CallBackToken requested.
683 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
688 PcdUnRegisterCallBackOnSet (
689 IN CONST EFI_GUID
*Guid
, OPTIONAL
690 IN UINTN TokenNumber
,
691 IN PCD_PPI_CALLBACK CallBackFunction
695 Retrieves the next valid PCD token for a given namespace.
697 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
698 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
699 If the input token namespace or token number does not exist on the platform,
700 an error is returned and the value of *TokenNumber is undefined. To retrieve the "first" token,
701 have the pointer reference a TokenNumber value of 0. If the input token number is 0 and
702 there is no valid token number for this token namespace, *TokenNumber will be assigned to
703 0 and the function return EFI_SUCCESS. If the token number is the last valid token number,
704 *TokenNumber will be assigned to 0 and the function return EFI_SUCCESS.
706 @retval EFI_SUCCESS The PCD service retrieved the next valid token number. Or the input token number
707 is already the last valid token number in the PCD database.
708 In the later case, *TokenNumber is updated with the value of 0.
709 @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.
715 IN CONST EFI_GUID
*Guid
, OPTIONAL
716 IN OUT UINTN
*TokenNumber
720 Retrieves the next valid PCD token namespace for a given namespace.
722 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates
723 a known token namespace from which the search will start. On output,
724 it designates the next valid token namespace on the platform. If the input
725 token namespace does not exist on the platform, an error is returned and
726 the value of *Guid is undefined. If *Guid is NULL, then the GUID of the
727 first token space of the current platform is assigned to *Guid the function
728 return EFI_SUCCESS. If *Guid is NULL and there is no namespace exist in
729 the platform other than the default (NULL) tokennamespace, *Guid is unchanged
730 and the function return EFI_SUCCESS. If this input token namespace is the last
731 namespace on the platform, *Guid will be assigned to NULL and the function return
734 @retval EFI_SUCCESS The PCD service retrieved the next valid token space Guid.
735 Or the input token space Guid is already the last valid token space Guid
736 in the PCD database. In the later case, *Guid is updated with the value of NULL.
737 @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.
742 PeiPcdGetNextTokenSpace (
743 IN OUT CONST EFI_GUID
**Guid
747 /* Internal Function definitions */
749 Get PCD database from GUID HOB in PEI phase.
751 @return Pointer to PCD database.
760 Wrapper function for setting non-pointer type value for a PCD entry.
762 @param TokenNumber Pcd token number autogenerated by build tools.
763 @param Data Value want to be set for PCD entry
764 @param Size Size of value.
766 @return status of SetWorker.
771 IN UINTN TokenNumber
,
777 Set value for an PCD entry
779 @param TokenNumber Pcd token number autogenerated by build tools.
780 @param Data Value want to be set for PCD entry
781 @param Size Size of value.
782 @param PtrType If TRUE, the type of PCD entry's value is Pointer.
783 If False, the type of PCD entry's value is not Pointer.
785 @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set.
786 @retval EFI_INVALID_PARAMETER If Size can not be set to size table.
787 @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in
788 range of UINT8, UINT16, UINT32, UINT64
789 @retval EFI_NOT_FOUND Can not find the PCD type according to token number.
793 IN UINTN TokenNumber
,
800 Wrapper function for set PCD value for non-Pointer type dynamic-ex PCD.
802 @param ExTokenNumber Token number for dynamic-ex PCD.
803 @param Guid Token space guid for dynamic-ex PCD.
804 @param Data Value want to be set.
805 @param SetSize The size of value.
807 @return status of ExSetWorker().
812 IN UINTN ExTokenNumber
,
813 IN CONST EFI_GUID
*Guid
,
819 Set value for a dynamic PCD entry.
821 This routine find the local token number according to dynamic-ex PCD's token
822 space guid and token number firstly, and invoke callback function if this PCD
823 entry registered callback function. Finally, invoken general SetWorker to set
826 @param ExTokenNumber Dynamic-ex PCD token number.
827 @param Guid Token space guid for dynamic-ex PCD.
828 @param Data PCD value want to be set
829 @param SetSize Size of value.
830 @param PtrType If TRUE, this PCD entry is pointer type.
831 If FALSE, this PCD entry is not pointer type.
833 @return status of SetWorker().
838 IN UINTN ExTokenNumber
,
839 IN CONST EFI_GUID
*Guid
,
846 Get the PCD entry pointer in PCD database.
848 This routine will visit PCD database to find the PCD entry according to given
849 token number. The given token number is autogened by build tools and it will be
850 translated to local token number. Local token number contains PCD's type and
851 offset of PCD entry in PCD database.
853 @param TokenNumber Token's number, it is autogened by build tools
854 @param GetSize The size of token's value
856 @return PCD entry pointer in PCD database
861 IN UINTN TokenNumber
,
866 Wrapper function for get PCD value for dynamic-ex PCD.
868 @param Guid Token space guid for dynamic-ex PCD.
869 @param ExTokenNumber Token number for dyanmic-ex PCD.
870 @param GetSize The size of dynamic-ex PCD value.
872 @return PCD entry in PCD database.
877 IN CONST EFI_GUID
*Guid
,
878 IN UINTN ExTokenNumber
,
885 UINT32 LocalTokenNumberAlias
;
886 } EX_PCD_ENTRY_ATTRIBUTE
;
889 Get local token number according to dynamic-ex PCD's {token space guid:token number}
891 A dynamic-ex type PCD, developer must provide pair of token space guid: token number
892 in DEC file. PCD database maintain a mapping table that translate pair of {token
893 space guid: token number} to local token number.
895 @param Guid Token space guid for dynamic-ex PCD entry.
896 @param ExTokenNumber Token number for dynamic-ex PCD.
898 @return local token number for dynamic-ex PCD.
902 GetExPcdTokenNumber (
903 IN CONST EFI_GUID
*Guid
,
904 IN UINTN ExTokenNumber
908 The function registers the CallBackOnSet fucntion
909 according to TokenNumber and EFI_GUID space.
911 @param TokenNumber The token number.
912 @param Guid The GUID space.
913 @param CallBackFunction The Callback function to be registered.
914 @param Register To register or unregister the callback function.
916 @retval EFI_SUCCESS If the Callback function is registered.
917 @retval EFI_NOT_FOUND If the PCD Entry is not found according to Token Number and GUID space.
918 @retval EFI_OUT_OF_RESOURCES If the callback function can't be registered because there is not free
919 slot left in the CallbackFnTable.
922 PeiRegisterCallBackWorker (
923 IN UINTN TokenNumber
,
924 IN CONST EFI_GUID
*Guid
, OPTIONAL
925 IN PCD_PPI_CALLBACK CallBackFunction
,
930 The function builds the PCD database.
938 Get SKU ID tabble from PCD database.
940 @param LocalTokenNumberTableIdx Index of local token number in token number table.
941 @param Database PCD Database in PEI phase
943 @return Pointer to SKU ID array table
948 IN UINTN LocalTokenNumberTableIdx
,
949 IN PEI_PCD_DATABASE
*Database
953 Get index of PCD entry in size table.
955 @param LocalTokenNumberTableIdx Index of this PCD in local token number table.
956 @param Database Pointer to PCD database.
958 @return index of PCD entry in size table.
963 IN UINTN LocalTokenNumberTableIdx
,
964 IN PEI_PCD_DATABASE
*Database
968 Get PCD value's size for POINTER type PCD.
970 The POINTER type PCD's value will be stored into a buffer in specificed size.
971 The max size of this PCD's value is described in PCD's definition in DEC file.
973 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
974 @param MaxSize Maxmium size of PCD's value
975 @param Database Pcd database in PEI phase.
977 @return PCD value's size for POINTER type PCD.
982 IN UINTN LocalTokenNumberTableIdx
,
984 IN PEI_PCD_DATABASE
*Database
988 Set PCD value's size for POINTER type PCD.
990 The POINTER type PCD's value will be stored into a buffer in specificed size.
991 The max size of this PCD's value is described in PCD's definition in DEC file.
993 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
994 @param CurrentSize Maxmium size of PCD's value
995 @param Database Pcd database in PEI phase.
997 @retval TRUE Success to set PCD's value size, which is not exceed maxmium size
998 @retval FALSE Fail to set PCD's value size, which maybe exceed maxmium size
1003 IN UINTN LocalTokenNumberTableIdx
,
1004 IN OUT UINTN
*CurrentSize
,
1005 IN PEI_PCD_DATABASE
*Database
1009 // The init Database created by PCD Database generation tool
1011 extern PEI_PCD_DATABASE_INIT gPEIPcdDbInit
;
1015 ////////////////////////////////////////////////////////////////////////////////
1017 // Introduction of PEI PCD database //
1019 ////////////////////////////////////////////////////////////////////////////////
1022 PEI PCD database hold all dynamic type PCD information used in PEI phase.
1023 The structure of PEI PCD database is generated by build tools according to
1024 dynamic PCD usage for specified platform.
1027 Dynamic type PCD is designed for accessing setting which value is determined
1028 dynamic. In contrast, the value of static type PCD (FeatureFlag, FixedPcd,
1029 PatchablePcd) is fixed in final generated FD image in build time.
1031 2.1 The "dynamic" determination means:
1032 a) The PCD value is produced by someone driver and consumed by other driver
1034 b) The PCD value is set/get by user from FrontPage.
1035 c) The PCD value is produced by platform OEM specified area.
1037 2.2 According to distribution mehod, dynamic PCD could be classfied as:
1039 This type PCD is used for module in source distribution which will be
1042 This type PCD is used for module in binary distribution which will be
1045 2.3 According to storage method, dynamic PCD could be classfied as:
1047 - The value is stored in PCD database maintained by PCD database in boot
1048 time memory which is built as a guid hob in PEI phase.
1049 - This type is used for communication between PEIM/DXE driver, DXE/DXE
1050 driver. But all set/get value will be losted after boot-time memory
1052 - [PcdsDynamicDefault]/[PcdsDynamicExDefault] is used as section name
1053 for this type PCD in platform DSC file.
1055 b) Variable Storage:
1056 - The value is stored in variable area.
1057 - As default storage type, this type PCD could used for communication.
1058 But beside it, this type PCD could be used store the value associating
1059 with HII setting via variable technology.
1060 - In PEI phase, the PCD value could only be got but can not be set due
1061 to variable area is readonly for PEI phase.
1062 - [PcdsDynamicHii]/[PcdsDynamicExHii] is used as section name for this
1063 type PCD in platform DSC file.
1065 c) OEM specificed storage area:
1066 - The value is stored in OEM specified area, the base address is specified
1067 by a FixedAtBuild PCD PcdVpdBaseAddress.
1068 - The area is read only for PEI and DXE phase.
1069 - [PcdsDynamicVpd]/[PcdsDynamicExVpd] is used as section name for this
1070 type PCD in platform DSC file.
1072 Note: The default value of dynamic PCD are storaged in memory maintained
1073 by PEI/DXE PCD drvier.
1075 2.4 When and how to use dynamic PCD
1076 Module developer do not care the used PCD is dynamic or static when writting
1077 source code/INF. Dynamic PCD and dynamic type is pointed by platform integrator
1078 in platform DSC file. Please ref section 2.3 to get matching between dynamic
1079 PCD type and section name in DSC file.
1082 Although dynamic PCD could be in different storage type as above description,
1083 but the basic information and default value for all dynamic PCD is hold
1084 by PCD database maintained by PEI/DXE driver.
1086 As whole EFI BIOS boot path is divided into PEI/DXE phase, the PCD database
1087 also is divided into Pei/Dxe database maintaied by PcdPeim/PcdDxe driver separatly.
1088 To make PcdPeim's driver image smaller, PEI PCD database only hold all dynamic
1089 PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD
1090 database contains all PCDs used in PEI/DXE phase in memory.
1092 Build tool will generate PCD database into some C structure and variable for
1093 PEI/DXE PCD driver according to dynamic PCD section in platform DSC file.
1095 3.1 PcdPeim and PcdDxe
1096 PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver
1097 build guid hob in temporary memory and copy auto-generated C structure
1098 to temporary memory for PEI PCD database.
1099 DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,
1100 a new PCD database is allocated in boot-time memory which including all
1101 PEI PCD and DXE PCD entry.
1103 Pcd driver should run as early as possible before any other driver access
1104 dynamic PCD's value. PEI/DXE "Apriori File" mechanism make it possible by
1105 making PcdPeim/PcdDxe as first dispatching driver in PEI/DXE phase.
1107 3.2 Token space Guid/Token number, Platform token, Local token number
1109 +-----------+ +---------+
1110 |TokenSpace | |Platform |
1111 | Guid | build tool | Token |
1112 | + +-------------->| Number |
1113 | Token | +---------+`._
1115 +-----------+ `. +------+
1118 DynamicEx PCD ,-|Number|
1119 +-----------+ ,-' +------+
1128 3.2.1 Pair of Token space guid + Token number
1129 Any type PCD is identified by pair of "TokenSpaceGuid + TokeNumber". But it
1130 is not easy maintained by PCD driver, and hashed token number will make
1133 3.2.2 Platform Token Number
1134 "Platform token number" concept is introduced for mapping to a pair of
1135 "TokenSpaceGuid + TokenNumber". The platform token number is generated by
1136 build tool in autogen.h and all of them are continual in a platform scope
1137 started from 1.(0 meaning invalid internal token number)
1138 With auto-generated "platform token number", PcdGet(PcdSampleDynamicPcd)
1139 in source code is translated to LibPcdGet(_PCD_TOKEN_PcdSampleDynamicPcd)
1141 Notes: The mapping between pair of "tokenspace guid + token number" and
1142 "internal token number" need build tool establish, so "platform token number"
1143 mechanism is not suitable for binary module which use DynamicEx type PCD.
1144 To access a dynamicEx type PCD, pair of "token space guid/token number" all need
1145 to be specificed for PcdSet/PcdGet accessing macro.
1147 3.2.3 Local Token Number
1148 To fast searching a PCD entry in PCD database, PCD driver translate
1149 platform token number to local token number via a mapping table.
1150 For binary DynamicEx type PCD, there is a another mapping table to translate
1151 "token space guid + token number" to local token number directly.
1152 Local token number is identifier for all internal interface in PCD PEI/DXE
1155 A local token number is a 32-bit value in following meaning:
1156 32 ------------- 28 ---------- 24 -------- 0
1157 | PCD type mask | Datum Type | Offset |
1158 +-----------------------------------------+
1160 PCd type mask: indicate Pcd type from following macro:
1164 PCD_TYPE_SKU_ENABLED
1166 Datum Type : indicate PCD vaue type from following macro:
1167 PCD_DATUM_TYPE_POINTER
1168 PCD_DATUM_TYPE_UINT8
1169 PCD_DATUM_TYPE_UINT16
1170 PCD_DATUM_TYPE_UINT32
1171 PCD_DATUM_TYPE_UINT64
1172 Offset : indicate the related offset of PCD value in PCD database array.
1173 Based on local token number, PCD driver could fast determine PCD type, value
1174 type and get PCD entry from PCD database.
1176 3.3 PCD Database C structure.
1177 PCD Database C structure is generated by build tools in PCD driver's autogen.h/
1178 autogen.c file. In generated C structure, following information is stored:
1179 - ExMapTable: This table is used translate a binary dynamicex type PCD's
1180 "tokenguid + token" to local token number.
1181 - LocalTokenNumberTable:
1182 This table stores all local token number in array, use "Internal
1183 token number" as array index to get PCD entry's offset fastly.
1184 - SizeTable: This table stores the size information for all PCD entry.
1185 - GuidTable: This table stores guid value for DynamicEx's token space,
1186 HII type PCD's variable.
1189 - PCD value structure:
1190 Every PCD has a value record in PCD database. For different
1191 datum type PCD has different record structure which will be
1194 In a PCD database structure, there are two major area: Init and UnInit.
1195 Init area is use stored above PCD internal structure such as ExMapTable,
1196 LocalTokenNumberTable etc and the (default) value of PCD which has default
1197 value specified in platform DSC file.
1198 Unint area is used stored the value of PCD which has no default value in
1199 platform DSC file, the value of NULL, 0 specified in platform DSC file can
1200 be seemed as "no default value".
1202 3.3.1 Simple Sample PCD Database C Structure
1203 A general sample of PCD database structue is as follows:
1204 typedef struct _PCD_DATABASE {
1205 typedef struct _PCD_DATABASE_INIT {
1206 //===== Following is PCD database internal maintain structures
1207 DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];
1208 UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER_TABLE_SIZE];
1209 GUID GuidTable[PEI_GUID_TABLE_SIZE];
1210 SIZE_INFO SizeTable[PEI_SIZE_TABLE_SIZE];
1211 UINT8 SkuIdTable[PEI_SKUID_TABLE_SIZE];
1214 //===== Following is value structure for PCD with default value
1219 typedef struct _PCD_DATABSE_UNINIT {
1220 //==== Following is value structure for PCD without default value
1226 3.3.2 PCD value structure in PCD database C structure
1227 The value's structure is generated by build tool in PCD database C structure.
1228 The PCDs in different datum type has different value structure.
1230 3.3.2.1 UINT8/UINT16/UINT32/UINT64 datum type PCD
1231 The C structure for these datum type PCD is just a UINT8/UINT16/UINT32/UINT64
1232 data member in PCD database, For example:
1233 UINT16 PcdHardwareErrorRecordLevel_d3705011_bc19_4af7_be16_f68030378c15_VariableDefault_0;
1234 Above structure is generated by build tool, the member name is "PcdCName_Guidvalue"
1235 Member type is UINT16 according to PcdHardwareErrorRecordLevel declaration
1238 3.3.2.2 VOID* datum type PCD
1239 The value of VOID* datum type PCD is a UINT8/UINT16 array in PCD database.
1241 3.3.2.2.1 VOID* - string type
1242 If the default value for VOID* datum type PCD like L"xxx", the PCD is
1243 used for unicode string, and C structure of this datum type PCD is
1244 UINT16 string array in PCD database, for example:
1245 UINT16 StringTable[29];
1246 The number of 29 in above sample is max size of a unicode string.
1248 If the default value for VOID* datum type PCD like "xxx", the PCD is
1249 used for ascii string, and C structure of this datum type PCD is
1250 UINT8 string array in PCD database, for example:
1251 UINT8 StringTable[20];
1252 The number of 20 in above sample is max size of a ascii string.
1254 3.3.2.2.2 VOID* - byte array
1255 If the default value of VOID* datum type PCD like {'0x29', '0x01', '0xf2'}
1256 the PCD is used for byte array. The generated structrue is same as
1257 above ascii string table,
1258 UINT8 StringTable[13];
1259 The number of 13 in above sample is max size of byte array.