2 A emptry template implementation of PCD Library.
4 Copyright (c) 2006, 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.
16 #include <Library/DebugLib.h>
17 #include <Library/PcdLib.h>
18 #include <Library/BaseMemoryLib.h>
22 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
24 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
25 set values associated with a PCD token.
27 @retval SKU_ID Return the SKU ID that just be set.
36 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
42 Returns the 8-bit value for the token specified by TokenNumber.
44 @param[in] TokenNumber The PCD token number to retrieve a current value for.
46 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
55 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
63 Returns the 16-bit value for the token specified by TokenNumber.
65 @param[in] TokenNumber The PCD token number to retrieve a current value for.
67 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
76 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
84 Returns the 32-bit value for the token specified by TokenNumber.
86 @param[in] TokenNumber The PCD token number to retrieve a current value for.
88 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
97 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
105 Returns the 64-bit value for the token specified by TokenNumber.
107 @param[in] TokenNumber The PCD token number to retrieve a current value for.
109 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
118 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
126 Returns the pointer to the buffer of the token specified by TokenNumber.
128 @param[in] TokenNumber The PCD token number to retrieve a current value for.
130 @retval VOID* Returns the pointer to the token specified by TokenNumber.
139 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
147 Returns the Boolean value of the token specified by TokenNumber.
149 @param[in] TokenNumber The PCD token number to retrieve a current value for.
151 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
160 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
168 Returns the size of the token specified by TokenNumber.
170 @param[in] TokenNumber The PCD token number to retrieve a current value for.
172 @retval UINTN Returns the size of the token specified by TokenNumber.
181 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
189 Returns the 8-bit value for the token specified by TokenNumber and Guid.
190 If Guid is NULL, then ASSERT().
192 @param[in] Guid Pointer to a 128-bit unique value that designates
193 which namespace to retrieve a value from.
194 @param[in] TokenNumber The PCD token number to retrieve a current value for.
196 @retval UINT8 Return the UINT8.
206 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
214 Returns the 16-bit value for the token specified by TokenNumber and Guid.
215 If Guid is NULL, then ASSERT().
217 @param[in] Guid Pointer to a 128-bit unique value that designates
218 which namespace to retrieve a value from.
219 @param[in] TokenNumber The PCD token number to retrieve a current value for.
221 @retval UINT16 Return the UINT16.
231 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
239 Returns the 32-bit value for the token specified by TokenNumber and Guid.
240 If Guid is NULL, then ASSERT().
242 @param[in] Guid Pointer to a 128-bit unique value that designates
243 which namespace to retrieve a value from.
244 @param[in] TokenNumber The PCD token number to retrieve a current value for.
246 @retval UINT32 Return the UINT32.
256 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
264 Returns the 64-bit value for the token specified by TokenNumber and Guid.
265 If Guid is NULL, then ASSERT().
267 @param[in] Guid Pointer to a 128-bit unique value that designates
268 which namespace to retrieve a value from.
269 @param[in] TokenNumber The PCD token number to retrieve a current value for.
271 @retval UINT64 Return the UINT64.
281 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
289 Returns the pointer to the buffer of 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 VOID* Return the VOID* pointer.
306 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
314 Returns the Boolean value of the token specified by TokenNumber and Guid.
315 If Guid is NULL, then ASSERT().
317 @param[in] Guid Pointer to a 128-bit unique value that designates
318 which namespace to retrieve a value from.
319 @param[in] TokenNumber The PCD token number to retrieve a current value for.
321 @retval BOOLEAN Return the BOOLEAN.
331 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
339 Returns the size of the token specified by TokenNumber and Guid.
340 If Guid is NULL, then ASSERT().
342 @param[in] Guid Pointer to a 128-bit unique value that designates
343 which namespace to retrieve a value from.
344 @param[in] TokenNumber The PCD token number to retrieve a current value for.
346 @retval UINTN Return the size.
356 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
364 Sets the 8-bit value for the token specified by TokenNumber
365 to the value specified by Value. Value is returned.
367 @param[in] TokenNumber The PCD token number to set a current value for.
368 @param[in] Value The 8-bit value to set.
370 @retval UINT8 Return the value been set.
376 IN UINTN TokenNumber
,
380 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
388 Sets the 16-bit value for the token specified by TokenNumber
389 to the value specified by Value. Value is returned.
391 @param[in] TokenNumber The PCD token number to set a current value for.
392 @param[in] Value The 16-bit value to set.
394 @retval UINT16 Return the value been set.
400 IN UINTN TokenNumber
,
404 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
412 Sets the 32-bit value for the token specified by TokenNumber
413 to the value specified by Value. Value is returned.
415 @param[in] TokenNumber The PCD token number to set a current value for.
416 @param[in] Value The 32-bit value to set.
418 @retval UINT32 Return the value been set.
424 IN UINTN TokenNumber
,
428 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
436 Sets the 64-bit value for the token specified by TokenNumber
437 to the value specified by Value. Value is returned.
439 @param[in] TokenNumber The PCD token number to set a current value for.
440 @param[in] Value The 64-bit value to set.
442 @retval UINT64 Return the value been set.
448 IN UINTN TokenNumber
,
452 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
460 Sets a buffer for the token specified by TokenNumber to
461 the value specified by Buffer and SizeOfValue. Buffer to
462 be set is returned. The content of the buffer could be
463 overwritten if a Callback on SET is registered with this
466 If SizeOfValue is greater than the maximum
467 size support by TokenNumber, then set SizeOfValue to the
468 maximum size supported by TokenNumber and return NULL to
469 indicate that the set operation was not actually performed.
471 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
473 @param[in] TokenNumber The PCD token number to set a current value for.
474 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
475 @param[in] Buffer A pointer to the buffer to set.
477 @retval VOID* Return the pointer for the buffer been set.
483 IN UINTN TokenNumber
,
484 IN OUT UINTN
*SizeOfBuffer
,
488 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
496 Sets the Boolean value for the token specified by TokenNumber
497 to the value specified by Value. Value is returned.
499 @param[in] TokenNumber The PCD token number to set a current value for.
500 @param[in] Value The boolean value to set.
502 @retval BOOLEAN Return the value been set.
508 IN UINTN TokenNumber
,
512 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
520 Sets the 8-bit value for the token specified by TokenNumber and
521 Guid to the value specified by Value. Value is returned.
522 If Guid is NULL, then ASSERT().
524 @param[in] Guid Pointer to a 128-bit unique value that
525 designates which namespace to set a value from.
526 @param[in] TokenNumber The PCD token number to set a current value for.
527 @param[in] Value The 8-bit value to set.
529 @retval UINT8 Return the value been set.
536 IN UINTN TokenNumber
,
540 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
548 Sets the 16-bit value for the token specified by TokenNumber and
549 Guid to the value specified by Value. Value is returned.
550 If Guid is NULL, then ASSERT().
552 @param[in] Guid Pointer to a 128-bit unique value that
553 designates which namespace to set a value from.
554 @param[in] TokenNumber The PCD token number to set a current value for.
555 @param[in] Value The 16-bit value to set.
557 @retval UINT8 Return the value been set.
564 IN UINTN TokenNumber
,
568 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
576 Sets the 32-bit value for the token specified by TokenNumber and
577 Guid to the value specified by Value. Value is returned.
578 If Guid is NULL, then ASSERT().
580 @param[in] Guid Pointer to a 128-bit unique value that
581 designates which namespace to set a value from.
582 @param[in] TokenNumber The PCD token number to set a current value for.
583 @param[in] Value The 32-bit value to set.
585 @retval UINT32 Return the value been set.
592 IN UINTN TokenNumber
,
596 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
604 Sets the 64-bit value for the token specified by TokenNumber and
605 Guid to the value specified by Value. Value is returned.
606 If Guid is NULL, then ASSERT().
608 @param[in] Guid Pointer to a 128-bit unique value that
609 designates which namespace to set a value from.
610 @param[in] TokenNumber The PCD token number to set a current value for.
611 @param[in] Value The 64-bit value to set.
613 @retval UINT64 Return the value been set.
620 IN UINTN TokenNumber
,
624 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
632 Sets a buffer for the token specified by TokenNumber to the value specified by
633 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
634 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
635 supported by TokenNumber and return NULL to indicate that the set operation
636 was not actually performed.
638 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
640 @param[in] Guid Pointer to a 128-bit unique value that
641 designates which namespace to set a value from.
642 @param[in] TokenNumber The PCD token number to set a current value for.
643 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
644 @param[in] Buffer A pointer to the buffer to set.
646 @retval VOID * Return the pinter to the buffer been set.
653 IN UINTN TokenNumber
,
654 IN OUT UINTN
*SizeOfBuffer
,
658 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
666 Sets the Boolean value for the token specified by TokenNumber and
667 Guid to the value specified by Value. Value is returned.
668 If Guid is NULL, then ASSERT().
670 @param[in] Guid Pointer to a 128-bit unique value that
671 designates which namespace to set a value from.
672 @param[in] TokenNumber The PCD token number to set a current value for.
673 @param[in] Value The Boolean value to set.
675 @retval Boolean Return the value been set.
682 IN UINTN TokenNumber
,
686 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
694 When the token specified by TokenNumber and Guid is set,
695 then notification function specified by NotificationFunction is called.
696 If Guid is NULL, then the default token space is used.
697 If NotificationFunction is NULL, then ASSERT().
699 @param[in] Guid Pointer to a 128-bit unique value that designates which
700 namespace to set a value from. If NULL, then the default
702 @param[in] TokenNumber The PCD token number to monitor.
703 @param[in] NotificationFunction The function to call when the token
704 specified by Guid and TokenNumber is set.
711 LibPcdCallbackOnSet (
712 IN CONST GUID
*Guid
, OPTIONAL
713 IN UINTN TokenNumber
,
714 IN PCD_CALLBACK NotificationFunction
717 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
723 Disable a notification function that was established with LibPcdCallbackonSet().
724 If NotificationFunction is NULL, then ASSERT().
726 @param[in] Guid Specify the GUID token space.
727 @param[in] TokenNumber Specify the token number.
728 @param[in] NotificationFunction The callback function to be unregistered.
735 LibPcdCancelCallback (
736 IN CONST GUID
*Guid
, OPTIONAL
737 IN UINTN TokenNumber
,
738 IN PCD_CALLBACK NotificationFunction
741 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
747 Retrieves the next PCD token number from the token space specified by Guid.
748 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
749 then the first token number is returned. Otherwise, the token number that
750 follows TokenNumber in the token space is returned. If TokenNumber is the last
751 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
752 is not in the token space specified by Guid, then ASSERT().
754 @param[in] Guid Pointer to a 128-bit unique value that designates which namespace
755 to set a value from. If NULL, then the default token space is used.
756 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
759 @retval UINTN The next valid token number.
765 IN CONST GUID
*Guid
, OPTIONAL
769 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
777 Retrieves the next PCD token space from a token space specified by Guid.
778 Guid of NULL is reserved to mark the default local token namespace on the current
779 platform. If Guid is NULL, then the GUID of the first non-local token space of the
780 current platform is returned. If Guid is the last non-local token space,
781 then NULL is returned.
783 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
787 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
790 @retval CONST GUID * The next valid token namespace.
795 LibPcdGetNextTokenSpace (
799 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
807 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
808 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
809 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
810 NULL to indicate that the set operation was not actually performed.
811 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
812 MaximumDatumSize and NULL must be returned.
814 If PatchVariable is NULL, then ASSERT().
815 If SizeOfValue is NULL, then ASSERT().
816 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
818 @param[in] PatchVariable A pointer to the global variable in a module that is
819 the target of the set operation.
820 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
821 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
822 @param[in] Buffer A pointer to the buffer to used to set the target variable.
828 IN VOID
*PatchVariable
,
829 IN UINTN MaximumDatumSize
,
830 IN OUT UINTN
*SizeOfBuffer
,
831 IN CONST VOID
*Buffer
834 ASSERT (PatchVariable
!= NULL
);
835 ASSERT (SizeOfBuffer
!= NULL
);
837 if (*SizeOfBuffer
> 0) {
838 ASSERT (Buffer
!= NULL
);
841 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
842 (*SizeOfBuffer
== MAX_ADDRESS
)) {
843 *SizeOfBuffer
= MaximumDatumSize
;
847 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
849 return (VOID
*) Buffer
;