40 #ifndef __DEV_VIRTIO_BASE_HH__ 41 #define __DEV_VIRTIO_BASE_HH__ 43 #include "arch/isa_traits.hh" 50 struct VirtIODeviceBaseParams;
51 struct VirtIODummyDeviceParams;
191 void write(
size_t offset,
const uint8_t *src,
size_t size);
238 void chainRead(
size_t offset, uint8_t *dst,
size_t size)
const;
251 void chainWrite(
size_t offset,
const uint8_t *src,
size_t size);
311 void setAddress(
Addr address);
336 return &descriptors[
index];
386 virtual void onNotify();
412 static const Addr ALIGN_BITS = 12;
413 static const Addr ALIGN_SIZE = 1 << ALIGN_BITS;
489 _proxy.writeBlob(_base, &out,
sizeof(out));
499 _proxy.readBlob(_base +
sizeof(
header),
500 temp,
sizeof(T) * ring.size());
501 for (
int i = 0;
i < ring.size(); ++
i)
502 ring[
i] =
gtoh(temp[
i], byteOrder);
512 for (
int i = 0;
i < ring.size(); ++
i)
513 temp[
i] =
htog(ring[
i], byteOrder);
514 _proxy.writeBlob(_base +
sizeof(
header),
515 temp,
sizeof(T) * ring.size());
581 typedef VirtIODeviceBaseParams
Params;
583 FeatureBits features);
612 transKick->process();
689 virtual void reset();
704 void readConfigBlob(
PacketPtr pkt,
Addr cfgOffset,
const uint8_t *cfg);
713 void writeConfigBlob(
PacketPtr pkt,
Addr cfgOffset, uint8_t *cfg);
747 void onNotify(QueueID
index);
785 void setQueueAddress(uint32_t address);
799 uint32_t getQueueAddress()
const;
817 void setDeviceStatus(DeviceStatus
status);
832 void setGuestFeatures(FeatureBits features);
853 const VirtQueue &getCurrentQueue()
const;
885 #endif // __DEV_VIRTIO_BASE_HH__ Base class for all VirtIO-based devices.
void write(size_t offset, const uint8_t *src, size_t size)
Write to the contents of a descriptor.
VirtDescriptor * next() const
Get the pointer to the next descriptor in a chain.
uint16_t getSize() const
Get the number of descriptors available in this queue.
uint16_t VirtAddress
This is a VirtQueue address as exposed through the low-level interface. The address needs to be multi...
EndBitUnion(UserDescFlags) struct UserDesc32
uint16_t getQueueSize() const
Get the size (descriptors) of the currently active queue.
T gtoh(T value, ByteOrder guest_byte_order)
~VirtDescriptor() noexcept
void setQueueSelect(QueueID idx)
Change currently active queue.
#define VRING_DESC_F_WRITE
VirtDescriptor * getDescriptor(VirtDescriptor::Index index)
Get a pointer to a specific descriptor in the queue.
void dumpChain() const
Dump the contents of a descriptor chain starting at this descriptor.
void setAddress(Addr addr)
Set the base address of the VirtIO ring buffer.
const DeviceId deviceId
Device ID (sometimes known as subsystem ID)
size_t size() const
Retrieve the size of this descriptor.
void readHeader()
Update the ring buffer header with data from the guest.
void chainRead(size_t offset, uint8_t *dst, size_t size) const
Read the contents of a descriptor chain.
Addr _address
Base address of the queue.
ByteOrder byteOrder
The byte order of the queues, descriptors, etc.
PortProxy Object Declaration.
Bitfield< 0 > acknowledge
ByteOrder byteOrder
The byte order the descriptor is stored in.
DeviceStatus _deviceStatus
Status of the device.
PortProxy & memProxy
Guest physical memory proxy.
T htog(T value, ByteOrder guest_byte_order)
#define VRING_DESC_F_NEXT
bool isIncoming() const
Check if this is a read-only descriptor (incoming data).
void read(size_t offset, uint8_t *dst, size_t size) const
Read the contents of a descriptor.
size_t chainSize() const
Retrieve the size of this descriptor chain.
QueueID _queueSelect
Queue select register (set by guest)
std::vector< VirtDescriptor > descriptors
Vector of pre-created descriptors indexed by their index into the queue.
void kick()
Inform the guest of available buffers.
ByteOrder byteOrder
Byte order in the ring.
void chainWrite(size_t offset, const uint8_t *src, size_t size)
Write to a descriptor chain.
std::vector< VirtQueue * > _queues
List of virtual queues supported by this device.
Header header
Ring buffer header in host byte order.
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
VirtIO descriptor (chain) wrapper.
PortProxy & _proxy
Guest physical memory proxy.
void dump() const
Dump the contents of a descriptor.
Index _index
Index in virtqueue.
Callback * transKick
Callbacks to kick the guest through the transport layer.
VirtRing< VirtDescriptor::Index > avail
Ring of available (incoming) descriptors.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Index index() const
Get the descriptor's index into the virtqueue.
DeviceStatus getDeviceStatus() const
Retrieve the device status.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Basic support for object serialization.
VirtQueue * queue
Pointer to virtqueue owning this descriptor.
struct FXSave M5_ATTR_PACKED
FeatureBits guestFeatures
Feature set accepted by the guest.
const uint16_t _size
Queue size in terms of number of descriptors.
void updateChain()
Populate this descriptor chain with data from the guest.
This object is a proxy for a port or other object which implements the functional response protocol...
FeatureBits getGuestFeatures() const
Get features accepted by the guest driver.
uint16_t DeviceId
Device Type (sometimes known as subsystem ID)
const FeatureBits deviceFeatures
Feature set offered by the device.
Addr getAddress() const
Get the guest physical address of this queue.
std::ostream CheckpointOut
bool isOutgoing() const
Check if this is a write-only descriptor (outgoing data).
uint16_t Index
Descriptor index in virtqueue.
vring_used_elem swap_byte(vring_used_elem v)
void update()
Populate this descriptor with data from the guest.
VirtRing< struct vring_used_elem > used
Ring of used (outgoing) descriptors.
VirtIO ring buffer wrapper.
std::vector< T > ring
Elements in ring in host byte order.
ByteOrder byteOrder
Byte order in this queue.
void unserialize(ThreadContext &tc, CheckpointIn &cp)
void registerKickCallback(Callback *c)
Register a callback to kick the guest through the transport interface.
Base wrapper around a virtqueue.
QueueID getQueueSelect() const
Get the currently active queue.
bool hasNext() const
Is this descriptor chained to another descriptor?
uint16_t _last_avail
Offset of last consumed descriptor in the VirtQueue::avail ring.
vring_desc desc
Underlying descriptor.
Abstract superclass for simulation objects.
const size_t configSize
Size of the device's configuration space.
Addr _base
Guest physical base address of the ring buffer.
virtual void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
PortProxy * memProxy
Pointer to memory proxy.