2 Implementation of PcdLib class library for DXE phase.
4 Copyright (c) 2006 - 2016, 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.
19 #include <Protocol/Pcd.h>
20 #include <Protocol/PiPcd.h>
21 #include <Protocol/PcdInfo.h>
22 #include <Protocol/PiPcdInfo.h>
24 #include <Library/PcdLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <Library/BaseMemoryLib.h>
29 PCD_PROTOCOL
*mPcd
= NULL
;
30 EFI_PCD_PROTOCOL
*mPiPcd
= NULL
;
31 GET_PCD_INFO_PROTOCOL
*mPcdInfo
= NULL
;
32 EFI_GET_PCD_INFO_PROTOCOL
*mPiPcdInfo
= NULL
;
35 Retrieves the PI PCD protocol from the handle database.
37 @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.
49 // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module
50 // access DynamicEx type PCD.
52 Status
= gBS
->LocateProtocol (&gEfiPcdProtocolGuid
, NULL
, (VOID
**) &mPiPcd
);
53 ASSERT_EFI_ERROR (Status
);
54 ASSERT (mPiPcd
!= NULL
);
60 Retrieves the PCD protocol from the handle database.
62 @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.
74 // PCD protocol need to be installed before the module access Dynamic type PCD.
75 // But dynamic type PCD is not required in PI 1.2 specification.
77 Status
= gBS
->LocateProtocol (&gPcdProtocolGuid
, NULL
, (VOID
**)&mPcd
);
78 ASSERT_EFI_ERROR (Status
);
79 ASSERT (mPcd
!= NULL
);
85 Retrieves the PI PCD info protocol from the handle database.
87 @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.
89 EFI_GET_PCD_INFO_PROTOCOL
*
90 GetPiPcdInfoProtocolPointer (
96 if (mPiPcdInfo
== NULL
) {
97 Status
= gBS
->LocateProtocol (&gEfiGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPiPcdInfo
);
98 ASSERT_EFI_ERROR (Status
);
99 ASSERT (mPiPcdInfo
!= NULL
);
105 Retrieves the PCD info protocol from the handle database.
107 @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.
109 GET_PCD_INFO_PROTOCOL
*
110 GetPcdInfoProtocolPointer (
116 if (mPcdInfo
== NULL
) {
117 Status
= gBS
->LocateProtocol (&gGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPcdInfo
);
118 ASSERT_EFI_ERROR (Status
);
119 ASSERT (mPcdInfo
!= NULL
);
125 This function provides a means by which SKU support can be established in the PCD infrastructure.
127 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
129 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values
130 associated with a PCD token.
132 @return Return the SKU ID that just be set.
141 GetPcdProtocol()->SetSku (SkuId
);
149 This function provides a means by which to retrieve a value for a given PCD token.
151 Returns the 8-bit value for the token specified by TokenNumber.
153 @param[in] TokenNumber The PCD token number to retrieve a current value for.
155 @return Returns the 8-bit value for the token specified by TokenNumber.
164 return GetPcdProtocol()->Get8 (TokenNumber
);
170 This function provides a means by which to retrieve a value for a given PCD token.
172 Returns the 16-bit value for the token specified by TokenNumber.
174 @param[in] TokenNumber The PCD token number to retrieve a current value for.
176 @return Returns the 16-bit value for the token specified by TokenNumber.
185 return GetPcdProtocol()->Get16 (TokenNumber
);
191 This function provides a means by which to retrieve a value for a given PCD token.
193 Returns the 32-bit value for the token specified by TokenNumber.
195 @param[in] TokenNumber The PCD token number to retrieve a current value for.
197 @return Returns the 32-bit value for the token specified by TokenNumber.
206 return GetPcdProtocol()->Get32 (TokenNumber
);
212 This function provides a means by which to retrieve a value for a given PCD token.
214 Returns the 64-bit value for the token specified by TokenNumber.
216 @param[in] TokenNumber The PCD token number to retrieve a current value for.
218 @return Returns the 64-bit value for the token specified by TokenNumber.
227 return GetPcdProtocol()->Get64 (TokenNumber
);
233 This function provides a means by which to retrieve a value for a given PCD token.
235 Returns the pointer to the buffer of the token specified by TokenNumber.
237 @param[in] TokenNumber The PCD token number to retrieve a current value for.
239 @return Returns the pointer to the token specified by TokenNumber.
248 return GetPcdProtocol()->GetPtr (TokenNumber
);
254 This function provides a means by which to retrieve a value for a given PCD token.
256 Returns the Boolean value of the token specified by TokenNumber.
258 @param[in] TokenNumber The PCD token number to retrieve a current value for.
260 @return Returns the Boolean value of the token specified by TokenNumber.
269 return GetPcdProtocol()->GetBool (TokenNumber
);
275 This function provides a means by which to retrieve the size of a given PCD token.
277 @param[in] TokenNumber The PCD token number to retrieve a current value for.
279 @return Returns the size of the token specified by TokenNumber.
288 return GetPcdProtocol()->GetSize (TokenNumber
);
294 This function provides a means by which to retrieve a value for a given PCD token.
296 Returns the 8-bit value for the token specified by TokenNumber and Guid.
298 If Guid is NULL, then ASSERT().
300 @param[in] Guid The pointer to a 128-bit unique value that designates
301 which namespace to retrieve a value from.
302 @param[in] TokenNumber The PCD token number to retrieve a current value for.
304 @return Return the UINT8.
314 ASSERT (Guid
!= NULL
);
316 return GetPiPcdProtocol()->Get8 (Guid
, TokenNumber
);
321 This function provides a means by which to retrieve a value for a given PCD token.
323 Returns the 16-bit value for the token specified by TokenNumber and Guid.
325 If Guid is NULL, then ASSERT().
327 @param[in] Guid The pointer to a 128-bit unique value that designates
328 which namespace to retrieve a value from.
329 @param[in] TokenNumber The PCD token number to retrieve a current value for.
331 @return Return the UINT16.
341 ASSERT (Guid
!= NULL
);
343 return GetPiPcdProtocol()->Get16 (Guid
, TokenNumber
);
348 Returns the 32-bit value for the token specified by TokenNumber and Guid.
349 If Guid is NULL, then ASSERT().
351 @param[in] Guid The pointer to a 128-bit unique value that designates
352 which namespace to retrieve a value from.
353 @param[in] TokenNumber The PCD token number to retrieve a current value for.
355 @return Return the UINT32.
365 ASSERT (Guid
!= NULL
);
367 return GetPiPcdProtocol()->Get32 (Guid
, TokenNumber
);
373 This function provides a means by which to retrieve a value for a given PCD token.
375 Returns the 64-bit value for the token specified by TokenNumber and Guid.
377 If Guid is NULL, then ASSERT().
379 @param[in] Guid The pointer to a 128-bit unique value that designates
380 which namespace to retrieve a value from.
381 @param[in] TokenNumber The PCD token number to retrieve a current value for.
383 @return Return the UINT64.
393 ASSERT (Guid
!= NULL
);
395 return GetPiPcdProtocol()->Get64 (Guid
, TokenNumber
);
401 This function provides a means by which to retrieve a value for a given PCD token.
403 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
405 If Guid is NULL, then ASSERT().
407 @param[in] Guid The pointer to a 128-bit unique value that designates
408 which namespace to retrieve a value from.
409 @param[in] TokenNumber The PCD token number to retrieve a current value for.
411 @return Return the VOID* pointer.
421 ASSERT (Guid
!= NULL
);
423 return GetPiPcdProtocol()->GetPtr (Guid
, TokenNumber
);
429 This function provides a means by which to retrieve a value for a given PCD token.
431 Returns the Boolean value of the token specified by TokenNumber and Guid.
433 If Guid is NULL, then ASSERT().
435 @param[in] Guid The pointer to a 128-bit unique value that designates
436 which namespace to retrieve a value from.
437 @param[in] TokenNumber The PCD token number to retrieve a current value for.
439 @return Return the BOOLEAN.
449 ASSERT (Guid
!= NULL
);
451 return GetPiPcdProtocol()->GetBool (Guid
, TokenNumber
);
457 This function provides a means by which to retrieve the size of a given PCD token.
459 Returns the size of the token specified by TokenNumber and Guid.
461 If Guid is NULL, then ASSERT().
463 @param[in] Guid The pointer to a 128-bit unique value that designates
464 which namespace to retrieve a value from.
465 @param[in] TokenNumber The PCD token number to retrieve a current value for.
467 @return Return the size.
477 ASSERT (Guid
!= NULL
);
479 return GetPiPcdProtocol()->GetSize (Guid
, TokenNumber
);
484 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
486 This function provides a means by which to set a value for a given PCD token.
488 Sets the 8-bit value for the token specified by TokenNumber
489 to the value specified by Value. Value is returned.
491 @param[in] TokenNumber The PCD token number to set a current value for.
492 @param[in] Value The 8-bit value to set.
494 @return Return the value that was set.
500 IN UINTN TokenNumber
,
504 GetPcdProtocol()->Set8 (TokenNumber
, Value
);
512 This function provides a means by which to set a value for a given PCD token.
514 Sets the 16-bit value for the token specified by TokenNumber
515 to the value specified by Value. Value is returned.
517 @param[in] TokenNumber The PCD token number to set a current value for.
518 @param[in] Value The 16-bit value to set.
520 @return Return the value that was set.
526 IN UINTN TokenNumber
,
530 GetPcdProtocol()->Set16 (TokenNumber
, Value
);
538 This function provides a means by which to set a value for a given PCD token.
540 Sets the 32-bit value for the token specified by TokenNumber
541 to the value specified by Value. Value is returned.
543 @param[in] TokenNumber The PCD token number to set a current value for.
544 @param[in] Value The 32-bit value to set.
546 @return Return the value that was set.
552 IN UINTN TokenNumber
,
556 GetPcdProtocol()->Set32 (TokenNumber
, Value
);
564 This function provides a means by which to set a value for a given PCD token.
566 Sets the 64-bit value for the token specified by TokenNumber
567 to the value specified by Value. Value is returned.
569 @param[in] TokenNumber The PCD token number to set a current value for.
570 @param[in] Value The 64-bit value to set.
572 @return Return the value that was set.
578 IN UINTN TokenNumber
,
582 GetPcdProtocol()->Set64 (TokenNumber
, Value
);
590 This function provides a means by which to set a value for a given PCD token.
592 Sets a buffer for the token specified by TokenNumber to the value
593 specified by Buffer and SizeOfBuffer. Buffer is returned.
594 If SizeOfBuffer is greater than the maximum size support by TokenNumber,
595 then set SizeOfBuffer to the maximum size supported by TokenNumber and
596 return NULL to indicate that the set operation was not actually performed.
598 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
599 maximum size supported by TokenName and NULL must be returned.
601 If SizeOfBuffer is NULL, then ASSERT().
602 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
604 @param[in] TokenNumber The PCD token number to set a current value for.
605 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
606 @param[in] Buffer A pointer to the buffer to set.
608 @return Return the pointer for the buffer been set.
614 IN UINTN TokenNumber
,
615 IN OUT UINTN
*SizeOfBuffer
,
616 IN CONST VOID
*Buffer
620 UINTN InputSizeOfBuffer
;
622 ASSERT (SizeOfBuffer
!= NULL
);
624 if (*SizeOfBuffer
> 0) {
625 ASSERT (Buffer
!= NULL
);
628 InputSizeOfBuffer
= *SizeOfBuffer
;
629 Status
= GetPcdProtocol()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*) Buffer
);
630 if (EFI_ERROR (Status
) && (*SizeOfBuffer
< InputSizeOfBuffer
)) {
634 return (VOID
*)Buffer
;
640 This function provides a means by which to set a value for a given PCD token.
642 Sets the Boolean value for the token specified by TokenNumber
643 to the value specified by Value. Value is returned.
645 @param[in] TokenNumber The PCD token number to set a current value for.
646 @param[in] Value The boolean value to set.
648 @return Return the value that was set.
654 IN UINTN TokenNumber
,
658 GetPcdProtocol()->SetBool (TokenNumber
, Value
);
666 This function provides a means by which to set a value for a given PCD token.
668 Sets the 8-bit value for the token specified by TokenNumber and
669 Guid to the value specified by Value. Value is returned.
671 If Guid is NULL, then ASSERT().
673 @param[in] Guid The 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] Value The 8-bit value to set.
678 @return Return the value that was set.
685 IN UINTN TokenNumber
,
689 ASSERT (Guid
!= NULL
);
691 GetPiPcdProtocol()->Set8 (Guid
, TokenNumber
, Value
);
699 This function provides a means by which to set a value for a given PCD token.
701 Sets the 16-bit value for the token specified by TokenNumber and
702 Guid to the value specified by Value. Value is returned.
704 If Guid is NULL, then ASSERT().
706 @param[in] Guid The pointer to a 128-bit unique value that
707 designates which namespace to set a value from.
708 @param[in] TokenNumber The PCD token number to set a current value for.
709 @param[in] Value The 16-bit value to set.
711 @return Return the value that was set.
718 IN UINTN TokenNumber
,
722 ASSERT (Guid
!= NULL
);
724 GetPiPcdProtocol()->Set16 (Guid
, TokenNumber
, Value
);
732 This function provides a means by which to set a value for a given PCD token.
734 Sets the 32-bit value for the token specified by TokenNumber and
735 Guid to the value specified by Value. Value is returned.
737 If Guid is NULL, then ASSERT().
739 @param[in] Guid The pointer to a 128-bit unique value that
740 designates which namespace to set a value from.
741 @param[in] TokenNumber The PCD token number to set a current value for.
742 @param[in] Value The 32-bit value to set.
744 @return Return the value that was set.
751 IN UINTN TokenNumber
,
755 ASSERT (Guid
!= NULL
);
757 GetPiPcdProtocol()->Set32 (Guid
, TokenNumber
, Value
);
765 This function provides a means by which to set a value for a given PCD token.
767 Sets the 64-bit value for the token specified by TokenNumber and
768 Guid to the value specified by Value. Value is returned.
770 If Guid is NULL, then ASSERT().
772 @param[in] Guid The pointer to a 128-bit unique value that
773 designates which namespace to set a value from.
774 @param[in] TokenNumber The PCD token number to set a current value for.
775 @param[in] Value The 64-bit value to set.
777 @return Return the value that was set.
784 IN UINTN TokenNumber
,
788 ASSERT (Guid
!= NULL
);
790 GetPiPcdProtocol()->Set64 (Guid
, TokenNumber
, Value
);
798 This function provides a means by which to set a value for a given PCD token.
800 Sets a buffer for the token specified by TokenNumber to the value specified by
801 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
802 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
803 supported by TokenNumber and return NULL to indicate that the set operation
804 was not actually performed.
806 If Guid is NULL, then ASSERT().
807 If SizeOfBuffer is NULL, then ASSERT().
808 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
810 @param[in] Guid The pointer to a 128-bit unique value that
811 designates which namespace to set a value from.
812 @param[in] TokenNumber The PCD token number to set a current value for.
813 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
814 @param[in] Buffer A pointer to the buffer to set.
816 @return Return the pointer to the buffer been set.
823 IN UINTN TokenNumber
,
824 IN OUT UINTN
*SizeOfBuffer
,
829 UINTN InputSizeOfBuffer
;
831 ASSERT (Guid
!= NULL
);
833 ASSERT (SizeOfBuffer
!= NULL
);
835 if (*SizeOfBuffer
> 0) {
836 ASSERT (Buffer
!= NULL
);
839 InputSizeOfBuffer
= *SizeOfBuffer
;
840 Status
= GetPiPcdProtocol()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
841 if (EFI_ERROR (Status
) && (*SizeOfBuffer
< InputSizeOfBuffer
)) {
851 This function provides a means by which to set a value for a given PCD token.
853 Sets the Boolean value for the token specified by TokenNumber and
854 Guid to the value specified by Value. Value is returned.
856 If Guid is NULL, then ASSERT().
858 @param[in] Guid The pointer to a 128-bit unique value that
859 designates which namespace to set a value from.
860 @param[in] TokenNumber The PCD token number to set a current value for.
861 @param[in] Value The Boolean value to set.
863 @return Return the value that was set.
870 IN UINTN TokenNumber
,
874 ASSERT (Guid
!= NULL
);
876 GetPiPcdProtocol()->SetBool (Guid
, TokenNumber
, Value
);
883 This function provides a means by which to set a value for a given PCD token.
885 Sets the 8-bit value for the token specified by TokenNumber
886 to the value specified by Value.
888 @param[in] TokenNumber The PCD token number to set a current value for.
889 @param[in] Value The 8-bit value to set.
891 @return The status of the set operation.
897 IN UINTN TokenNumber
,
901 return GetPcdProtocol()->Set8 (TokenNumber
, Value
);
905 This function provides a means by which to set a value for a given PCD token.
907 Sets the 16-bit value for the token specified by TokenNumber
908 to the value specified by Value.
910 @param[in] TokenNumber The PCD token number to set a current value for.
911 @param[in] Value The 16-bit value to set.
913 @return The status of the set operation.
919 IN UINTN TokenNumber
,
923 return GetPcdProtocol()->Set16 (TokenNumber
, Value
);
927 This function provides a means by which to set a value for a given PCD token.
929 Sets the 32-bit value for the token specified by TokenNumber
930 to the value specified by Value.
932 @param[in] TokenNumber The PCD token number to set a current value for.
933 @param[in] Value The 32-bit value to set.
935 @return The status of the set operation.
941 IN UINTN TokenNumber
,
945 return GetPcdProtocol()->Set32 (TokenNumber
, Value
);
949 This function provides a means by which to set a value for a given PCD token.
951 Sets the 64-bit value for the token specified by TokenNumber
952 to the value specified by Value.
954 @param[in] TokenNumber The PCD token number to set a current value for.
955 @param[in] Value The 64-bit value to set.
957 @return The status of the set operation.
963 IN UINTN TokenNumber
,
967 return GetPcdProtocol()->Set64 (TokenNumber
, Value
);
971 This function provides a means by which to set a value for a given PCD token.
973 Sets a buffer for the token specified by TokenNumber to the value specified
974 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
975 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
976 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
977 was not actually performed.
979 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
980 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
982 If SizeOfBuffer is NULL, then ASSERT().
983 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
985 @param[in] TokenNumber The PCD token number to set a current value for.
986 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
987 @param[in] Buffer A pointer to the buffer to set.
989 @return The status of the set operation.
995 IN UINTN TokenNumber
,
996 IN OUT UINTN
*SizeOfBuffer
,
997 IN CONST VOID
*Buffer
1000 ASSERT (SizeOfBuffer
!= NULL
);
1002 if (*SizeOfBuffer
> 0) {
1003 ASSERT (Buffer
!= NULL
);
1006 return GetPcdProtocol()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*) Buffer
);
1010 This function provides a means by which to set a value for a given PCD token.
1012 Sets the boolean value for the token specified by TokenNumber
1013 to the value specified by Value.
1015 @param[in] TokenNumber The PCD token number to set a current value for.
1016 @param[in] Value The boolean value to set.
1018 @return The status of the set operation.
1024 IN UINTN TokenNumber
,
1028 return GetPcdProtocol()->SetBool (TokenNumber
, Value
);
1032 This function provides a means by which to set a value for a given PCD token.
1034 Sets the 8-bit value for the token specified by TokenNumber
1035 to the value specified by Value.
1037 If Guid is NULL, then ASSERT().
1039 @param[in] Guid The pointer to a 128-bit unique value that
1040 designates which namespace to set a value from.
1041 @param[in] TokenNumber The PCD token number to set a current value for.
1042 @param[in] Value The 8-bit value to set.
1044 @return The status of the set operation.
1050 IN CONST GUID
*Guid
,
1051 IN UINTN TokenNumber
,
1055 ASSERT (Guid
!= NULL
);
1057 return GetPiPcdProtocol()->Set8 (Guid
, TokenNumber
, Value
);
1061 This function provides a means by which to set a value for a given PCD token.
1063 Sets the 16-bit value for the token specified by TokenNumber
1064 to the value specified by Value.
1066 If Guid is NULL, then ASSERT().
1068 @param[in] Guid The pointer to a 128-bit unique value that
1069 designates which namespace to set a value from.
1070 @param[in] TokenNumber The PCD token number to set a current value for.
1071 @param[in] Value The 16-bit value to set.
1073 @return The status of the set operation.
1079 IN CONST GUID
*Guid
,
1080 IN UINTN TokenNumber
,
1084 ASSERT (Guid
!= NULL
);
1086 return GetPiPcdProtocol()->Set16 (Guid
, TokenNumber
, Value
);
1090 This function provides a means by which to set a value for a given PCD token.
1092 Sets the 32-bit value for the token specified by TokenNumber
1093 to the value specified by Value.
1095 If Guid is NULL, then ASSERT().
1097 @param[in] Guid The pointer to a 128-bit unique value that
1098 designates which namespace to set a value from.
1099 @param[in] TokenNumber The PCD token number to set a current value for.
1100 @param[in] Value The 32-bit value to set.
1102 @return The status of the set operation.
1108 IN CONST GUID
*Guid
,
1109 IN UINTN TokenNumber
,
1113 ASSERT (Guid
!= NULL
);
1115 return GetPiPcdProtocol()->Set32 (Guid
, TokenNumber
, Value
);
1119 This function provides a means by which to set a value for a given PCD token.
1121 Sets the 64-bit value for the token specified by TokenNumber
1122 to the value specified by Value.
1124 If Guid is NULL, then ASSERT().
1126 @param[in] Guid The pointer to a 128-bit unique value that
1127 designates which namespace to set a value from.
1128 @param[in] TokenNumber The PCD token number to set a current value for.
1129 @param[in] Value The 64-bit value to set.
1131 @return The status of the set operation.
1137 IN CONST GUID
*Guid
,
1138 IN UINTN TokenNumber
,
1142 ASSERT (Guid
!= NULL
);
1144 return GetPiPcdProtocol()->Set64 (Guid
, TokenNumber
, Value
);
1148 This function provides a means by which to set a value for a given PCD token.
1150 Sets a buffer for the token specified by TokenNumber to the value specified by
1151 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
1152 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
1153 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
1154 was not actually performed.
1156 If Guid is NULL, then ASSERT().
1157 If SizeOfBuffer is NULL, then ASSERT().
1158 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1160 @param[in] Guid Pointer to a 128-bit unique value that
1161 designates which namespace to set a value from.
1162 @param[in] TokenNumber The PCD token number to set a current value for.
1163 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
1164 @param[in] Buffer A pointer to the buffer to set.
1166 @return The status of the set operation.
1172 IN CONST GUID
*Guid
,
1173 IN UINTN TokenNumber
,
1174 IN OUT UINTN
*SizeOfBuffer
,
1178 ASSERT (Guid
!= NULL
);
1180 ASSERT (SizeOfBuffer
!= NULL
);
1182 if (*SizeOfBuffer
> 0) {
1183 ASSERT (Buffer
!= NULL
);
1186 return GetPiPcdProtocol()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
1190 This function provides a means by which to set a value for a given PCD token.
1192 Sets the boolean value for the token specified by TokenNumber
1193 to the value specified by Value.
1195 If Guid is NULL, then ASSERT().
1197 @param[in] Guid The pointer to a 128-bit unique value that
1198 designates which namespace to set a value from.
1199 @param[in] TokenNumber The PCD token number to set a current value for.
1200 @param[in] Value The boolean value to set.
1202 @return The status of the set operation.
1208 IN CONST GUID
*Guid
,
1209 IN UINTN TokenNumber
,
1213 ASSERT (Guid
!= NULL
);
1215 return GetPiPcdProtocol()->SetBool (Guid
, TokenNumber
, Value
);
1219 Set up a notification function that is called when a specified token is set.
1221 When the token specified by TokenNumber and Guid is set,
1222 then notification function specified by NotificationFunction is called.
1223 If Guid is NULL, then the default token space is used.
1224 If NotificationFunction is NULL, then ASSERT().
1226 @param[in] Guid The pointer to a 128-bit unique value that designates which
1227 namespace to set a value from. If NULL, then the default
1228 token space is used.
1229 @param[in] TokenNumber The PCD token number to monitor.
1230 @param[in] NotificationFunction The function to call when the token
1231 specified by Guid and TokenNumber is set.
1236 LibPcdCallbackOnSet (
1237 IN CONST GUID
*Guid
, OPTIONAL
1238 IN UINTN TokenNumber
,
1239 IN PCD_CALLBACK NotificationFunction
1244 ASSERT (NotificationFunction
!= NULL
);
1246 Status
= GetPiPcdProtocol()->CallbackOnSet (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
1247 ASSERT_EFI_ERROR (Status
);
1255 Disable a notification function that was established with LibPcdCallbackonSet().
1257 Disable a notification function that was previously established with LibPcdCallbackOnSet().
1258 If NotificationFunction is NULL, then ASSERT().
1259 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
1260 and NotificationFunction, then ASSERT().
1262 @param[in] Guid Specify the GUID token space.
1263 @param[in] TokenNumber Specify the token number.
1264 @param[in] NotificationFunction The callback function to be unregistered.
1269 LibPcdCancelCallback (
1270 IN CONST GUID
*Guid
, OPTIONAL
1271 IN UINTN TokenNumber
,
1272 IN PCD_CALLBACK NotificationFunction
1277 ASSERT (NotificationFunction
!= NULL
);
1279 Status
= GetPiPcdProtocol()->CancelCallback (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
1280 ASSERT_EFI_ERROR (Status
);
1288 Retrieves the next token in a token space.
1290 Retrieves the next PCD token number from the token space specified by Guid.
1291 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
1292 then the first token number is returned. Otherwise, the token number that
1293 follows TokenNumber in the token space is returned. If TokenNumber is the last
1294 token number in the token space, then 0 is returned.
1296 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
1298 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
1299 to set a value from. If NULL, then the default token space is used.
1300 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
1303 @return The next valid token number.
1308 LibPcdGetNextToken (
1309 IN CONST GUID
*Guid
, OPTIONAL
1310 IN UINTN TokenNumber
1315 Status
= GetPiPcdProtocol()->GetNextToken (Guid
, &TokenNumber
);
1316 ASSERT (!EFI_ERROR (Status
) || TokenNumber
== 0);
1324 Used to retrieve the list of available PCD token space GUIDs.
1326 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
1328 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
1329 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
1331 @param TokenSpaceGuid The pointer to the a PCD token space GUID.
1333 @return The next valid token namespace.
1338 LibPcdGetNextTokenSpace (
1339 IN CONST GUID
*TokenSpaceGuid
1342 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid
);
1344 return (GUID
*)TokenSpaceGuid
;
1349 Sets a value of a patchable PCD entry that is type pointer.
1351 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1352 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1353 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1354 NULL to indicate that the set operation was not actually performed.
1355 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1356 MaximumDatumSize and NULL must be returned.
1358 If PatchVariable is NULL, then ASSERT().
1359 If SizeOfBuffer is NULL, then ASSERT().
1360 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1362 @param[out] PatchVariable A pointer to the global variable in a module that is
1363 the target of the set operation.
1364 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1365 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1366 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1368 @return Return the pointer to the buffer been set.
1374 OUT VOID
*PatchVariable
,
1375 IN UINTN MaximumDatumSize
,
1376 IN OUT UINTN
*SizeOfBuffer
,
1377 IN CONST VOID
*Buffer
1380 ASSERT (PatchVariable
!= NULL
);
1381 ASSERT (SizeOfBuffer
!= NULL
);
1383 if (*SizeOfBuffer
> 0) {
1384 ASSERT (Buffer
!= NULL
);
1387 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1388 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1389 *SizeOfBuffer
= MaximumDatumSize
;
1393 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1395 return (VOID
*) Buffer
;
1399 Sets a value of a patchable PCD entry that is type pointer.
1401 Sets the PCD entry specified by PatchVariable to the value specified
1402 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1403 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1404 to indicate that the set operation was not actually performed.
1405 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1406 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1408 If PatchVariable is NULL, then ASSERT().
1409 If SizeOfBuffer is NULL, then ASSERT().
1410 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1412 @param[out] PatchVariable A pointer to the global variable in a module that is
1413 the target of the set operation.
1414 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1415 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1416 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1418 @return The status of the set operation.
1423 LibPatchPcdSetPtrS (
1424 OUT VOID
*PatchVariable
,
1425 IN UINTN MaximumDatumSize
,
1426 IN OUT UINTN
*SizeOfBuffer
,
1427 IN CONST VOID
*Buffer
1430 ASSERT (PatchVariable
!= NULL
);
1431 ASSERT (SizeOfBuffer
!= NULL
);
1433 if (*SizeOfBuffer
> 0) {
1434 ASSERT (Buffer
!= NULL
);
1437 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1438 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1439 *SizeOfBuffer
= MaximumDatumSize
;
1440 return RETURN_INVALID_PARAMETER
;
1443 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1445 return RETURN_SUCCESS
;
1450 Sets a value and size of a patchable PCD entry that is type pointer.
1452 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1453 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1454 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1455 NULL to indicate that the set operation was not actually performed.
1456 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1457 MaximumDatumSize and NULL must be returned.
1459 If PatchVariable is NULL, then ASSERT().
1460 If SizeOfPatchVariable is NULL, then ASSERT().
1461 If SizeOfBuffer is NULL, then ASSERT().
1462 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1464 @param[out] PatchVariable A pointer to the global variable in a module that is
1465 the target of the set operation.
1466 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1467 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1468 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1469 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1471 @return Return the pointer to the buffer been set.
1476 LibPatchPcdSetPtrAndSize (
1477 OUT VOID
*PatchVariable
,
1478 OUT UINTN
*SizeOfPatchVariable
,
1479 IN UINTN MaximumDatumSize
,
1480 IN OUT UINTN
*SizeOfBuffer
,
1481 IN CONST VOID
*Buffer
1484 ASSERT (PatchVariable
!= NULL
);
1485 ASSERT (SizeOfPatchVariable
!= NULL
);
1486 ASSERT (SizeOfBuffer
!= NULL
);
1488 if (*SizeOfBuffer
> 0) {
1489 ASSERT (Buffer
!= NULL
);
1492 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1493 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1494 *SizeOfBuffer
= MaximumDatumSize
;
1498 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1499 *SizeOfPatchVariable
= *SizeOfBuffer
;
1501 return (VOID
*) Buffer
;
1505 Sets a value and size of a patchable PCD entry that is type pointer.
1507 Sets the PCD entry specified by PatchVariable to the value specified
1508 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1509 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1510 to indicate that the set operation was not actually performed.
1511 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1512 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1514 If PatchVariable is NULL, then ASSERT().
1515 If SizeOfPatchVariable is NULL, then ASSERT().
1516 If SizeOfBuffer is NULL, then ASSERT().
1517 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1519 @param[out] PatchVariable A pointer to the global variable in a module that is
1520 the target of the set operation.
1521 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1522 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1523 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1524 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1526 @return The status of the set operation.
1531 LibPatchPcdSetPtrAndSizeS (
1532 OUT VOID
*PatchVariable
,
1533 OUT UINTN
*SizeOfPatchVariable
,
1534 IN UINTN MaximumDatumSize
,
1535 IN OUT UINTN
*SizeOfBuffer
,
1536 IN CONST VOID
*Buffer
1539 ASSERT (PatchVariable
!= NULL
);
1540 ASSERT (SizeOfPatchVariable
!= NULL
);
1541 ASSERT (SizeOfBuffer
!= NULL
);
1543 if (*SizeOfBuffer
> 0) {
1544 ASSERT (Buffer
!= NULL
);
1547 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1548 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1549 *SizeOfBuffer
= MaximumDatumSize
;
1550 return RETURN_INVALID_PARAMETER
;
1553 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1554 *SizeOfPatchVariable
= *SizeOfBuffer
;
1556 return RETURN_SUCCESS
;
1560 Retrieve additional information associated with a PCD token.
1562 This includes information such as the type of value the TokenNumber is associated with as well as possible
1563 human readable name that is associated with the token.
1565 If TokenNumber is not in the default token space specified, then ASSERT().
1567 @param[in] TokenNumber The PCD token number.
1568 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1569 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1574 IN UINTN TokenNumber
,
1575 OUT PCD_INFO
*PcdInfo
1580 Status
= GetPcdInfoProtocolPointer()->GetInfo (TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1581 ASSERT_EFI_ERROR (Status
);
1585 Retrieve additional information associated with a PCD token.
1587 This includes information such as the type of value the TokenNumber is associated with as well as possible
1588 human readable name that is associated with the token.
1590 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1592 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1593 @param[in] TokenNumber The PCD token number.
1594 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1595 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1600 IN CONST GUID
*Guid
,
1601 IN UINTN TokenNumber
,
1602 OUT PCD_INFO
*PcdInfo
1607 Status
= GetPiPcdInfoProtocolPointer()->GetInfo (Guid
, TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1608 ASSERT_EFI_ERROR (Status
);
1612 Retrieve the currently set SKU Id.
1614 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1615 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1624 return GetPiPcdInfoProtocolPointer()->GetSku ();