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>
16 This function provides a means by which SKU support can be established in the PCD infrastructure.
18 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
20 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
21 set values associated with a PCD token.
23 @return Return the SKU ID that just be set.
38 This function provides a means by which to retrieve a value for a given PCD token.
40 Returns the 8-bit value for the token specified by TokenNumber.
42 @param[in] TokenNumber The PCD token number to retrieve a current value for.
44 @return Returns the 8-bit value for the token specified by TokenNumber.
59 This function provides a means by which to retrieve a value for a given PCD token.
61 Returns the 16-bit value for the token specified by TokenNumber.
63 @param[in] TokenNumber The PCD token number to retrieve a current value for.
65 @return Returns the 16-bit value for the token specified by TokenNumber.
80 This function provides a means by which to retrieve a value for a given PCD token.
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 @return Returns the 32-bit value for the token specified by TokenNumber.
101 This function provides a means by which to retrieve a value for a given PCD token.
103 Returns the 64-bit value for the token specified by TokenNumber.
105 @param[in] TokenNumber The PCD token number to retrieve a current value for.
107 @return Returns the 64-bit value for the token specified by TokenNumber.
122 This function provides a means by which to retrieve a value for a given PCD token.
124 Returns the pointer to the buffer of the token specified by TokenNumber.
126 @param[in] TokenNumber The PCD token number to retrieve a current value for.
128 @return Returns the pointer to the token specified by TokenNumber.
143 This function provides a means by which to retrieve a value for a given PCD token.
145 Returns the Boolean value of the token specified by TokenNumber.
147 @param[in] TokenNumber The PCD token number to retrieve a current value for.
149 @return Returns the Boolean value of the token specified by TokenNumber.
164 This function provides a means by which to retrieve the size of a given PCD token.
166 @param[in] TokenNumber The PCD token number to retrieve a current value for.
168 @return Returns the size of the token specified by TokenNumber.
183 This function provides a means by which to retrieve a value for a given PCD token.
185 Returns the 8-bit value for the token specified by TokenNumber and Guid.
187 If Guid is NULL, then ASSERT().
189 @param[in] Guid The pointer to a 128-bit unique value that designates
190 which namespace to retrieve a value from.
191 @param[in] TokenNumber The PCD token number to retrieve a current value for.
193 @return Return the UINT8.
209 This function provides a means by which to retrieve a value for a given PCD token.
211 Returns the 16-bit value for the token specified by TokenNumber and Guid.
213 If Guid is NULL, then ASSERT().
215 @param[in] Guid The pointer to a 128-bit unique value that designates
216 which namespace to retrieve a value from.
217 @param[in] TokenNumber The PCD token number to retrieve a current value for.
219 @return Return the UINT16.
235 Returns the 32-bit value for the token specified by TokenNumber and Guid.
236 If Guid is NULL, then ASSERT().
238 @param[in] Guid The pointer to a 128-bit unique value that designates
239 which namespace to retrieve a value from.
240 @param[in] TokenNumber The PCD token number to retrieve a current value for.
242 @return Return the UINT32.
258 This function provides a means by which to retrieve a value for a given PCD token.
260 Returns the 64-bit value for the token specified by TokenNumber and Guid.
262 If Guid is NULL, then ASSERT().
264 @param[in] Guid The pointer to a 128-bit unique value that designates
265 which namespace to retrieve a value from.
266 @param[in] TokenNumber The PCD token number to retrieve a current value for.
268 @return Return the UINT64.
284 This function provides a means by which to retrieve a value for a given PCD token.
286 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
288 If Guid is NULL, then ASSERT().
290 @param[in] Guid The pointer to a 128-bit unique value that designates
291 which namespace to retrieve a value from.
292 @param[in] TokenNumber The PCD token number to retrieve a current value for.
294 @return Return the VOID* pointer.
310 This function provides a means by which to retrieve a value for a given PCD token.
312 Returns the Boolean value of the token specified by TokenNumber and Guid.
314 If Guid is NULL, then ASSERT().
316 @param[in] Guid The pointer to a 128-bit unique value that designates
317 which namespace to retrieve a value from.
318 @param[in] TokenNumber The PCD token number to retrieve a current value for.
320 @return Return the BOOLEAN.
336 This function provides a means by which to retrieve the size of a given PCD token.
338 Returns the size of the token specified by TokenNumber and Guid.
340 If Guid is NULL, then ASSERT().
342 @param[in] Guid The pointer to a 128-bit unique value that designates
343 which namespace to retrieve a value from.
344 @param[in] TokenNumber The PCD token number to retrieve a current value for.
346 @return Return the size.
362 This function provides a means by which to set a value for a given PCD token.
364 Sets the 8-bit value for the token specified by TokenNumber
365 to the value specified by Value.
367 @param[in] TokenNumber The PCD token number to set a current value for.
368 @param[in] Value The 8-bit value to set.
370 @return The status of the set operation.
376 IN UINTN TokenNumber
,
382 return RETURN_INVALID_PARAMETER
;
386 This function provides a means by which to set a value for a given PCD token.
388 Sets the 16-bit value for the token specified by TokenNumber
389 to the value specified by Value.
391 @param[in] TokenNumber The PCD token number to set a current value for.
392 @param[in] Value The 16-bit value to set.
394 @return The status of the set operation.
400 IN UINTN TokenNumber
,
406 return RETURN_INVALID_PARAMETER
;
410 This function provides a means by which to set a value for a given PCD token.
412 Sets the 32-bit value for the token specified by TokenNumber
413 to the value specified by Value.
415 @param[in] TokenNumber The PCD token number to set a current value for.
416 @param[in] Value The 32-bit value to set.
418 @return The status of the set operation.
424 IN UINTN TokenNumber
,
430 return RETURN_INVALID_PARAMETER
;
434 This function provides a means by which to set a value for a given PCD token.
436 Sets the 64-bit value for the token specified by TokenNumber
437 to the value specified by Value.
439 @param[in] TokenNumber The PCD token number to set a current value for.
440 @param[in] Value The 64-bit value to set.
442 @return The status of the set operation.
448 IN UINTN TokenNumber
,
454 return RETURN_INVALID_PARAMETER
;
458 This function provides a means by which to set a value for a given PCD token.
460 Sets a buffer for the token specified by TokenNumber to the value specified
461 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
462 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
463 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
464 was not actually performed.
466 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
467 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
469 If SizeOfBuffer is NULL, then ASSERT().
470 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
472 @param[in] TokenNumber The PCD token number to set a current value for.
473 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
474 @param[in] Buffer A pointer to the buffer to set.
476 @return The status of the set operation.
482 IN UINTN TokenNumber
,
483 IN OUT UINTN
*SizeOfBuffer
,
484 IN CONST VOID
*Buffer
489 return RETURN_INVALID_PARAMETER
;
493 This function provides a means by which to set a value for a given PCD token.
495 Sets the boolean value for the token specified by TokenNumber
496 to the value specified by Value.
498 @param[in] TokenNumber The PCD token number to set a current value for.
499 @param[in] Value The boolean value to set.
501 @return The status of the set operation.
507 IN UINTN TokenNumber
,
513 return RETURN_INVALID_PARAMETER
;
517 This function provides a means by which to set a value for a given PCD token.
519 Sets the 8-bit value for the token specified by TokenNumber
520 to the value specified by Value.
522 If Guid is NULL, then ASSERT().
524 @param[in] Guid The pointer to a 128-bit unique value that
525 designates which namespace to set a value from.
526 @param[in] TokenNumber The PCD token number to set a current value for.
527 @param[in] Value The 8-bit value to set.
529 @return The status of the set operation.
536 IN UINTN TokenNumber
,
542 return RETURN_INVALID_PARAMETER
;
546 This function provides a means by which to set a value for a given PCD token.
548 Sets the 16-bit value for the token specified by TokenNumber
549 to the value specified by Value.
551 If Guid is NULL, then ASSERT().
553 @param[in] Guid The 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 The status of the set operation.
565 IN UINTN TokenNumber
,
571 return RETURN_INVALID_PARAMETER
;
575 This function provides a means by which to set a value for a given PCD token.
577 Sets the 32-bit value for the token specified by TokenNumber
578 to the value specified by Value.
580 If Guid is NULL, then ASSERT().
582 @param[in] Guid The pointer to a 128-bit unique value that
583 designates which namespace to set a value from.
584 @param[in] TokenNumber The PCD token number to set a current value for.
585 @param[in] Value The 32-bit value to set.
587 @return The status of the set operation.
594 IN UINTN TokenNumber
,
600 return RETURN_INVALID_PARAMETER
;
604 This function provides a means by which to set a value for a given PCD token.
606 Sets the 64-bit value for the token specified by TokenNumber
607 to the value specified by Value.
609 If Guid is NULL, then ASSERT().
611 @param[in] Guid The pointer to a 128-bit unique value that
612 designates which namespace to set a value from.
613 @param[in] TokenNumber The PCD token number to set a current value for.
614 @param[in] Value The 64-bit value to set.
616 @return The status of the set operation.
623 IN UINTN TokenNumber
,
629 return RETURN_INVALID_PARAMETER
;
633 This function provides a means by which to set a value for a given PCD token.
635 Sets a buffer for the token specified by TokenNumber to the value specified by
636 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
637 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
638 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
639 was not actually performed.
641 If Guid is NULL, then ASSERT().
642 If SizeOfBuffer is NULL, then ASSERT().
643 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
645 @param[in] Guid Pointer to a 128-bit unique value that
646 designates which namespace to set a value from.
647 @param[in] TokenNumber The PCD token number to set a current value for.
648 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
649 @param[in] Buffer A pointer to the buffer to set.
651 @return The status of the set operation.
658 IN UINTN TokenNumber
,
659 IN OUT UINTN
*SizeOfBuffer
,
665 return RETURN_INVALID_PARAMETER
;
669 This function provides a means by which to set a value for a given PCD token.
671 Sets the boolean value for the token specified by TokenNumber
672 to the value specified by Value.
674 If Guid is NULL, then ASSERT().
676 @param[in] Guid The pointer to a 128-bit unique value that
677 designates which namespace to set a value from.
678 @param[in] TokenNumber The PCD token number to set a current value for.
679 @param[in] Value The boolean value to set.
681 @return The status of the set operation.
688 IN UINTN TokenNumber
,
694 return RETURN_INVALID_PARAMETER
;
698 Set up a notification function that is called when a specified token is set.
700 When the token specified by TokenNumber and Guid is set,
701 then notification function specified by NotificationFunction is called.
702 If Guid is NULL, then the default token space is used.
704 If NotificationFunction is NULL, then ASSERT().
706 @param[in] Guid The pointer to a 128-bit unique value that designates which
707 namespace to set a value from. If NULL, then the default
709 @param[in] TokenNumber The PCD token number to monitor.
710 @param[in] NotificationFunction The function to call when the token
711 specified by Guid and TokenNumber is set.
716 LibPcdCallbackOnSet (
717 IN CONST GUID
*Guid OPTIONAL
,
718 IN UINTN TokenNumber
,
719 IN PCD_CALLBACK NotificationFunction
726 Disable a notification function that was established with LibPcdCallbackonSet().
728 Disable a notification function that was previously established with LibPcdCallbackOnSet().
730 If NotificationFunction is NULL, then ASSERT().
731 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
732 and NotificationFunction, then ASSERT().
734 @param[in] Guid Specify the GUID token space.
735 @param[in] TokenNumber Specify the token number.
736 @param[in] NotificationFunction The callback function to be unregistered.
741 LibPcdCancelCallback (
742 IN CONST GUID
*Guid OPTIONAL
,
743 IN UINTN TokenNumber
,
744 IN PCD_CALLBACK NotificationFunction
751 Retrieves the next token in a token space.
753 Retrieves the next PCD token number from the token space specified by Guid.
754 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
755 then the first token number is returned. Otherwise, the token number that
756 follows TokenNumber in the token space is returned. If TokenNumber is the last
757 token number in the token space, then 0 is returned.
759 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
761 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
762 to set a value from. If NULL, then the default token space is used.
763 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
766 @return The next valid token number.
772 IN CONST GUID
*Guid OPTIONAL
,
782 Used to retrieve the list of available PCD token space GUIDs.
784 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
786 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
787 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
789 @param TokenSpaceGuid The pointer to a PCD token space GUID.
791 @return The next valid token namespace.
796 LibPcdGetNextTokenSpace (
797 IN CONST GUID
*TokenSpaceGuid
806 Sets a value of a patchable PCD entry that is type pointer.
808 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
809 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
810 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
811 NULL to indicate that the set operation was not actually performed.
812 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
813 MaximumDatumSize and NULL must be returned.
815 If PatchVariable is NULL, then ASSERT().
816 If SizeOfBuffer is NULL, then ASSERT().
817 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
819 @param[out] PatchVariable A pointer to the global variable in a module that is
820 the target of the set operation.
821 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
822 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
823 @param[in] Buffer A pointer to the buffer to used to set the target variable.
825 @return Return the pointer to the buffer that was set.
831 OUT VOID
*PatchVariable
,
832 IN UINTN MaximumDatumSize
,
833 IN OUT UINTN
*SizeOfBuffer
,
834 IN CONST VOID
*Buffer
837 ASSERT (PatchVariable
!= NULL
);
838 ASSERT (SizeOfBuffer
!= NULL
);
840 if (*SizeOfBuffer
> 0) {
841 ASSERT (Buffer
!= NULL
);
844 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
845 (*SizeOfBuffer
== MAX_ADDRESS
))
847 *SizeOfBuffer
= MaximumDatumSize
;
851 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
853 return (VOID
*)Buffer
;
857 Sets a value of a patchable PCD entry that is type pointer.
859 Sets the PCD entry specified by PatchVariable to the value specified
860 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
861 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
862 to indicate that the set operation was not actually performed.
863 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
864 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
866 If PatchVariable is NULL, then ASSERT().
867 If SizeOfBuffer is NULL, then ASSERT().
868 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
870 @param[out] PatchVariable A pointer to the global variable in a module that is
871 the target of the set operation.
872 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
873 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
874 @param[in] Buffer A pointer to the buffer to used to set the target variable.
876 @return The status of the set operation.
882 OUT VOID
*PatchVariable
,
883 IN UINTN MaximumDatumSize
,
884 IN OUT UINTN
*SizeOfBuffer
,
885 IN CONST VOID
*Buffer
888 ASSERT (PatchVariable
!= NULL
);
889 ASSERT (SizeOfBuffer
!= NULL
);
891 if (*SizeOfBuffer
> 0) {
892 ASSERT (Buffer
!= NULL
);
895 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
896 (*SizeOfBuffer
== MAX_ADDRESS
))
898 *SizeOfBuffer
= MaximumDatumSize
;
899 return RETURN_INVALID_PARAMETER
;
902 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
904 return RETURN_SUCCESS
;
908 Sets a value and size of a patchable PCD entry that is type pointer.
910 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
911 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
912 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
913 NULL to indicate that the set operation was not actually performed.
914 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
915 MaximumDatumSize and NULL must be returned.
917 If PatchVariable is NULL, then ASSERT().
918 If SizeOfPatchVariable is NULL, then ASSERT().
919 If SizeOfBuffer is NULL, then ASSERT().
920 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
922 @param[out] PatchVariable A pointer to the global variable in a module that is
923 the target of the set operation.
924 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
925 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
926 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
927 @param[in] Buffer A pointer to the buffer to used to set the target variable.
929 @return Return the pointer to the buffer been set.
934 LibPatchPcdSetPtrAndSize (
935 OUT VOID
*PatchVariable
,
936 OUT UINTN
*SizeOfPatchVariable
,
937 IN UINTN MaximumDatumSize
,
938 IN OUT UINTN
*SizeOfBuffer
,
939 IN CONST VOID
*Buffer
942 ASSERT (PatchVariable
!= NULL
);
943 ASSERT (SizeOfPatchVariable
!= NULL
);
944 ASSERT (SizeOfBuffer
!= NULL
);
946 if (*SizeOfBuffer
> 0) {
947 ASSERT (Buffer
!= NULL
);
950 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
951 (*SizeOfBuffer
== MAX_ADDRESS
))
953 *SizeOfBuffer
= MaximumDatumSize
;
957 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
958 *SizeOfPatchVariable
= *SizeOfBuffer
;
960 return (VOID
*)Buffer
;
964 Sets a value and size of a patchable PCD entry that is type pointer.
966 Sets the PCD entry specified by PatchVariable to the value specified
967 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
968 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
969 to indicate that the set operation was not actually performed.
970 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
971 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
973 If PatchVariable is NULL, then ASSERT().
974 If SizeOfPatchVariable is NULL, then ASSERT().
975 If SizeOfBuffer is NULL, then ASSERT().
976 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
978 @param[out] PatchVariable A pointer to the global variable in a module that is
979 the target of the set operation.
980 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
981 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
982 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
983 @param[in] Buffer A pointer to the buffer to used to set the target variable.
985 @return The status of the set operation.
990 LibPatchPcdSetPtrAndSizeS (
991 OUT VOID
*PatchVariable
,
992 OUT UINTN
*SizeOfPatchVariable
,
993 IN UINTN MaximumDatumSize
,
994 IN OUT UINTN
*SizeOfBuffer
,
995 IN CONST VOID
*Buffer
998 ASSERT (PatchVariable
!= NULL
);
999 ASSERT (SizeOfPatchVariable
!= NULL
);
1000 ASSERT (SizeOfBuffer
!= NULL
);
1002 if (*SizeOfBuffer
> 0) {
1003 ASSERT (Buffer
!= NULL
);
1006 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1007 (*SizeOfBuffer
== MAX_ADDRESS
))
1009 *SizeOfBuffer
= MaximumDatumSize
;
1010 return RETURN_INVALID_PARAMETER
;
1013 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1014 *SizeOfPatchVariable
= *SizeOfBuffer
;
1016 return RETURN_SUCCESS
;
1020 Retrieve additional information associated with a PCD token.
1022 This includes information such as the type of value the TokenNumber is associated with as well as possible
1023 human readable name that is associated with the token.
1025 If TokenNumber is not in the default token space specified, then ASSERT().
1027 @param[in] TokenNumber The PCD token number.
1028 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1029 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1034 IN UINTN TokenNumber
,
1035 OUT PCD_INFO
*PcdInfo
1042 Retrieve additional information associated with a PCD token.
1044 This includes information such as the type of value the TokenNumber is associated with as well as possible
1045 human readable name that is associated with the token.
1047 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1049 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1050 @param[in] TokenNumber The PCD token number.
1051 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1052 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1057 IN CONST GUID
*Guid
,
1058 IN UINTN TokenNumber
,
1059 OUT PCD_INFO
*PcdInfo
1066 Retrieve the currently set SKU Id.
1068 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1069 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU