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 (SkuId
< 0x100);
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.
63 Returns the 16-bit value for the token specified by TokenNumber.
65 @param[in] The PCD token number to retrieve a current value for.
67 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
82 Returns the 32-bit value for the token specified by TokenNumber.
84 @param[in] TokenNumber The PCD token number to retrieve a current value for.
86 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
101 Returns the 64-bit value for the token specified by TokenNumber.
103 @param[in] TokenNumber The PCD token number to retrieve a current value for.
105 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
120 Returns the pointer to the buffer of the token specified by TokenNumber.
122 @param[in] TokenNumber The PCD token number to retrieve a current value for.
124 @retval VOID* Returns the pointer to the token specified by TokenNumber.
139 Returns the Boolean value of the token specified by TokenNumber.
141 @param[in] TokenNumber The PCD token number to retrieve a current value for.
143 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
158 Returns the size of the token specified by TokenNumber.
160 @param[in] TokenNumber The PCD token number to retrieve a current value for.
162 @retval UINTN Returns the size of the token specified by TokenNumber.
177 Returns the 8-bit value for the token specified by TokenNumber and Guid.
178 If Guid is NULL, then ASSERT().
180 @param[in] Guid Pointer to a 128-bit unique value that designates
181 which namespace to retrieve a value from.
182 @param[in] TokenNumber The PCD token number to retrieve a current value for.
184 @retval UINT8 Return the UINT8.
194 ASSERT (Guid
!= NULL
);
202 Returns the 16-bit value for the token specified by TokenNumber and Guid.
203 If Guid is NULL, then ASSERT().
205 @param[in] Guid Pointer to a 128-bit unique value that designates
206 which namespace to retrieve a value from.
207 @param[in] TokenNumber The PCD token number to retrieve a current value for.
209 @retval UINT16 Return the UINT16.
219 ASSERT (Guid
!= NULL
);
227 Returns the 32-bit value for the token specified by TokenNumber and Guid.
228 If Guid is NULL, then ASSERT().
230 @param[in] Guid Pointer to a 128-bit unique value that designates
231 which namespace to retrieve a value from.
232 @param[in] TokenNumber The PCD token number to retrieve a current value for.
234 @retval UINT32 Return the UINT32.
244 ASSERT (Guid
!= NULL
);
252 Returns the 64-bit value for the token specified by TokenNumber and Guid.
253 If Guid is NULL, then ASSERT().
255 @param[in] Guid Pointer to a 128-bit unique value that designates
256 which namespace to retrieve a value from.
257 @param[in] TokenNumber The PCD token number to retrieve a current value for.
259 @retval UINT64 Return the UINT64.
269 ASSERT (Guid
!= NULL
);
277 Returns the pointer to the buffer of the token specified by TokenNumber and Guid.
278 If Guid is NULL, then ASSERT().
280 @param[in] Guid Pointer to a 128-bit unique value that designates
281 which namespace to retrieve a value from.
282 @param[in] TokenNumber The PCD token number to retrieve a current value for.
284 @retval VOID* Return the VOID* pointer.
294 ASSERT (Guid
!= NULL
);
302 Returns the Boolean value of the token specified by TokenNumber and Guid.
303 If Guid is NULL, then ASSERT().
305 @param[in] Guid Pointer to a 128-bit unique value that designates
306 which namespace to retrieve a value from.
307 @param[in] TokenNumber The PCD token number to retrieve a current value for.
309 @retval BOOLEAN Return the BOOLEAN.
319 ASSERT (Guid
!= NULL
);
327 Returns the size 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 UINTN Return the size.
344 ASSERT (Guid
!= NULL
);
352 Sets the 8-bit value for the token specified by TokenNumber
353 to the value specified by Value. Value is returned.
355 @param[in] TokenNumber The PCD token number to set a current value for.
356 @param[in] Value The 8-bit value to set.
358 @retval UINT8 Return the value been set.
364 IN UINTN TokenNumber
,
374 Sets the 16-bit value for the token specified by TokenNumber
375 to the value specified by Value. Value is returned.
377 @param[in] TokenNumber The PCD token number to set a current value for.
378 @param[in] Value The 16-bit value to set.
380 @retval UINT16 Return the value been set.
386 IN UINTN TokenNumber
,
396 Sets the 32-bit value for the token specified by TokenNumber
397 to the value specified by Value. Value is returned.
399 @param[in] TokenNumber The PCD token number to set a current value for.
400 @param[in] Value The 32-bit value to set.
402 @retval UINT32 Return the value been set.
408 IN UINTN TokenNumber
,
418 Sets the 64-bit value for the token specified by TokenNumber
419 to the value specified by Value. Value is returned.
421 @param[in] TokenNumber The PCD token number to set a current value for.
422 @param[in] Value The 64-bit value to set.
424 @retval UINT64 Return the value been set.
430 IN UINTN TokenNumber
,
440 Sets a buffer for the token specified by TokenNumber to
441 the value specified by Buffer and SizeOfValue. Buffer to
442 be set is returned. The content of the buffer could be
443 overwritten if a Callback on SET is registered with this
446 If SizeOfValue is greater than the maximum
447 size support by TokenNumber, then set SizeOfValue to the
448 maximum size supported by TokenNumber and return NULL to
449 indicate that the set operation was not actually performed.
451 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
453 @param[in] TokenNumber The PCD token number to set a current value for.
454 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
455 @param[in] Value A pointer to the buffer to set.
457 @retval VOID* Return the pointer for the buffer been set.
463 IN UINTN TokenNumber
,
464 IN OUT UINTN
*SizeOfBuffer
,
468 ASSERT (SizeOfBuffer
!= NULL
);
470 if (*SizeOfBuffer
> 0) {
471 ASSERT (Buffer
!= NULL
);
480 Sets the Boolean value for the token specified by TokenNumber
481 to the value specified by Value. Value is returned.
483 @param[in] TokenNumber The PCD token number to set a current value for.
484 @param[in] Value The boolean value to set.
486 @retval BOOLEAN Return the value been set.
492 IN UINTN TokenNumber
,
502 Sets the 8-bit value for the token specified by TokenNumber and
503 Guid to the value specified by Value. Value is returned.
504 If Guid is NULL, then ASSERT().
506 @param[in] Guid Pointer to a 128-bit unique value that
507 designates which namespace to set a value from.
508 @param[in] TokenNumber The PCD token number to set a current value for.
509 @param[in] Value The 8-bit value to set.
511 @retval UINT8 Return the value been set.
518 IN UINTN TokenNumber
,
522 ASSERT (Guid
!= NULL
);
530 Sets the 16-bit value for the token specified by TokenNumber and
531 Guid to the value specified by Value. Value is returned.
532 If Guid is NULL, then ASSERT().
534 @param[in] Guid Pointer to a 128-bit unique value that
535 designates which namespace to set a value from.
536 @param[in] TokenNumber The PCD token number to set a current value for.
537 @param[in] Value The 16-bit value to set.
539 @retval UINT8 Return the value been set.
546 IN UINTN TokenNumber
,
550 ASSERT (Guid
!= NULL
);
558 Sets the 32-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 32-bit value to set.
567 @retval UINT32 Return the value been set.
574 IN UINTN TokenNumber
,
578 ASSERT (Guid
!= NULL
);
586 Sets the 64-bit value for the token specified by TokenNumber and
587 Guid to the value specified by Value. Value is returned.
588 If Guid 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] Value The 64-bit value to set.
595 @retval UINT64 Return the value been set.
602 IN UINTN TokenNumber
,
606 ASSERT (Guid
!= NULL
);
614 Sets a buffer for the token specified by TokenNumber to the value specified by
615 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
616 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
617 supported by TokenNumber and return NULL to indicate that the set operation
618 was not actually performed.
620 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
622 @param[in] Guid Pointer to a 128-bit unique value that
623 designates which namespace to set a value from.
624 @param[in] TokenNumber The PCD token number to set a current value for.
625 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
626 @param[in] Buffer A pointer to the buffer to set.
628 @retval VOID * Return the pinter to the buffer been set.
635 IN UINTN TokenNumber
,
636 IN OUT UINTN
*SizeOfBuffer
,
640 ASSERT (Guid
!= NULL
);
642 ASSERT (SizeOfBuffer
!= NULL
);
644 if (*SizeOfBuffer
> 0) {
645 ASSERT (Buffer
!= NULL
);
654 Sets the Boolean value for the token specified by TokenNumber and
655 Guid to the value specified by Value. Value is returned.
656 If Guid is NULL, then ASSERT().
658 @param[in] Guid Pointer to a 128-bit unique value that
659 designates which namespace to set a value from.
660 @param[in] TokenNumber The PCD token number to set a current value for.
661 @param[in] Value The Boolean value to set.
663 @retval Boolean Return the value been set.
670 IN UINTN TokenNumber
,
674 ASSERT (Guid
!= NULL
);
682 When the token specified by TokenNumber and Guid is set,
683 then notification function specified by NotificationFunction is called.
684 If Guid is NULL, then the default token space is used.
685 If NotificationFunction is NULL, then ASSERT().
687 @param[in] Guid Pointer to a 128-bit unique value that designates which
688 namespace to set a value from. If NULL, then the default
690 @param[in] TokenNumber The PCD token number to monitor.
691 @param[in] NotificationFunction The function to call when the token
692 specified by Guid and TokenNumber is set.
699 LibPcdCallbackOnSet (
700 IN CONST GUID
*Guid
, OPTIONAL
701 IN UINTN TokenNumber
,
702 IN PCD_CALLBACK NotificationFunction
705 ASSERT (NotificationFunction
!= NULL
);
711 Disable a notification function that was established with LibPcdCallbackonSet().
712 If NotificationFunction is NULL, then ASSERT().
714 @param[in] Guid Specify the GUID token space.
715 @param[in] TokenNumber Specify the token number.
716 @param[in] NotificationFunction The callback function to be unregistered.
723 LibPcdCancelCallback (
724 IN CONST GUID
*Guid
, OPTIONAL
725 IN UINTN TokenNumber
,
726 IN PCD_CALLBACK NotificationFunction
729 ASSERT (NotificationFunction
!= NULL
);
735 Retrieves the next PCD token number from the token space specified by Guid.
736 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
737 then the first token number is returned. Otherwise, the token number that
738 follows TokenNumber in the token space is returned. If TokenNumber is the last
739 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
740 is not in the token space specified by Guid, then ASSERT().
742 @param[in] Pointer to a 128-bit unique value that designates which namespace
743 to set a value from. If NULL, then the default token space is used.
744 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
747 @retval UINTN The next valid token number.
753 IN CONST GUID
*Guid
, OPTIONAL
763 Retrieves the next PCD token space from a token space specified by Guid.
764 Guid of NULL is reserved to mark the default local token namespace on the current
765 platform. If Guid is NULL, then the GUID of the first non-local token space of the
766 current platform is returned. If Guid is the last non-local token space,
767 then NULL is returned.
769 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
773 @param[in] Pointer to a 128-bit unique value that designates from which namespace
776 @retval CONST GUID * The next valid token namespace.
781 LibPcdGetNextTokenSpace (
791 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
792 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
793 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
794 NULL to indicate that the set operation was not actually performed.
795 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
796 MaximumDatumSize and NULL must be returned.
798 If PatchVariable is NULL, then ASSERT().
799 If SizeOfValue is NULL, then ASSERT().
800 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
802 @param[in] PatchVariable A pointer to the global variable in a module that is
803 the target of the set operation.
804 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
805 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
806 @param[in] Buffer A pointer to the buffer to used to set the target variable.
812 IN VOID
*PatchVariable
,
813 IN UINTN MaximumDatumSize
,
814 IN OUT UINTN
*SizeOfBuffer
,
815 IN CONST VOID
*Buffer
818 ASSERT (PatchVariable
!= NULL
);
819 ASSERT (SizeOfBuffer
!= NULL
);
821 if (*SizeOfBuffer
> 0) {
822 ASSERT (Buffer
!= NULL
);
825 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
826 (*SizeOfBuffer
== MAX_ADDRESS
)) {
827 *SizeOfBuffer
= MaximumDatumSize
;
831 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
833 return (VOID
*) Buffer
;