40 #ifndef __DEV_VIRTIO_BASE_HH__ 
   41 #define __DEV_VIRTIO_BASE_HH__ 
   43 #include "arch/isa_traits.hh" 
   50 struct VirtIODeviceBaseParams;
 
   51 struct VirtIODummyDeviceParams;
 
   69 template <
typename T> 
inline T
 
   75 template <
typename T> 
inline T
 
  514                             (uint8_t *)temp, 
sizeof(T) * 
ring.size());
 
  515             for (
int i = 0; 
i < 
ring.size(); ++
i)
 
  524             for (
int i = 0; 
i < 
ring.size(); ++
i)
 
  527                              (uint8_t *)temp, 
sizeof(T) * 
ring.size());
 
  591     typedef VirtIODeviceBaseParams 
Params;
 
  699     virtual void reset();
 
  890 #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. 
 
void dump() const 
Dump the contents of a queue. 
 
virtual void process()=0
virtual process function that is invoked when the callback queue is executed. 
 
void setAddress(Addr address)
Set the base address of this queue. 
 
uint16_t VirtAddress
This is a VirtQueue address as exposed through the low-level interface. The address needs to be multi...
 
void unserialize(CheckpointIn &cp) override
Unserialize an object. 
 
BitUnion8(DeviceStatus) Bitfield< 7 > failed
 
void setQueueSelect(QueueID idx)
Change currently active queue. 
 
#define VRING_DESC_F_WRITE
 
bool hasNext() const 
Is this descriptor chained to another descriptor? 
 
Index index() const 
Get the descriptor's index into the virtqueue. 
 
const Params * params() const 
 
DeviceStatus getDeviceStatus() const 
Retrieve the device status. 
 
static const unsigned ALIGN_BITS
Page size used by VirtIO. It's hard-coded to 4096 bytes in the spec for historical reasons...
 
void setGuestFeatures(FeatureBits features)
Set feature bits accepted by the guest driver. 
 
VirtDescriptor * getDescriptor(VirtDescriptor::Index index)
Get a pointer to a specific descriptor in the queue. 
 
void setAddress(Addr addr)
Set the base address of the VirtIO ring buffer. 
 
const DeviceId deviceId
Device ID (sometimes known as subsystem ID) 
 
void dumpChain() const 
Dump the contents of a descriptor chain starting at this descriptor. 
 
void setDeviceStatus(DeviceStatus status)
Update device status and optionally reset device. 
 
bool isIncoming() const 
Check if this is a read-only descriptor (incoming data). 
 
static const DeviceId ID_INVALID
VirtIO device ID. 
 
struct VirtQueue::VirtRing::Header M5_ATTR_PACKED
 
void serialize(CheckpointOut &cp) const override
Serialize an object. 
 
void readHeader()
Update the ring buffer header with data from the guest. 
 
VirtDescriptor * consumeDescriptor()
Get an incoming descriptor chain from the queue. 
 
void dump() const 
Dump the contents of a descriptor. 
 
void produceDescriptor(VirtDescriptor *desc, uint32_t len)
Send a descriptor chain to the guest. 
 
Addr _address
Base address of the queue. 
 
uint16_t getQueueSize() const 
Get the size (descriptors) of the currently active queue. 
 
PortProxy Object Declaration. 
 
Bitfield< 0 > acknowledge
 
T htov_legacy(T v)
Convert host endianness to legacy VirtIO endianness. 
 
void writeConfigBlob(PacketPtr pkt, Addr cfgOffset, uint8_t *cfg)
Write configuration data to a device structure. 
 
DeviceStatus _deviceStatus
Status of the device. 
 
QueueID getQueueSelect() const 
Get the currently active queue. 
 
PortProxy & memProxy
Guest physical memory proxy. 
 
#define VRING_DESC_F_NEXT
 
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 chainRead(size_t offset, uint8_t *dst, size_t size) const 
Read the contents of a descriptor chain. 
 
void kick()
Inform the guest of available buffers. 
 
uint16_t getSize() const 
Get the number of descriptors available in this queue. 
 
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. 
 
virtual void writeConfig(PacketPtr pkt, Addr cfgOffset)
Write to the configuration space of a device. 
 
VirtIO descriptor (chain) wrapper. 
 
Addr getAddress() const 
Get the guest physical address of this queue. 
 
PortProxy & _proxy
Guest physical memory proxy. 
 
virtual void reset()
Driver-request device reset. 
 
EndBitUnion(DeviceStatus) typedef VirtIODeviceBaseParams Params
 
void onNotify(QueueID index)
Driver is requesting service. 
 
Index _index
Index in virtqueue. 
 
virtual void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device. 
 
Callback * transKick
Callbacks to kick the guest through the transport layer. 
 
VirtRing< VirtDescriptor::Index > avail
Ring of available (incoming) descriptors. 
 
const VirtQueue & getCurrentQueue() const 
Convenience method to get the currently selected queue. 
 
uint64_t Addr
Address type This will probably be moved somewhere else in the near future. 
 
virtual void onNotify()
Notify queue of pending events. 
 
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. 
 
size_t size() const 
Retrieve the size of this descriptor. 
 
virtual void readBlob(Addr addr, uint8_t *p, int size) const 
Read size bytes memory at address and store in p. 
 
FeatureBits guestFeatures
Feature set accepted by the guest. 
 
uint32_t getQueueAddress() const 
Get the host physical address of the currently active queue. 
 
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 structural port, to be used for debug accesses. 
 
VirtIODummyDevice(VirtIODummyDeviceParams *params)
 
VirtDescriptor * next() const 
Get the pointer to the next descriptor in a chain. 
 
void registerQueue(VirtQueue &queue)
Register a new VirtQueue with the device model. 
 
uint16_t DeviceId
Device Type (sometimes known as subsystem ID) 
 
void read(size_t offset, uint8_t *dst, size_t size) const 
Read the contents of a descriptor. 
 
const FeatureBits deviceFeatures
Feature set offered by the device. 
 
std::ostream CheckpointOut
 
void setQueueAddress(uint32_t address)
Change the host physical address of the currently active queue. 
 
uint16_t Index
Descriptor index in virtqueue. 
 
virtual void writeBlob(Addr addr, const uint8_t *p, int size) const 
Write size bytes from p to address. 
 
T vtoh_legacy(T v)
Convert legacy VirtIO endianness to host endianness. 
 
size_t chainSize() const 
Retrieve the size of this descriptor chain. 
 
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. 
 
bool isOutgoing() const 
Check if this is a write-only descriptor (outgoing data). 
 
static const unsigned ALIGN_SIZE
 
void registerKickCallback(Callback *c)
Register a callback to kick the guest through the transport interface. 
 
void serialize(CheckpointOut &cp) const override
Serialize an object. 
 
Base wrapper around a virtqueue. 
 
void unserialize(CheckpointIn &cp) override
Unserialize an object. 
 
uint16_t _last_avail
Offset of last consumed descriptor in the VirtQueue::avail ring. 
 
FeatureBits getGuestFeatures() const 
Get features accepted by the guest driver. 
 
void readConfigBlob(PacketPtr pkt, Addr cfgOffset, const uint8_t *cfg)
Read configuration data from a device structure. 
 
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.