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.
17 #include <Library/DebugLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/BaseMemoryLib.h>
23 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
25 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
26 set values associated with a PCD token.
28 @retval SKU_ID Return the SKU ID that just be set.
37 ASSERT (SkuId
< 0x100);
45 Returns the 8-bit value for the token specified by TokenNumber.
47 @param[in] The PCD token number to retrieve a current value for.
49 @retval UINT8 Returns the 8-bit value for the token specified by TokenNumber.
64 Returns the 16-bit value for the token specified by TokenNumber.
66 @param[in] The PCD token number to retrieve a current value for.
68 @retval UINT16 Returns the 16-bit value for the token specified by TokenNumber.
83 Returns the 32-bit value for the token specified by TokenNumber.
85 @param[in] TokenNumber The PCD token number to retrieve a current value for.
87 @retval UINT32 Returns the 32-bit value for the token specified by TokenNumber.
102 Returns the 64-bit value for the token specified by TokenNumber.
104 @param[in] TokenNumber The PCD token number to retrieve a current value for.
106 @retval UINT64 Returns the 64-bit value for the token specified by TokenNumber.
121 Returns the pointer to the buffer of the token specified by TokenNumber.
123 @param[in] TokenNumber The PCD token number to retrieve a current value for.
125 @retval VOID* Returns the pointer to the token specified by TokenNumber.
140 Returns the Boolean value of the token specified by TokenNumber.
142 @param[in] TokenNumber The PCD token number to retrieve a current value for.
144 @retval BOOLEAN Returns the Boolean value of the token specified by TokenNumber.
159 Returns the size of the token specified by TokenNumber.
161 @param[in] TokenNumber The PCD token number to retrieve a current value for.
163 @retval UINTN Returns the size of the token specified by TokenNumber.
178 Returns the 8-bit value for the token specified by TokenNumber and Guid.
179 If Guid is NULL, then ASSERT().
181 @param[in] Guid Pointer to a 128-bit unique value that designates
182 which namespace to retrieve a value from.
183 @param[in] TokenNumber The PCD token number to retrieve a current value for.
185 @retval UINT8 Return the UINT8.
195 ASSERT (Guid
!= NULL
);
203 Returns the 16-bit value for the token specified by TokenNumber and Guid.
204 If Guid is NULL, then ASSERT().
206 @param[in] Guid Pointer to a 128-bit unique value that designates
207 which namespace to retrieve a value from.
208 @param[in] TokenNumber The PCD token number to retrieve a current value for.
210 @retval UINT16 Return the UINT16.
220 ASSERT (Guid
!= NULL
);
228 Returns the 32-bit value for the token specified by TokenNumber and Guid.
229 If Guid is NULL, then ASSERT().
231 @param[in] Guid Pointer to a 128-bit unique value that designates
232 which namespace to retrieve a value from.
233 @param[in] TokenNumber The PCD token number to retrieve a current value for.
235 @retval UINT32 Return the UINT32.
245 ASSERT (Guid
!= NULL
);
253 Returns the 64-bit value for the token specified by TokenNumber and Guid.
254 If Guid is NULL, then ASSERT().
256 @param[in] Guid Pointer to a 128-bit unique value that designates
257 which namespace to retrieve a value from.
258 @param[in] TokenNumber The PCD token number to retrieve a current value for.
260 @retval UINT64 Return the UINT64.
270 ASSERT (Guid
!= NULL
);
278 Returns the pointer to the buffer of the token specified by TokenNumber and Guid.
279 If Guid is NULL, then ASSERT().
281 @param[in] Guid Pointer to a 128-bit unique value that designates
282 which namespace to retrieve a value from.
283 @param[in] TokenNumber The PCD token number to retrieve a current value for.
285 @retval VOID* Return the VOID* pointer.
295 ASSERT (Guid
!= NULL
);
303 Returns the Boolean value of the token specified by TokenNumber and Guid.
304 If Guid is NULL, then ASSERT().
306 @param[in] Guid Pointer to a 128-bit unique value that designates
307 which namespace to retrieve a value from.
308 @param[in] TokenNumber The PCD token number to retrieve a current value for.
310 @retval BOOLEAN Return the BOOLEAN.
320 ASSERT (Guid
!= NULL
);
328 Returns the size of the token specified by TokenNumber and Guid.
329 If Guid is NULL, then ASSERT().
331 @param[in] Guid Pointer to a 128-bit unique value that designates
332 which namespace to retrieve a value from.
333 @param[in] TokenNumber The PCD token number to retrieve a current value for.
335 @retval UINTN Return the size.
345 ASSERT (Guid
!= NULL
);
353 Sets the 8-bit value for the token specified by TokenNumber
354 to the value specified by Value. Value is returned.
356 @param[in] TokenNumber The PCD token number to set a current value for.
357 @param[in] Value The 8-bit value to set.
359 @retval UINT8 Return the value been set.
365 IN UINTN TokenNumber
,
375 Sets the 16-bit value for the token specified by TokenNumber
376 to the value specified by Value. Value is returned.
378 @param[in] TokenNumber The PCD token number to set a current value for.
379 @param[in] Value The 16-bit value to set.
381 @retval UINT16 Return the value been set.
387 IN UINTN TokenNumber
,
397 Sets the 32-bit value for the token specified by TokenNumber
398 to the value specified by Value. Value is returned.
400 @param[in] TokenNumber The PCD token number to set a current value for.
401 @param[in] Value The 32-bit value to set.
403 @retval UINT32 Return the value been set.
409 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
,
441 Sets a buffer for the token specified by TokenNumber to
442 the value specified by Buffer and SizeOfValue. Buffer to
443 be set is returned. The content of the buffer could be
444 overwritten if a Callback on SET is registered with this
447 If SizeOfValue is greater than the maximum
448 size support by TokenNumber, then set SizeOfValue to the
449 maximum size supported by TokenNumber and return NULL to
450 indicate that the set operation was not actually performed.
452 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
454 @param[in] TokenNumber The PCD token number to set a current value for.
455 @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.
456 @param[in] Value A pointer to the buffer to set.
458 @retval VOID* Return the pointer for the buffer been set.
464 IN UINTN TokenNumber
,
465 IN OUT UINTN
*SizeOfBuffer
,
469 ASSERT (SizeOfBuffer
!= NULL
);
471 if (*SizeOfBuffer
> 0) {
472 ASSERT (Buffer
!= NULL
);
481 Sets the Boolean value for the token specified by TokenNumber
482 to the value specified by Value. Value is returned.
484 @param[in] TokenNumber The PCD token number to set a current value for.
485 @param[in] Value The boolean value to set.
487 @retval BOOLEAN Return the value been set.
493 IN UINTN TokenNumber
,
503 Sets the 8-bit value for the token specified by TokenNumber and
504 Guid to the value specified by Value. Value is returned.
505 If Guid is NULL, then ASSERT().
507 @param[in] Guid Pointer to a 128-bit unique value that
508 designates which namespace to set a value from.
509 @param[in] TokenNumber The PCD token number to set a current value for.
510 @param[in] Value The 8-bit value to set.
512 @retval UINT8 Return the value been set.
519 IN UINTN TokenNumber
,
523 ASSERT (Guid
!= NULL
);
531 Sets the 16-bit value for the token specified by TokenNumber and
532 Guid to the value specified by Value. Value is returned.
533 If Guid is NULL, then ASSERT().
535 @param[in] Guid Pointer to a 128-bit unique value that
536 designates which namespace to set a value from.
537 @param[in] TokenNumber The PCD token number to set a current value for.
538 @param[in] Value The 16-bit value to set.
540 @retval UINT8 Return the value been set.
547 IN UINTN TokenNumber
,
551 ASSERT (Guid
!= NULL
);
559 Sets the 32-bit value for the token specified by TokenNumber and
560 Guid to the value specified by Value. Value is returned.
561 If Guid is NULL, then ASSERT().
563 @param[in] Guid Pointer to a 128-bit unique value that
564 designates which namespace to set a value from.
565 @param[in] TokenNumber The PCD token number to set a current value for.
566 @param[in] Value The 32-bit value to set.
568 @retval UINT32 Return the value been set.
575 IN UINTN TokenNumber
,
579 ASSERT (Guid
!= NULL
);
587 Sets the 64-bit value for the token specified by TokenNumber and
588 Guid to the value specified by Value. Value is returned.
589 If Guid is NULL, then ASSERT().
591 @param[in] Guid Pointer to a 128-bit unique value that
592 designates which namespace to set a value from.
593 @param[in] TokenNumber The PCD token number to set a current value for.
594 @param[in] Value The 64-bit value to set.
596 @retval UINT64 Return the value been set.
603 IN UINTN TokenNumber
,
607 ASSERT (Guid
!= NULL
);
615 Sets a buffer for the token specified by TokenNumber to the value specified by
616 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
617 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
618 supported by TokenNumber and return NULL to indicate that the set operation
619 was not actually performed.
621 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
623 @param[in] Guid Pointer to a 128-bit unique value that
624 designates which namespace to set a value from.
625 @param[in] TokenNumber The PCD token number to set a current value for.
626 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
627 @param[in] Buffer A pointer to the buffer to set.
629 @retval VOID * Return the pinter to the buffer been set.
636 IN UINTN TokenNumber
,
637 IN OUT UINTN
*SizeOfBuffer
,
641 ASSERT (Guid
!= NULL
);
643 ASSERT (SizeOfBuffer
!= NULL
);
645 if (*SizeOfBuffer
> 0) {
646 ASSERT (Buffer
!= NULL
);
655 Sets the Boolean value for the token specified by TokenNumber and
656 Guid to the value specified by Value. Value is returned.
657 If Guid is NULL, then ASSERT().
659 @param[in] Guid Pointer to a 128-bit unique value that
660 designates which namespace to set a value from.
661 @param[in] TokenNumber The PCD token number to set a current value for.
662 @param[in] Value The Boolean value to set.
664 @retval Boolean Return the value been set.
671 IN UINTN TokenNumber
,
675 ASSERT (Guid
!= NULL
);
683 When the token specified by TokenNumber and Guid is set,
684 then notification function specified by NotificationFunction is called.
685 If Guid is NULL, then the default token space is used.
686 If NotificationFunction is NULL, then ASSERT().
688 @param[in] Guid Pointer to a 128-bit unique value that designates which
689 namespace to set a value from. If NULL, then the default
691 @param[in] TokenNumber The PCD token number to monitor.
692 @param[in] NotificationFunction The function to call when the token
693 specified by Guid and TokenNumber is set.
700 LibPcdCallbackOnSet (
701 IN CONST GUID
*Guid
, OPTIONAL
702 IN UINTN TokenNumber
,
703 IN PCD_CALLBACK NotificationFunction
706 ASSERT (NotificationFunction
!= NULL
);
712 Disable a notification function that was established with LibPcdCallbackonSet().
713 If NotificationFunction is NULL, then ASSERT().
715 @param[in] Guid Specify the GUID token space.
716 @param[in] TokenNumber Specify the token number.
717 @param[in] NotificationFunction The callback function to be unregistered.
724 LibPcdCancelCallback (
725 IN CONST GUID
*Guid
, OPTIONAL
726 IN UINTN TokenNumber
,
727 IN PCD_CALLBACK NotificationFunction
730 ASSERT (NotificationFunction
!= NULL
);
736 Retrieves the next PCD token number from the token space specified by Guid.
737 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
738 then the first token number is returned. Otherwise, the token number that
739 follows TokenNumber in the token space is returned. If TokenNumber is the last
740 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
741 is not in the token space specified by Guid, then ASSERT().
743 @param[in] Pointer to a 128-bit unique value that designates which namespace
744 to set a value from. If NULL, then the default token space is used.
745 @param[in] The previous PCD token number. If 0, then retrieves the first PCD
748 @retval UINTN The next valid token number.
754 IN CONST GUID
*Guid
, OPTIONAL
764 Retrieves the next PCD token space from a token space specified by Guid.
765 Guid of NULL is reserved to mark the default local token namespace on the current
766 platform. If Guid is NULL, then the GUID of the first non-local token space of the
767 current platform is returned. If Guid is the last non-local token space,
768 then NULL is returned.
770 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
774 @param[in] Pointer to a 128-bit unique value that designates from which namespace
777 @retval CONST GUID * The next valid token namespace.
782 LibPcdGetNextTokenSpace (
792 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
793 and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
794 MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return
795 NULL to indicate that the set operation was not actually performed.
796 If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to
797 MaximumDatumSize and NULL must be returned.
799 If PatchVariable is NULL, then ASSERT().
800 If SizeOfValue is NULL, then ASSERT().
801 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
803 @param[in] PatchVariable A pointer to the global variable in a module that is
804 the target of the set operation.
805 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
806 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
807 @param[in] Buffer A pointer to the buffer to used to set the target variable.
813 IN VOID
*PatchVariable
,
814 IN UINTN MaximumDatumSize
,
815 IN OUT UINTN
*SizeOfBuffer
,
816 IN CONST VOID
*Buffer
819 ASSERT (PatchVariable
!= NULL
);
820 ASSERT (SizeOfBuffer
!= NULL
);
822 if (*SizeOfBuffer
> 0) {
823 ASSERT (Buffer
!= NULL
);
826 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
827 (*SizeOfBuffer
== MAX_ADDRESS
)) {
828 *SizeOfBuffer
= MaximumDatumSize
;
832 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
834 return (VOID
*) Buffer
;