dma_device.hh (11169:44b5c183c3cd) dma_device.hh (11625:2344c9dcc0d6)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

180 unsigned int cacheBlockSize() const { return sys->cacheLineSize(); }
181
182 BaseMasterPort &getMasterPort(const std::string &if_name,
183 PortID idx = InvalidPortID) override;
184
185};
186
187/**
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

180 unsigned int cacheBlockSize() const { return sys->cacheLineSize(); }
181
182 BaseMasterPort &getMasterPort(const std::string &if_name,
183 PortID idx = InvalidPortID) override;
184
185};
186
187/**
188 * DMA callback class.
189 *
190 * Allows one to register for a callback event after a sequence of (potentially
191 * non-contiguous) DMA transfers on a DmaPort completes. Derived classes must
192 * implement the process() method and use getChunkEvent() to allocate a
193 * callback event for each participating DMA.
194 */
195class DmaCallback : public Drainable
196{
197 public:
198 virtual const std::string name() const { return "DmaCallback"; }
199
200 /**
201 * DmaPort ensures that all oustanding DMA accesses have completed before
202 * it finishes draining. However, DmaChunkEvents scheduled with a delay
203 * might still be sitting on the event queue. Therefore, draining is not
204 * complete until count is 0, which ensures that all outstanding
205 * DmaChunkEvents associated with this DmaCallback have fired.
206 */
207 DrainState drain() override
208 {
209 return count ? DrainState::Draining : DrainState::Drained;
210 }
211
212 protected:
213 int count;
214
215 DmaCallback()
216 : count(0)
217 { }
218
219 virtual ~DmaCallback() { }
220
221 /**
222 * Callback function invoked on completion of all chunks.
223 */
224 virtual void process() = 0;
225
226 private:
227 /**
228 * Called by DMA engine completion event on each chunk completion.
229 * Since the object may delete itself here, callers should not use
230 * the object pointer after calling this function.
231 */
232 void chunkComplete()
233 {
234 if (--count == 0) {
235 process();
236 // Need to notify DrainManager that this object is finished
237 // draining, even though it is immediately deleted.
238 signalDrainDone();
239 delete this;
240 }
241 }
242
243 /**
244 * Event invoked by DmaDevice on completion of each chunk.
245 */
246 class DmaChunkEvent : public Event
247 {
248 private:
249 DmaCallback *callback;
250
251 public:
252 DmaChunkEvent(DmaCallback *cb)
253 : Event(Default_Pri, AutoDelete), callback(cb)
254 { }
255
256 void process() { callback->chunkComplete(); }
257 };
258
259 public:
260
261 /**
262 * Request a chunk event. Chunks events should be provided to each DMA
263 * request that wishes to participate in this DmaCallback.
264 */
265 Event *getChunkEvent()
266 {
267 ++count;
268 return new DmaChunkEvent(this);
269 }
270};
271
272/**
188 * Buffered DMA engine helper class
189 *
190 * This class implements a simple DMA engine that feeds a FIFO
191 * buffer. The size of the buffer, the maximum number of pending
192 * requests and the maximum request size are all set when the engine
193 * is instantiated.
194 *
195 * An <i>asynchronous</i> transfer of a <i>block</i> of data

--- 230 unchanged lines hidden ---
273 * Buffered DMA engine helper class
274 *
275 * This class implements a simple DMA engine that feeds a FIFO
276 * buffer. The size of the buffer, the maximum number of pending
277 * requests and the maximum request size are all set when the engine
278 * is instantiated.
279 *
280 * An <i>asynchronous</i> transfer of a <i>block</i> of data

--- 230 unchanged lines hidden ---