Go to the documentation of this file.
38 #ifndef __DEV_VIRTIO_BASE_HH__
39 #define __DEV_VIRTIO_BASE_HH__
56 struct VirtIODeviceBaseParams;
57 struct VirtIODummyDeviceParams;
75 inline std::enable_if_t<std::is_same_v<T, vring_used_elem>, T>
84 inline std::enable_if_t<std::is_same_v<T, vring_desc>, T>
527 temp,
sizeof(T) *
ring.size());
528 for (
int i = 0;
i <
ring.size(); ++
i)
539 for (
int i = 0;
i <
ring.size(); ++
i)
542 temp,
sizeof(T) *
ring.size());
608 typedef VirtIODeviceBaseParams
Params;
718 virtual void reset();
918 #endif // __DEV_VIRTIO_BASE_HH__
const VirtQueue & getCurrentQueue() const
Convenience method to get the currently selected queue.
PortProxy & memProxy
Guest physical memory proxy.
VirtRing< struct vring_used_elem > used
Ring of used (outgoing) descriptors.
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void writeConfigBlob(PacketPtr pkt, Addr cfgOffset, uint8_t *cfg)
Write configuration data to a device structure.
virtual ~VirtIODeviceBase()
void write(size_t offset, const uint8_t *src, size_t size)
Write to the contents of a descriptor.
void dumpChain() const
Dump the contents of a descriptor chain starting at this descriptor.
std::function< void()> transKick
Callbacks to kick the guest through the transport layer
Index index() const
Get the descriptor's index into the virtqueue.
vring_desc desc
Underlying descriptor.
bool hasNext() const
Is this descriptor chained to another descriptor?
uint16_t DeviceId
Device Type (sometimes known as subsystem ID)
Addr getAddress() const
Get the guest physical address of this queue.
uint16_t Index
Descriptor index in virtqueue.
Addr _base
Guest physical base address of the ring buffer.
bool isIncoming() const
Check if this is a read-only descriptor (incoming data).
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void update()
Populate this descriptor with data from the guest.
void reset()
Reset cached state in this queue and in the associated ring buffers.
VirtQueue * queue
Pointer to virtqueue owning this descriptor.
void dump() const
Dump the contents of a queue.
#define VRING_DESC_F_NEXT
QueueID _queueSelect
Queue select register (set by guest)
const size_t configSize
Size of the device's configuration space.
static const Addr ALIGN_BITS
Page size used by VirtIO. It's hard-coded to 4096 bytes in the spec for historical reasons.
static const DeviceId ID_INVALID
VirtIO device ID.
virtual void writeConfig(PacketPtr pkt, Addr cfgOffset)
Write to the configuration space of a device.
void chainWrite(size_t offset, const uint8_t *src, size_t size)
Write to a descriptor chain.
void setGuestFeatures(FeatureBits features)
Set feature bits accepted by the guest driver.
EndBitUnion(DeviceStatus) typedef VirtIODeviceBaseParams Params
void dump() const
Dump the contents of a descriptor.
VirtIO ring buffer wrapper.
void reset()
Reset any state in the ring buffer.
void readConfigBlob(PacketPtr pkt, Addr cfgOffset, const uint8_t *cfg)
Read configuration data from a device structure.
VirtDescriptor * next() const
Get the pointer to the next descriptor in a chain.
bool isOutgoing() const
Check if this is a write-only descriptor (outgoing data).
virtual void reset()
Driver-request device reset.
void serialize(CheckpointOut &cp) const override
Serialize an object.
Base wrapper around a virtqueue.
PortProxy & _proxy
Guest physical memory proxy.
Basic support for object serialization.
virtual void onNotify()
Notify queue of pending events.
uint16_t getQueueSize() const
Get the size (descriptors) of the currently active queue.
Bitfield< 0 > acknowledge
void serialize(CheckpointOut &cp) const override
Serialize an object.
void setQueueSelect(QueueID idx)
Change currently active queue.
void registerKickCallback(const std::function< void()> &callback)
Register a callback to kick the guest through the transport interface.
const Params & params() const
size_t chainSize() const
Retrieve the size of this descriptor chain.
void registerQueue(VirtQueue &queue)
Register a new VirtQueue with the device model.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setQueueAddress(uint32_t address)
Change the host physical address of the currently active queue.
void kick()
Inform the guest of available buffers.
const DeviceId deviceId
Device ID (sometimes known as subsystem ID)
std::vector< VirtQueue * > _queues
List of virtual queues supported by this device.
DeviceStatus _deviceStatus
Status of the device.
void setAddress(Addr address)
Set the base address of this queue.
PortProxy * memProxy
Pointer to memory proxy.
const FeatureBits deviceFeatures
Feature set offered by the device.
size_t size() const
Retrieve the size of this descriptor.
void readHeader()
Update the ring buffer header with data from the guest.
T gtoh(T value, ByteOrder guest_byte_order)
FeatureBits guestFeatures
Feature set accepted by the guest.
This object is a proxy for a port or other object which implements the functional response protocol,...
VirtIODummyDevice(const VirtIODummyDeviceParams ¶ms)
T htog(T value, ByteOrder guest_byte_order)
ByteOrder byteOrder
Byte order in the ring.
ByteOrder byteOrder
The byte order the descriptor is stored in.
void onNotify(QueueID index)
Driver is requesting service.
Base class for all VirtIO-based devices.
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
Abstract superclass for simulation objects.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::vector< VirtDescriptor > descriptors
Vector of pre-created descriptors indexed by their index into the queue.
BitUnion8(DeviceStatus) Bitfield< 7 > failed
Header header
Ring buffer header in host byte order.
void setAddress(Addr addr)
Set the base address of the VirtIO ring buffer.
const uint16_t _size
Queue size in terms of number of descriptors.
Index _index
Index in virtqueue.
DeviceStatus getDeviceStatus() const
Retrieve the device status.
VirtRing< VirtDescriptor::Index > avail
Ring of available (incoming) descriptors.
uint16_t VirtAddress
This is a VirtQueue address as exposed through the low-level interface. The address needs to be multi...
virtual void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
VirtIO descriptor (chain) wrapper.
static const Addr ALIGN_SIZE
uint16_t getSize() const
Get the number of descriptors available in this queue.
ByteOrder byteOrder
The byte order of the queues, descriptors, etc.
void produceDescriptor(VirtDescriptor *desc, uint32_t len)
Send a descriptor chain to the guest.
VirtDescriptor * getDescriptor(VirtDescriptor::Index index)
Get a pointer to a specific descriptor in the queue.
ByteOrder byteOrder
Byte order in this queue.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
QueueID getQueueSelect() const
Get the currently active queue.
void chainRead(size_t offset, uint8_t *dst, size_t size) const
Read the contents of a descriptor chain.
VirtIODeviceBase(const Params ¶ms, DeviceId id, size_t config_size, FeatureBits features)
Addr _address
Base address of the queue.
std::ostream CheckpointOut
~VirtDescriptor() noexcept
FeatureBits getGuestFeatures() const
Get features accepted by the guest driver.
uint16_t _last_avail
Offset of last consumed descriptor in the VirtQueue::avail ring.
std::vector< T > ring
Elements in ring in host byte order.
#define VRING_DESC_F_WRITE
uint32_t getQueueAddress() const
Get the host physical address of the currently active queue.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void read(size_t offset, uint8_t *dst, size_t size) const
Read the contents of a descriptor.
VirtDescriptor * consumeDescriptor()
Get an incoming descriptor chain from the queue.
std::enable_if_t< std::is_same_v< T, vring_used_elem >, T > swap_byte(T v)
void updateChain()
Populate this descriptor chain with data from the guest.
virtual void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
void setDeviceStatus(DeviceStatus status)
Update device status and optionally reset device.
Generated on Wed Jul 13 2022 10:39:13 for gem5 by doxygen 1.8.17