42#include "debug/VIOIface.hh"
44#include "params/PciVirtIO.hh"
50 :
PciDevice(params), queueNotify(0), interruptDeliveryPending(false),
72 [[maybe_unused]]
const unsigned size(pkt->
getSize());
76 panic(
"Invalid PCI memory access to unmapped memory.\n");
79 DPRINTF(VIOIface,
"Reading offset 0x%x [len: %i]\n",
offset, size);
91 DPRINTF(VIOIface,
" DEVICE_FEATURES request\n");
92 assert(size ==
sizeof(uint32_t));
97 DPRINTF(VIOIface,
" GUEST_FEATURES request\n");
98 assert(size ==
sizeof(uint32_t));
103 DPRINTF(VIOIface,
" QUEUE_ADDRESS request\n");
104 assert(size ==
sizeof(uint32_t));
109 DPRINTF(VIOIface,
" QUEUE_SIZE request\n");
110 assert(size ==
sizeof(uint16_t));
115 DPRINTF(VIOIface,
" QUEUE_SELECT\n");
116 assert(size ==
sizeof(uint16_t));
121 DPRINTF(VIOIface,
" QUEUE_NOTIFY request\n");
122 assert(size ==
sizeof(uint16_t));
127 DPRINTF(VIOIface,
" DEVICE_STATUS request\n");
128 assert(size ==
sizeof(uint8_t));
133 DPRINTF(VIOIface,
" ISR_STATUS\n");
134 assert(size ==
sizeof(uint8_t));
140 pkt->
setLE<uint8_t>(isr_status);
153 [[maybe_unused]]
const unsigned size(pkt->
getSize());
157 panic(
"Invalid PCI memory access to unmapped memory.\n");
160 DPRINTF(VIOIface,
"Writing offset 0x%x [len: %i]\n",
offset, size);
172 warn(
"Guest tried to write device features.");
176 DPRINTF(VIOIface,
" WRITE GUEST_FEATURES request\n");
177 assert(size ==
sizeof(uint32_t));
182 DPRINTF(VIOIface,
" WRITE QUEUE_ADDRESS\n");
183 assert(size ==
sizeof(uint32_t));
188 panic(
"Guest tried to write queue size.");
192 DPRINTF(VIOIface,
" WRITE QUEUE_SELECT\n");
193 assert(size ==
sizeof(uint16_t));
198 DPRINTF(VIOIface,
" WRITE QUEUE_NOTIFY\n");
199 assert(size ==
sizeof(uint16_t));
205 assert(size ==
sizeof(uint8_t));
212 warn(
"Guest tried to write ISR status.");
225 DPRINTF(VIOIface,
"kick(): Sending interrupt...\n");
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
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.
PCI device, base implementation is only config space.
PCIConfig config
The current config space.
bool getBAR(Addr addr, int &num, Addr &offs)
Which base address register (if any) maps the given address?
std::array< PciBar *, 6 > BARs
static const Addr OFF_GUEST_FEATURES
Tick read(PacketPtr pkt)
Pure virtual function that the device must implement.
Tick write(PacketPtr pkt)
Pure virtual function that the device must implement.
static const Addr OFF_DEVICE_FEATURES
Offsets into VirtIO header (BAR0 relative).
static const Addr OFF_QUEUE_SELECT
static const Addr OFF_QUEUE_NOTIFY
static const Addr OFF_QUEUE_ADDRESS
PciVirtIO(const Params ¶ms)
static const Addr OFF_VIO_DEVICE
static const Addr BAR0_SIZE_BASE
bool interruptDeliveryPending
static const Addr OFF_QUEUE_SIZE
static const Addr OFF_DEVICE_STATUS
static const Addr OFF_ISR_STATUS
VirtIODeviceBase::QueueID queueNotify
void setDeviceStatus(DeviceStatus status)
Update device status and optionally reset device.
const size_t configSize
Size of the device's configuration space.
virtual void writeConfig(PacketPtr pkt, Addr cfgOffset)
Write to the configuration space of a device.
FeatureBits getGuestFeatures() const
Get features accepted by the guest driver.
QueueID getQueueSelect() const
Get the currently active queue.
DeviceStatus getDeviceStatus() const
Retrieve the device status.
uint32_t getQueueAddress() const
Get the host physical address of the currently active queue.
const FeatureBits deviceFeatures
Feature set offered by the device.
void onNotify(QueueID index)
Driver is requesting service.
void setQueueSelect(QueueID idx)
Change currently active queue.
uint16_t getQueueSize() const
Get the size (descriptors) of the currently active queue.
void registerKickCallback(const std::function< void()> &callback)
Register a callback to kick the guest through the transport interface.
virtual void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
void setQueueAddress(uint32_t address)
Change the host physical address of the currently active queue.
const DeviceId deviceId
Device ID (sometimes known as subsystem ID)
void setGuestFeatures(FeatureBits features)
Set feature bits accepted by the guest driver.
constexpr uint64_t alignToPowerOfTwo(uint64_t val)
Align to the next highest power of two.
#define panic(...)
This implements a cprintf based panic() function.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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.