0a83790956edce9691ca02723eaf66b024fb5078
2 * Copyright (c) 2006 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.
29 #include "base/trace.hh"
30 #include "dev/io_device.hh"
31 #include "sim/builder.hh"
34 PioPort::PioPort(PioDevice
*dev
, Platform
*p
)
35 : Port(dev
->name() + "-pioport"), device(dev
), platform(p
)
40 PioPort::recvAtomic(Packet
*pkt
)
42 return device
->recvAtomic(pkt
);
46 PioPort::recvFunctional(Packet
*pkt
)
48 device
->recvAtomic(pkt
);
52 PioPort::getDeviceAddressRanges(AddrRangeList
&resp
, AddrRangeList
&snoop
)
55 device
->addressRanges(resp
);
62 Packet
* pkt
= transmitList
.front();
63 if (Port::sendTiming(pkt
)) {
64 transmitList
.pop_front();
70 PioPort::SendEvent::process()
72 if (port
->Port::sendTiming(packet
))
75 port
->transmitList
.push_back(packet
);
81 PioPort::recvTiming(Packet
*pkt
)
83 Tick latency
= device
->recvAtomic(pkt
);
84 // turn packet around to go back to requester
85 pkt
->makeTimingResponse();
86 sendTiming(pkt
, latency
);
90 PioDevice::~PioDevice()
100 panic("Pio port not connected to anything!");
101 pioPort
->sendStatusChange(Port::RangeChange
);
105 BasicPioDevice::addressRanges(AddrRangeList
&range_list
)
107 assert(pioSize
!= 0);
109 range_list
.push_back(RangeSize(pioAddr
, pioSize
));
113 DmaPort::DmaPort(DmaDevice
*dev
, Platform
*p
)
114 : Port(dev
->name() + "-dmaport"), device(dev
), platform(p
), pendingCount(0)
118 DmaPort::recvTiming(Packet
*pkt
)
120 if (pkt
->senderState
) {
122 DPRINTF(DMA
, "Received response Packet %#x with senderState: %#x\n",
123 pkt
, pkt
->senderState
);
124 state
= dynamic_cast<DmaReqState
*>(pkt
->senderState
);
126 state
->completionEvent
->process();
130 DPRINTF(DMA
, "Received response Packet %#x with no senderState\n", pkt
);
138 DmaDevice::DmaDevice(Params
*p
)
139 : PioDevice(p
), dmaPort(NULL
)
145 Packet
* pkt
= transmitList
.front();
146 DPRINTF(DMA
, "Retry on Packet %#x with senderState: %#x\n",
147 pkt
, pkt
->senderState
);
148 if (sendTiming(pkt
)) {
149 DPRINTF(DMA
, "-- Done\n");
150 transmitList
.pop_front();
152 assert(pendingCount
>= 0);
154 DPRINTF(DMA
, "-- Failed, queued\n");
160 DmaPort::dmaAction(Packet::Command cmd
, Addr addr
, int size
, Event
*event
,
167 for (ChunkGenerator
gen(addr
, size
, peerBlockSize());
168 !gen
.done(); gen
.next()) {
169 Request
*req
= new Request(false);
170 req
->setPaddr(gen
.addr());
171 req
->setSize(gen
.size());
172 req
->setTime(curTick
);
173 Packet
*pkt
= new Packet(req
, cmd
, Packet::Broadcast
);
175 // Increment the data pointer on a write
177 pkt
->dataStatic(data
+ prevSize
) ;
179 prevSize
+= gen
.size();
181 // Set the last bit of the dma as the final packet for this dma
182 // and set it's completion event.
183 if (prevSize
== size
) {
184 pkt
->senderState
= new DmaReqState(event
, true);
186 assert(pendingCount
>= 0);
194 DmaPort::sendDma(Packet
*pkt
)
196 // some kind of selction between access methods
197 // more work is going to have to be done to make
198 // switching actually work
199 /* MemState state = device->platform->system->memState;
201 if (state == Timing) { */
202 DPRINTF(DMA
, "Attempting to send Packet %#x with senderState: %#x\n",
203 pkt
, pkt
->senderState
);
204 if (!sendTiming(pkt
)) {
205 transmitList
.push_back(pkt
);
206 DPRINTF(DMA
, "-- Failed: queued\n");
208 DPRINTF(DMA
, "-- Done\n");
210 assert(pendingCount
>= 0);
212 /* } else if (state == Atomic) {
214 if (pkt->senderState) {
215 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState);
217 state->completionEvent->schedule(curTick + (pkt->time - pkt->req->getTime()) +1);
220 assert(pendingCount >= 0);
224 } else if (state == Functional) {
226 // Is this correct???
227 completionEvent->schedule(pkt->req->responseTime - pkt->req->requestTime);
228 completionEvent == NULL;
230 panic("Unknown memory command state.");
234 DmaDevice::~DmaDevice()