HyperDbg Debugger
Toggle main menu visibility
Loading...
Searching...
No Matches
Pcie.h
Go to the documentation of this file.
1
12
#pragma once
13
#pragma pack(1)
14
16
// Headers //
18
19
//
20
// TODO
21
// - Add support for domains beyond 0000
22
// - Add ECAM support
23
//
24
// PCIe Base Specification, Rev. 4.0, Version 1.0, Table 7-59: Link Address for Link Type 1
25
// Bus: 0-255 (8 bit)
26
// Device: 0-31 (5 bit)
27
// Function: 0-7 (3 bit)
28
//
29
#define BUS_BIT_WIDTH 8
30
#define DEVICE_BIT_WIDTH 5
31
#define FUNCTION_BIT_WIDTH 3
32
33
//
34
// NOTE
35
// On real-world systems, the number of endpoints will likely not exceed 255.
36
// If increasing DEV_MAX_NUM is necessary, ensure PCI_DEV_MINIMAL[DEV_MAX_NUM] does not result in exceeding MaxSerialPacketSize.
37
//
38
#define DOMAIN_MAX_NUM 0
39
#define BUS_MAX_NUM 255
40
#define DEVICE_MAX_NUM 32
41
#define FUNCTION_MAX_NUM 8
42
#define DEV_MAX_NUM 255
43
#define CAM_CONFIG_SPACE_LENGTH 255
44
49
typedef
struct
_PORTABLE_PCI_COMMON_HEADER
50
{
51
UINT16
VendorId
;
52
UINT16
DeviceId
;
53
UINT16
Command
;
54
UINT16
Status
;
55
UINT8
RevisionId
;
56
UINT8
ClassCode
[3];
57
UINT8
CacheLineSize
;
58
UINT8
PrimaryLatencyTimer
;
59
UINT8
HeaderType
;
60
UINT8
Bist
;
61
}
PORTABLE_PCI_COMMON_HEADER
, *
PPORTABLE_PCI_COMMON_HEADER
;
62
67
typedef
union
_PORTABLE_PCI_DEVICE_HEADER
68
{
69
struct
_PORTABLE_PCI_EP_HEADER
70
{
71
UINT32
Bar
[6];
// Base Address Registers
72
UINT32
CardBusCISPtr
;
// CardBus CIS Pointer
73
UINT16
SubVendorId
;
// Subsystem Vendor ID
74
UINT16
SubSystemId
;
// Subsystem ID
75
UINT32
ROMBar
;
// Expansion ROM Base Address
76
UINT8
CapabilitiesPtr
;
// Capabilities Pointer
77
UINT8
Reserved
[3];
78
UINT32
Reserved1
;
79
UINT8
InterruptLine
;
// Interrupt Line
80
UINT8
InterruptPin
;
// Interrupt Pin
81
UINT8
MinGnt
;
// Min_Gnt
82
UINT8
MaxLat
;
// Max_Lat
83
}
ConfigSpaceEp
;
84
85
struct
_PORTABLE_PCI_BRIDGE_HEADER
86
{
87
UINT32
Bar
[2];
88
UINT8
PrimaryBusNumber
;
89
UINT8
SecondaryBusNumber
;
90
UINT8
SubordinateBusNumber
;
91
UINT8
SecondaryLatencyTimer
;
92
UINT8
IoBase
;
93
UINT8
IoLimit
;
94
UINT16
SecondaryStatus
;
95
UINT16
MemoryBase
;
96
UINT16
MemoryLimit
;
97
UINT16
PrefetchableMemoryBase
;
98
UINT16
PrefetchableMemoryLimit
;
99
UINT32
PrefetchableBaseUpper32b
;
100
UINT32
PrefetchableLimitUpper32b
;
101
UINT16
IoBaseUpper16b
;
102
UINT16
IoLimitUpper16b
;
103
UINT8
CapabilityPtr
;
104
UINT8
Reserved
[3];
105
UINT32
ROMBar
;
106
UINT8
InterruptLine
;
107
UINT8
InterruptPin
;
108
UINT16
BridgeControl
;
109
}
ConfigSpacePtpBridge
;
110
111
// TODO: Add support for HeaderType 0x2 (PCI-to-CardBus bridge)
112
}
PORTABLE_PCI_DEVICE_HEADER
, *
PPORTABLE_PCI_DEVICE_HEADER
;
113
118
typedef
struct
_PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
119
{
120
//
121
// Common header
122
//
123
UINT16
VendorId
;
124
UINT16
DeviceId
;
125
UINT8
ClassCode
[3];
126
}
PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
, *
PPORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
;
127
132
typedef
struct
_PCI_DEV_MINIMAL
133
{
134
UINT8
Bus
:
BUS_BIT_WIDTH
;
135
UINT8
Device
:
DEVICE_BIT_WIDTH
;
136
UINT8
Function
:
FUNCTION_BIT_WIDTH
;
137
PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
ConfigSpace
;
138
}
PCI_DEV_MINIMAL
, *
PPCI_DEV_MINIMAL
;
139
144
typedef
struct
_PCI_DEV_MMIOBAR_INFO
145
{
146
BOOL
Is64Bit
;
147
BOOL
IsEnabled
;
148
UINT64
BarOffsetEnd
;
149
UINT64
BarSize
;
150
}
PCI_DEV_MMIOBAR_INFO
, *
PPCI_DEV_MMIOBAR_INFO
;
151
156
typedef
struct
_PORTABLE_PCI_CONFIG_SPACE_HEADER
157
{
158
PORTABLE_PCI_COMMON_HEADER
CommonHeader
;
159
PORTABLE_PCI_DEVICE_HEADER
DeviceHeader
;
160
}
PORTABLE_PCI_CONFIG_SPACE_HEADER
, *
PPORTABLE_PCI_CONFIG_SPACE_HEADER
;
161
166
typedef
struct
_PCI_DEV
167
{
168
UINT8
Bus
:
BUS_BIT_WIDTH
;
169
UINT8
Device
:
DEVICE_BIT_WIDTH
;
170
UINT8
Function
:
FUNCTION_BIT_WIDTH
;
171
PORTABLE_PCI_CONFIG_SPACE_HEADER
ConfigSpace
;
172
BYTE
ConfigSpaceAdditional
[
CAM_CONFIG_SPACE_LENGTH
-
sizeof
(
PORTABLE_PCI_CONFIG_SPACE_HEADER
)];
173
PCI_DEV_MMIOBAR_INFO
MmioBarInfo
[6];
174
}
PCI_DEV
, *
PPCI_DEV
;
175
176
#pragma pack()
BOOL
int BOOL
Definition
BasicTypes.h:25
UINT16
unsigned short UINT16
Definition
BasicTypes.h:53
BYTE
unsigned char BYTE
Definition
BasicTypes.h:40
UINT8
unsigned char UINT8
Definition
BasicTypes.h:52
UINT32
unsigned int UINT32
Definition
BasicTypes.h:54
PCI_DEV_MMIOBAR_INFO
struct _PCI_DEV_MMIOBAR_INFO PCI_DEV_MMIOBAR_INFO
PCI Device MMIO BAR Metadata.
PPCI_DEV
struct _PCI_DEV * PPCI_DEV
PCI_DEV_MINIMAL
struct _PCI_DEV_MINIMAL PCI_DEV_MINIMAL
PCI Device Minimal Data Structure for !pcitree.
PPCI_DEV_MINIMAL
struct _PCI_DEV_MINIMAL * PPCI_DEV_MINIMAL
PORTABLE_PCI_COMMON_HEADER
struct _PORTABLE_PCI_COMMON_HEADER PORTABLE_PCI_COMMON_HEADER
PCI Common Header.
PPORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
struct _PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL * PPORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
PPORTABLE_PCI_CONFIG_SPACE_HEADER
struct _PORTABLE_PCI_CONFIG_SPACE_HEADER * PPORTABLE_PCI_CONFIG_SPACE_HEADER
PORTABLE_PCI_CONFIG_SPACE_HEADER
struct _PORTABLE_PCI_CONFIG_SPACE_HEADER PORTABLE_PCI_CONFIG_SPACE_HEADER
PCI Configuration Space Header.
PORTABLE_PCI_DEVICE_HEADER
union _PORTABLE_PCI_DEVICE_HEADER PORTABLE_PCI_DEVICE_HEADER
PCI Device Header.
PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
struct _PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
PCI Configuration Space Minimal Header for !pcitree.
PPCI_DEV_MMIOBAR_INFO
struct _PCI_DEV_MMIOBAR_INFO * PPCI_DEV_MMIOBAR_INFO
PPORTABLE_PCI_COMMON_HEADER
struct _PORTABLE_PCI_COMMON_HEADER * PPORTABLE_PCI_COMMON_HEADER
PPORTABLE_PCI_DEVICE_HEADER
union _PORTABLE_PCI_DEVICE_HEADER * PPORTABLE_PCI_DEVICE_HEADER
PCI_DEV
struct _PCI_DEV PCI_DEV
PCI Device Data Structure.
BUS_BIT_WIDTH
#define BUS_BIT_WIDTH
Definition
Pcie.h:29
PCI_DEV_MMIOBAR_INFO
struct _PCI_DEV_MMIOBAR_INFO PCI_DEV_MMIOBAR_INFO
PCI Device MMIO BAR Metadata.
DEVICE_BIT_WIDTH
#define DEVICE_BIT_WIDTH
Definition
Pcie.h:30
PORTABLE_PCI_COMMON_HEADER
struct _PORTABLE_PCI_COMMON_HEADER PORTABLE_PCI_COMMON_HEADER
PCI Common Header.
PORTABLE_PCI_CONFIG_SPACE_HEADER
struct _PORTABLE_PCI_CONFIG_SPACE_HEADER PORTABLE_PCI_CONFIG_SPACE_HEADER
PCI Configuration Space Header.
PORTABLE_PCI_DEVICE_HEADER
union _PORTABLE_PCI_DEVICE_HEADER PORTABLE_PCI_DEVICE_HEADER
PCI Device Header.
PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
struct _PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
PCI Configuration Space Minimal Header for !pcitree.
FUNCTION_BIT_WIDTH
#define FUNCTION_BIT_WIDTH
Definition
Pcie.h:31
CAM_CONFIG_SPACE_LENGTH
#define CAM_CONFIG_SPACE_LENGTH
Definition
Pcie.h:43
_PCI_DEV_MINIMAL
PCI Device Minimal Data Structure for !pcitree.
Definition
Pcie.h:133
_PCI_DEV_MINIMAL::ConfigSpace
PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL ConfigSpace
Definition
Pcie.h:137
_PCI_DEV_MINIMAL::Bus
UINT8 Bus
Definition
Pcie.h:134
_PCI_DEV_MINIMAL::Function
UINT8 Function
Definition
Pcie.h:136
_PCI_DEV_MINIMAL::Device
UINT8 Device
Definition
Pcie.h:135
_PCI_DEV_MMIOBAR_INFO
PCI Device MMIO BAR Metadata.
Definition
Pcie.h:145
_PCI_DEV_MMIOBAR_INFO::IsEnabled
BOOL IsEnabled
Definition
Pcie.h:147
_PCI_DEV_MMIOBAR_INFO::Is64Bit
BOOL Is64Bit
Definition
Pcie.h:146
_PCI_DEV_MMIOBAR_INFO::BarSize
UINT64 BarSize
Definition
Pcie.h:149
_PCI_DEV_MMIOBAR_INFO::BarOffsetEnd
UINT64 BarOffsetEnd
Definition
Pcie.h:148
_PCI_DEV
PCI Device Data Structure.
Definition
Pcie.h:167
_PCI_DEV::Device
UINT8 Device
Definition
Pcie.h:169
_PCI_DEV::ConfigSpaceAdditional
BYTE ConfigSpaceAdditional[CAM_CONFIG_SPACE_LENGTH - sizeof(PORTABLE_PCI_CONFIG_SPACE_HEADER)]
Definition
Pcie.h:172
_PCI_DEV::Bus
UINT8 Bus
Definition
Pcie.h:168
_PCI_DEV::Function
UINT8 Function
Definition
Pcie.h:170
_PCI_DEV::MmioBarInfo
PCI_DEV_MMIOBAR_INFO MmioBarInfo[6]
Definition
Pcie.h:173
_PCI_DEV::ConfigSpace
PORTABLE_PCI_CONFIG_SPACE_HEADER ConfigSpace
Definition
Pcie.h:171
_PORTABLE_PCI_COMMON_HEADER
PCI Common Header.
Definition
Pcie.h:50
_PORTABLE_PCI_COMMON_HEADER::Bist
UINT8 Bist
Definition
Pcie.h:60
_PORTABLE_PCI_COMMON_HEADER::ClassCode
UINT8 ClassCode[3]
Definition
Pcie.h:56
_PORTABLE_PCI_COMMON_HEADER::RevisionId
UINT8 RevisionId
Definition
Pcie.h:55
_PORTABLE_PCI_COMMON_HEADER::Command
UINT16 Command
Definition
Pcie.h:53
_PORTABLE_PCI_COMMON_HEADER::CacheLineSize
UINT8 CacheLineSize
Definition
Pcie.h:57
_PORTABLE_PCI_COMMON_HEADER::VendorId
UINT16 VendorId
Definition
Pcie.h:51
_PORTABLE_PCI_COMMON_HEADER::DeviceId
UINT16 DeviceId
Definition
Pcie.h:52
_PORTABLE_PCI_COMMON_HEADER::HeaderType
UINT8 HeaderType
Definition
Pcie.h:59
_PORTABLE_PCI_COMMON_HEADER::Status
UINT16 Status
Definition
Pcie.h:54
_PORTABLE_PCI_COMMON_HEADER::PrimaryLatencyTimer
UINT8 PrimaryLatencyTimer
Definition
Pcie.h:58
_PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL
PCI Configuration Space Minimal Header for !pcitree.
Definition
Pcie.h:119
_PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL::ClassCode
UINT8 ClassCode[3]
Definition
Pcie.h:125
_PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL::VendorId
UINT16 VendorId
Definition
Pcie.h:123
_PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL::DeviceId
UINT16 DeviceId
Definition
Pcie.h:124
_PORTABLE_PCI_CONFIG_SPACE_HEADER
PCI Configuration Space Header.
Definition
Pcie.h:157
_PORTABLE_PCI_CONFIG_SPACE_HEADER::CommonHeader
PORTABLE_PCI_COMMON_HEADER CommonHeader
Definition
Pcie.h:158
_PORTABLE_PCI_CONFIG_SPACE_HEADER::DeviceHeader
PORTABLE_PCI_DEVICE_HEADER DeviceHeader
Definition
Pcie.h:159
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER
Definition
Pcie.h:86
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::InterruptPin
UINT8 InterruptPin
Definition
Pcie.h:107
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::PrefetchableMemoryLimit
UINT16 PrefetchableMemoryLimit
Definition
Pcie.h:98
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::IoLimit
UINT8 IoLimit
Definition
Pcie.h:93
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::IoLimitUpper16b
UINT16 IoLimitUpper16b
Definition
Pcie.h:102
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::CapabilityPtr
UINT8 CapabilityPtr
Definition
Pcie.h:103
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::IoBase
UINT8 IoBase
Definition
Pcie.h:92
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::PrefetchableLimitUpper32b
UINT32 PrefetchableLimitUpper32b
Definition
Pcie.h:100
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::InterruptLine
UINT8 InterruptLine
Definition
Pcie.h:106
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::MemoryBase
UINT16 MemoryBase
Definition
Pcie.h:95
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::SecondaryLatencyTimer
UINT8 SecondaryLatencyTimer
Definition
Pcie.h:91
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::PrimaryBusNumber
UINT8 PrimaryBusNumber
Definition
Pcie.h:88
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::PrefetchableMemoryBase
UINT16 PrefetchableMemoryBase
Definition
Pcie.h:97
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::PrefetchableBaseUpper32b
UINT32 PrefetchableBaseUpper32b
Definition
Pcie.h:99
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::MemoryLimit
UINT16 MemoryLimit
Definition
Pcie.h:96
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::Bar
UINT32 Bar[2]
Definition
Pcie.h:87
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::SecondaryStatus
UINT16 SecondaryStatus
Definition
Pcie.h:94
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::SubordinateBusNumber
UINT8 SubordinateBusNumber
Definition
Pcie.h:90
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::Reserved
UINT8 Reserved[3]
Definition
Pcie.h:104
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::IoBaseUpper16b
UINT16 IoBaseUpper16b
Definition
Pcie.h:101
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::ROMBar
UINT32 ROMBar
Definition
Pcie.h:105
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::SecondaryBusNumber
UINT8 SecondaryBusNumber
Definition
Pcie.h:89
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER::BridgeControl
UINT16 BridgeControl
Definition
Pcie.h:108
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER
Definition
Pcie.h:70
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::MinGnt
UINT8 MinGnt
Definition
Pcie.h:81
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::InterruptPin
UINT8 InterruptPin
Definition
Pcie.h:80
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::Bar
UINT32 Bar[6]
Definition
Pcie.h:71
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::InterruptLine
UINT8 InterruptLine
Definition
Pcie.h:79
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::CardBusCISPtr
UINT32 CardBusCISPtr
Definition
Pcie.h:72
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::CapabilitiesPtr
UINT8 CapabilitiesPtr
Definition
Pcie.h:76
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::SubSystemId
UINT16 SubSystemId
Definition
Pcie.h:74
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::Reserved1
UINT32 Reserved1
Definition
Pcie.h:78
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::SubVendorId
UINT16 SubVendorId
Definition
Pcie.h:73
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::Reserved
UINT8 Reserved[3]
Definition
Pcie.h:77
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::MaxLat
UINT8 MaxLat
Definition
Pcie.h:82
_PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER::ROMBar
UINT32 ROMBar
Definition
Pcie.h:75
_PORTABLE_PCI_DEVICE_HEADER
PCI Device Header.
Definition
Pcie.h:68
_PORTABLE_PCI_DEVICE_HEADER::ConfigSpaceEp
struct _PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER ConfigSpaceEp
_PORTABLE_PCI_DEVICE_HEADER::ConfigSpacePtpBridge
struct _PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER ConfigSpacePtpBridge
hyperdbg
include
SDK
headers
Pcie.h
Generated by
1.17.0