42#include "debug/VIOIface.hh"
44#include "params/PciVirtIO.hh"
62 vio.registerKickCallback([
this]() {
kick(); });
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));
93 pkt->
setLE<uint32_t>(
vio.deviceFeatures);
97 DPRINTF(VIOIface,
" GUEST_FEATURES request\n");
98 assert(size ==
sizeof(uint32_t));
99 pkt->
setLE<uint32_t>(
vio.getGuestFeatures());
103 DPRINTF(VIOIface,
" QUEUE_ADDRESS request\n");
104 assert(size ==
sizeof(uint32_t));
105 pkt->
setLE<uint32_t>(
vio.getQueueAddress());
109 DPRINTF(VIOIface,
" QUEUE_SIZE request\n");
110 assert(size ==
sizeof(uint16_t));
111 pkt->
setLE<uint16_t>(
vio.getQueueSize());
115 DPRINTF(VIOIface,
" QUEUE_SELECT\n");
116 assert(size ==
sizeof(uint16_t));
117 pkt->
setLE<uint16_t>(
vio.getQueueSelect());
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));
129 pkt->
setLE<uint8_t>(
vio.getDeviceStatus());
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));
178 vio.setGuestFeatures(pkt->
getLE<uint32_t>());
182 DPRINTF(VIOIface,
" WRITE QUEUE_ADDRESS\n");
183 assert(size ==
sizeof(uint32_t));
184 vio.setQueueAddress(pkt->
getLE<uint32_t>());
188 panic(
"Guest tried to write queue size.");
192 DPRINTF(VIOIface,
" WRITE QUEUE_SELECT\n");
193 assert(size ==
sizeof(uint16_t));
194 vio.setQueueSelect(pkt->
getLE<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");
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.
bool getBAR(Addr addr, int &num, Addr &offs)
Which base address register (if any) maps the given address?
std::vector< PciBar * > BARs
PCIConfigType0 & config()
PciEndpoint(const PciEndpointParams ¶ms)
Constructor for PCI Dev.
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
constexpr uint64_t alignToPowerOfTwo(uint64_t val)
Align to the next highest power of two.
#define panic(...)
This implements a cprintf based panic() function.
const Params & params() const
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.