40#include "debug/VIOBlock.hh"
41#include "params/VirtIOBlock.hh"
50 params.queueSize, *this),
74 size_t off_data,
size_t size)
77 uint64_t sector(req.
sector);
79 DPRINTF(VIOBlock,
"Read request starting @ sector %i (size: %i)\n",
83 panic(
"Unexpected request/sector size relationship\n");
87 warn(
"Failed to read sector %i\n", sector);
100 size_t off_data,
size_t size)
103 uint64_t sector(req.
sector);
105 DPRINTF(VIOBlock,
"Write request starting @ sector %i (size: %i)\n",
109 panic(
"Unexpected request/sector size relationship\n");
116 warn(
"Failed to write sector %i\n", sector);
129 DPRINTF(VIOBlock,
"Got input data descriptor (len: %i)\n",
136 desc->
chainRead(0, (uint8_t *)&req,
sizeof(req));
158 warn(
"Unsupported IO request: %i\n", req.
type);
virtual std::streampos write(const uint8_t *data, std::streampos offset)=0
virtual std::streampos size() const =0
virtual std::streampos read(uint8_t *data, std::streampos offset) const =0
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
VirtIO descriptor (chain) wrapper.
size_t size() const
Retrieve the size of this descriptor.
void chainRead(size_t offset, uint8_t *dst, size_t size) const
Read the contents of a descriptor chain.
void chainWrite(size_t offset, const uint8_t *src, size_t size)
Write to a descriptor chain.
size_t chainSize() const
Retrieve the size of this descriptor chain.
void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
DiskImage & image
Image backing this device.
static const RequestType T_OUT
Write request.
static const RequestType T_FLUSH
Flush device buffers.
RequestQueue qRequests
Device I/O request queue.
VirtIOBlock(const Params ¶ms)
static const Status S_UNSUPP
Request not supported.
static const Status S_IOERR
Request failed due to a device error.
Status read(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device read request.
static const Status S_OK
Request succeeded.
Status write(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device write request.
void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
static const RequestType T_IN
Read request.
Base class for all VirtIO-based devices.
void kick()
Inform the guest of available buffers.
ByteOrder byteOrder
The byte order of the queues, descriptors, etc.
void readConfigBlob(PacketPtr pkt, Addr cfgOffset, const uint8_t *cfg)
Read configuration data from a device structure.
void registerQueue(VirtQueue &queue)
Register a new VirtQueue with the device model.
void produceDescriptor(VirtDescriptor *desc, uint32_t len)
Send a descriptor chain to the guest.
ByteOrder byteOrder
Byte order in this queue.
#define panic(...)
This implements a cprintf based panic() function.
ByteOrder byteOrder(const ThreadContext *tc)
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.
T htog(T value, ByteOrder guest_byte_order)
VirtIO block device request as sent by guest.
Block device configuration structure.