40 #include "debug/VIOIface.hh" 43 #include "params/MmioVirtIO.hh" 47 hostFeaturesSelect(0), guestFeaturesSelect(0), pageSize(0),
49 callbackKick(this), vio(*params->vio),
50 interrupt(params->interrupt->get())
65 const unsigned size(pkt->
getSize());
67 DPRINTF(VIOIface,
"Reading %u bytes @ 0x%x:\n", size, offset);
75 panic_if(size != 4,
"Unexpected read size: %u\n", size);
77 const uint32_t value =
read(offset);
78 DPRINTF(VIOIface,
" value: 0x%x\n", value);
80 pkt->
setLE<uint32_t>(value);
150 warn(
"Guest is trying to read to write-only register 0x%\n",
155 panic(
"Unhandled read offset (0x%x)\n", offset);
163 const unsigned size(pkt->
getSize());
165 DPRINTF(VIOIface,
"Writing %u bytes @ 0x%x:\n", size, offset);
173 panic_if(size != 4,
"Unexpected write size @ 0x%x: %u\n", offset, size);
174 DPRINTF(VIOIface,
" value: 0x%x\n", pkt->
getLE<uint32_t>());
191 }
else if (value != 0) {
192 warn(
"Setting unimplemented guest features register %u: %u\n",
204 "Unhandled VirtIO page size: %u", value);
214 warn_once(
"Ignoring queue resize hint. Requested size: %u\n", value);
221 "Unhandled VirtIO alignment size: %u", value);
237 panic_if(value > 0xff,
"Unexpected status: 0x%x\n", value);
249 warn(
"Guest is trying to write to read-only register 0x%\n",
254 panic(
"Unhandled read offset (0x%x)\n", offset);
261 DPRINTF(VIOIface,
"kick(): Sending interrupt...\n");
280 MmioVirtIOParams::create()
#define panic(...)
This implements a cprintf based panic() function.
static const uint32_t MAGIC
static const uint32_t VERSION
uint16_t getQueueSize() const
Get the size (descriptors) of the currently active queue.
void setQueueSelect(QueueID idx)
Change currently active queue.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr ALIGN_SIZE
ArmInterruptPin *const interrupt
virtual void clear()=0
Clear a signalled interrupt.
void setGuestFeatures(FeatureBits features)
Set feature bits accepted by the guest driver.
const DeviceId deviceId
Device ID (sometimes known as subsystem ID)
MakeCallback< MmioVirtIO, &MmioVirtIO::kick > callbackKick
void setDeviceStatus(DeviceStatus status)
Update device status and optionally reset device.
void setLE(T v)
Set the value in the data pointer to v as little endian.
uint64_t Tick
Tick count type.
uint32_t guestFeaturesSelect
uint32_t hostFeaturesSelect
virtual void writeConfig(PacketPtr pkt, Addr cfgOffset)
Write to the configuration space of a device.
MmioVirtIO(const MmioVirtIOParams *params)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Tick read(PacketPtr pkt) override
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.
DeviceStatus getDeviceStatus() const
Retrieve the device status.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
FeatureBits getGuestFeatures() const
Get features accepted by the guest driver.
Base class for ARM GIC implementations.
virtual void raise()=0
Signal an interrupt.
const FeatureBits deviceFeatures
Feature set offered by the device.
void setInterrupts(uint32_t value)
void setQueueAddress(uint32_t address)
Change the host physical address of the currently active queue.
uint32_t getQueueAddress() const
Get the host physical address of the currently active queue.
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
void registerKickCallback(Callback *c)
Register a callback to kick the guest through the transport interface.
QueueID getQueueSelect() const
Get the currently active queue.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Addr pioAddr
Address that the device listens to.
static const uint32_t VENDOR_ID