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 "dev/io_device.hh"
30 #include "sim/builder.hh"
33 PioPort::PioPort(PioDevice
*dev
, Platform
*p
)
34 : device(dev
), platform(p
)
39 PioPort::recvAtomic(Packet
*pkt
)
41 return device
->recvAtomic(pkt
);
45 PioPort::recvFunctional(Packet
*pkt
)
47 device
->recvAtomic(pkt
);
51 PioPort::getDeviceAddressRanges(AddrRangeList
&resp
, AddrRangeList
&snoop
)
54 device
->addressRanges(resp
);
61 Packet
* pkt
= transmitList
.front();
62 transmitList
.pop_front();
68 PioPort::SendEvent::process()
70 if (port
->Port::sendTiming(packet
) == Success
)
73 port
->transmitList
.push_back(packet
);
78 PioPort::recvTiming(Packet
*pkt
)
80 device
->recvAtomic(pkt
);
81 sendTiming(pkt
, pkt
->time
- pkt
->req
->getTime());
85 PioDevice::~PioDevice()
95 panic("Pio port not connected to anything!");
96 pioPort
->sendStatusChange(Port::RangeChange
);
100 BasicPioDevice::addressRanges(AddrRangeList
&range_list
)
102 assert(pioSize
!= 0);
104 range_list
.push_back(RangeSize(pioAddr
, pioSize
));
108 DmaPort::DmaPort(DmaDevice
*dev
, Platform
*p
)
109 : device(dev
), platform(p
), pendingCount(0)
113 DmaPort::recvTiming(Packet
*pkt
)
115 if (pkt
->senderState
) {
117 state
= (DmaReqState
*)pkt
->senderState
;
118 state
->completionEvent
->schedule(pkt
->time
- pkt
->req
->getTime());
129 DmaDevice::DmaDevice(Params
*p
)
130 : PioDevice(p
), dmaPort(NULL
)
134 DmaPort::SendEvent::process()
136 if (port
->Port::sendTiming(packet
) == Success
)
139 port
->transmitList
.push_back(packet
);
145 Packet
* pkt
= transmitList
.front();
146 transmitList
.pop_front();
150 DmaPort::dmaAction(Command cmd
, Addr addr
, int size
, Event
*event
,
158 Request
baseReq(false);
161 basePkt
.coherence
= NULL
;
162 basePkt
.senderState
= NULL
;
163 basePkt
.dest
= Packet::Broadcast
;
165 basePkt
.result
= Unknown
;
167 // baseReq.nicReq = true;
168 baseReq
.setTime(curTick
);
170 for (ChunkGenerator
gen(addr
, size
, peerBlockSize());
171 !gen
.done(); gen
.next()) {
172 Packet
*pkt
= new Packet(basePkt
);
173 Request
*req
= new Request(baseReq
);
174 pkt
->addr
= gen
.addr();
175 pkt
->size
= gen
.size();
177 pkt
->req
->setPaddr(pkt
->addr
);
178 pkt
->req
->setSize(pkt
->size
);
179 // Increment the data pointer on a write
181 pkt
->dataStatic(data
+ prevSize
) ;
182 prevSize
+= pkt
->size
;
183 // Set the last bit of the dma as the final packet for this dma
184 // and set it's completion event.
185 if (prevSize
== size
) {
186 DmaReqState
*state
= new DmaReqState(event
, true);
188 pkt
->senderState
= (void*)state
;
190 assert(pendingCount
>= 0);
194 // since this isn't getting used and we want a check to make sure that all
195 // packets had data in them at some point.
196 basePkt
.dataStatic((uint8_t*)NULL
);
201 DmaPort::sendDma(Packet
*pkt
)
203 // some kind of selction between access methods
204 // more work is going to have to be done to make
205 // switching actually work
206 /* MemState state = device->platform->system->memState;
208 if (state == Timing) {
209 if (sendTiming(pkt) == Failure)
210 transmitList.push_back(&packet);
211 } else if (state == Atomic) {*/
213 if (pkt
->senderState
) {
214 DmaReqState
*state
= (DmaReqState
*)pkt
->senderState
;
215 state
->completionEvent
->schedule(curTick
+ (pkt
->time
- pkt
->req
->getTime()) +1);
218 assert(pendingCount
>= 0);
222 /* } else if (state == Functional) {
224 // Is this correct???
225 completionEvent->schedule(pkt->req->responseTime - pkt->req->requestTime);
226 completionEvent == NULL;
228 panic("Unknown memory command state.");
232 DmaDevice::~DmaDevice()