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
12 #include <Protocol/Pcd.h>
13 #include <Protocol/PiPcd.h>
14 #include <Protocol/PcdInfo.h>
15 #include <Protocol/PiPcdInfo.h>
17 #include <Library/PcdLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/BaseMemoryLib.h>
22 PCD_PROTOCOL
*mPcd
= NULL
;
23 EFI_PCD_PROTOCOL
*mPiPcd
= NULL
;
24 GET_PCD_INFO_PROTOCOL
*mPcdInfo
= NULL
;
25 EFI_GET_PCD_INFO_PROTOCOL
*mPiPcdInfo
= NULL
;
28 Retrieves the PI PCD protocol from the handle database.
30 @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.
42 // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module
43 // access DynamicEx type PCD.
45 Status
= gBS
->LocateProtocol (&gEfiPcdProtocolGuid
, NULL
, (VOID
**)&mPiPcd
);
46 ASSERT_EFI_ERROR (Status
);
47 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
);
80 Retrieves the PI PCD info protocol from the handle database.
82 @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.
84 EFI_GET_PCD_INFO_PROTOCOL
*
85 GetPiPcdInfoProtocolPointer (
91 if (mPiPcdInfo
== NULL
) {
92 Status
= gBS
->LocateProtocol (&gEfiGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPiPcdInfo
);
93 ASSERT_EFI_ERROR (Status
);
94 ASSERT (mPiPcdInfo
!= NULL
);
101 Retrieves the PCD info protocol from the handle database.
103 @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.
105 GET_PCD_INFO_PROTOCOL
*
106 GetPcdInfoProtocolPointer (
112 if (mPcdInfo
== NULL
) {
113 Status
= gBS
->LocateProtocol (&gGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPcdInfo
);
114 ASSERT_EFI_ERROR (Status
);
115 ASSERT (mPcdInfo
!= NULL
);
122 This function provides a means by which SKU support can be established in the PCD infrastructure.
124 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
126 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values
127 associated with a PCD token.
129 @return Return the SKU ID that just be set.
138 GetPcdProtocol ()->SetSku (SkuId
);
144 This function provides a means by which to retrieve a value for a given PCD token.
146 Returns the 8-bit value for the token specified by TokenNumber.
148 @param[in] TokenNumber The PCD token number to retrieve a current value for.
150 @return Returns the 8-bit value for the token specified by TokenNumber.
159 return GetPcdProtocol ()->Get8 (TokenNumber
);
163 This function provides a means by which to retrieve a value for a given PCD token.
165 Returns the 16-bit value for the token specified by TokenNumber.
167 @param[in] TokenNumber The PCD token number to retrieve a current value for.
169 @return Returns the 16-bit value for the token specified by TokenNumber.
178 return GetPcdProtocol ()->Get16 (TokenNumber
);
182 This function provides a means by which to retrieve a value for a given PCD token.
184 Returns the 32-bit value for the token specified by TokenNumber.
186 @param[in] TokenNumber The PCD token number to retrieve a current value for.
188 @return Returns the 32-bit value for the token specified by TokenNumber.
197 return GetPcdProtocol ()->Get32 (TokenNumber
);
201 This function provides a means by which to retrieve a value for a given PCD token.
203 Returns the 64-bit value for the token specified by TokenNumber.
205 @param[in] TokenNumber The PCD token number to retrieve a current value for.
207 @return Returns the 64-bit value for the token specified by TokenNumber.
216 return GetPcdProtocol ()->Get64 (TokenNumber
);
220 This function provides a means by which to retrieve a value for a given PCD token.
222 Returns the pointer to the buffer of the token specified by TokenNumber.
224 @param[in] TokenNumber The PCD token number to retrieve a current value for.
226 @return Returns the pointer to the token specified by TokenNumber.
235 return GetPcdProtocol ()->GetPtr (TokenNumber
);
239 This function provides a means by which to retrieve a value for a given PCD token.
241 Returns the Boolean value of the token specified by TokenNumber.
243 @param[in] TokenNumber The PCD token number to retrieve a current value for.
245 @return Returns the Boolean value of the token specified by TokenNumber.
254 return GetPcdProtocol ()->GetBool (TokenNumber
);
258 This function provides a means by which to retrieve the size of a given PCD token.
260 @param[in] TokenNumber The PCD token number to retrieve a current value for.
262 @return Returns the size of the token specified by TokenNumber.
271 return GetPcdProtocol ()->GetSize (TokenNumber
);
275 This function provides a means by which to retrieve a value for a given PCD token.
277 Returns the 8-bit value for the token specified by TokenNumber and Guid.
279 If Guid is NULL, then ASSERT().
281 @param[in] Guid The pointer to a 128-bit unique value that designates
282 which namespace to retrieve a value from.
283 @param[in] TokenNumber The PCD token number to retrieve a current value for.
285 @return Return the UINT8.
295 ASSERT (Guid
!= NULL
);
297 return GetPiPcdProtocol ()->Get8 (Guid
, TokenNumber
);
301 This function provides a means by which to retrieve a value for a given PCD token.
303 Returns the 16-bit value for the token specified by TokenNumber and Guid.
305 If Guid is NULL, then ASSERT().
307 @param[in] Guid The pointer to a 128-bit unique value that designates
308 which namespace to retrieve a value from.
309 @param[in] TokenNumber The PCD token number to retrieve a current value for.
311 @return Return the UINT16.
321 ASSERT (Guid
!= NULL
);
323 return GetPiPcdProtocol ()->Get16 (Guid
, TokenNumber
);
327 Returns the 32-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 UINT32.
344 ASSERT (Guid
!= NULL
);
346 return GetPiPcdProtocol ()->Get32 (Guid
, TokenNumber
);
350 This function provides a means by which to retrieve a value for a given PCD token.
352 Returns the 64-bit value for the token specified by TokenNumber and Guid.
354 If Guid is NULL, then ASSERT().
356 @param[in] Guid The pointer to a 128-bit unique value that designates
357 which namespace to retrieve a value from.
358 @param[in] TokenNumber The PCD token number to retrieve a current value for.
360 @return Return the UINT64.
370 ASSERT (Guid
!= NULL
);
372 return GetPiPcdProtocol ()->Get64 (Guid
, TokenNumber
);
376 This function provides a means by which to retrieve a value for a given PCD token.
378 Returns the pointer to the buffer of 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 VOID* pointer.
396 ASSERT (Guid
!= NULL
);
398 return GetPiPcdProtocol ()->GetPtr (Guid
, TokenNumber
);
402 This function provides a means by which to retrieve a value for a given PCD token.
404 Returns the Boolean value of the token specified by TokenNumber and Guid.
406 If Guid is NULL, then ASSERT().
408 @param[in] Guid The pointer to a 128-bit unique value that designates
409 which namespace to retrieve a value from.
410 @param[in] TokenNumber The PCD token number to retrieve a current value for.
412 @return Return the BOOLEAN.
422 ASSERT (Guid
!= NULL
);
424 return GetPiPcdProtocol ()->GetBool (Guid
, TokenNumber
);
428 This function provides a means by which to retrieve the size of a given PCD token.
430 Returns the size of the token specified by TokenNumber and Guid.
432 If Guid is NULL, then ASSERT().
434 @param[in] Guid The pointer to a 128-bit unique value that designates
435 which namespace to retrieve a value from.
436 @param[in] TokenNumber The PCD token number to retrieve a current value for.
438 @return Return the size.
448 ASSERT (Guid
!= NULL
);
450 return GetPiPcdProtocol ()->GetSize (Guid
, TokenNumber
);
454 This function provides a means by which to set a value for a given PCD token.
456 Sets the 8-bit value for the token specified by TokenNumber
457 to the value specified by Value.
459 @param[in] TokenNumber The PCD token number to set a current value for.
460 @param[in] Value The 8-bit value to set.
462 @return The status of the set operation.
468 IN UINTN TokenNumber
,
472 return GetPcdProtocol ()->Set8 (TokenNumber
, Value
);
476 This function provides a means by which to set a value for a given PCD token.
478 Sets the 16-bit value for the token specified by TokenNumber
479 to the value specified by Value.
481 @param[in] TokenNumber The PCD token number to set a current value for.
482 @param[in] Value The 16-bit value to set.
484 @return The status of the set operation.
490 IN UINTN TokenNumber
,
494 return GetPcdProtocol ()->Set16 (TokenNumber
, Value
);
498 This function provides a means by which to set a value for a given PCD token.
500 Sets the 32-bit value for the token specified by TokenNumber
501 to the value specified by Value.
503 @param[in] TokenNumber The PCD token number to set a current value for.
504 @param[in] Value The 32-bit value to set.
506 @return The status of the set operation.
512 IN UINTN TokenNumber
,
516 return GetPcdProtocol ()->Set32 (TokenNumber
, Value
);
520 This function provides a means by which to set a value for a given PCD token.
522 Sets the 64-bit value for the token specified by TokenNumber
523 to the value specified by Value.
525 @param[in] TokenNumber The PCD token number to set a current value for.
526 @param[in] Value The 64-bit value to set.
528 @return The status of the set operation.
534 IN UINTN TokenNumber
,
538 return GetPcdProtocol ()->Set64 (TokenNumber
, Value
);
542 This function provides a means by which to set a value for a given PCD token.
544 Sets a buffer for the token specified by TokenNumber to the value specified
545 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
546 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
547 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
548 was not actually performed.
550 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
551 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
553 If SizeOfBuffer is NULL, then ASSERT().
554 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
556 @param[in] TokenNumber The PCD token number to set a current value for.
557 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
558 @param[in] Buffer A pointer to the buffer to set.
560 @return The status of the set operation.
566 IN UINTN TokenNumber
,
567 IN OUT UINTN
*SizeOfBuffer
,
568 IN CONST VOID
*Buffer
571 ASSERT (SizeOfBuffer
!= NULL
);
573 if (*SizeOfBuffer
> 0) {
574 ASSERT (Buffer
!= NULL
);
577 return GetPcdProtocol ()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*)Buffer
);
581 This function provides a means by which to set a value for a given PCD token.
583 Sets the boolean value for the token specified by TokenNumber
584 to the value specified by Value.
586 @param[in] TokenNumber The PCD token number to set a current value for.
587 @param[in] Value The boolean value to set.
589 @return The status of the set operation.
595 IN UINTN TokenNumber
,
599 return GetPcdProtocol ()->SetBool (TokenNumber
, Value
);
603 This function provides a means by which to set a value for a given PCD token.
605 Sets the 8-bit value for the token specified by TokenNumber
606 to the value specified by Value.
608 If Guid is NULL, then ASSERT().
610 @param[in] Guid The pointer to a 128-bit unique value that
611 designates which namespace to set a value from.
612 @param[in] TokenNumber The PCD token number to set a current value for.
613 @param[in] Value The 8-bit value to set.
615 @return The status of the set operation.
622 IN UINTN TokenNumber
,
626 ASSERT (Guid
!= NULL
);
628 return GetPiPcdProtocol ()->Set8 (Guid
, TokenNumber
, Value
);
632 This function provides a means by which to set a value for a given PCD token.
634 Sets the 16-bit value for the token specified by TokenNumber
635 to the value specified by Value.
637 If Guid is NULL, then ASSERT().
639 @param[in] Guid The pointer to a 128-bit unique value that
640 designates which namespace to set a value from.
641 @param[in] TokenNumber The PCD token number to set a current value for.
642 @param[in] Value The 16-bit value to set.
644 @return The status of the set operation.
651 IN UINTN TokenNumber
,
655 ASSERT (Guid
!= NULL
);
657 return GetPiPcdProtocol ()->Set16 (Guid
, TokenNumber
, Value
);
661 This function provides a means by which to set a value for a given PCD token.
663 Sets the 32-bit value for the token specified by TokenNumber
664 to the value specified by Value.
666 If Guid is NULL, then ASSERT().
668 @param[in] Guid The pointer to a 128-bit unique value that
669 designates which namespace to set a value from.
670 @param[in] TokenNumber The PCD token number to set a current value for.
671 @param[in] Value The 32-bit value to set.
673 @return The status of the set operation.
680 IN UINTN TokenNumber
,
684 ASSERT (Guid
!= NULL
);
686 return GetPiPcdProtocol ()->Set32 (Guid
, TokenNumber
, Value
);
690 This function provides a means by which to set a value for a given PCD token.
692 Sets the 64-bit value for the token specified by TokenNumber
693 to the value specified by Value.
695 If Guid is NULL, then ASSERT().
697 @param[in] Guid The pointer to a 128-bit unique value that
698 designates which namespace to set a value from.
699 @param[in] TokenNumber The PCD token number to set a current value for.
700 @param[in] Value The 64-bit value to set.
702 @return The status of the set operation.
709 IN UINTN TokenNumber
,
713 ASSERT (Guid
!= NULL
);
715 return GetPiPcdProtocol ()->Set64 (Guid
, TokenNumber
, Value
);
719 This function provides a means by which to set a value for a given PCD token.
721 Sets a buffer for the token specified by TokenNumber to the value specified by
722 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
723 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
724 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
725 was not actually performed.
727 If Guid is NULL, then ASSERT().
728 If SizeOfBuffer is NULL, then ASSERT().
729 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
731 @param[in] Guid Pointer to a 128-bit unique value that
732 designates which namespace to set a value from.
733 @param[in] TokenNumber The PCD token number to set a current value for.
734 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
735 @param[in] Buffer A pointer to the buffer to set.
737 @return The status of the set operation.
744 IN UINTN TokenNumber
,
745 IN OUT UINTN
*SizeOfBuffer
,
749 ASSERT (Guid
!= NULL
);
751 ASSERT (SizeOfBuffer
!= NULL
);
753 if (*SizeOfBuffer
> 0) {
754 ASSERT (Buffer
!= NULL
);
757 return GetPiPcdProtocol ()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
761 This function provides a means by which to set a value for a given PCD token.
763 Sets the boolean value for the token specified by TokenNumber
764 to the value specified by Value.
766 If Guid is NULL, then ASSERT().
768 @param[in] Guid The pointer to a 128-bit unique value that
769 designates which namespace to set a value from.
770 @param[in] TokenNumber The PCD token number to set a current value for.
771 @param[in] Value The boolean value to set.
773 @return The status of the set operation.
780 IN UINTN TokenNumber
,
784 ASSERT (Guid
!= NULL
);
786 return GetPiPcdProtocol ()->SetBool (Guid
, TokenNumber
, Value
);
790 Set up a notification function that is called when a specified token is set.
792 When the token specified by TokenNumber and Guid is set,
793 then notification function specified by NotificationFunction is called.
794 If Guid is NULL, then the default token space is used.
795 If NotificationFunction is NULL, then ASSERT().
797 @param[in] Guid The pointer to a 128-bit unique value that designates which
798 namespace to set a value from. If NULL, then the default
800 @param[in] TokenNumber The PCD token number to monitor.
801 @param[in] NotificationFunction The function to call when the token
802 specified by Guid and TokenNumber is set.
807 LibPcdCallbackOnSet (
808 IN CONST GUID
*Guid OPTIONAL
,
809 IN UINTN TokenNumber
,
810 IN PCD_CALLBACK NotificationFunction
815 ASSERT (NotificationFunction
!= NULL
);
817 Status
= GetPiPcdProtocol ()->CallbackOnSet (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
)NotificationFunction
);
818 ASSERT_EFI_ERROR (Status
);
824 Disable a notification function that was established with LibPcdCallbackonSet().
826 Disable a notification function that was previously established with LibPcdCallbackOnSet().
827 If NotificationFunction is NULL, then ASSERT().
828 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
829 and NotificationFunction, then ASSERT().
831 @param[in] Guid Specify the GUID token space.
832 @param[in] TokenNumber Specify the token number.
833 @param[in] NotificationFunction The callback function to be unregistered.
838 LibPcdCancelCallback (
839 IN CONST GUID
*Guid OPTIONAL
,
840 IN UINTN TokenNumber
,
841 IN PCD_CALLBACK NotificationFunction
846 ASSERT (NotificationFunction
!= NULL
);
848 Status
= GetPiPcdProtocol ()->CancelCallback (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
)NotificationFunction
);
849 ASSERT_EFI_ERROR (Status
);
855 Retrieves the next token in a token space.
857 Retrieves the next PCD token number from the token space specified by Guid.
858 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
859 then the first token number is returned. Otherwise, the token number that
860 follows TokenNumber in the token space is returned. If TokenNumber is the last
861 token number in the token space, then 0 is returned.
863 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
865 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
866 to set a value from. If NULL, then the default token space is used.
867 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
870 @return The next valid token number.
876 IN CONST GUID
*Guid OPTIONAL
,
882 Status
= GetPiPcdProtocol ()->GetNextToken (Guid
, &TokenNumber
);
883 ASSERT (!EFI_ERROR (Status
) || TokenNumber
== 0);
889 Used to retrieve the list of available PCD token space GUIDs.
891 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
893 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
894 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
896 @param TokenSpaceGuid The pointer to the a PCD token space GUID.
898 @return The next valid token namespace.
903 LibPcdGetNextTokenSpace (
904 IN CONST GUID
*TokenSpaceGuid
907 GetPiPcdProtocol ()->GetNextTokenSpace (&TokenSpaceGuid
);
909 return (GUID
*)TokenSpaceGuid
;
913 Sets a value of a patchable PCD entry that is type pointer.
915 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
916 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
917 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
918 NULL to indicate that the set operation was not actually performed.
919 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
920 MaximumDatumSize and NULL must be returned.
922 If PatchVariable is NULL, then ASSERT().
923 If SizeOfBuffer is NULL, then ASSERT().
924 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
926 @param[out] PatchVariable A pointer to the global variable in a module that is
927 the target of the set operation.
928 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
929 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
930 @param[in] Buffer A pointer to the buffer to used to set the target variable.
932 @return Return the pointer to the buffer been set.
938 OUT VOID
*PatchVariable
,
939 IN UINTN MaximumDatumSize
,
940 IN OUT UINTN
*SizeOfBuffer
,
941 IN CONST VOID
*Buffer
944 ASSERT (PatchVariable
!= NULL
);
945 ASSERT (SizeOfBuffer
!= NULL
);
947 if (*SizeOfBuffer
> 0) {
948 ASSERT (Buffer
!= NULL
);
951 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
952 (*SizeOfBuffer
== MAX_ADDRESS
))
954 *SizeOfBuffer
= MaximumDatumSize
;
958 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
960 return (VOID
*)Buffer
;
964 Sets a value of a patchable PCD entry that is type pointer.
966 Sets the PCD entry specified by PatchVariable to the value specified
967 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
968 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
969 to indicate that the set operation was not actually performed.
970 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
971 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
973 If PatchVariable is NULL, then ASSERT().
974 If SizeOfBuffer is NULL, then ASSERT().
975 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
977 @param[out] PatchVariable A pointer to the global variable in a module that is
978 the target of the set operation.
979 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
980 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
981 @param[in] Buffer A pointer to the buffer to used to set the target variable.
983 @return The status of the set operation.
989 OUT VOID
*PatchVariable
,
990 IN UINTN MaximumDatumSize
,
991 IN OUT UINTN
*SizeOfBuffer
,
992 IN CONST VOID
*Buffer
995 ASSERT (PatchVariable
!= NULL
);
996 ASSERT (SizeOfBuffer
!= NULL
);
998 if (*SizeOfBuffer
> 0) {
999 ASSERT (Buffer
!= NULL
);
1002 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1003 (*SizeOfBuffer
== MAX_ADDRESS
))
1005 *SizeOfBuffer
= MaximumDatumSize
;
1006 return RETURN_INVALID_PARAMETER
;
1009 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1011 return RETURN_SUCCESS
;
1015 Sets a value and size of a patchable PCD entry that is type pointer.
1017 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1018 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1019 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1020 NULL to indicate that the set operation was not actually performed.
1021 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1022 MaximumDatumSize and NULL must be returned.
1024 If PatchVariable is NULL, then ASSERT().
1025 If SizeOfPatchVariable is NULL, then ASSERT().
1026 If SizeOfBuffer is NULL, then ASSERT().
1027 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1029 @param[out] PatchVariable A pointer to the global variable in a module that is
1030 the target of the set operation.
1031 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1032 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1033 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1034 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1036 @return Return the pointer to the buffer been set.
1041 LibPatchPcdSetPtrAndSize (
1042 OUT VOID
*PatchVariable
,
1043 OUT UINTN
*SizeOfPatchVariable
,
1044 IN UINTN MaximumDatumSize
,
1045 IN OUT UINTN
*SizeOfBuffer
,
1046 IN CONST VOID
*Buffer
1049 ASSERT (PatchVariable
!= NULL
);
1050 ASSERT (SizeOfPatchVariable
!= NULL
);
1051 ASSERT (SizeOfBuffer
!= NULL
);
1053 if (*SizeOfBuffer
> 0) {
1054 ASSERT (Buffer
!= NULL
);
1057 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1058 (*SizeOfBuffer
== MAX_ADDRESS
))
1060 *SizeOfBuffer
= MaximumDatumSize
;
1064 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1065 *SizeOfPatchVariable
= *SizeOfBuffer
;
1067 return (VOID
*)Buffer
;
1071 Sets a value and size of a patchable PCD entry that is type pointer.
1073 Sets the PCD entry specified by PatchVariable to the value specified
1074 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1075 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1076 to indicate that the set operation was not actually performed.
1077 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1078 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1080 If PatchVariable is NULL, then ASSERT().
1081 If SizeOfPatchVariable is NULL, then ASSERT().
1082 If SizeOfBuffer is NULL, then ASSERT().
1083 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1085 @param[out] PatchVariable A pointer to the global variable in a module that is
1086 the target of the set operation.
1087 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1088 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1089 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1090 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1092 @return The status of the set operation.
1097 LibPatchPcdSetPtrAndSizeS (
1098 OUT VOID
*PatchVariable
,
1099 OUT UINTN
*SizeOfPatchVariable
,
1100 IN UINTN MaximumDatumSize
,
1101 IN OUT UINTN
*SizeOfBuffer
,
1102 IN CONST VOID
*Buffer
1105 ASSERT (PatchVariable
!= NULL
);
1106 ASSERT (SizeOfPatchVariable
!= NULL
);
1107 ASSERT (SizeOfBuffer
!= NULL
);
1109 if (*SizeOfBuffer
> 0) {
1110 ASSERT (Buffer
!= NULL
);
1113 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1114 (*SizeOfBuffer
== MAX_ADDRESS
))
1116 *SizeOfBuffer
= MaximumDatumSize
;
1117 return RETURN_INVALID_PARAMETER
;
1120 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1121 *SizeOfPatchVariable
= *SizeOfBuffer
;
1123 return RETURN_SUCCESS
;
1127 Retrieve additional information associated with a PCD token.
1129 This includes information such as the type of value the TokenNumber is associated with as well as possible
1130 human readable name that is associated with the token.
1132 If TokenNumber is not in the default token space specified, then ASSERT().
1134 @param[in] TokenNumber The PCD token number.
1135 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1136 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1141 IN UINTN TokenNumber
,
1142 OUT PCD_INFO
*PcdInfo
1147 Status
= GetPcdInfoProtocolPointer ()->GetInfo (TokenNumber
, (EFI_PCD_INFO
*)PcdInfo
);
1148 ASSERT_EFI_ERROR (Status
);
1152 Retrieve additional information associated with a PCD token.
1154 This includes information such as the type of value the TokenNumber is associated with as well as possible
1155 human readable name that is associated with the token.
1157 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1159 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1160 @param[in] TokenNumber The PCD token number.
1161 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1162 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1167 IN CONST GUID
*Guid
,
1168 IN UINTN TokenNumber
,
1169 OUT PCD_INFO
*PcdInfo
1174 Status
= GetPiPcdInfoProtocolPointer ()->GetInfo (Guid
, TokenNumber
, (EFI_PCD_INFO
*)PcdInfo
);
1175 ASSERT_EFI_ERROR (Status
);
1179 Retrieve the currently set SKU Id.
1181 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1182 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1191 return GetPiPcdInfoProtocolPointer ()->GetSku ();