Deleted Added
sdiff udiff text old ( 2846:89fbe74d8ea8 ) new ( 2901:f9a45473ab55 )
full compact
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;

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

27 *
28 * Authors: Ali Saidi
29 * Nathan Binkert
30 */
31
32#include "base/trace.hh"
33#include "dev/io_device.hh"
34#include "sim/builder.hh"
35
36
37PioPort::PioPort(PioDevice *dev, Platform *p, std::string pname)
38 : Port(dev->name() + pname), device(dev), platform(p)
39{ }
40
41
42Tick
43PioPort::recvAtomic(Packet *pkt)
44{
45 return device->recvAtomic(pkt);
46}

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

63PioPort::recvRetry()
64{
65 bool result = true;
66 while (result && transmitList.size()) {
67 result = Port::sendTiming(transmitList.front());
68 if (result)
69 transmitList.pop_front();
70 }
71}
72
73void
74PioPort::SendEvent::process()
75{
76 if (port->Port::sendTiming(packet))
77 return;
78
79 port->transmitList.push_back(packet);
80}
81
82void
83PioPort::resendNacked(Packet *pkt) {
84 pkt->reinitNacked();
85 if (transmitList.size()) {

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

100 Tick latency = device->recvAtomic(pkt);
101 // turn packet around to go back to requester
102 pkt->makeTimingResponse();
103 sendTiming(pkt, latency);
104 }
105 return true;
106}
107
108PioDevice::~PioDevice()
109{
110 if (pioPort)
111 delete pioPort;
112}
113
114void
115PioDevice::init()
116{
117 if (!pioPort)
118 panic("Pio port not connected to anything!");
119 pioPort->sendStatusChange(Port::RangeChange);
120}
121
122void
123BasicPioDevice::addressRanges(AddrRangeList &range_list)
124{
125 assert(pioSize != 0);
126 range_list.clear();
127 range_list.push_back(RangeSize(pioAddr, pioSize));
128}
129
130
131DmaPort::DmaPort(DmaDevice *dev, Platform *p)
132 : Port(dev->name() + "-dmaport"), device(dev), platform(p), pendingCount(0)
133{ }
134
135bool
136DmaPort::recvTiming(Packet *pkt)
137{
138
139
140 if (pkt->result == Packet::Nacked) {

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

154
155 state->numBytes += pkt->req->getSize();
156 if (state->totBytes == state->numBytes) {
157 state->completionEvent->process();
158 delete state;
159 }
160 delete pkt->req;
161 delete pkt;
162 } else {
163 panic("Got packet without sender state... huh?\n");
164 }
165
166 return true;
167}
168
169DmaDevice::DmaDevice(Params *p)
170 : PioDevice(p), dmaPort(NULL)
171{ }
172
173void
174DmaPort::recvRetry()
175{
176 Packet* pkt = transmitList.front();
177 bool result = true;
178 while (result && transmitList.size()) {
179 DPRINTF(DMA, "Retry on Packet %#x with senderState: %#x\n",
180 pkt, pkt->senderState);

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

190
191
192void
193DmaPort::dmaAction(Packet::Command cmd, Addr addr, int size, Event *event,
194 uint8_t *data)
195{
196 assert(event);
197
198 DmaReqState *reqState = new DmaReqState(event, this, size);
199
200 for (ChunkGenerator gen(addr, size, peerBlockSize());
201 !gen.done(); gen.next()) {
202 Request *req = new Request(gen.addr(), gen.size(), 0);
203 Packet *pkt = new Packet(req, cmd, Packet::Broadcast);
204
205 // Increment the data pointer on a write
206 if (data)
207 pkt->dataStatic(data + gen.complete());
208
209 pkt->senderState = reqState;
210
211 assert(pendingCount >= 0);
212 pendingCount++;
213 sendDma(pkt);
214 }
215}
216
217
218void
219DmaPort::sendDma(Packet *pkt, bool front)
220{
221 // some kind of selction between access methods
222 // more work is going to have to be done to make
223 // switching actually work
224 /* MemState state = device->platform->system->memState;
225
226 if (state == Timing) { */
227 DPRINTF(DMA, "Attempting to send Packet %#x with addr: %#x\n",
228 pkt, pkt->getAddr());
229 if (transmitList.size() || !sendTiming(pkt)) {
230 if (front)
231 transmitList.push_front(pkt);
232 else
233 transmitList.push_back(pkt);
234 DPRINTF(DMA, "-- Failed: queued\n");
235 } else {
236 DPRINTF(DMA, "-- Done\n");
237 }
238 /* } else if (state == Atomic) {
239 sendAtomic(pkt);
240 if (pkt->senderState) {
241 DmaReqState *state = dynamic_cast<DmaReqState*>(pkt->senderState);
242 assert(state);
243 state->completionEvent->schedule(curTick + (pkt->time -
244 pkt->req->getTime()) +1);
245 delete state;
246 }
247 pendingCount--;
248 assert(pendingCount >= 0);
249 delete pkt->req;
250 delete pkt;
251
252 } else if (state == Functional) {
253 sendFunctional(pkt);
254 // Is this correct???
255 completionEvent->schedule(pkt->req->responseTime - pkt->req->requestTime);
256 completionEvent == NULL;
257 } else
258 panic("Unknown memory command state.");
259 */
260}
261
262DmaDevice::~DmaDevice()
263{
264 if (dmaPort)
265 delete dmaPort;
266}
267
268