2 A emptry template implementation of PCD Library.
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5 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 This function provides a means by which SKU support can be established in the PCD infrastructure.
25 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
27 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
28 set values associated with a PCD token.
30 If SkuId >= 0x100, then ASSERT().
32 @return Return the SKU ID that just be set.
47 This function provides a means by which to retrieve a value for a given PCD token.
49 Returns the 8-bit value for the token specified by TokenNumber.
51 @param[in] TokenNumber The PCD token number to retrieve a current value for.
53 @return Returns the 8-bit value for the token specified by TokenNumber.
70 This function provides a means by which to retrieve a value for a given PCD token.
72 Returns the 16-bit value for the token specified by TokenNumber.
74 @param[in] TokenNumber The PCD token number to retrieve a current value for.
76 @return Returns the 16-bit value for the token specified by TokenNumber.
93 This function provides a means by which to retrieve a value for a given PCD token.
95 Returns the 32-bit value for the token specified by TokenNumber.
97 @param[in] TokenNumber The PCD token number to retrieve a current value for.
99 @return Returns the 32-bit value for the token specified by TokenNumber.
116 This function provides a means by which to retrieve a value for a given PCD token.
118 Returns the 64-bit value for the token specified by TokenNumber.
120 @param[in] TokenNumber The PCD token number to retrieve a current value for.
122 @return Returns the 64-bit value for the token specified by TokenNumber.
139 This function provides a means by which to retrieve a value for a given PCD token.
141 Returns the pointer to the buffer of the token specified by TokenNumber.
143 @param[in] TokenNumber The PCD token number to retrieve a current value for.
145 @return Returns the pointer to the token specified by TokenNumber.
162 This function provides a means by which to retrieve a value for a given PCD token.
164 Returns the Boolean value of the token specified by TokenNumber.
166 @param[in] TokenNumber The PCD token number to retrieve a current value for.
168 @return Returns the Boolean value of the token specified by TokenNumber.
185 This function provides a means by which to retrieve the size of a given PCD token.
187 @param[in] TokenNumber The PCD token number to retrieve a current value for.
189 @return Returns the size of the token specified by TokenNumber.
206 This function provides a means by which to retrieve a value for a given PCD token.
208 Returns the 8-bit value for the token specified by TokenNumber and Guid.
210 If Guid is NULL, then ASSERT().
212 @param[in] Guid The pointer to a 128-bit unique value that designates
213 which namespace to retrieve a value from.
214 @param[in] TokenNumber The PCD token number to retrieve a current value for.
216 @return Return the UINT8.
234 This function provides a means by which to retrieve a value for a given PCD token.
236 Returns the 16-bit value for the token specified by TokenNumber and Guid.
238 If Guid is NULL, then ASSERT().
240 @param[in] Guid The pointer to a 128-bit unique value that designates
241 which namespace to retrieve a value from.
242 @param[in] TokenNumber The PCD token number to retrieve a current value for.
244 @return Return the UINT16.
262 Returns the 32-bit value for the token specified by TokenNumber and Guid.
263 If Guid is NULL, then ASSERT().
265 @param[in] Guid The pointer to a 128-bit unique value that designates
266 which namespace to retrieve a value from.
267 @param[in] TokenNumber The PCD token number to retrieve a current value for.
269 @return Return the UINT32.
287 This function provides a means by which to retrieve a value for a given PCD token.
289 Returns the 64-bit value for the token specified by TokenNumber and Guid.
291 If Guid is NULL, then ASSERT().
293 @param[in] Guid The 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 UINT64.
315 This function provides a means by which to retrieve a value for a given PCD token.
317 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
319 If Guid is NULL, then ASSERT().
321 @param[in] Guid The pointer to a 128-bit unique value that designates
322 which namespace to retrieve a value from.
323 @param[in] TokenNumber The PCD token number to retrieve a current value for.
325 @return Return the VOID* pointer.
343 This function provides a means by which to retrieve a value for a given PCD token.
345 Returns the Boolean value of the token specified by TokenNumber and Guid.
347 If Guid is NULL, then ASSERT().
349 @param[in] Guid The pointer to a 128-bit unique value that designates
350 which namespace to retrieve a value from.
351 @param[in] TokenNumber The PCD token number to retrieve a current value for.
353 @return Return the BOOLEAN.
371 This function provides a means by which to retrieve the size of a given PCD token.
373 Returns the size of the token specified by TokenNumber and Guid.
375 If Guid is NULL, then ASSERT().
377 @param[in] Guid The pointer to a 128-bit unique value that designates
378 which namespace to retrieve a value from.
379 @param[in] TokenNumber The PCD token number to retrieve a current value for.
381 @return Return the size.
399 This function provides a means by which to set a value for a given PCD token.
401 Sets the 8-bit value for the token specified by TokenNumber
402 to the value specified by Value. Value is returned.
404 If the set operation was not correctly performed, then ASSERT().
406 @param[in] TokenNumber The PCD token number to set a current value for.
407 @param[in] Value The 8-bit value to set.
409 @return Return the value that was set.
415 IN UINTN TokenNumber
,
427 This function provides a means by which to set a value for a given PCD token.
429 Sets the 16-bit value for the token specified by TokenNumber
430 to the value specified by Value. Value is returned.
432 If the set operation was not correctly performed, then ASSERT().
434 @param[in] TokenNumber The PCD token number to set a current value for.
435 @param[in] Value The 16-bit value to set.
437 @return Return the value that was set.
443 IN UINTN TokenNumber
,
455 This function provides a means by which to set a value for a given PCD token.
457 Sets the 32-bit value for the token specified by TokenNumber
458 to the value specified by Value. Value is returned.
460 If the set operation was not correctly performed, then ASSERT().
462 @param[in] TokenNumber The PCD token number to set a current value for.
463 @param[in] Value The 32-bit value to set.
465 @return Return the value that was set.
471 IN UINTN TokenNumber
,
483 This function provides a means by which to set a value for a given PCD token.
485 Sets the 64-bit value for the token specified by TokenNumber
486 to the value specified by Value. Value is returned.
488 If the set operation was not correctly performed, then ASSERT().
490 @param[in] TokenNumber The PCD token number to set a current value for.
491 @param[in] Value The 64-bit value to set.
493 @return Return the value that was set.
499 IN UINTN TokenNumber
,
511 This function provides a means by which to set a value for a given PCD token.
513 Sets a buffer for the token specified by TokenNumber to the value
514 specified by Buffer and SizeOfBuffer. Buffer is returned.
515 If SizeOfBuffer is greater than the maximum size support by TokenNumber,
516 then set SizeOfBuffer to the maximum size supported by TokenNumber and
517 return NULL to indicate that the set operation was not actually performed,
518 or ASSERT() if the set operation was not corretly performed.
520 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
521 maximum size supported by TokenName and NULL must be returned.
523 If SizeOfBuffer is NULL, then ASSERT().
524 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
526 @param[in] TokenNumber The PCD token number to set a current value for.
527 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
528 @param[in] Buffer A pointer to the buffer to set.
530 @return Return the pointer for the buffer been set.
536 IN UINTN TokenNumber
,
537 IN OUT UINTN
*SizeOfBuffer
,
538 IN CONST VOID
*Buffer
549 This function provides a means by which to set a value for a given PCD token.
551 Sets the Boolean value for the token specified by TokenNumber
552 to the value specified by Value. Value is returned.
554 If the set operation was not correctly performed, then ASSERT().
556 @param[in] TokenNumber The PCD token number to set a current value for.
557 @param[in] Value The boolean value to set.
559 @return Return the value that was set.
565 IN UINTN TokenNumber
,
577 This function provides a means by which to set a value for a given PCD token.
579 Sets the 8-bit value for the token specified by TokenNumber and
580 Guid to the value specified by Value. Value is returned.
582 If Guid is NULL, then ASSERT().
583 If the set operation was not correctly performed, then ASSERT().
585 @param[in] Guid The pointer to a 128-bit unique value that
586 designates which namespace to set a value from.
587 @param[in] TokenNumber The PCD token number to set a current value for.
588 @param[in] Value The 8-bit value to set.
590 @return Return the value that was set.
597 IN UINTN TokenNumber
,
609 This function provides a means by which to set a value for a given PCD token.
611 Sets the 16-bit value for the token specified by TokenNumber and
612 Guid to the value specified by Value. Value is returned.
614 If Guid is NULL, then ASSERT().
615 If the set operation was not correctly performed, then ASSERT().
617 @param[in] Guid The pointer to a 128-bit unique value that
618 designates which namespace to set a value from.
619 @param[in] TokenNumber The PCD token number to set a current value for.
620 @param[in] Value The 16-bit value to set.
622 @return Return the value that was set.
629 IN UINTN TokenNumber
,
641 This function provides a means by which to set a value for a given PCD token.
643 Sets the 32-bit value for the token specified by TokenNumber and
644 Guid to the value specified by Value. Value is returned.
646 If Guid is NULL, then ASSERT().
647 If the set operation was not correctly performed, then ASSERT().
649 @param[in] Guid The pointer to a 128-bit unique value that
650 designates which namespace to set a value from.
651 @param[in] TokenNumber The PCD token number to set a current value for.
652 @param[in] Value The 32-bit value to set.
654 @return Return the value that was set.
661 IN UINTN TokenNumber
,
673 This function provides a means by which to set a value for a given PCD token.
675 Sets the 64-bit value for the token specified by TokenNumber and
676 Guid to the value specified by Value. Value is returned.
678 If Guid is NULL, then ASSERT().
679 If the set operation was not correctly performed, then ASSERT().
681 @param[in] Guid The pointer to a 128-bit unique value that
682 designates which namespace to set a value from.
683 @param[in] TokenNumber The PCD token number to set a current value for.
684 @param[in] Value The 64-bit value to set.
686 @return Return the value that was set.
693 IN UINTN TokenNumber
,
705 This function provides a means by which to set a value for a given PCD token.
707 Sets a buffer for the token specified by TokenNumber to the value specified by
708 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
709 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
710 supported by TokenNumber and return NULL to indicate that the set operation
711 was not actually performed, or ASSERT() if the set operation was not corretly performed.
713 If Guid is NULL, then ASSERT().
714 If SizeOfBuffer is NULL, then ASSERT().
715 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
717 @param[in] Guid The pointer to a 128-bit unique value that
718 designates which namespace to set a value from.
719 @param[in] TokenNumber The PCD token number to set a current value for.
720 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
721 @param[in] Buffer A pointer to the buffer to set.
723 @return Return the pinter to the buffer been set.
730 IN UINTN TokenNumber
,
731 IN OUT UINTN
*SizeOfBuffer
,
743 This function provides a means by which to set a value for a given PCD token.
745 Sets the Boolean value for the token specified by TokenNumber and
746 Guid to the value specified by Value. Value is returned.
748 If Guid is NULL, then ASSERT().
749 If the set operation was not correctly performed, then ASSERT().
751 @param[in] Guid The pointer to a 128-bit unique value that
752 designates which namespace to set a value from.
753 @param[in] TokenNumber The PCD token number to set a current value for.
754 @param[in] Value The Boolean value to set.
756 @return Return the value that was set.
763 IN UINTN TokenNumber
,
775 Set up a notification function that is called when a specified token is set.
777 When the token specified by TokenNumber and Guid is set,
778 then notification function specified by NotificationFunction is called.
779 If Guid is NULL, then the default token space is used.
781 If NotificationFunction is NULL, then ASSERT().
783 @param[in] Guid The pointer to a 128-bit unique value that designates which
784 namespace to set a value from. If NULL, then the default
786 @param[in] TokenNumber The PCD token number to monitor.
787 @param[in] NotificationFunction The function to call when the token
788 specified by Guid and TokenNumber is set.
793 LibPcdCallbackOnSet (
794 IN CONST GUID
*Guid
, OPTIONAL
795 IN UINTN TokenNumber
,
796 IN PCD_CALLBACK NotificationFunction
805 Disable a notification function that was established with LibPcdCallbackonSet().
807 Disable a notification function that was previously established with LibPcdCallbackOnSet().
809 If NotificationFunction is NULL, then ASSERT().
810 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
811 and NotificationFunction, then ASSERT().
813 @param[in] Guid Specify the GUID token space.
814 @param[in] TokenNumber Specify the token number.
815 @param[in] NotificationFunction The callback function to be unregistered.
820 LibPcdCancelCallback (
821 IN CONST GUID
*Guid
, OPTIONAL
822 IN UINTN TokenNumber
,
823 IN PCD_CALLBACK NotificationFunction
832 Retrieves the next token in a token space.
834 Retrieves the next PCD token number from the token space specified by Guid.
835 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
836 then the first token number is returned. Otherwise, the token number that
837 follows TokenNumber in the token space is returned. If TokenNumber is the last
838 token number in the token space, then 0 is returned.
840 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
842 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
843 to set a value from. If NULL, then the default token space is used.
844 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
847 @return The next valid token number.
853 IN CONST GUID
*Guid
, OPTIONAL
865 Used to retrieve the list of available PCD token space GUIDs.
867 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
869 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
870 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
872 @param TokenSpaceGuid The pointer to a PCD token space GUID.
874 @return The next valid token namespace.
879 LibPcdGetNextTokenSpace (
880 IN CONST GUID
*TokenSpaceGuid
890 Sets a value of a patchable PCD entry that is type pointer.
892 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
893 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
894 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
895 NULL to indicate that the set operation was not actually performed.
896 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
897 MaximumDatumSize and NULL must be returned.
899 If PatchVariable is NULL, then ASSERT().
900 If SizeOfBuffer is NULL, then ASSERT().
901 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
903 @param[in] PatchVariable A pointer to the global variable in a module that is
904 the target of the set operation.
905 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
906 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
907 @param[in] Buffer A pointer to the buffer to used to set the target variable.
909 @return Return the pointer to the buffer that was set.
915 IN VOID
*PatchVariable
,
916 IN UINTN MaximumDatumSize
,
917 IN OUT UINTN
*SizeOfBuffer
,
918 IN CONST VOID
*Buffer
921 ASSERT (PatchVariable
!= NULL
);
922 ASSERT (SizeOfBuffer
!= NULL
);
924 if (*SizeOfBuffer
> 0) {
925 ASSERT (Buffer
!= NULL
);
928 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
929 (*SizeOfBuffer
== MAX_ADDRESS
)) {
930 *SizeOfBuffer
= MaximumDatumSize
;
934 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
936 return (VOID
*) Buffer
;
940 Retrieve additional information associated with a PCD token.
942 This includes information such as the type of value the TokenNumber is associated with as well as possible
943 human readable name that is associated with the token.
945 If TokenNumber is not in the default token space specified, then ASSERT().
947 @param[in] TokenNumber The PCD token number.
948 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
949 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
954 IN UINTN TokenNumber
,
955 OUT PCD_INFO
*PcdInfo
962 Retrieve additional information associated with a PCD token.
964 This includes information such as the type of value the TokenNumber is associated with as well as possible
965 human readable name that is associated with the token.
967 If TokenNumber is not in the token space specified by Guid, then ASSERT().
969 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
970 @param[in] TokenNumber The PCD token number.
971 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
972 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
978 IN UINTN TokenNumber
,
979 OUT PCD_INFO
*PcdInfo
986 Retrieve the currently set SKU Id.
988 If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().
990 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
991 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU