gem5  v21.1.0.2
base.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, 2016, 2021 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #include "dev/virtio/base.hh"
39 
40 #include "base/trace.hh"
41 #include "debug/VIO.hh"
42 #include "params/VirtIODeviceBase.hh"
43 #include "params/VirtIODummyDevice.hh"
44 #include "sim/serialize.hh"
45 
46 namespace gem5
47 {
48 
50  VirtQueue &_queue, Index descIndex)
51  : memProxy(&_memProxy), queue(&_queue), byteOrder(bo), _index(descIndex),
52  desc{0, 0, 0, 0}
53 {
54 }
55 
57 {
58  *this = std::forward<VirtDescriptor>(other);
59 }
60 
62 {
63 }
64 
67 {
68  memProxy = std::move(rhs.memProxy);
69  queue = std::move(rhs.queue);
70  byteOrder = std::move(rhs.byteOrder);
71  _index = std::move(rhs._index);
72  desc = std::move(rhs.desc);
73 
74  return *this;
75 }
76 
77 void
79 {
80  const Addr vq_addr(queue->getAddress());
81  // Check if the queue has been initialized yet
82  if (vq_addr == 0)
83  return;
84 
85  assert(_index < queue->getSize());
86  const Addr desc_addr(vq_addr + sizeof(desc) * _index);
87  vring_desc guest_desc;
88  memProxy->readBlob(desc_addr, &guest_desc, sizeof(guest_desc));
89  desc = gtoh(guest_desc, byteOrder);
90  DPRINTF(VIO,
91  "VirtDescriptor(%i): Addr: 0x%x, Len: %i, Flags: 0x%x, "
92  "Next: 0x%x\n",
94 }
95 
96 void
98 {
99  VirtDescriptor *desc(this);
100  do {
101  desc->update();
102  } while ((desc = desc->next()) != NULL && desc != this);
103 
104  if (desc == this)
105  panic("Loop in descriptor chain!\n");
106 }
107 
108 void
110 {
111  if (!debug::VIO)
112  return;
113 
114  DPRINTF(VIO, "Descriptor[%i]: "
115  "Addr: 0x%x, Len: %i, Flags: 0x%x, Next: 0x%x\n",
117 
118  if (isIncoming()) {
119  uint8_t data[desc.len];
120  read(0, data, desc.len);
121  DDUMP(VIO, data, desc.len);
122  }
123 }
124 
125 void
127 {
128  if (!debug::VIO)
129  return;
130 
131  const VirtDescriptor *desc(this);
132  do {
133  desc->dump();
134  } while ((desc = desc->next()) != NULL);
135 }
136 
139 {
140  if (hasNext()) {
141  return queue->getDescriptor(desc.next);
142  } else {
143  return NULL;
144  }
145 }
146 
147 void
148 VirtDescriptor::read(size_t offset, uint8_t *dst, size_t size) const
149 {
150  DPRINTF(VIO, "VirtDescriptor(%p, 0x%x, %i)::read: offset: %i, dst: 0x%x, size: %i\n",
151  this, desc.addr, desc.len, offset, (long)dst, size);
152  assert(size <= desc.len - offset);
153  if (!isIncoming())
154  panic("Trying to read from outgoing buffer\n");
155 
156  memProxy->readBlob(desc.addr + offset, dst, size);
157 }
158 
159 void
160 VirtDescriptor::write(size_t offset, const uint8_t *src, size_t size)
161 {
162  DPRINTF(VIO, "VirtDescriptor(%p, 0x%x, %i)::write: offset: %i, src: 0x%x, size: %i\n",
163  this, desc.addr, desc.len, offset, (long)src, size);
164  assert(size <= desc.len - offset);
165  if (!isOutgoing())
166  panic("Trying to write to incoming buffer\n");
167 
169 }
170 
171 void
172 VirtDescriptor::chainRead(size_t offset, uint8_t *dst, size_t size) const
173 {
174  const VirtDescriptor *desc(this);
175  const size_t full_size(size);
176  do {
177  if (offset < desc->size()) {
178  const size_t chunk_size(std::min(desc->size() - offset, size));
179  desc->read(offset, dst, chunk_size);
180  dst += chunk_size;
181  size -= chunk_size;
182  offset = 0;
183  } else {
184  offset -= desc->size();
185  }
186  } while ((desc = desc->next()) != NULL && desc->isIncoming() && size > 0);
187 
188  if (size != 0) {
189  panic("Failed to read %i bytes from chain of %i bytes @ offset %i\n",
190  full_size, chainSize(), offset);
191  }
192 }
193 
194 void
195 VirtDescriptor::chainWrite(size_t offset, const uint8_t *src, size_t size)
196 {
197  VirtDescriptor *desc(this);
198  const size_t full_size(size);
199  do {
200  if (offset < desc->size()) {
201  const size_t chunk_size(std::min(desc->size() - offset, size));
202  desc->write(offset, src, chunk_size);
203  src += chunk_size;
204  size -= chunk_size;
205  offset = 0;
206  } else {
207  offset -= desc->size();
208  }
209  } while ((desc = desc->next()) != NULL && size > 0);
210 
211  if (size != 0) {
212  panic("Failed to write %i bytes into chain of %i bytes @ offset %i\n",
213  full_size, chainSize(), offset);
214  }
215 }
216 
217 size_t
219 {
220  size_t size(0);
221  const VirtDescriptor *desc(this);
222  do {
223  size += desc->size();
224  } while ((desc = desc->next()) != NULL);
225 
226  return size;
227 }
228 
229 
230 
231 VirtQueue::VirtQueue(PortProxy &proxy, ByteOrder bo, uint16_t size)
232  : byteOrder(bo), _size(size), _address(0), memProxy(proxy),
233  avail(proxy, bo, size), used(proxy, bo, size),
234  _last_avail(0)
235 {
236  descriptors.reserve(_size);
237  for (int i = 0; i < _size; ++i)
238  descriptors.emplace_back(proxy, bo, *this, i);
239 }
240 
241 void
243 {
246 }
247 
248 void
250 {
251  Addr addr_in;
252 
253  paramIn(cp, "_address", addr_in);
255 
256  // Use the address setter to ensure that the ring buffer addresses
257  // are updated as well.
258  setAddress(addr_in);
259 }
260 
261 void
263 {
264  _address = 0;
265  _last_avail = 0;
266 
267  avail.reset();
268  used.reset();
269 }
270 
271 void
273 {
274  const Addr addr_avail(address + _size * sizeof(struct vring_desc));
275  const Addr addr_avail_end(addr_avail + sizeof(struct vring_avail) +
276  _size * sizeof(uint16_t));
277  const Addr addr_used((addr_avail_end + sizeof(uint16_t) +
278  (ALIGN_SIZE - 1)) & ~(ALIGN_SIZE - 1));
279  _address = address;
280  avail.setAddress(addr_avail);
281  used.setAddress(addr_used);
282 }
283 
286 {
287  avail.read();
288  DPRINTF(VIO, "consumeDescriptor: _last_avail: %i, avail.idx: %i (->%i)\n",
289  _last_avail, avail.header.index,
290  avail.ring[_last_avail % used.ring.size()]);
291  if (_last_avail == avail.header.index)
292  return NULL;
293 
295  ++_last_avail;
296 
298  d->updateChain();
299 
300  return d;
301 }
302 
303 void
305 {
306  used.readHeader();
307  DPRINTF(VIO, "produceDescriptor: dscIdx: %i, len: %i, used.idx: %i\n",
308  desc->index(), len, used.header.index);
309 
310  struct vring_used_elem &e(used.ring[used.header.index % used.ring.size()]);
311  e.id = desc->index();
312  e.len = len;
313  used.header.index += 1;
314  used.write();
315 }
316 
317 void
319 {
320  if (!debug::VIO)
321  return;
322 
323  for (const VirtDescriptor &d : descriptors)
324  d.dump();
325 }
326 
327 void
329 {
330  DPRINTF(VIO, "onNotify\n");
331 
332  // Consume all pending descriptors from the input queue.
333  VirtDescriptor *d;
334  while ((d = consumeDescriptor()) != NULL)
336 }
337 
338 
340  size_t config_size, FeatureBits features)
341  : SimObject(params),
342  guestFeatures(0),
343  byteOrder(params.byte_order),
344  deviceId(id), configSize(config_size), deviceFeatures(features),
345  _deviceStatus(0), _queueSelect(0)
346 {
347 }
348 
349 
351 {
352 }
353 
354 void
356 {
360  for (QueueID i = 0; i < _queues.size(); ++i)
361  _queues[i]->serializeSection(cp, csprintf("_queues.%i", i));
362 }
363 
364 void
366 {
370  for (QueueID i = 0; i < _queues.size(); ++i)
371  _queues[i]->unserializeSection(cp, csprintf("_queues.%i", i));
372 }
373 
374 void
376 {
377  _queueSelect = 0;
378  guestFeatures = 0;
379  _deviceStatus = 0;
380 
381  for (QueueID i = 0; i < _queues.size(); ++i)
382  _queues[i]->reset();
383 }
384 
385 void
387 {
388  DPRINTF(VIO, "onNotify: idx: %i\n", idx);
389  if (idx >= _queues.size()) {
390  panic("Guest tried to notify queue (%i), but only %i "
391  "queues registered.\n",
392  idx, _queues.size());
393  }
394  _queues[idx]->onNotify();
395 }
396 
397 void
399 {
400  DPRINTF(VIO, "Setting guest features: 0x%x\n", features);
401  if (~deviceFeatures & features) {
402  panic("Guest tried to enable unsupported features:\n"
403  "Device features: 0x%x\n"
404  "Requested features: 0x%x\n",
405  deviceFeatures, features);
406  }
407  guestFeatures = features;
408 }
409 
410 
411 void
413 {
415  DPRINTF(VIO, "ACK: %i, DRIVER: %i, DRIVER_OK: %i, FAILED: %i\n",
416  status.acknowledge, status.driver, status.driver_ok, status.failed);
417  if (status == 0)
418  reset();
419 }
420 
421 void
423 {
424  panic("Unhandled device config read (offset: 0x%x).\n", cfgOffset);
425 }
426 
427 void
429 {
430  panic("Unhandled device config write (offset: 0x%x).\n", cfgOffset);
431 }
432 
433 void
434 VirtIODeviceBase::readConfigBlob(PacketPtr pkt, Addr cfgOffset, const uint8_t *cfg)
435 {
436  const unsigned size(pkt->getSize());
437 
438  if (cfgOffset + size > configSize)
439  panic("Config read out of bounds.\n");
440 
441  pkt->makeResponse();
442  pkt->setData(const_cast<uint8_t *>(cfg) + cfgOffset);
443 }
444 
445 void
446 VirtIODeviceBase::writeConfigBlob(PacketPtr pkt, Addr cfgOffset, uint8_t *cfg)
447 {
448  const unsigned size(pkt->getSize());
449 
450  if (cfgOffset + size > configSize)
451  panic("Config write out of bounds.\n");
452 
453  pkt->makeResponse();
454  pkt->writeData((uint8_t *)cfg + cfgOffset);
455 }
456 
457 
458 const VirtQueue &
460 {
461  if (_queueSelect >= _queues.size())
462  panic("Guest tried to access non-existing VirtQueue (%i).\n", _queueSelect);
463 
464  return *_queues[_queueSelect];
465 }
466 
467 VirtQueue &
469 {
470  if (_queueSelect >= _queues.size())
471  panic("Guest tried to access non-existing VirtQueue (%i).\n", _queueSelect);
472 
473  return *_queues[_queueSelect];
474 }
475 
476 void
478 {
480 }
481 
482 uint32_t
484 {
485  Addr address(getCurrentQueue().getAddress());
486  assert(!(address & ((1 >> VirtQueue::ALIGN_BITS) - 1)));
487  return address >> VirtQueue::ALIGN_BITS;
488 }
489 
490 void
492 {
493  _queues.push_back(&queue);
494 }
495 
496 
497 VirtIODummyDevice::VirtIODummyDevice(const VirtIODummyDeviceParams &params)
498  : VirtIODeviceBase(params, ID_INVALID, 0, 0)
499 {
500 }
501 
502 } // namespace gem5
gem5::VirtIODeviceBase::getCurrentQueue
const VirtQueue & getCurrentQueue() const
Convenience method to get the currently selected queue.
Definition: base.cc:459
gem5::VirtQueue::used
VirtRing< struct vring_used_elem > used
Ring of used (outgoing) descriptors.
Definition: base.hh:566
gem5::ArmISA::len
Bitfield< 18, 16 > len
Definition: misc_types.hh:444
gem5::PortProxy::writeBlob
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
Definition: port_proxy.hh:192
gem5::VirtIODeviceBase::writeConfigBlob
void writeConfigBlob(PacketPtr pkt, Addr cfgOffset, uint8_t *cfg)
Write configuration data to a device structure.
Definition: base.cc:446
gem5::VirtIODeviceBase::~VirtIODeviceBase
virtual ~VirtIODeviceBase()
Definition: base.cc:350
gem5::VirtDescriptor::write
void write(size_t offset, const uint8_t *src, size_t size)
Write to the contents of a descriptor.
Definition: base.cc:160
gem5::VirtDescriptor::dumpChain
void dumpChain() const
Dump the contents of a descriptor chain starting at this descriptor.
Definition: base.cc:126
data
const char data[]
Definition: circlebuf.test.cc:48
serialize.hh
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:575
gem5::VirtDescriptor::index
Index index() const
Get the descriptor's index into the virtqueue.
Definition: base.hh:144
gem5::VirtQueue::VirtRing::read
void read()
Definition: base.hh:520
gem5::VirtDescriptor::operator=
VirtDescriptor & operator=(VirtDescriptor &&rhs) noexcept
Definition: base.cc:66
gem5::MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:47
gem5::VirtDescriptor::desc
vring_desc desc
Underlying descriptor.
Definition: base.hh:290
gem5::Packet::setData
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
Definition: packet.hh:1252
gem5::VirtDescriptor::hasNext
bool hasNext() const
Is this descriptor chained to another descriptor?
Definition: base.hh:220
gem5::VirtIODeviceBase::DeviceId
uint16_t DeviceId
Device Type (sometimes known as subsystem ID)
Definition: base.hh:599
gem5::VirtQueue::getAddress
Addr getAddress() const
Get the guest physical address of this queue.
Definition: base.hh:335
vring_desc::addr
uint64_t addr
Definition: virtio_ring.h:65
gem5::VirtDescriptor::Index
uint16_t Index
Descriptor index in virtqueue.
Definition: base.hh:121
gem5::VirtDescriptor::isIncoming
bool isIncoming() const
Check if this is a read-only descriptor (incoming data).
Definition: base.hh:230
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::VirtIODeviceBase::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: base.cc:365
gem5::VirtDescriptor::update
void update()
Populate this descriptor with data from the guest.
Definition: base.cc:78
gem5::VirtQueue::reset
void reset()
Reset cached state in this queue and in the associated ring buffers.
Definition: base.cc:262
gem5::VirtDescriptor::queue
VirtQueue * queue
Pointer to virtqueue owning this descriptor.
Definition: base.hh:281
gem5::VirtQueue::dump
void dump() const
Dump the contents of a queue.
Definition: base.cc:318
gem5::Serializable::serializeSection
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
Definition: serialize.cc:74
gem5::VirtIODeviceBase::_queueSelect
QueueID _queueSelect
Queue select register (set by guest)
Definition: base.hh:897
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:64
gem5::VirtIODeviceBase::configSize
const size_t configSize
Size of the device's configuration space.
Definition: base.hh:876
gem5::VirtQueue::ALIGN_BITS
static const Addr ALIGN_BITS
Page size used by VirtIO. It's hard-coded to 4096 bytes in the spec for historical reasons.
Definition: base.hh:430
vring_desc::len
uint32_t len
Definition: virtio_ring.h:67
gem5::VirtIODeviceBase::writeConfig
virtual void writeConfig(PacketPtr pkt, Addr cfgOffset)
Write to the configuration space of a device.
Definition: base.cc:428
gem5::ArmISA::byteOrder
ByteOrder byteOrder(const ThreadContext *tc)
Definition: utility.hh:412
gem5::csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
gem5::VirtDescriptor::chainWrite
void chainWrite(size_t offset, const uint8_t *src, size_t size)
Write to a descriptor chain.
Definition: base.cc:195
gem5::VirtIODeviceBase::setGuestFeatures
void setGuestFeatures(FeatureBits features)
Set feature bits accepted by the guest driver.
Definition: base.cc:398
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::VirtDescriptor::dump
void dump() const
Dump the contents of a descriptor.
Definition: base.cc:109
gem5::VirtQueue::VirtRing::reset
void reset()
Reset any state in the ring buffer.
Definition: base.hh:486
gem5::VirtIODeviceBase::readConfigBlob
void readConfigBlob(PacketPtr pkt, Addr cfgOffset, const uint8_t *cfg)
Read configuration data from a device structure.
Definition: base.cc:434
gem5::VirtDescriptor::next
VirtDescriptor * next() const
Get the pointer to the next descriptor in a chain.
Definition: base.cc:138
base.hh
gem5::VirtDescriptor::isOutgoing
bool isOutgoing() const
Check if this is a write-only descriptor (outgoing data).
Definition: base.hh:232
gem5::VirtIODeviceBase::reset
virtual void reset()
Driver-request device reset.
Definition: base.cc:375
gem5::SimObject::Params
SimObjectParams Params
Definition: sim_object.hh:170
gem5::VirtIODeviceBase::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: base.cc:355
gem5::VirtQueue
Base wrapper around a virtqueue.
Definition: base.hh:302
gem5::VirtQueue::onNotify
virtual void onNotify()
Notify queue of pending events.
Definition: base.cc:328
gem5::VirtQueue::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: base.cc:242
gem5::Serializable::unserializeSection
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
Definition: serialize.cc:81
gem5::VirtDescriptor::chainSize
size_t chainSize() const
Retrieve the size of this descriptor chain.
Definition: base.cc:218
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::VirtIODeviceBase::registerQueue
void registerQueue(VirtQueue &queue)
Register a new VirtQueue with the device model.
Definition: base.cc:491
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::VirtIODeviceBase::setQueueAddress
void setQueueAddress(uint32_t address)
Change the host physical address of the currently active queue.
Definition: base.cc:477
gem5::ArmISA::d
Bitfield< 9 > d
Definition: misc_types.hh:63
gem5::VirtIODeviceBase::_queues
std::vector< VirtQueue * > _queues
List of virtual queues supported by this device.
Definition: base.hh:900
gem5::PowerISA::bo
Bitfield< 25, 21 > bo
Definition: types.hh:82
gem5::VirtIODeviceBase::_deviceStatus
DeviceStatus _deviceStatus
Status of the device.
Definition: base.hh:894
gem5::VirtQueue::setAddress
void setAddress(Addr address)
Set the base address of this queue.
Definition: base.cc:272
gem5::VirtDescriptor::memProxy
PortProxy * memProxy
Pointer to memory proxy.
Definition: base.hh:279
gem5::VirtIODeviceBase::deviceFeatures
const FeatureBits deviceFeatures
Feature set offered by the device.
Definition: base.hh:879
gem5::VirtDescriptor::size
size_t size() const
Retrieve the size of this descriptor.
Definition: base.hh:213
gem5::VirtQueue::VirtRing::readHeader
void readHeader()
Update the ring buffer header with data from the guest.
Definition: base.hh:501
gem5::gtoh
T gtoh(T value, ByteOrder guest_byte_order)
Definition: byteswap.hh:194
gem5::VirtIODeviceBase::guestFeatures
FeatureBits guestFeatures
Feature set accepted by the guest.
Definition: base.hh:668
gem5::PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:86
gem5::VirtIODummyDevice::VirtIODummyDevice
VirtIODummyDevice(const VirtIODummyDeviceParams &params)
Definition: base.cc:497
gem5::ArmISA::offset
Bitfield< 23, 0 > offset
Definition: types.hh:144
gem5::VirtDescriptor::byteOrder
ByteOrder byteOrder
The byte order the descriptor is stored in.
Definition: base.hh:284
gem5::VirtIODeviceBase
Base class for all VirtIO-based devices.
Definition: base.hh:587
gem5::VirtIODeviceBase::onNotify
void onNotify(QueueID index)
Driver is requesting service.
Definition: base.cc:386
gem5::PortProxy::readBlob
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
Definition: port_proxy.hh:182
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::Packet::writeData
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
Definition: packet.hh:1281
vring_avail
Definition: virtio_ring.h:74
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::VirtQueue::descriptors
std::vector< VirtDescriptor > descriptors
Vector of pre-created descriptors indexed by their index into the queue.
Definition: base.hh:574
gem5::VirtQueue::VirtRing::header
Header header
Ring buffer header in host byte order.
Definition: base.hh:547
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:568
DDUMP
#define DDUMP(x, data, count)
DPRINTF is a debugging trace facility that allows one to selectively enable tracing statements.
Definition: trace.hh:180
gem5::VirtQueue::VirtRing::setAddress
void setAddress(Addr addr)
Set the base address of the VirtIO ring buffer.
Definition: base.hh:497
gem5::VirtQueue::_size
const uint16_t _size
Queue size in terms of number of descriptors.
Definition: base.hh:453
gem5::VirtIODeviceBase::FeatureBits
uint32_t FeatureBits
Definition: base.hh:591
gem5::VirtDescriptor::_index
Index _index
Index in virtqueue.
Definition: base.hh:287
vring_desc::next
uint16_t next
Definition: virtio_ring.h:71
vring_desc::flags
uint16_t flags
Definition: virtio_ring.h:69
vring_desc
Definition: virtio_ring.h:62
gem5::VirtQueue::avail
VirtRing< VirtDescriptor::Index > avail
Ring of available (incoming) descriptors.
Definition: base.hh:564
gem5::VirtQueue::onNotifyDescriptor
virtual void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
Definition: base.hh:415
gem5::VirtDescriptor
VirtIO descriptor (chain) wrapper.
Definition: base.hh:117
gem5::VirtQueue::ALIGN_SIZE
static const Addr ALIGN_SIZE
Definition: base.hh:431
vring_used_elem
Definition: virtio_ring.h:82
gem5::VirtQueue::produceDescriptor
void produceDescriptor(VirtDescriptor *desc, uint32_t len)
Send a descriptor chain to the guest.
Definition: base.cc:304
gem5::VirtQueue::getDescriptor
VirtDescriptor * getDescriptor(VirtDescriptor::Index index)
Get a pointer to a specific descriptor in the queue.
Definition: base.hh:353
gem5::VirtQueue::VirtQueue
VirtQueue()
gem5::Packet::makeResponse
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
Definition: packet.hh:1031
gem5::paramIn
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
Definition: types.cc:72
gem5::VirtDescriptor::VirtDescriptor
VirtDescriptor()
gem5::VirtQueue::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: base.cc:249
gem5::VirtDescriptor::chainRead
void chainRead(size_t offset, uint8_t *dst, size_t size) const
Read the contents of a descriptor chain.
Definition: base.cc:172
gem5::VirtIODeviceBase::VirtIODeviceBase
VirtIODeviceBase(const Params &params, DeviceId id, size_t config_size, FeatureBits features)
Definition: base.cc:339
gem5::ArmISA::id
Bitfield< 33 > id
Definition: misc_types.hh:250
gem5::VirtQueue::_address
Addr _address
Base address of the queue.
Definition: base.hh:455
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::VirtDescriptor::~VirtDescriptor
~VirtDescriptor() noexcept
Definition: base.cc:61
gem5::VirtIODeviceBase::QueueID
uint16_t QueueID
Definition: base.hh:590
trace.hh
gem5::VirtQueue::_last_avail
uint16_t _last_avail
Offset of last consumed descriptor in the VirtQueue::avail ring.
Definition: base.hh:570
gem5::VirtQueue::VirtRing::ring
std::vector< T > ring
Elements in ring in host byte order.
Definition: base.hh:549
gem5::VirtIODeviceBase::getQueueAddress
uint32_t getQueueAddress() const
Get the host physical address of the currently active queue.
Definition: base.cc:483
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::VirtDescriptor::read
void read(size_t offset, uint8_t *dst, size_t size) const
Read the contents of a descriptor.
Definition: base.cc:148
gem5::VirtQueue::consumeDescriptor
VirtDescriptor * consumeDescriptor()
Get an incoming descriptor chain from the queue.
Definition: base.cc:285
gem5::VirtDescriptor::updateChain
void updateChain()
Populate this descriptor chain with data from the guest.
Definition: base.cc:97
gem5::VirtQueue::VirtRing::write
void write()
Definition: base.hh:533
gem5::VirtIODeviceBase::readConfig
virtual void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
Definition: base.cc:422
gem5::Packet::getSize
unsigned getSize() const
Definition: packet.hh:791
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177
gem5::VirtIODeviceBase::setDeviceStatus
void setDeviceStatus(DeviceStatus status)
Update device status and optionally reset device.
Definition: base.cc:412
gem5::ArmISA::status
Bitfield< 5, 0 > status
Definition: misc_types.hh:422

Generated on Tue Sep 21 2021 12:25:00 for gem5 by doxygen 1.8.17