gem5  v20.1.0.0
block.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 #ifndef __DEV_VIRTIO_BLOCK_HH__
39 #define __DEV_VIRTIO_BLOCK_HH__
40 
41 #include "dev/virtio/base.hh"
43 
44 struct VirtIOBlockParams;
45 
67 {
68  public:
69  typedef VirtIOBlockParams Params;
71  virtual ~VirtIOBlock();
72 
73  void readConfig(PacketPtr pkt, Addr cfgOffset);
74 
75  protected:
76  static const DeviceId ID_BLOCK = 0x02;
77 
84  struct Config {
85  uint64_t capacity;
88 
92  static const FeatureBits F_SIZE_MAX = (1 << 1);
93  static const FeatureBits F_SEG_MAX = (1 << 2);
94  static const FeatureBits F_GEOMETRY = (1 << 4);
95  static const FeatureBits F_RO = (1 << 5);
96  static const FeatureBits F_BLK_SIZE = (1 << 6);
97  static const FeatureBits F_TOPOLOGY = (1 << 10);
103  typedef uint32_t RequestType;
105  static const RequestType T_IN = 0;
107  static const RequestType T_OUT = 1;
109  static const RequestType T_FLUSH = 4;
115  typedef uint8_t Status;
117  static const Status S_OK = 0;
119  static const Status S_IOERR = 1;
121  static const Status S_UNSUPP = 2;
125  struct BlkRequest {
127  uint32_t reserved;
128  uint64_t sector;
129  } M5_ATTR_PACKED;
130 
141  Status read(const BlkRequest &req, VirtDescriptor *desc_chain,
142  size_t off_data, size_t size);
153  Status write(const BlkRequest &req, VirtDescriptor *desc_chain,
154  size_t off_data, size_t size);
155 
156  protected:
161  : public VirtQueue
162  {
163  public:
164  RequestQueue(PortProxy &proxy, ByteOrder bo,
165  uint16_t size, VirtIOBlock &_parent)
166  : VirtQueue(proxy, bo, size), parent(_parent) {}
167  virtual ~RequestQueue() {}
168 
170 
171  std::string name() const { return parent.name() + ".qRequests"; }
172 
173  protected:
175  };
176 
179 
182 };
183 
184 #endif // __DEV_VIRTIO_BLOCK_HH__
VirtIOBlock::Config::capacity
uint64_t capacity
Definition: block.hh:85
VirtIOBlock::RequestQueue::RequestQueue
RequestQueue(PortProxy &proxy, ByteOrder bo, uint16_t size, VirtIOBlock &_parent)
Definition: block.hh:164
VirtIOBlock::VirtIOBlock
VirtIOBlock(Params *params)
Definition: block.cc:44
VirtIOBlock::Config
Block device configuration structure.
Definition: block.hh:84
VirtIOBlock::S_OK
static const Status S_OK
Request succeeded.
Definition: block.hh:117
VirtQueue
Base wrapper around a virtqueue.
Definition: base.hh:291
VirtIOBlock::qRequests
RequestQueue qRequests
Device I/O request queue.
Definition: block.hh:178
VirtIOBlock::read
Status read(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device read request.
Definition: block.cc:70
VirtIOBlock::~VirtIOBlock
virtual ~VirtIOBlock()
Definition: block.cc:56
VirtIOBlock::BlkRequest
VirtIO block device request as sent by guest.
Definition: block.hh:125
VirtIOBlock::F_SIZE_MAX
static const FeatureBits F_SIZE_MAX
Definition: block.hh:92
VirtIOBlock
VirtIO block device.
Definition: block.hh:66
VirtIOBlock::T_FLUSH
static const RequestType T_FLUSH
Flush device buffers.
Definition: block.hh:109
VirtIOBlock::RequestQueue::~RequestQueue
virtual ~RequestQueue()
Definition: block.hh:167
VirtIOBlock::F_TOPOLOGY
static const FeatureBits F_TOPOLOGY
Definition: block.hh:97
disk_image.hh
VirtIOBlock::BlkRequest::reserved
uint32_t reserved
Definition: block.hh:127
VirtIOBlock::Status
uint8_t Status
Definition: block.hh:115
VirtIODeviceBase
Base class for all VirtIO-based devices.
Definition: base.hh:558
PowerISA::bo
Bitfield< 25, 21 > bo
Definition: types.hh:62
VirtIOBlock::RequestQueue::parent
VirtIOBlock & parent
Definition: block.hh:174
VirtIODeviceBase::DeviceId
uint16_t DeviceId
Device Type (sometimes known as subsystem ID)
Definition: base.hh:570
VirtIOBlock::image
DiskImage & image
Image backing this device.
Definition: block.hh:181
VirtIOBlock::Params
VirtIOBlockParams Params
Definition: block.hh:69
VirtIOBlock::RequestQueue
Virtqueue for disk requests.
Definition: block.hh:160
base.hh
VirtIOBlock::BlkRequest::type
RequestType type
Definition: block.hh:126
DiskImage
Basic interface for accessing a disk image.
Definition: disk_image.hh:49
VirtIOBlock::write
Status write(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device write request.
Definition: block.cc:96
VirtIOBlock::T_IN
static const RequestType T_IN
Read request.
Definition: block.hh:105
VirtIOBlock::config
Config config
Definition: block.hh:87
VirtIOBlock::T_OUT
static const RequestType T_OUT
Write request.
Definition: block.hh:107
VirtIOBlock::F_GEOMETRY
static const FeatureBits F_GEOMETRY
Definition: block.hh:94
VirtIOBlock::readConfig
void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
Definition: block.cc:61
VirtIOBlock::F_RO
static const FeatureBits F_RO
Definition: block.hh:95
VirtIODeviceBase::FeatureBits
uint32_t FeatureBits
Definition: base.hh:562
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
VirtIOBlock::RequestQueue::name
std::string name() const
Definition: block.hh:171
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
VirtIOBlock::ID_BLOCK
static const DeviceId ID_BLOCK
Definition: block.hh:76
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
VirtIOBlock::F_BLK_SIZE
static const FeatureBits F_BLK_SIZE
Definition: block.hh:96
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
VirtIOBlock::M5_ATTR_PACKED
struct VirtIOBlock::Config M5_ATTR_PACKED
VirtIOBlock::F_SEG_MAX
static const FeatureBits F_SEG_MAX
Definition: block.hh:93
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
VirtIOBlock::S_UNSUPP
static const Status S_UNSUPP
Request not supported.
Definition: block.hh:121
VirtIOBlock::RequestQueue::onNotifyDescriptor
void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
Definition: block.cc:124
VirtIOBlock::BlkRequest::sector
uint64_t sector
Definition: block.hh:128
VirtIOBlock::S_IOERR
static const Status S_IOERR
Request failed due to a device error.
Definition: block.hh:119
VirtIOBlock::RequestType
uint32_t RequestType
Definition: block.hh:103
VirtDescriptor
VirtIO descriptor (chain) wrapper.
Definition: base.hh:106

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17