2 Implementation of PcdLib class library for DXE phase.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Protocol/Pcd.h>
14 #include <Protocol/PiPcd.h>
15 #include <Protocol/PcdInfo.h>
16 #include <Protocol/PiPcdInfo.h>
18 #include <Library/PcdLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/UefiBootServicesTableLib.h>
21 #include <Library/BaseMemoryLib.h>
23 PCD_PROTOCOL
*mPcd
= NULL
;
24 EFI_PCD_PROTOCOL
*mPiPcd
= NULL
;
25 GET_PCD_INFO_PROTOCOL
*mPcdInfo
= NULL
;
26 EFI_GET_PCD_INFO_PROTOCOL
*mPiPcdInfo
= NULL
;
29 Retrieves the PI PCD protocol from the handle database.
31 @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.
43 // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module
44 // access DynamicEx type PCD.
46 Status
= gBS
->LocateProtocol (&gEfiPcdProtocolGuid
, NULL
, (VOID
**) &mPiPcd
);
47 ASSERT_EFI_ERROR (Status
);
48 ASSERT (mPiPcd
!= NULL
);
54 Retrieves the PCD protocol from the handle database.
56 @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.
68 // PCD protocol need to be installed before the module access Dynamic type PCD.
69 // But dynamic type PCD is not required in PI 1.2 specification.
71 Status
= gBS
->LocateProtocol (&gPcdProtocolGuid
, NULL
, (VOID
**)&mPcd
);
72 ASSERT_EFI_ERROR (Status
);
73 ASSERT (mPcd
!= NULL
);
79 Retrieves the PI PCD info protocol from the handle database.
81 @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.
83 EFI_GET_PCD_INFO_PROTOCOL
*
84 GetPiPcdInfoProtocolPointer (
90 if (mPiPcdInfo
== NULL
) {
91 Status
= gBS
->LocateProtocol (&gEfiGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPiPcdInfo
);
92 ASSERT_EFI_ERROR (Status
);
93 ASSERT (mPiPcdInfo
!= NULL
);
99 Retrieves the PCD info protocol from the handle database.
101 @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.
103 GET_PCD_INFO_PROTOCOL
*
104 GetPcdInfoProtocolPointer (
110 if (mPcdInfo
== NULL
) {
111 Status
= gBS
->LocateProtocol (&gGetPcdInfoProtocolGuid
, NULL
, (VOID
**)&mPcdInfo
);
112 ASSERT_EFI_ERROR (Status
);
113 ASSERT (mPcdInfo
!= NULL
);
119 This function provides a means by which SKU support can be established in the PCD infrastructure.
121 Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned.
123 @param SkuId The SKU value that will be used when the PCD service retrieves and sets values
124 associated with a PCD token.
126 @return Return the SKU ID that just be set.
135 GetPcdProtocol()->SetSku (SkuId
);
143 This function provides a means by which to retrieve a value for a given PCD token.
145 Returns the 8-bit value for the token specified by TokenNumber.
147 @param[in] TokenNumber The PCD token number to retrieve a current value for.
149 @return Returns the 8-bit value for the token specified by TokenNumber.
158 return GetPcdProtocol()->Get8 (TokenNumber
);
164 This function provides a means by which to retrieve a value for a given PCD token.
166 Returns the 16-bit value for the token specified by TokenNumber.
168 @param[in] TokenNumber The PCD token number to retrieve a current value for.
170 @return Returns the 16-bit value for the token specified by TokenNumber.
179 return GetPcdProtocol()->Get16 (TokenNumber
);
185 This function provides a means by which to retrieve a value for a given PCD token.
187 Returns the 32-bit value for the token specified by TokenNumber.
189 @param[in] TokenNumber The PCD token number to retrieve a current value for.
191 @return Returns the 32-bit value for the token specified by TokenNumber.
200 return GetPcdProtocol()->Get32 (TokenNumber
);
206 This function provides a means by which to retrieve a value for a given PCD token.
208 Returns the 64-bit value for the token specified by TokenNumber.
210 @param[in] TokenNumber The PCD token number to retrieve a current value for.
212 @return Returns the 64-bit value for the token specified by TokenNumber.
221 return GetPcdProtocol()->Get64 (TokenNumber
);
227 This function provides a means by which to retrieve a value for a given PCD token.
229 Returns the pointer to the buffer of the token specified by TokenNumber.
231 @param[in] TokenNumber The PCD token number to retrieve a current value for.
233 @return Returns the pointer to the token specified by TokenNumber.
242 return GetPcdProtocol()->GetPtr (TokenNumber
);
248 This function provides a means by which to retrieve a value for a given PCD token.
250 Returns the Boolean value of the token specified by TokenNumber.
252 @param[in] TokenNumber The PCD token number to retrieve a current value for.
254 @return Returns the Boolean value of the token specified by TokenNumber.
263 return GetPcdProtocol()->GetBool (TokenNumber
);
269 This function provides a means by which to retrieve the size of a given PCD token.
271 @param[in] TokenNumber The PCD token number to retrieve a current value for.
273 @return Returns the size of the token specified by TokenNumber.
282 return GetPcdProtocol()->GetSize (TokenNumber
);
288 This function provides a means by which to retrieve a value for a given PCD token.
290 Returns the 8-bit value for the token specified by TokenNumber and Guid.
292 If Guid is NULL, then ASSERT().
294 @param[in] Guid The pointer to a 128-bit unique value that designates
295 which namespace to retrieve a value from.
296 @param[in] TokenNumber The PCD token number to retrieve a current value for.
298 @return Return the UINT8.
308 ASSERT (Guid
!= NULL
);
310 return GetPiPcdProtocol()->Get8 (Guid
, TokenNumber
);
315 This function provides a means by which to retrieve a value for a given PCD token.
317 Returns the 16-bit value for the token specified by TokenNumber and Guid.
319 If Guid is NULL, then ASSERT().
321 @param[in] Guid The pointer to a 128-bit unique value that designates
322 which namespace to retrieve a value from.
323 @param[in] TokenNumber The PCD token number to retrieve a current value for.
325 @return Return the UINT16.
335 ASSERT (Guid
!= NULL
);
337 return GetPiPcdProtocol()->Get16 (Guid
, TokenNumber
);
342 Returns the 32-bit value for the token specified by TokenNumber and Guid.
343 If Guid is NULL, then ASSERT().
345 @param[in] Guid The pointer to a 128-bit unique value that designates
346 which namespace to retrieve a value from.
347 @param[in] TokenNumber The PCD token number to retrieve a current value for.
349 @return Return the UINT32.
359 ASSERT (Guid
!= NULL
);
361 return GetPiPcdProtocol()->Get32 (Guid
, TokenNumber
);
367 This function provides a means by which to retrieve a value for a given PCD token.
369 Returns the 64-bit value for the token specified by TokenNumber and Guid.
371 If Guid is NULL, then ASSERT().
373 @param[in] Guid The pointer to a 128-bit unique value that designates
374 which namespace to retrieve a value from.
375 @param[in] TokenNumber The PCD token number to retrieve a current value for.
377 @return Return the UINT64.
387 ASSERT (Guid
!= NULL
);
389 return GetPiPcdProtocol()->Get64 (Guid
, TokenNumber
);
395 This function provides a means by which to retrieve a value for a given PCD token.
397 Returns the pointer to the buffer of token specified by TokenNumber and Guid.
399 If Guid is NULL, then ASSERT().
401 @param[in] Guid The pointer to a 128-bit unique value that designates
402 which namespace to retrieve a value from.
403 @param[in] TokenNumber The PCD token number to retrieve a current value for.
405 @return Return the VOID* pointer.
415 ASSERT (Guid
!= NULL
);
417 return GetPiPcdProtocol()->GetPtr (Guid
, TokenNumber
);
423 This function provides a means by which to retrieve a value for a given PCD token.
425 Returns the Boolean value of the token specified by TokenNumber and Guid.
427 If Guid is NULL, then ASSERT().
429 @param[in] Guid The pointer to a 128-bit unique value that designates
430 which namespace to retrieve a value from.
431 @param[in] TokenNumber The PCD token number to retrieve a current value for.
433 @return Return the BOOLEAN.
443 ASSERT (Guid
!= NULL
);
445 return GetPiPcdProtocol()->GetBool (Guid
, TokenNumber
);
451 This function provides a means by which to retrieve the size of a given PCD token.
453 Returns the size of the token specified by TokenNumber and Guid.
455 If Guid is NULL, then ASSERT().
457 @param[in] Guid The pointer to a 128-bit unique value that designates
458 which namespace to retrieve a value from.
459 @param[in] TokenNumber The PCD token number to retrieve a current value for.
461 @return Return the size.
471 ASSERT (Guid
!= NULL
);
473 return GetPiPcdProtocol()->GetSize (Guid
, TokenNumber
);
478 This function provides a means by which to set a value for a given PCD token.
480 Sets the 8-bit value for the token specified by TokenNumber
481 to the value specified by Value.
483 @param[in] TokenNumber The PCD token number to set a current value for.
484 @param[in] Value The 8-bit value to set.
486 @return The status of the set operation.
492 IN UINTN TokenNumber
,
496 return GetPcdProtocol()->Set8 (TokenNumber
, Value
);
500 This function provides a means by which to set a value for a given PCD token.
502 Sets the 16-bit value for the token specified by TokenNumber
503 to the value specified by Value.
505 @param[in] TokenNumber The PCD token number to set a current value for.
506 @param[in] Value The 16-bit value to set.
508 @return The status of the set operation.
514 IN UINTN TokenNumber
,
518 return GetPcdProtocol()->Set16 (TokenNumber
, Value
);
522 This function provides a means by which to set a value for a given PCD token.
524 Sets the 32-bit value for the token specified by TokenNumber
525 to the value specified by Value.
527 @param[in] TokenNumber The PCD token number to set a current value for.
528 @param[in] Value The 32-bit value to set.
530 @return The status of the set operation.
536 IN UINTN TokenNumber
,
540 return GetPcdProtocol()->Set32 (TokenNumber
, Value
);
544 This function provides a means by which to set a value for a given PCD token.
546 Sets the 64-bit value for the token specified by TokenNumber
547 to the value specified by Value.
549 @param[in] TokenNumber The PCD token number to set a current value for.
550 @param[in] Value The 64-bit value to set.
552 @return The status of the set operation.
558 IN UINTN TokenNumber
,
562 return GetPcdProtocol()->Set64 (TokenNumber
, Value
);
566 This function provides a means by which to set a value for a given PCD token.
568 Sets a buffer for the token specified by TokenNumber to the value specified
569 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
570 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
571 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
572 was not actually performed.
574 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to the
575 maximum size supported by TokenName and EFI_INVALID_PARAMETER must be returned.
577 If SizeOfBuffer is NULL, then ASSERT().
578 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
580 @param[in] TokenNumber The PCD token number to set a current value for.
581 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
582 @param[in] Buffer A pointer to the buffer to set.
584 @return The status of the set operation.
590 IN UINTN TokenNumber
,
591 IN OUT UINTN
*SizeOfBuffer
,
592 IN CONST VOID
*Buffer
595 ASSERT (SizeOfBuffer
!= NULL
);
597 if (*SizeOfBuffer
> 0) {
598 ASSERT (Buffer
!= NULL
);
601 return GetPcdProtocol()->SetPtr (TokenNumber
, SizeOfBuffer
, (VOID
*) Buffer
);
605 This function provides a means by which to set a value for a given PCD token.
607 Sets the boolean value for the token specified by TokenNumber
608 to the value specified by Value.
610 @param[in] TokenNumber The PCD token number to set a current value for.
611 @param[in] Value The boolean value to set.
613 @return The status of the set operation.
619 IN UINTN TokenNumber
,
623 return GetPcdProtocol()->SetBool (TokenNumber
, Value
);
627 This function provides a means by which to set a value for a given PCD token.
629 Sets the 8-bit value for the token specified by TokenNumber
630 to the value specified by Value.
632 If Guid is NULL, then ASSERT().
634 @param[in] Guid The pointer to a 128-bit unique value that
635 designates which namespace to set a value from.
636 @param[in] TokenNumber The PCD token number to set a current value for.
637 @param[in] Value The 8-bit value to set.
639 @return The status of the set operation.
646 IN UINTN TokenNumber
,
650 ASSERT (Guid
!= NULL
);
652 return GetPiPcdProtocol()->Set8 (Guid
, TokenNumber
, Value
);
656 This function provides a means by which to set a value for a given PCD token.
658 Sets the 16-bit value for the token specified by TokenNumber
659 to the value specified by Value.
661 If Guid is NULL, then ASSERT().
663 @param[in] Guid The pointer to a 128-bit unique value that
664 designates which namespace to set a value from.
665 @param[in] TokenNumber The PCD token number to set a current value for.
666 @param[in] Value The 16-bit value to set.
668 @return The status of the set operation.
675 IN UINTN TokenNumber
,
679 ASSERT (Guid
!= NULL
);
681 return GetPiPcdProtocol()->Set16 (Guid
, TokenNumber
, Value
);
685 This function provides a means by which to set a value for a given PCD token.
687 Sets the 32-bit value for the token specified by TokenNumber
688 to the value specified by Value.
690 If Guid is NULL, then ASSERT().
692 @param[in] Guid The pointer to a 128-bit unique value that
693 designates which namespace to set a value from.
694 @param[in] TokenNumber The PCD token number to set a current value for.
695 @param[in] Value The 32-bit value to set.
697 @return The status of the set operation.
704 IN UINTN TokenNumber
,
708 ASSERT (Guid
!= NULL
);
710 return GetPiPcdProtocol()->Set32 (Guid
, TokenNumber
, Value
);
714 This function provides a means by which to set a value for a given PCD token.
716 Sets the 64-bit value for the token specified by TokenNumber
717 to the value specified by Value.
719 If Guid is NULL, then ASSERT().
721 @param[in] Guid The pointer to a 128-bit unique value that
722 designates which namespace to set a value from.
723 @param[in] TokenNumber The PCD token number to set a current value for.
724 @param[in] Value The 64-bit value to set.
726 @return The status of the set operation.
733 IN UINTN TokenNumber
,
737 ASSERT (Guid
!= NULL
);
739 return GetPiPcdProtocol()->Set64 (Guid
, TokenNumber
, Value
);
743 This function provides a means by which to set a value for a given PCD token.
745 Sets a buffer for the token specified by TokenNumber to the value specified by
746 Buffer and SizeOfBuffer. If SizeOfBuffer is greater than the maximum size
747 support by TokenNumber, then set SizeOfBuffer to the maximum size supported by
748 TokenNumber and return EFI_INVALID_PARAMETER to indicate that the set operation
749 was not actually performed.
751 If Guid is NULL, then ASSERT().
752 If SizeOfBuffer is NULL, then ASSERT().
753 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
755 @param[in] Guid Pointer to a 128-bit unique value that
756 designates which namespace to set a value from.
757 @param[in] TokenNumber The PCD token number to set a current value for.
758 @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.
759 @param[in] Buffer A pointer to the buffer to set.
761 @return The status of the set operation.
768 IN UINTN TokenNumber
,
769 IN OUT UINTN
*SizeOfBuffer
,
773 ASSERT (Guid
!= NULL
);
775 ASSERT (SizeOfBuffer
!= NULL
);
777 if (*SizeOfBuffer
> 0) {
778 ASSERT (Buffer
!= NULL
);
781 return GetPiPcdProtocol()->SetPtr (Guid
, TokenNumber
, SizeOfBuffer
, Buffer
);
785 This function provides a means by which to set a value for a given PCD token.
787 Sets the boolean value for the token specified by TokenNumber
788 to the value specified by Value.
790 If Guid is NULL, then ASSERT().
792 @param[in] Guid The pointer to a 128-bit unique value that
793 designates which namespace to set a value from.
794 @param[in] TokenNumber The PCD token number to set a current value for.
795 @param[in] Value The boolean value to set.
797 @return The status of the set operation.
804 IN UINTN TokenNumber
,
808 ASSERT (Guid
!= NULL
);
810 return GetPiPcdProtocol()->SetBool (Guid
, TokenNumber
, Value
);
814 Set up a notification function that is called when a specified token is set.
816 When the token specified by TokenNumber and Guid is set,
817 then notification function specified by NotificationFunction is called.
818 If Guid is NULL, then the default token space is used.
819 If NotificationFunction is NULL, then ASSERT().
821 @param[in] Guid The pointer to a 128-bit unique value that designates which
822 namespace to set a value from. If NULL, then the default
824 @param[in] TokenNumber The PCD token number to monitor.
825 @param[in] NotificationFunction The function to call when the token
826 specified by Guid and TokenNumber is set.
831 LibPcdCallbackOnSet (
832 IN CONST GUID
*Guid OPTIONAL
,
833 IN UINTN TokenNumber
,
834 IN PCD_CALLBACK NotificationFunction
839 ASSERT (NotificationFunction
!= NULL
);
841 Status
= GetPiPcdProtocol()->CallbackOnSet (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
842 ASSERT_EFI_ERROR (Status
);
850 Disable a notification function that was established with LibPcdCallbackonSet().
852 Disable a notification function that was previously established with LibPcdCallbackOnSet().
853 If NotificationFunction is NULL, then ASSERT().
854 If LibPcdCallbackOnSet() was not previously called with Guid, TokenNumber,
855 and NotificationFunction, then ASSERT().
857 @param[in] Guid Specify the GUID token space.
858 @param[in] TokenNumber Specify the token number.
859 @param[in] NotificationFunction The callback function to be unregistered.
864 LibPcdCancelCallback (
865 IN CONST GUID
*Guid OPTIONAL
,
866 IN UINTN TokenNumber
,
867 IN PCD_CALLBACK NotificationFunction
872 ASSERT (NotificationFunction
!= NULL
);
874 Status
= GetPiPcdProtocol()->CancelCallback (Guid
, TokenNumber
, (EFI_PCD_PROTOCOL_CALLBACK
) NotificationFunction
);
875 ASSERT_EFI_ERROR (Status
);
883 Retrieves the next token in a token space.
885 Retrieves the next PCD token number from the token space specified by Guid.
886 If Guid is NULL, then the default token space is used. If TokenNumber is 0,
887 then the first token number is returned. Otherwise, the token number that
888 follows TokenNumber in the token space is returned. If TokenNumber is the last
889 token number in the token space, then 0 is returned.
891 If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT().
893 @param[in] Guid The pointer to a 128-bit unique value that designates which namespace
894 to set a value from. If NULL, then the default token space is used.
895 @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD
898 @return The next valid token number.
904 IN CONST GUID
*Guid OPTIONAL
,
910 Status
= GetPiPcdProtocol()->GetNextToken (Guid
, &TokenNumber
);
911 ASSERT (!EFI_ERROR (Status
) || TokenNumber
== 0);
919 Used to retrieve the list of available PCD token space GUIDs.
921 Returns the PCD token space GUID that follows TokenSpaceGuid in the list of token spaces
923 If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned.
924 If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned.
926 @param TokenSpaceGuid The pointer to the a PCD token space GUID.
928 @return The next valid token namespace.
933 LibPcdGetNextTokenSpace (
934 IN CONST GUID
*TokenSpaceGuid
937 GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid
);
939 return (GUID
*)TokenSpaceGuid
;
944 Sets a value of a patchable PCD entry that is type pointer.
946 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
947 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
948 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
949 NULL to indicate that the set operation was not actually performed.
950 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
951 MaximumDatumSize and NULL must be returned.
953 If PatchVariable is NULL, then ASSERT().
954 If SizeOfBuffer is NULL, then ASSERT().
955 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
957 @param[out] PatchVariable A pointer to the global variable in a module that is
958 the target of the set operation.
959 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
960 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
961 @param[in] Buffer A pointer to the buffer to used to set the target variable.
963 @return Return the pointer to the buffer been set.
969 OUT VOID
*PatchVariable
,
970 IN UINTN MaximumDatumSize
,
971 IN OUT UINTN
*SizeOfBuffer
,
972 IN CONST VOID
*Buffer
975 ASSERT (PatchVariable
!= NULL
);
976 ASSERT (SizeOfBuffer
!= NULL
);
978 if (*SizeOfBuffer
> 0) {
979 ASSERT (Buffer
!= NULL
);
982 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
983 (*SizeOfBuffer
== MAX_ADDRESS
)) {
984 *SizeOfBuffer
= MaximumDatumSize
;
988 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
990 return (VOID
*) Buffer
;
994 Sets a value of a patchable PCD entry that is type pointer.
996 Sets the PCD entry specified by PatchVariable to the value specified
997 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
998 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
999 to indicate that the set operation was not actually performed.
1000 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1001 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1003 If PatchVariable is NULL, then ASSERT().
1004 If SizeOfBuffer is NULL, then ASSERT().
1005 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1007 @param[out] PatchVariable A pointer to the global variable in a module that is
1008 the target of the set operation.
1009 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1010 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1011 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1013 @return The status of the set operation.
1018 LibPatchPcdSetPtrS (
1019 OUT VOID
*PatchVariable
,
1020 IN UINTN MaximumDatumSize
,
1021 IN OUT UINTN
*SizeOfBuffer
,
1022 IN CONST VOID
*Buffer
1025 ASSERT (PatchVariable
!= NULL
);
1026 ASSERT (SizeOfBuffer
!= NULL
);
1028 if (*SizeOfBuffer
> 0) {
1029 ASSERT (Buffer
!= NULL
);
1032 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1033 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1034 *SizeOfBuffer
= MaximumDatumSize
;
1035 return RETURN_INVALID_PARAMETER
;
1038 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1040 return RETURN_SUCCESS
;
1045 Sets a value and size of a patchable PCD entry that is type pointer.
1047 Sets the PCD entry specified by PatchVariable to the value specified by Buffer
1048 and SizeOfBuffer. Buffer is returned. If SizeOfBuffer is greater than
1049 MaximumDatumSize, then set SizeOfBuffer to MaximumDatumSize and return
1050 NULL to indicate that the set operation was not actually performed.
1051 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1052 MaximumDatumSize and NULL must be returned.
1054 If PatchVariable is NULL, then ASSERT().
1055 If SizeOfPatchVariable is NULL, then ASSERT().
1056 If SizeOfBuffer is NULL, then ASSERT().
1057 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1059 @param[out] PatchVariable A pointer to the global variable in a module that is
1060 the target of the set operation.
1061 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1062 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1063 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1064 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1066 @return Return the pointer to the buffer been set.
1071 LibPatchPcdSetPtrAndSize (
1072 OUT VOID
*PatchVariable
,
1073 OUT UINTN
*SizeOfPatchVariable
,
1074 IN UINTN MaximumDatumSize
,
1075 IN OUT UINTN
*SizeOfBuffer
,
1076 IN CONST VOID
*Buffer
1079 ASSERT (PatchVariable
!= NULL
);
1080 ASSERT (SizeOfPatchVariable
!= NULL
);
1081 ASSERT (SizeOfBuffer
!= NULL
);
1083 if (*SizeOfBuffer
> 0) {
1084 ASSERT (Buffer
!= NULL
);
1087 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1088 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1089 *SizeOfBuffer
= MaximumDatumSize
;
1093 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1094 *SizeOfPatchVariable
= *SizeOfBuffer
;
1096 return (VOID
*) Buffer
;
1100 Sets a value and size of a patchable PCD entry that is type pointer.
1102 Sets the PCD entry specified by PatchVariable to the value specified
1103 by Buffer and SizeOfBuffer. If SizeOfBuffer is greater than MaximumDatumSize,
1104 then set SizeOfBuffer to MaximumDatumSize and return RETURN_INVALID_PARAMETER
1105 to indicate that the set operation was not actually performed.
1106 If SizeOfBuffer is set to MAX_ADDRESS, then SizeOfBuffer must be set to
1107 MaximumDatumSize and RETURN_INVALID_PARAMETER must be returned.
1109 If PatchVariable is NULL, then ASSERT().
1110 If SizeOfPatchVariable is NULL, then ASSERT().
1111 If SizeOfBuffer is NULL, then ASSERT().
1112 If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT().
1114 @param[out] PatchVariable A pointer to the global variable in a module that is
1115 the target of the set operation.
1116 @param[out] SizeOfPatchVariable A pointer to the size, in bytes, of PatchVariable.
1117 @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable.
1118 @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer.
1119 @param[in] Buffer A pointer to the buffer to used to set the target variable.
1121 @return The status of the set operation.
1126 LibPatchPcdSetPtrAndSizeS (
1127 OUT VOID
*PatchVariable
,
1128 OUT UINTN
*SizeOfPatchVariable
,
1129 IN UINTN MaximumDatumSize
,
1130 IN OUT UINTN
*SizeOfBuffer
,
1131 IN CONST VOID
*Buffer
1134 ASSERT (PatchVariable
!= NULL
);
1135 ASSERT (SizeOfPatchVariable
!= NULL
);
1136 ASSERT (SizeOfBuffer
!= NULL
);
1138 if (*SizeOfBuffer
> 0) {
1139 ASSERT (Buffer
!= NULL
);
1142 if ((*SizeOfBuffer
> MaximumDatumSize
) ||
1143 (*SizeOfBuffer
== MAX_ADDRESS
)) {
1144 *SizeOfBuffer
= MaximumDatumSize
;
1145 return RETURN_INVALID_PARAMETER
;
1148 CopyMem (PatchVariable
, Buffer
, *SizeOfBuffer
);
1149 *SizeOfPatchVariable
= *SizeOfBuffer
;
1151 return RETURN_SUCCESS
;
1155 Retrieve additional information associated with a PCD token.
1157 This includes information such as the type of value the TokenNumber is associated with as well as possible
1158 human readable name that is associated with the token.
1160 If TokenNumber is not in the default token space specified, then ASSERT().
1162 @param[in] TokenNumber The PCD token number.
1163 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1164 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1169 IN UINTN TokenNumber
,
1170 OUT PCD_INFO
*PcdInfo
1175 Status
= GetPcdInfoProtocolPointer()->GetInfo (TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1176 ASSERT_EFI_ERROR (Status
);
1180 Retrieve additional information associated with a PCD token.
1182 This includes information such as the type of value the TokenNumber is associated with as well as possible
1183 human readable name that is associated with the token.
1185 If TokenNumber is not in the token space specified by Guid, then ASSERT().
1187 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1188 @param[in] TokenNumber The PCD token number.
1189 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
1190 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
1195 IN CONST GUID
*Guid
,
1196 IN UINTN TokenNumber
,
1197 OUT PCD_INFO
*PcdInfo
1202 Status
= GetPiPcdInfoProtocolPointer()->GetInfo (Guid
, TokenNumber
, (EFI_PCD_INFO
*) PcdInfo
);
1203 ASSERT_EFI_ERROR (Status
);
1207 Retrieve the currently set SKU Id.
1209 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
1210 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
1219 return GetPiPcdInfoProtocolPointer()->GetSku ();