41#include "debug/VirtIOMMIO.hh"
44#include "params/RiscvMmioVirtIO.hh"
57 vio.registerKickCallback([
this]() {
kick(); });
68 const unsigned size(pkt->
getSize());
70 DPRINTF(VirtIOMMIO,
"Reading %u bytes @ 0x%x:\n", size,
offset);
77 panic_if(size != 4,
"Unexpected read size: %u\n", size);
80 DPRINTF(VirtIOMMIO,
" value: 0x%x\n", value);
82 pkt->
setLE<uint32_t>(value);
106 return vio.deviceFeatures;
116 return vio.getGuestFeatures();
127 return vio.getQueueSelect();
130 return vio.getQueueSize();
134 return vio.getQueueSize();
141 return vio.getQueueAddress();
147 return vio.getDeviceStatus();
152 warn(
"Guest is trying to read to write-only register 0x%\n",
165 const unsigned size(pkt->
getSize());
167 DPRINTF(VirtIOMMIO,
"Writing %u bytes @ 0x%x:\n", size,
offset);
175 panic_if(size != 4,
"Unexpected write size @ 0x%x: %u\n",
offset, size);
176 DPRINTF(VirtIOMMIO,
" value: 0x%x\n", pkt->
getLE<uint32_t>());
192 vio.setGuestFeatures(value);
193 }
else if (value != 0) {
194 warn(
"Setting unimplemented guest features register %u: %u\n",
206 "Unhandled VirtIO page size: %u", value);
211 vio.setQueueSelect(value);
216 warn_once(
"Ignoring queue resize hint. Requested size: %u\n", value);
223 "Unhandled VirtIO alignment size: %u", value);
227 vio.setQueueAddress(value);
239 panic_if(value > 0xff,
"Unexpected status: 0x%x\n", value);
240 vio.setDeviceStatus(value);
251 warn(
"Guest is trying to write to read-only register 0x%\n",
263 DPRINTF(VirtIOMMIO,
"kick(): Sending interrupt...\n");
Addr pioAddr
Address that the device listens to.
void setLE(T v)
Set the value in the data pointer to v as little endian.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
PlicIntDevice(const Params ¶ms)
const Params & params() const
MmioVirtIO(const RiscvMmioVirtIOParams ¶ms)
@ OFF_GUEST_FEATURES_SELECT
@ OFF_HOST_FEATURES_SELECT
static const uint32_t MAGIC
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const uint32_t VERSION
uint32_t guestFeaturesSelect
uint32_t hostFeaturesSelect
static const uint32_t VENDOR_ID
void setInterrupts(uint32_t value)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr ALIGN_SIZE
#define panic(...)
This implements a cprintf based panic() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Copyright (c) 2024 Arm Limited All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.