io_device.hh (8796:a2ae5c378d0a) io_device.hh (8799:dac1e33e07b0)
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;

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

45class PioDevice;
46class DmaDevice;
47class System;
48
49/**
50 * The PioPort class is a programmed i/o port that all devices that are
51 * sensitive to an address range use. The port takes all the memory
52 * access types and roles them into one read() and write() call that the device
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;

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

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

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

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
65
66 public:
67
68 PioPort(PioDevice *dev, System *s, std::string pname = "-pioport");
69};
70
71
72class DmaPort : public Port

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

126
127 /** If the port is currently waiting for a retry before it can send whatever
128 * it is that it's sending. */
129 bool inRetry;
130
131 /** Port accesses a cache which requires snooping */
132 bool recvSnoops;
133
135 /** Records snoop response so we only reply once to a status change */
136 bool snoopRangeSent;
137
138 virtual bool recvTiming(PacketPtr pkt);
139 virtual Tick recvAtomic(PacketPtr pkt)
140 {
141 if (recvSnoops) return 0;
142
143 panic("dma port shouldn't be used for pio access."); M5_DUMMY_RETURN
144 }
145 virtual void recvFunctional(PacketPtr pkt)
146 {
147 if (recvSnoops) return;
148
149 panic("dma port shouldn't be used for pio access.");
150 }
151
134 virtual bool recvTiming(PacketPtr pkt);
135 virtual Tick recvAtomic(PacketPtr pkt)
136 {
137 if (recvSnoops) return 0;
138
139 panic("dma port shouldn't be used for pio access."); M5_DUMMY_RETURN
140 }
141 virtual void recvFunctional(PacketPtr pkt)
142 {
143 if (recvSnoops) return;
144
145 panic("dma port shouldn't be used for pio access.");
146 }
147
152 virtual void recvStatusChange(Status status)
148 virtual void recvRangeChange()
153 {
149 {
154 if (recvSnoops) {
155 if (status == RangeChange) {
156 if (!snoopRangeSent) {
157 snoopRangeSent = true;
158 sendStatusChange(Port::RangeChange);
159 }
160 return;
161 }
162 panic("Unexpected recvStatusChange\n");
163 }
150 // DMA port is a master with a single slave so there is no choice and
151 // thus no need to worry about any address changes
164 }
165
166 virtual void recvRetry() ;
167
152 }
153
154 virtual void recvRetry() ;
155
168 virtual void getDeviceAddressRanges(AddrRangeList &resp,
169 bool &snoop)
170 { resp.clear(); snoop = recvSnoops; }
156 virtual bool isSnooping()
157 { return recvSnoops; }
171
172 void queueDma(PacketPtr pkt, bool front = false);
173 void sendDma();
174
175 /** event to give us a kick every time we backoff time is reached. */
176 EventWrapper<DmaPort, &DmaPort::sendDma> backoffEvent;
177
178 public:

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

186
187 unsigned cacheBlockSize() const { return peerBlockSize(); }
188 unsigned int drain(Event *de);
189};
190
191/**
192 * This device is the base class which all devices senstive to an address range
193 * inherit from. There are three pure virtual functions which all devices must
158
159 void queueDma(PacketPtr pkt, bool front = false);
160 void sendDma();
161
162 /** event to give us a kick every time we backoff time is reached. */
163 EventWrapper<DmaPort, &DmaPort::sendDma> backoffEvent;
164
165 public:

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

173
174 unsigned cacheBlockSize() const { return peerBlockSize(); }
175 unsigned int drain(Event *de);
176};
177
178/**
179 * This device is the base class which all devices senstive to an address range
180 * inherit from. There are three pure virtual functions which all devices must
194 * implement addressRanges(), read(), and write(). The magic do choose which
181 * implement getAddrRanges(), read(), and write(). The magic do choose which
195 * mode we are in, etc is handled by the PioPort so the device doesn't have to
196 * bother.
197 */
198class PioDevice : public MemObject
199{
200 protected:
201 System *sys;
202
203 /** The pioPort that handles the requests for us and provides us requests
204 * that it sees. */
205 PioPort *pioPort;
206
182 * mode we are in, etc is handled by the PioPort so the device doesn't have to
183 * bother.
184 */
185class PioDevice : public MemObject
186{
187 protected:
188 System *sys;
189
190 /** The pioPort that handles the requests for us and provides us requests
191 * that it sees. */
192 PioPort *pioPort;
193
207 virtual void addressRanges(AddrRangeList &range_list) = 0;
194 /**
195 * Every PIO device is obliged to provide an implementation that
196 * returns the address ranges the device responds to.
197 *
198 * @return a list of non-overlapping address ranges
199 */
200 virtual AddrRangeList getAddrRanges() = 0;
208
209 /** Pure virtual function that the device must implement. Called
210 * when a read command is recieved by the port.
211 * @param pkt Packet describing this request
212 * @return number of ticks it took to complete
213 */
214 virtual Tick read(PacketPtr pkt) = 0;
215

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

258 BasicPioDevice(const Params *p);
259
260 const Params *
261 params() const
262 {
263 return dynamic_cast<const Params *>(_params);
264 }
265
201
202 /** Pure virtual function that the device must implement. Called
203 * when a read command is recieved by the port.
204 * @param pkt Packet describing this request
205 * @return number of ticks it took to complete
206 */
207 virtual Tick read(PacketPtr pkt) = 0;
208

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

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

--- 34 unchanged lines hidden ---
265
266};
267
268class DmaDevice : public PioDevice
269{
270 protected:
271 DmaPort *dmaPort;
272

--- 34 unchanged lines hidden ---