2 Implementation of PcdLib class library for DXE phase.
4 Copyright (c) 2006 - 2015, 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.
128 If SkuId >= PCD_MAX_SKU_ID, then ASSERT().
130 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values
131 associated with a PCD token.
133 @return Return the SKU ID that just be set.
142 ASSERT (SkuId
< PCD_MAX_SKU_ID
);
144 GetPcdProtocol()->SetSku (SkuId
);
152 This function provides a means by which to retrieve a value for a given PCD token.
154 Returns the 8-bit value for the token specified by TokenNumber.
156 @param[in] TokenNumber The PCD token number to retrieve a current value for.
158 @return Returns the 8-bit value for the token specified by TokenNumber.
167 return GetPcdProtocol()->Get8 (TokenNumber
);
173 This function provides a means by which to retrieve a value for a given PCD token.
175 Returns the 16-bit value for the token specified by TokenNumber.
177 @param[in] TokenNumber The PCD token number to retrieve a current value for.
179 @return Returns the 16-bit value for the token specified by TokenNumber.
188 return GetPcdProtocol()->Get16 (TokenNumber
);
194 This function provides a means by which to retrieve a value for a given PCD token.
196 Returns the 32-bit value for the token specified by TokenNumber.
198 @param[in] TokenNumber The PCD token number to retrieve a current value for.
200 @return Returns the 32-bit value for the token specified by TokenNumber.
209 return GetPcdProtocol()->Get32 (TokenNumber
);
215 This function provides a means by which to retrieve a value for a given PCD token.
217 Returns the 64-bit value for the token specified by TokenNumber.
219 @param[in] TokenNumber The PCD token number to retrieve a current value for.
221 @return Returns the 64-bit value for the token specified by TokenNumber.
230 return GetPcdProtocol()->Get64 (TokenNumber
);
236 This function provides a means by which to retrieve a value for a given PCD token.
238 Returns the pointer to the buffer of the token specified by TokenNumber.
240 @param[in] TokenNumber The PCD token number to retrieve a current value for.
242 @return Returns the pointer to the token specified by TokenNumber.
251 return GetPcdProtocol()->GetPtr (TokenNumber
);
257 This function provides a means by which to retrieve a value for a given PCD token.
259 Returns the Boolean value of the token specified by TokenNumber.
261 @param[in] TokenNumber The PCD token number to retrieve a current value for.
263 @return Returns the Boolean value of the token specified by TokenNumber.
272 return GetPcdProtocol()->GetBool (TokenNumber
);
278 This function provides a means by which to retrieve the size of a given PCD token.
280 @param[in] TokenNumber The PCD token number to retrieve a current value for.
282 @return Returns the size of the token specified by TokenNumber.
291 return GetPcdProtocol()->GetSize (TokenNumber
);
297 This function provides a means by which to retrieve a value for a given PCD token.
299 Returns the 8-bit value for the token specified by TokenNumber and Guid.
301 If Guid is NULL, then ASSERT().
303 @param[in] Guid The pointer to a 128-bit unique value that designates
304 which namespace to retrieve a value from.
305 @param[in] TokenNumber The PCD token number to retrieve a current value for.
307 @return Return the UINT8.
317 ASSERT (Guid
!= NULL
);
319 return GetPiPcdProtocol()->Get8 (Guid
, TokenNumber
);
324 This function provides a means by which to retrieve a value for a given PCD token.
326 Returns the 16-bit value for the token specified by TokenNumber and Guid.
328 If Guid is NULL, then ASSERT().
330 @param[in] Guid The pointer to a 128-bit unique value that designates
331 which namespace to retrieve a value from.
332 @param[in] TokenNumber The PCD token number to retrieve a current value for.
334 @return Return the UINT16.
344 ASSERT (Guid
!= NULL
);
346 return GetPiPcdProtocol()->Get16 (Guid
, TokenNumber
);
351 Returns the 32-bit value for the token specified by TokenNumber and Guid.
352 If Guid is NULL, then ASSERT().
354 @param[in] Guid The pointer to a 128-bit unique value that designates
355 which namespace to retrieve a value from.
356 @param[in] TokenNumber The PCD token number to retrieve a current value for.
358 @return Return the UINT32.
368 ASSERT (Guid
!= NULL
);
370 return GetPiPcdProtocol()->Get32 (Guid
, TokenNumber
);
376 This function provides a means by which to retrieve a value for a given PCD token.
378 Returns the 64-bit value for the token specified by TokenNumber and Guid.
380 If Guid is NULL, then ASSERT().
382 @param[in] Guid The pointer to a 128-bit unique value that designates
383 which namespace to retrieve a value from.
384 @param[in] TokenNumber The PCD token number to retrieve a current value for.
386 @return Return the UINT64.
396 ASSERT (Guid
!= NULL
);
398 return GetPiPcdProtocol()->Get64 (Guid
, TokenNumber
);
404 This function provides a means by which to retrieve a value for a given PCD token.
406 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
408 If Guid is NULL, then ASSERT().
410 @param[in] Guid The pointer to a 128-bit unique value that designates
411 which namespace to retrieve a value from.
412 @param[in] TokenNumber The PCD token number to retrieve a current value for.
414 @return Return the VOID* pointer.
424 ASSERT (Guid
!= NULL
);
426 return GetPiPcdProtocol()->GetPtr (Guid
, TokenNumber
);
432 This function provides a means by which to retrieve a value for a given PCD token.
434 Returns the Boolean value of the token specified by TokenNumber and Guid.
436 If Guid is NULL, then ASSERT().
438 @param[in] Guid The pointer to a 128-bit unique value that designates
439 which namespace to retrieve a value from.
440 @param[in] TokenNumber The PCD token number to retrieve a current value for.
442 @return Return the BOOLEAN.
452 ASSERT (Guid
!= NULL
);
454 return GetPiPcdProtocol()->GetBool (Guid
, TokenNumber
);
460 This function provides a means by which to retrieve the size of a given PCD token.
462 Returns the size of the token specified by TokenNumber and Guid.
464 If Guid is NULL, then ASSERT().
466 @param[in] Guid The pointer to a 128-bit unique value that designates
467 which namespace to retrieve a value from.
468 @param[in] TokenNumber The PCD token number to retrieve a current value for.
470 @return Return the size.
480 ASSERT (Guid
!= NULL
);
482 return GetPiPcdProtocol()->GetSize (Guid
, TokenNumber
);
487 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
489 This function provides a means by which to set a value for a given PCD token.
491 Sets the 8-bit value for the token specified by TokenNumber
492 to the value specified by Value. Value is returned.
494 @param[in] TokenNumber The PCD token number to set a current value for.
495 @param[in] Value The 8-bit value to set.
497 @return Return the value that was set.
503 IN UINTN TokenNumber
,
507 GetPcdProtocol()->Set8 (TokenNumber
, Value
);
515 This function provides a means by which to set a value for a given PCD token.
517 Sets the 16-bit value for the token specified by TokenNumber
518 to the value specified by Value. Value is returned.
520 @param[in] TokenNumber The PCD token number to set a current value for.
521 @param[in] Value The 16-bit value to set.
523 @return Return the value that was set.
529 IN UINTN TokenNumber
,
533 GetPcdProtocol()->Set16 (TokenNumber
, Value
);
541 This function provides a means by which to set a value for a given PCD token.
543 Sets the 32-bit value for the token specified by TokenNumber
544 to the value specified by Value. Value is returned.
546 @param[in] TokenNumber The PCD token number to set a current value for.
547 @param[in] Value The 32-bit value to set.
549 @return Return the value that was set.
555 IN UINTN TokenNumber
,
559 GetPcdProtocol()->Set32 (TokenNumber
, Value
);
567 This function provides a means by which to set a value for a given PCD token.
569 Sets the 64-bit value for the token specified by TokenNumber
570 to the value specified by Value. Value is returned.
572 @param[in] TokenNumber The PCD token number to set a current value for.
573 @param[in] Value The 64-bit value to set.
575 @return Return the value that was set.
581 IN UINTN TokenNumber
,
585 GetPcdProtocol()->Set64 (TokenNumber
, Value
);
593 This function provides a means by which to set a value for a given PCD token.
595 Sets a buffer for the token specified by TokenNumber to the value
596 specified by Buffer and SizeOfBuffer. Buffer is returned.
597 If SizeOfBuffer is greater than the maximum size support by TokenNumber,
598 then set SizeOfBuffer to the maximum size supported by TokenNumber and
599 return NULL to indicate that the set operation was not actually performed.
601 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
602 maximum size supported by TokenName and NULL must be returned.
604 If SizeOfBuffer is NULL, then ASSERT().
605 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
607 @param[in] TokenNumber The PCD token number to set a current value for.
608 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
609 @param[in] Buffer A pointer to the buffer to set.
611 @return Return the pointer for the buffer been set.
617 IN UINTN TokenNumber
,
618 IN OUT UINTN
*SizeOfBuffer
,
619 IN CONST VOID
*Buffer
623 UINTN InputSizeOfBuffer
;
625 ASSERT (SizeOfBuffer
!= NULL
);
627 if (*SizeOfBuffer
> 0) {
628 ASSERT (Buffer
!= NULL
);
631 InputSizeOfBuffer
= *SizeOfBuffer
;
632 Status
= GetPcdProtocol()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*) Buffer
);
633 if (EFI_ERROR (Status
) && (*SizeOfBuffer
< InputSizeOfBuffer
)) {
637 return (VOID
*)Buffer
;
643 This function provides a means by which to set a value for a given PCD token.
645 Sets the Boolean value for the token specified by TokenNumber
646 to the value specified by Value. Value is returned.
648 @param[in] TokenNumber The PCD token number to set a current value for.
649 @param[in] Value The boolean value to set.
651 @return Return the value that was set.
657 IN UINTN TokenNumber
,
661 GetPcdProtocol()->SetBool (TokenNumber
, Value
);
669 This function provides a means by which to set a value for a given PCD token.
671 Sets the 8-bit value for the token specified by TokenNumber and
672 Guid to the value specified by Value. Value is returned.
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 8-bit value to set.
681 @return Return the value that was set.
688 IN UINTN TokenNumber
,
692 ASSERT (Guid
!= NULL
);
694 GetPiPcdProtocol()->Set8 (Guid
, TokenNumber
, Value
);
702 This function provides a means by which to set a value for a given PCD token.
704 Sets the 16-bit value for the token specified by TokenNumber and
705 Guid to the value specified by Value. Value is returned.
707 If Guid is NULL, then ASSERT().
709 @param[in] Guid The pointer to a 128-bit unique value that
710 designates which namespace to set a value from.
711 @param[in] TokenNumber The PCD token number to set a current value for.
712 @param[in] Value The 16-bit value to set.
714 @return Return the value that was set.
721 IN UINTN TokenNumber
,
725 ASSERT (Guid
!= NULL
);
727 GetPiPcdProtocol()->Set16 (Guid
, TokenNumber
, Value
);
735 This function provides a means by which to set a value for a given PCD token.
737 Sets the 32-bit value for the token specified by TokenNumber and
738 Guid to the value specified by Value. Value is returned.
740 If Guid is NULL, then ASSERT().
742 @param[in] Guid The pointer to a 128-bit unique value that
743 designates which namespace to set a value from.
744 @param[in] TokenNumber The PCD token number to set a current value for.
745 @param[in] Value The 32-bit value to set.
747 @return Return the value that was set.
754 IN UINTN TokenNumber
,
758 ASSERT (Guid
!= NULL
);
760 GetPiPcdProtocol()->Set32 (Guid
, TokenNumber
, Value
);
768 This function provides a means by which to set a value for a given PCD token.
770 Sets the 64-bit value for the token specified by TokenNumber and
771 Guid to the value specified by Value. Value is returned.
773 If Guid is NULL, then ASSERT().
775 @param[in] Guid The pointer to a 128-bit unique value that
776 designates which namespace to set a value from.
777 @param[in] TokenNumber The PCD token number to set a current value for.
778 @param[in] Value The 64-bit value to set.
780 @return Return the value that was set.
787 IN UINTN TokenNumber
,
791 ASSERT (Guid
!= NULL
);
793 GetPiPcdProtocol()->Set64 (Guid
, TokenNumber
, Value
);
801 This function provides a means by which to set a value for a given PCD token.
803 Sets a buffer for the token specified by TokenNumber to the value specified by
804 Buffer and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
805 the maximum size support by TokenNumber, then set SizeOfBuffer to the maximum size
806 supported by TokenNumber and return NULL to indicate that the set operation
807 was not actually performed.
809 If Guid is NULL, then ASSERT().
810 If SizeOfBuffer is NULL, then ASSERT().
811 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
813 @param[in] Guid The pointer to a 128-bit unique value that
814 designates which namespace to set a value from.
815 @param[in] TokenNumber The PCD token number to set a current value for.
816 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
817 @param[in] Buffer A pointer to the buffer to set.
819 @return Return the pointer to the buffer been set.
826 IN UINTN TokenNumber
,
827 IN OUT UINTN
*SizeOfBuffer
,
832 UINTN InputSizeOfBuffer
;
834 ASSERT (Guid
!= NULL
);
836 ASSERT (SizeOfBuffer
!= NULL
);
838 if (*SizeOfBuffer
> 0) {
839 ASSERT (Buffer
!= NULL
);
842 InputSizeOfBuffer
= *SizeOfBuffer
;
843 Status
= GetPiPcdProtocol()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
844 if (EFI_ERROR (Status
) && (*SizeOfBuffer
< InputSizeOfBuffer
)) {
854 This function provides a means by which to set a value for a given PCD token.
856 Sets the Boolean value for the token specified by TokenNumber and
857 Guid to the value specified by Value. Value is returned.
859 If Guid is NULL, then ASSERT().
861 @param[in] Guid The pointer to a 128-bit unique value that
862 designates which namespace to set a value from.
863 @param[in] TokenNumber The PCD token number to set a current value for.
864 @param[in] Value The Boolean value to set.
866 @return Return the value that was set.
873 IN UINTN TokenNumber
,
877 ASSERT (Guid
!= NULL
);
879 GetPiPcdProtocol()->SetBool (Guid
, TokenNumber
, Value
);
886 This function provides a means by which to set a value for a given PCD token.
888 Sets the 8-bit value for the token specified by TokenNumber
889 to the value specified by Value.
891 @param[in] TokenNumber The PCD token number to set a current value for.
892 @param[in] Value The 8-bit value to set.
894 @return The status of the set operation.
900 IN UINTN TokenNumber
,
904 return GetPcdProtocol()->Set8 (TokenNumber
, Value
);
908 This function provides a means by which to set a value for a given PCD token.
910 Sets the 16-bit value for the token specified by TokenNumber
911 to the value specified by Value.
913 @param[in] TokenNumber The PCD token number to set a current value for.
914 @param[in] Value The 16-bit value to set.
916 @return The status of the set operation.
922 IN UINTN TokenNumber
,
926 return GetPcdProtocol()->Set16 (TokenNumber
, Value
);
930 This function provides a means by which to set a value for a given PCD token.
932 Sets the 32-bit value for the token specified by TokenNumber
933 to the value specified by Value.
935 @param[in] TokenNumber The PCD token number to set a current value for.
936 @param[in] Value The 32-bit value to set.
938 @return The status of the set operation.
944 IN UINTN TokenNumber
,
948 return GetPcdProtocol()->Set32 (TokenNumber
, Value
);
952 This function provides a means by which to set a value for a given PCD token.
954 Sets the 64-bit value for the token specified by TokenNumber
955 to the value specified by Value.
957 @param[in] TokenNumber The PCD token number to set a current value for.
958 @param[in] Value The 64-bit value to set.
960 @return The status of the set operation.
966 IN UINTN TokenNumber
,
970 return GetPcdProtocol()->Set64 (TokenNumber
, Value
);
974 This function provides a means by which to set a value for a given PCD token.
976 Sets a buffer for the token specified by TokenNumber to the value specified
977 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
978 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
979 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
980 was not actually performed.
982 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
983 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
985 If SizeOfBuffer is NULL, then ASSERT().
986 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
988 @param[in] TokenNumber The PCD token number to set a current value for.
989 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
990 @param[in] Buffer A pointer to the buffer to set.
992 @return The status of the set operation.
998 IN UINTN TokenNumber
,
999 IN OUT UINTN
*SizeOfBuffer
,
1000 IN CONST VOID
*Buffer
1003 ASSERT (SizeOfBuffer
!= NULL
);
1005 if (*SizeOfBuffer
> 0) {
1006 ASSERT (Buffer
!= NULL
);
1009 return GetPcdProtocol()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*) Buffer
);
1013 This function provides a means by which to set a value for a given PCD token.
1015 Sets the boolean value for the token specified by TokenNumber
1016 to the value specified by Value.
1018 @param[in] TokenNumber The PCD token number to set a current value for.
1019 @param[in] Value The boolean value to set.
1021 @return The status of the set operation.
1027 IN UINTN TokenNumber
,
1031 return GetPcdProtocol()->SetBool (TokenNumber
, Value
);
1035 This function provides a means by which to set a value for a given PCD token.
1037 Sets the 8-bit value for the token specified by TokenNumber
1038 to the value specified by Value.
1040 If Guid is NULL, then ASSERT().
1042 @param[in] Guid The pointer to a 128-bit unique value that
1043 designates which namespace to set a value from.
1044 @param[in] TokenNumber The PCD token number to set a current value for.
1045 @param[in] Value The 8-bit value to set.
1047 @return The status of the set operation.
1053 IN CONST GUID
*Guid
,
1054 IN UINTN TokenNumber
,
1058 ASSERT (Guid
!= NULL
);
1060 return GetPiPcdProtocol()->Set8 (Guid
, TokenNumber
, Value
);
1064 This function provides a means by which to set a value for a given PCD token.
1066 Sets the 16-bit value for the token specified by TokenNumber
1067 to the value specified by Value.
1069 If Guid is NULL, then ASSERT().
1071 @param[in] Guid The pointer to a 128-bit unique value that
1072 designates which namespace to set a value from.
1073 @param[in] TokenNumber The PCD token number to set a current value for.
1074 @param[in] Value The 16-bit value to set.
1076 @return The status of the set operation.
1082 IN CONST GUID
*Guid
,
1083 IN UINTN TokenNumber
,
1087 ASSERT (Guid
!= NULL
);
1089 return GetPiPcdProtocol()->Set16 (Guid
, TokenNumber
, Value
);
1093 This function provides a means by which to set a value for a given PCD token.
1095 Sets the 32-bit value for the token specified by TokenNumber
1096 to the value specified by Value.
1098 If Guid is NULL, then ASSERT().
1100 @param[in] Guid The pointer to a 128-bit unique value that
1101 designates which namespace to set a value from.
1102 @param[in] TokenNumber The PCD token number to set a current value for.
1103 @param[in] Value The 32-bit value to set.
1105 @return The status of the set operation.
1111 IN CONST GUID
*Guid
,
1112 IN UINTN TokenNumber
,
1116 ASSERT (Guid
!= NULL
);
1118 return GetPiPcdProtocol()->Set32 (Guid
, TokenNumber
, Value
);
1122 This function provides a means by which to set a value for a given PCD token.
1124 Sets the 64-bit value for the token specified by TokenNumber
1125 to the value specified by Value.
1127 If Guid is NULL, then ASSERT().
1129 @param[in] Guid The pointer to a 128-bit unique value that
1130 designates which namespace to set a value from.
1131 @param[in] TokenNumber The PCD token number to set a current value for.
1132 @param[in] Value The 64-bit value to set.
1134 @return The status of the set operation.
1140 IN CONST GUID
*Guid
,
1141 IN UINTN TokenNumber
,
1145 ASSERT (Guid
!= NULL
);
1147 return GetPiPcdProtocol()->Set64 (Guid
, TokenNumber
, Value
);
1151 This function provides a means by which to set a value for a given PCD token.
1153 Sets a buffer for the token specified by TokenNumber to the value specified by
1154 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
1155 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
1156 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
1157 was not actually performed.
1159 If Guid is NULL, then ASSERT().
1160 If SizeOfBuffer is NULL, then ASSERT().
1161 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1163 @param[in] Guid Pointer to a 128-bit unique value that
1164 designates which namespace to set a value from.
1165 @param[in] TokenNumber The PCD token number to set a current value for.
1166 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
1167 @param[in] Buffer A pointer to the buffer to set.
1169 @return The status of the set operation.
1175 IN CONST GUID
*Guid
,
1176 IN UINTN TokenNumber
,
1177 IN OUT UINTN
*SizeOfBuffer
,
1181 ASSERT (Guid
!= NULL
);
1183 ASSERT (SizeOfBuffer
!= NULL
);
1185 if (*SizeOfBuffer
> 0) {
1186 ASSERT (Buffer
!= NULL
);
1189 return GetPiPcdProtocol()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
1193 This function provides a means by which to set a value for a given PCD token.
1195 Sets the boolean value for the token specified by TokenNumber
1196 to the value specified by Value.
1198 If Guid is NULL, then ASSERT().
1200 @param[in] Guid The pointer to a 128-bit unique value that
1201 designates which namespace to set a value from.
1202 @param[in] TokenNumber The PCD token number to set a current value for.
1203 @param[in] Value The boolean value to set.
1205 @return The status of the set operation.
1211 IN CONST GUID
*Guid
,
1212 IN UINTN TokenNumber
,
1216 ASSERT (Guid
!= NULL
);
1218 return GetPiPcdProtocol()->SetBool (Guid
, TokenNumber
, Value
);
1222 Set up a notification function that is called when a specified token is set.
1224 When the token specified by TokenNumber and Guid is set,
1225 then notification function specified by NotificationFunction is called.
1226 If Guid is NULL, then the default token space is used.
1227 If NotificationFunction is NULL, then ASSERT().
1229 @param[in] Guid The pointer to a 128-bit unique value that designates which
1230 namespace to set a value from. If NULL, then the default
1231 token space is used.
1232 @param[in] TokenNumber The PCD token number to monitor.
1233 @param[in] NotificationFunction The function to call when the token
1234 specified by Guid and TokenNumber is set.
1239 LibPcdCallbackOnSet (
1240 IN CONST GUID
*Guid
, OPTIONAL
1241 IN UINTN TokenNumber
,
1242 IN PCD_CALLBACK NotificationFunction
1247 ASSERT (NotificationFunction
!= NULL
);
1249 Status
= GetPiPcdProtocol()->CallbackOnSet (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
1250 ASSERT_EFI_ERROR (Status
);
1258 Disable a notification function that was established with LibPcdCallbackonSet().
1260 Disable a notification function that was previously established with LibPcdCallbackOnSet().
1261 If NotificationFunction is NULL, then ASSERT().
1262 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
1263 and NotificationFunction, then ASSERT().
1265 @param[in] Guid Specify the GUID token space.
1266 @param[in] TokenNumber Specify the token number.
1267 @param[in] NotificationFunction The callback function to be unregistered.
1272 LibPcdCancelCallback (
1273 IN CONST GUID
*Guid
, OPTIONAL
1274 IN UINTN TokenNumber
,
1275 IN PCD_CALLBACK NotificationFunction
1280 ASSERT (NotificationFunction
!= NULL
);
1282 Status
= GetPiPcdProtocol()->CancelCallback (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
1283 ASSERT_EFI_ERROR (Status
);
1291 Retrieves the next token in a token space.
1293 Retrieves the next PCD token number from the token space specified by Guid.
1294 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
1295 then the first token number is returned. Otherwise, the token number that
1296 follows TokenNumber in the token space is returned. If TokenNumber is the last
1297 token number in the token space, then 0 is returned.
1299 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
1301 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
1302 to set a value from. If NULL, then the default token space is used.
1303 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
1306 @return The next valid token number.
1311 LibPcdGetNextToken (
1312 IN CONST GUID
*Guid
, OPTIONAL
1313 IN UINTN TokenNumber
1318 Status
= GetPiPcdProtocol()->GetNextToken (Guid
, &TokenNumber
);
1319 ASSERT (!EFI_ERROR (Status
) || TokenNumber
== 0);
1327 Used to retrieve the list of available PCD token space GUIDs.
1329 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
1331 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
1332 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
1334 @param TokenSpaceGuid The pointer to the a PCD token space GUID.
1336 @return The next valid token namespace.
1341 LibPcdGetNextTokenSpace (
1342 IN CONST GUID
*TokenSpaceGuid
1345 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid
);
1347 return (GUID
*)TokenSpaceGuid
;
1352 Sets a value of a patchable PCD entry that is type pointer.
1354 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1355 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1356 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1357 NULL to indicate that the set operation was not actually performed.
1358 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1359 MaximumDatumSize and NULL must be returned.
1361 If PatchVariable is NULL, then ASSERT().
1362 If SizeOfBuffer is NULL, then ASSERT().
1363 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1365 @param[out] PatchVariable A pointer to the global variable in a module that is
1366 the target of the set operation.
1367 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1368 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1369 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1371 @return Return the pointer to the buffer been set.
1377 OUT VOID
*PatchVariable
,
1378 IN UINTN MaximumDatumSize
,
1379 IN OUT UINTN
*SizeOfBuffer
,
1380 IN CONST VOID
*Buffer
1383 ASSERT (PatchVariable
!= NULL
);
1384 ASSERT (SizeOfBuffer
!= NULL
);
1386 if (*SizeOfBuffer
> 0) {
1387 ASSERT (Buffer
!= NULL
);
1390 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1391 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1392 *SizeOfBuffer
= MaximumDatumSize
;
1396 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1398 return (VOID
*) Buffer
;
1402 Sets a value of a patchable PCD entry that is type pointer.
1404 Sets the PCD entry specified by PatchVariable to the value specified
1405 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1406 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1407 to indicate that the set operation was not actually performed.
1408 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1409 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1411 If PatchVariable is NULL, then ASSERT().
1412 If SizeOfBuffer is NULL, then ASSERT().
1413 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1415 @param[out] PatchVariable A pointer to the global variable in a module that is
1416 the target of the set operation.
1417 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1418 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1419 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1421 @return The status of the set operation.
1426 LibPatchPcdSetPtrS (
1427 OUT VOID
*PatchVariable
,
1428 IN UINTN MaximumDatumSize
,
1429 IN OUT UINTN
*SizeOfBuffer
,
1430 IN CONST VOID
*Buffer
1433 ASSERT (PatchVariable
!= NULL
);
1434 ASSERT (SizeOfBuffer
!= NULL
);
1436 if (*SizeOfBuffer
> 0) {
1437 ASSERT (Buffer
!= NULL
);
1440 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1441 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1442 *SizeOfBuffer
= MaximumDatumSize
;
1443 return RETURN_INVALID_PARAMETER
;
1446 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1448 return RETURN_SUCCESS
;
1453 Sets a value and size of a patchable PCD entry that is type pointer.
1455 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1456 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1457 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1458 NULL to indicate that the set operation was not actually performed.
1459 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1460 MaximumDatumSize and NULL must be returned.
1462 If PatchVariable is NULL, then ASSERT().
1463 If SizeOfPatchVariable is NULL, then ASSERT().
1464 If SizeOfBuffer is NULL, then ASSERT().
1465 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1467 @param[out] PatchVariable A pointer to the global variable in a module that is
1468 the target of the set operation.
1469 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1470 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1471 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1472 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1474 @return Return the pointer to the buffer been set.
1479 LibPatchPcdSetPtrAndSize (
1480 OUT VOID
*PatchVariable
,
1481 OUT UINTN
*SizeOfPatchVariable
,
1482 IN UINTN MaximumDatumSize
,
1483 IN OUT UINTN
*SizeOfBuffer
,
1484 IN CONST VOID
*Buffer
1487 ASSERT (PatchVariable
!= NULL
);
1488 ASSERT (SizeOfPatchVariable
!= NULL
);
1489 ASSERT (SizeOfBuffer
!= NULL
);
1491 if (*SizeOfBuffer
> 0) {
1492 ASSERT (Buffer
!= NULL
);
1495 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1496 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1497 *SizeOfBuffer
= MaximumDatumSize
;
1501 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1502 *SizeOfPatchVariable
= *SizeOfBuffer
;
1504 return (VOID
*) Buffer
;
1508 Sets a value and size of a patchable PCD entry that is type pointer.
1510 Sets the PCD entry specified by PatchVariable to the value specified
1511 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1512 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1513 to indicate that the set operation was not actually performed.
1514 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1515 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1517 If PatchVariable is NULL, then ASSERT().
1518 If SizeOfPatchVariable is NULL, then ASSERT().
1519 If SizeOfBuffer is NULL, then ASSERT().
1520 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1522 @param[out] PatchVariable A pointer to the global variable in a module that is
1523 the target of the set operation.
1524 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1525 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1526 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1527 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1529 @return The status of the set operation.
1534 LibPatchPcdSetPtrAndSizeS (
1535 OUT VOID
*PatchVariable
,
1536 OUT UINTN
*SizeOfPatchVariable
,
1537 IN UINTN MaximumDatumSize
,
1538 IN OUT UINTN
*SizeOfBuffer
,
1539 IN CONST VOID
*Buffer
1542 ASSERT (PatchVariable
!= NULL
);
1543 ASSERT (SizeOfPatchVariable
!= NULL
);
1544 ASSERT (SizeOfBuffer
!= NULL
);
1546 if (*SizeOfBuffer
> 0) {
1547 ASSERT (Buffer
!= NULL
);
1550 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1551 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1552 *SizeOfBuffer
= MaximumDatumSize
;
1553 return RETURN_INVALID_PARAMETER
;
1556 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1557 *SizeOfPatchVariable
= *SizeOfBuffer
;
1559 return RETURN_SUCCESS
;
1563 Retrieve additional information associated with a PCD token.
1565 This includes information such as the type of value the TokenNumber is associated with as well as possible
1566 human readable name that is associated with the token.
1568 If TokenNumber is not in the default token space specified, then ASSERT().
1570 @param[in] TokenNumber The PCD token number.
1571 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1572 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1577 IN UINTN TokenNumber
,
1578 OUT PCD_INFO
*PcdInfo
1583 Status
= GetPcdInfoProtocolPointer()->GetInfo (TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1584 ASSERT_EFI_ERROR (Status
);
1588 Retrieve additional information associated with a PCD token.
1590 This includes information such as the type of value the TokenNumber is associated with as well as possible
1591 human readable name that is associated with the token.
1593 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1595 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1596 @param[in] TokenNumber The PCD token number.
1597 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1598 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1603 IN CONST GUID
*Guid
,
1604 IN UINTN TokenNumber
,
1605 OUT PCD_INFO
*PcdInfo
1610 Status
= GetPiPcdInfoProtocolPointer()->GetInfo (Guid
, TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1611 ASSERT_EFI_ERROR (Status
);
1615 Retrieve the currently set SKU Id.
1617 If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().
1619 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1620 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1631 SkuId
= GetPiPcdInfoProtocolPointer()->GetSku ();
1632 ASSERT (SkuId
< PCD_MAX_SKU_ID
);