gem5 v24.0.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. | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. | |
Low-level Device Interface | |
void | reset () |
Reset cached state in this queue and in the associated ring buffers. | |
void | setAddress (Addr address) |
Set the base address of this queue. | |
Addr | getAddress () const |
Get the guest physical address of this queue. | |
uint16_t | getSize () const |
Get the number of descriptors available in this queue. | |
VirtDescriptor * | getDescriptor (VirtDescriptor::Index index) |
Get a pointer to a specific descriptor in the queue. | |
Device Model Interfaces | |
VirtDescriptor * | consumeDescriptor () |
Get an incoming descriptor chain from the queue. | |
void | produceDescriptor (VirtDescriptor *desc, uint32_t len) |
Send a descriptor chain to the guest. | |
Device Model Callbacks | |
virtual void | onNotify () |
Notify queue of pending events. | |
virtual void | onNotifyDescriptor (VirtDescriptor *desc) |
Notify queue of pending incoming descriptor. | |
Debug interfaces | |
void | dump () const |
Dump the contents of a queue. | |
Public Member Functions inherited from gem5::Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. | |
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. | |
static const Addr | ALIGN_SIZE = 1 << ALIGN_BITS |
Protected Member Functions | |
VirtQueue (PortProxy &proxy, ByteOrder bo, uint16_t size) | |
Instantiate a new virtqueue. | |
Protected Attributes | |
ByteOrder | byteOrder |
Byte order in this queue. | |
Private Member Functions | |
VirtQueue () | |
Private Attributes | |
const uint16_t | _size |
Queue size in terms of number of descriptors. | |
Addr | _address |
Base address of the queue. | |
PortProxy & | memProxy |
Guest physical memory proxy. | |
VirtRing< VirtDescriptor::Index > | avail |
Ring of available (incoming) descriptors. | |
VirtRing< struct vring_used_elem > | used |
Ring of used (outgoing) descriptors. | |
uint16_t | _last_avail |
Offset of last consumed descriptor in the VirtQueue::avail ring. | |
std::vector< VirtDescriptor > | descriptors |
Vector of pre-created descriptors indexed by their index into the queue. | |
Additional Inherited Members | |
Static Public Member Functions inherited from gem5::Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. | |
static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
Generate a checkpoint file so that the serialization can be routed to it. | |
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 231 of file base.cc.
References _size, gem5::PowerISA::bo, descriptors, and gem5::ArmISA::i.
|
private |
VirtDescriptor * gem5::VirtQueue::consumeDescriptor | ( | ) |
Get an incoming descriptor chain from the queue.
Definition at line 285 of file base.cc.
References _last_avail, avail, gem5::ArmISA::d, descriptors, DPRINTF, gem5::VirtQueue::VirtRing< T >::header, gem5::MipsISA::index, gem5::VirtQueue::VirtRing< T >::read(), gem5::VirtQueue::VirtRing< T >::ring, and used.
Referenced by onNotify(), and gem5::VirtIOConsole::TermRecvQueue::trySend().
void gem5::VirtQueue::dump | ( | ) | const |
Dump the contents of a queue.
Definition at line 318 of file base.cc.
References gem5::ArmISA::d, and descriptors.
|
inline |
Get the guest physical address of this queue.
Definition at line 335 of file base.hh.
References _address.
Referenced by gem5::VirtDescriptor::update().
|
inline |
Get a pointer to a specific descriptor in the queue.
Definition at line 353 of file base.hh.
References descriptors, and gem5::MipsISA::index.
Referenced by gem5::VirtDescriptor::next().
|
inline |
Get the number of descriptors available in this queue.
Definition at line 342 of file base.hh.
References _size.
Referenced by gem5::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 gem5::VirtIOConsole::TermRecvQueue, and gem5::VirtIORng::RngQueue.
Definition at line 328 of file base.cc.
References consumeDescriptor(), gem5::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 gem5::VirtIO9PBase::FSQueue, gem5::VirtIOBlock::RequestQueue, and gem5::VirtIOConsole::TermTransQueue.
Definition at line 415 of file base.hh.
Referenced by onNotify().
void gem5::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 304 of file base.cc.
References DPRINTF, gem5::ArmISA::e, gem5::VirtQueue::VirtRing< T >::header, gem5::VirtDescriptor::index(), gem5::ArmISA::len, gem5::VirtQueue::VirtRing< T >::readHeader(), gem5::VirtQueue::VirtRing< T >::ring, used, and gem5::VirtQueue::VirtRing< T >::write().
Referenced by gem5::VirtIOBlock::RequestQueue::onNotifyDescriptor(), gem5::VirtIO9PBase::sendRMsg(), and gem5::VirtIOConsole::TermRecvQueue::trySend().
void gem5::VirtQueue::reset | ( | ) |
Reset cached state in this queue and in the associated ring buffers.
A client of this method should be the VirtIODeviceBase::reset.
Definition at line 262 of file base.cc.
References _address, _last_avail, avail, gem5::VirtQueue::VirtRing< T >::reset(), and used.
|
overridevirtual |
Serialize an object.
Output an object's state into the current checkpoint section.
cp | Checkpoint state |
Implements gem5::Serializable.
Definition at line 242 of file base.cc.
References _address, _last_avail, and SERIALIZE_SCALAR.
void gem5::VirtQueue::setAddress | ( | Addr | address | ) |
Set the base address of this queue.
address | Guest physical base address of the queue. |
Definition at line 272 of file base.cc.
References _address, _size, ALIGN_SIZE, avail, gem5::VirtQueue::VirtRing< T >::setAddress(), and used.
Referenced by gem5::VirtIODeviceBase::setQueueAddress(), and unserialize().
|
overridevirtual |
Unserialize an object.
Read an object's state from the current checkpoint section.
cp | Checkpoint state |
Implements gem5::Serializable.
Definition at line 249 of file base.cc.
References _last_avail, gem5::paramIn(), setAddress(), and UNSERIALIZE_SCALAR.
|
private |
Base address of the queue.
Definition at line 455 of file base.hh.
Referenced by getAddress(), reset(), serialize(), and setAddress().
|
private |
Offset of last consumed descriptor in the VirtQueue::avail ring.
Definition at line 570 of file base.hh.
Referenced by consumeDescriptor(), reset(), serialize(), and unserialize().
|
private |
Queue size in terms of number of descriptors.
Definition at line 453 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 430 of file base.hh.
Referenced by gem5::VirtIODeviceBase::getQueueAddress().
|
static |
Definition at line 431 of file base.hh.
Referenced by gem5::MmioVirtIO::read(), gem5::RiscvISA::MmioVirtIO::read(), setAddress(), gem5::VirtIODeviceBase::setQueueAddress(), gem5::MmioVirtIO::write(), and gem5::RiscvISA::MmioVirtIO::write().
|
private |
Ring of available (incoming) descriptors.
Definition at line 564 of file base.hh.
Referenced by consumeDescriptor(), reset(), and setAddress().
|
protected |
Byte order in this queue.
Definition at line 447 of file base.hh.
Referenced by gem5::VirtIOBlock::RequestQueue::onNotifyDescriptor().
|
private |
Vector of pre-created descriptors indexed by their index into the queue.
Definition at line 574 of file base.hh.
Referenced by consumeDescriptor(), dump(), getDescriptor(), and VirtQueue().
|
private |
|
private |
Ring of used (outgoing) descriptors.
Definition at line 566 of file base.hh.
Referenced by consumeDescriptor(), produceDescriptor(), reset(), and setAddress().