gem5  v20.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 class CopyEngine : public PciDevice
59 {
60  class CopyEngineChannel : public Drainable, public Serializable
61  {
62  private:
66  int channelId;
68  uint8_t *copyBuffer;
69 
70  bool busy;
71  bool underReset;
75 
78 
80 
81  enum ChannelState {
88  };
89 
91 
92  public:
93  CopyEngineChannel(CopyEngine *_ce, int cid);
94  virtual ~CopyEngineChannel();
95  Port &getPort();
96 
97  std::string name() { assert(ce); return ce->name() + csprintf("-chan%d", channelId); }
98  virtual Tick read(PacketPtr pkt)
99  { panic("CopyEngineChannel has no I/O access\n");}
100  virtual Tick write(PacketPtr pkt)
101  { panic("CopyEngineChannel has no I/O access\n"); }
102 
103  void channelRead(PacketPtr pkt, Addr daddr, int size);
104  void channelWrite(PacketPtr pkt, Addr daddr, int size);
105 
106  DrainState drain() override;
107  void drainResume() override;
108 
109  void serialize(CheckpointOut &cp) const override;
110  void unserialize(CheckpointIn &cp) override;
111 
112  private:
113  void fetchDescriptor(Addr address);
114  void fetchDescComplete();
116 
117  void fetchNextAddr(Addr address);
118  void fetchAddrComplete();
120 
121  void readCopyBytes();
122  void readCopyBytesComplete();
124 
125  void writeCopyBytes();
126  void writeCopyBytesComplete();
128 
129  void writeCompletionStatus();
130  void writeStatusComplete();
132 
133 
134  void continueProcessing();
135  void recvCommand();
136  bool inDrain();
137  void restartStateMachine();
138  };
139 
140  private:
141 
144 
145  // device registers
147 
148  // Array of channels each one with regs/dma port/etc
150 
151  public:
152  typedef CopyEngineParams Params;
153  const Params *
154  params() const
155  {
156  return dynamic_cast<const Params *>(_params);
157  }
158  CopyEngine(const Params *params);
159  ~CopyEngine();
160 
161  void regStats() override;
162 
163  Port &getPort(const std::string &if_name,
164  PortID idx = InvalidPortID) override;
165 
166  Tick read(PacketPtr pkt) override;
167  Tick write(PacketPtr pkt) override;
168 
169  void serialize(CheckpointOut &cp) const override;
170  void unserialize(CheckpointIn &cp) override;
171 };
172 
173 #endif //__DEV_PCI_COPY_ENGINE_HH__
174 
CopyEngineReg::ChanRegs
Definition: copy_engine_defs.hh:144
CopyEngineReg::Regs
Definition: copy_engine_defs.hh:112
CopyEngine::CopyEngineChannel::continueProcessing
void continueProcessing()
Definition: copy_engine.cc:548
CopyEngine::chan
std::vector< CopyEngineChannel * > chan
Definition: copy_engine.hh:149
CopyEngine::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: copy_engine.cc:289
CopyEngine::regs
CopyEngineReg::Regs regs
Definition: copy_engine.hh:146
CopyEngine::CopyEngineChannel::latBeforeBegin
Tick latBeforeBegin
Definition: copy_engine.hh:76
CopyEngine::CopyEngineChannel::Idle
@ Idle
Definition: copy_engine.hh:82
CopyEngine::CopyEngineChannel::write
virtual Tick write(PacketPtr pkt)
Definition: copy_engine.hh:100
CopyEngine::CopyEngineChannel::DescriptorFetch
@ DescriptorFetch
Definition: copy_engine.hh:84
CopyEngine::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: copy_engine.cc:166
CopyEngine::CopyEngineChannel::completionDataReg
uint64_t completionDataReg
Definition: copy_engine.hh:79
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
CopyEngine::CopyEngineChannel::cePort
DmaPort cePort
Definition: copy_engine.hh:63
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
CopyEngine::CopyEngineChannel::nextState
ChannelState nextState
Definition: copy_engine.hh:90
CopyEngine::CopyEngineChannel::fetchDescComplete
void fetchDescComplete()
Definition: copy_engine.cc:466
CopyEngine::CopyEngineChannel::channelWrite
void channelWrite(PacketPtr pkt, Addr daddr, int size)
Definition: copy_engine.cc:367
CopyEngine::CopyEngineChannel::writeCopyBytes
void writeCopyBytes()
Definition: copy_engine.cc:515
CopyEngine::regStats
void regStats() override
Callback to set stat parameters.
Definition: copy_engine.cc:429
CopyEngineReg::DmaDesc
Definition: copy_engine_defs.hh:65
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
CopyEngine::CopyEngineChannel::fetchDescriptor
void fetchDescriptor(Addr address)
Definition: copy_engine.cc:449
CopyEngine::CopyEngineChannel::copyBuffer
uint8_t * copyBuffer
Definition: copy_engine.hh:68
CopyEngine::CopyEngineChannel::drain
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:637
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
CopyEngine::CopyEngineChannel::channelRead
void channelRead(PacketPtr pkt, Addr daddr, int size)
Definition: copy_engine.cc:239
CopyEngine::CopyEngineChannel::fetchAddress
Addr fetchAddress
Definition: copy_engine.hh:74
std::vector
STL vector class.
Definition: stl.hh:37
CopyEngine::CopyEngineChannel::name
std::string name()
Definition: copy_engine.hh:97
CopyEngine
Definition: copy_engine.hh:58
CopyEngine::CopyEngineChannel::underReset
bool underReset
Definition: copy_engine.hh:71
CopyEngine::CopyEngineChannel::channelId
int channelId
Definition: copy_engine.hh:66
Stats::Vector
A vector of scalar stats.
Definition: statistics.hh:2575
device.hh
CopyEngine::CopyEngineChannel::fetchCompleteEvent
EventFunctionWrapper fetchCompleteEvent
Definition: copy_engine.hh:115
CopyEngine::CopyEngineChannel::addrCompleteEvent
EventFunctionWrapper addrCompleteEvent
Definition: copy_engine.hh:119
CopyEngine::CopyEngineChannel::refreshNext
bool refreshNext
Definition: copy_engine.hh:72
CopyEngine::CopyEngineChannel::getPort
Port & getPort()
Definition: copy_engine.cc:130
CopyEngine::CopyEngineChannel::readCompleteEvent
EventFunctionWrapper readCompleteEvent
Definition: copy_engine.hh:123
EventFunctionWrapper
Definition: eventq.hh:1101
CopyEngine::bytesCopied
Stats::Vector bytesCopied
Definition: copy_engine.hh:142
CopyEngine::CopyEngine
CopyEngine(const Params *params)
Definition: copy_engine.cc:60
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
CopyEngine::CopyEngineChannel::CompletionWrite
@ CompletionWrite
Definition: copy_engine.hh:87
CopyEngine::CopyEngineChannel::writeCopyBytesComplete
void writeCopyBytesComplete()
Definition: copy_engine.cc:529
CopyEngine::params
const Params * params() const
Definition: copy_engine.hh:154
cp
Definition: cprintf.cc:40
CopyEngine::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: copy_engine.cc:114
CopyEngine::CopyEngineChannel::read
virtual Tick read(PacketPtr pkt)
Definition: copy_engine.hh:98
CopyEngine::CopyEngineChannel::AddressFetch
@ AddressFetch
Definition: copy_engine.hh:83
CopyEngine::CopyEngineChannel::busy
bool busy
Definition: copy_engine.hh:70
CopyEngine::CopyEngineChannel::curDmaDesc
CopyEngineReg::DmaDesc * curDmaDesc
Definition: copy_engine.hh:67
Drainable
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:230
CopyEngine::CopyEngineChannel::writeCompletionStatus
void writeCompletionStatus()
Definition: copy_engine.cc:577
CopyEngine::CopyEngineChannel::restartStateMachine
void restartStateMachine()
Definition: copy_engine.cc:702
statistics.hh
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
CopyEngine::CopyEngineChannel::readCopyBytesComplete
void readCopyBytesComplete()
Definition: copy_engine.cc:505
CopyEngine::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: copy_engine.cc:657
CopyEngine::CopyEngineChannel::fetchNextAddr
void fetchNextAddr(Addr address)
Definition: copy_engine.cc:597
CopyEngine::CopyEngineChannel::ce
CopyEngine * ce
Definition: copy_engine.hh:64
CopyEngine::CopyEngineChannel::CopyEngineChannel
CopyEngineChannel(CopyEngine *_ce, int cid)
Definition: copy_engine.cc:78
CopyEngine::CopyEngineChannel::cr
CopyEngineReg::ChanRegs cr
Definition: copy_engine.hh:65
CopyEngine::CopyEngineChannel::recvCommand
void recvCommand()
Definition: copy_engine.cc:136
CopyEngine::CopyEngineChannel
Definition: copy_engine.hh:60
CopyEngine::~CopyEngine
~CopyEngine()
Definition: copy_engine.cc:100
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
CopyEngine::CopyEngineChannel::lastDescriptorAddr
Addr lastDescriptorAddr
Definition: copy_engine.hh:73
CopyEngine::CopyEngineChannel::fetchAddrComplete
void fetchAddrComplete()
Definition: copy_engine.cc:608
CopyEngine::CopyEngineChannel::readCopyBytes
void readCopyBytes()
Definition: copy_engine.cc:495
CopyEngine::CopyEngineChannel::inDrain
bool inDrain()
Definition: copy_engine.cc:626
CopyEngine::CopyEngineChannel::ChannelState
ChannelState
Definition: copy_engine.hh:81
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
CopyEngine::CopyEngineChannel::latAfterCompletion
Tick latAfterCompletion
Definition: copy_engine.hh:77
CopyEngine::Params
CopyEngineParams Params
Definition: copy_engine.hh:152
CopyEngine::CopyEngineChannel::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: copy_engine.cc:666
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
CopyEngine::CopyEngineChannel::writeStatusComplete
void writeStatusComplete()
Definition: copy_engine.cc:590
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
CopyEngine::CopyEngineChannel::writeCompleteEvent
EventFunctionWrapper writeCompleteEvent
Definition: copy_engine.hh:127
CopyEngine::CopyEngineChannel::statusCompleteEvent
EventFunctionWrapper statusCompleteEvent
Definition: copy_engine.hh:131
CopyEngine::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: copy_engine.cc:648
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
CopyEngine::CopyEngineChannel::drainResume
void drainResume() override
Resume execution after a successful drain.
Definition: copy_engine.cc:728
drain.hh
CopyEngine::CopyEngineChannel::~CopyEngineChannel
virtual ~CopyEngineChannel()
Definition: copy_engine.cc:107
CopyEngine::copiesProcessed
Stats::Vector copiesProcessed
Definition: copy_engine.hh:143
CopyEngine::CopyEngineChannel::DMAWrite
@ DMAWrite
Definition: copy_engine.hh:86
CheckpointIn
Definition: serialize.hh:67
DmaPort
Definition: dma_device.hh:55
copy_engine_defs.hh
CopyEngine::CopyEngineChannel::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: copy_engine.cc:683
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
PciDevice
PCI device, base implementation is only config space.
Definition: device.hh:66
DmaDevice::Params
DmaDeviceParams Params
Definition: dma_device.hh:171
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
CopyEngine::CopyEngineChannel::DMARead
@ DMARead
Definition: copy_engine.hh:85
eventq.hh

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