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 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 @return Return the SKU ID that just be set.
43 Returns the 8-bit value for the token specified by TokenNumber.
45 @param[in] TokenNumber The PCD token number to retrieve a current value for.
47 @return 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] TokenNumber The PCD token number to retrieve a current value for.
68 @return Returns the 16-bit value for the token specified by TokenNumber.
85 Returns the 32-bit value for the token specified by TokenNumber.
87 @param[in] TokenNumber The PCD token number to retrieve a current value for.
89 @return Returns the 32-bit value for the token specified by TokenNumber.
106 Returns the 64-bit value for the token specified by TokenNumber.
108 @param[in] TokenNumber The PCD token number to retrieve a current value for.
110 @return Returns the 64-bit value for the token specified by TokenNumber.
127 Returns the pointer to the buffer of the token specified by TokenNumber.
129 @param[in] TokenNumber The PCD token number to retrieve a current value for.
131 @return Returns the pointer to the token specified by TokenNumber.
148 Returns the Boolean value of the token specified by TokenNumber.
150 @param[in] TokenNumber The PCD token number to retrieve a current value for.
152 @return Returns the Boolean value of the token specified by TokenNumber.
169 Returns the size of the token specified by TokenNumber.
171 @param[in] TokenNumber The PCD token number to retrieve a current value for.
173 @return Returns the size of the token specified by TokenNumber.
190 Returns the 8-bit value for the token specified by TokenNumber and Guid.
191 If Guid is NULL, then ASSERT().
193 @param[in] Guid Pointer to a 128-bit unique value that designates
194 which namespace to retrieve a value from.
195 @param[in] TokenNumber The PCD token number to retrieve a current value for.
197 @return Return the UINT8.
215 Returns the 16-bit value for the token specified by TokenNumber and Guid.
216 If Guid is NULL, then ASSERT().
218 @param[in] Guid Pointer to a 128-bit unique value that designates
219 which namespace to retrieve a value from.
220 @param[in] TokenNumber The PCD token number to retrieve a current value for.
222 @return Return the UINT16.
240 Returns the 32-bit value for the token specified by TokenNumber and Guid.
241 If Guid is NULL, then ASSERT().
243 @param[in] Guid Pointer to a 128-bit unique value that designates
244 which namespace to retrieve a value from.
245 @param[in] TokenNumber The PCD token number to retrieve a current value for.
247 @return Return the UINT32.
265 Returns the 64-bit value for the token specified by TokenNumber and Guid.
266 If Guid is NULL, then ASSERT().
268 @param[in] Guid Pointer to a 128-bit unique value that designates
269 which namespace to retrieve a value from.
270 @param[in] TokenNumber The PCD token number to retrieve a current value for.
272 @return Return the UINT64.
290 Returns the pointer to the buffer of 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 VOID* pointer.
315 Returns the Boolean value of the token specified by TokenNumber and Guid.
316 If Guid is NULL, then ASSERT().
318 @param[in] Guid Pointer to a 128-bit unique value that designates
319 which namespace to retrieve a value from.
320 @param[in] TokenNumber The PCD token number to retrieve a current value for.
322 @return Return the BOOLEAN.
340 Returns the size of the token specified by TokenNumber and Guid.
341 If Guid is NULL, then ASSERT().
343 @param[in] Guid Pointer to a 128-bit unique value that designates
344 which namespace to retrieve a value from.
345 @param[in] TokenNumber The PCD token number to retrieve a current value for.
347 @return Return the size.
365 Sets the 8-bit value for the token specified by TokenNumber
366 to the value specified by Value. Value is returned.
368 @param[in] TokenNumber The PCD token number to set a current value for.
369 @param[in] Value The 8-bit value to set.
371 @return Return the value been set.
377 IN UINTN TokenNumber
,
389 Sets the 16-bit value for the token specified by TokenNumber
390 to the value specified by Value. Value is returned.
392 @param[in] TokenNumber The PCD token number to set a current value for.
393 @param[in] Value The 16-bit value to set.
395 @return Return the value been set.
401 IN UINTN TokenNumber
,
413 Sets the 32-bit value for the token specified by TokenNumber
414 to the value specified by Value. Value is returned.
416 @param[in] TokenNumber The PCD token number to set a current value for.
417 @param[in] Value The 32-bit value to set.
419 @return Return the value been set.
425 IN UINTN TokenNumber
,
437 Sets the 64-bit value for the token specified by TokenNumber
438 to the value specified by Value. Value is returned.
440 @param[in] TokenNumber The PCD token number to set a current value for.
441 @param[in] Value The 64-bit value to set.
443 @return Return the value been set.
449 IN UINTN TokenNumber
,
461 Sets a buffer for the token specified by TokenNumber to
462 the value specified by Buffer and SizeOfValue. Buffer to
463 be set is returned. The content of the buffer could be
464 overwritten if a Callback on SET is registered with this
467 If SizeOfValue is greater than the maximum
468 size support by TokenNumber, then set SizeOfValue to the
469 maximum size supported by TokenNumber and return NULL to
470 indicate that the set operation was not actually performed.
472 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
474 @param[in] TokenNumber The PCD token number to set a current value for.
475 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
476 @param[in] Buffer A pointer to the buffer to set.
478 @return Return the pointer for the buffer been set.
484 IN UINTN TokenNumber
,
485 IN OUT UINTN
*SizeOfBuffer
,
497 Sets the Boolean value for the token specified by TokenNumber
498 to the value specified by Value. Value is returned.
500 @param[in] TokenNumber The PCD token number to set a current value for.
501 @param[in] Value The boolean value to set.
503 @return Return the value been set.
509 IN UINTN TokenNumber
,
521 Sets the 8-bit value for the token specified by TokenNumber and
522 Guid to the value specified by Value. Value is returned.
523 If Guid is NULL, then ASSERT().
525 @param[in] Guid Pointer to a 128-bit unique value that
526 designates which namespace to set a value from.
527 @param[in] TokenNumber The PCD token number to set a current value for.
528 @param[in] Value The 8-bit value to set.
530 @return Return the value been set.
537 IN UINTN TokenNumber
,
549 Sets the 16-bit value for the token specified by TokenNumber and
550 Guid to the value specified by Value. Value is returned.
551 If Guid is NULL, then ASSERT().
553 @param[in] Guid Pointer to a 128-bit unique value that
554 designates which namespace to set a value from.
555 @param[in] TokenNumber The PCD token number to set a current value for.
556 @param[in] Value The 16-bit value to set.
558 @return Return the value been set.
565 IN UINTN TokenNumber
,
577 Sets the 32-bit value for the token specified by TokenNumber and
578 Guid to the value specified by Value. Value is returned.
579 If Guid is NULL, then ASSERT().
581 @param[in] Guid Pointer to a 128-bit unique value that
582 designates which namespace to set a value from.
583 @param[in] TokenNumber The PCD token number to set a current value for.
584 @param[in] Value The 32-bit value to set.
586 @return Return the value been set.
593 IN UINTN TokenNumber
,
605 Sets the 64-bit value for the token specified by TokenNumber and
606 Guid to the value specified by Value. Value is returned.
607 If Guid is NULL, then ASSERT().
609 @param[in] Guid Pointer to a 128-bit unique value that
610 designates which namespace to set a value from.
611 @param[in] TokenNumber The PCD token number to set a current value for.
612 @param[in] Value The 64-bit value to set.
614 @return Return the value been set.
621 IN UINTN TokenNumber
,
633 Sets a buffer for the token specified by TokenNumber to the value specified by
634 Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than
635 the maximum size support by TokenNumber, then set SizeOfValue to the maximum size
636 supported by TokenNumber and return NULL to indicate that the set operation
637 was not actually performed.
639 If SizeOfValue > 0 and Buffer is NULL, then ASSERT().
641 @param[in] Guid Pointer to a 128-bit unique value that
642 designates which namespace to set a value from.
643 @param[in] TokenNumber The PCD token number to set a current value for.
644 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
645 @param[in] Buffer A pointer to the buffer to set.
647 @return Return the pinter to the buffer been set.
654 IN UINTN TokenNumber
,
655 IN OUT UINTN
*SizeOfBuffer
,
667 Sets the Boolean value for the token specified by TokenNumber and
668 Guid to the value specified by Value. Value is returned.
669 If Guid is NULL, then ASSERT().
671 @param[in] Guid Pointer to a 128-bit unique value that
672 designates which namespace to set a value from.
673 @param[in] TokenNumber The PCD token number to set a current value for.
674 @param[in] Value The Boolean value to set.
676 @return Return the value been set.
683 IN UINTN TokenNumber
,
695 When the token specified by TokenNumber and Guid is set,
696 then notification function specified by NotificationFunction is called.
697 If Guid is NULL, then the default token space is used.
698 If NotificationFunction is NULL, then ASSERT().
700 @param[in] Guid Pointer to a 128-bit unique value that designates which
701 namespace to set a value from. If NULL, then the default
703 @param[in] TokenNumber The PCD token number to monitor.
704 @param[in] NotificationFunction The function to call when the token
705 specified by Guid and TokenNumber is set.
710 LibPcdCallbackOnSet (
711 IN CONST GUID
*Guid
, OPTIONAL
712 IN UINTN TokenNumber
,
713 IN PCD_CALLBACK NotificationFunction
722 Disable a notification function that was established with LibPcdCallbackonSet().
723 If NotificationFunction is NULL, then ASSERT().
725 @param[in] Guid Specify the GUID token space.
726 @param[in] TokenNumber Specify the token number.
727 @param[in] NotificationFunction The callback function to be unregistered.
732 LibPcdCancelCallback (
733 IN CONST GUID
*Guid
, OPTIONAL
734 IN UINTN TokenNumber
,
735 IN PCD_CALLBACK NotificationFunction
744 Retrieves the next PCD token number from the token space specified by Guid.
745 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
746 then the first token number is returned. Otherwise, the token number that
747 follows TokenNumber in the token space is returned. If TokenNumber is the last
748 token number in the token space, then 0 is returned. If TokenNumber is not 0 and
749 is not in the token space specified by Guid, then ASSERT().
751 @param[in] Guid Pointer to a 128-bit unique value that designates which namespace
752 to set a value from. If NULL, then the default token space is used.
753 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
756 @return The next valid token number.
762 IN CONST GUID
*Guid
, OPTIONAL
774 Retrieves the next PCD token space from a token space specified by Guid.
775 Guid of NULL is reserved to mark the default local token namespace on the current
776 platform. If Guid is NULL, then the GUID of the first non-local token space of the
777 current platform is returned. If Guid is the last non-local token space,
778 then NULL is returned.
780 If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().
782 @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace
785 @return The next valid token namespace.
790 LibPcdGetNextTokenSpace (
801 Sets a value of a patchable PCD entry that is type pointer.
803 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
804 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
805 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
806 NULL to indicate that the set operation was not actually performed.
807 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
808 MaximumDatumSize and NULL must be returned.
810 If PatchVariable is NULL, then ASSERT().
811 If SizeOfBuffer is NULL, then ASSERT().
812 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
814 @param[in] PatchVariable A pointer to the global variable in a module that is
815 the target of the set operation.
816 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
817 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
818 @param[in] Buffer A pointer to the buffer to used to set the target variable.
820 @return Return the pointer to the buffer been set.
826 IN VOID
*PatchVariable
,
827 IN UINTN MaximumDatumSize
,
828 IN OUT UINTN
*SizeOfBuffer
,
829 IN CONST VOID
*Buffer
832 ASSERT (PatchVariable
!= NULL
);
833 ASSERT (SizeOfBuffer
!= NULL
);
835 if (*SizeOfBuffer
> 0) {
836 ASSERT (Buffer
!= NULL
);
839 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
840 (*SizeOfBuffer
== MAX_ADDRESS
)) {
841 *SizeOfBuffer
= MaximumDatumSize
;
845 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
847 return (VOID
*) Buffer
;