2 Implementation of PcdLib class library for DXE phase.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Protocol/Pcd.h>
14 #include <Protocol/PiPcd.h>
15 #include <Protocol/PcdInfo.h>
16 #include <Protocol/PiPcdInfo.h>
18 #include <Library/PcdLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/UefiBootServicesTableLib.h>
21 #include <Library/BaseMemoryLib.h>
23 PCD_PROTOCOL
*mPcd
= NULL
;
24 EFI_PCD_PROTOCOL
*mPiPcd
= NULL
;
25 GET_PCD_INFO_PROTOCOL
*mPcdInfo
= NULL
;
26 EFI_GET_PCD_INFO_PROTOCOL
*mPiPcdInfo
= NULL
;
29 Retrieves the PI PCD protocol from the handle database.
31 @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.
43 // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module
44 // access DynamicEx type PCD.
46 Status
= gBS
->LocateProtocol (&gEfiPcdProtocolGuid
, NULL
, (VOID
**) &mPiPcd
);
47 ASSERT_EFI_ERROR (Status
);
48 ASSERT (mPiPcd
!= NULL
);
54 Retrieves the PCD protocol from the handle database.
56 @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.
68 // PCD protocol need to be installed before the module access Dynamic type PCD.
69 // But dynamic type PCD is not required in PI 1.2 specification.
71 Status
= gBS
->LocateProtocol (&gPcdProtocolGuid
, NULL
, (VOID
**)&mPcd
);
72 ASSERT_EFI_ERROR (Status
);
73 ASSERT (mPcd
!= NULL
);
79 Retrieves the PI PCD info protocol from the handle database.
81 @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.
83 EFI_GET_PCD_INFO_PROTOCOL
*
84 GetPiPcdInfoProtocolPointer (
90 if (mPiPcdInfo
== NULL
) {
91 Status
= gBS
->LocateProtocol (&gEfiGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPiPcdInfo
);
92 ASSERT_EFI_ERROR (Status
);
93 ASSERT (mPiPcdInfo
!= NULL
);
99 Retrieves the PCD info protocol from the handle database.
101 @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.
103 GET_PCD_INFO_PROTOCOL
*
104 GetPcdInfoProtocolPointer (
110 if (mPcdInfo
== NULL
) {
111 Status
= gBS
->LocateProtocol (&gGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPcdInfo
);
112 ASSERT_EFI_ERROR (Status
);
113 ASSERT (mPcdInfo
!= NULL
);
119 This function provides a means by which SKU support can be established in the PCD infrastructure.
121 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
123 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values
124 associated with a PCD token.
126 @return Return the SKU ID that just be set.
135 GetPcdProtocol()->SetSku (SkuId
);
143 This function provides a means by which to retrieve a value for a given PCD token.
145 Returns the 8-bit value for the token specified by TokenNumber.
147 @param[in] TokenNumber The PCD token number to retrieve a current value for.
149 @return Returns the 8-bit value for the token specified by TokenNumber.
158 return GetPcdProtocol()->Get8 (TokenNumber
);
164 This function provides a means by which to retrieve a value for a given PCD token.
166 Returns the 16-bit value for the token specified by TokenNumber.
168 @param[in] TokenNumber The PCD token number to retrieve a current value for.
170 @return Returns the 16-bit value for the token specified by TokenNumber.
179 return GetPcdProtocol()->Get16 (TokenNumber
);
185 This function provides a means by which to retrieve a value for a given PCD token.
187 Returns the 32-bit value for the token specified by TokenNumber.
189 @param[in] TokenNumber The PCD token number to retrieve a current value for.
191 @return Returns the 32-bit value for the token specified by TokenNumber.
200 return GetPcdProtocol()->Get32 (TokenNumber
);
206 This function provides a means by which to retrieve a value for a given PCD token.
208 Returns the 64-bit value for the token specified by TokenNumber.
210 @param[in] TokenNumber The PCD token number to retrieve a current value for.
212 @return Returns the 64-bit value for the token specified by TokenNumber.
221 return GetPcdProtocol()->Get64 (TokenNumber
);
227 This function provides a means by which to retrieve a value for a given PCD token.
229 Returns the pointer to the buffer of the token specified by TokenNumber.
231 @param[in] TokenNumber The PCD token number to retrieve a current value for.
233 @return Returns the pointer to the token specified by TokenNumber.
242 return GetPcdProtocol()->GetPtr (TokenNumber
);
248 This function provides a means by which to retrieve a value for a given PCD token.
250 Returns the Boolean value of the token specified by TokenNumber.
252 @param[in] TokenNumber The PCD token number to retrieve a current value for.
254 @return Returns the Boolean value of the token specified by TokenNumber.
263 return GetPcdProtocol()->GetBool (TokenNumber
);
269 This function provides a means by which to retrieve the size of a given PCD token.
271 @param[in] TokenNumber The PCD token number to retrieve a current value for.
273 @return Returns the size of the token specified by TokenNumber.
282 return GetPcdProtocol()->GetSize (TokenNumber
);
288 This function provides a means by which to retrieve a value for a given PCD token.
290 Returns the 8-bit value for the token specified by TokenNumber and Guid.
292 If Guid is NULL, then ASSERT().
294 @param[in] Guid The pointer to a 128-bit unique value that designates
295 which namespace to retrieve a value from.
296 @param[in] TokenNumber The PCD token number to retrieve a current value for.
298 @return Return the UINT8.
308 ASSERT (Guid
!= NULL
);
310 return GetPiPcdProtocol()->Get8 (Guid
, TokenNumber
);
315 This function provides a means by which to retrieve a value for a given PCD token.
317 Returns the 16-bit value for the 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 UINT16.
335 ASSERT (Guid
!= NULL
);
337 return GetPiPcdProtocol()->Get16 (Guid
, TokenNumber
);
342 Returns the 32-bit value for the token specified by TokenNumber and Guid.
343 If Guid is NULL, then ASSERT().
345 @param[in] Guid The pointer to a 128-bit unique value that designates
346 which namespace to retrieve a value from.
347 @param[in] TokenNumber The PCD token number to retrieve a current value for.
349 @return Return the UINT32.
359 ASSERT (Guid
!= NULL
);
361 return GetPiPcdProtocol()->Get32 (Guid
, TokenNumber
);
367 This function provides a means by which to retrieve a value for a given PCD token.
369 Returns the 64-bit value for the token specified by TokenNumber and Guid.
371 If Guid is NULL, then ASSERT().
373 @param[in] Guid The pointer to a 128-bit unique value that designates
374 which namespace to retrieve a value from.
375 @param[in] TokenNumber The PCD token number to retrieve a current value for.
377 @return Return the UINT64.
387 ASSERT (Guid
!= NULL
);
389 return GetPiPcdProtocol()->Get64 (Guid
, TokenNumber
);
395 This function provides a means by which to retrieve a value for a given PCD token.
397 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
399 If Guid is NULL, then ASSERT().
401 @param[in] Guid The pointer to a 128-bit unique value that designates
402 which namespace to retrieve a value from.
403 @param[in] TokenNumber The PCD token number to retrieve a current value for.
405 @return Return the VOID* pointer.
415 ASSERT (Guid
!= NULL
);
417 return GetPiPcdProtocol()->GetPtr (Guid
, TokenNumber
);
423 This function provides a means by which to retrieve a value for a given PCD token.
425 Returns the Boolean value of the token specified by TokenNumber and Guid.
427 If Guid is NULL, then ASSERT().
429 @param[in] Guid The pointer to a 128-bit unique value that designates
430 which namespace to retrieve a value from.
431 @param[in] TokenNumber The PCD token number to retrieve a current value for.
433 @return Return the BOOLEAN.
443 ASSERT (Guid
!= NULL
);
445 return GetPiPcdProtocol()->GetBool (Guid
, TokenNumber
);
451 This function provides a means by which to retrieve the size of a given PCD token.
453 Returns the size of the token specified by TokenNumber and Guid.
455 If Guid is NULL, then ASSERT().
457 @param[in] Guid The pointer to a 128-bit unique value that designates
458 which namespace to retrieve a value from.
459 @param[in] TokenNumber The PCD token number to retrieve a current value for.
461 @return Return the size.
471 ASSERT (Guid
!= NULL
);
473 return GetPiPcdProtocol()->GetSize (Guid
, TokenNumber
);
478 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
480 This function provides a means by which to set a value for a given PCD token.
482 Sets the 8-bit value for the token specified by TokenNumber
483 to the value specified by Value. Value is returned.
485 @param[in] TokenNumber The PCD token number to set a current value for.
486 @param[in] Value The 8-bit value to set.
488 @return Return the value that was set.
494 IN UINTN TokenNumber
,
498 GetPcdProtocol()->Set8 (TokenNumber
, Value
);
506 This function provides a means by which to set a value for a given PCD token.
508 Sets the 16-bit value for the token specified by TokenNumber
509 to the value specified by Value. Value is returned.
511 @param[in] TokenNumber The PCD token number to set a current value for.
512 @param[in] Value The 16-bit value to set.
514 @return Return the value that was set.
520 IN UINTN TokenNumber
,
524 GetPcdProtocol()->Set16 (TokenNumber
, Value
);
532 This function provides a means by which to set a value for a given PCD token.
534 Sets the 32-bit value for the token specified by TokenNumber
535 to the value specified by Value. Value is returned.
537 @param[in] TokenNumber The PCD token number to set a current value for.
538 @param[in] Value The 32-bit value to set.
540 @return Return the value that was set.
546 IN UINTN TokenNumber
,
550 GetPcdProtocol()->Set32 (TokenNumber
, Value
);
558 This function provides a means by which to set a value for a given PCD token.
560 Sets the 64-bit value for the token specified by TokenNumber
561 to the value specified by Value. Value is returned.
563 @param[in] TokenNumber The PCD token number to set a current value for.
564 @param[in] Value The 64-bit value to set.
566 @return Return the value that was set.
572 IN UINTN TokenNumber
,
576 GetPcdProtocol()->Set64 (TokenNumber
, Value
);
584 This function provides a means by which to set a value for a given PCD token.
586 Sets a buffer for the token specified by TokenNumber to the value
587 specified by Buffer and SizeOfBuffer. Buffer is returned.
588 If SizeOfBuffer is greater than the maximum size support by TokenNumber,
589 then set SizeOfBuffer to the maximum size supported by TokenNumber and
590 return NULL to indicate that the set operation was not actually performed.
592 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
593 maximum size supported by TokenName and NULL must be returned.
595 If SizeOfBuffer is NULL, then ASSERT().
596 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
598 @param[in] TokenNumber The PCD token number to set a current value for.
599 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
600 @param[in] Buffer A pointer to the buffer to set.
602 @return Return the pointer for the buffer been set.
608 IN UINTN TokenNumber
,
609 IN OUT UINTN
*SizeOfBuffer
,
610 IN CONST VOID
*Buffer
614 UINTN InputSizeOfBuffer
;
616 ASSERT (SizeOfBuffer
!= NULL
);
618 if (*SizeOfBuffer
> 0) {
619 ASSERT (Buffer
!= NULL
);
622 InputSizeOfBuffer
= *SizeOfBuffer
;
623 Status
= GetPcdProtocol()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*) Buffer
);
624 if (EFI_ERROR (Status
) && (*SizeOfBuffer
< InputSizeOfBuffer
)) {
628 return (VOID
*)Buffer
;
634 This function provides a means by which to set a value for a given PCD token.
636 Sets the Boolean value for the token specified by TokenNumber
637 to the value specified by Value. Value is returned.
639 @param[in] TokenNumber The PCD token number to set a current value for.
640 @param[in] Value The boolean value to set.
642 @return Return the value that was set.
648 IN UINTN TokenNumber
,
652 GetPcdProtocol()->SetBool (TokenNumber
, Value
);
660 This function provides a means by which to set a value for a given PCD token.
662 Sets the 8-bit value for the token specified by TokenNumber and
663 Guid to the value specified by Value. Value is returned.
665 If Guid is NULL, then ASSERT().
667 @param[in] Guid The pointer to a 128-bit unique value that
668 designates which namespace to set a value from.
669 @param[in] TokenNumber The PCD token number to set a current value for.
670 @param[in] Value The 8-bit value to set.
672 @return Return the value that was set.
679 IN UINTN TokenNumber
,
683 ASSERT (Guid
!= NULL
);
685 GetPiPcdProtocol()->Set8 (Guid
, TokenNumber
, Value
);
693 This function provides a means by which to set a value for a given PCD token.
695 Sets the 16-bit value for the token specified by TokenNumber and
696 Guid to the value specified by Value. Value is returned.
698 If Guid is NULL, then ASSERT().
700 @param[in] Guid The pointer to a 128-bit unique value that
701 designates which namespace to set a value from.
702 @param[in] TokenNumber The PCD token number to set a current value for.
703 @param[in] Value The 16-bit value to set.
705 @return Return the value that was set.
712 IN UINTN TokenNumber
,
716 ASSERT (Guid
!= NULL
);
718 GetPiPcdProtocol()->Set16 (Guid
, TokenNumber
, Value
);
726 This function provides a means by which to set a value for a given PCD token.
728 Sets the 32-bit value for the token specified by TokenNumber and
729 Guid to the value specified by Value. Value is returned.
731 If Guid is NULL, then ASSERT().
733 @param[in] Guid The pointer to a 128-bit unique value that
734 designates which namespace to set a value from.
735 @param[in] TokenNumber The PCD token number to set a current value for.
736 @param[in] Value The 32-bit value to set.
738 @return Return the value that was set.
745 IN UINTN TokenNumber
,
749 ASSERT (Guid
!= NULL
);
751 GetPiPcdProtocol()->Set32 (Guid
, TokenNumber
, Value
);
759 This function provides a means by which to set a value for a given PCD token.
761 Sets the 64-bit value for the token specified by TokenNumber and
762 Guid to the value specified by Value. Value is returned.
764 If Guid is NULL, then ASSERT().
766 @param[in] Guid The pointer to a 128-bit unique value that
767 designates which namespace to set a value from.
768 @param[in] TokenNumber The PCD token number to set a current value for.
769 @param[in] Value The 64-bit value to set.
771 @return Return the value that was set.
778 IN UINTN TokenNumber
,
782 ASSERT (Guid
!= NULL
);
784 GetPiPcdProtocol()->Set64 (Guid
, TokenNumber
, Value
);
792 This function provides a means by which to set a value for a given PCD token.
794 Sets a buffer for the token specified by TokenNumber to the value specified by
795 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
796 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
797 supported by TokenNumber and return NULL to indicate that the set operation
798 was not actually performed.
800 If Guid is NULL, then ASSERT().
801 If SizeOfBuffer is NULL, then ASSERT().
802 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
804 @param[in] Guid The pointer to a 128-bit unique value that
805 designates which namespace to set a value from.
806 @param[in] TokenNumber The PCD token number to set a current value for.
807 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
808 @param[in] Buffer A pointer to the buffer to set.
810 @return Return the pointer to the buffer been set.
817 IN UINTN TokenNumber
,
818 IN OUT UINTN
*SizeOfBuffer
,
823 UINTN InputSizeOfBuffer
;
825 ASSERT (Guid
!= NULL
);
827 ASSERT (SizeOfBuffer
!= NULL
);
829 if (*SizeOfBuffer
> 0) {
830 ASSERT (Buffer
!= NULL
);
833 InputSizeOfBuffer
= *SizeOfBuffer
;
834 Status
= GetPiPcdProtocol()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
835 if (EFI_ERROR (Status
) && (*SizeOfBuffer
< InputSizeOfBuffer
)) {
845 This function provides a means by which to set a value for a given PCD token.
847 Sets the Boolean value for the token specified by TokenNumber and
848 Guid to the value specified by Value. Value is returned.
850 If Guid is NULL, then ASSERT().
852 @param[in] Guid The pointer to a 128-bit unique value that
853 designates which namespace to set a value from.
854 @param[in] TokenNumber The PCD token number to set a current value for.
855 @param[in] Value The Boolean value to set.
857 @return Return the value that was set.
864 IN UINTN TokenNumber
,
868 ASSERT (Guid
!= NULL
);
870 GetPiPcdProtocol()->SetBool (Guid
, TokenNumber
, Value
);
877 This function provides a means by which to set a value for a given PCD token.
879 Sets the 8-bit value for the token specified by TokenNumber
880 to the value specified by Value.
882 @param[in] TokenNumber The PCD token number to set a current value for.
883 @param[in] Value The 8-bit value to set.
885 @return The status of the set operation.
891 IN UINTN TokenNumber
,
895 return GetPcdProtocol()->Set8 (TokenNumber
, Value
);
899 This function provides a means by which to set a value for a given PCD token.
901 Sets the 16-bit value for the token specified by TokenNumber
902 to the value specified by Value.
904 @param[in] TokenNumber The PCD token number to set a current value for.
905 @param[in] Value The 16-bit value to set.
907 @return The status of the set operation.
913 IN UINTN TokenNumber
,
917 return GetPcdProtocol()->Set16 (TokenNumber
, Value
);
921 This function provides a means by which to set a value for a given PCD token.
923 Sets the 32-bit value for the token specified by TokenNumber
924 to the value specified by Value.
926 @param[in] TokenNumber The PCD token number to set a current value for.
927 @param[in] Value The 32-bit value to set.
929 @return The status of the set operation.
935 IN UINTN TokenNumber
,
939 return GetPcdProtocol()->Set32 (TokenNumber
, Value
);
943 This function provides a means by which to set a value for a given PCD token.
945 Sets the 64-bit value for the token specified by TokenNumber
946 to the value specified by Value.
948 @param[in] TokenNumber The PCD token number to set a current value for.
949 @param[in] Value The 64-bit value to set.
951 @return The status of the set operation.
957 IN UINTN TokenNumber
,
961 return GetPcdProtocol()->Set64 (TokenNumber
, Value
);
965 This function provides a means by which to set a value for a given PCD token.
967 Sets a buffer for the token specified by TokenNumber to the value specified
968 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
969 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
970 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
971 was not actually performed.
973 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
974 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
976 If SizeOfBuffer is NULL, then ASSERT().
977 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
979 @param[in] TokenNumber The PCD token number to set a current value for.
980 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
981 @param[in] Buffer A pointer to the buffer to set.
983 @return The status of the set operation.
989 IN UINTN TokenNumber
,
990 IN OUT UINTN
*SizeOfBuffer
,
991 IN CONST VOID
*Buffer
994 ASSERT (SizeOfBuffer
!= NULL
);
996 if (*SizeOfBuffer
> 0) {
997 ASSERT (Buffer
!= NULL
);
1000 return GetPcdProtocol()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*) Buffer
);
1004 This function provides a means by which to set a value for a given PCD token.
1006 Sets the boolean value for the token specified by TokenNumber
1007 to the value specified by Value.
1009 @param[in] TokenNumber The PCD token number to set a current value for.
1010 @param[in] Value The boolean value to set.
1012 @return The status of the set operation.
1018 IN UINTN TokenNumber
,
1022 return GetPcdProtocol()->SetBool (TokenNumber
, Value
);
1026 This function provides a means by which to set a value for a given PCD token.
1028 Sets the 8-bit value for the token specified by TokenNumber
1029 to the value specified by Value.
1031 If Guid is NULL, then ASSERT().
1033 @param[in] Guid The pointer to a 128-bit unique value that
1034 designates which namespace to set a value from.
1035 @param[in] TokenNumber The PCD token number to set a current value for.
1036 @param[in] Value The 8-bit value to set.
1038 @return The status of the set operation.
1044 IN CONST GUID
*Guid
,
1045 IN UINTN TokenNumber
,
1049 ASSERT (Guid
!= NULL
);
1051 return GetPiPcdProtocol()->Set8 (Guid
, TokenNumber
, Value
);
1055 This function provides a means by which to set a value for a given PCD token.
1057 Sets the 16-bit value for the token specified by TokenNumber
1058 to the value specified by Value.
1060 If Guid is NULL, then ASSERT().
1062 @param[in] Guid The pointer to a 128-bit unique value that
1063 designates which namespace to set a value from.
1064 @param[in] TokenNumber The PCD token number to set a current value for.
1065 @param[in] Value The 16-bit value to set.
1067 @return The status of the set operation.
1073 IN CONST GUID
*Guid
,
1074 IN UINTN TokenNumber
,
1078 ASSERT (Guid
!= NULL
);
1080 return GetPiPcdProtocol()->Set16 (Guid
, TokenNumber
, Value
);
1084 This function provides a means by which to set a value for a given PCD token.
1086 Sets the 32-bit value for the token specified by TokenNumber
1087 to the value specified by Value.
1089 If Guid is NULL, then ASSERT().
1091 @param[in] Guid The pointer to a 128-bit unique value that
1092 designates which namespace to set a value from.
1093 @param[in] TokenNumber The PCD token number to set a current value for.
1094 @param[in] Value The 32-bit value to set.
1096 @return The status of the set operation.
1102 IN CONST GUID
*Guid
,
1103 IN UINTN TokenNumber
,
1107 ASSERT (Guid
!= NULL
);
1109 return GetPiPcdProtocol()->Set32 (Guid
, TokenNumber
, Value
);
1113 This function provides a means by which to set a value for a given PCD token.
1115 Sets the 64-bit value for the token specified by TokenNumber
1116 to the value specified by Value.
1118 If Guid is NULL, then ASSERT().
1120 @param[in] Guid The pointer to a 128-bit unique value that
1121 designates which namespace to set a value from.
1122 @param[in] TokenNumber The PCD token number to set a current value for.
1123 @param[in] Value The 64-bit value to set.
1125 @return The status of the set operation.
1131 IN CONST GUID
*Guid
,
1132 IN UINTN TokenNumber
,
1136 ASSERT (Guid
!= NULL
);
1138 return GetPiPcdProtocol()->Set64 (Guid
, TokenNumber
, Value
);
1142 This function provides a means by which to set a value for a given PCD token.
1144 Sets a buffer for the token specified by TokenNumber to the value specified by
1145 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
1146 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
1147 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
1148 was not actually performed.
1150 If Guid is NULL, then ASSERT().
1151 If SizeOfBuffer is NULL, then ASSERT().
1152 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1154 @param[in] Guid Pointer to a 128-bit unique value that
1155 designates which namespace to set a value from.
1156 @param[in] TokenNumber The PCD token number to set a current value for.
1157 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
1158 @param[in] Buffer A pointer to the buffer to set.
1160 @return The status of the set operation.
1166 IN CONST GUID
*Guid
,
1167 IN UINTN TokenNumber
,
1168 IN OUT UINTN
*SizeOfBuffer
,
1172 ASSERT (Guid
!= NULL
);
1174 ASSERT (SizeOfBuffer
!= NULL
);
1176 if (*SizeOfBuffer
> 0) {
1177 ASSERT (Buffer
!= NULL
);
1180 return GetPiPcdProtocol()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
1184 This function provides a means by which to set a value for a given PCD token.
1186 Sets the boolean value for the token specified by TokenNumber
1187 to the value specified by Value.
1189 If Guid is NULL, then ASSERT().
1191 @param[in] Guid The pointer to a 128-bit unique value that
1192 designates which namespace to set a value from.
1193 @param[in] TokenNumber The PCD token number to set a current value for.
1194 @param[in] Value The boolean value to set.
1196 @return The status of the set operation.
1202 IN CONST GUID
*Guid
,
1203 IN UINTN TokenNumber
,
1207 ASSERT (Guid
!= NULL
);
1209 return GetPiPcdProtocol()->SetBool (Guid
, TokenNumber
, Value
);
1213 Set up a notification function that is called when a specified token is set.
1215 When the token specified by TokenNumber and Guid is set,
1216 then notification function specified by NotificationFunction is called.
1217 If Guid is NULL, then the default token space is used.
1218 If NotificationFunction is NULL, then ASSERT().
1220 @param[in] Guid The pointer to a 128-bit unique value that designates which
1221 namespace to set a value from. If NULL, then the default
1222 token space is used.
1223 @param[in] TokenNumber The PCD token number to monitor.
1224 @param[in] NotificationFunction The function to call when the token
1225 specified by Guid and TokenNumber is set.
1230 LibPcdCallbackOnSet (
1231 IN CONST GUID
*Guid
, OPTIONAL
1232 IN UINTN TokenNumber
,
1233 IN PCD_CALLBACK NotificationFunction
1238 ASSERT (NotificationFunction
!= NULL
);
1240 Status
= GetPiPcdProtocol()->CallbackOnSet (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
1241 ASSERT_EFI_ERROR (Status
);
1249 Disable a notification function that was established with LibPcdCallbackonSet().
1251 Disable a notification function that was previously established with LibPcdCallbackOnSet().
1252 If NotificationFunction is NULL, then ASSERT().
1253 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
1254 and NotificationFunction, then ASSERT().
1256 @param[in] Guid Specify the GUID token space.
1257 @param[in] TokenNumber Specify the token number.
1258 @param[in] NotificationFunction The callback function to be unregistered.
1263 LibPcdCancelCallback (
1264 IN CONST GUID
*Guid
, OPTIONAL
1265 IN UINTN TokenNumber
,
1266 IN PCD_CALLBACK NotificationFunction
1271 ASSERT (NotificationFunction
!= NULL
);
1273 Status
= GetPiPcdProtocol()->CancelCallback (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
1274 ASSERT_EFI_ERROR (Status
);
1282 Retrieves the next token in a token space.
1284 Retrieves the next PCD token number from the token space specified by Guid.
1285 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
1286 then the first token number is returned. Otherwise, the token number that
1287 follows TokenNumber in the token space is returned. If TokenNumber is the last
1288 token number in the token space, then 0 is returned.
1290 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
1292 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
1293 to set a value from. If NULL, then the default token space is used.
1294 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
1297 @return The next valid token number.
1302 LibPcdGetNextToken (
1303 IN CONST GUID
*Guid
, OPTIONAL
1304 IN UINTN TokenNumber
1309 Status
= GetPiPcdProtocol()->GetNextToken (Guid
, &TokenNumber
);
1310 ASSERT (!EFI_ERROR (Status
) || TokenNumber
== 0);
1318 Used to retrieve the list of available PCD token space GUIDs.
1320 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
1322 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
1323 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
1325 @param TokenSpaceGuid The pointer to the a PCD token space GUID.
1327 @return The next valid token namespace.
1332 LibPcdGetNextTokenSpace (
1333 IN CONST GUID
*TokenSpaceGuid
1336 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid
);
1338 return (GUID
*)TokenSpaceGuid
;
1343 Sets a value of a patchable PCD entry that is type pointer.
1345 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1346 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1347 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1348 NULL to indicate that the set operation was not actually performed.
1349 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1350 MaximumDatumSize and NULL must be returned.
1352 If PatchVariable is NULL, then ASSERT().
1353 If SizeOfBuffer is NULL, then ASSERT().
1354 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1356 @param[out] PatchVariable A pointer to the global variable in a module that is
1357 the target of the set operation.
1358 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1359 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1360 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1362 @return Return the pointer to the buffer been set.
1368 OUT VOID
*PatchVariable
,
1369 IN UINTN MaximumDatumSize
,
1370 IN OUT UINTN
*SizeOfBuffer
,
1371 IN CONST VOID
*Buffer
1374 ASSERT (PatchVariable
!= NULL
);
1375 ASSERT (SizeOfBuffer
!= NULL
);
1377 if (*SizeOfBuffer
> 0) {
1378 ASSERT (Buffer
!= NULL
);
1381 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1382 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1383 *SizeOfBuffer
= MaximumDatumSize
;
1387 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1389 return (VOID
*) Buffer
;
1393 Sets a value of a patchable PCD entry that is type pointer.
1395 Sets the PCD entry specified by PatchVariable to the value specified
1396 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1397 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1398 to indicate that the set operation was not actually performed.
1399 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1400 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1402 If PatchVariable is NULL, then ASSERT().
1403 If SizeOfBuffer is NULL, then ASSERT().
1404 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1406 @param[out] PatchVariable A pointer to the global variable in a module that is
1407 the target of the set operation.
1408 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1409 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1410 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1412 @return The status of the set operation.
1417 LibPatchPcdSetPtrS (
1418 OUT VOID
*PatchVariable
,
1419 IN UINTN MaximumDatumSize
,
1420 IN OUT UINTN
*SizeOfBuffer
,
1421 IN CONST VOID
*Buffer
1424 ASSERT (PatchVariable
!= NULL
);
1425 ASSERT (SizeOfBuffer
!= NULL
);
1427 if (*SizeOfBuffer
> 0) {
1428 ASSERT (Buffer
!= NULL
);
1431 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1432 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1433 *SizeOfBuffer
= MaximumDatumSize
;
1434 return RETURN_INVALID_PARAMETER
;
1437 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1439 return RETURN_SUCCESS
;
1444 Sets a value and size of a patchable PCD entry that is type pointer.
1446 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1447 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1448 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1449 NULL to indicate that the set operation was not actually performed.
1450 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1451 MaximumDatumSize and NULL must be returned.
1453 If PatchVariable is NULL, then ASSERT().
1454 If SizeOfPatchVariable is NULL, then ASSERT().
1455 If SizeOfBuffer is NULL, then ASSERT().
1456 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1458 @param[out] PatchVariable A pointer to the global variable in a module that is
1459 the target of the set operation.
1460 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1461 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1462 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1463 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1465 @return Return the pointer to the buffer been set.
1470 LibPatchPcdSetPtrAndSize (
1471 OUT VOID
*PatchVariable
,
1472 OUT UINTN
*SizeOfPatchVariable
,
1473 IN UINTN MaximumDatumSize
,
1474 IN OUT UINTN
*SizeOfBuffer
,
1475 IN CONST VOID
*Buffer
1478 ASSERT (PatchVariable
!= NULL
);
1479 ASSERT (SizeOfPatchVariable
!= NULL
);
1480 ASSERT (SizeOfBuffer
!= NULL
);
1482 if (*SizeOfBuffer
> 0) {
1483 ASSERT (Buffer
!= NULL
);
1486 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1487 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1488 *SizeOfBuffer
= MaximumDatumSize
;
1492 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1493 *SizeOfPatchVariable
= *SizeOfBuffer
;
1495 return (VOID
*) Buffer
;
1499 Sets a value and size of a patchable PCD entry that is type pointer.
1501 Sets the PCD entry specified by PatchVariable to the value specified
1502 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1503 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1504 to indicate that the set operation was not actually performed.
1505 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1506 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1508 If PatchVariable is NULL, then ASSERT().
1509 If SizeOfPatchVariable is NULL, then ASSERT().
1510 If SizeOfBuffer is NULL, then ASSERT().
1511 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1513 @param[out] PatchVariable A pointer to the global variable in a module that is
1514 the target of the set operation.
1515 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1516 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1517 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1518 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1520 @return The status of the set operation.
1525 LibPatchPcdSetPtrAndSizeS (
1526 OUT VOID
*PatchVariable
,
1527 OUT UINTN
*SizeOfPatchVariable
,
1528 IN UINTN MaximumDatumSize
,
1529 IN OUT UINTN
*SizeOfBuffer
,
1530 IN CONST VOID
*Buffer
1533 ASSERT (PatchVariable
!= NULL
);
1534 ASSERT (SizeOfPatchVariable
!= NULL
);
1535 ASSERT (SizeOfBuffer
!= NULL
);
1537 if (*SizeOfBuffer
> 0) {
1538 ASSERT (Buffer
!= NULL
);
1541 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1542 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1543 *SizeOfBuffer
= MaximumDatumSize
;
1544 return RETURN_INVALID_PARAMETER
;
1547 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1548 *SizeOfPatchVariable
= *SizeOfBuffer
;
1550 return RETURN_SUCCESS
;
1554 Retrieve additional information associated with a PCD token.
1556 This includes information such as the type of value the TokenNumber is associated with as well as possible
1557 human readable name that is associated with the token.
1559 If TokenNumber is not in the default token space specified, then ASSERT().
1561 @param[in] TokenNumber The PCD token number.
1562 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1563 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1568 IN UINTN TokenNumber
,
1569 OUT PCD_INFO
*PcdInfo
1574 Status
= GetPcdInfoProtocolPointer()->GetInfo (TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1575 ASSERT_EFI_ERROR (Status
);
1579 Retrieve additional information associated with a PCD token.
1581 This includes information such as the type of value the TokenNumber is associated with as well as possible
1582 human readable name that is associated with the token.
1584 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1586 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1587 @param[in] TokenNumber The PCD token number.
1588 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1589 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1594 IN CONST GUID
*Guid
,
1595 IN UINTN TokenNumber
,
1596 OUT PCD_INFO
*PcdInfo
1601 Status
= GetPiPcdInfoProtocolPointer()->GetInfo (Guid
, TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1602 ASSERT_EFI_ERROR (Status
);
1606 Retrieve the currently set SKU Id.
1608 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1609 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1618 return GetPiPcdInfoProtocolPointer()->GetSku ();