43 #include "debug/VIOIface.hh"
45 #include "params/PciVirtIO.hh"
48 :
PciDevice(params), queueNotify(0), interruptDeliveryPending(false),
49 vio(*params->vio), callbackKick(this)
74 panic(
"Invalid PCI memory access to unmapped memory.\n");
77 DPRINTF(VIOIface,
"Reading offset 0x%x [len: %i]\n", offset,
size);
89 DPRINTF(VIOIface,
" DEVICE_FEATURES request\n");
90 assert(
size ==
sizeof(uint32_t));
95 DPRINTF(VIOIface,
" GUEST_FEATURES request\n");
96 assert(
size ==
sizeof(uint32_t));
101 DPRINTF(VIOIface,
" QUEUE_ADDRESS request\n");
102 assert(
size ==
sizeof(uint32_t));
107 DPRINTF(VIOIface,
" QUEUE_SIZE request\n");
108 assert(
size ==
sizeof(uint16_t));
113 DPRINTF(VIOIface,
" QUEUE_SELECT\n");
114 assert(
size ==
sizeof(uint16_t));
119 DPRINTF(VIOIface,
" QUEUE_NOTIFY request\n");
120 assert(
size ==
sizeof(uint16_t));
125 DPRINTF(VIOIface,
" DEVICE_STATUS request\n");
126 assert(
size ==
sizeof(uint8_t));
131 DPRINTF(VIOIface,
" ISR_STATUS\n");
132 assert(
size ==
sizeof(uint8_t));
138 pkt->
set<uint8_t>(isr_status);
142 panic(
"Unhandled read offset (0x%x)\n", offset);
155 panic(
"Invalid PCI memory access to unmapped memory.\n");
158 DPRINTF(VIOIface,
"Writing offset 0x%x [len: %i]\n", offset,
size);
170 warn(
"Guest tried to write device features.");
174 DPRINTF(VIOIface,
" WRITE GUEST_FEATURES request\n");
175 assert(
size ==
sizeof(uint32_t));
180 DPRINTF(VIOIface,
" WRITE QUEUE_ADDRESS\n");
181 assert(
size ==
sizeof(uint32_t));
186 panic(
"Guest tried to write queue size.");
190 DPRINTF(VIOIface,
" WRITE QUEUE_SELECT\n");
191 assert(
size ==
sizeof(uint16_t));
196 DPRINTF(VIOIface,
" WRITE QUEUE_NOTIFY\n");
197 assert(
size ==
sizeof(uint16_t));
203 assert(
size ==
sizeof(uint8_t));
205 DPRINTF(VIOIface,
"VirtIO set status: 0x%x\n", status);
210 warn(
"Guest tried to write ISR status.");
214 panic(
"Unhandled read offset (0x%x)\n", offset);
223 DPRINTF(VIOIface,
"kick(): Sending interrupt...\n");
229 PciVirtIOParams::create()
uint64_t alignToPowerOfTwo(uint64_t val)
Align to the next highest power of two.
void set(T v, ByteOrder endian)
Set the value in the data pointer to v using the specified endianness.
PCI device, base implementation is only config space.
void setQueueSelect(QueueID idx)
Change currently active queue.
static const Addr OFF_DEVICE_FEATURES
Offsets into VirtIO header (BAR0 relative).
DeviceStatus getDeviceStatus() const
Retrieve the device status.
void setGuestFeatures(FeatureBits features)
Set feature bits accepted by the guest driver.
MakeCallback< PciVirtIO,&PciVirtIO::kick > callbackKick
const DeviceId deviceId
Device ID (sometimes known as subsystem ID)
void setDeviceStatus(DeviceStatus status)
Update device status and optionally reset device.
T get(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness.
uint16_t getQueueSize() const
Get the size (descriptors) of the currently active queue.
static const Addr OFF_QUEUE_ADDRESS
QueueID getQueueSelect() const
Get the currently active queue.
uint64_t Tick
Tick count type.
bool interruptDeliveryPending
virtual void writeConfig(PacketPtr pkt, Addr cfgOffset)
Write to the configuration space of a device.
Tick write(PacketPtr pkt)
Pure virtual function that the device must implement.
int getBAR(Addr addr)
Which base address register (if any) maps the given address?
Tick read(PacketPtr pkt)
Pure virtual function that the device must implement.
void onNotify(QueueID index)
Driver is requesting service.
virtual void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
static const Addr BAR0_SIZE_BASE
uint32_t getQueueAddress() const
Get the host physical address of the currently active queue.
static const int NumArgumentRegs M5_VAR_USED
static const Addr OFF_GUEST_FEATURES
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
static const Addr OFF_DEVICE_STATUS
static const Addr OFF_QUEUE_NOTIFY
const FeatureBits deviceFeatures
Feature set offered by the device.
void setQueueAddress(uint32_t address)
Change the host physical address of the currently active queue.
PciVirtIO(const Params *params)
static const Addr OFF_QUEUE_SELECT
static const Addr OFF_VIO_DEVICE
VirtIODeviceBase::QueueID queueNotify
void registerKickCallback(Callback *c)
Register a callback to kick the guest through the transport interface.
PCIConfig config
The current config space.
FeatureBits getGuestFeatures() const
Get features accepted by the guest driver.
static const Addr OFF_ISR_STATUS
static const Addr OFF_QUEUE_SIZE
uint32_t BARSize[6]
The size of the BARs.
const size_t configSize
Size of the device's configuration space.