2 A emptry template implementation of PCD Library.
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.
17 #include <Library/DebugLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/BaseMemoryLib.h>
23 This function provides a means by which SKU support can be established in the PCD infrastructure.
25 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
27 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
28 set values associated with a PCD token.
30 If SkuId >= 0x100, then ASSERT().
32 @return Return the SKU ID that just be set.
47 This function provides a means by which to retrieve a value for a given PCD token.
49 Returns the 8-bit value for the token specified by TokenNumber.
51 @param[in] TokenNumber The PCD token number to retrieve a current value for.
53 @return Returns the 8-bit value for the token specified by TokenNumber.
70 This function provides a means by which to retrieve a value for a given PCD token.
72 Returns the 16-bit value for the token specified by TokenNumber.
74 @param[in] TokenNumber The PCD token number to retrieve a current value for.
76 @return Returns the 16-bit value for the token specified by TokenNumber.
93 This function provides a means by which to retrieve a value for a given PCD token.
95 Returns the 32-bit value for the token specified by TokenNumber.
97 @param[in] TokenNumber The PCD token number to retrieve a current value for.
99 @return Returns the 32-bit value for the token specified by TokenNumber.
116 This function provides a means by which to retrieve a value for a given PCD token.
118 Returns the 64-bit value for the token specified by TokenNumber.
120 @param[in] TokenNumber The PCD token number to retrieve a current value for.
122 @return Returns the 64-bit value for the token specified by TokenNumber.
139 This function provides a means by which to retrieve a value for a given PCD token.
141 Returns the pointer to the buffer of the token specified by TokenNumber.
143 @param[in] TokenNumber The PCD token number to retrieve a current value for.
145 @return Returns the pointer to the token specified by TokenNumber.
162 This function provides a means by which to retrieve a value for a given PCD token.
164 Returns the Boolean value of the token specified by TokenNumber.
166 @param[in] TokenNumber The PCD token number to retrieve a current value for.
168 @return Returns the Boolean value of the token specified by TokenNumber.
185 This function provides a means by which to retrieve the size of a given PCD token.
187 @param[in] TokenNumber The PCD token number to retrieve a current value for.
189 @return Returns the size of the token specified by TokenNumber.
206 This function provides a means by which to retrieve a value for a given PCD token.
208 Returns the 8-bit value for the token specified by TokenNumber and Guid.
210 If Guid is NULL, then ASSERT().
212 @param[in] Guid Pointer to a 128-bit unique value that designates
213 which namespace to retrieve a value from.
214 @param[in] TokenNumber The PCD token number to retrieve a current value for.
216 @return Return the UINT8.
234 This function provides a means by which to retrieve a value for a given PCD token.
236 Returns the 16-bit value for the token specified by TokenNumber and Guid.
238 If Guid is NULL, then ASSERT().
240 @param[in] Guid Pointer to a 128-bit unique value that designates
241 which namespace to retrieve a value from.
242 @param[in] TokenNumber The PCD token number to retrieve a current value for.
244 @return Return the UINT16.
262 Returns the 32-bit value for the token specified by TokenNumber and Guid.
263 If Guid is NULL, then ASSERT().
265 @param[in] Guid Pointer to a 128-bit unique value that designates
266 which namespace to retrieve a value from.
267 @param[in] TokenNumber The PCD token number to retrieve a current value for.
269 @return Return the UINT32.
287 This function provides a means by which to retrieve a value for a given PCD token.
289 Returns the 64-bit value for the token specified by TokenNumber and Guid.
291 If Guid is NULL, then ASSERT().
293 @param[in] Guid Pointer to a 128-bit unique value that designates
294 which namespace to retrieve a value from.
295 @param[in] TokenNumber The PCD token number to retrieve a current value for.
297 @return Return the UINT64.
315 This function provides a means by which to retrieve a value for a given PCD token.
317 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 @return Return the VOID* pointer.
343 This function provides a means by which to retrieve a value for a given PCD token.
345 Returns the Boolean value 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 @return Return the BOOLEAN.
371 This function provides a means by which to retrieve the size of a given PCD token.
373 Returns the size of the token specified by TokenNumber and Guid.
375 If Guid is NULL, then ASSERT().
377 @param[in] Guid Pointer to a 128-bit unique value that designates
378 which namespace to retrieve a value from.
379 @param[in] TokenNumber The PCD token number to retrieve a current value for.
381 @return Return the size.
399 This function provides a means by which to set a value for a given PCD token.
401 Sets the 8-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 8-bit value to set.
407 @return Return the value been set.
413 IN UINTN TokenNumber
,
425 This function provides a means by which to set a value for a given PCD token.
427 Sets the 16-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 16-bit value to set.
433 @return Return the value been set.
439 IN UINTN TokenNumber
,
451 This function provides a means by which to set a value for a given PCD token.
453 Sets the 32-bit value for the token specified by TokenNumber
454 to the value specified by Value. Value is returned.
456 @param[in] TokenNumber The PCD token number to set a current value for.
457 @param[in] Value The 32-bit value to set.
459 @return Return the value been set.
465 IN UINTN TokenNumber
,
477 This function provides a means by which to set a value for a given PCD token.
479 Sets the 64-bit value for the token specified by TokenNumber
480 to the value specified by Value. Value is returned.
482 @param[in] TokenNumber The PCD token number to set a current value for.
483 @param[in] Value The 64-bit value to set.
485 @return Return the value been set.
491 IN UINTN TokenNumber
,
503 This function provides a means by which to set a value for a given PCD token.
505 Sets a buffer for the token specified by TokenNumber to the value
506 specified by Buffer and SizeOfBuffer. Buffer is returned.
507 If SizeOfBuffer is greater than the maximum size support by TokenNumber,
508 then set SizeOfBuffer to the maximum size supported by TokenNumber and
509 return NULL to indicate that the set operation was not actually performed.
511 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
512 maximum size supported by TokenName and NULL must be returned.
514 If SizeOfBuffer is NULL, then ASSERT().
515 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
517 @param[in] TokenNumber The PCD token number to set a current value for.
518 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
519 @param[in] Buffer A pointer to the buffer to set.
521 @return Return the pointer for the buffer been set.
527 IN UINTN TokenNumber
,
528 IN OUT UINTN
*SizeOfBuffer
,
529 IN CONST VOID
*Buffer
540 This function provides a means by which to set a value for a given PCD token.
542 Sets the Boolean value for the token specified by TokenNumber
543 to the value specified by Value. Value is returned.
545 @param[in] TokenNumber The PCD token number to set a current value for.
546 @param[in] Value The boolean value to set.
548 @return Return the value been set.
554 IN UINTN TokenNumber
,
566 This function provides a means by which to set a value for a given PCD token.
568 Sets the 8-bit value for the token specified by TokenNumber and
569 Guid to the value specified by Value. Value is returned.
571 If Guid is NULL, then ASSERT().
573 @param[in] Guid Pointer to a 128-bit unique value that
574 designates which namespace to set a value from.
575 @param[in] TokenNumber The PCD token number to set a current value for.
576 @param[in] Value The 8-bit value to set.
578 @return Return the value been set.
585 IN UINTN TokenNumber
,
597 This function provides a means by which to set a value for a given PCD token.
599 Sets the 16-bit value for the token specified by TokenNumber and
600 Guid to the value specified by Value. Value is returned.
602 If Guid is NULL, then ASSERT().
604 @param[in] Guid Pointer to a 128-bit unique value that
605 designates which namespace to set a value from.
606 @param[in] TokenNumber The PCD token number to set a current value for.
607 @param[in] Value The 16-bit value to set.
609 @return Return the value been set.
616 IN UINTN TokenNumber
,
628 This function provides a means by which to set a value for a given PCD token.
630 Sets the 32-bit value for the token specified by TokenNumber and
631 Guid to the value specified by Value. Value is returned.
633 If Guid is NULL, then ASSERT().
635 @param[in] Guid Pointer to a 128-bit unique value that
636 designates which namespace to set a value from.
637 @param[in] TokenNumber The PCD token number to set a current value for.
638 @param[in] Value The 32-bit value to set.
640 @return Return the value been set.
647 IN UINTN TokenNumber
,
659 This function provides a means by which to set a value for a given PCD token.
661 Sets the 64-bit value for the token specified by TokenNumber and
662 Guid to the value specified by Value. Value is returned.
663 If Guid is NULL, then ASSERT().
665 @param[in] Guid Pointer to a 128-bit unique value that
666 designates which namespace to set a value from.
667 @param[in] TokenNumber The PCD token number to set a current value for.
668 @param[in] Value The 64-bit value to set.
670 @return Return the value been set.
677 IN UINTN TokenNumber
,
689 This function provides a means by which to set a value for a given PCD token.
691 Sets a buffer for the token specified by TokenNumber to the value specified by
692 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
693 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
694 supported by TokenNumber and return NULL to indicate that the set operation
695 was not actually performed.
697 If Guid is NULL, then ASSERT().
698 If SizeOfBuffer is NULL, then ASSERT().
699 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
701 @param[in] Guid Pointer to a 128-bit unique value that
702 designates which namespace to set a value from.
703 @param[in] TokenNumber The PCD token number to set a current value for.
704 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
705 @param[in] Buffer A pointer to the buffer to set.
707 @return Return the pinter to the buffer been set.
714 IN UINTN TokenNumber
,
715 IN OUT UINTN
*SizeOfBuffer
,
727 This function provides a means by which to set a value for a given PCD token.
729 Sets the Boolean value for the token specified by TokenNumber and
730 Guid to the value specified by Value. Value is returned.
732 If Guid is NULL, then ASSERT().
734 @param[in] Guid Pointer to a 128-bit unique value that
735 designates which namespace to set a value from.
736 @param[in] TokenNumber The PCD token number to set a current value for.
737 @param[in] Value The Boolean value to set.
739 @return Return the value been set.
746 IN UINTN TokenNumber
,
758 Set up a notification function that is called when a specified token is set.
760 When the token specified by TokenNumber and Guid is set,
761 then notification function specified by NotificationFunction is called.
762 If Guid is NULL, then the default token space is used.
764 If NotificationFunction is NULL, then ASSERT().
766 @param[in] Guid Pointer to a 128-bit unique value that designates which
767 namespace to set a value from. If NULL, then the default
769 @param[in] TokenNumber The PCD token number to monitor.
770 @param[in] NotificationFunction The function to call when the token
771 specified by Guid and TokenNumber is set.
776 LibPcdCallbackOnSet (
777 IN CONST GUID
*Guid
, OPTIONAL
778 IN UINTN TokenNumber
,
779 IN PCD_CALLBACK NotificationFunction
788 Disable a notification function that was established with LibPcdCallbackonSet().
790 Disable a notification function that was previously established with LibPcdCallbackOnSet().
792 If NotificationFunction is NULL, then ASSERT().
793 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
794 and NotificationFunction, then ASSERT().
796 @param[in] Guid Specify the GUID token space.
797 @param[in] TokenNumber Specify the token number.
798 @param[in] NotificationFunction The callback function to be unregistered.
803 LibPcdCancelCallback (
804 IN CONST GUID
*Guid
, OPTIONAL
805 IN UINTN TokenNumber
,
806 IN PCD_CALLBACK NotificationFunction
815 Retrieves the next token in a token space.
817 Retrieves the next PCD token number from the token space specified by Guid.
818 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
819 then the first token number is returned. Otherwise, the token number that
820 follows TokenNumber in the token space is returned. If TokenNumber is the last
821 token number in the token space, then 0 is returned.
823 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
825 @param[in] Guid Pointer to a 128-bit unique value that designates which namespace
826 to set a value from. If NULL, then the default token space is used.
827 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
830 @return The next valid token number.
836 IN CONST GUID
*Guid
, OPTIONAL
848 Used to retrieve the list of available PCD token space GUIDs.
850 Retrieves the next PCD token space from a token space specified by Guid.
851 Guid of NULL is reserved to mark the default local token namespace on the current
852 platform. If Guid is NULL, then the GUID of the first non-local token space of the
853 current platform is returned. If Guid is the last non-local token space,
854 then NULL is returned.
856 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
860 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
863 @return The next valid token namespace.
868 LibPcdGetNextTokenSpace (
869 IN CONST GUID
*TokenSpaceGuid
879 Sets a value of a patchable PCD entry that is type pointer.
881 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
882 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
883 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
884 NULL to indicate that the set operation was not actually performed.
885 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
886 MaximumDatumSize and NULL must be returned.
888 If PatchVariable is NULL, then ASSERT().
889 If SizeOfBuffer is NULL, then ASSERT().
890 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
892 @param[in] PatchVariable A pointer to the global variable in a module that is
893 the target of the set operation.
894 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
895 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
896 @param[in] Buffer A pointer to the buffer to used to set the target variable.
898 @return Return the pointer to the buffer been set.
904 IN VOID
*PatchVariable
,
905 IN UINTN MaximumDatumSize
,
906 IN OUT UINTN
*SizeOfBuffer
,
907 IN CONST VOID
*Buffer
910 ASSERT (PatchVariable
!= NULL
);
911 ASSERT (SizeOfBuffer
!= NULL
);
913 if (*SizeOfBuffer
> 0) {
914 ASSERT (Buffer
!= NULL
);
917 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
918 (*SizeOfBuffer
== MAX_ADDRESS
)) {
919 *SizeOfBuffer
= MaximumDatumSize
;
923 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
925 return (VOID
*) Buffer
;