2 * Copyright (c) 2008 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * Device model for Intel's I/O Acceleration Technology (I/OAT).
33 * A DMA asyncronous copy engine
36 #ifndef __DEV_COPY_ENGINE_HH__
37 #define __DEV_COPY_ENGINE_HH__
41 #include "base/statistics.hh"
42 #include "dev/copy_engine_defs.hh"
43 #include "dev/pcidev.hh"
44 #include "params/CopyEngine.hh"
45 #include "sim/eventq.hh"
47 class CopyEngine : public PciDev
49 class CopyEngineChannel
54 CopyEngineReg::ChanRegs cr;
56 CopyEngineReg::DmaDesc *curDmaDesc;
62 Addr lastDescriptorAddr;
66 Tick latAfterCompletion;
68 uint64_t completionDataReg;
79 ChannelState nextState;
83 CopyEngineChannel(CopyEngine *_ce, int cid);
84 virtual ~CopyEngineChannel();
87 std::string name() { assert(ce); return ce->name() + csprintf("-chan%d", channelId); }
88 virtual Tick read(PacketPtr pkt)
89 { panic("CopyEngineChannel has no I/O access\n");}
90 virtual Tick write(PacketPtr pkt)
91 { panic("CopyEngineChannel has no I/O access\n"); }
93 void channelRead(PacketPtr pkt, Addr daddr, int size);
94 void channelWrite(PacketPtr pkt, Addr daddr, int size);
96 unsigned int drain(Event *de);
98 void serialize(std::ostream &os);
99 void unserialize(Checkpoint *cp, const std::string §ion);
102 void fetchDescriptor(Addr address);
103 void fetchDescComplete();
104 EventWrapper<CopyEngineChannel, &CopyEngineChannel::fetchDescComplete>
107 void fetchNextAddr(Addr address);
108 void fetchAddrComplete();
109 EventWrapper<CopyEngineChannel, &CopyEngineChannel::fetchAddrComplete>
112 void readCopyBytes();
113 void readCopyBytesComplete();
114 EventWrapper<CopyEngineChannel, &CopyEngineChannel::readCopyBytesComplete>
117 void writeCopyBytes();
118 void writeCopyBytesComplete();
119 EventWrapper <CopyEngineChannel, &CopyEngineChannel::writeCopyBytesComplete>
122 void writeCompletionStatus();
123 void writeStatusComplete();
124 EventWrapper <CopyEngineChannel, &CopyEngineChannel::writeStatusComplete>
128 void continueProcessing();
131 void restartStateMachine();
132 inline void anBegin(const char *s)
134 CPA::cpa()->hwBegin(CPA::FL_NONE, ce->sys,
135 channelId, "CopyEngine", s);
140 CPA::cpa()->hwWe(CPA::FL_NONE, ce->sys,
141 channelId, "CopyEngine", "DMAUnusedDescQ", channelId);
146 CPA::cpa()->hwDq(CPA::FL_NONE, ce->sys,
147 channelId, "CopyEngine", "DMAUnusedDescQ", channelId);
152 CPA::cpa()->hwDq(CPA::FL_NONE, ce->sys,
153 channelId, "CopyEngine", "DMAUnusedDescQ", channelId);
156 inline void anQ(const char * s, uint64_t id, int size = 1)
158 CPA::cpa()->hwQ(CPA::FL_NONE, ce->sys, channelId,
159 "CopyEngine", s, id, NULL, size);
166 Stats::Vector bytesCopied;
167 Stats::Vector copiesProcessed;
170 CopyEngineReg::Regs regs;
172 // Array of channels each one with regs/dma port/etc
173 std::vector<CopyEngineChannel*> chan;
176 typedef CopyEngineParams Params;
180 return dynamic_cast<const Params *>(_params);
182 CopyEngine(const Params *params);
188 virtual Tick read(PacketPtr pkt);
189 virtual Tick write(PacketPtr pkt);
191 virtual void serialize(std::ostream &os);
192 virtual void unserialize(Checkpoint *cp, const std::string §ion);
193 virtual unsigned int drain(Event *de);
194 virtual void resume();
197 #endif //__DEV_COPY_ENGINE_HH__