gem5  v22.1.0.0
copy_engine.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 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  * Copyright (c) 2008 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 /* @file
42  * Device model for Intel's I/O Acceleration Technology (I/OAT).
43  * A DMA asyncronous copy engine
44  */
45 
46 #ifndef __DEV_PCI_COPY_ENGINE_HH__
47 #define __DEV_PCI_COPY_ENGINE_HH__
48 
49 #include <vector>
50 
51 #include "base/statistics.hh"
53 #include "dev/pci/device.hh"
54 #include "params/CopyEngine.hh"
55 #include "sim/drain.hh"
56 #include "sim/eventq.hh"
57 
58 namespace gem5
59 {
60 
61 class CopyEngine : public PciDevice
62 {
63  class CopyEngineChannel : public Drainable, public Serializable
64  {
65  private:
69  int channelId;
71  uint8_t *copyBuffer;
72 
73  bool busy;
74  bool underReset;
78 
81 
83 
85  {
92  };
93 
95 
96  public:
97  CopyEngineChannel(CopyEngine *_ce, int cid);
98  virtual ~CopyEngineChannel();
99  Port &getPort();
100 
101  std::string
103  {
104  assert(ce);
105  return ce->name() + csprintf("-chan%d", channelId);
106  }
107 
108  virtual Tick read(PacketPtr pkt)
109  { panic("CopyEngineChannel has no I/O access\n");}
110  virtual Tick write(PacketPtr pkt)
111  { panic("CopyEngineChannel has no I/O access\n"); }
112 
113  void channelRead(PacketPtr pkt, Addr daddr, int size);
114  void channelWrite(PacketPtr pkt, Addr daddr, int size);
115 
116  DrainState drain() override;
117  void drainResume() override;
118 
119  void serialize(CheckpointOut &cp) const override;
120  void unserialize(CheckpointIn &cp) override;
121 
122  private:
123  void fetchDescriptor(Addr address);
124  void fetchDescComplete();
126 
127  void fetchNextAddr(Addr address);
128  void fetchAddrComplete();
130 
131  void readCopyBytes();
132  void readCopyBytesComplete();
134 
135  void writeCopyBytes();
136  void writeCopyBytesComplete();
138 
139  void writeCompletionStatus();
140  void writeStatusComplete();
142 
143 
144  void continueProcessing();
145  void recvCommand();
146  bool inDrain();
147  void restartStateMachine();
148  };
149 
150  private:
151 
153  {
155  const uint8_t& channel_count);
156 
160 
161  // device registers
163 
164  // Array of channels each one with regs/dma port/etc
166 
167  public:
169  CopyEngine(const Params &params);
170  ~CopyEngine();
171 
172  Port &getPort(const std::string &if_name,
173  PortID idx = InvalidPortID) override;
174 
175  Tick read(PacketPtr pkt) override;
176  Tick write(PacketPtr pkt) override;
177 
178  void serialize(CheckpointOut &cp) const override;
179  void unserialize(CheckpointIn &cp) override;
180 };
181 
182 } // namespace gem5
183 
184 #endif //__DEV_PCI_COPY_ENGINE_HH__
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: copy_engine.cc:687
EventFunctionWrapper addrCompleteEvent
Definition: copy_engine.hh:129
EventFunctionWrapper statusCompleteEvent
Definition: copy_engine.hh:141
virtual Tick write(PacketPtr pkt)
Definition: copy_engine.hh:110
copy_engine_reg::DmaDesc * curDmaDesc
Definition: copy_engine.hh:70
CopyEngineChannel(CopyEngine *_ce, int cid)
Definition: copy_engine.cc:83
EventFunctionWrapper readCompleteEvent
Definition: copy_engine.hh:133
void channelWrite(PacketPtr pkt, Addr daddr, int size)
Definition: copy_engine.cc:372
EventFunctionWrapper writeCompleteEvent
Definition: copy_engine.hh:137
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: copy_engine.cc:641
copy_engine_reg::ChanRegs cr
Definition: copy_engine.hh:68
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: copy_engine.cc:670
virtual Tick read(PacketPtr pkt)
Definition: copy_engine.hh:108
void drainResume() override
Resume execution after a successful drain.
Definition: copy_engine.cc:732
void channelRead(PacketPtr pkt, Addr daddr, int size)
Definition: copy_engine.cc:244
EventFunctionWrapper fetchCompleteEvent
Definition: copy_engine.hh:125
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: copy_engine.cc:294
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: copy_engine.cc:171
PARAMS(CopyEngine)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: copy_engine.cc:661
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: copy_engine.cc:652
std::vector< CopyEngineChannel * > chan
Definition: copy_engine.hh:165
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: copy_engine.cc:119
CopyEngine(const Params &params)
Definition: copy_engine.cc:64
gem5::CopyEngine::CopyEngineStats copyEngineStats
copy_engine_reg::Regs regs
Definition: copy_engine.hh:162
DmaDeviceParams Params
Definition: dma_device.hh:209
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:235
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
PCI device, base implementation is only config space.
Definition: device.hh:270
Ports are used to interface objects to each other.
Definition: port.hh:62
Basic support for object serialization.
Definition: serialize.hh:170
Statistics container.
Definition: group.hh:94
A vector of scalar stats.
Definition: statistics.hh:2007
STL vector class.
Definition: stl.hh:37
DrainState
Object drain/handover states.
Definition: drain.hh:75
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
const Params & params() const
Definition: sim_object.hh:176
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
Declaration of Statistics objects.
statistics::Vector copiesProcessed
Definition: copy_engine.hh:158
CopyEngineStats(statistics::Group *parent, const uint8_t &channel_count)
Definition: copy_engine.cc:434

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