gem5  v22.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 "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 
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;
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__
Basic interface for accessing a disk image.
Definition: disk_image.hh:53
virtual std::string name() const
Definition: named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:87
VirtIO descriptor (chain) wrapper.
Definition: base.hh:118
Virtqueue for disk requests.
Definition: block.hh:168
void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
Definition: block.cc:127
std::string name() const
Definition: block.hh:177
RequestQueue(PortProxy &proxy, ByteOrder bo, uint16_t size, VirtIOBlock &_parent)
Definition: block.hh:170
VirtIO block device.
Definition: block.hh:71
uint32_t RequestType
Definition: block.hh:108
static const FeatureBits F_BLK_SIZE
Definition: block.hh:101
DiskImage & image
Image backing this device.
Definition: block.hh:187
static const FeatureBits F_SEG_MAX
Definition: block.hh:98
static const FeatureBits F_GEOMETRY
Definition: block.hh:99
static const RequestType T_OUT
Write request.
Definition: block.hh:112
static const DeviceId ID_BLOCK
Definition: block.hh:80
static const RequestType T_FLUSH
Flush device buffers.
Definition: block.hh:114
static const FeatureBits F_RO
Definition: block.hh:100
RequestQueue qRequests
Device I/O request queue.
Definition: block.hh:184
VirtIOBlock(const Params &params)
Definition: block.cc:47
static const Status S_UNSUPP
Request not supported.
Definition: block.hh:126
uint8_t Status
Definition: block.hh:120
VirtIOBlockParams Params
Definition: block.hh:73
static const FeatureBits F_TOPOLOGY
Definition: block.hh:102
static const Status S_IOERR
Request failed due to a device error.
Definition: block.hh:124
Status read(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device read request.
Definition: block.cc:73
virtual ~VirtIOBlock()
Definition: block.cc:59
static const FeatureBits F_SIZE_MAX
Definition: block.hh:97
Config config
Definition: block.hh:92
static const Status S_OK
Request succeeded.
Definition: block.hh:122
Status write(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device write request.
Definition: block.cc:99
void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
Definition: block.cc:64
static const RequestType T_IN
Read request.
Definition: block.hh:110
Base class for all VirtIO-based devices.
Definition: base.hh:588
uint32_t FeatureBits
Definition: base.hh:591
uint16_t DeviceId
Device Type (sometimes known as subsystem ID)
Definition: base.hh:599
Base wrapper around a virtqueue.
Definition: base.hh:303
Disk Image Interfaces.
const Params & params() const
Definition: sim_object.hh:176
Bitfield< 25, 21 > bo
Definition: types.hh:82
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
PM4 packets.
Definition: pm4_defines.hh:78
VirtIO block device request as sent by guest.
Definition: block.hh:131
Block device configuration structure.
Definition: block.hh:89

Generated on Wed Dec 21 2022 10:22:35 for gem5 by doxygen 1.9.1