gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Authors: Andreas Sandberg
38  */
39 
40 #ifndef __DEV_VIRTIO_BLOCK_HH__
41 #define __DEV_VIRTIO_BLOCK_HH__
42 
43 #include "dev/virtio/base.hh"
45 #include "dev/terminal.hh"
46 
47 struct VirtIOBlockParams;
48 
70 {
71  public:
72  typedef VirtIOBlockParams Params;
74  virtual ~VirtIOBlock();
75 
76  void readConfig(PacketPtr pkt, Addr cfgOffset);
77 
78  protected:
79  static const DeviceId ID_BLOCK = 0x02;
80 
87  struct Config {
88  uint64_t capacity;
91 
95  static const FeatureBits F_SIZE_MAX = (1 << 1);
96  static const FeatureBits F_SEG_MAX = (1 << 2);
97  static const FeatureBits F_GEOMETRY = (1 << 4);
98  static const FeatureBits F_RO = (1 << 5);
99  static const FeatureBits F_BLK_SIZE = (1 << 6);
100  static const FeatureBits F_TOPOLOGY = (1 << 10);
106  typedef uint32_t RequestType;
108  static const RequestType T_IN = 0;
110  static const RequestType T_OUT = 1;
112  static const RequestType T_FLUSH = 4;
118  typedef uint8_t Status;
120  static const Status S_OK = 0;
122  static const Status S_IOERR = 1;
124  static const Status S_UNSUPP = 2;
128  struct BlkRequest {
130  uint32_t reserved;
131  uint64_t sector;
132  } M5_ATTR_PACKED;
133 
144  Status read(const BlkRequest &req, VirtDescriptor *desc_chain,
145  size_t off_data, size_t size);
156  Status write(const BlkRequest &req, VirtDescriptor *desc_chain,
157  size_t off_data, size_t size);
158 
159  protected:
164  : public VirtQueue
165  {
166  public:
167  RequestQueue(PortProxy &proxy, uint16_t size, VirtIOBlock &_parent)
168  : VirtQueue(proxy, size), parent(_parent) {}
169  virtual ~RequestQueue() {}
170 
172 
173  std::string name() const { return parent.name() + ".qRequests"; }
174 
175  protected:
177  };
178 
181 
184 };
185 
186 #endif // __DEV_VIRTIO_BLOCK_HH__
RequestType type
Definition: block.hh:129
VirtIOBlock & parent
Definition: block.hh:176
Base class for all VirtIO-based devices.
Definition: base.hh:570
static const FeatureBits F_TOPOLOGY
Definition: block.hh:100
Status read(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device read request.
Definition: block.cc:71
virtual ~VirtIOBlock()
Definition: block.cc:57
VirtIOBlock(Params *params)
Definition: block.cc:46
std::string name() const
Definition: block.hh:173
DiskImage & image
Image backing this device.
Definition: block.hh:183
VirtIOBlockParams Params
Definition: block.hh:72
static const FeatureBits F_SIZE_MAX
Definition: block.hh:95
Virtqueue for disk requests.
Definition: block.hh:163
RequestQueue(PortProxy &proxy, uint16_t size, VirtIOBlock &_parent)
Definition: block.hh:167
static const RequestType T_FLUSH
Flush device buffers.
Definition: block.hh:112
const Params * params() const
Definition: sim_object.hh:111
Block device configuration structure.
Definition: block.hh:87
uint8_t Status
Definition: block.hh:118
Status write(const BlkRequest &req, VirtDescriptor *desc_chain, size_t off_data, size_t size)
Device write request.
Definition: block.cc:97
static const RequestType T_OUT
Write request.
Definition: block.hh:110
VirtIO block device request as sent by guest.
Definition: block.hh:128
virtual ~RequestQueue()
Definition: block.hh:169
Config config
Definition: block.hh:90
static const FeatureBits F_GEOMETRY
Definition: block.hh:97
static const FeatureBits F_RO
Definition: block.hh:98
static const RequestType T_IN
Read request.
Definition: block.hh:108
VirtIO descriptor (chain) wrapper.
Definition: base.hh:136
uint64_t capacity
Definition: block.hh:88
void onNotifyDescriptor(VirtDescriptor *desc)
Notify queue of pending incoming descriptor.
Definition: block.cc:125
Basic interface for accessing a disk image.
Definition: disk_image.hh:51
static const DeviceId ID_BLOCK
Definition: block.hh:79
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
void readConfig(PacketPtr pkt, Addr cfgOffset)
Read from the configuration space of a device.
Definition: block.cc:62
static const FeatureBits F_BLK_SIZE
Definition: block.hh:99
This object is a proxy for a structural port, to be used for debug accesses.
Definition: port_proxy.hh:84
static const Status S_IOERR
Request failed due to a device error.
Definition: block.hh:122
int size()
Definition: pagetable.hh:146
virtual const std::string name() const
Definition: sim_object.hh:117
static const FeatureBits F_SEG_MAX
Definition: block.hh:96
uint16_t DeviceId
Device Type (sometimes known as subsystem ID)
Definition: base.hh:582
Disk Image Interfaces.
struct VirtIOBlock::Config M5_ATTR_PACKED
VirtIO block device.
Definition: block.hh:69
uint32_t RequestType
Definition: block.hh:106
static const Status S_OK
Request succeeded.
Definition: block.hh:120
Base wrapper around a virtqueue.
Definition: base.hh:317
RequestQueue qRequests
Device I/O request queue.
Definition: block.hh:180
static const Status S_UNSUPP
Request not supported.
Definition: block.hh:124
uint32_t FeatureBits
Definition: base.hh:574

Generated on Fri Jun 9 2017 13:03:47 for gem5 by doxygen 1.8.6