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
)
113 DmaPort::recvTiming(Packet
&pkt
)
115 completionEvent
->schedule(curTick
+1);
116 completionEvent
= NULL
;
120 DmaDevice::DmaDevice(Params
*p
)
123 dmaPort
= new DmaPort(this);
127 DmaPort::SendEvent::process()
129 if (port
->Port::sendTiming(packet
) == Success
)
132 port
->transmitList
.push_back(&packet
);
138 Packet
* pkt
= transmitList
.front();
139 transmitList
.pop_front();
143 DmaPort::dmaAction(Command cmd
, DmaPort port
, Addr addr
, int size
,
144 Event
*event
, uint8_t *data
)
151 Request
baseReq(false);
154 basePkt
.coherence
= NULL
;
155 basePkt
.senderState
= NULL
;
159 basePkt
.result
= Unknown
;
161 // baseReq.nicReq = true;
162 baseReq
.setTime(curTick
);
164 completionEvent
= event
;
166 for (ChunkGenerator
gen(addr
, size
, peerBlockSize());
167 !gen
.done(); gen
.next()) {
168 Packet
*pkt
= new Packet(basePkt
);
169 Request
*req
= new Request(baseReq
);
170 pkt
->addr
= gen
.addr();
171 pkt
->size
= gen
.size();
173 pkt
->req
->setPaddr(pkt
->addr
);
174 pkt
->req
->setSize(pkt
->size
);
175 // Increment the data pointer on a write
176 pkt
->data
= data
? data
+ prevSize
: NULL
;
177 prevSize
+= pkt
->size
;
185 DmaPort::sendDma(Packet
&pkt
)
187 // some kind of selction between access methods
188 // more work is going to have to be done to make
189 // switching actually work
190 /* MemState state = device->platform->system->memState;
192 if (state == Timing) {
193 if (sendTiming(pkt) == Failure)
194 transmitList.push_back(&packet);
195 } else if (state == Atomic) {*/
197 completionEvent
->schedule(pkt
.time
- pkt
.req
->getTime());
198 completionEvent
= NULL
;
199 /* } else if (state == Functional) {
201 // Is this correct???
202 completionEvent->schedule(pkt.req->responseTime - pkt.req->requestTime);
203 completionEvent == NULL;
205 panic("Unknown memory command state.");
209 DmaDevice::~DmaDevice()