10 #define TEMU_BUS_PCI_H
14 #include "temu-c/Bus/PCIDefines.h"
15 #include "temu-c/Memory/Memory.h"
16 #include "temu-c/Support/Logging.h"
17 #include "temu-c/Support/Objsys.h"
33 } temu_PCIDeviceVTable;
49 void (*
mapPciIo)(temu_Object *Obj,
unsigned Device,
unsigned Bar,
50 uint64_t Addr, uint64_t Len);
52 void (*
mapPciMem)(temu_Object *Obj,
unsigned Device,
unsigned Bar,
53 uint64_t Addr, uint64_t Len);
56 TEMU_IFACE_REFERENCE_TYPE(temu_PCIBus)
57 #define TEMU_PCI_BUS_IFACE_TYPE "temu::PCIBusIface"
64 } temu_PCIBridgeIface;
65 TEMU_IFACE_REFERENCE_TYPE(temu_PCIBridge)
66 #define TEMU_PCI_BRIDGE_IFACE_TYPE "temu::PCIBridgeIface"
71 temu_PCIConfig *(*getPciConfig)(temu_Object *);
74 uint32_t (*readConfig)(temu_Object *Obj, uint32_t offset);
75 uint64_t (*getPciBarSize)(temu_Object *,
unsigned bar);
76 uint64_t (*getPciExpansionROMSize)(temu_Object *);
78 } temu_PCIDeviceIface;
79 TEMU_IFACE_REFERENCE_TYPE(temu_PCIDevice)
80 #define TEMU_PCI_DEVICE_IFACE_TYPE "temu::PCIDeviceIface"
88 temu_pciDeviceRegister(temu_Class *C)
90 temu_addProperty(C,
"pciConfigDeviceVendorID",
91 offsetof(temu_PCIDevice, Conf.DeviceVendorID), teTY_U32,
93 NULL, NULL,
"PCI Device and Vendor ID");
95 temu_addProperty(C,
"pciConfigStatusCommand",
96 offsetof(temu_PCIDevice, Conf.StatusCommand), teTY_U32,
98 NULL, NULL,
"PCI Status and Command Register");
100 temu_addProperty(C,
"pciConfigClassCodeRevID",
101 offsetof(temu_PCIDevice, Conf.ClassCodeRevID), teTY_U32,
103 NULL, NULL,
"PCI Class Code and Revision ID");
106 C,
"pciConfigBistHeaderLatencyCacheLineAndSize",
107 offsetof(temu_PCIDevice, Conf.BISTHeaderTypeLatencyTimerCacheLineSize),
110 NULL, NULL,
"PCI BIST, Header Type, Latency and cache line size");
112 temu_addProperty(C,
"pciConfigBAR", offsetof(temu_PCIDevice, Conf.BAR),
115 NULL, NULL,
"PCI Base Address Registers");
117 temu_addProperty(C,
"pciConfigCardbusCISPointer",
118 offsetof(temu_PCIDevice, Conf.CardbusCISPointer), teTY_U32,
120 NULL, NULL,
"PCI Cardbus CIS Pointer");
122 temu_addProperty(C,
"pciConfigSubsystemVendorID",
123 offsetof(temu_PCIDevice, Conf.SubsystemVendorID), teTY_U32,
125 NULL, NULL,
"PCI Subsystem and Subsystem Vendor ID");
127 temu_addProperty(C,
"pciConfigExpansionROMBaseAddress",
128 offsetof(temu_PCIDevice, Conf.ExpansionROMBaseAddress),
131 NULL, NULL,
"PCI Expansion ROM base address");
133 temu_addProperty(C,
"pciConfigCapabilityPointer",
134 offsetof(temu_PCIDevice, Conf.CapPointer), teTY_U32,
136 NULL, NULL,
"PCI Capability list pointer");
139 C,
"pciConfigMaxLatMinGntIntPinLine",
140 offsetof(temu_PCIDevice, Conf.MaxLatMinGntIntPinLine), teTY_U32,
142 NULL, NULL,
"PCI Max latency, min gnt, int pin and int line");
146 temu_pciSetDeviceId(temu_PCIConfig *C, uint16_t Val)
152 temu_pciSetVendorId(temu_PCIConfig *C, uint16_t Val)
158 temu_pciSetStatus(temu_PCIConfig *C, uint16_t Val)
164 temu_pciSetClassCode(temu_PCIConfig *C, uint32_t Val)
171 temu_pciSetRevId(temu_PCIConfig *C, uint8_t Val)
178 temu_pciSetBist(temu_PCIConfig *C, uint8_t Val)
181 ((uint32_t)Val << 24) |
186 temu_pciSetHeaderType(temu_PCIConfig *C, uint8_t Val)
189 ((uint32_t)Val << 16) |
194 temu_pciSetLatencyTimer(temu_PCIConfig *C, uint8_t Val)
197 ((uint32_t)Val << 8) |
202 temu_pciSetCacheLineSize(temu_PCIConfig *C, uint8_t Val)
205 ((uint32_t)Val << 0) |
210 temu_pciSetInterruptPin(temu_PCIConfig *C, uint8_t Val)
218 temu_pciSetSubsystemId(temu_PCIConfig *C, uint16_t Val)
225 temu_pciSetSubsystemVendorId(temu_PCIConfig *C, uint16_t Val)