TianoCore EDK2 master
Loading...
Searching...
No Matches
S3PciLib.c
Go to the documentation of this file.
1
12#include <Base.h>
13
14#include <Library/DebugLib.h>
16#include <Library/PciLib.h>
17#include <Library/S3PciLib.h>
18
19#define PCILIB_TO_COMMON_ADDRESS(Address) \
20 ((((UINTN) ((Address>>20) & 0xff)) << 24) + (((UINTN) ((Address>>15) & 0x1f)) << 16) + (((UINTN) ((Address>>12) & 0x07)) << 8) + ((UINTN) (Address & 0xfff )))
21
36VOID
39 IN UINTN Address,
40 IN VOID *Buffer
41 )
42{
43 RETURN_STATUS Status;
44
46 Width,
47 PCILIB_TO_COMMON_ADDRESS (Address),
48 1,
49 Buffer
50 );
51 ASSERT (Status == RETURN_SUCCESS);
52}
53
69UINT8
71 IN UINTN Address,
72 IN UINT8 Value
73 )
74{
76
77 return Value;
78}
79
96UINT8
97EFIAPI
99 IN UINTN Address
100 )
101{
102 return InternalSavePciWrite8ValueToBootScript (Address, PciRead8 (Address));
103}
104
122UINT8
123EFIAPI
125 IN UINTN Address,
126 IN UINT8 Value
127 )
128{
129 return InternalSavePciWrite8ValueToBootScript (Address, PciWrite8 (Address, Value));
130}
131
152UINT8
153EFIAPI
155 IN UINTN Address,
156 IN UINT8 OrData
157 )
158{
159 return InternalSavePciWrite8ValueToBootScript (Address, PciOr8 (Address, OrData));
160}
161
182UINT8
183EFIAPI
185 IN UINTN Address,
186 IN UINT8 AndData
187 )
188{
189 return InternalSavePciWrite8ValueToBootScript (Address, PciAnd8 (Address, AndData));
190}
191
215UINT8
216EFIAPI
218 IN UINTN Address,
219 IN UINT8 AndData,
220 IN UINT8 OrData
221 )
222{
223 return InternalSavePciWrite8ValueToBootScript (Address, PciAndThenOr8 (Address, AndData, OrData));
224}
225
248UINT8
249EFIAPI
251 IN UINTN Address,
252 IN UINTN StartBit,
253 IN UINTN EndBit
254 )
255{
256 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldRead8 (Address, StartBit, EndBit));
257}
258
284UINT8
285EFIAPI
287 IN UINTN Address,
288 IN UINTN StartBit,
289 IN UINTN EndBit,
290 IN UINT8 Value
291 )
292{
293 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldWrite8 (Address, StartBit, EndBit, Value));
294}
295
324UINT8
325EFIAPI
327 IN UINTN Address,
328 IN UINTN StartBit,
329 IN UINTN EndBit,
330 IN UINT8 OrData
331 )
332{
333 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldOr8 (Address, StartBit, EndBit, OrData));
334}
335
364UINT8
365EFIAPI
367 IN UINTN Address,
368 IN UINTN StartBit,
369 IN UINTN EndBit,
370 IN UINT8 AndData
371 )
372{
373 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldAnd8 (Address, StartBit, EndBit, AndData));
374}
375
407UINT8
408EFIAPI
410 IN UINTN Address,
411 IN UINTN StartBit,
412 IN UINTN EndBit,
413 IN UINT8 AndData,
414 IN UINT8 OrData
415 )
416{
417 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData));
418}
419
435UINT16
437 IN UINTN Address,
438 IN UINT16 Value
439 )
440{
442
443 return Value;
444}
445
463UINT16
464EFIAPI
466 IN UINTN Address
467 )
468{
469 return InternalSavePciWrite16ValueToBootScript (Address, PciRead16 (Address));
470}
471
490UINT16
491EFIAPI
493 IN UINTN Address,
494 IN UINT16 Value
495 )
496{
497 return InternalSavePciWrite16ValueToBootScript (Address, PciWrite16 (Address, Value));
498}
499
521UINT16
522EFIAPI
524 IN UINTN Address,
525 IN UINT16 OrData
526 )
527{
528 return InternalSavePciWrite16ValueToBootScript (Address, PciOr16 (Address, OrData));
529}
530
552UINT16
553EFIAPI
555 IN UINTN Address,
556 IN UINT16 AndData
557 )
558{
559 return InternalSavePciWrite16ValueToBootScript (Address, PciAnd16 (Address, AndData));
560}
561
586UINT16
587EFIAPI
589 IN UINTN Address,
590 IN UINT16 AndData,
591 IN UINT16 OrData
592 )
593{
594 return InternalSavePciWrite16ValueToBootScript (Address, PciAndThenOr16 (Address, AndData, OrData));
595}
596
620UINT16
621EFIAPI
623 IN UINTN Address,
624 IN UINTN StartBit,
625 IN UINTN EndBit
626 )
627{
628 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldRead16 (Address, StartBit, EndBit));
629}
630
657UINT16
658EFIAPI
660 IN UINTN Address,
661 IN UINTN StartBit,
662 IN UINTN EndBit,
663 IN UINT16 Value
664 )
665{
666 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldWrite16 (Address, StartBit, EndBit, Value));
667}
668
698UINT16
699EFIAPI
701 IN UINTN Address,
702 IN UINTN StartBit,
703 IN UINTN EndBit,
704 IN UINT16 OrData
705 )
706{
707 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldOr16 (Address, StartBit, EndBit, OrData));
708}
709
739UINT16
740EFIAPI
742 IN UINTN Address,
743 IN UINTN StartBit,
744 IN UINTN EndBit,
745 IN UINT16 AndData
746 )
747{
748 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldAnd16 (Address, StartBit, EndBit, AndData));
749}
750
783UINT16
784EFIAPI
786 IN UINTN Address,
787 IN UINTN StartBit,
788 IN UINTN EndBit,
789 IN UINT16 AndData,
790 IN UINT16 OrData
791 )
792{
793 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData));
794}
795
811UINT32
813 IN UINTN Address,
814 IN UINT32 Value
815 )
816{
818
819 return Value;
820}
821
839UINT32
840EFIAPI
842 IN UINTN Address
843 )
844{
845 return InternalSavePciWrite32ValueToBootScript (Address, PciRead32 (Address));
846}
847
866UINT32
867EFIAPI
869 IN UINTN Address,
870 IN UINT32 Value
871 )
872{
873 return InternalSavePciWrite32ValueToBootScript (Address, PciWrite32 (Address, Value));
874}
875
897UINT32
898EFIAPI
900 IN UINTN Address,
901 IN UINT32 OrData
902 )
903{
904 return InternalSavePciWrite32ValueToBootScript (Address, PciOr32 (Address, OrData));
905}
906
928UINT32
929EFIAPI
931 IN UINTN Address,
932 IN UINT32 AndData
933 )
934{
935 return InternalSavePciWrite32ValueToBootScript (Address, PciAnd32 (Address, AndData));
936}
937
962UINT32
963EFIAPI
965 IN UINTN Address,
966 IN UINT32 AndData,
967 IN UINT32 OrData
968 )
969{
970 return InternalSavePciWrite32ValueToBootScript (Address, PciAndThenOr32 (Address, AndData, OrData));
971}
972
996UINT32
997EFIAPI
999 IN UINTN Address,
1000 IN UINTN StartBit,
1001 IN UINTN EndBit
1002 )
1003{
1004 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldRead32 (Address, StartBit, EndBit));
1005}
1006
1033UINT32
1034EFIAPI
1036 IN UINTN Address,
1037 IN UINTN StartBit,
1038 IN UINTN EndBit,
1039 IN UINT32 Value
1040 )
1041{
1042 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldWrite32 (Address, StartBit, EndBit, Value));
1043}
1044
1074UINT32
1075EFIAPI
1077 IN UINTN Address,
1078 IN UINTN StartBit,
1079 IN UINTN EndBit,
1080 IN UINT32 OrData
1081 )
1082{
1083 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldOr32 (Address, StartBit, EndBit, OrData));
1084}
1085
1115UINT32
1116EFIAPI
1118 IN UINTN Address,
1119 IN UINTN StartBit,
1120 IN UINTN EndBit,
1121 IN UINT32 AndData
1122 )
1123{
1124 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldAnd32 (Address, StartBit, EndBit, AndData));
1125}
1126
1159UINT32
1160EFIAPI
1162 IN UINTN Address,
1163 IN UINTN StartBit,
1164 IN UINTN EndBit,
1165 IN UINT32 AndData,
1166 IN UINT32 OrData
1167 )
1168{
1169 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData));
1170}
1171
1196UINTN
1197EFIAPI
1199 IN UINTN StartAddress,
1200 IN UINTN Size,
1201 OUT VOID *Buffer
1202 )
1203{
1204 RETURN_STATUS Status;
1205
1208 PCILIB_TO_COMMON_ADDRESS (StartAddress),
1209 PciReadBuffer (StartAddress, Size, Buffer),
1210 Buffer
1211 );
1212 ASSERT (Status == RETURN_SUCCESS);
1213
1214 return Size;
1215}
1216
1242UINTN
1243EFIAPI
1245 IN UINTN StartAddress,
1246 IN UINTN Size,
1247 IN VOID *Buffer
1248 )
1249{
1250 RETURN_STATUS Status;
1251
1254 PCILIB_TO_COMMON_ADDRESS (StartAddress),
1255 PciWriteBuffer (StartAddress, Size, Buffer),
1256 Buffer
1257 );
1258 ASSERT (Status == RETURN_SUCCESS);
1259
1260 return Size;
1261}
UINT64 UINTN
RETURN_STATUS EFIAPI S3BootScriptSavePciCfgWrite(IN S3_BOOT_SCRIPT_LIB_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer)
#define RETURN_SUCCESS
Definition: Base.h:1066
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT16 EFIAPI PciBitFieldOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData)
Definition: PciLib.c:626
UINTN EFIAPI PciWriteBuffer(IN UINTN StartAddress, IN UINTN Size, IN VOID *Buffer)
Definition: PciLib.c:1124
UINT32 EFIAPI PciBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
Definition: PciLib.c:929
UINT32 EFIAPI PciAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
Definition: PciLib.c:860
UINT32 EFIAPI PciBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
Definition: PciLib.c:969
UINT32 EFIAPI PciRead32(IN UINTN Address)
Definition: PciLib.c:739
UINT32 EFIAPI PciOr32(IN UINTN Address, IN UINT32 OrData)
Definition: PciLib.c:796
UINT8 EFIAPI PciBitFieldWrite8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value)
Definition: PciLib.c:246
UINT8 EFIAPI PciRead8(IN UINTN Address)
Definition: PciLib.c:62
UINT8 EFIAPI PciAnd8(IN UINTN Address, IN UINT8 AndData)
Definition: PciLib.c:147
UINT8 EFIAPI PciOr8(IN UINTN Address, IN UINT8 OrData)
Definition: PciLib.c:117
UINT16 EFIAPI PciAnd16(IN UINTN Address, IN UINT16 AndData)
Definition: PciLib.c:484
UINT32 EFIAPI PciWrite32(IN UINTN Address, IN UINT32 Value)
Definition: PciLib.c:765
UINT16 EFIAPI PciOr16(IN UINTN Address, IN UINT16 OrData)
Definition: PciLib.c:453
UINT16 EFIAPI PciBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
Definition: PciLib.c:666
UINT32 EFIAPI PciBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
Definition: PciLib.c:1009
UINT32 EFIAPI PciBitFieldRead32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
Definition: PciLib.c:893
UINT16 EFIAPI PciBitFieldAndThenOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData, IN UINT16 OrData)
Definition: PciLib.c:710
UINT8 EFIAPI PciAndThenOr8(IN UINTN Address, IN UINT8 AndData, IN UINT8 OrData)
Definition: PciLib.c:179
UINT8 EFIAPI PciWrite8(IN UINTN Address, IN UINT8 Value)
Definition: PciLib.c:87
UINT16 EFIAPI PciWrite16(IN UINTN Address, IN UINT16 Value)
Definition: PciLib.c:422
UINT16 EFIAPI PciBitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
Definition: PciLib.c:550
UINT16 EFIAPI PciBitFieldWrite16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
Definition: PciLib.c:586
UINT8 EFIAPI PciBitFieldAnd8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData)
Definition: PciLib.c:324
UINT8 EFIAPI PciBitFieldAndThenOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
Definition: PciLib.c:367
UINT8 EFIAPI PciBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
Definition: PciLib.c:285
UINT32 EFIAPI PciAnd32(IN UINTN Address, IN UINT32 AndData)
Definition: PciLib.c:827
UINT32 EFIAPI PciBitFieldAndThenOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData, IN UINT32 OrData)
Definition: PciLib.c:1053
UINT8 EFIAPI PciBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
Definition: PciLib.c:211
UINT16 EFIAPI PciAndThenOr16(IN UINTN Address, IN UINT16 AndData, IN UINT16 OrData)
Definition: PciLib.c:517
UINTN EFIAPI PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
Definition: PciLib.c:1089
UINT16 EFIAPI PciRead16(IN UINTN Address)
Definition: PciLib.c:396
S3_BOOT_SCRIPT_LIB_WIDTH
@ S3BootScriptWidthUint16
16-bit operation.
@ S3BootScriptWidthUint32
32-bit operation.
@ S3BootScriptWidthUint8
8-bit operation.
UINT32 EFIAPI S3PciBitFieldAndThenOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData, IN UINT32 OrData)
Definition: S3PciLib.c:1161
UINT16 EFIAPI S3PciBitFieldOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData)
Definition: S3PciLib.c:700
UINT16 EFIAPI S3PciOr16(IN UINTN Address, IN UINT16 OrData)
Definition: S3PciLib.c:523
VOID InternalSavePciWriteValueToBootScript(IN S3_BOOT_SCRIPT_LIB_WIDTH Width, IN UINTN Address, IN VOID *Buffer)
Definition: S3PciLib.c:37
UINT16 EFIAPI S3PciWrite16(IN UINTN Address, IN UINT16 Value)
Definition: S3PciLib.c:492
UINT8 EFIAPI S3PciAndThenOr8(IN UINTN Address, IN UINT8 AndData, IN UINT8 OrData)
Definition: S3PciLib.c:217
UINT32 InternalSavePciWrite32ValueToBootScript(IN UINTN Address, IN UINT32 Value)
Definition: S3PciLib.c:812
UINTN EFIAPI S3PciWriteBuffer(IN UINTN StartAddress, IN UINTN Size, IN VOID *Buffer)
Definition: S3PciLib.c:1244
UINT16 InternalSavePciWrite16ValueToBootScript(IN UINTN Address, IN UINT16 Value)
Definition: S3PciLib.c:436
UINT16 EFIAPI S3PciRead16(IN UINTN Address)
Definition: S3PciLib.c:465
UINT8 EFIAPI S3PciWrite8(IN UINTN Address, IN UINT8 Value)
Definition: S3PciLib.c:124
UINT16 EFIAPI S3PciAnd16(IN UINTN Address, IN UINT16 AndData)
Definition: S3PciLib.c:554
UINT16 EFIAPI S3PciBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
Definition: S3PciLib.c:741
UINT16 EFIAPI S3PciBitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
Definition: S3PciLib.c:622
UINT8 InternalSavePciWrite8ValueToBootScript(IN UINTN Address, IN UINT8 Value)
Definition: S3PciLib.c:70
UINT8 EFIAPI S3PciRead8(IN UINTN Address)
Definition: S3PciLib.c:98
UINT8 EFIAPI S3PciOr8(IN UINTN Address, IN UINT8 OrData)
Definition: S3PciLib.c:154
UINT32 EFIAPI S3PciBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
Definition: S3PciLib.c:1117
UINT32 EFIAPI S3PciRead32(IN UINTN Address)
Definition: S3PciLib.c:841
UINT16 EFIAPI S3PciBitFieldWrite16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
Definition: S3PciLib.c:659
UINT8 EFIAPI S3PciBitFieldAnd8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData)
Definition: S3PciLib.c:366
UINT16 EFIAPI S3PciAndThenOr16(IN UINTN Address, IN UINT16 AndData, IN UINT16 OrData)
Definition: S3PciLib.c:588
UINTN EFIAPI S3PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
Definition: S3PciLib.c:1198
UINT32 EFIAPI S3PciBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
Definition: S3PciLib.c:1035
UINT8 EFIAPI S3PciBitFieldWrite8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value)
Definition: S3PciLib.c:286
UINT32 EFIAPI S3PciAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
Definition: S3PciLib.c:964
UINT16 EFIAPI S3PciBitFieldAndThenOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData, IN UINT16 OrData)
Definition: S3PciLib.c:785
UINT32 EFIAPI S3PciAnd32(IN UINTN Address, IN UINT32 AndData)
Definition: S3PciLib.c:930
UINT32 EFIAPI S3PciWrite32(IN UINTN Address, IN UINT32 Value)
Definition: S3PciLib.c:868
UINT8 EFIAPI S3PciBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
Definition: S3PciLib.c:250
UINT32 EFIAPI S3PciBitFieldRead32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
Definition: S3PciLib.c:998
UINT8 EFIAPI S3PciBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
Definition: S3PciLib.c:326
UINT32 EFIAPI S3PciBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
Definition: S3PciLib.c:1076
UINT8 EFIAPI S3PciAnd8(IN UINTN Address, IN UINT8 AndData)
Definition: S3PciLib.c:184
UINT8 EFIAPI S3PciBitFieldAndThenOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
Definition: S3PciLib.c:409
UINT32 EFIAPI S3PciOr32(IN UINTN Address, IN UINT32 OrData)
Definition: S3PciLib.c:899