TianoCore EDK2 master
Loading...
Searching...
No Matches
PeiPcdLib.c
Go to the documentation of this file.
1
10#include <PiPei.h>
11
12#include <Ppi/Pcd.h>
13#include <Ppi/PiPcd.h>
14#include <Ppi/PcdInfo.h>
15#include <Ppi/PiPcdInfo.h>
16
18#include <Library/PcdLib.h>
19#include <Library/DebugLib.h>
21
31PCD_PPI *
33 VOID
34 )
35{
36 EFI_STATUS Status;
37 PCD_PPI *PcdPpi;
38
39 Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);
40 ASSERT_EFI_ERROR (Status);
41
42 return PcdPpi;
43}
44
56 VOID
57 )
58{
59 EFI_STATUS Status;
60 EFI_PEI_PCD_PPI *PiPcdPpi;
61
62 Status = PeiServicesLocatePpi (&gEfiPeiPcdPpiGuid, 0, NULL, (VOID **)&PiPcdPpi);
63 ASSERT_EFI_ERROR (Status);
64
65 return PiPcdPpi;
66}
67
79 VOID
80 )
81{
82 EFI_STATUS Status;
83 GET_PCD_INFO_PPI *PcdInfoPpi;
84
85 Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);
86 ASSERT_EFI_ERROR (Status);
87
88 return PcdInfoPpi;
89}
90
102 VOID
103 )
104{
105 EFI_STATUS Status;
106 EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi;
107
108 Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);
109 ASSERT_EFI_ERROR (Status);
110
111 return PiPcdInfoPpi;
112}
113
125UINTN
126EFIAPI
128 IN UINTN SkuId
129 )
130{
131 GetPiPcdPpiPointer ()->SetSku (SkuId);
132
133 return SkuId;
134}
135
146UINT8
147EFIAPI
149 IN UINTN TokenNumber
150 )
151{
152 return (GetPcdPpiPointer ())->Get8 (TokenNumber);
153}
154
165UINT16
166EFIAPI
168 IN UINTN TokenNumber
169 )
170{
171 return (GetPcdPpiPointer ())->Get16 (TokenNumber);
172}
173
184UINT32
185EFIAPI
187 IN UINTN TokenNumber
188 )
189{
190 return (GetPcdPpiPointer ())->Get32 (TokenNumber);
191}
192
203UINT64
204EFIAPI
206 IN UINTN TokenNumber
207 )
208{
209 return (GetPcdPpiPointer ())->Get64 (TokenNumber);
210}
211
222VOID *
223EFIAPI
225 IN UINTN TokenNumber
226 )
227{
228 return (GetPcdPpiPointer ())->GetPtr (TokenNumber);
229}
230
241BOOLEAN
242EFIAPI
244 IN UINTN TokenNumber
245 )
246{
247 return (GetPcdPpiPointer ())->GetBool (TokenNumber);
248}
249
258UINTN
259EFIAPI
261 IN UINTN TokenNumber
262 )
263{
264 return (GetPcdPpiPointer ())->GetSize (TokenNumber);
265}
266
281UINT8
282EFIAPI
284 IN CONST GUID *Guid,
285 IN UINTN TokenNumber
286 )
287{
288 ASSERT (Guid != NULL);
289
290 return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber);
291}
292
307UINT16
308EFIAPI
310 IN CONST GUID *Guid,
311 IN UINTN TokenNumber
312 )
313{
314 ASSERT (Guid != NULL);
315
316 return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber);
317}
318
330UINT32
331EFIAPI
333 IN CONST GUID *Guid,
334 IN UINTN TokenNumber
335 )
336{
337 ASSERT (Guid != NULL);
338
339 return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber);
340}
341
356UINT64
357EFIAPI
359 IN CONST GUID *Guid,
360 IN UINTN TokenNumber
361 )
362{
363 ASSERT (Guid != NULL);
364 return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber);
365}
366
381VOID *
382EFIAPI
384 IN CONST GUID *Guid,
385 IN UINTN TokenNumber
386 )
387{
388 ASSERT (Guid != NULL);
389
390 return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber);
391}
392
407BOOLEAN
408EFIAPI
410 IN CONST GUID *Guid,
411 IN UINTN TokenNumber
412 )
413{
414 ASSERT (Guid != NULL);
415 return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber);
416}
417
432UINTN
433EFIAPI
435 IN CONST GUID *Guid,
436 IN UINTN TokenNumber
437 )
438{
439 ASSERT (Guid != NULL);
440 return (GetPiPcdPpiPointer ())->GetSize (Guid, TokenNumber);
441}
442
455RETURN_STATUS
456EFIAPI
458 IN UINTN TokenNumber,
459 IN UINT8 Value
460 )
461{
462 return (GetPcdPpiPointer ())->Set8 (TokenNumber, Value);
463}
464
477RETURN_STATUS
478EFIAPI
480 IN UINTN TokenNumber,
481 IN UINT16 Value
482 )
483{
484 return (GetPcdPpiPointer ())->Set16 (TokenNumber, Value);
485}
486
499RETURN_STATUS
500EFIAPI
502 IN UINTN TokenNumber,
503 IN UINT32 Value
504 )
505{
506 return (GetPcdPpiPointer ())->Set32 (TokenNumber, Value);
507}
508
521RETURN_STATUS
522EFIAPI
524 IN UINTN TokenNumber,
525 IN UINT64 Value
526 )
527{
528 return (GetPcdPpiPointer ())->Set64 (TokenNumber, Value);
529}
530
553RETURN_STATUS
554EFIAPI
556 IN UINTN TokenNumber,
557 IN OUT UINTN *SizeOfBuffer,
558 IN CONST VOID *Buffer
559 )
560{
561 ASSERT (SizeOfBuffer != NULL);
562
563 if (*SizeOfBuffer > 0) {
564 ASSERT (Buffer != NULL);
565 }
566
567 return (GetPcdPpiPointer ())->SetPtr (TokenNumber, SizeOfBuffer, (VOID *)Buffer);
568}
569
582RETURN_STATUS
583EFIAPI
585 IN UINTN TokenNumber,
586 IN BOOLEAN Value
587 )
588{
589 return (GetPcdPpiPointer ())->SetBool (TokenNumber, Value);
590}
591
608RETURN_STATUS
609EFIAPI
611 IN CONST GUID *Guid,
612 IN UINTN TokenNumber,
613 IN UINT8 Value
614 )
615{
616 ASSERT (Guid != NULL);
617
618 return (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value);
619}
620
637RETURN_STATUS
638EFIAPI
640 IN CONST GUID *Guid,
641 IN UINTN TokenNumber,
642 IN UINT16 Value
643 )
644{
645 ASSERT (Guid != NULL);
646
647 return (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value);
648}
649
666RETURN_STATUS
667EFIAPI
669 IN CONST GUID *Guid,
670 IN UINTN TokenNumber,
671 IN UINT32 Value
672 )
673{
674 ASSERT (Guid != NULL);
675
676 return (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value);
677}
678
695RETURN_STATUS
696EFIAPI
698 IN CONST GUID *Guid,
699 IN UINTN TokenNumber,
700 IN UINT64 Value
701 )
702{
703 ASSERT (Guid != NULL);
704
705 return (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value);
706}
707
730RETURN_STATUS
731EFIAPI
733 IN CONST GUID *Guid,
734 IN UINTN TokenNumber,
735 IN OUT UINTN *SizeOfBuffer,
736 IN VOID *Buffer
737 )
738{
739 ASSERT (Guid != NULL);
740
741 ASSERT (SizeOfBuffer != NULL);
742
743 if (*SizeOfBuffer > 0) {
744 ASSERT (Buffer != NULL);
745 }
746
747 return (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer);
748}
749
766RETURN_STATUS
767EFIAPI
769 IN CONST GUID *Guid,
770 IN UINTN TokenNumber,
771 IN BOOLEAN Value
772 )
773{
774 ASSERT (Guid != NULL);
775
776 return (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value);
777}
778
795VOID
796EFIAPI
798 IN CONST GUID *Guid OPTIONAL,
799 IN UINTN TokenNumber,
801 )
802{
803 EFI_STATUS Status;
804
805 ASSERT (NotificationFunction != NULL);
806
807 Status = (GetPiPcdPpiPointer ())->CallbackOnSet (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK)NotificationFunction);
808
809 ASSERT_EFI_ERROR (Status);
810
811 return;
812}
813
827VOID
828EFIAPI
830 IN CONST GUID *Guid OPTIONAL,
831 IN UINTN TokenNumber,
833 )
834{
835 EFI_STATUS Status;
836
837 ASSERT (NotificationFunction != NULL);
838
839 Status = (GetPiPcdPpiPointer ())->CancelCallback (Guid, TokenNumber, (EFI_PEI_PCD_PPI_CALLBACK)NotificationFunction);
840
841 ASSERT_EFI_ERROR (Status);
842
843 return;
844}
845
865UINTN
866EFIAPI
868 IN CONST GUID *Guid OPTIONAL,
869 IN UINTN TokenNumber
870 )
871{
872 EFI_STATUS Status;
873
874 Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);
875 ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
876
877 return TokenNumber;
878}
879
893GUID *
894EFIAPI
896 IN CONST GUID *TokenSpaceGuid
897 )
898{
899 (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);
900
901 return (GUID *)TokenSpaceGuid;
902}
903
927VOID *
928EFIAPI
930 OUT VOID *PatchVariable,
931 IN UINTN MaximumDatumSize,
932 IN OUT UINTN *SizeOfBuffer,
933 IN CONST VOID *Buffer
934 )
935{
936 ASSERT (PatchVariable != NULL);
937 ASSERT (SizeOfBuffer != NULL);
938
939 if (*SizeOfBuffer > 0) {
940 ASSERT (Buffer != NULL);
941 }
942
943 if ((*SizeOfBuffer > MaximumDatumSize) ||
944 (*SizeOfBuffer == MAX_ADDRESS))
945 {
946 *SizeOfBuffer = MaximumDatumSize;
947 return NULL;
948 }
949
950 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
951
952 return (VOID *)Buffer;
953}
954
978RETURN_STATUS
979EFIAPI
981 OUT VOID *PatchVariable,
982 IN UINTN MaximumDatumSize,
983 IN OUT UINTN *SizeOfBuffer,
984 IN CONST VOID *Buffer
985 )
986{
987 ASSERT (PatchVariable != NULL);
988 ASSERT (SizeOfBuffer != NULL);
989
990 if (*SizeOfBuffer > 0) {
991 ASSERT (Buffer != NULL);
992 }
993
994 if ((*SizeOfBuffer > MaximumDatumSize) ||
995 (*SizeOfBuffer == MAX_ADDRESS))
996 {
997 *SizeOfBuffer = MaximumDatumSize;
999 }
1000
1001 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1002
1003 return RETURN_SUCCESS;
1004}
1005
1031VOID *
1032EFIAPI
1034 OUT VOID *PatchVariable,
1035 OUT UINTN *SizeOfPatchVariable,
1036 IN UINTN MaximumDatumSize,
1037 IN OUT UINTN *SizeOfBuffer,
1038 IN CONST VOID *Buffer
1039 )
1040{
1041 ASSERT (PatchVariable != NULL);
1042 ASSERT (SizeOfPatchVariable != NULL);
1043 ASSERT (SizeOfBuffer != NULL);
1044
1045 if (*SizeOfBuffer > 0) {
1046 ASSERT (Buffer != NULL);
1047 }
1048
1049 if ((*SizeOfBuffer > MaximumDatumSize) ||
1050 (*SizeOfBuffer == MAX_ADDRESS))
1051 {
1052 *SizeOfBuffer = MaximumDatumSize;
1053 return NULL;
1054 }
1055
1056 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1057 *SizeOfPatchVariable = *SizeOfBuffer;
1058
1059 return (VOID *)Buffer;
1060}
1061
1087RETURN_STATUS
1088EFIAPI
1090 OUT VOID *PatchVariable,
1091 OUT UINTN *SizeOfPatchVariable,
1092 IN UINTN MaximumDatumSize,
1093 IN OUT UINTN *SizeOfBuffer,
1094 IN CONST VOID *Buffer
1095 )
1096{
1097 ASSERT (PatchVariable != NULL);
1098 ASSERT (SizeOfPatchVariable != NULL);
1099 ASSERT (SizeOfBuffer != NULL);
1100
1101 if (*SizeOfBuffer > 0) {
1102 ASSERT (Buffer != NULL);
1103 }
1104
1105 if ((*SizeOfBuffer > MaximumDatumSize) ||
1106 (*SizeOfBuffer == MAX_ADDRESS))
1107 {
1108 *SizeOfBuffer = MaximumDatumSize;
1110 }
1111
1112 CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
1113 *SizeOfPatchVariable = *SizeOfBuffer;
1114
1115 return RETURN_SUCCESS;
1116}
1117
1130VOID
1131EFIAPI
1133 IN UINTN TokenNumber,
1134 OUT PCD_INFO *PcdInfo
1135 )
1136{
1137 EFI_STATUS Status;
1138
1139 Status = GetPcdInfoPpiPointer ()->GetInfo (TokenNumber, (EFI_PCD_INFO *)PcdInfo);
1140 ASSERT_EFI_ERROR (Status);
1141}
1142
1156VOID
1157EFIAPI
1159 IN CONST GUID *Guid,
1160 IN UINTN TokenNumber,
1161 OUT PCD_INFO *PcdInfo
1162 )
1163{
1164 EFI_STATUS Status;
1165
1166 Status = GetPiPcdInfoPpiPointer ()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *)PcdInfo);
1167 ASSERT_EFI_ERROR (Status);
1168}
1169
1177UINTN
1178EFIAPI
1180 VOID
1181 )
1182{
1183 return GetPiPcdInfoPpiPointer ()->GetSku ();
1184}
UINT64 UINTN
#define MAX_ADDRESS
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EFIAPI NotificationFunction(IN EFI_KEY_DATA *KeyData)
Definition: DriverSample.c:117
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define RETURN_SUCCESS
Definition: Base.h:1066
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define RETURN_INVALID_PARAMETER
Definition: Base.h:1076
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
VOID(EFIAPI * PCD_CALLBACK)(IN CONST GUID *CallBackGuid OPTIONAL, IN UINTN CallBackToken, IN OUT VOID *TokenData, IN UINTN TokenDataSize)
Definition: PcdLib.h:1363
VOID EFIAPI LibPcdCallbackOnSet(IN CONST GUID *Guid OPTIONAL, IN UINTN TokenNumber, IN PCD_CALLBACK NotificationFunction)
Definition: PeiPcdLib.c:797
PCD_PPI * GetPcdPpiPointer(VOID)
Definition: PeiPcdLib.c:32
RETURN_STATUS EFIAPI LibPcdSetEx16S(IN CONST GUID *Guid, IN UINTN TokenNumber, IN UINT16 Value)
Definition: PeiPcdLib.c:639
RETURN_STATUS EFIAPI LibPcdSet8S(IN UINTN TokenNumber, IN UINT8 Value)
Definition: PeiPcdLib.c:457
RETURN_STATUS EFIAPI LibPatchPcdSetPtrS(OUT VOID *PatchVariable, IN UINTN MaximumDatumSize, IN OUT UINTN *SizeOfBuffer, IN CONST VOID *Buffer)
Definition: PeiPcdLib.c:980
UINTN EFIAPI LibPcdGetNextToken(IN CONST GUID *Guid OPTIONAL, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:867
UINT32 EFIAPI LibPcdGetEx32(IN CONST GUID *Guid, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:332
UINT8 EFIAPI LibPcdGetEx8(IN CONST GUID *Guid, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:283
VOID EFIAPI LibPcdGetInfoEx(IN CONST GUID *Guid, IN UINTN TokenNumber, OUT PCD_INFO *PcdInfo)
Definition: PeiPcdLib.c:1158
RETURN_STATUS EFIAPI LibPatchPcdSetPtrAndSizeS(OUT VOID *PatchVariable, OUT UINTN *SizeOfPatchVariable, IN UINTN MaximumDatumSize, IN OUT UINTN *SizeOfBuffer, IN CONST VOID *Buffer)
Definition: PeiPcdLib.c:1089
UINT16 EFIAPI LibPcdGet16(IN UINTN TokenNumber)
Definition: PeiPcdLib.c:167
UINT64 EFIAPI LibPcdGetEx64(IN CONST GUID *Guid, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:358
UINT16 EFIAPI LibPcdGetEx16(IN CONST GUID *Guid, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:309
RETURN_STATUS EFIAPI LibPcdSetExPtrS(IN CONST GUID *Guid, IN UINTN TokenNumber, IN OUT UINTN *SizeOfBuffer, IN VOID *Buffer)
Definition: PeiPcdLib.c:732
VOID EFIAPI LibPcdGetInfo(IN UINTN TokenNumber, OUT PCD_INFO *PcdInfo)
Definition: PeiPcdLib.c:1132
UINTN EFIAPI LibPcdGetSize(IN UINTN TokenNumber)
Definition: PeiPcdLib.c:260
RETURN_STATUS EFIAPI LibPcdSetPtrS(IN UINTN TokenNumber, IN OUT UINTN *SizeOfBuffer, IN CONST VOID *Buffer)
Definition: PeiPcdLib.c:555
UINT64 EFIAPI LibPcdGet64(IN UINTN TokenNumber)
Definition: PeiPcdLib.c:205
UINTN EFIAPI LibPcdGetSku(VOID)
Definition: PeiPcdLib.c:1179
GUID *EFIAPI LibPcdGetNextTokenSpace(IN CONST GUID *TokenSpaceGuid)
Definition: PeiPcdLib.c:895
RETURN_STATUS EFIAPI LibPcdSetEx8S(IN CONST GUID *Guid, IN UINTN TokenNumber, IN UINT8 Value)
Definition: PeiPcdLib.c:610
RETURN_STATUS EFIAPI LibPcdSetExBoolS(IN CONST GUID *Guid, IN UINTN TokenNumber, IN BOOLEAN Value)
Definition: PeiPcdLib.c:768
RETURN_STATUS EFIAPI LibPcdSetEx64S(IN CONST GUID *Guid, IN UINTN TokenNumber, IN UINT64 Value)
Definition: PeiPcdLib.c:697
VOID *EFIAPI LibPatchPcdSetPtrAndSize(OUT VOID *PatchVariable, OUT UINTN *SizeOfPatchVariable, IN UINTN MaximumDatumSize, IN OUT UINTN *SizeOfBuffer, IN CONST VOID *Buffer)
Definition: PeiPcdLib.c:1033
EFI_GET_PCD_INFO_PPI * GetPiPcdInfoPpiPointer(VOID)
Definition: PeiPcdLib.c:101
UINT8 EFIAPI LibPcdGet8(IN UINTN TokenNumber)
Definition: PeiPcdLib.c:148
VOID *EFIAPI LibPatchPcdSetPtr(OUT VOID *PatchVariable, IN UINTN MaximumDatumSize, IN OUT UINTN *SizeOfBuffer, IN CONST VOID *Buffer)
Definition: PeiPcdLib.c:929
GET_PCD_INFO_PPI * GetPcdInfoPpiPointer(VOID)
Definition: PeiPcdLib.c:78
RETURN_STATUS EFIAPI LibPcdSet32S(IN UINTN TokenNumber, IN UINT32 Value)
Definition: PeiPcdLib.c:501
RETURN_STATUS EFIAPI LibPcdSet16S(IN UINTN TokenNumber, IN UINT16 Value)
Definition: PeiPcdLib.c:479
VOID EFIAPI LibPcdCancelCallback(IN CONST GUID *Guid OPTIONAL, IN UINTN TokenNumber, IN PCD_CALLBACK NotificationFunction)
Definition: PeiPcdLib.c:829
UINT32 EFIAPI LibPcdGet32(IN UINTN TokenNumber)
Definition: PeiPcdLib.c:186
RETURN_STATUS EFIAPI LibPcdSetEx32S(IN CONST GUID *Guid, IN UINTN TokenNumber, IN UINT32 Value)
Definition: PeiPcdLib.c:668
VOID *EFIAPI LibPcdGetExPtr(IN CONST GUID *Guid, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:383
VOID *EFIAPI LibPcdGetPtr(IN UINTN TokenNumber)
Definition: PeiPcdLib.c:224
RETURN_STATUS EFIAPI LibPcdSet64S(IN UINTN TokenNumber, IN UINT64 Value)
Definition: PeiPcdLib.c:523
UINTN EFIAPI LibPcdGetExSize(IN CONST GUID *Guid, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:434
UINTN EFIAPI LibPcdSetSku(IN UINTN SkuId)
Definition: PeiPcdLib.c:127
EFI_PEI_PCD_PPI * GetPiPcdPpiPointer(VOID)
Definition: PeiPcdLib.c:55
BOOLEAN EFIAPI LibPcdGetBool(IN UINTN TokenNumber)
Definition: PeiPcdLib.c:243
RETURN_STATUS EFIAPI LibPcdSetBoolS(IN UINTN TokenNumber, IN BOOLEAN Value)
Definition: PeiPcdLib.c:584
BOOLEAN EFIAPI LibPcdGetExBool(IN CONST GUID *Guid, IN UINTN TokenNumber)
Definition: PeiPcdLib.c:409
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_GET_PCD_INFO_PPI_GET_INFO GetInfo
Definition: PiPcdInfo.h:68
EFI_GET_PCD_INFO_PPI_GET_SKU GetSku
Definition: PiPcdInfo.h:72
GET_PCD_INFO_PPI_GET_INFO GetInfo
Definition: PcdInfo.h:90
Definition: Base.h:213
Definition: Pcd.h:753