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; --- 33 unchanged lines hidden (view full) --- 42 43 44Tick 45PioPort::recvAtomic(PacketPtr pkt) 46{ 47 return pkt->isRead() ? device->read(pkt) : device->write(pkt); 48} 49 |
50void 51PioPort::getDeviceAddressRanges(AddrRangeList &resp, bool &snoop) |
52{ |
53 snoop = false; 54 device->addressRanges(resp); 55 for (AddrRangeIter i = resp.begin(); i != resp.end(); i++) 56 DPRINTF(BusAddrRanges, "Adding Range %#x-%#x\n", i->start, i->end); |
57} 58 59 60PioDevice::PioDevice(const Params *p) |
61 : MemObject(p), sys(p->system), pioPort(NULL) |
62{} 63 64PioDevice::~PioDevice() 65{ 66 if (pioPort) 67 delete pioPort; 68} 69 70void 71PioDevice::init() 72{ 73 if (!pioPort) |
74 panic("Pio port not connected to anything!"); 75 pioPort->sendStatusChange(Port::RangeChange); |
76} 77 |
78 79unsigned int 80PioDevice::drain(Event *de) 81{ 82 unsigned int count; 83 count = pioPort->drain(de); 84 if (count) 85 changeState(Draining); 86 else 87 changeState(Drained); 88 return count; 89} 90 91BasicPioDevice::BasicPioDevice(const Params *p) 92 : PioDevice(p), pioAddr(p->pio_addr), pioSize(0), 93 pioDelay(p->pio_latency) 94{} 95 |
96void 97BasicPioDevice::addressRanges(AddrRangeList &range_list) |
98{ 99 assert(pioSize != 0); |
100 range_list.clear(); |
101 DPRINTF(BusAddrRanges, "registering range: %#x-%#x\n", pioAddr, pioSize); |
102 range_list.push_back(RangeSize(pioAddr, pioSize)); |
103} 104 105 |
106DmaPort::DmaPort(MemObject *dev, System *s, Tick min_backoff, Tick max_backoff) |
107 : Port(dev->name() + "-dmaport", dev), device(dev), sys(s), 108 pendingCount(0), actionInProgress(0), drainEvent(NULL), 109 backoffTime(0), minBackoffDelay(min_backoff), |
110 maxBackoffDelay(max_backoff), inRetry(false), backoffEvent(this) |
111{ } 112 113bool 114DmaPort::recvTiming(PacketPtr pkt) 115{ 116 if (pkt->wasNacked()) { 117 DPRINTF(DMA, "Received nacked %s addr %#x\n", 118 pkt->cmdString(), pkt->getAddr()); 119 120 if (backoffTime < minBackoffDelay) 121 backoffTime = minBackoffDelay; 122 else if (backoffTime < maxBackoffDelay) 123 backoffTime <<= 1; 124 |
125 reschedule(backoffEvent, curTick() + backoffTime, true); |
126 127 DPRINTF(DMA, "Backoff time set to %d ticks\n", backoffTime); 128 129 pkt->reinitNacked(); 130 queueDma(pkt, true); |
131 } else if (pkt->senderState) { 132 DmaReqState *state; 133 backoffTime >>= 2; 134 135 DPRINTF(DMA, "Received response %s addr %#x size %#x\n", 136 pkt->cmdString(), pkt->getAddr(), pkt->req->getSize()); 137 state = dynamic_cast<DmaReqState*>(pkt->senderState); 138 pendingCount--; --- 4 unchanged lines hidden (view full) --- 143 // We shouldn't ever get a block in ownership state 144 assert(!(pkt->memInhibitAsserted() && !pkt->sharedAsserted())); 145 146 state->numBytes += pkt->req->getSize(); 147 assert(state->totBytes >= state->numBytes); 148 if (state->totBytes == state->numBytes) { 149 if (state->completionEvent) { 150 if (state->delay) |
151 schedule(state->completionEvent, curTick() + state->delay); |
152 else 153 state->completionEvent->process(); 154 } 155 delete state; 156 } 157 delete pkt->req; 158 delete pkt; 159 --- 53 unchanged lines hidden (view full) --- 213 inRetry = true; 214 DPRINTF(DMA, "-- Failed, queued\n"); 215 } 216 } while (!backoffTime && result && transmitList.size()); 217 218 if (transmitList.size() && backoffTime && !inRetry) { 219 DPRINTF(DMA, "Scheduling backoff for %d\n", curTick()+backoffTime); 220 if (!backoffEvent.scheduled()) |
221 schedule(backoffEvent, backoffTime + curTick()); |
222 } 223 DPRINTF(DMA, "TransmitList: %d, backoffTime: %d inRetry: %d es: %d\n", 224 transmitList.size(), backoffTime, inRetry, 225 backoffEvent.scheduled()); 226} 227 228 229void --- 69 unchanged lines hidden (view full) --- 299 DPRINTF(DMA, "-- Failed: queued\n"); 300 } 301 } while (result && !backoffTime && transmitList.size()); 302 303 if (transmitList.size() && backoffTime && !inRetry && 304 !backoffEvent.scheduled()) { 305 DPRINTF(DMA, "-- Scheduling backoff timer for %d\n", 306 backoffTime+curTick()); |
307 schedule(backoffEvent, backoffTime + curTick()); |
308 } 309 } else if (state == Enums::atomic) { 310 transmitList.pop_front(); 311 312 Tick lat; 313 DPRINTF(DMA, "--Sending DMA for addr: %#x size: %d\n", 314 pkt->req->getPaddr(), pkt->req->getSize()); 315 lat = sendAtomic(pkt); --- 5 unchanged lines hidden (view full) --- 321 DPRINTF(DMA, "--Received response for DMA for addr: %#x size: %d nb: %d, tot: %d sched %d\n", 322 pkt->req->getPaddr(), pkt->req->getSize(), state->numBytes, 323 state->totBytes, 324 state->completionEvent ? state->completionEvent->scheduled() : 0 ); 325 326 if (state->totBytes == state->numBytes) { 327 if (state->completionEvent) { 328 assert(!state->completionEvent->scheduled()); |
329 schedule(state->completionEvent, curTick() + lat + state->delay); |
330 } 331 delete state; 332 delete pkt->req; 333 } 334 pendingCount--; 335 assert(pendingCount >= 0); 336 delete pkt; 337 --- 6 unchanged lines hidden (view full) --- 344 panic("Unknown memory command state."); 345} 346 347DmaDevice::~DmaDevice() 348{ 349 if (dmaPort) 350 delete dmaPort; 351} |