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