diff options
Diffstat (limited to 'dev/io_device.cc')
-rw-r--r-- | dev/io_device.cc | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/dev/io_device.cc b/dev/io_device.cc index a2e5a8a0d..42b3c382f 100644 --- a/dev/io_device.cc +++ b/dev/io_device.cc @@ -105,23 +105,24 @@ BasicPioDevice::addressRanges(AddrRangeList &range_list) } -DmaPort::DmaPort(DmaDevice *dev) - : device(dev) +DmaPort::DmaPort(DmaDevice *dev, Platform *p) + : device(dev), platform(p), pendingCount(0) { } bool DmaPort::recvTiming(Packet &pkt) { - completionEvent->schedule(curTick+1); - completionEvent = NULL; + if (pkt.senderState) { + DmaReqState *state; + state = (DmaReqState*)pkt.senderState; + state->completionEvent->schedule(pkt.time - pkt.req->getTime()); + } return Success; } DmaDevice::DmaDevice(Params *p) - : PioDevice(p) -{ - dmaPort = new DmaPort(this); -} + : PioDevice(p), dmaPort(NULL) +{ } void DmaPort::SendEvent::process() @@ -140,8 +141,8 @@ DmaPort::recvRetry() return pkt; } void -DmaPort::dmaAction(Command cmd, DmaPort port, Addr addr, int size, - Event *event, uint8_t *data) +DmaPort::dmaAction(Command cmd, Addr addr, int size, Event *event, + uint8_t *data) { assert(event); @@ -161,8 +162,6 @@ DmaPort::dmaAction(Command cmd, DmaPort port, Addr addr, int size, // baseReq.nicReq = true; baseReq.setTime(curTick); - completionEvent = event; - for (ChunkGenerator gen(addr, size, peerBlockSize()); !gen.done(); gen.next()) { Packet *pkt = new Packet(basePkt); @@ -173,16 +172,28 @@ DmaPort::dmaAction(Command cmd, DmaPort port, Addr addr, int size, pkt->req->setPaddr(pkt->addr); pkt->req->setSize(pkt->size); // Increment the data pointer on a write - pkt->data = data ? data + prevSize : NULL ; + if (data) + pkt->dataStatic(data + prevSize) ; prevSize += pkt->size; - - sendDma(*pkt); + // Set the last bit of the dma as the final packet for this dma + // and set it's completion event. + if (prevSize == size) { + DmaReqState *state = new DmaReqState(event, true); + + pkt->senderState = (void*)state; + } + assert(pendingCount >= 0); + pendingCount++; + sendDma(pkt); } + // since this isn't getting used and we want a check to make sure that all + // packets had data in them at some point. + basePkt.dataStatic((uint8_t*)NULL); } void -DmaPort::sendDma(Packet &pkt) +DmaPort::sendDma(Packet *pkt) { // some kind of selction between access methods // more work is going to have to be done to make @@ -193,9 +204,16 @@ DmaPort::sendDma(Packet &pkt) if (sendTiming(pkt) == Failure) transmitList.push_back(&packet); } else if (state == Atomic) {*/ - sendAtomic(pkt); - completionEvent->schedule(pkt.time - pkt.req->getTime()); - completionEvent = NULL; + sendAtomic(*pkt); + if (pkt->senderState) { + DmaReqState *state = (DmaReqState*)pkt->senderState; + state->completionEvent->schedule(curTick + (pkt->time - pkt->req->getTime()) +1); + } + pendingCount--; + assert(pendingCount >= 0); + delete pkt->req; + delete pkt; + /* } else if (state == Functional) { sendFunctional(pkt); // Is this correct??? |