io_device.cc (3401:1df0cb879413) | io_device.cc (4435:7da241055348) |
---|---|
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; --- 79 unchanged lines hidden (view full) --- 88 assert(pioSize != 0); 89 range_list.clear(); 90 range_list.push_back(RangeSize(pioAddr, pioSize)); 91} 92 93 94DmaPort::DmaPort(DmaDevice *dev, System *s) 95 : Port(dev->name() + "-dmaport", dev), device(dev), sys(s), | 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; --- 79 unchanged lines hidden (view full) --- 88 assert(pioSize != 0); 89 range_list.clear(); 90 range_list.push_back(RangeSize(pioAddr, pioSize)); 91} 92 93 94DmaPort::DmaPort(DmaDevice *dev, System *s) 95 : Port(dev->name() + "-dmaport", dev), device(dev), sys(s), |
96 pendingCount(0), actionInProgress(0), drainEvent(NULL) | 96 pendingCount(0), actionInProgress(0), drainEvent(NULL), 97 backoffTime(0), inRetry(false), backoffEvent(this) |
97{ } 98 99bool 100DmaPort::recvTiming(PacketPtr pkt) 101{ 102 103 104 if (pkt->result == Packet::Nacked) { 105 DPRINTF(DMA, "Received nacked Pkt %#x with State: %#x Addr: %#x\n", 106 pkt, pkt->senderState, pkt->getAddr()); | 98{ } 99 100bool 101DmaPort::recvTiming(PacketPtr pkt) 102{ 103 104 105 if (pkt->result == Packet::Nacked) { 106 DPRINTF(DMA, "Received nacked Pkt %#x with State: %#x Addr: %#x\n", 107 pkt, pkt->senderState, pkt->getAddr()); |
108 109 if (backoffTime < device->minBackoffDelay) 110 backoffTime = device->minBackoffDelay; 111 else if (backoffTime < device->maxBackoffDelay) 112 backoffTime <<= 1; 113 114 if (backoffEvent.scheduled()) 115 backoffEvent.reschedule(curTick + backoffTime); 116 else 117 backoffEvent.schedule(curTick + backoffTime); 118 119 DPRINTF(DMA, "Backoff time set to %d ticks\n", backoffTime); 120 |
|
107 pkt->reinitNacked(); | 121 pkt->reinitNacked(); |
108 sendDma(pkt, true); | 122 queueDma(pkt, true); |
109 } else if (pkt->senderState) { 110 DmaReqState *state; | 123 } else if (pkt->senderState) { 124 DmaReqState *state; |
111 DPRINTF(DMA, "Received response Pkt %#x with State: %#x Addr: %#x\n", 112 pkt, pkt->senderState, pkt->getAddr()); | 125 backoffTime >>= 2; 126 127 DPRINTF(DMA, "Received response Pkt %#x with State: %#x Addr: %#x size: %#x\n", 128 pkt, pkt->senderState, pkt->getAddr(), pkt->req->getSize()); |
113 state = dynamic_cast<DmaReqState*>(pkt->senderState); 114 pendingCount--; 115 116 assert(pendingCount >= 0); 117 assert(state); 118 119 state->numBytes += pkt->req->getSize(); | 129 state = dynamic_cast<DmaReqState*>(pkt->senderState); 130 pendingCount--; 131 132 assert(pendingCount >= 0); 133 assert(state); 134 135 state->numBytes += pkt->req->getSize(); |
136 assert(state->totBytes >= state->numBytes); |
|
120 if (state->totBytes == state->numBytes) { 121 state->completionEvent->process(); 122 delete state; 123 } 124 delete pkt->req; 125 delete pkt; 126 127 if (pendingCount == 0 && drainEvent) { 128 drainEvent->process(); 129 drainEvent = NULL; 130 } 131 } else { 132 panic("Got packet without sender state... huh?\n"); 133 } 134 135 return true; 136} 137 138DmaDevice::DmaDevice(Params *p) | 137 if (state->totBytes == state->numBytes) { 138 state->completionEvent->process(); 139 delete state; 140 } 141 delete pkt->req; 142 delete pkt; 143 144 if (pendingCount == 0 && drainEvent) { 145 drainEvent->process(); 146 drainEvent = NULL; 147 } 148 } else { 149 panic("Got packet without sender state... huh?\n"); 150 } 151 152 return true; 153} 154 155DmaDevice::DmaDevice(Params *p) |
139 : PioDevice(p), dmaPort(NULL) | 156 : PioDevice(p), dmaPort(NULL), minBackoffDelay(p->min_backoff_delay), 157 maxBackoffDelay(p->max_backoff_delay) |
140{ } 141 142 143unsigned int 144DmaDevice::drain(Event *de) 145{ 146 unsigned int count; 147 count = pioPort->drain(de) + dmaPort->drain(de); --- 12 unchanged lines hidden (view full) --- 160 drainEvent = de; 161 return 1; 162} 163 164 165void 166DmaPort::recvRetry() 167{ | 158{ } 159 160 161unsigned int 162DmaDevice::drain(Event *de) 163{ 164 unsigned int count; 165 count = pioPort->drain(de) + dmaPort->drain(de); --- 12 unchanged lines hidden (view full) --- 178 drainEvent = de; 179 return 1; 180} 181 182 183void 184DmaPort::recvRetry() 185{ |
186 assert(transmitList.size()); |
|
168 PacketPtr pkt = transmitList.front(); 169 bool result = true; | 187 PacketPtr pkt = transmitList.front(); 188 bool result = true; |
170 while (result && transmitList.size()) { | 189 do { |
171 DPRINTF(DMA, "Retry on Packet %#x with senderState: %#x\n", 172 pkt, pkt->senderState); 173 result = sendTiming(pkt); 174 if (result) { 175 DPRINTF(DMA, "-- Done\n"); 176 transmitList.pop_front(); | 190 DPRINTF(DMA, "Retry on Packet %#x with senderState: %#x\n", 191 pkt, pkt->senderState); 192 result = sendTiming(pkt); 193 if (result) { 194 DPRINTF(DMA, "-- Done\n"); 195 transmitList.pop_front(); |
196 inRetry = false; |
|
177 } else { | 197 } else { |
198 inRetry = true; |
|
178 DPRINTF(DMA, "-- Failed, queued\n"); 179 } | 199 DPRINTF(DMA, "-- Failed, queued\n"); 200 } |
201 } while (!backoffTime && result && transmitList.size()); 202 203 if (transmitList.size() && backoffTime && !inRetry) { 204 DPRINTF(DMA, "Scheduling backoff for %d\n", curTick+backoffTime); 205 if (!backoffEvent.scheduled()) 206 backoffEvent.schedule(backoffTime+curTick); |
|
180 } | 207 } |
208 DPRINTF(DMA, "TransmitList: %d, backoffTime: %d inRetry: %d es: %d\n", 209 transmitList.size(), backoffTime, inRetry, 210 backoffEvent.scheduled()); |
|
181} 182 183 184void 185DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, 186 uint8_t *data) 187{ 188 assert(event); --- 10 unchanged lines hidden (view full) --- 199 // Increment the data pointer on a write 200 if (data) 201 pkt->dataStatic(data + gen.complete()); 202 203 pkt->senderState = reqState; 204 205 assert(pendingCount >= 0); 206 pendingCount++; | 211} 212 213 214void 215DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, 216 uint8_t *data) 217{ 218 assert(event); --- 10 unchanged lines hidden (view full) --- 229 // Increment the data pointer on a write 230 if (data) 231 pkt->dataStatic(data + gen.complete()); 232 233 pkt->senderState = reqState; 234 235 assert(pendingCount >= 0); 236 pendingCount++; |
207 sendDma(pkt); | 237 queueDma(pkt); |
208 } 209 210} 211 | 238 } 239 240} 241 |
242void 243DmaPort::queueDma(PacketPtr pkt, bool front) 244{ |
|
212 | 245 |
246 if (front) 247 transmitList.push_front(pkt); 248 else 249 transmitList.push_back(pkt); 250 sendDma(); 251} 252 253 |
|
213void | 254void |
214DmaPort::sendDma(PacketPtr pkt, bool front) | 255DmaPort::sendDma() |
215{ 216 // some kind of selction between access methods 217 // more work is going to have to be done to make 218 // switching actually work | 256{ 257 // some kind of selction between access methods 258 // more work is going to have to be done to make 259 // switching actually work |
260 assert(transmitList.size()); 261 PacketPtr pkt = transmitList.front(); |
|
219 220 System::MemoryMode state = sys->getMemoryMode(); 221 if (state == System::Timing) { | 262 263 System::MemoryMode state = sys->getMemoryMode(); 264 if (state == System::Timing) { |
265 if (backoffEvent.scheduled() || inRetry) { 266 DPRINTF(DMA, "Can't send immediately, waiting for retry or backoff timer\n"); 267 return; 268 } 269 |
|
222 DPRINTF(DMA, "Attempting to send Packet %#x with addr: %#x\n", 223 pkt, pkt->getAddr()); | 270 DPRINTF(DMA, "Attempting to send Packet %#x with addr: %#x\n", 271 pkt, pkt->getAddr()); |
224 if (transmitList.size() || !sendTiming(pkt)) { 225 if (front) 226 transmitList.push_front(pkt); 227 else 228 transmitList.push_back(pkt); 229 DPRINTF(DMA, "-- Failed: queued\n"); 230 } else { 231 DPRINTF(DMA, "-- Done\n"); | 272 273 bool result; 274 do { 275 result = sendTiming(pkt); 276 if (result) { 277 transmitList.pop_front(); 278 DPRINTF(DMA, "-- Done\n"); 279 } else { 280 inRetry = true; 281 DPRINTF(DMA, "-- Failed: queued\n"); 282 } 283 } while (result && !backoffTime && transmitList.size()); 284 285 if (transmitList.size() && backoffTime && !inRetry && 286 !backoffEvent.scheduled()) { 287 backoffEvent.schedule(backoffTime+curTick); |
232 } 233 } else if (state == System::Atomic) { | 288 } 289 } else if (state == System::Atomic) { |
290 transmitList.pop_front(); 291 |
|
234 Tick lat; 235 lat = sendAtomic(pkt); 236 assert(pkt->senderState); 237 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState); 238 assert(state); 239 240 state->numBytes += pkt->req->getSize(); 241 if (state->totBytes == state->numBytes) { --- 24 unchanged lines hidden --- | 292 Tick lat; 293 lat = sendAtomic(pkt); 294 assert(pkt->senderState); 295 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState); 296 assert(state); 297 298 state->numBytes += pkt->req->getSize(); 299 if (state->totBytes == state->numBytes) { --- 24 unchanged lines hidden --- |