2 PCD Library Class Interface Declarations
4 Copyright (c) 2006 - 2007, 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.
18 #define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0)
20 #define PcdToken(TokenName) _PCD_TOKEN_##TokenName
24 // Feature Flag is in the form of a global constant
26 #define FeaturePcdGet(TokenName) _PCD_GET_MODE_BOOL_##TokenName
30 // Fixed is fixed at build time
32 #define FixedPcdGet8(TokenName) _PCD_VALUE_##TokenName
33 #define FixedPcdGet16(TokenName) _PCD_VALUE_##TokenName
34 #define FixedPcdGet32(TokenName) _PCD_VALUE_##TokenName
35 #define FixedPcdGet64(TokenName) _PCD_VALUE_##TokenName
36 #define FixedPcdGetBool(TokenName) _PCD_VALUE_##TokenName
39 #define FixedPcdGetPtr(TokenName) ((VOID *)_PCD_VALUE_##TokenName)
43 // (Binary) Patch is in the form of a global variable
45 #define PatchPcdGet8(TokenName) _gPcd_BinaryPatch_##TokenName
46 #define PatchPcdGet16(TokenName) _gPcd_BinaryPatch_##TokenName
47 #define PatchPcdGet32(TokenName) _gPcd_BinaryPatch_##TokenName
48 #define PatchPcdGet64(TokenName) _gPcd_BinaryPatch_##TokenName
49 #define PatchPcdGetBool(TokenName) _gPcd_BinaryPatch_##TokenName
50 #define PatchPcdGetPtr(TokenName) ((VOID *)_gPcd_BinaryPatch_##TokenName)
52 #define PatchPcdSet8(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
53 #define PatchPcdSet16(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
54 #define PatchPcdSet32(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
55 #define PatchPcdSet64(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
56 #define PatchPcdSetBool(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value))
57 #define PatchPcdSetPtr(TokenName, Size, Buffer) \
59 _gPcd_BinaryPatch_##TokenName, \
60 (UINTN)_PCD_PATCHABLE_##TokenName##_SIZE, \
66 // Dynamic is via the protocol with only the TokenNumber as argument
67 // It can also be Patch or Fixed type based on a build option
69 #define PcdGet8(TokenName) _PCD_GET_MODE_8_##TokenName
70 #define PcdGet16(TokenName) _PCD_GET_MODE_16_##TokenName
71 #define PcdGet32(TokenName) _PCD_GET_MODE_32_##TokenName
72 #define PcdGet64(TokenName) _PCD_GET_MODE_64_##TokenName
73 #define PcdGetPtr(TokenName) _PCD_GET_MODE_PTR_##TokenName
74 #define PcdGetBool(TokenName) _PCD_GET_MODE_BOOL_##TokenName
79 #define PcdSet8(TokenName, Value) _PCD_SET_MODE_8_##TokenName ((Value))
80 #define PcdSet16(TokenName, Value) _PCD_SET_MODE_16_##TokenName ((Value))
81 #define PcdSet32(TokenName, Value) _PCD_SET_MODE_32_##TokenName ((Value))
82 #define PcdSet64(TokenName, Value) _PCD_SET_MODE_64_##TokenName ((Value))
83 #define PcdSetPtr(TokenName, SizeOfBuffer, Buffer) \
84 _PCD_SET_MODE_PTR_##TokenName ((SizeOfBuffer), (Buffer))
85 #define PcdSetBool(TokenName, Value) _PCD_SET_MODE_BOOL_##TokenName ((Value))
88 // Dynamic Ex is to support binary distribution
90 #define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 ((Guid), _PCD_TOKEN_##TokenName)
91 #define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 ((Guid), _PCD_TOKEN_##TokenName)
92 #define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 ((Guid), _PCD_TOKEN_##TokenName)
93 #define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 ((Guid), _PCD_TOKEN_##TokenName)
94 #define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr ((Guid), _PCD_TOKEN_##TokenName)
95 #define PcdGetExBool(Guid, TokenName) LibPcdGetExBool ((Guid), _PCD_TOKEN_##TokenName)
100 #define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 ((Guid), _PCD_TOKEN_##TokenName, (Value))
101 #define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 ((Guid), _PCD_TOKEN_##TokenName, (Value))
102 #define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 ((Guid), _PCD_TOKEN_##TokenName, (Value))
103 #define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 ((Guid), _PCD_TOKEN_##TokenName, (Value))
104 #define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \
105 LibPcdSetExPtr ((Guid), _PCD_TOKEN_##TokenName, (SizeOfBuffer), (Buffer))
106 #define PcdSetExBool(Guid, TokenName, Value) \
107 LibPcdSetExBool((Guid), _PCD_TOKEN_##TokenName, (Value))
111 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
113 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
114 set values associated with a PCD token.
116 @retval SKU_ID Return the SKU ID that just be set.
127 Returns the 8-bit value for the token specified by TokenNumber.
129 @param[in] The PCD token number to retrieve a current value for.
131 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
142 Returns the 16-bit value for the token specified by TokenNumber.
144 @param[in] The PCD token number to retrieve a current value for.
146 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
157 Returns the 32-bit value for the token specified by TokenNumber.
159 @param[in] TokenNumber The PCD token number to retrieve a current value for.
161 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
172 Returns the 64-bit value for the token specified by TokenNumber.
174 @param[in] TokenNumber The PCD token number to retrieve a current value for.
176 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
187 Returns the pointer to the buffer of the token specified by TokenNumber.
189 @param[in] TokenNumber The PCD token number to retrieve a current value for.
191 @retval VOID* Returns the pointer to the token specified by TokenNumber.
202 Returns the Boolean value of the token specified by TokenNumber.
204 @param[in] TokenNumber The PCD token number to retrieve a current value for.
206 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
217 Returns the size of the token specified by TokenNumber.
219 @param[in] TokenNumber The PCD token number to retrieve a current value for.
221 @retval UINTN Returns the size of the token specified by TokenNumber.
232 Returns the 8-bit value for the token specified by TokenNumber and Guid.
233 If Guid is NULL, then ASSERT().
235 @param[in] Guid Pointer to a 128-bit unique value that designates
236 which namespace to retrieve a value from.
237 @param[in] TokenNumber The PCD token number to retrieve a current value for.
239 @retval UINT8 Return the UINT8.
251 Returns the 16-bit value for the token specified by TokenNumber and Guid.
252 If Guid is NULL, then ASSERT().
254 @param[in] Guid Pointer to a 128-bit unique value that designates
255 which namespace to retrieve a value from.
256 @param[in] TokenNumber The PCD token number to retrieve a current value for.
258 @retval UINT16 Return the UINT16.
270 Returns the 32-bit value for the token specified by TokenNumber and Guid.
271 If Guid is NULL, then ASSERT().
273 @param[in] Guid Pointer to a 128-bit unique value that designates
274 which namespace to retrieve a value from.
275 @param[in] TokenNumber The PCD token number to retrieve a current value for.
277 @retval UINT32 Return the UINT32.
289 Returns the 64-bit value for the token specified by TokenNumber and Guid.
290 If Guid is NULL, then ASSERT().
292 @param[in] Guid Pointer to a 128-bit unique value that designates
293 which namespace to retrieve a value from.
294 @param[in] TokenNumber The PCD token number to retrieve a current value for.
296 @retval UINT64 Return the UINT64.
308 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
309 If Guid is NULL, then ASSERT().
311 @param[in] Guid Pointer to a 128-bit unique value that designates
312 which namespace to retrieve a value from.
313 @param[in] TokenNumber The PCD token number to retrieve a current value for.
315 @retval VOID* Return the VOID* pointer.
327 Returns the Boolean value of the token specified by TokenNumber and Guid.
328 If Guid is NULL, then ASSERT().
330 @param[in] Guid Pointer to a 128-bit unique value that designates
331 which namespace to retrieve a value from.
332 @param[in] TokenNumber The PCD token number to retrieve a current value for.
334 @retval BOOLEAN Return the BOOLEAN.
346 Returns the size of the token specified by TokenNumber and Guid.
347 If Guid is NULL, then ASSERT().
349 @param[in] Guid Pointer to a 128-bit unique value that designates
350 which namespace to retrieve a value from.
351 @param[in] TokenNumber The PCD token number to retrieve a current value for.
353 @retval UINTN Return the size.
365 Sets the 8-bit value for the token specified by TokenNumber
366 to the value specified by Value. Value is returned.
368 @param[in] TokenNumber The PCD token number to set a current value for.
369 @param[in] Value The 8-bit value to set.
371 @retval UINT8 Return the value been set.
377 IN UINTN TokenNumber
,
383 Sets the 16-bit value for the token specified by TokenNumber
384 to the value specified by Value. Value is returned.
386 @param[in] TokenNumber The PCD token number to set a current value for.
387 @param[in] Value The 16-bit value to set.
389 @retval UINT16 Return the value been set.
395 IN UINTN TokenNumber
,
401 Sets the 32-bit value for the token specified by TokenNumber
402 to the value specified by Value. Value is returned.
404 @param[in] TokenNumber The PCD token number to set a current value for.
405 @param[in] Value The 32-bit value to set.
407 @retval UINT32 Return the value been set.
413 IN UINTN TokenNumber
,
419 Sets the 64-bit value for the token specified by TokenNumber
420 to the value specified by Value. Value is returned.
422 @param[in] TokenNumber The PCD token number to set a current value for.
423 @param[in] Value The 64-bit value to set.
425 @retval UINT64 Return the value been set.
431 IN UINTN TokenNumber
,
437 Sets a buffer for the token specified by TokenNumber to the value
438 specified by Buffer and SizeOfValue. Buffer is returned.
439 If SizeOfValue is greater than the maximum size support by TokenNumber,
440 then set SizeOfValue to the maximum size supported by TokenNumber and
441 return NULL to indicate that the set operation was not actually performed.
443 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to the
444 maximum size supported by TokenName and NULL must be returned.
446 If SizeOfValue is NULL, then ASSERT().
447 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
449 @param[in] TokenNumber The PCD token number to set a current value for.
450 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
451 @param[in] Value A pointer to the buffer to set.
453 @retval VOID* Return the pointer for the buffer been set.
459 IN UINTN TokenNumber
,
460 IN OUT UINTN
*SizeOfBuffer
,
466 Sets the Boolean value for the token specified by TokenNumber
467 to the value specified by Value. Value is returned.
469 @param[in] TokenNumber The PCD token number to set a current value for.
470 @param[in] Value The boolean value to set.
472 @retval BOOLEAN Return the value been set.
478 IN UINTN TokenNumber
,
484 Sets the 8-bit value for the token specified by TokenNumber and
485 Guid to the value specified by Value. Value is returned.
486 If Guid is NULL, then ASSERT().
488 @param[in] Guid Pointer to a 128-bit unique value that
489 designates which namespace to set a value from.
490 @param[in] TokenNumber The PCD token number to set a current value for.
491 @param[in] Value The 8-bit value to set.
493 @retval UINT8 Return the value been set.
500 IN UINTN TokenNumber
,
506 Sets the 16-bit value for the token specified by TokenNumber and
507 Guid to the value specified by Value. Value is returned.
508 If Guid is NULL, then ASSERT().
510 @param[in] Guid Pointer to a 128-bit unique value that
511 designates which namespace to set a value from.
512 @param[in] TokenNumber The PCD token number to set a current value for.
513 @param[in] Value The 16-bit value to set.
515 @retval UINT8 Return the value been set.
522 IN UINTN TokenNumber
,
528 Sets the 32-bit value for the token specified by TokenNumber and
529 Guid to the value specified by Value. Value is returned.
530 If Guid is NULL, then ASSERT().
532 @param[in] Guid Pointer to a 128-bit unique value that
533 designates which namespace to set a value from.
534 @param[in] TokenNumber The PCD token number to set a current value for.
535 @param[in] Value The 32-bit value to set.
537 @retval UINT32 Return the value been set.
544 IN UINTN TokenNumber
,
550 Sets the 64-bit value for the token specified by TokenNumber and
551 Guid to the value specified by Value. Value is returned.
552 If Guid is NULL, then ASSERT().
554 @param[in] Guid Pointer to a 128-bit unique value that
555 designates which namespace to set a value from.
556 @param[in] TokenNumber The PCD token number to set a current value for.
557 @param[in] Value The 64-bit value to set.
559 @retval UINT64 Return the value been set.
566 IN UINTN TokenNumber
,
572 Sets a buffer for the token specified by TokenNumber to the value specified by
573 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
574 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
575 supported by TokenNumber and return NULL to indicate that the set operation
576 was not actually performed.
578 If Guid is NULL, then ASSERT().
579 If SizeOfValue is NULL, then ASSERT().
580 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
582 @param[in] Guid Pointer to a 128-bit unique value that
583 designates which namespace to set a value from.
584 @param[in] TokenNumber The PCD token number to set a current value for.
585 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
586 @param[in] Buffer A pointer to the buffer to set.
588 @retval VOID * Return the pinter to the buffer been set.
595 IN UINTN TokenNumber
,
596 IN OUT UINTN
*SizeOfBuffer
,
602 Sets the Boolean value for the token specified by TokenNumber and
603 Guid to the value specified by Value. Value is returned.
604 If Guid is NULL, then ASSERT().
606 @param[in] Guid Pointer to a 128-bit unique value that
607 designates which namespace to set a value from.
608 @param[in] TokenNumber The PCD token number to set a current value for.
609 @param[in] Value The Boolean value to set.
611 @retval Boolean Return the value been set.
618 IN UINTN TokenNumber
,
624 When the token specified by TokenNumber and Guid is set,
625 then notification function specified by NotificationFunction is called.
626 If Guid is NULL, then the default token space is used.
627 If NotificationFunction is NULL, then ASSERT().
629 This notification function serves two purposes. Firstly, it notifies the module which
630 did the registration that the value of this PCD token has been set. Secondly,
631 it provides a mechanism for the module which did the registration to intercept
632 the set operation and override the value been set if necessary. After the invocation
633 of the callback function, TokenData will be used by PCD service PEIM or driver to
634 modify the internal data in PCD database.
637 @param[in] CallBackGuid The PCD token GUID being set.
638 @param[in] CallBackToken The PCD token number being set.
639 @param[in, out] TokenData A pointer to the token data being set.
640 @param[in] TokenDataSize The size, in bytes, of the data being set.
647 (EFIAPI
*PCD_CALLBACK
) (
648 IN CONST GUID
*CallBackGuid
, OPTIONAL
649 IN UINTN CallBackToken
,
650 IN OUT VOID
*TokenData
,
651 IN UINTN TokenDataSize
656 When the token specified by TokenNumber and Guid is set,
657 then notification function specified by NotificationFunction is called.
658 If Guid is NULL, then the default token space is used.
659 If NotificationFunction is NULL, then ASSERT().
661 @param[in] Guid Pointer to a 128-bit unique value that designates which
662 namespace to set a value from. If NULL, then the default
664 @param[in] TokenNumber The PCD token number to monitor.
665 @param[in] NotificationFunction The function to call when the token
666 specified by Guid and TokenNumber is set.
673 LibPcdCallbackOnSet (
674 IN CONST GUID
*Guid
, OPTIONAL
675 IN UINTN TokenNumber
,
676 IN PCD_CALLBACK NotificationFunction
681 Disable a notification function that was established with LibPcdCallbackonSet().
683 @param[in] Guid Specify the GUID token space.
684 @param[in] TokenNumber Specify the token number.
685 @param[in] NotificationFunction The callback function to be unregistered.
692 LibPcdCancelCallback (
693 IN CONST GUID
*Guid
, OPTIONAL
694 IN UINTN TokenNumber
,
695 IN PCD_CALLBACK NotificationFunction
700 Retrieves the next PCD token number from the token space specified by Guid.
701 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
702 then the first token number is returned. Otherwise, the token number that
703 follows TokenNumber in the token space is returned. If TokenNumber is the last
704 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
705 is not in the token space specified by Guid, then ASSERT().
707 @param[in] Pointer to a 128-bit unique value that designates which namespace
708 to set a value from. If NULL, then the default token space is used.
709 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
712 @retval UINTN The next valid token number.
718 IN CONST GUID
*Guid
, OPTIONAL
725 Retrieves the next PCD token space from a token space specified by Guid.
726 Guid of NULL is reserved to mark the default local token namespace on the current
727 platform. If Guid is NULL, then the GUID of the first non-local token space of the
728 current platform is returned. If Guid is the last non-local token space,
729 then NULL is returned.
731 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
735 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
738 @retval CONST GUID * The next valid token namespace.
743 LibPcdGetNextTokenSpace (
749 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
750 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
751 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
752 NULL to indicate that the set operation was not actually performed.
753 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
754 MaximumDatumSize and NULL must be returned.
756 If PatchVariable is NULL, then ASSERT().
757 If SizeOfValue is NULL, then ASSERT().
758 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
760 @param[in] PatchVariable A pointer to the global variable in a module that is
761 the target of the set operation.
762 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
763 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
764 @param[in] Buffer A pointer to the buffer to used to set the target variable.
770 IN VOID
*PatchVariable
,
771 IN UINTN MaximumDatumSize
,
772 IN OUT UINTN
*SizeOfBuffer
,
773 IN CONST VOID
*Buffer