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
);
44 Returns the 8-bit value for the token specified by TokenNumber.
46 @param[in] The PCD token number to retrieve a current value for.
48 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
57 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
65 Returns the 16-bit value for the token specified by TokenNumber.
67 @param[in] The PCD token number to retrieve a current value for.
69 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
78 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
86 Returns the 32-bit value for the token specified by TokenNumber.
88 @param[in] TokenNumber The PCD token number to retrieve a current value for.
90 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
99 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
107 Returns the 64-bit value for the token specified by TokenNumber.
109 @param[in] TokenNumber The PCD token number to retrieve a current value for.
111 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
120 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
128 Returns the pointer to the buffer of the token specified by TokenNumber.
130 @param[in] TokenNumber The PCD token number to retrieve a current value for.
132 @retval VOID* Returns the pointer to the token specified by TokenNumber.
141 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
149 Returns the Boolean value of the token specified by TokenNumber.
151 @param[in] TokenNumber The PCD token number to retrieve a current value for.
153 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
162 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
170 Returns the size of the token specified by TokenNumber.
172 @param[in] TokenNumber The PCD token number to retrieve a current value for.
174 @retval UINTN Returns the size of the token specified by TokenNumber.
183 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
191 Returns the 8-bit value for the token specified by TokenNumber and Guid.
192 If Guid is NULL, then ASSERT().
194 @param[in] Guid Pointer to a 128-bit unique value that designates
195 which namespace to retrieve a value from.
196 @param[in] TokenNumber The PCD token number to retrieve a current value for.
198 @retval UINT8 Return the UINT8.
208 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
216 Returns the 16-bit value for the token specified by TokenNumber and Guid.
217 If Guid is NULL, then ASSERT().
219 @param[in] Guid Pointer to a 128-bit unique value that designates
220 which namespace to retrieve a value from.
221 @param[in] TokenNumber The PCD token number to retrieve a current value for.
223 @retval UINT16 Return the UINT16.
233 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
241 Returns the 32-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 @retval UINT32 Return the UINT32.
258 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
266 Returns the 64-bit value for the token specified by TokenNumber and Guid.
267 If Guid is NULL, then ASSERT().
269 @param[in] Guid Pointer to a 128-bit unique value that designates
270 which namespace to retrieve a value from.
271 @param[in] TokenNumber The PCD token number to retrieve a current value for.
273 @retval UINT64 Return the UINT64.
283 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
291 Returns the pointer to the buffer of the token specified by TokenNumber and Guid.
292 If Guid is NULL, then ASSERT().
294 @param[in] Guid Pointer to a 128-bit unique value that designates
295 which namespace to retrieve a value from.
296 @param[in] TokenNumber The PCD token number to retrieve a current value for.
298 @retval VOID* Return the VOID* pointer.
308 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
316 Returns the Boolean value of the 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 @retval BOOLEAN Return the BOOLEAN.
333 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
341 Returns the size of the token specified by TokenNumber and Guid.
342 If Guid is NULL, then ASSERT().
344 @param[in] Guid Pointer to a 128-bit unique value that designates
345 which namespace to retrieve a value from.
346 @param[in] TokenNumber The PCD token number to retrieve a current value for.
348 @retval UINTN Return the size.
358 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
366 Sets the 8-bit value for the token specified by TokenNumber
367 to the value specified by Value. Value is returned.
369 @param[in] TokenNumber The PCD token number to set a current value for.
370 @param[in] Value The 8-bit value to set.
372 @retval UINT8 Return the value been set.
378 IN UINTN TokenNumber
,
382 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
390 Sets the 16-bit value for the token specified by TokenNumber
391 to the value specified by Value. Value is returned.
393 @param[in] TokenNumber The PCD token number to set a current value for.
394 @param[in] Value The 16-bit value to set.
396 @retval UINT16 Return the value been set.
402 IN UINTN TokenNumber
,
406 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
414 Sets the 32-bit value for the token specified by TokenNumber
415 to the value specified by Value. Value is returned.
417 @param[in] TokenNumber The PCD token number to set a current value for.
418 @param[in] Value The 32-bit value to set.
420 @retval UINT32 Return the value been set.
426 IN UINTN TokenNumber
,
430 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
438 Sets the 64-bit value for the token specified by TokenNumber
439 to the value specified by Value. Value is returned.
441 @param[in] TokenNumber The PCD token number to set a current value for.
442 @param[in] Value The 64-bit value to set.
444 @retval UINT64 Return the value been set.
450 IN UINTN TokenNumber
,
454 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
462 Sets a buffer for the token specified by TokenNumber to
463 the value specified by Buffer and SizeOfValue. Buffer to
464 be set is returned. The content of the buffer could be
465 overwritten if a Callback on SET is registered with this
468 If SizeOfValue is greater than the maximum
469 size support by TokenNumber, then set SizeOfValue to the
470 maximum size supported by TokenNumber and return NULL to
471 indicate that the set operation was not actually performed.
473 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
475 @param[in] TokenNumber The PCD token number to set a current value for.
476 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
477 @param[in] Value A pointer to the buffer to set.
479 @retval VOID* Return the pointer for the buffer been set.
485 IN UINTN TokenNumber
,
486 IN OUT UINTN
*SizeOfBuffer
,
490 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
498 Sets the Boolean value for the token specified by TokenNumber
499 to the value specified by Value. Value is returned.
501 @param[in] TokenNumber The PCD token number to set a current value for.
502 @param[in] Value The boolean value to set.
504 @retval BOOLEAN Return the value been set.
510 IN UINTN TokenNumber
,
514 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
522 Sets the 8-bit value for the token specified by TokenNumber and
523 Guid to the value specified by Value. Value is returned.
524 If Guid is NULL, then ASSERT().
526 @param[in] Guid Pointer to a 128-bit unique value that
527 designates which namespace to set a value from.
528 @param[in] TokenNumber The PCD token number to set a current value for.
529 @param[in] Value The 8-bit value to set.
531 @retval UINT8 Return the value been set.
538 IN UINTN TokenNumber
,
542 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
550 Sets the 16-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 16-bit value to set.
559 @retval UINT8 Return the value been set.
566 IN UINTN TokenNumber
,
570 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
578 Sets the 32-bit value for the token specified by TokenNumber and
579 Guid to the value specified by Value. Value is returned.
580 If Guid 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] Value The 32-bit value to set.
587 @retval UINT32 Return the value been set.
594 IN UINTN TokenNumber
,
598 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
606 Sets the 64-bit value for the token specified by TokenNumber and
607 Guid to the value specified by Value. Value is returned.
608 If Guid is NULL, then ASSERT().
610 @param[in] Guid Pointer to a 128-bit unique value that
611 designates which namespace to set a value from.
612 @param[in] TokenNumber The PCD token number to set a current value for.
613 @param[in] Value The 64-bit value to set.
615 @retval UINT64 Return the value been set.
622 IN UINTN TokenNumber
,
626 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
634 Sets a buffer for the token specified by TokenNumber to the value specified by
635 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
636 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
637 supported by TokenNumber and return NULL to indicate that the set operation
638 was not actually performed.
640 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
642 @param[in] Guid Pointer to a 128-bit unique value that
643 designates which namespace to set a value from.
644 @param[in] TokenNumber The PCD token number to set a current value for.
645 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
646 @param[in] Buffer A pointer to the buffer to set.
648 @retval VOID * Return the pinter to the buffer been set.
655 IN UINTN TokenNumber
,
656 IN OUT UINTN
*SizeOfBuffer
,
660 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
668 Sets the Boolean value for the token specified by TokenNumber and
669 Guid to the value specified by Value. Value is returned.
670 If Guid is NULL, then ASSERT().
672 @param[in] Guid Pointer to a 128-bit unique value that
673 designates which namespace to set a value from.
674 @param[in] TokenNumber The PCD token number to set a current value for.
675 @param[in] Value The Boolean value to set.
677 @retval Boolean Return the value been set.
684 IN UINTN TokenNumber
,
688 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
696 When the token specified by TokenNumber and Guid is set,
697 then notification function specified by NotificationFunction is called.
698 If Guid is NULL, then the default token space is used.
699 If NotificationFunction is NULL, then ASSERT().
701 @param[in] Guid Pointer to a 128-bit unique value that designates which
702 namespace to set a value from. If NULL, then the default
704 @param[in] TokenNumber The PCD token number to monitor.
705 @param[in] NotificationFunction The function to call when the token
706 specified by Guid and TokenNumber is set.
713 LibPcdCallbackOnSet (
714 IN CONST GUID
*Guid
, OPTIONAL
715 IN UINTN TokenNumber
,
716 IN PCD_CALLBACK NotificationFunction
719 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
725 Disable a notification function that was established with LibPcdCallbackonSet().
726 If NotificationFunction is NULL, then ASSERT().
728 @param[in] Guid Specify the GUID token space.
729 @param[in] TokenNumber Specify the token number.
730 @param[in] NotificationFunction The callback function to be unregistered.
737 LibPcdCancelCallback (
738 IN CONST GUID
*Guid
, OPTIONAL
739 IN UINTN TokenNumber
,
740 IN PCD_CALLBACK NotificationFunction
743 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
749 Retrieves the next PCD token number from the token space specified by Guid.
750 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
751 then the first token number is returned. Otherwise, the token number that
752 follows TokenNumber in the token space is returned. If TokenNumber is the last
753 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
754 is not in the token space specified by Guid, then ASSERT().
756 @param[in] Pointer to a 128-bit unique value that designates which namespace
757 to set a value from. If NULL, then the default token space is used.
758 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
761 @retval UINTN The next valid token number.
767 IN CONST GUID
*Guid
, OPTIONAL
771 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
779 Retrieves the next PCD token space from a token space specified by Guid.
780 Guid of NULL is reserved to mark the default local token namespace on the current
781 platform. If Guid is NULL, then the GUID of the first non-local token space of the
782 current platform is returned. If Guid is the last non-local token space,
783 then NULL is returned.
785 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
789 @param[in] Pointer to a 128-bit unique value that designates from which namespace
792 @retval CONST GUID * The next valid token namespace.
797 LibPcdGetNextTokenSpace (
801 ASSERT_EFI_ERROR (EFI_UNSUPPORTED
);
809 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
810 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
811 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
812 NULL to indicate that the set operation was not actually performed.
813 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
814 MaximumDatumSize and NULL must be returned.
816 If PatchVariable is NULL, then ASSERT().
817 If SizeOfValue is NULL, then ASSERT().
818 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
820 @param[in] PatchVariable A pointer to the global variable in a module that is
821 the target of the set operation.
822 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
823 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
824 @param[in] Buffer A pointer to the buffer to used to set the target variable.
830 IN VOID
*PatchVariable
,
831 IN UINTN MaximumDatumSize
,
832 IN OUT UINTN
*SizeOfBuffer
,
833 IN CONST VOID
*Buffer
836 ASSERT (PatchVariable
!= NULL
);
837 ASSERT (SizeOfBuffer
!= NULL
);
839 if (*SizeOfBuffer
> 0) {
840 ASSERT (Buffer
!= NULL
);
843 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
844 (*SizeOfBuffer
== MAX_ADDRESS
)) {
845 *SizeOfBuffer
= MaximumDatumSize
;
849 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
851 return (VOID
*) Buffer
;