2 PCD Library Class provides PCD usage macro interface for all PCD types. It should be
3 included at any module who use PCD.
5 If module use dynamic/dynamicex PCD, module should be linked to PEIM/DXE library
6 instance to access that PCD.
7 If module uses PatchableInModule type PCD, also need library instance produce LibPatchPcdSetPtr()
9 For FeatureFlag/Fixed PCD, macro interface is translated to an variable or macro
10 which is auto-generated by build tool in module's autogen.h/autogen.c
12 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
13 All rights reserved. This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
28 #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0)
30 #define PcdToken(TokenName) _PCD_TOKEN_##TokenName
34 /// Feature Flag is in the form of a global constant
36 #define FeaturePcdGet(TokenName) _PCD_GET_MODE_BOOL_##TokenName
40 // Fixed is fixed at build time
42 #define FixedPcdGet8(TokenName) _PCD_VALUE_##TokenName
43 #define FixedPcdGet16(TokenName) _PCD_VALUE_##TokenName
44 #define FixedPcdGet32(TokenName) _PCD_VALUE_##TokenName
45 #define FixedPcdGet64(TokenName) _PCD_VALUE_##TokenName
46 #define FixedPcdGetBool(TokenName) _PCD_VALUE_##TokenName
49 #define FixedPcdGetPtr(TokenName) ((VOID *)_PCD_VALUE_##TokenName)
53 // (Binary) Patch is in the form of a global variable
55 #define PatchPcdGet8(TokenName) _gPcd_BinaryPatch_##TokenName
56 #define PatchPcdGet16(TokenName) _gPcd_BinaryPatch_##TokenName
57 #define PatchPcdGet32(TokenName) _gPcd_BinaryPatch_##TokenName
58 #define PatchPcdGet64(TokenName) _gPcd_BinaryPatch_##TokenName
59 #define PatchPcdGetBool(TokenName) _gPcd_BinaryPatch_##TokenName
60 #define PatchPcdGetPtr(TokenName) ((VOID *)_gPcd_BinaryPatch_##TokenName)
62 #define PatchPcdSet8(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
63 #define PatchPcdSet16(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
64 #define PatchPcdSet32(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
65 #define PatchPcdSet64(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
66 #define PatchPcdSetBool(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
67 #define PatchPcdSetPtr(TokenName, Size, Buffer) \
69 _gPcd_BinaryPatch_##TokenName, \
70 (UINTN)_PCD_PATCHABLE_##TokenName##_SIZE, \
76 // Dynamic is via the protocol with only the TokenNumber as argument
77 // It can also be Patch or Fixed type based on a build option
79 #define PcdGet8(TokenName) _PCD_GET_MODE_8_##TokenName
80 #define PcdGet16(TokenName) _PCD_GET_MODE_16_##TokenName
81 #define PcdGet32(TokenName) _PCD_GET_MODE_32_##TokenName
82 #define PcdGet64(TokenName) _PCD_GET_MODE_64_##TokenName
83 #define PcdGetPtr(TokenName) _PCD_GET_MODE_PTR_##TokenName
84 #define PcdGetBool(TokenName) _PCD_GET_MODE_BOOL_##TokenName
89 #define PcdSet8(TokenName, Value) _PCD_SET_MODE_8_##TokenName ((Value))
90 #define PcdSet16(TokenName, Value) _PCD_SET_MODE_16_##TokenName ((Value))
91 #define PcdSet32(TokenName, Value) _PCD_SET_MODE_32_##TokenName ((Value))
92 #define PcdSet64(TokenName, Value) _PCD_SET_MODE_64_##TokenName ((Value))
93 #define PcdSetPtr(TokenName, SizeOfBuffer, Buffer) \
94 _PCD_SET_MODE_PTR_##TokenName ((SizeOfBuffer), (Buffer))
95 #define PcdSetBool(TokenName, Value) _PCD_SET_MODE_BOOL_##TokenName ((Value))
98 // Dynamic Ex is to support binary distribution
100 #define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 ((Guid), _PCD_TOKEN_##TokenName)
101 #define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 ((Guid), _PCD_TOKEN_##TokenName)
102 #define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 ((Guid), _PCD_TOKEN_##TokenName)
103 #define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 ((Guid), _PCD_TOKEN_##TokenName)
104 #define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr ((Guid), _PCD_TOKEN_##TokenName)
105 #define PcdGetExBool(Guid, TokenName) LibPcdGetExBool ((Guid), _PCD_TOKEN_##TokenName)
110 #define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 ((Guid), _PCD_TOKEN_##TokenName, (Value))
111 #define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 ((Guid), _PCD_TOKEN_##TokenName, (Value))
112 #define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 ((Guid), _PCD_TOKEN_##TokenName, (Value))
113 #define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 ((Guid), _PCD_TOKEN_##TokenName, (Value))
114 #define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \
115 LibPcdSetExPtr ((Guid), _PCD_TOKEN_##TokenName, (SizeOfBuffer), (Buffer))
116 #define PcdSetExBool(Guid, TokenName, Value) \
117 LibPcdSetExBool((Guid), _PCD_TOKEN_##TokenName, (Value))
121 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
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.
126 @retval SKU_ID Return the SKU ID that just be set.
137 Returns the 8-bit value for the token specified by TokenNumber.
139 @param[in] TokenNumber The PCD token number to retrieve a current value for.
141 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
152 Returns the 16-bit value for the token specified by TokenNumber.
154 @param[in] TokenNumber The PCD token number to retrieve a current value for.
156 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
167 Returns the 32-bit value for the token specified by TokenNumber.
169 @param[in] TokenNumber The PCD token number to retrieve a current value for.
171 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
182 Returns the 64-bit value for the token specified by TokenNumber.
184 @param[in] TokenNumber The PCD token number to retrieve a current value for.
186 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
197 Returns the pointer to the buffer of the token specified by TokenNumber.
199 @param[in] TokenNumber The PCD token number to retrieve a current value for.
201 @retval VOID* Returns the pointer to the token specified by TokenNumber.
212 Returns the Boolean value of the token specified by TokenNumber.
214 @param[in] TokenNumber The PCD token number to retrieve a current value for.
216 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
227 Returns the size of the token specified by TokenNumber.
229 @param[in] TokenNumber The PCD token number to retrieve a current value for.
231 @retval UINTN Returns the size of the token specified by TokenNumber.
242 Returns the 8-bit value for the token specified by TokenNumber and Guid.
243 If Guid is NULL, then ASSERT().
245 @param[in] Guid Pointer to a 128-bit unique value that designates
246 which namespace to retrieve a value from.
247 @param[in] TokenNumber The PCD token number to retrieve a current value for.
249 @retval UINT8 Return the UINT8.
261 Returns the 16-bit value for the token specified by TokenNumber and Guid.
262 If Guid is NULL, then ASSERT().
264 @param[in] Guid Pointer to a 128-bit unique value that designates
265 which namespace to retrieve a value from.
266 @param[in] TokenNumber The PCD token number to retrieve a current value for.
268 @retval UINT16 Return the UINT16.
280 Returns the 32-bit value for the token specified by TokenNumber and Guid.
281 If Guid is NULL, then ASSERT().
283 @param[in] Guid Pointer to a 128-bit unique value that designates
284 which namespace to retrieve a value from.
285 @param[in] TokenNumber The PCD token number to retrieve a current value for.
287 @retval UINT32 Return the UINT32.
299 Returns the 64-bit value for the token specified by TokenNumber and Guid.
300 If Guid is NULL, then ASSERT().
302 @param[in] Guid Pointer to a 128-bit unique value that designates
303 which namespace to retrieve a value from.
304 @param[in] TokenNumber The PCD token number to retrieve a current value for.
306 @retval UINT64 Return the UINT64.
318 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
319 If Guid is NULL, then ASSERT().
321 @param[in] Guid Pointer to a 128-bit unique value that designates
322 which namespace to retrieve a value from.
323 @param[in] TokenNumber The PCD token number to retrieve a current value for.
325 @retval VOID* Return the VOID* pointer.
337 Returns the Boolean value of the token specified by TokenNumber and Guid.
338 If Guid is NULL, then ASSERT().
340 @param[in] Guid Pointer to a 128-bit unique value that designates
341 which namespace to retrieve a value from.
342 @param[in] TokenNumber The PCD token number to retrieve a current value for.
344 @retval BOOLEAN Return the BOOLEAN.
356 Returns the size of the token specified by TokenNumber and Guid.
357 If Guid is NULL, then ASSERT().
359 @param[in] Guid Pointer to a 128-bit unique value that designates
360 which namespace to retrieve a value from.
361 @param[in] TokenNumber The PCD token number to retrieve a current value for.
363 @retval UINTN Return the size.
375 Sets the 8-bit value for the token specified by TokenNumber
376 to the value specified by Value. Value is returned.
378 @param[in] TokenNumber The PCD token number to set a current value for.
379 @param[in] Value The 8-bit value to set.
381 @retval UINT8 Return the value been set.
387 IN UINTN TokenNumber
,
393 Sets the 16-bit value for the token specified by TokenNumber
394 to the value specified by Value. Value is returned.
396 @param[in] TokenNumber The PCD token number to set a current value for.
397 @param[in] Value The 16-bit value to set.
399 @retval UINT16 Return the value been set.
405 IN UINTN TokenNumber
,
411 Sets the 32-bit value for the token specified by TokenNumber
412 to the value specified by Value. Value is returned.
414 @param[in] TokenNumber The PCD token number to set a current value for.
415 @param[in] Value The 32-bit value to set.
417 @retval UINT32 Return the value been set.
423 IN UINTN TokenNumber
,
429 Sets the 64-bit value for the token specified by TokenNumber
430 to the value specified by Value. Value is returned.
432 @param[in] TokenNumber The PCD token number to set a current value for.
433 @param[in] Value The 64-bit value to set.
435 @retval UINT64 Return the value been set.
441 IN UINTN TokenNumber
,
447 Sets a buffer for the token specified by TokenNumber to the value
448 specified by Buffer and SizeOfValue. Buffer is returned.
449 If SizeOfValue is greater than the maximum size support by TokenNumber,
450 then set SizeOfValue to the maximum size supported by TokenNumber and
451 return NULL to indicate that the set operation was not actually performed.
453 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to the
454 maximum size supported by TokenName and NULL must be returned.
456 If SizeOfValue is NULL, then ASSERT().
457 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
459 @param[in] TokenNumber The PCD token number to set a current value for.
460 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
461 @param[in] Buffer Value A pointer to the buffer to set.
463 @retval VOID* Return the pointer for the buffer been set.
469 IN UINTN TokenNumber
,
470 IN OUT UINTN
*SizeOfBuffer
,
476 Sets the Boolean value for the token specified by TokenNumber
477 to the value specified by Value. Value is returned.
479 @param[in] TokenNumber The PCD token number to set a current value for.
480 @param[in] Value The boolean value to set.
482 @retval BOOLEAN Return the value been set.
488 IN UINTN TokenNumber
,
494 Sets the 8-bit value for the token specified by TokenNumber and
495 Guid to the value specified by Value. Value is returned.
496 If Guid is NULL, then ASSERT().
498 @param[in] Guid Pointer to a 128-bit unique value that
499 designates which namespace to set a value from.
500 @param[in] TokenNumber The PCD token number to set a current value for.
501 @param[in] Value The 8-bit value to set.
503 @retval UINT8 Return the value been set.
510 IN UINTN TokenNumber
,
516 Sets the 16-bit value for the token specified by TokenNumber and
517 Guid to the value specified by Value. Value is returned.
518 If Guid is NULL, then ASSERT().
520 @param[in] Guid Pointer to a 128-bit unique value that
521 designates which namespace to set a value from.
522 @param[in] TokenNumber The PCD token number to set a current value for.
523 @param[in] Value The 16-bit value to set.
525 @retval UINT8 Return the value been set.
532 IN UINTN TokenNumber
,
538 Sets the 32-bit value for the token specified by TokenNumber and
539 Guid to the value specified by Value. Value is returned.
540 If Guid is NULL, then ASSERT().
542 @param[in] Guid Pointer to a 128-bit unique value that
543 designates which namespace to set a value from.
544 @param[in] TokenNumber The PCD token number to set a current value for.
545 @param[in] Value The 32-bit value to set.
547 @retval UINT32 Return the value been set.
554 IN UINTN TokenNumber
,
560 Sets the 64-bit value for the token specified by TokenNumber and
561 Guid to the value specified by Value. Value is returned.
562 If Guid is NULL, then ASSERT().
564 @param[in] Guid Pointer to a 128-bit unique value that
565 designates which namespace to set a value from.
566 @param[in] TokenNumber The PCD token number to set a current value for.
567 @param[in] Value The 64-bit value to set.
569 @retval UINT64 Return the value been set.
576 IN UINTN TokenNumber
,
582 Sets a buffer for the token specified by TokenNumber to the value specified by
583 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
584 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
585 supported by TokenNumber and return NULL to indicate that the set operation
586 was not actually performed.
588 If Guid is NULL, then ASSERT().
589 If SizeOfValue is NULL, then ASSERT().
590 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
592 @param[in] Guid Pointer to a 128-bit unique value that
593 designates which namespace to set a value from.
594 @param[in] TokenNumber The PCD token number to set a current value for.
595 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
596 @param[in] Buffer A pointer to the buffer to set.
598 @retval VOID * Return the pinter to the buffer been set.
605 IN UINTN TokenNumber
,
606 IN OUT UINTN
*SizeOfBuffer
,
612 Sets the Boolean value for the token specified by TokenNumber and
613 Guid to the value specified by Value. Value is returned.
614 If Guid is NULL, then ASSERT().
616 @param[in] Guid Pointer to a 128-bit unique value that
617 designates which namespace to set a value from.
618 @param[in] TokenNumber The PCD token number to set a current value for.
619 @param[in] Value The Boolean value to set.
621 @retval Boolean Return the value been set.
628 IN UINTN TokenNumber
,
634 When the token specified by TokenNumber and Guid is set,
635 then notification function specified by NotificationFunction is called.
636 If Guid is NULL, then the default token space is used.
637 If NotificationFunction is NULL, then ASSERT().
639 This notification function serves two purposes. Firstly, it notifies the module which
640 did the registration that the value of this PCD token has been set. Secondly,
641 it provides a mechanism for the module which did the registration to intercept
642 the set operation and override the value been set if necessary. After the invocation
643 of the callback function, TokenData will be used by PCD service PEIM or driver to
644 modify the internal data in PCD database.
647 @param[in] CallBackGuid The PCD token GUID being set.
648 @param[in] CallBackToken The PCD token number being set.
649 @param[in, out] TokenData A pointer to the token data being set.
650 @param[in] TokenDataSize The size, in bytes, of the data being set.
655 (EFIAPI
*PCD_CALLBACK
)(
656 IN CONST GUID
*CallBackGuid
, OPTIONAL
657 IN UINTN CallBackToken
,
658 IN OUT VOID
*TokenData
,
659 IN UINTN TokenDataSize
664 When the token specified by TokenNumber and Guid is set,
665 then notification function specified by NotificationFunction is called.
666 If Guid is NULL, then the default token space is used.
667 If NotificationFunction is NULL, then ASSERT().
669 @param[in] Guid Pointer to a 128-bit unique value that designates which
670 namespace to set a value from. If NULL, then the default
672 @param[in] TokenNumber The PCD token number to monitor.
673 @param[in] NotificationFunction The function to call when the token
674 specified by Guid and TokenNumber is set.
679 LibPcdCallbackOnSet (
680 IN CONST GUID
*Guid
, OPTIONAL
681 IN UINTN TokenNumber
,
682 IN PCD_CALLBACK NotificationFunction
687 Disable a notification function that was established with LibPcdCallbackonSet().
689 @param[in] Guid Specify the GUID token space.
690 @param[in] TokenNumber Specify the token number.
691 @param[in] NotificationFunction The callback function to be unregistered.
696 LibPcdCancelCallback (
697 IN CONST GUID
*Guid
, OPTIONAL
698 IN UINTN TokenNumber
,
699 IN PCD_CALLBACK NotificationFunction
704 Retrieves the next PCD token number from the token space specified by Guid.
705 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
706 then the first token number is returned. Otherwise, the token number that
707 follows TokenNumber in the token space is returned. If TokenNumber is the last
708 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
709 is not in the token space specified by Guid, then ASSERT().
711 @param[in] Guid Pointer to a 128-bit unique value that designates which namespace
712 to set a value from. If NULL, then the default token space is used.
713 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
716 @retval UINTN The next valid token number.
722 IN CONST GUID
*Guid
, OPTIONAL
729 Retrieves the next PCD token space from a token space specified by Guid.
730 Guid of NULL is reserved to mark the default local token namespace on the current
731 platform. If Guid is NULL, then the GUID of the first non-local token space of the
732 current platform is returned. If Guid is the last non-local token space,
733 then NULL is returned.
735 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
739 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
742 @retval CONST GUID * The next valid token namespace.
747 LibPcdGetNextTokenSpace (
753 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
754 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
755 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
756 NULL to indicate that the set operation was not actually performed.
757 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
758 MaximumDatumSize and NULL must be returned.
760 If PatchVariable is NULL, then ASSERT().
761 If SizeOfValue is NULL, then ASSERT().
762 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
764 @param[in] PatchVariable A pointer to the global variable in a module that is
765 the target of the set operation.
766 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
767 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
768 @param[in] Buffer A pointer to the buffer to used to set the target variable.
774 IN VOID
*PatchVariable
,
775 IN UINTN MaximumDatumSize
,
776 IN OUT UINTN
*SizeOfBuffer
,
777 IN CONST VOID
*Buffer