io_device.hh (2846:89fbe74d8ea8) io_device.hh (2901:f9a45473ab55)
1/*
2 * Copyright (c) 2004-2005 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;

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

55 * connects to is blocked.
56 */
57class PioPort : public Port
58{
59 protected:
60 /** The device that this port serves. */
61 PioDevice *device;
62
1/*
2 * Copyright (c) 2004-2005 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;

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

55 * connects to is blocked.
56 */
57class PioPort : public Port
58{
59 protected:
60 /** The device that this port serves. */
61 PioDevice *device;
62
63 /** The platform that device/port are in. This is used to select which mode
63 /** The system that device/port are in. This is used to select which mode
64 * we are currently operating in. */
64 * we are currently operating in. */
65 Platform *platform;
65 System *sys;
66
67 /** A list of outgoing timing response packets that haven't been serviced
68 * yet. */
69 std::list<Packet*> transmitList;
70
71 /** The current status of the peer(bus) that we are connected to. */
72 Status peerStatus;
73

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

101 virtual void process();
102
103 virtual const char *description()
104 { return "Future scheduled sendTiming event"; }
105
106 friend class PioPort;
107 };
108
66
67 /** A list of outgoing timing response packets that haven't been serviced
68 * yet. */
69 std::list<Packet*> transmitList;
70
71 /** The current status of the peer(bus) that we are connected to. */
72 Status peerStatus;
73

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

101 virtual void process();
102
103 virtual const char *description()
104 { return "Future scheduled sendTiming event"; }
105
106 friend class PioPort;
107 };
108
109 /** Number of timing requests that are emulating the device timing before
110 * attempting to end up on the bus.
111 */
112 int outTiming;
113
114 /** If we need to drain, keep the drain event around until we're done
115 * here.*/
116 Event *drainEvent;
117
109 /** Schedule a sendTiming() event to be called in the future. */
110 void sendTiming(Packet *pkt, Tick time)
118 /** Schedule a sendTiming() event to be called in the future. */
119 void sendTiming(Packet *pkt, Tick time)
111 { new PioPort::SendEvent(this, pkt, time); }
120 { outTiming++; new PioPort::SendEvent(this, pkt, time); }
112
113 /** This function is notification that the device should attempt to send a
114 * packet again. */
115 virtual void recvRetry();
116
117 public:
121
122 /** This function is notification that the device should attempt to send a
123 * packet again. */
124 virtual void recvRetry();
125
126 public:
118 PioPort(PioDevice *dev, Platform *p, std::string pname = "-pioport");
127 PioPort(PioDevice *dev, System *s, std::string pname = "-pioport");
119
128
129 unsigned int drain(Event *de);
130
120 friend class PioPort::SendEvent;
121};
122
123
124class DmaPort : public Port
125{
126 protected:
127 struct DmaReqState : public Packet::SenderState

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

142 DmaReqState(Event *ce, Port *p, Addr tb)
143 : completionEvent(ce), outPort(p), totBytes(tb), numBytes(0)
144 {}
145 };
146
147 DmaDevice *device;
148 std::list<Packet*> transmitList;
149
131 friend class PioPort::SendEvent;
132};
133
134
135class DmaPort : public Port
136{
137 protected:
138 struct DmaReqState : public Packet::SenderState

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

153 DmaReqState(Event *ce, Port *p, Addr tb)
154 : completionEvent(ce), outPort(p), totBytes(tb), numBytes(0)
155 {}
156 };
157
158 DmaDevice *device;
159 std::list<Packet*> transmitList;
160
150 /** The platform that device/port are in. This is used to select which mode
161 /** The system that device/port are in. This is used to select which mode
151 * we are currently operating in. */
162 * we are currently operating in. */
152 Platform *platform;
163 System *sys;
153
154 /** Number of outstanding packets the dma port has. */
155 int pendingCount;
156
164
165 /** Number of outstanding packets the dma port has. */
166 int pendingCount;
167
168 /** If a dmaAction is in progress. */
169 int actionInProgress;
170
171 /** If we need to drain, keep the drain event around until we're done
172 * here.*/
173 Event *drainEvent;
174
157 virtual bool recvTiming(Packet *pkt);
158 virtual Tick recvAtomic(Packet *pkt)
159 { panic("dma port shouldn't be used for pio access."); }
160 virtual void recvFunctional(Packet *pkt)
161 { panic("dma port shouldn't be used for pio access."); }
162
163 virtual void recvStatusChange(Status status)
164 { ; }
165
166 virtual void recvRetry() ;
167
168 virtual void getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop)
169 { resp.clear(); snoop.clear(); }
170
171 void sendDma(Packet *pkt, bool front = false);
172
173 public:
175 virtual bool recvTiming(Packet *pkt);
176 virtual Tick recvAtomic(Packet *pkt)
177 { panic("dma port shouldn't be used for pio access."); }
178 virtual void recvFunctional(Packet *pkt)
179 { panic("dma port shouldn't be used for pio access."); }
180
181 virtual void recvStatusChange(Status status)
182 { ; }
183
184 virtual void recvRetry() ;
185
186 virtual void getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop)
187 { resp.clear(); snoop.clear(); }
188
189 void sendDma(Packet *pkt, bool front = false);
190
191 public:
174 DmaPort(DmaDevice *dev, Platform *p);
192 DmaPort(DmaDevice *dev, System *s);
175
176 void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event,
177 uint8_t *data = NULL);
178
179 bool dmaPending() { return pendingCount > 0; }
180
193
194 void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event,
195 uint8_t *data = NULL);
196
197 bool dmaPending() { return pendingCount > 0; }
198
199 unsigned int drain(Event *de);
181};
182
183/**
184 * This device is the base class which all devices senstive to an address range
185 * inherit from. There are three pure virtual functions which all devices must
186 * implement addressRanges(), read(), and write(). The magic do choose which
187 * mode we are in, etc is handled by the PioPort so the device doesn't have to
188 * bother.
189 */
190
191class PioDevice : public MemObject
192{
193 protected:
194
195 /** The platform we are in. This is used to decide what type of memory
196 * transaction we should perform. */
197 Platform *platform;
198
200};
201
202/**
203 * This device is the base class which all devices senstive to an address range
204 * inherit from. There are three pure virtual functions which all devices must
205 * implement addressRanges(), read(), and write(). The magic do choose which
206 * mode we are in, etc is handled by the PioPort so the device doesn't have to
207 * bother.
208 */
209
210class PioDevice : public MemObject
211{
212 protected:
213
214 /** The platform we are in. This is used to decide what type of memory
215 * transaction we should perform. */
216 Platform *platform;
217
218 System *sys;
219
199 /** The pioPort that handles the requests for us and provides us requests
200 * that it sees. */
201 PioPort *pioPort;
202
203 virtual void addressRanges(AddrRangeList &range_list) = 0;
204
205 /** As far as the devices are concerned they only accept atomic transactions
206 * which are converted to either a write or a read. */

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

235
236 protected:
237 Params *_params;
238
239 public:
240 const Params *params() const { return _params; }
241
242 PioDevice(Params *p)
220 /** The pioPort that handles the requests for us and provides us requests
221 * that it sees. */
222 PioPort *pioPort;
223
224 virtual void addressRanges(AddrRangeList &range_list) = 0;
225
226 /** As far as the devices are concerned they only accept atomic transactions
227 * which are converted to either a write or a read. */

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

256
257 protected:
258 Params *_params;
259
260 public:
261 const Params *params() const { return _params; }
262
263 PioDevice(Params *p)
243 : MemObject(p->name), platform(p->platform), pioPort(NULL),
244 _params(p)
264 : MemObject(p->name), platform(p->platform), sys(p->system),
265 pioPort(NULL), _params(p)
245 {}
246
247 virtual ~PioDevice();
248
249 virtual void init();
250
266 {}
267
268 virtual ~PioDevice();
269
270 virtual void init();
271
272 virtual unsigned int drain(Event *de);
273
251 virtual Port *getPort(const std::string &if_name, int idx = -1)
252 {
253 if (if_name == "pio") {
254 if (pioPort != NULL)
255 panic("pio port already connected to.");
274 virtual Port *getPort(const std::string &if_name, int idx = -1)
275 {
276 if (if_name == "pio") {
277 if (pioPort != NULL)
278 panic("pio port already connected to.");
256 pioPort = new PioPort(this, params()->platform);
279 pioPort = new PioPort(this, sys);
257 return pioPort;
258 } else
259 return NULL;
260 }
261 friend class PioPort;
262
263};
264

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

305 void dmaWrite(Addr addr, int size, Event *event, uint8_t *data)
306 { dmaPort->dmaAction(Packet::WriteReq, addr, size, event, data) ; }
307
308 void dmaRead(Addr addr, int size, Event *event, uint8_t *data = NULL)
309 { dmaPort->dmaAction(Packet::ReadReq, addr, size, event, data); }
310
311 bool dmaPending() { return dmaPort->dmaPending(); }
312
280 return pioPort;
281 } else
282 return NULL;
283 }
284 friend class PioPort;
285
286};
287

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

328 void dmaWrite(Addr addr, int size, Event *event, uint8_t *data)
329 { dmaPort->dmaAction(Packet::WriteReq, addr, size, event, data) ; }
330
331 void dmaRead(Addr addr, int size, Event *event, uint8_t *data = NULL)
332 { dmaPort->dmaAction(Packet::ReadReq, addr, size, event, data); }
333
334 bool dmaPending() { return dmaPort->dmaPending(); }
335
336 virtual unsigned int drain(Event *de);
337
313 virtual Port *getPort(const std::string &if_name, int idx = -1)
314 {
315 if (if_name == "pio") {
316 if (pioPort != NULL)
317 panic("pio port already connected to.");
338 virtual Port *getPort(const std::string &if_name, int idx = -1)
339 {
340 if (if_name == "pio") {
341 if (pioPort != NULL)
342 panic("pio port already connected to.");
318 pioPort = new PioPort(this, params()->platform);
343 pioPort = new PioPort(this, sys);
319 return pioPort;
320 } else if (if_name == "dma") {
321 if (dmaPort != NULL)
322 panic("dma port already connected to.");
344 return pioPort;
345 } else if (if_name == "dma") {
346 if (dmaPort != NULL)
347 panic("dma port already connected to.");
323 dmaPort = new DmaPort(this, params()->platform);
348 dmaPort = new DmaPort(this, sys);
324 return dmaPort;
325 } else
326 return NULL;
327 }
328
329 friend class DmaPort;
330};
331
332
333#endif // __DEV_IO_DEVICE_HH__
349 return dmaPort;
350 } else
351 return NULL;
352 }
353
354 friend class DmaPort;
355};
356
357
358#endif // __DEV_IO_DEVICE_HH__