gem5
v20.1.0.0
|
Base wrapper around a virtqueue. More...
#include <base.hh>
Classes | |
class | VirtRing |
VirtIO ring buffer wrapper. More... | |
Public Member Functions | |
virtual | ~VirtQueue () |
Checkpointing Interface | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
Low-level Device Interface | |
void | setAddress (Addr address) |
Set the base address of this queue. More... | |
Addr | getAddress () const |
Get the guest physical address of this queue. More... | |
uint16_t | getSize () const |
Get the number of descriptors available in this queue. More... | |
VirtDescriptor * | getDescriptor (VirtDescriptor::Index index) |
Get a pointer to a specific descriptor in the queue. More... | |
Device Model Interfaces | |
VirtDescriptor * | consumeDescriptor () |
Get an incoming descriptor chain from the queue. More... | |
void | produceDescriptor (VirtDescriptor *desc, uint32_t len) |
Send a descriptor chain to the guest. More... | |
Device Model Callbacks | |
virtual void | onNotify () |
Notify queue of pending events. More... | |
virtual void | onNotifyDescriptor (VirtDescriptor *desc) |
Notify queue of pending incoming descriptor. More... | |
Debug interfaces | |
void | dump () const |
Dump the contents of a queue. More... | |
Public Member Functions inherited from Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. More... | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. More... | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Static Public Attributes | |
static const Addr | ALIGN_BITS = 12 |
Page size used by VirtIO. It's hard-coded to 4096 bytes in the spec for historical reasons. More... | |
static const Addr | ALIGN_SIZE = 1 << ALIGN_BITS |
Protected Member Functions | |
VirtQueue (PortProxy &proxy, ByteOrder bo, uint16_t size) | |
Instantiate a new virtqueue. More... | |
Protected Attributes | |
ByteOrder | byteOrder |
Byte order in this queue. More... | |
Private Member Functions | |
VirtQueue () | |
Private Attributes | |
const uint16_t | _size |
Queue size in terms of number of descriptors. More... | |
Addr | _address |
Base address of the queue. More... | |
PortProxy & | memProxy |
Guest physical memory proxy. More... | |
VirtRing< VirtDescriptor::Index > | avail |
Ring of available (incoming) descriptors. More... | |
VirtRing< struct vring_used_elem > | used |
Ring of used (outgoing) descriptors. More... | |
uint16_t | _last_avail |
Offset of last consumed descriptor in the VirtQueue::avail ring. More... | |
std::vector< VirtDescriptor > | descriptors |
Vector of pre-created descriptors indexed by their index into the queue. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. More... | |
static void | serializeAll (const std::string &cpt_dir) |
Serializes all the SimObjects. More... | |
static void | unserializeGlobals (CheckpointIn &cp) |
Base wrapper around a virtqueue.
VirtIO device models typically need to extend this class to implement their own device queues.
|
protected |
Instantiate a new virtqueue.
Instantiate a virtqueue with a fixed size. The size is specified in descriptors which are defined as 4096 bytes each.
proxy | Proxy to the guest physical memory. |
size | Size in descriptors/pages. |
Definition at line 227 of file base.cc.
References _size, PowerISA::bo, descriptors, and ArmISA::i.
|
private |
VirtDescriptor * VirtQueue::consumeDescriptor | ( | ) |
Get an incoming descriptor chain from the queue.
Definition at line 271 of file base.cc.
References _last_avail, avail, ArmISA::d, descriptors, DPRINTF, VirtQueue::VirtRing< T >::header, MipsISA::index, VirtQueue::VirtRing< T >::read(), VirtQueue::VirtRing< T >::ring, and used.
Referenced by onNotify(), and VirtIOConsole::TermRecvQueue::trySend().
void VirtQueue::dump | ( | ) | const |
Dump the contents of a queue.
Definition at line 304 of file base.cc.
References ArmISA::d, descriptors, and DTRACE.
|
inline |
Get the guest physical address of this queue.
Definition at line 315 of file base.hh.
References _address.
Referenced by VirtDescriptor::update().
|
inline |
Get a pointer to a specific descriptor in the queue.
Definition at line 333 of file base.hh.
References descriptors, and MipsISA::index.
Referenced by VirtDescriptor::next().
|
inline |
Get the number of descriptors available in this queue.
Definition at line 322 of file base.hh.
References _size.
Referenced by VirtIODeviceBase::getQueueSize().
|
virtual |
Notify queue of pending events.
This method is called by VirtIODeviceBase::onNotify() to notify the device model of pending data in a virtqueue. The default implementation of this method iterates over the available descriptor chains and calls onNotifyDescriptor() for every new incoming chain.
Device models should normally overload one of onNotify() and onNotifyDescriptor().
Reimplemented in VirtIOConsole::TermRecvQueue.
Definition at line 314 of file base.cc.
References consumeDescriptor(), ArmISA::d, DPRINTF, and onNotifyDescriptor().
|
inlinevirtual |
Notify queue of pending incoming descriptor.
This method is called by the default implementation of onNotify() to notify the device model of pending data in a descriptor chain.
Device models should normally overload one of onNotify() and onNotifyDescriptor().
Reimplemented in VirtIOBlock::RequestQueue, VirtIO9PBase::FSQueue, and VirtIOConsole::TermTransQueue.
Definition at line 395 of file base.hh.
Referenced by onNotify().
void VirtQueue::produceDescriptor | ( | VirtDescriptor * | desc, |
uint32_t | len | ||
) |
Send a descriptor chain to the guest.
This method posts a descriptor chain to the guest after a device model has finished processing it. The device model typically needs to call VirtIODeviceBase::kick() to deliver notify tell the guest that the queue has been updated.
desc | Start of descriptor chain. |
len | Length of the produced data. |
Definition at line 290 of file base.cc.
References DPRINTF, ArmISA::e, VirtQueue::VirtRing< T >::header, VirtDescriptor::index(), ArmISA::len, VirtQueue::VirtRing< T >::readHeader(), VirtQueue::VirtRing< T >::ring, used, and VirtQueue::VirtRing< T >::write().
Referenced by VirtIOBlock::RequestQueue::onNotifyDescriptor(), VirtIO9PBase::sendRMsg(), and VirtIOConsole::TermRecvQueue::trySend().
|
overridevirtual |
Serialize an object.
Output an object's state into the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 238 of file base.cc.
References _address, _last_avail, and SERIALIZE_SCALAR.
void VirtQueue::setAddress | ( | Addr | address | ) |
Set the base address of this queue.
address | Guest physical base address of the queue. |
Definition at line 258 of file base.cc.
References _address, _size, ALIGN_SIZE, avail, VirtQueue::VirtRing< T >::setAddress(), and used.
Referenced by VirtIODeviceBase::setQueueAddress(), and unserialize().
|
overridevirtual |
Unserialize an object.
Read an object's state from the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 245 of file base.cc.
References _last_avail, paramIn(), setAddress(), and UNSERIALIZE_SCALAR.
|
private |
Base address of the queue.
Definition at line 435 of file base.hh.
Referenced by getAddress(), serialize(), and setAddress().
|
private |
Offset of last consumed descriptor in the VirtQueue::avail ring.
Definition at line 541 of file base.hh.
Referenced by consumeDescriptor(), serialize(), and unserialize().
|
private |
Queue size in terms of number of descriptors.
Definition at line 433 of file base.hh.
Referenced by getSize(), setAddress(), and VirtQueue().
|
static |
Page size used by VirtIO. It's hard-coded to 4096 bytes in the spec for historical reasons.
Definition at line 410 of file base.hh.
Referenced by VirtIODeviceBase::getQueueAddress().
|
static |
Definition at line 411 of file base.hh.
Referenced by MmioVirtIO::read(), setAddress(), VirtIODeviceBase::setQueueAddress(), and MmioVirtIO::write().
|
private |
Ring of available (incoming) descriptors.
Definition at line 535 of file base.hh.
Referenced by consumeDescriptor(), and setAddress().
|
protected |
Byte order in this queue.
Definition at line 427 of file base.hh.
Referenced by VirtIOBlock::RequestQueue::onNotifyDescriptor().
|
private |
Vector of pre-created descriptors indexed by their index into the queue.
Definition at line 545 of file base.hh.
Referenced by consumeDescriptor(), dump(), getDescriptor(), and VirtQueue().
|
private |
|
private |
Ring of used (outgoing) descriptors.
Definition at line 537 of file base.hh.
Referenced by consumeDescriptor(), produceDescriptor(), and setAddress().