io_device.cc (2665:a124942bacb8) | io_device.cc (2685:a0821abe7132) |
---|---|
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; --- 106 unchanged lines hidden (view full) --- 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{ | 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; --- 106 unchanged lines hidden (view full) --- 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 if (pkt->senderState) { | 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) { |
124 DmaReqState *state; | 131 DmaReqState *state; |
125 DPRINTF(DMA, "Received response Packet %#x with senderState: %#x\n", 126 pkt, pkt->senderState); | 132 DPRINTF(DMA, "Received response Pkt %#x with State: %#x Addr: %#x\n", 133 pkt, pkt->senderState, pkt->getAddr()); |
127 state = dynamic_cast<DmaReqState*>(pkt->senderState); | 134 state = dynamic_cast<DmaReqState*>(pkt->senderState); |
135 pendingCount--; 136 137 assert(pendingCount >= 0); |
|
128 assert(state); | 138 assert(state); |
129 state->completionEvent->process(); | 139 140 state->numBytes += pkt->req->getSize(); 141 if (state->totBytes == state->numBytes) { 142 state->completionEvent->process(); 143 delete state; 144 } |
130 delete pkt->req; 131 delete pkt; 132 } else { | 145 delete pkt->req; 146 delete pkt; 147 } else { |
133 DPRINTF(DMA, "Received response Packet %#x with no senderState\n", pkt); 134 delete pkt->req; 135 delete pkt; | 148 panic("Got packet without sender state... huh?\n"); |
136 } 137 138 return true; 139} 140 141DmaDevice::DmaDevice(Params *p) 142 : PioDevice(p), dmaPort(NULL) 143{ } --- 5 unchanged lines hidden (view full) --- 149 bool result = true; 150 while (result && transmitList.size()) { 151 DPRINTF(DMA, "Retry on Packet %#x with senderState: %#x\n", 152 pkt, pkt->senderState); 153 result = sendTiming(pkt); 154 if (result) { 155 DPRINTF(DMA, "-- Done\n"); 156 transmitList.pop_front(); | 149 } 150 151 return true; 152} 153 154DmaDevice::DmaDevice(Params *p) 155 : PioDevice(p), dmaPort(NULL) 156{ } --- 5 unchanged lines hidden (view full) --- 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(); |
157 pendingCount--; 158 assert(pendingCount >= 0); | |
159 } else { 160 DPRINTF(DMA, "-- Failed, queued\n"); 161 } 162 } 163} 164 165 166void 167DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, 168 uint8_t *data) 169{ 170 assert(event); 171 | 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 |
172 int prevSize = 0; | 183 DmaReqState *reqState = new DmaReqState(event, this, size); |
173 174 for (ChunkGenerator gen(addr, size, peerBlockSize()); 175 !gen.done(); gen.next()) { 176 Request *req = new Request(gen.addr(), gen.size(), 0); 177 Packet *pkt = new Packet(req, cmd, Packet::Broadcast); 178 179 // Increment the data pointer on a write 180 if (data) | 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) |
181 pkt->dataStatic(data + prevSize); | 192 pkt->dataStatic(data + gen.complete()); |
182 | 193 |
183 prevSize += gen.size(); | 194 pkt->senderState = reqState; |
184 | 195 |
185 // Set the last bit of the dma as the final packet for this dma 186 // and set it's completion event. 187 if (prevSize == size) { 188 pkt->senderState = new DmaReqState(event, true); 189 } | |
190 assert(pendingCount >= 0); 191 pendingCount++; 192 sendDma(pkt); 193 } 194} 195 196 197void | 196 assert(pendingCount >= 0); 197 pendingCount++; 198 sendDma(pkt); 199 } 200} 201 202 203void |
198DmaPort::sendDma(Packet *pkt) | 204DmaPort::sendDma(Packet *pkt, bool front) |
199{ 200 // some kind of selction between access methods 201 // more work is going to have to be done to make 202 // switching actually work 203 /* MemState state = device->platform->system->memState; 204 205 if (state == Timing) { */ | 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) { */ |
206 DPRINTF(DMA, "Attempting to send Packet %#x with senderState: %#x\n", 207 pkt, pkt->senderState); | 212 DPRINTF(DMA, "Attempting to send Packet %#x with addr: %#x\n", 213 pkt, pkt->getAddr()); |
208 if (transmitList.size() || !sendTiming(pkt)) { | 214 if (transmitList.size() || !sendTiming(pkt)) { |
209 transmitList.push_back(pkt); | 215 if (front) 216 transmitList.push_front(pkt); 217 else 218 transmitList.push_back(pkt); |
210 DPRINTF(DMA, "-- Failed: queued\n"); 211 } else { 212 DPRINTF(DMA, "-- Done\n"); | 219 DPRINTF(DMA, "-- Failed: queued\n"); 220 } else { 221 DPRINTF(DMA, "-- Done\n"); |
213 pendingCount--; 214 assert(pendingCount >= 0); | |
215 } 216 /* } else if (state == Atomic) { 217 sendAtomic(pkt); 218 if (pkt->senderState) { 219 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState); 220 assert(state); | 222 } 223 /* } else if (state == Atomic) { 224 sendAtomic(pkt); 225 if (pkt->senderState) { 226 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState); 227 assert(state); |
221 state->completionEvent->schedule(curTick + (pkt->time - pkt->req->getTime()) +1); | 228 state->completionEvent->schedule(curTick + (pkt->time - 229 pkt->req->getTime()) +1); 230 delete state; |
222 } 223 pendingCount--; 224 assert(pendingCount >= 0); 225 delete pkt->req; 226 delete pkt; 227 228 } else if (state == Functional) { 229 sendFunctional(pkt); --- 15 unchanged lines hidden --- | 231 } 232 pendingCount--; 233 assert(pendingCount >= 0); 234 delete pkt->req; 235 delete pkt; 236 237 } else if (state == Functional) { 238 sendFunctional(pkt); --- 15 unchanged lines hidden --- |