gem5  v21.1.0.2
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 "base/compiler.hh"
43 #include "dev/virtio/base.hh"
44 
45 namespace gem5
46 {
47 
48 struct VirtIOBlockParams;
49 
71 {
72  public:
73  typedef VirtIOBlockParams Params;
74  VirtIOBlock(const Params &params);
75  virtual ~VirtIOBlock();
76 
77  void readConfig(PacketPtr pkt, Addr cfgOffset);
78 
79  protected:
80  static const DeviceId ID_BLOCK = 0x02;
81 
88  struct GEM5_PACKED Config
89  {
90  uint64_t capacity;
91  };
93 
97  static const FeatureBits F_SIZE_MAX = (1 << 1);
98  static const FeatureBits F_SEG_MAX = (1 << 2);
99  static const FeatureBits F_GEOMETRY = (1 << 4);
100  static const FeatureBits F_RO = (1 << 5);
101  static const FeatureBits F_BLK_SIZE = (1 << 6);
102  static const FeatureBits F_TOPOLOGY = (1 << 10);
108  typedef uint32_t RequestType;
110  static const RequestType T_IN = 0;
112  static const RequestType T_OUT = 1;
114  static const RequestType T_FLUSH = 4;
120  typedef uint8_t Status;
122  static const Status S_OK = 0;
124  static const Status S_IOERR = 1;
126  static const Status S_UNSUPP = 2;
130  struct GEM5_PACKED BlkRequest
131  {
133  uint32_t reserved;
134  uint64_t sector;
135  };
136 
147  Status read(const BlkRequest &req, VirtDescriptor *desc_chain,
148  size_t off_data, size_t size);
159  Status write(const BlkRequest &req, VirtDescriptor *desc_chain,
160  size_t off_data, size_t size);
161 
162  protected:
167  : public VirtQueue
168  {
169  public:
170  RequestQueue(PortProxy &proxy, ByteOrder bo,
171  uint16_t size, VirtIOBlock &_parent)
172  : VirtQueue(proxy, bo, size), parent(_parent) {}
173  virtual ~RequestQueue() {}
174 
176 
177  std::string name() const { return parent.name() + ".qRequests"; }
178 
179  protected:
181  };
182 
185 
188 };
189 
190 } // namespace gem5
191 
192 #endif // __DEV_VIRTIO_BLOCK_HH__
gem5::VirtIOBlock::RequestQueue::onNotifyDescriptor
void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
Definition: block.cc:127
gem5::VirtIOBlock::config
Config config
Definition: block.hh:92
gem5::VirtIOBlock::Params
VirtIOBlockParams Params
Definition: block.hh:73
gem5::VirtIOBlock::S_OK
static const Status S_OK
Request succeeded.
Definition: block.hh:122
gem5::VirtIODeviceBase::DeviceId
uint16_t DeviceId
Device Type (sometimes known as subsystem ID)
Definition: base.hh:599
disk_image.hh
gem5::VirtIOBlock::BlkRequest::reserved
uint32_t reserved
Definition: block.hh:133
gem5::VirtIOBlock::RequestQueue::name
std::string name() const
Definition: block.hh:177
gem5::VirtIOBlock
VirtIO block device.
Definition: block.hh:70
gem5::VirtIOBlock::F_SIZE_MAX
static const FeatureBits F_SIZE_MAX
Definition: block.hh:97
gem5::VirtIOBlock::VirtIOBlock
VirtIOBlock(const Params &params)
Definition: block.cc:47
gem5::VirtIOBlock::F_TOPOLOGY
static const FeatureBits F_TOPOLOGY
Definition: block.hh:102
gem5::DiskImage
Basic interface for accessing a disk image.
Definition: disk_image.hh:52
gem5::VirtIOBlock::qRequests
RequestQueue qRequests
Device I/O request queue.
Definition: block.hh:184
base.hh
gem5::VirtIOBlock::ID_BLOCK
static const DeviceId ID_BLOCK
Definition: block.hh:80
gem5::VirtQueue
Base wrapper around a virtqueue.
Definition: base.hh:302
gem5::VirtIOBlock::Config
Block device configuration structure.
Definition: block.hh:88
gem5::VirtIOBlock::RequestQueue::RequestQueue
RequestQueue(PortProxy &proxy, ByteOrder bo, uint16_t size, VirtIOBlock &_parent)
Definition: block.hh:170
gem5::VirtIOBlock::F_GEOMETRY
static const FeatureBits F_GEOMETRY
Definition: block.hh:99
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
gem5::VirtIOBlock::image
DiskImage & image
Image backing this device.
Definition: block.hh:187
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::PowerISA::bo
Bitfield< 25, 21 > bo
Definition: types.hh:82
gem5::VirtIOBlock::BlkRequest::sector
uint64_t sector
Definition: block.hh:134
gem5::VirtIOBlock::~VirtIOBlock
virtual ~VirtIOBlock()
Definition: block.cc:59
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::VirtIOBlock::F_BLK_SIZE
static const FeatureBits F_BLK_SIZE
Definition: block.hh:101
compiler.hh
gem5::VirtIODeviceBase
Base class for all VirtIO-based devices.
Definition: base.hh:587
gem5::VirtIOBlock::S_IOERR
static const Status S_IOERR
Request failed due to a device error.
Definition: block.hh:124
gem5::VirtIOBlock::RequestQueue::parent
VirtIOBlock & parent
Definition: block.hh:180
gem5::VirtIOBlock::T_IN
static const RequestType T_IN
Read request.
Definition: block.hh:110
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::VirtIOBlock::readConfig
void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
Definition: block.cc:64
gem5::VirtIOBlock::Config::capacity
uint64_t capacity
Definition: block.hh:90
gem5::VirtIODeviceBase::FeatureBits
uint32_t FeatureBits
Definition: base.hh:591
gem5::VirtDescriptor
VirtIO descriptor (chain) wrapper.
Definition: base.hh:117
gem5::VirtIOBlock::read
Status read(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device read request.
Definition: block.cc:73
gem5::VirtIOBlock::S_UNSUPP
static const Status S_UNSUPP
Request not supported.
Definition: block.hh:126
gem5::VirtIOBlock::T_OUT
static const RequestType T_OUT
Write request.
Definition: block.hh:112
gem5::VirtIOBlock::BlkRequest::type
RequestType type
Definition: block.hh:132
gem5::VirtIOBlock::F_RO
static const FeatureBits F_RO
Definition: block.hh:100
gem5::VirtIOBlock::RequestQueue
Virtqueue for disk requests.
Definition: block.hh:166
gem5::VirtIOBlock::Status
uint8_t Status
Definition: block.hh:120
gem5::VirtIOBlock::RequestType
uint32_t RequestType
Definition: block.hh:108
gem5::VirtIOBlock::F_SEG_MAX
static const FeatureBits F_SEG_MAX
Definition: block.hh:98
gem5::VirtIOBlock::BlkRequest
VirtIO block device request as sent by guest.
Definition: block.hh:130
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::VirtIOBlock::write
Status write(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device write request.
Definition: block.cc:99
gem5::VirtIOBlock::T_FLUSH
static const RequestType T_FLUSH
Flush device buffers.
Definition: block.hh:114
gem5::VirtIOBlock::RequestQueue::~RequestQueue
virtual ~RequestQueue()
Definition: block.hh:173

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