Deleted Added
sdiff udiff text old ( 8711:c7e14f52c682 ) new ( 8742:9df38d259935 )
full compact
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;

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

37#include "mem/packet.hh"
38#include "mem/tport.hh"
39#include "params/BasicPioDevice.hh"
40#include "params/DmaDevice.hh"
41#include "params/PioDevice.hh"
42#include "sim/sim_object.hh"
43
44class Event;
45class Platform;
46class PioDevice;
47class DmaDevice;
48class System;
49
50/**
51 * The PioPort class is a programmed i/o port that all devices that are
52 * sensitive to an address range use. The port takes all the memory
53 * access types and roles them into one read() and write() call that the device
54 * must respond to. The device must also provide getAddrRanges() function
55 * with which it returns the address ranges it is interested in.
56 */
57class PioPort : public SimpleTimingPort
58{
59 protected:
60 /** The device that this port serves. */
61 PioDevice *device;
62
63 virtual Tick recvAtomic(PacketPtr pkt);
64
65 virtual AddrRangeList getAddrRanges();
66
67 public:
68
69 PioPort(PioDevice *dev, System *s, std::string pname = "-pioport");
70};
71
72
73class DmaPort : public Port

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

124
125 /** Maximum time that device should back off for after failed sendTiming */
126 Tick maxBackoffDelay;
127
128 /** If the port is currently waiting for a retry before it can send whatever
129 * it is that it's sending. */
130 bool inRetry;
131
132 /** Port accesses a cache which requires snooping */
133 bool recvSnoops;
134
135 virtual bool recvTiming(PacketPtr pkt);
136 virtual Tick recvAtomic(PacketPtr pkt)
137 {
138 if (recvSnoops) return 0;
139
140 panic("dma port shouldn't be used for pio access."); M5_DUMMY_RETURN
141 }
142 virtual void recvFunctional(PacketPtr pkt)
143 {
144 if (recvSnoops) return;
145
146 panic("dma port shouldn't be used for pio access.");
147 }
148
149 virtual void recvRangeChange()
150 {
151 // DMA port is a master with a single slave so there is no choice and
152 // thus no need to worry about any address changes
153 }
154
155 virtual void recvRetry() ;
156
157 virtual bool isSnooping()
158 { return recvSnoops; }
159
160 void queueDma(PacketPtr pkt, bool front = false);
161 void sendDma();
162
163 /** event to give us a kick every time we backoff time is reached. */
164 EventWrapper<DmaPort, &DmaPort::sendDma> backoffEvent;
165
166 public:
167 DmaPort(MemObject *dev, System *s, Tick min_backoff, Tick max_backoff,
168 bool recv_snoops = false);
169
170 void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event,
171 uint8_t *data, Tick delay, Request::Flags flag = 0);
172
173 bool dmaPending() { return pendingCount > 0; }
174
175 unsigned cacheBlockSize() const { return peerBlockSize(); }
176 unsigned int drain(Event *de);
177};
178
179/**
180 * This device is the base class which all devices senstive to an address range
181 * inherit from. There are three pure virtual functions which all devices must
182 * implement getAddrRanges(), read(), and write(). The magic do choose which
183 * mode we are in, etc is handled by the PioPort so the device doesn't have to
184 * bother.
185 */
186class PioDevice : public MemObject
187{
188 protected:
189
190 /** The platform we are in. This is used to decide what type of memory
191 * transaction we should perform. */
192 Platform *platform;
193
194 System *sys;
195
196 /** The pioPort that handles the requests for us and provides us requests
197 * that it sees. */
198 PioPort *pioPort;
199
200 /**
201 * Every PIO device is obliged to provide an implementation that
202 * returns the address ranges the device responds to.
203 *
204 * @return a list of non-overlapping address ranges
205 */
206 virtual AddrRangeList getAddrRanges() = 0;
207
208 /** Pure virtual function that the device must implement. Called
209 * when a read command is recieved by the port.
210 * @param pkt Packet describing this request
211 * @return number of ticks it took to complete
212 */
213 virtual Tick read(PacketPtr pkt) = 0;
214

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

229 {
230 return dynamic_cast<const Params *>(_params);
231 }
232
233 virtual void init();
234
235 virtual unsigned int drain(Event *de);
236
237 virtual Port *getPort(const std::string &if_name, int idx = -1);
238
239 friend class PioPort;
240
241};
242
243class BasicPioDevice : public PioDevice
244{
245 protected:
246 /** Address that the device listens to. */

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

257 BasicPioDevice(const Params *p);
258
259 const Params *
260 params() const
261 {
262 return dynamic_cast<const Params *>(_params);
263 }
264
265 /**
266 * Determine the address ranges that this device responds to.
267 *
268 * @return a list of non-overlapping address ranges
269 */
270 virtual AddrRangeList getAddrRanges();
271
272};
273
274class DmaDevice : public PioDevice
275{
276 protected:
277 DmaPort *dmaPort;
278

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

298 }
299
300 bool dmaPending() { return dmaPort->dmaPending(); }
301
302 virtual unsigned int drain(Event *de);
303
304 unsigned cacheBlockSize() const { return dmaPort->cacheBlockSize(); }
305
306 virtual Port *getPort(const std::string &if_name, int idx = -1);
307
308 friend class DmaPort;
309};
310
311
312#endif // __DEV_IO_DEVICE_HH__