2 Provides library services to get and set Platform Configuration Database entries.
4 PCD Library Class provides PCD usage macro interface for all PCD types.
5 It should be included at any module who use PCD. If module use dynamic/dynamicex
6 PCD, module should be linked to PEIM/DXE library instance to access that PCD.
7 If module uses PatchableInModule type PCD, also need library instance produce
8 LibPatchPcdSetPtr() interface. For FeatureFlag/Fixed PCD, macro interface is
9 translated to an variable or macro which is auto-generated by build tool in
10 module's autogen.h/autogen.c.
12 Copyright (c) 2006 - 2008, Intel Corporation
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_MAX_SKU_ID 0x100
28 #define PcdToken(TokenName) _PCD_TOKEN_##TokenName
32 /// Feature Flag is in the form of a global constant
34 #define FeaturePcdGet(TokenName) _PCD_GET_MODE_BOOL_##TokenName
38 // Fixed is fixed at build time
40 #define FixedPcdGet8(TokenName) _PCD_VALUE_##TokenName
41 #define FixedPcdGet16(TokenName) _PCD_VALUE_##TokenName
42 #define FixedPcdGet32(TokenName) _PCD_VALUE_##TokenName
43 #define FixedPcdGet64(TokenName) _PCD_VALUE_##TokenName
44 #define FixedPcdGetBool(TokenName) _PCD_VALUE_##TokenName
47 #define FixedPcdGetPtr(TokenName) ((VOID *)_PCD_VALUE_##TokenName)
51 // (Binary) Patch is in the form of a global variable
53 #define PatchPcdGet8(TokenName) _gPcd_BinaryPatch_##TokenName
54 #define PatchPcdGet16(TokenName) _gPcd_BinaryPatch_##TokenName
55 #define PatchPcdGet32(TokenName) _gPcd_BinaryPatch_##TokenName
56 #define PatchPcdGet64(TokenName) _gPcd_BinaryPatch_##TokenName
57 #define PatchPcdGetBool(TokenName) _gPcd_BinaryPatch_##TokenName
58 #define PatchPcdGetPtr(TokenName) ((VOID *)_gPcd_BinaryPatch_##TokenName)
60 #define PatchPcdSet8(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
61 #define PatchPcdSet16(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
62 #define PatchPcdSet32(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
63 #define PatchPcdSet64(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
64 #define PatchPcdSetBool(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
65 #define PatchPcdSetPtr(TokenName, Size, Buffer) \
67 _gPcd_BinaryPatch_##TokenName, \
68 (UINTN)_PCD_PATCHABLE_##TokenName##_SIZE, \
74 // Dynamic is via the protocol with only the TokenNumber as argument
75 // It can also be Patch or Fixed type based on a build option
77 #define PcdGet8(TokenName) _PCD_GET_MODE_8_##TokenName
78 #define PcdGet16(TokenName) _PCD_GET_MODE_16_##TokenName
79 #define PcdGet32(TokenName) _PCD_GET_MODE_32_##TokenName
80 #define PcdGet64(TokenName) _PCD_GET_MODE_64_##TokenName
81 #define PcdGetPtr(TokenName) _PCD_GET_MODE_PTR_##TokenName
82 #define PcdGetBool(TokenName) _PCD_GET_MODE_BOOL_##TokenName
87 #define PcdSet8(TokenName, Value) _PCD_SET_MODE_8_##TokenName ((Value))
88 #define PcdSet16(TokenName, Value) _PCD_SET_MODE_16_##TokenName ((Value))
89 #define PcdSet32(TokenName, Value) _PCD_SET_MODE_32_##TokenName ((Value))
90 #define PcdSet64(TokenName, Value) _PCD_SET_MODE_64_##TokenName ((Value))
91 #define PcdSetPtr(TokenName, SizeOfBuffer, Buffer) \
92 _PCD_SET_MODE_PTR_##TokenName ((SizeOfBuffer), (Buffer))
93 #define PcdSetBool(TokenName, Value) _PCD_SET_MODE_BOOL_##TokenName ((Value))
96 // Dynamic Ex is to support binary distribution
98 #define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 ((Guid), _PCD_TOKEN_##TokenName)
99 #define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 ((Guid), _PCD_TOKEN_##TokenName)
100 #define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 ((Guid), _PCD_TOKEN_##TokenName)
101 #define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 ((Guid), _PCD_TOKEN_##TokenName)
102 #define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr ((Guid), _PCD_TOKEN_##TokenName)
103 #define PcdGetExBool(Guid, TokenName) LibPcdGetExBool ((Guid), _PCD_TOKEN_##TokenName)
108 #define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 ((Guid), _PCD_TOKEN_##TokenName, (Value))
109 #define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 ((Guid), _PCD_TOKEN_##TokenName, (Value))
110 #define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 ((Guid), _PCD_TOKEN_##TokenName, (Value))
111 #define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 ((Guid), _PCD_TOKEN_##TokenName, (Value))
112 #define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \
113 LibPcdSetExPtr ((Guid), _PCD_TOKEN_##TokenName, (SizeOfBuffer), (Buffer))
114 #define PcdSetExBool(Guid, TokenName, Value) \
115 LibPcdSetExBool((Guid), _PCD_TOKEN_##TokenName, (Value))
119 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
121 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
122 set values associated with a PCD token.
124 @return Return the SKU ID that just be set.
135 Returns the 8-bit value for the token specified by TokenNumber.
137 @param[in] TokenNumber The PCD token number to retrieve a current value for.
139 @return Returns the 8-bit value for the token specified by TokenNumber.
150 Returns the 16-bit value for the token specified by TokenNumber.
152 @param[in] TokenNumber The PCD token number to retrieve a current value for.
154 @return Returns the 16-bit value for the token specified by TokenNumber.
165 Returns the 32-bit value for the token specified by TokenNumber.
167 @param[in] TokenNumber The PCD token number to retrieve a current value for.
169 @return Returns the 32-bit value for the token specified by TokenNumber.
180 Returns the 64-bit value for the token specified by TokenNumber.
182 @param[in] TokenNumber The PCD token number to retrieve a current value for.
184 @return Returns the 64-bit value for the token specified by TokenNumber.
195 Returns the pointer to the buffer of the token specified by TokenNumber.
197 @param[in] TokenNumber The PCD token number to retrieve a current value for.
199 @return Returns the pointer to the token specified by TokenNumber.
210 Returns the Boolean value of the token specified by TokenNumber.
212 @param[in] TokenNumber The PCD token number to retrieve a current value for.
214 @return Returns the Boolean value of the token specified by TokenNumber.
225 Returns the size of the token specified by TokenNumber.
227 @param[in] TokenNumber The PCD token number to retrieve a current value for.
229 @return Returns the size of the token specified by TokenNumber.
240 Returns the 8-bit value for the token specified by TokenNumber and Guid.
241 If Guid is NULL, then ASSERT().
243 @param[in] Guid Pointer to a 128-bit unique value that designates
244 which namespace to retrieve a value from.
245 @param[in] TokenNumber The PCD token number to retrieve a current value for.
247 @return Return the UINT8.
259 Returns the 16-bit value for the token specified by TokenNumber and Guid.
260 If Guid is NULL, then ASSERT().
262 @param[in] Guid Pointer to a 128-bit unique value that designates
263 which namespace to retrieve a value from.
264 @param[in] TokenNumber The PCD token number to retrieve a current value for.
266 @return Return the UINT16.
278 Returns the 32-bit value for the token specified by TokenNumber and Guid.
279 If Guid is NULL, then ASSERT().
281 @param[in] Guid Pointer to a 128-bit unique value that designates
282 which namespace to retrieve a value from.
283 @param[in] TokenNumber The PCD token number to retrieve a current value for.
285 @return Return the UINT32.
297 Returns the 64-bit value for the token specified by TokenNumber and Guid.
298 If Guid is NULL, then ASSERT().
300 @param[in] Guid Pointer to a 128-bit unique value that designates
301 which namespace to retrieve a value from.
302 @param[in] TokenNumber The PCD token number to retrieve a current value for.
304 @return Return the UINT64.
316 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
317 If Guid is NULL, then ASSERT().
319 @param[in] Guid Pointer to a 128-bit unique value that designates
320 which namespace to retrieve a value from.
321 @param[in] TokenNumber The PCD token number to retrieve a current value for.
323 @return Return the VOID* pointer.
335 Returns the Boolean value of the token specified by TokenNumber and Guid.
336 If Guid is NULL, then ASSERT().
338 @param[in] Guid Pointer to a 128-bit unique value that designates
339 which namespace to retrieve a value from.
340 @param[in] TokenNumber The PCD token number to retrieve a current value for.
342 @return Return the BOOLEAN.
354 Returns the size of the token specified by TokenNumber and Guid.
355 If Guid is NULL, then ASSERT().
357 @param[in] Guid Pointer to a 128-bit unique value that designates
358 which namespace to retrieve a value from.
359 @param[in] TokenNumber The PCD token number to retrieve a current value for.
361 @return Return the size.
373 Sets the 8-bit value for the token specified by TokenNumber
374 to the value specified by Value. Value is returned.
376 @param[in] TokenNumber The PCD token number to set a current value for.
377 @param[in] Value The 8-bit value to set.
379 @return Return the value been set.
385 IN UINTN TokenNumber
,
391 Sets the 16-bit value for the token specified by TokenNumber
392 to the value specified by Value. Value is returned.
394 @param[in] TokenNumber The PCD token number to set a current value for.
395 @param[in] Value The 16-bit value to set.
397 @return Return the value been set.
403 IN UINTN TokenNumber
,
409 Sets the 32-bit value for the token specified by TokenNumber
410 to the value specified by Value. Value is returned.
412 @param[in] TokenNumber The PCD token number to set a current value for.
413 @param[in] Value The 32-bit value to set.
415 @return Return the value been set.
421 IN UINTN TokenNumber
,
427 Sets the 64-bit value for the token specified by TokenNumber
428 to the value specified by Value. Value is returned.
430 @param[in] TokenNumber The PCD token number to set a current value for.
431 @param[in] Value The 64-bit value to set.
433 @return Return the value been set.
439 IN UINTN TokenNumber
,
445 Sets a buffer for the token specified by TokenNumber to the value
446 specified by Buffer and SizeOfBuffer. Buffer is returned.
447 If SizeOfBuffer is greater than the maximum size support by TokenNumber,
448 then set SizeOfBuffer to the maximum size supported by TokenNumber and
449 return NULL to indicate that the set operation was not actually performed.
451 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
452 maximum size supported by TokenName and NULL must be returned.
454 If SizeOfBuffer is NULL, then ASSERT().
455 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
457 @param[in] TokenNumber The PCD token number to set a current value for.
458 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
459 @param[in] Buffer Value A pointer to the buffer to set.
461 @return Return the pointer for the buffer been set.
467 IN UINTN TokenNumber
,
468 IN OUT UINTN
*SizeOfBuffer
,
474 Sets the Boolean value for the token specified by TokenNumber
475 to the value specified by Value. Value is returned.
477 @param[in] TokenNumber The PCD token number to set a current value for.
478 @param[in] Value The boolean value to set.
480 @return Return the value been set.
486 IN UINTN TokenNumber
,
492 Sets the 8-bit value for the token specified by TokenNumber and
493 Guid to the value specified by Value. Value is returned.
494 If Guid is NULL, then ASSERT().
496 @param[in] Guid Pointer to a 128-bit unique value that
497 designates which namespace to set a value from.
498 @param[in] TokenNumber The PCD token number to set a current value for.
499 @param[in] Value The 8-bit value to set.
501 @return Return the value been set.
508 IN UINTN TokenNumber
,
514 Sets the 16-bit value for the token specified by TokenNumber and
515 Guid to the value specified by Value. Value is returned.
516 If Guid is NULL, then ASSERT().
518 @param[in] Guid Pointer to a 128-bit unique value that
519 designates which namespace to set a value from.
520 @param[in] TokenNumber The PCD token number to set a current value for.
521 @param[in] Value The 16-bit value to set.
523 @return Return the value been set.
530 IN UINTN TokenNumber
,
536 Sets the 32-bit value for the token specified by TokenNumber and
537 Guid to the value specified by Value. Value is returned.
538 If Guid is NULL, then ASSERT().
540 @param[in] Guid Pointer to a 128-bit unique value that
541 designates which namespace to set a value from.
542 @param[in] TokenNumber The PCD token number to set a current value for.
543 @param[in] Value The 32-bit value to set.
545 @return Return the value been set.
552 IN UINTN TokenNumber
,
558 Sets the 64-bit value for the token specified by TokenNumber and
559 Guid to the value specified by Value. Value is returned.
560 If Guid is NULL, then ASSERT().
562 @param[in] Guid Pointer to a 128-bit unique value that
563 designates which namespace to set a value from.
564 @param[in] TokenNumber The PCD token number to set a current value for.
565 @param[in] Value The 64-bit value to set.
567 @return Return the value been set.
574 IN UINTN TokenNumber
,
580 Sets a buffer for the token specified by TokenNumber to the value specified by
581 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
582 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
583 supported by TokenNumber and return NULL to indicate that the set operation
584 was not actually performed.
586 If Guid is NULL, then ASSERT().
587 If SizeOfBuffer is NULL, then ASSERT().
588 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
590 @param[in] Guid Pointer to a 128-bit unique value that
591 designates which namespace to set a value from.
592 @param[in] TokenNumber The PCD token number to set a current value for.
593 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
594 @param[in] Buffer A pointer to the buffer to set.
596 @return Return the pinter to the buffer been set.
603 IN UINTN TokenNumber
,
604 IN OUT UINTN
*SizeOfBuffer
,
610 Sets the Boolean value for the token specified by TokenNumber and
611 Guid to the value specified by Value. Value is returned.
612 If Guid is NULL, then ASSERT().
614 @param[in] Guid Pointer to a 128-bit unique value that
615 designates which namespace to set a value from.
616 @param[in] TokenNumber The PCD token number to set a current value for.
617 @param[in] Value The Boolean value to set.
619 @return Return the value been set.
626 IN UINTN TokenNumber
,
632 When the token specified by TokenNumber and Guid is set,
633 then notification function specified by NotificationFunction is called.
634 If Guid is NULL, then the default token space is used.
635 If NotificationFunction is NULL, then ASSERT().
637 This notification function serves two purposes. Firstly, it notifies the module which
638 did the registration that the value of this PCD token has been set. Secondly,
639 it provides a mechanism for the module which did the registration to intercept
640 the set operation and override the value been set if necessary. After the invocation
641 of the callback function, TokenData will be used by PCD service PEIM or driver to
642 modify the internal data in PCD database.
645 @param[in] CallBackGuid The PCD token GUID being set.
646 @param[in] CallBackToken The PCD token number being set.
647 @param[in, out] TokenData A pointer to the token data being set.
648 @param[in] TokenDataSize The size, in bytes, of the data being set.
653 (EFIAPI
*PCD_CALLBACK
)(
654 IN CONST GUID
*CallBackGuid
, OPTIONAL
655 IN UINTN CallBackToken
,
656 IN OUT VOID
*TokenData
,
657 IN UINTN TokenDataSize
662 When the token specified by TokenNumber and Guid is set,
663 then notification function specified by NotificationFunction is called.
664 If Guid is NULL, then the default token space is used.
665 If NotificationFunction is NULL, then ASSERT().
667 @param[in] Guid Pointer to a 128-bit unique value that designates which
668 namespace to set a value from. If NULL, then the default
670 @param[in] TokenNumber The PCD token number to monitor.
671 @param[in] NotificationFunction The function to call when the token
672 specified by Guid and TokenNumber is set.
677 LibPcdCallbackOnSet (
678 IN CONST GUID
*Guid
, OPTIONAL
679 IN UINTN TokenNumber
,
680 IN PCD_CALLBACK NotificationFunction
685 Disable a notification function that was established with LibPcdCallbackonSet().
687 @param[in] Guid Specify the GUID token space.
688 @param[in] TokenNumber Specify the token number.
689 @param[in] NotificationFunction The callback function to be unregistered.
694 LibPcdCancelCallback (
695 IN CONST GUID
*Guid
, OPTIONAL
696 IN UINTN TokenNumber
,
697 IN PCD_CALLBACK NotificationFunction
702 Retrieves the next PCD token number from the token space specified by Guid.
703 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
704 then the first token number is returned. Otherwise, the token number that
705 follows TokenNumber in the token space is returned. If TokenNumber is the last
706 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
707 is not in the token space specified by Guid, then ASSERT().
709 @param[in] Guid Pointer to a 128-bit unique value that designates which namespace
710 to set a value from. If NULL, then the default token space is used.
711 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
714 @return The next valid token number.
720 IN CONST GUID
*Guid
, OPTIONAL
727 Retrieves the next PCD token space from a token space specified by Guid.
728 Guid of NULL is reserved to mark the default local token namespace on the current
729 platform. If Guid is NULL, then the GUID of the first non-local token space of the
730 current platform is returned. If Guid is the last non-local token space,
731 then NULL is returned.
733 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
737 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
740 @return The next valid token namespace.
745 LibPcdGetNextTokenSpace (
751 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
752 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
753 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
754 NULL to indicate that the set operation was not actually performed.
755 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
756 MaximumDatumSize and NULL must be returned.
758 If PatchVariable is NULL, then ASSERT().
759 If SizeOfBuffer is NULL, then ASSERT().
760 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
762 @param[in] PatchVariable A pointer to the global variable in a module that is
763 the target of the set operation.
764 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
765 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
766 @param[in] Buffer A pointer to the buffer to used to set the target variable.
768 @return Return the pinter to the buffer been set.
774 IN VOID
*PatchVariable
,
775 IN UINTN MaximumDatumSize
,
776 IN OUT UINTN
*SizeOfBuffer
,
777 IN CONST VOID
*Buffer