1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 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. 15 * 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. 27 * 28 * Authors: Ali Saidi 29 * Nathan Binkert 30 */ 31 32#include "base/trace.hh" 33#include "dev/io_device.hh" 34#include "sim/builder.hh" 35 36 37PioPort::PioPort(PioDevice *dev, Platform *p) 38 : Port(dev->name() + "-pioport"), device(dev), platform(p) 39{ } 40 41 42Tick 43PioPort::recvAtomic(Packet *pkt) 44{ 45 return device->recvAtomic(pkt); 46} 47 48void 49PioPort::recvFunctional(Packet *pkt) 50{ 51 device->recvAtomic(pkt); 52} 53 54void 55PioPort::getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop) 56{ 57 snoop.clear(); 58 device->addressRanges(resp); 59} 60 61 62void 63PioPort::recvRetry() 64{
| 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 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. 15 * 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. 27 * 28 * Authors: Ali Saidi 29 * Nathan Binkert 30 */ 31 32#include "base/trace.hh" 33#include "dev/io_device.hh" 34#include "sim/builder.hh" 35 36 37PioPort::PioPort(PioDevice *dev, Platform *p) 38 : Port(dev->name() + "-pioport"), device(dev), platform(p) 39{ } 40 41 42Tick 43PioPort::recvAtomic(Packet *pkt) 44{ 45 return device->recvAtomic(pkt); 46} 47 48void 49PioPort::recvFunctional(Packet *pkt) 50{ 51 device->recvAtomic(pkt); 52} 53 54void 55PioPort::getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop) 56{ 57 snoop.clear(); 58 device->addressRanges(resp); 59} 60 61 62void 63PioPort::recvRetry() 64{
|
90 return true; 91} 92 93PioDevice::~PioDevice() 94{ 95 if (pioPort) 96 delete pioPort; 97} 98 99void 100PioDevice::init() 101{ 102 if (!pioPort) 103 panic("Pio port not connected to anything!"); 104 pioPort->sendStatusChange(Port::RangeChange); 105} 106 107void 108BasicPioDevice::addressRanges(AddrRangeList &range_list) 109{ 110 assert(pioSize != 0); 111 range_list.clear(); 112 range_list.push_back(RangeSize(pioAddr, pioSize)); 113} 114 115 116DmaPort::DmaPort(DmaDevice *dev, Platform *p) 117 : Port(dev->name() + "-dmaport"), device(dev), platform(p), pendingCount(0) 118{ } 119 120bool 121DmaPort::recvTiming(Packet *pkt) 122{ 123 124 125 if (pkt->result == Packet::Nacked) { 126 DPRINTF(DMA, "Received nacked Pkt %#x with State: %#x Addr: %#x\n", 127 pkt, pkt->senderState, pkt->getAddr()); 128 pkt->reinitNacked(); 129 sendDma(pkt, true); 130 } else if (pkt->senderState) { 131 DmaReqState *state; 132 DPRINTF(DMA, "Received response Pkt %#x with State: %#x Addr: %#x\n", 133 pkt, pkt->senderState, pkt->getAddr()); 134 state = dynamic_cast<DmaReqState*>(pkt->senderState); 135 pendingCount--; 136 137 assert(pendingCount >= 0); 138 assert(state); 139 140 state->numBytes += pkt->req->getSize(); 141 if (state->totBytes == state->numBytes) { 142 state->completionEvent->process(); 143 delete state; 144 } 145 delete pkt->req; 146 delete pkt; 147 } else { 148 panic("Got packet without sender state... huh?\n"); 149 } 150 151 return true; 152} 153 154DmaDevice::DmaDevice(Params *p) 155 : PioDevice(p), dmaPort(NULL) 156{ } 157 158void 159DmaPort::recvRetry() 160{ 161 Packet* pkt = transmitList.front(); 162 bool result = true; 163 while (result && transmitList.size()) { 164 DPRINTF(DMA, "Retry on Packet %#x with senderState: %#x\n", 165 pkt, pkt->senderState); 166 result = sendTiming(pkt); 167 if (result) { 168 DPRINTF(DMA, "-- Done\n"); 169 transmitList.pop_front(); 170 } else { 171 DPRINTF(DMA, "-- Failed, queued\n"); 172 } 173 } 174} 175 176 177void 178DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, 179 uint8_t *data) 180{ 181 assert(event); 182 183 DmaReqState *reqState = new DmaReqState(event, this, size); 184 185 for (ChunkGenerator gen(addr, size, peerBlockSize()); 186 !gen.done(); gen.next()) { 187 Request *req = new Request(gen.addr(), gen.size(), 0); 188 Packet *pkt = new Packet(req, cmd, Packet::Broadcast); 189 190 // Increment the data pointer on a write 191 if (data) 192 pkt->dataStatic(data + gen.complete()); 193 194 pkt->senderState = reqState; 195 196 assert(pendingCount >= 0); 197 pendingCount++; 198 sendDma(pkt); 199 } 200} 201 202 203void 204DmaPort::sendDma(Packet *pkt, bool front) 205{ 206 // some kind of selction between access methods 207 // more work is going to have to be done to make 208 // switching actually work 209 /* MemState state = device->platform->system->memState; 210 211 if (state == Timing) { */ 212 DPRINTF(DMA, "Attempting to send Packet %#x with addr: %#x\n", 213 pkt, pkt->getAddr()); 214 if (transmitList.size() || !sendTiming(pkt)) { 215 if (front) 216 transmitList.push_front(pkt); 217 else 218 transmitList.push_back(pkt); 219 DPRINTF(DMA, "-- Failed: queued\n"); 220 } else { 221 DPRINTF(DMA, "-- Done\n"); 222 } 223 /* } else if (state == Atomic) { 224 sendAtomic(pkt); 225 if (pkt->senderState) { 226 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState); 227 assert(state); 228 state->completionEvent->schedule(curTick + (pkt->time - 229 pkt->req->getTime()) +1); 230 delete state; 231 } 232 pendingCount--; 233 assert(pendingCount >= 0); 234 delete pkt->req; 235 delete pkt; 236 237 } else if (state == Functional) { 238 sendFunctional(pkt); 239 // Is this correct??? 240 completionEvent->schedule(pkt->req->responseTime - pkt->req->requestTime); 241 completionEvent == NULL; 242 } else 243 panic("Unknown memory command state."); 244 */ 245} 246 247DmaDevice::~DmaDevice() 248{ 249 if (dmaPort) 250 delete dmaPort; 251} 252 253
| 101 return true; 102} 103 104PioDevice::~PioDevice() 105{ 106 if (pioPort) 107 delete pioPort; 108} 109 110void 111PioDevice::init() 112{ 113 if (!pioPort) 114 panic("Pio port not connected to anything!"); 115 pioPort->sendStatusChange(Port::RangeChange); 116} 117 118void 119BasicPioDevice::addressRanges(AddrRangeList &range_list) 120{ 121 assert(pioSize != 0); 122 range_list.clear(); 123 range_list.push_back(RangeSize(pioAddr, pioSize)); 124} 125 126 127DmaPort::DmaPort(DmaDevice *dev, Platform *p) 128 : Port(dev->name() + "-dmaport"), device(dev), platform(p), pendingCount(0) 129{ } 130 131bool 132DmaPort::recvTiming(Packet *pkt) 133{ 134 135 136 if (pkt->result == Packet::Nacked) { 137 DPRINTF(DMA, "Received nacked Pkt %#x with State: %#x Addr: %#x\n", 138 pkt, pkt->senderState, pkt->getAddr()); 139 pkt->reinitNacked(); 140 sendDma(pkt, true); 141 } else if (pkt->senderState) { 142 DmaReqState *state; 143 DPRINTF(DMA, "Received response Pkt %#x with State: %#x Addr: %#x\n", 144 pkt, pkt->senderState, pkt->getAddr()); 145 state = dynamic_cast<DmaReqState*>(pkt->senderState); 146 pendingCount--; 147 148 assert(pendingCount >= 0); 149 assert(state); 150 151 state->numBytes += pkt->req->getSize(); 152 if (state->totBytes == state->numBytes) { 153 state->completionEvent->process(); 154 delete state; 155 } 156 delete pkt->req; 157 delete pkt; 158 } else { 159 panic("Got packet without sender state... huh?\n"); 160 } 161 162 return true; 163} 164 165DmaDevice::DmaDevice(Params *p) 166 : PioDevice(p), dmaPort(NULL) 167{ } 168 169void 170DmaPort::recvRetry() 171{ 172 Packet* pkt = transmitList.front(); 173 bool result = true; 174 while (result && transmitList.size()) { 175 DPRINTF(DMA, "Retry on Packet %#x with senderState: %#x\n", 176 pkt, pkt->senderState); 177 result = sendTiming(pkt); 178 if (result) { 179 DPRINTF(DMA, "-- Done\n"); 180 transmitList.pop_front(); 181 } else { 182 DPRINTF(DMA, "-- Failed, queued\n"); 183 } 184 } 185} 186 187 188void 189DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, 190 uint8_t *data) 191{ 192 assert(event); 193 194 DmaReqState *reqState = new DmaReqState(event, this, size); 195 196 for (ChunkGenerator gen(addr, size, peerBlockSize()); 197 !gen.done(); gen.next()) { 198 Request *req = new Request(gen.addr(), gen.size(), 0); 199 Packet *pkt = new Packet(req, cmd, Packet::Broadcast); 200 201 // Increment the data pointer on a write 202 if (data) 203 pkt->dataStatic(data + gen.complete()); 204 205 pkt->senderState = reqState; 206 207 assert(pendingCount >= 0); 208 pendingCount++; 209 sendDma(pkt); 210 } 211} 212 213 214void 215DmaPort::sendDma(Packet *pkt, bool front) 216{ 217 // some kind of selction between access methods 218 // more work is going to have to be done to make 219 // switching actually work 220 /* MemState state = device->platform->system->memState; 221 222 if (state == Timing) { */ 223 DPRINTF(DMA, "Attempting to send Packet %#x with addr: %#x\n", 224 pkt, pkt->getAddr()); 225 if (transmitList.size() || !sendTiming(pkt)) { 226 if (front) 227 transmitList.push_front(pkt); 228 else 229 transmitList.push_back(pkt); 230 DPRINTF(DMA, "-- Failed: queued\n"); 231 } else { 232 DPRINTF(DMA, "-- Done\n"); 233 } 234 /* } else if (state == Atomic) { 235 sendAtomic(pkt); 236 if (pkt->senderState) { 237 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState); 238 assert(state); 239 state->completionEvent->schedule(curTick + (pkt->time - 240 pkt->req->getTime()) +1); 241 delete state; 242 } 243 pendingCount--; 244 assert(pendingCount >= 0); 245 delete pkt->req; 246 delete pkt; 247 248 } else if (state == Functional) { 249 sendFunctional(pkt); 250 // Is this correct??? 251 completionEvent->schedule(pkt->req->responseTime - pkt->req->requestTime); 252 completionEvent == NULL; 253 } else 254 panic("Unknown memory command state."); 255 */ 256} 257 258DmaDevice::~DmaDevice() 259{ 260 if (dmaPort) 261 delete dmaPort; 262} 263 264
|