io_device.cc (5606:6da7a58b0bc8) io_device.cc (7403:3d433863cd41)
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;

--- 85 unchanged lines hidden (view full) ---

94BasicPioDevice::addressRanges(AddrRangeList &range_list)
95{
96 assert(pioSize != 0);
97 range_list.clear();
98 range_list.push_back(RangeSize(pioAddr, pioSize));
99}
100
101
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;

--- 85 unchanged lines hidden (view full) ---

94BasicPioDevice::addressRanges(AddrRangeList &range_list)
95{
96 assert(pioSize != 0);
97 range_list.clear();
98 range_list.push_back(RangeSize(pioAddr, pioSize));
99}
100
101
102DmaPort::DmaPort(DmaDevice *dev, System *s)
102DmaPort::DmaPort(MemObject *dev, System *s, Tick min_backoff, Tick max_backoff)
103 : Port(dev->name() + "-dmaport", dev), device(dev), sys(s),
104 pendingCount(0), actionInProgress(0), drainEvent(NULL),
103 : Port(dev->name() + "-dmaport", dev), device(dev), sys(s),
104 pendingCount(0), actionInProgress(0), drainEvent(NULL),
105 backoffTime(0), inRetry(false), backoffEvent(this)
105 backoffTime(0), minBackoffDelay(min_backoff),
106 maxBackoffDelay(max_backoff), inRetry(false), backoffEvent(this)
106{ }
107
108bool
109DmaPort::recvTiming(PacketPtr pkt)
110{
111 if (pkt->wasNacked()) {
112 DPRINTF(DMA, "Received nacked %s addr %#x\n",
113 pkt->cmdString(), pkt->getAddr());
114
107{ }
108
109bool
110DmaPort::recvTiming(PacketPtr pkt)
111{
112 if (pkt->wasNacked()) {
113 DPRINTF(DMA, "Received nacked %s addr %#x\n",
114 pkt->cmdString(), pkt->getAddr());
115
115 if (backoffTime < device->minBackoffDelay)
116 backoffTime = device->minBackoffDelay;
117 else if (backoffTime < device->maxBackoffDelay)
116 if (backoffTime < minBackoffDelay)
117 backoffTime = minBackoffDelay;
118 else if (backoffTime < maxBackoffDelay)
118 backoffTime <<= 1;
119
120 reschedule(backoffEvent, curTick + backoffTime, true);
121
122 DPRINTF(DMA, "Backoff time set to %d ticks\n", backoffTime);
123
124 pkt->reinitNacked();
125 queueDma(pkt, true);

--- 7 unchanged lines hidden (view full) ---

133 pendingCount--;
134
135 assert(pendingCount >= 0);
136 assert(state);
137
138 state->numBytes += pkt->req->getSize();
139 assert(state->totBytes >= state->numBytes);
140 if (state->totBytes == state->numBytes) {
119 backoffTime <<= 1;
120
121 reschedule(backoffEvent, curTick + backoffTime, true);
122
123 DPRINTF(DMA, "Backoff time set to %d ticks\n", backoffTime);
124
125 pkt->reinitNacked();
126 queueDma(pkt, true);

--- 7 unchanged lines hidden (view full) ---

134 pendingCount--;
135
136 assert(pendingCount >= 0);
137 assert(state);
138
139 state->numBytes += pkt->req->getSize();
140 assert(state->totBytes >= state->numBytes);
141 if (state->totBytes == state->numBytes) {
141 if (state->delay)
142 schedule(state->completionEvent, curTick + state->delay);
143 else
144 state->completionEvent->process();
142 if (state->completionEvent) {
143 if (state->delay)
144 schedule(state->completionEvent, curTick + state->delay);
145 else
146 state->completionEvent->process();
147 }
145 delete state;
146 }
147 delete pkt->req;
148 delete pkt;
149
150 if (pendingCount == 0 && drainEvent) {
151 drainEvent->process();
152 drainEvent = NULL;
153 }
154 } else {
155 panic("Got packet without sender state... huh?\n");
156 }
157
158 return true;
159}
160
161DmaDevice::DmaDevice(const Params *p)
148 delete state;
149 }
150 delete pkt->req;
151 delete pkt;
152
153 if (pendingCount == 0 && drainEvent) {
154 drainEvent->process();
155 drainEvent = NULL;
156 }
157 } else {
158 panic("Got packet without sender state... huh?\n");
159 }
160
161 return true;
162}
163
164DmaDevice::DmaDevice(const Params *p)
162 : PioDevice(p), dmaPort(NULL), minBackoffDelay(p->min_backoff_delay),
163 maxBackoffDelay(p->max_backoff_delay)
165 : PioDevice(p), dmaPort(NULL)
164{ }
165
166
167unsigned int
168DmaDevice::drain(Event *de)
169{
170 unsigned int count;
171 count = pioPort->drain(de) + dmaPort->drain(de);

--- 44 unchanged lines hidden (view full) ---

216 backoffEvent.scheduled());
217}
218
219
220void
221DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event,
222 uint8_t *data, Tick delay)
223{
166{ }
167
168
169unsigned int
170DmaDevice::drain(Event *de)
171{
172 unsigned int count;
173 count = pioPort->drain(de) + dmaPort->drain(de);

--- 44 unchanged lines hidden (view full) ---

218 backoffEvent.scheduled());
219}
220
221
222void
223DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event,
224 uint8_t *data, Tick delay)
225{
224 assert(event);
225
226 assert(device->getState() == SimObject::Running);
227
228 DmaReqState *reqState = new DmaReqState(event, this, size, delay);
229
230
231 DPRINTF(DMA, "Starting DMA for addr: %#x size: %d sched: %d\n", addr, size,
232 event->scheduled());
233 for (ChunkGenerator gen(addr, size, peerBlockSize());

--- 74 unchanged lines hidden (view full) ---

308 lat = sendAtomic(pkt);
309 assert(pkt->senderState);
310 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState);
311 assert(state);
312 state->numBytes += pkt->req->getSize();
313
314 DPRINTF(DMA, "--Received response for DMA for addr: %#x size: %d nb: %d, tot: %d sched %d\n",
315 pkt->req->getPaddr(), pkt->req->getSize(), state->numBytes,
226 assert(device->getState() == SimObject::Running);
227
228 DmaReqState *reqState = new DmaReqState(event, this, size, delay);
229
230
231 DPRINTF(DMA, "Starting DMA for addr: %#x size: %d sched: %d\n", addr, size,
232 event->scheduled());
233 for (ChunkGenerator gen(addr, size, peerBlockSize());

--- 74 unchanged lines hidden (view full) ---

308 lat = sendAtomic(pkt);
309 assert(pkt->senderState);
310 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState);
311 assert(state);
312 state->numBytes += pkt->req->getSize();
313
314 DPRINTF(DMA, "--Received response for DMA for addr: %#x size: %d nb: %d, tot: %d sched %d\n",
315 pkt->req->getPaddr(), pkt->req->getSize(), state->numBytes,
316 state->totBytes, state->completionEvent->scheduled());
316 state->totBytes,
317 state->completionEvent ? state->completionEvent->scheduled() : 0 );
317
318 if (state->totBytes == state->numBytes) {
318
319 if (state->totBytes == state->numBytes) {
319 assert(!state->completionEvent->scheduled());
320 schedule(state->completionEvent, curTick + lat + state->delay);
320 if (state->completionEvent) {
321 assert(!state->completionEvent->scheduled());
322 schedule(state->completionEvent, curTick + lat + state->delay);
323 }
321 delete state;
322 delete pkt->req;
323 }
324 pendingCount--;
325 assert(pendingCount >= 0);
326 delete pkt;
327
328 if (pendingCount == 0 && drainEvent) {

--- 13 unchanged lines hidden ---
324 delete state;
325 delete pkt->req;
326 }
327 pendingCount--;
328 assert(pendingCount >= 0);
329 delete pkt;
330
331 if (pendingCount == 0 && drainEvent) {

--- 13 unchanged lines hidden ---