2 A emptry template implementation of PCD Library.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/DebugLib.h>
12 #include <Library/PcdLib.h>
13 #include <Library/BaseMemoryLib.h>
17 This function provides a means by which SKU support can be established in the PCD infrastructure.
19 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
21 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
22 set values associated with a PCD token.
24 @return Return the SKU ID that just be set.
39 This function provides a means by which to retrieve a value for a given PCD token.
41 Returns the 8-bit value for the token specified by TokenNumber.
43 @param[in] TokenNumber The PCD token number to retrieve a current value for.
45 @return Returns the 8-bit value for the token specified by TokenNumber.
62 This function provides a means by which to retrieve a value for a given PCD token.
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 This function provides a means by which to retrieve a value for a given PCD token.
87 Returns the 32-bit value for the token specified by TokenNumber.
89 @param[in] TokenNumber The PCD token number to retrieve a current value for.
91 @return Returns the 32-bit value for the token specified by TokenNumber.
108 This function provides a means by which to retrieve a value for a given PCD token.
110 Returns the 64-bit value for the token specified by TokenNumber.
112 @param[in] TokenNumber The PCD token number to retrieve a current value for.
114 @return Returns the 64-bit value for the token specified by TokenNumber.
131 This function provides a means by which to retrieve a value for a given PCD token.
133 Returns the pointer to the buffer of the token specified by TokenNumber.
135 @param[in] TokenNumber The PCD token number to retrieve a current value for.
137 @return Returns the pointer to the token specified by TokenNumber.
154 This function provides a means by which to retrieve a value for a given PCD token.
156 Returns the Boolean value of the token specified by TokenNumber.
158 @param[in] TokenNumber The PCD token number to retrieve a current value for.
160 @return Returns the Boolean value of the token specified by TokenNumber.
177 This function provides a means by which to retrieve the size of a given PCD token.
179 @param[in] TokenNumber The PCD token number to retrieve a current value for.
181 @return Returns the size of the token specified by TokenNumber.
198 This function provides a means by which to retrieve a value for a given PCD token.
200 Returns the 8-bit value for the token specified by TokenNumber and Guid.
202 If Guid is NULL, then ASSERT().
204 @param[in] Guid The pointer to a 128-bit unique value that designates
205 which namespace to retrieve a value from.
206 @param[in] TokenNumber The PCD token number to retrieve a current value for.
208 @return Return the UINT8.
226 This function provides a means by which to retrieve a value for a given PCD token.
228 Returns the 16-bit value for the token specified by TokenNumber and Guid.
230 If Guid is NULL, then ASSERT().
232 @param[in] Guid The pointer to a 128-bit unique value that designates
233 which namespace to retrieve a value from.
234 @param[in] TokenNumber The PCD token number to retrieve a current value for.
236 @return Return the UINT16.
254 Returns the 32-bit value for the token specified by TokenNumber and Guid.
255 If Guid is NULL, then ASSERT().
257 @param[in] Guid The pointer to a 128-bit unique value that designates
258 which namespace to retrieve a value from.
259 @param[in] TokenNumber The PCD token number to retrieve a current value for.
261 @return Return the UINT32.
279 This function provides a means by which to retrieve a value for a given PCD token.
281 Returns the 64-bit value for the token specified by TokenNumber and Guid.
283 If Guid is NULL, then ASSERT().
285 @param[in] Guid The pointer to a 128-bit unique value that designates
286 which namespace to retrieve a value from.
287 @param[in] TokenNumber The PCD token number to retrieve a current value for.
289 @return Return the UINT64.
307 This function provides a means by which to retrieve a value for a given PCD token.
309 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
311 If Guid is NULL, then ASSERT().
313 @param[in] Guid The pointer to a 128-bit unique value that designates
314 which namespace to retrieve a value from.
315 @param[in] TokenNumber The PCD token number to retrieve a current value for.
317 @return Return the VOID* pointer.
335 This function provides a means by which to retrieve a value for a given PCD token.
337 Returns the Boolean value of the token specified by TokenNumber and Guid.
339 If Guid is NULL, then ASSERT().
341 @param[in] Guid The pointer to a 128-bit unique value that designates
342 which namespace to retrieve a value from.
343 @param[in] TokenNumber The PCD token number to retrieve a current value for.
345 @return Return the BOOLEAN.
363 This function provides a means by which to retrieve the size of a given PCD token.
365 Returns the size of the token specified by TokenNumber and Guid.
367 If Guid is NULL, then ASSERT().
369 @param[in] Guid The pointer to a 128-bit unique value that designates
370 which namespace to retrieve a value from.
371 @param[in] TokenNumber The PCD token number to retrieve a current value for.
373 @return Return the size.
390 This function provides a means by which to set a value for a given PCD token.
392 Sets the 8-bit value for the token specified by TokenNumber
393 to the value specified by Value.
395 @param[in] TokenNumber The PCD token number to set a current value for.
396 @param[in] Value The 8-bit value to set.
398 @return The status of the set operation.
404 IN UINTN TokenNumber
,
410 return RETURN_INVALID_PARAMETER
;
414 This function provides a means by which to set a value for a given PCD token.
416 Sets the 16-bit value for the token specified by TokenNumber
417 to the value specified by Value.
419 @param[in] TokenNumber The PCD token number to set a current value for.
420 @param[in] Value The 16-bit value to set.
422 @return The status of the set operation.
428 IN UINTN TokenNumber
,
434 return RETURN_INVALID_PARAMETER
;
438 This function provides a means by which to set a value for a given PCD token.
440 Sets the 32-bit value for the token specified by TokenNumber
441 to the value specified by Value.
443 @param[in] TokenNumber The PCD token number to set a current value for.
444 @param[in] Value The 32-bit value to set.
446 @return The status of the set operation.
452 IN UINTN TokenNumber
,
458 return RETURN_INVALID_PARAMETER
;
462 This function provides a means by which to set a value for a given PCD token.
464 Sets the 64-bit value for the token specified by TokenNumber
465 to the value specified by Value.
467 @param[in] TokenNumber The PCD token number to set a current value for.
468 @param[in] Value The 64-bit value to set.
470 @return The status of the set operation.
476 IN UINTN TokenNumber
,
482 return RETURN_INVALID_PARAMETER
;
486 This function provides a means by which to set a value for a given PCD token.
488 Sets a buffer for the token specified by TokenNumber to the value specified
489 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
490 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
491 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
492 was not actually performed.
494 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
495 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
497 If SizeOfBuffer is NULL, then ASSERT().
498 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
500 @param[in] TokenNumber The PCD token number to set a current value for.
501 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
502 @param[in] Buffer A pointer to the buffer to set.
504 @return The status of the set operation.
510 IN UINTN TokenNumber
,
511 IN OUT UINTN
*SizeOfBuffer
,
512 IN CONST VOID
*Buffer
517 return RETURN_INVALID_PARAMETER
;
521 This function provides a means by which to set a value for a given PCD token.
523 Sets the boolean value for the token specified by TokenNumber
524 to the value specified by Value.
526 @param[in] TokenNumber The PCD token number to set a current value for.
527 @param[in] Value The boolean value to set.
529 @return The status of the set operation.
535 IN UINTN TokenNumber
,
541 return RETURN_INVALID_PARAMETER
;
545 This function provides a means by which to set a value for a given PCD token.
547 Sets the 8-bit value for the token specified by TokenNumber
548 to the value specified by Value.
550 If Guid is NULL, then ASSERT().
552 @param[in] Guid The pointer to a 128-bit unique value that
553 designates which namespace to set a value from.
554 @param[in] TokenNumber The PCD token number to set a current value for.
555 @param[in] Value The 8-bit value to set.
557 @return The status of the set operation.
564 IN UINTN TokenNumber
,
570 return RETURN_INVALID_PARAMETER
;
574 This function provides a means by which to set a value for a given PCD token.
576 Sets the 16-bit value for the token specified by TokenNumber
577 to the value specified by Value.
579 If Guid is NULL, then ASSERT().
581 @param[in] Guid The 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 16-bit value to set.
586 @return The status of the set operation.
593 IN UINTN TokenNumber
,
599 return RETURN_INVALID_PARAMETER
;
603 This function provides a means by which to set a value for a given PCD token.
605 Sets the 32-bit value for the token specified by TokenNumber
606 to the value specified by Value.
608 If Guid is NULL, then ASSERT().
610 @param[in] Guid The 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 32-bit value to set.
615 @return The status of the set operation.
622 IN UINTN TokenNumber
,
628 return RETURN_INVALID_PARAMETER
;
632 This function provides a means by which to set a value for a given PCD token.
634 Sets the 64-bit value for the token specified by TokenNumber
635 to the value specified by Value.
637 If Guid is NULL, then ASSERT().
639 @param[in] Guid The pointer to a 128-bit unique value that
640 designates which namespace to set a value from.
641 @param[in] TokenNumber The PCD token number to set a current value for.
642 @param[in] Value The 64-bit value to set.
644 @return The status of the set operation.
651 IN UINTN TokenNumber
,
657 return RETURN_INVALID_PARAMETER
;
661 This function provides a means by which to set a value for a given PCD token.
663 Sets a buffer for the token specified by TokenNumber to the value specified by
664 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
665 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
666 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
667 was not actually performed.
669 If Guid is NULL, then ASSERT().
670 If SizeOfBuffer is NULL, then ASSERT().
671 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
673 @param[in] Guid Pointer to a 128-bit unique value that
674 designates which namespace to set a value from.
675 @param[in] TokenNumber The PCD token number to set a current value for.
676 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
677 @param[in] Buffer A pointer to the buffer to set.
679 @return The status of the set operation.
686 IN UINTN TokenNumber
,
687 IN OUT UINTN
*SizeOfBuffer
,
693 return RETURN_INVALID_PARAMETER
;
697 This function provides a means by which to set a value for a given PCD token.
699 Sets the boolean value for the token specified by TokenNumber
700 to the value specified by Value.
702 If Guid is NULL, then ASSERT().
704 @param[in] Guid The pointer to a 128-bit unique value that
705 designates which namespace to set a value from.
706 @param[in] TokenNumber The PCD token number to set a current value for.
707 @param[in] Value The boolean value to set.
709 @return The status of the set operation.
716 IN UINTN TokenNumber
,
722 return RETURN_INVALID_PARAMETER
;
726 Set up a notification function that is called when a specified token is set.
728 When the token specified by TokenNumber and Guid is set,
729 then notification function specified by NotificationFunction is called.
730 If Guid is NULL, then the default token space is used.
732 If NotificationFunction is NULL, then ASSERT().
734 @param[in] Guid The pointer to a 128-bit unique value that designates which
735 namespace to set a value from. If NULL, then the default
737 @param[in] TokenNumber The PCD token number to monitor.
738 @param[in] NotificationFunction The function to call when the token
739 specified by Guid and TokenNumber is set.
744 LibPcdCallbackOnSet (
745 IN CONST GUID
*Guid
, OPTIONAL
746 IN UINTN TokenNumber
,
747 IN PCD_CALLBACK NotificationFunction
756 Disable a notification function that was established with LibPcdCallbackonSet().
758 Disable a notification function that was previously established with LibPcdCallbackOnSet().
760 If NotificationFunction is NULL, then ASSERT().
761 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
762 and NotificationFunction, then ASSERT().
764 @param[in] Guid Specify the GUID token space.
765 @param[in] TokenNumber Specify the token number.
766 @param[in] NotificationFunction The callback function to be unregistered.
771 LibPcdCancelCallback (
772 IN CONST GUID
*Guid
, OPTIONAL
773 IN UINTN TokenNumber
,
774 IN PCD_CALLBACK NotificationFunction
783 Retrieves the next token in a token space.
785 Retrieves the next PCD token number from the token space specified by Guid.
786 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
787 then the first token number is returned. Otherwise, the token number that
788 follows TokenNumber in the token space is returned. If TokenNumber is the last
789 token number in the token space, then 0 is returned.
791 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
793 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
794 to set a value from. If NULL, then the default token space is used.
795 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
798 @return The next valid token number.
804 IN CONST GUID
*Guid
, OPTIONAL
816 Used to retrieve the list of available PCD token space GUIDs.
818 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
820 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
821 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
823 @param TokenSpaceGuid The pointer to a PCD token space GUID.
825 @return The next valid token namespace.
830 LibPcdGetNextTokenSpace (
831 IN CONST GUID
*TokenSpaceGuid
841 Sets a value of a patchable PCD entry that is type pointer.
843 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
844 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
845 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
846 NULL to indicate that the set operation was not actually performed.
847 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
848 MaximumDatumSize and NULL must be returned.
850 If PatchVariable is NULL, then ASSERT().
851 If SizeOfBuffer is NULL, then ASSERT().
852 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
854 @param[out] PatchVariable A pointer to the global variable in a module that is
855 the target of the set operation.
856 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
857 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
858 @param[in] Buffer A pointer to the buffer to used to set the target variable.
860 @return Return the pointer to the buffer that was set.
866 OUT VOID
*PatchVariable
,
867 IN UINTN MaximumDatumSize
,
868 IN OUT UINTN
*SizeOfBuffer
,
869 IN CONST VOID
*Buffer
872 ASSERT (PatchVariable
!= NULL
);
873 ASSERT (SizeOfBuffer
!= NULL
);
875 if (*SizeOfBuffer
> 0) {
876 ASSERT (Buffer
!= NULL
);
879 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
880 (*SizeOfBuffer
== MAX_ADDRESS
)) {
881 *SizeOfBuffer
= MaximumDatumSize
;
885 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
887 return (VOID
*) Buffer
;
891 Sets a value of a patchable PCD entry that is type pointer.
893 Sets the PCD entry specified by PatchVariable to the value specified
894 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
895 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
896 to indicate that the set operation was not actually performed.
897 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
898 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
900 If PatchVariable is NULL, then ASSERT().
901 If SizeOfBuffer is NULL, then ASSERT().
902 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
904 @param[out] PatchVariable A pointer to the global variable in a module that is
905 the target of the set operation.
906 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
907 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
908 @param[in] Buffer A pointer to the buffer to used to set the target variable.
910 @return The status of the set operation.
916 OUT VOID
*PatchVariable
,
917 IN UINTN MaximumDatumSize
,
918 IN OUT UINTN
*SizeOfBuffer
,
919 IN CONST VOID
*Buffer
922 ASSERT (PatchVariable
!= NULL
);
923 ASSERT (SizeOfBuffer
!= NULL
);
925 if (*SizeOfBuffer
> 0) {
926 ASSERT (Buffer
!= NULL
);
929 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
930 (*SizeOfBuffer
== MAX_ADDRESS
)) {
931 *SizeOfBuffer
= MaximumDatumSize
;
932 return RETURN_INVALID_PARAMETER
;
935 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
937 return RETURN_SUCCESS
;
941 Sets a value and size of a patchable PCD entry that is type pointer.
943 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
944 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
945 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
946 NULL to indicate that the set operation was not actually performed.
947 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
948 MaximumDatumSize and NULL must be returned.
950 If PatchVariable is NULL, then ASSERT().
951 If SizeOfPatchVariable is NULL, then ASSERT().
952 If SizeOfBuffer is NULL, then ASSERT().
953 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
955 @param[out] PatchVariable A pointer to the global variable in a module that is
956 the target of the set operation.
957 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
958 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
959 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
960 @param[in] Buffer A pointer to the buffer to used to set the target variable.
962 @return Return the pointer to the buffer been set.
967 LibPatchPcdSetPtrAndSize (
968 OUT VOID
*PatchVariable
,
969 OUT UINTN
*SizeOfPatchVariable
,
970 IN UINTN MaximumDatumSize
,
971 IN OUT UINTN
*SizeOfBuffer
,
972 IN CONST VOID
*Buffer
975 ASSERT (PatchVariable
!= NULL
);
976 ASSERT (SizeOfPatchVariable
!= NULL
);
977 ASSERT (SizeOfBuffer
!= NULL
);
979 if (*SizeOfBuffer
> 0) {
980 ASSERT (Buffer
!= NULL
);
983 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
984 (*SizeOfBuffer
== MAX_ADDRESS
)) {
985 *SizeOfBuffer
= MaximumDatumSize
;
989 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
990 *SizeOfPatchVariable
= *SizeOfBuffer
;
992 return (VOID
*) Buffer
;
996 Sets a value and size of a patchable PCD entry that is type pointer.
998 Sets the PCD entry specified by PatchVariable to the value specified
999 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1000 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1001 to indicate that the set operation was not actually performed.
1002 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1003 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1005 If PatchVariable is NULL, then ASSERT().
1006 If SizeOfPatchVariable is NULL, then ASSERT().
1007 If SizeOfBuffer is NULL, then ASSERT().
1008 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1010 @param[out] PatchVariable A pointer to the global variable in a module that is
1011 the target of the set operation.
1012 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1013 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1014 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1015 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1017 @return The status of the set operation.
1022 LibPatchPcdSetPtrAndSizeS (
1023 OUT VOID
*PatchVariable
,
1024 OUT UINTN
*SizeOfPatchVariable
,
1025 IN UINTN MaximumDatumSize
,
1026 IN OUT UINTN
*SizeOfBuffer
,
1027 IN CONST VOID
*Buffer
1030 ASSERT (PatchVariable
!= NULL
);
1031 ASSERT (SizeOfPatchVariable
!= NULL
);
1032 ASSERT (SizeOfBuffer
!= NULL
);
1034 if (*SizeOfBuffer
> 0) {
1035 ASSERT (Buffer
!= NULL
);
1038 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1039 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1040 *SizeOfBuffer
= MaximumDatumSize
;
1041 return RETURN_INVALID_PARAMETER
;
1044 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1045 *SizeOfPatchVariable
= *SizeOfBuffer
;
1047 return RETURN_SUCCESS
;
1051 Retrieve additional information associated with a PCD token.
1053 This includes information such as the type of value the TokenNumber is associated with as well as possible
1054 human readable name that is associated with the token.
1056 If TokenNumber is not in the default token space specified, then ASSERT().
1058 @param[in] TokenNumber The PCD token number.
1059 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1060 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1065 IN UINTN TokenNumber
,
1066 OUT PCD_INFO
*PcdInfo
1073 Retrieve additional information associated with a PCD token.
1075 This includes information such as the type of value the TokenNumber is associated with as well as possible
1076 human readable name that is associated with the token.
1078 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1080 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1081 @param[in] TokenNumber The PCD token number.
1082 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1083 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1088 IN CONST GUID
*Guid
,
1089 IN UINTN TokenNumber
,
1090 OUT PCD_INFO
*PcdInfo
1097 Retrieve the currently set SKU Id.
1099 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1100 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU