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.
26 #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0)
27 #define PCD_MAX_SKU_ID 0x100
29 #define PcdToken(TokenName) _PCD_TOKEN_##TokenName
33 /// Feature Flag is in the form of a global constant
35 #define FeaturePcdGet(TokenName) _PCD_GET_MODE_BOOL_##TokenName
39 // Fixed is fixed at build time
41 #define FixedPcdGet8(TokenName) _PCD_VALUE_##TokenName
42 #define FixedPcdGet16(TokenName) _PCD_VALUE_##TokenName
43 #define FixedPcdGet32(TokenName) _PCD_VALUE_##TokenName
44 #define FixedPcdGet64(TokenName) _PCD_VALUE_##TokenName
45 #define FixedPcdGetBool(TokenName) _PCD_VALUE_##TokenName
48 #define FixedPcdGetPtr(TokenName) ((VOID *)_PCD_VALUE_##TokenName)
52 // (Binary) Patch is in the form of a global variable
54 #define PatchPcdGet8(TokenName) _gPcd_BinaryPatch_##TokenName
55 #define PatchPcdGet16(TokenName) _gPcd_BinaryPatch_##TokenName
56 #define PatchPcdGet32(TokenName) _gPcd_BinaryPatch_##TokenName
57 #define PatchPcdGet64(TokenName) _gPcd_BinaryPatch_##TokenName
58 #define PatchPcdGetBool(TokenName) _gPcd_BinaryPatch_##TokenName
59 #define PatchPcdGetPtr(TokenName) ((VOID *)_gPcd_BinaryPatch_##TokenName)
61 #define PatchPcdSet8(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
62 #define PatchPcdSet16(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
63 #define PatchPcdSet32(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
64 #define PatchPcdSet64(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
65 #define PatchPcdSetBool(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
66 #define PatchPcdSetPtr(TokenName, Size, Buffer) \
68 _gPcd_BinaryPatch_##TokenName, \
69 (UINTN)_PCD_PATCHABLE_##TokenName##_SIZE, \
75 // Dynamic is via the protocol with only the TokenNumber as argument
76 // It can also be Patch or Fixed type based on a build option
78 #define PcdGet8(TokenName) _PCD_GET_MODE_8_##TokenName
79 #define PcdGet16(TokenName) _PCD_GET_MODE_16_##TokenName
80 #define PcdGet32(TokenName) _PCD_GET_MODE_32_##TokenName
81 #define PcdGet64(TokenName) _PCD_GET_MODE_64_##TokenName
82 #define PcdGetPtr(TokenName) _PCD_GET_MODE_PTR_##TokenName
83 #define PcdGetBool(TokenName) _PCD_GET_MODE_BOOL_##TokenName
88 #define PcdSet8(TokenName, Value) _PCD_SET_MODE_8_##TokenName ((Value))
89 #define PcdSet16(TokenName, Value) _PCD_SET_MODE_16_##TokenName ((Value))
90 #define PcdSet32(TokenName, Value) _PCD_SET_MODE_32_##TokenName ((Value))
91 #define PcdSet64(TokenName, Value) _PCD_SET_MODE_64_##TokenName ((Value))
92 #define PcdSetPtr(TokenName, SizeOfBuffer, Buffer) \
93 _PCD_SET_MODE_PTR_##TokenName ((SizeOfBuffer), (Buffer))
94 #define PcdSetBool(TokenName, Value) _PCD_SET_MODE_BOOL_##TokenName ((Value))
97 // Dynamic Ex is to support binary distribution
99 #define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 ((Guid), _PCD_TOKEN_##TokenName)
100 #define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 ((Guid), _PCD_TOKEN_##TokenName)
101 #define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 ((Guid), _PCD_TOKEN_##TokenName)
102 #define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 ((Guid), _PCD_TOKEN_##TokenName)
103 #define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr ((Guid), _PCD_TOKEN_##TokenName)
104 #define PcdGetExBool(Guid, TokenName) LibPcdGetExBool ((Guid), _PCD_TOKEN_##TokenName)
109 #define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 ((Guid), _PCD_TOKEN_##TokenName, (Value))
110 #define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 ((Guid), _PCD_TOKEN_##TokenName, (Value))
111 #define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 ((Guid), _PCD_TOKEN_##TokenName, (Value))
112 #define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 ((Guid), _PCD_TOKEN_##TokenName, (Value))
113 #define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \
114 LibPcdSetExPtr ((Guid), _PCD_TOKEN_##TokenName, (SizeOfBuffer), (Buffer))
115 #define PcdSetExBool(Guid, TokenName, Value) \
116 LibPcdSetExBool((Guid), _PCD_TOKEN_##TokenName, (Value))
120 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
122 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
123 set values associated with a PCD token.
125 @return Return the SKU ID that just be set.
136 Returns the 8-bit value for the token specified by TokenNumber.
138 @param[in] TokenNumber The PCD token number to retrieve a current value for.
140 @return Returns the 8-bit value for the token specified by TokenNumber.
151 Returns the 16-bit value for the token specified by TokenNumber.
153 @param[in] TokenNumber The PCD token number to retrieve a current value for.
155 @return Returns the 16-bit value for the token specified by TokenNumber.
166 Returns the 32-bit value for the token specified by TokenNumber.
168 @param[in] TokenNumber The PCD token number to retrieve a current value for.
170 @return Returns the 32-bit value for the token specified by TokenNumber.
181 Returns the 64-bit value for the token specified by TokenNumber.
183 @param[in] TokenNumber The PCD token number to retrieve a current value for.
185 @return Returns the 64-bit value for the token specified by TokenNumber.
196 Returns the pointer to the buffer of the token specified by TokenNumber.
198 @param[in] TokenNumber The PCD token number to retrieve a current value for.
200 @return Returns the pointer to the token specified by TokenNumber.
211 Returns the Boolean value of the token specified by TokenNumber.
213 @param[in] TokenNumber The PCD token number to retrieve a current value for.
215 @return Returns the Boolean value of the token specified by TokenNumber.
226 Returns the size of the token specified by TokenNumber.
228 @param[in] TokenNumber The PCD token number to retrieve a current value for.
230 @return Returns the size of the token specified by TokenNumber.
241 Returns the 8-bit value for the token specified by TokenNumber and Guid.
242 If Guid is NULL, then ASSERT().
244 @param[in] Guid Pointer to a 128-bit unique value that designates
245 which namespace to retrieve a value from.
246 @param[in] TokenNumber The PCD token number to retrieve a current value for.
248 @return Return the UINT8.
260 Returns the 16-bit value for the token specified by TokenNumber and Guid.
261 If Guid is NULL, then ASSERT().
263 @param[in] Guid Pointer to a 128-bit unique value that designates
264 which namespace to retrieve a value from.
265 @param[in] TokenNumber The PCD token number to retrieve a current value for.
267 @return Return the UINT16.
279 Returns the 32-bit value for the token specified by TokenNumber and Guid.
280 If Guid is NULL, then ASSERT().
282 @param[in] Guid Pointer to a 128-bit unique value that designates
283 which namespace to retrieve a value from.
284 @param[in] TokenNumber The PCD token number to retrieve a current value for.
286 @return Return the UINT32.
298 Returns the 64-bit value for the token specified by TokenNumber and Guid.
299 If Guid is NULL, then ASSERT().
301 @param[in] Guid Pointer to a 128-bit unique value that designates
302 which namespace to retrieve a value from.
303 @param[in] TokenNumber The PCD token number to retrieve a current value for.
305 @return Return the UINT64.
317 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
318 If Guid is NULL, then ASSERT().
320 @param[in] Guid Pointer to a 128-bit unique value that designates
321 which namespace to retrieve a value from.
322 @param[in] TokenNumber The PCD token number to retrieve a current value for.
324 @return Return the VOID* pointer.
336 Returns the Boolean value of the token specified by TokenNumber and Guid.
337 If Guid is NULL, then ASSERT().
339 @param[in] Guid Pointer to a 128-bit unique value that designates
340 which namespace to retrieve a value from.
341 @param[in] TokenNumber The PCD token number to retrieve a current value for.
343 @return Return the BOOLEAN.
355 Returns the size of the token specified by TokenNumber and Guid.
356 If Guid is NULL, then ASSERT().
358 @param[in] Guid Pointer to a 128-bit unique value that designates
359 which namespace to retrieve a value from.
360 @param[in] TokenNumber The PCD token number to retrieve a current value for.
362 @return Return the size.
374 Sets the 8-bit value for the token specified by TokenNumber
375 to the value specified by Value. Value is returned.
377 @param[in] TokenNumber The PCD token number to set a current value for.
378 @param[in] Value The 8-bit value to set.
380 @return Return the value been set.
386 IN UINTN TokenNumber
,
392 Sets the 16-bit value for the token specified by TokenNumber
393 to the value specified by Value. Value is returned.
395 @param[in] TokenNumber The PCD token number to set a current value for.
396 @param[in] Value The 16-bit value to set.
398 @return Return the value been set.
404 IN UINTN TokenNumber
,
410 Sets the 32-bit value for the token specified by TokenNumber
411 to the value specified by Value. Value is returned.
413 @param[in] TokenNumber The PCD token number to set a current value for.
414 @param[in] Value The 32-bit value to set.
416 @return Return the value been set.
422 IN UINTN TokenNumber
,
428 Sets the 64-bit value for the token specified by TokenNumber
429 to the value specified by Value. Value is returned.
431 @param[in] TokenNumber The PCD token number to set a current value for.
432 @param[in] Value The 64-bit value to set.
434 @return Return the value been set.
440 IN UINTN TokenNumber
,
446 Sets a buffer for the token specified by TokenNumber to the value
447 specified by Buffer and SizeOfValue. Buffer is returned.
448 If SizeOfValue is greater than the maximum size support by TokenNumber,
449 then set SizeOfValue to the maximum size supported by TokenNumber and
450 return NULL to indicate that the set operation was not actually performed.
452 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to the
453 maximum size supported by TokenName and NULL must be returned.
455 If SizeOfValue is NULL, then ASSERT().
456 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
458 @param[in] TokenNumber The PCD token number to set a current value for.
459 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
460 @param[in] Buffer Value A pointer to the buffer to set.
462 @return Return the pointer for the buffer been set.
468 IN UINTN TokenNumber
,
469 IN OUT UINTN
*SizeOfBuffer
,
475 Sets the Boolean value for the token specified by TokenNumber
476 to the value specified by Value. Value is returned.
478 @param[in] TokenNumber The PCD token number to set a current value for.
479 @param[in] Value The boolean value to set.
481 @return Return the value been set.
487 IN UINTN TokenNumber
,
493 Sets the 8-bit value for the token specified by TokenNumber and
494 Guid to the value specified by Value. Value is returned.
495 If Guid is NULL, then ASSERT().
497 @param[in] Guid Pointer to a 128-bit unique value that
498 designates which namespace to set a value from.
499 @param[in] TokenNumber The PCD token number to set a current value for.
500 @param[in] Value The 8-bit value to set.
502 @return Return the value been set.
509 IN UINTN TokenNumber
,
515 Sets the 16-bit value for the token specified by TokenNumber and
516 Guid to the value specified by Value. Value is returned.
517 If Guid is NULL, then ASSERT().
519 @param[in] Guid Pointer to a 128-bit unique value that
520 designates which namespace to set a value from.
521 @param[in] TokenNumber The PCD token number to set a current value for.
522 @param[in] Value The 16-bit value to set.
524 @return Return the value been set.
531 IN UINTN TokenNumber
,
537 Sets the 32-bit value for the token specified by TokenNumber and
538 Guid to the value specified by Value. Value is returned.
539 If Guid is NULL, then ASSERT().
541 @param[in] Guid Pointer to a 128-bit unique value that
542 designates which namespace to set a value from.
543 @param[in] TokenNumber The PCD token number to set a current value for.
544 @param[in] Value The 32-bit value to set.
546 @return Return the value been set.
553 IN UINTN TokenNumber
,
559 Sets the 64-bit value for the token specified by TokenNumber and
560 Guid to the value specified by Value. Value is returned.
561 If Guid is NULL, then ASSERT().
563 @param[in] Guid Pointer to a 128-bit unique value that
564 designates which namespace to set a value from.
565 @param[in] TokenNumber The PCD token number to set a current value for.
566 @param[in] Value The 64-bit value to set.
568 @return Return the value been set.
575 IN UINTN TokenNumber
,
581 Sets a buffer for the token specified by TokenNumber to the value specified by
582 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
583 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
584 supported by TokenNumber and return NULL to indicate that the set operation
585 was not actually performed.
587 If Guid is NULL, then ASSERT().
588 If SizeOfValue is NULL, then ASSERT().
589 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
591 @param[in] Guid Pointer to a 128-bit unique value that
592 designates which namespace to set a value from.
593 @param[in] TokenNumber The PCD token number to set a current value for.
594 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
595 @param[in] Buffer A pointer to the buffer to set.
597 @return Return the pinter to the buffer been set.
604 IN UINTN TokenNumber
,
605 IN OUT UINTN
*SizeOfBuffer
,
611 Sets the Boolean value for the token specified by TokenNumber and
612 Guid to the value specified by Value. Value is returned.
613 If Guid is NULL, then ASSERT().
615 @param[in] Guid Pointer to a 128-bit unique value that
616 designates which namespace to set a value from.
617 @param[in] TokenNumber The PCD token number to set a current value for.
618 @param[in] Value The Boolean value to set.
620 @return Return the value been set.
627 IN UINTN TokenNumber
,
633 When the token specified by TokenNumber and Guid is set,
634 then notification function specified by NotificationFunction is called.
635 If Guid is NULL, then the default token space is used.
636 If NotificationFunction is NULL, then ASSERT().
638 This notification function serves two purposes. Firstly, it notifies the module which
639 did the registration that the value of this PCD token has been set. Secondly,
640 it provides a mechanism for the module which did the registration to intercept
641 the set operation and override the value been set if necessary. After the invocation
642 of the callback function, TokenData will be used by PCD service PEIM or driver to
643 modify the internal data in PCD database.
646 @param[in] CallBackGuid The PCD token GUID being set.
647 @param[in] CallBackToken The PCD token number being set.
648 @param[in, out] TokenData A pointer to the token data being set.
649 @param[in] TokenDataSize The size, in bytes, of the data being set.
654 (EFIAPI
*PCD_CALLBACK
)(
655 IN CONST GUID
*CallBackGuid
, OPTIONAL
656 IN UINTN CallBackToken
,
657 IN OUT VOID
*TokenData
,
658 IN UINTN TokenDataSize
663 When the token specified by TokenNumber and Guid is set,
664 then notification function specified by NotificationFunction is called.
665 If Guid is NULL, then the default token space is used.
666 If NotificationFunction is NULL, then ASSERT().
668 @param[in] Guid Pointer to a 128-bit unique value that designates which
669 namespace to set a value from. If NULL, then the default
671 @param[in] TokenNumber The PCD token number to monitor.
672 @param[in] NotificationFunction The function to call when the token
673 specified by Guid and TokenNumber is set.
678 LibPcdCallbackOnSet (
679 IN CONST GUID
*Guid
, OPTIONAL
680 IN UINTN TokenNumber
,
681 IN PCD_CALLBACK NotificationFunction
686 Disable a notification function that was established with LibPcdCallbackonSet().
688 @param[in] Guid Specify the GUID token space.
689 @param[in] TokenNumber Specify the token number.
690 @param[in] NotificationFunction The callback function to be unregistered.
695 LibPcdCancelCallback (
696 IN CONST GUID
*Guid
, OPTIONAL
697 IN UINTN TokenNumber
,
698 IN PCD_CALLBACK NotificationFunction
703 Retrieves the next PCD token number from the token space specified by Guid.
704 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
705 then the first token number is returned. Otherwise, the token number that
706 follows TokenNumber in the token space is returned. If TokenNumber is the last
707 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
708 is not in the token space specified by Guid, then ASSERT().
710 @param[in] Guid Pointer to a 128-bit unique value that designates which namespace
711 to set a value from. If NULL, then the default token space is used.
712 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
715 @return The next valid token number.
721 IN CONST GUID
*Guid
, OPTIONAL
728 Retrieves the next PCD token space from a token space specified by Guid.
729 Guid of NULL is reserved to mark the default local token namespace on the current
730 platform. If Guid is NULL, then the GUID of the first non-local token space of the
731 current platform is returned. If Guid is the last non-local token space,
732 then NULL is returned.
734 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
738 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
741 @return The next valid token namespace.
746 LibPcdGetNextTokenSpace (
752 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
753 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
754 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
755 NULL to indicate that the set operation was not actually performed.
756 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
757 MaximumDatumSize and NULL must be returned.
759 If PatchVariable is NULL, then ASSERT().
760 If SizeOfValue is NULL, then ASSERT().
761 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
763 @param[in] PatchVariable A pointer to the global variable in a module that is
764 the target of the set operation.
765 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
766 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
767 @param[in] Buffer A pointer to the buffer to used to set the target variable.
769 @return Return the pinter to the buffer been set.
775 IN VOID
*PatchVariable
,
776 IN UINTN MaximumDatumSize
,
777 IN OUT UINTN
*SizeOfBuffer
,
778 IN CONST VOID
*Buffer