TianoCore EDK2 master
Loading...
Searching...
No Matches
S3PciSegmentLib.c
Go to the documentation of this file.
1
11#include <Base.h>
12
13#include <Library/DebugLib.h>
16
25#define PCI_SEGMENT_LIB_ADDRESS_TO_S3_BOOT_SCRIPT_PCI_ADDRESS(Address) \
26 ((((UINT32)(Address) >> 20) & 0xff) << 24) | \
27 ((((UINT32)(Address) >> 15) & 0x1f) << 16) | \
28 ((((UINT32)(Address) >> 12) & 0x07) << 8) | \
29 LShiftU64 ((Address) & 0xfff, 32) // Always put Register in high four bytes.
30
45VOID
48 IN UINT64 Address,
49 IN VOID *Buffer
50 )
51{
52 RETURN_STATUS Status;
53
55 Width,
56 RShiftU64 ((Address), 32) & 0xffff,
58 1,
59 Buffer
60 );
61 ASSERT_RETURN_ERROR (Status);
62}
63
79UINT8
81 IN UINT64 Address,
82 IN UINT8 Value
83 )
84{
86
87 return Value;
88}
89
104UINT8
105EFIAPI
107 IN UINT64 Address
108 )
109{
111}
112
128UINT8
129EFIAPI
131 IN UINT64 Address,
132 IN UINT8 Value
133 )
134{
135 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentWrite8 (Address, Value));
136}
137
156UINT8
157EFIAPI
159 IN UINT64 Address,
160 IN UINT8 OrData
161 )
162{
163 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentOr8 (Address, OrData));
164}
165
183UINT8
184EFIAPI
186 IN UINT64 Address,
187 IN UINT8 AndData
188 )
189{
190 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentAnd8 (Address, AndData));
191}
192
214UINT8
215EFIAPI
217 IN UINT64 Address,
218 IN UINT8 AndData,
219 IN UINT8 OrData
220 )
221{
222 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentAndThenOr8 (Address, AndData, OrData));
223}
224
247UINT8
248EFIAPI
250 IN UINT64 Address,
251 IN UINTN StartBit,
252 IN UINTN EndBit
253 )
254{
255 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldRead8 (Address, StartBit, EndBit));
256}
257
283UINT8
284EFIAPI
286 IN UINT64 Address,
287 IN UINTN StartBit,
288 IN UINTN EndBit,
289 IN UINT8 Value
290 )
291{
292 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldWrite8 (Address, StartBit, EndBit, Value));
293}
294
323UINT8
324EFIAPI
326 IN UINT64 Address,
327 IN UINTN StartBit,
328 IN UINTN EndBit,
329 IN UINT8 OrData
330 )
331{
332 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldOr8 (Address, StartBit, EndBit, OrData));
333}
334
363UINT8
364EFIAPI
366 IN UINT64 Address,
367 IN UINTN StartBit,
368 IN UINTN EndBit,
369 IN UINT8 AndData
370 )
371{
372 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldAnd8 (Address, StartBit, EndBit, AndData));
373}
374
406UINT8
407EFIAPI
409 IN UINT64 Address,
410 IN UINTN StartBit,
411 IN UINTN EndBit,
412 IN UINT8 AndData,
413 IN UINT8 OrData
414 )
415{
416 return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData));
417}
418
434UINT16
436 IN UINT64 Address,
437 IN UINT16 Value
438 )
439{
441
442 return Value;
443}
444
460UINT16
461EFIAPI
463 IN UINT64 Address
464 )
465{
467}
468
485UINT16
486EFIAPI
488 IN UINT64 Address,
489 IN UINT16 Value
490 )
491{
492 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentWrite16 (Address, Value));
493}
494
515UINT16
516EFIAPI
518 IN UINT64 Address,
519 IN UINT16 OrData
520 )
521{
522 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentOr16 (Address, OrData));
523}
524
544UINT16
545EFIAPI
547 IN UINT64 Address,
548 IN UINT16 AndData
549 )
550{
551 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentAnd16 (Address, AndData));
552}
553
576UINT16
577EFIAPI
579 IN UINT64 Address,
580 IN UINT16 AndData,
581 IN UINT16 OrData
582 )
583{
584 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentAndThenOr16 (Address, AndData, OrData));
585}
586
610UINT16
611EFIAPI
613 IN UINT64 Address,
614 IN UINTN StartBit,
615 IN UINTN EndBit
616 )
617{
618 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldRead16 (Address, StartBit, EndBit));
619}
620
647UINT16
648EFIAPI
650 IN UINT64 Address,
651 IN UINTN StartBit,
652 IN UINTN EndBit,
653 IN UINT16 Value
654 )
655{
656 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldWrite16 (Address, StartBit, EndBit, Value));
657}
658
688UINT16
689EFIAPI
691 IN UINT64 Address,
692 IN UINTN StartBit,
693 IN UINTN EndBit,
694 IN UINT16 OrData
695 )
696{
697 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldOr16 (Address, StartBit, EndBit, OrData));
698}
699
729UINT16
730EFIAPI
732 IN UINT64 Address,
733 IN UINTN StartBit,
734 IN UINTN EndBit,
735 IN UINT16 AndData
736 )
737{
738 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldAnd16 (Address, StartBit, EndBit, AndData));
739}
740
772UINT16
773EFIAPI
775 IN UINT64 Address,
776 IN UINTN StartBit,
777 IN UINTN EndBit,
778 IN UINT16 AndData,
779 IN UINT16 OrData
780 )
781{
782 return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData));
783}
784
800UINT32
802 IN UINT64 Address,
803 IN UINT32 Value
804 )
805{
807
808 return Value;
809}
810
826UINT32
827EFIAPI
829 IN UINT64 Address
830 )
831{
833}
834
851UINT32
852EFIAPI
854 IN UINT64 Address,
855 IN UINT32 Value
856 )
857{
858 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentWrite32 (Address, Value));
859}
860
881UINT32
882EFIAPI
884 IN UINT64 Address,
885 IN UINT32 OrData
886 )
887{
888 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentOr32 (Address, OrData));
889}
890
910UINT32
911EFIAPI
913 IN UINT64 Address,
914 IN UINT32 AndData
915 )
916{
917 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentAnd32 (Address, AndData));
918}
919
942UINT32
943EFIAPI
945 IN UINT64 Address,
946 IN UINT32 AndData,
947 IN UINT32 OrData
948 )
949{
950 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentAndThenOr32 (Address, AndData, OrData));
951}
952
976UINT32
977EFIAPI
979 IN UINT64 Address,
980 IN UINTN StartBit,
981 IN UINTN EndBit
982 )
983{
984 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldRead32 (Address, StartBit, EndBit));
985}
986
1013UINT32
1014EFIAPI
1016 IN UINT64 Address,
1017 IN UINTN StartBit,
1018 IN UINTN EndBit,
1019 IN UINT32 Value
1020 )
1021{
1022 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldWrite32 (Address, StartBit, EndBit, Value));
1023}
1024
1054UINT32
1055EFIAPI
1057 IN UINT64 Address,
1058 IN UINTN StartBit,
1059 IN UINTN EndBit,
1060 IN UINT32 OrData
1061 )
1062{
1063 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldOr32 (Address, StartBit, EndBit, OrData));
1064}
1065
1095UINT32
1096EFIAPI
1098 IN UINT64 Address,
1099 IN UINTN StartBit,
1100 IN UINTN EndBit,
1101 IN UINT32 AndData
1102 )
1103{
1104 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldAnd32 (Address, StartBit, EndBit, AndData));
1105}
1106
1138UINT32
1139EFIAPI
1141 IN UINT64 Address,
1142 IN UINTN StartBit,
1143 IN UINTN EndBit,
1144 IN UINT32 AndData,
1145 IN UINT32 OrData
1146 )
1147{
1148 return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData));
1149}
1150
1175UINTN
1176EFIAPI
1178 IN UINT64 StartAddress,
1179 IN UINTN Size,
1180 OUT VOID *Buffer
1181 )
1182{
1183 RETURN_STATUS Status;
1184
1187 RShiftU64 (StartAddress, 32) & 0xffff,
1189 PciSegmentReadBuffer (StartAddress, Size, Buffer),
1190 Buffer
1191 );
1192 ASSERT_RETURN_ERROR (Status);
1193 return Size;
1194}
1195
1221UINTN
1222EFIAPI
1224 IN UINT64 StartAddress,
1225 IN UINTN Size,
1226 IN VOID *Buffer
1227 )
1228{
1229 RETURN_STATUS Status;
1230
1233 RShiftU64 (StartAddress, 32) & 0xffff,
1235 PciSegmentWriteBuffer (StartAddress, Size, Buffer),
1236 Buffer
1237 );
1238 ASSERT_RETURN_ERROR (Status);
1239 return Size;
1240}
UINT64 UINTN
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition: RShiftU64.c:28
RETURN_STATUS EFIAPI S3BootScriptSavePciCfg2Write(IN S3_BOOT_SCRIPT_LIB_WIDTH Width, IN UINT16 Segment, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer)
UINT8 EFIAPI PciSegmentRead8(IN UINT64 Address)
Definition: PciSegmentLib.c:78
UINT32 EFIAPI PciSegmentAnd32(IN UINT64 Address, IN UINT32 AndData)
UINT16 EFIAPI PciSegmentWrite16(IN UINT64 Address, IN UINT16 Value)
UINT16 EFIAPI PciSegmentBitFieldAnd16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
UINT32 EFIAPI PciSegmentWrite32(IN UINT64 Address, IN UINT32 Value)
UINT8 EFIAPI PciSegmentBitFieldOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
UINT16 EFIAPI PciSegmentBitFieldOr16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData)
UINTN EFIAPI PciSegmentReadBuffer(IN UINT64 StartAddress, IN UINTN Size, OUT VOID *Buffer)
UINT8 EFIAPI PciSegmentBitFieldAnd8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData)
UINT16 EFIAPI PciSegmentAnd16(IN UINT64 Address, IN UINT16 AndData)
UINT16 EFIAPI PciSegmentRead16(IN UINT64 Address)
UINT32 EFIAPI PciSegmentBitFieldWrite32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
UINT8 EFIAPI PciSegmentBitFieldWrite8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value)
UINT16 EFIAPI PciSegmentOr16(IN UINT64 Address, IN UINT16 OrData)
UINT32 EFIAPI PciSegmentBitFieldAndThenOr32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData, IN UINT32 OrData)
UINT8 EFIAPI PciSegmentBitFieldRead8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
UINT8 EFIAPI PciSegmentOr8(IN UINT64 Address, IN UINT8 OrData)
UINT16 EFIAPI PciSegmentBitFieldAndThenOr16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData, IN UINT16 OrData)
UINT16 EFIAPI PciSegmentBitFieldRead16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
UINT32 EFIAPI PciSegmentAndThenOr32(IN UINT64 Address, IN UINT32 AndData, IN UINT32 OrData)
UINT32 EFIAPI PciSegmentRead32(IN UINT64 Address)
UINT8 EFIAPI PciSegmentAnd8(IN UINT64 Address, IN UINT8 AndData)
UINT8 EFIAPI PciSegmentBitFieldAndThenOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
UINT32 EFIAPI PciSegmentBitFieldOr32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
UINT16 EFIAPI PciSegmentAndThenOr16(IN UINT64 Address, IN UINT16 AndData, IN UINT16 OrData)
UINT32 EFIAPI PciSegmentBitFieldAnd32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
UINT8 EFIAPI PciSegmentAndThenOr8(IN UINT64 Address, IN UINT8 AndData, IN UINT8 OrData)
UINT16 EFIAPI PciSegmentBitFieldWrite16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
UINT8 EFIAPI PciSegmentWrite8(IN UINT64 Address, IN UINT8 Value)
UINT32 EFIAPI PciSegmentBitFieldRead32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
UINTN EFIAPI PciSegmentWriteBuffer(IN UINT64 StartAddress, IN UINTN Size, IN VOID *Buffer)
UINT32 EFIAPI PciSegmentOr32(IN UINT64 Address, IN UINT32 OrData)
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_RETURN_ERROR(StatusParameter)
Definition: DebugLib.h:493
S3_BOOT_SCRIPT_LIB_WIDTH
@ S3BootScriptWidthUint16
16-bit operation.
@ S3BootScriptWidthUint32
32-bit operation.
@ S3BootScriptWidthUint8
8-bit operation.
UINT8 EFIAPI S3PciSegmentBitFieldRead8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
UINT16 EFIAPI S3PciSegmentAnd16(IN UINT64 Address, IN UINT16 AndData)
UINT8 InternalSavePciSegmentWrite8ValueToBootScript(IN UINT64 Address, IN UINT8 Value)
UINT32 EFIAPI S3PciSegmentRead32(IN UINT64 Address)
UINT32 EFIAPI S3PciSegmentBitFieldWrite32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
UINT8 EFIAPI S3PciSegmentBitFieldAndThenOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
UINT16 EFIAPI S3PciSegmentOr16(IN UINT64 Address, IN UINT16 OrData)
UINT32 InternalSavePciSegmentWrite32ValueToBootScript(IN UINT64 Address, IN UINT32 Value)
UINT16 EFIAPI S3PciSegmentBitFieldOr16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData)
UINT16 EFIAPI S3PciSegmentRead16(IN UINT64 Address)
UINT32 EFIAPI S3PciSegmentOr32(IN UINT64 Address, IN UINT32 OrData)
UINTN EFIAPI S3PciSegmentWriteBuffer(IN UINT64 StartAddress, IN UINTN Size, IN VOID *Buffer)
UINT32 EFIAPI S3PciSegmentBitFieldAndThenOr32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData, IN UINT32 OrData)
UINT32 EFIAPI S3PciSegmentAnd32(IN UINT64 Address, IN UINT32 AndData)
UINT8 EFIAPI S3PciSegmentWrite8(IN UINT64 Address, IN UINT8 Value)
UINTN EFIAPI S3PciSegmentReadBuffer(IN UINT64 StartAddress, IN UINTN Size, OUT VOID *Buffer)
UINT8 EFIAPI S3PciSegmentBitFieldAnd8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData)
UINT32 EFIAPI S3PciSegmentBitFieldRead32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
UINT32 EFIAPI S3PciSegmentAndThenOr32(IN UINT64 Address, IN UINT32 AndData, IN UINT32 OrData)
VOID InternalSavePciSegmentWriteValueToBootScript(IN S3_BOOT_SCRIPT_LIB_WIDTH Width, IN UINT64 Address, IN VOID *Buffer)
UINT16 EFIAPI S3PciSegmentBitFieldAndThenOr16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData, IN UINT16 OrData)
UINT8 EFIAPI S3PciSegmentRead8(IN UINT64 Address)
UINT8 EFIAPI S3PciSegmentOr8(IN UINT64 Address, IN UINT8 OrData)
UINT8 EFIAPI S3PciSegmentBitFieldWrite8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value)
UINT16 EFIAPI S3PciSegmentBitFieldAnd16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
UINT16 EFIAPI S3PciSegmentBitFieldRead16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
UINT16 EFIAPI S3PciSegmentBitFieldWrite16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
UINT16 EFIAPI S3PciSegmentAndThenOr16(IN UINT64 Address, IN UINT16 AndData, IN UINT16 OrData)
UINT16 InternalSavePciSegmentWrite16ValueToBootScript(IN UINT64 Address, IN UINT16 Value)
UINT8 EFIAPI S3PciSegmentAnd8(IN UINT64 Address, IN UINT8 AndData)
UINT32 EFIAPI S3PciSegmentBitFieldOr32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
UINT8 EFIAPI S3PciSegmentAndThenOr8(IN UINT64 Address, IN UINT8 AndData, IN UINT8 OrData)
UINT8 EFIAPI S3PciSegmentBitFieldOr8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
UINT16 EFIAPI S3PciSegmentWrite16(IN UINT64 Address, IN UINT16 Value)
UINT32 EFIAPI S3PciSegmentWrite32(IN UINT64 Address, IN UINT32 Value)
#define PCI_SEGMENT_LIB_ADDRESS_TO_S3_BOOT_SCRIPT_PCI_ADDRESS(Address)
UINT32 EFIAPI S3PciSegmentBitFieldAnd32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)