author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 31 Mar 2010 23:38:45 +0300 | |
branch | RCL_3 |
changeset 87 | 2f92ad2dc5db |
parent 81 | e7d2d738d3c2 |
child 89 | 1df514389a47 |
permissions | -rw-r--r-- |
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
80
diff
changeset
|
1 |
// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32\drivers\dmapil.cpp |
|
15 |
// DMA Platform Independent Layer (PIL) |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include <drivers/dma.h> |
|
20 |
#include <kernel/kern_priv.h> |
|
21 |
||
22 |
||
23 |
static const char KDmaPanicCat[] = "DMA"; |
|
24 |
||
25 |
NFastMutex DmaChannelMgr::Lock; |
|
26 |
||
27 |
class TDmaCancelInfo : public SDblQueLink |
|
28 |
{ |
|
29 |
public: |
|
30 |
TDmaCancelInfo(); |
|
31 |
void Signal(); |
|
32 |
public: |
|
33 |
NFastSemaphore iSem; |
|
34 |
}; |
|
35 |
||
36 |
TDmaCancelInfo::TDmaCancelInfo() |
|
37 |
: iSem(0) |
|
38 |
{ |
|
39 |
iNext = this; |
|
40 |
iPrev = this; |
|
41 |
} |
|
42 |
||
43 |
void TDmaCancelInfo::Signal() |
|
44 |
{ |
|
45 |
TDmaCancelInfo* p = this; |
|
46 |
FOREVER |
|
47 |
{ |
|
48 |
TDmaCancelInfo* next = (TDmaCancelInfo*)p->iNext; |
|
49 |
if (p!=next) |
|
50 |
p->Deque(); |
|
51 |
NKern::FSSignal(&p->iSem); // Don't dereference p after this |
|
52 |
if (p==next) |
|
53 |
break; |
|
54 |
p = next; |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
////////////////////////////////////////////////////////////////////////////// |
|
59 |
||
60 |
#ifdef __DMASIM__ |
|
61 |
#ifdef __WINS__ |
|
62 |
typedef TLinAddr TPhysAddr; |
|
63 |
#endif |
|
64 |
static inline TPhysAddr LinToPhys(TLinAddr aLin) {return aLin;} |
|
65 |
#else |
|
66 |
static inline TPhysAddr LinToPhys(TLinAddr aLin) {return Epoc::LinearToPhysical(aLin);} |
|
67 |
#endif |
|
68 |
||
69 |
// |
|
70 |
// Return minimum of aMaxSize and size of largest physically contiguous block |
|
71 |
// starting at aLinAddr. |
|
72 |
// |
|
73 |
static TInt MaxPhysSize(TLinAddr aLinAddr, const TInt aMaxSize) |
|
74 |
{ |
|
75 |
const TPhysAddr physBase = LinToPhys(aLinAddr); |
|
76 |
TLinAddr lin = aLinAddr; |
|
77 |
TInt size = 0; |
|
78 |
for (;;) |
|
79 |
{ |
|
80 |
// Round up the linear address to the next MMU page boundary |
|
81 |
const TLinAddr linBoundary = Kern::RoundToPageSize(lin + 1); |
|
82 |
size += linBoundary - lin; |
|
83 |
if (size >= aMaxSize) |
|
84 |
return aMaxSize; |
|
85 |
if ((physBase + size) != LinToPhys(linBoundary)) |
|
86 |
return size; |
|
87 |
lin = linBoundary; |
|
88 |
} |
|
89 |
} |
|
90 |
||
91 |
||
92 |
////////////////////////////////////////////////////////////////////////////// |
|
93 |
// TDmac |
|
94 |
||
95 |
TDmac::TDmac(const SCreateInfo& aInfo) |
|
96 |
: iMaxDesCount(aInfo.iDesCount), |
|
97 |
iAvailDesCount(aInfo.iDesCount), |
|
98 |
iDesSize(aInfo.iDesSize), |
|
99 |
iCaps(aInfo.iCaps) |
|
100 |
{ |
|
101 |
__DMA_ASSERTD(iMaxDesCount > 0); |
|
102 |
__DMA_ASSERTD((iCaps & ~KCapsBitHwDes) == 0); // undefined bits set? |
|
103 |
__DMA_ASSERTD(iDesSize > 0); |
|
104 |
} |
|
105 |
||
106 |
// |
|
107 |
// Second-phase c'tor |
|
108 |
// |
|
109 |
||
110 |
TInt TDmac::Create(const SCreateInfo& aInfo) |
|
111 |
{ |
|
112 |
iHdrPool = new SDmaDesHdr[iMaxDesCount]; |
|
113 |
if (iHdrPool == NULL) |
|
114 |
return KErrNoMemory; |
|
115 |
||
116 |
TInt r = AllocDesPool(aInfo.iDesChunkAttribs); |
|
117 |
if (r != KErrNone) |
|
118 |
return KErrNoMemory; |
|
119 |
||
120 |
// Link all descriptor headers together on the free list |
|
121 |
iFreeHdr = iHdrPool; |
|
122 |
TInt i; |
|
123 |
for (i = 0; i < iMaxDesCount - 1; i++) |
|
124 |
iHdrPool[i].iNext = iHdrPool + i + 1; |
|
125 |
iHdrPool[iMaxDesCount-1].iNext = NULL; |
|
126 |
||
127 |
__DMA_INVARIANT(); |
|
128 |
return KErrNone; |
|
129 |
} |
|
130 |
||
131 |
||
132 |
TDmac::~TDmac() |
|
133 |
{ |
|
134 |
__DMA_INVARIANT(); |
|
135 |
||
136 |
FreeDesPool(); |
|
137 |
delete[] iHdrPool; |
|
138 |
} |
|
139 |
||
140 |
||
141 |
// Calling thread must be in CS |
|
142 |
TInt TDmac::AllocDesPool(TUint aAttribs) |
|
143 |
{ |
|
144 |
TInt r; |
|
145 |
if (iCaps & KCapsBitHwDes) |
|
146 |
{ |
|
147 |
TInt size = iMaxDesCount*iDesSize; |
|
148 |
#ifdef __WINS__ |
|
149 |
(void)aAttribs; |
|
150 |
iDesPool = new TUint8[size]; |
|
151 |
r = iDesPool ? KErrNone : KErrNoMemory; |
|
152 |
#else |
|
153 |
// Chunk not mapped as supervisor r/w user none? incorrect mask passed by PSL |
|
154 |
__DMA_ASSERTD((aAttribs & EMapAttrAccessMask) == EMapAttrSupRw); |
|
155 |
TPhysAddr phys; |
|
156 |
r = Epoc::AllocPhysicalRam(size, phys); |
|
157 |
if (r == KErrNone) |
|
158 |
{ |
|
159 |
r = DPlatChunkHw::New(iHwDesChunk, phys, size, aAttribs); |
|
160 |
if (r == KErrNone) |
|
161 |
{ |
|
162 |
iDesPool = (TAny*)iHwDesChunk->LinearAddress(); |
|
163 |
__KTRACE_OPT(KDMA, Kern::Printf("descriptor hw chunk created lin=0x%08X phys=0x%08X, size=0x%X", |
|
164 |
iHwDesChunk->iLinAddr, iHwDesChunk->iPhysAddr, size)); |
|
165 |
} |
|
166 |
else |
|
167 |
Epoc::FreePhysicalRam(phys, size); |
|
168 |
} |
|
169 |
#endif |
|
170 |
} |
|
171 |
else |
|
172 |
{ |
|
173 |
iDesPool = new SDmaPseudoDes[iMaxDesCount]; |
|
174 |
r = iDesPool ? KErrNone : KErrNoMemory; |
|
175 |
} |
|
176 |
return r; |
|
177 |
} |
|
178 |
||
179 |
||
180 |
// Calling thread must be in CS |
|
181 |
void TDmac::FreeDesPool() |
|
182 |
{ |
|
183 |
if (iCaps & KCapsBitHwDes) |
|
184 |
{ |
|
185 |
#ifdef __WINS__ |
|
186 |
delete[] iDesPool; |
|
187 |
#else |
|
188 |
if (iHwDesChunk) |
|
189 |
{ |
|
190 |
TPhysAddr phys = iHwDesChunk->PhysicalAddress(); |
|
191 |
TInt size = iHwDesChunk->iSize; |
|
192 |
iHwDesChunk->Close(NULL); |
|
193 |
Epoc::FreePhysicalRam(phys, size); |
|
194 |
} |
|
195 |
#endif |
|
196 |
} |
|
197 |
else |
|
198 |
Kern::Free(iDesPool); |
|
199 |
} |
|
200 |
||
201 |
||
202 |
/** |
|
203 |
Prealloc the given number of descriptors. |
|
204 |
*/ |
|
205 |
||
206 |
TInt TDmac::ReserveSetOfDes(TInt aCount) |
|
207 |
{ |
|
208 |
__KTRACE_OPT(KDMA, Kern::Printf(">TDmac::ReserveSetOfDes count=%d", aCount)); |
|
209 |
__DMA_ASSERTD(aCount > 0); |
|
210 |
TInt r = KErrTooBig; |
|
211 |
Wait(); |
|
212 |
if (iAvailDesCount - aCount >= 0) |
|
213 |
{ |
|
214 |
iAvailDesCount -= aCount; |
|
215 |
r = KErrNone; |
|
216 |
} |
|
217 |
Signal(); |
|
218 |
__DMA_INVARIANT(); |
|
219 |
__KTRACE_OPT(KDMA, Kern::Printf("<TDmac::ReserveSetOfDes r=%d", r)); |
|
220 |
return r; |
|
221 |
} |
|
222 |
||
223 |
||
224 |
/** |
|
225 |
Return the given number of preallocated descriptors to the free pool. |
|
226 |
*/ |
|
227 |
||
228 |
void TDmac::ReleaseSetOfDes(TInt aCount) |
|
229 |
{ |
|
230 |
__DMA_ASSERTD(aCount >= 0); |
|
231 |
Wait(); |
|
232 |
iAvailDesCount += aCount; |
|
233 |
Signal(); |
|
234 |
__DMA_INVARIANT(); |
|
235 |
} |
|
236 |
||
237 |
||
238 |
/** |
|
239 |
Queue DFC and update word used to communicate with DFC. |
|
240 |
||
241 |
Called in interrupt context by PSL. |
|
242 |
*/ |
|
243 |
||
244 |
void TDmac::HandleIsr(TDmaChannel& aChannel, TBool aIsComplete) |
|
245 |
{ |
|
246 |
//__KTRACE_OPT(KDMA, Kern::Printf("TDmac::HandleIsr channel=%d complete=%d", aChannelIdx, aIsComplete)); |
|
247 |
||
248 |
// Queue DFC if necessary. The possible scenarios are: |
|
249 |
// * no DFC queued --> need to queue DFC |
|
250 |
// * DFC queued (not running yet) --> just need to update iIsrDfc |
|
251 |
// * DFC running / iIsrDfc already reset --> need to requeue DFC |
|
252 |
// * DFC running / iIsrDfc not reset yet --> just need to update iIsrDfc |
|
253 |
// Set error flag if necessary. |
|
254 |
TUint32 inc = aIsComplete ? 1u : TUint32(TDmaChannel::KErrorFlagMask)|1u; |
|
255 |
TUint32 orig = __e32_atomic_tau_ord32(&aChannel.iIsrDfc, TUint32(TDmaChannel::KCancelFlagMask), 0, inc); |
|
256 |
||
257 |
// As transfer should be suspended when an error occurs, we |
|
258 |
// should never get there with the error flag already set. |
|
259 |
__DMA_ASSERTD((orig & inc & (TUint32)TDmaChannel::KErrorFlagMask) == 0); |
|
260 |
||
261 |
if (orig == 0) |
|
262 |
aChannel.iDfc.Add(); |
|
263 |
} |
|
264 |
||
265 |
||
266 |
void TDmac::InitDes(const SDmaDesHdr& aHdr, TUint32 aSrc, TUint32 aDest, TInt aCount, |
|
267 |
TUint aFlags, TUint32 aPslInfo, TUint32 aCookie) |
|
268 |
{ |
|
269 |
if (iCaps & KCapsBitHwDes) |
|
270 |
InitHwDes(aHdr, aSrc, aDest, aCount, aFlags, aPslInfo, aCookie); |
|
271 |
else |
|
272 |
{ |
|
273 |
SDmaPseudoDes& des = HdrToDes(aHdr); |
|
274 |
des.iSrc = aSrc; |
|
275 |
des.iDest = aDest; |
|
276 |
des.iCount = aCount; |
|
277 |
des.iFlags = aFlags; |
|
278 |
des.iPslInfo = aPslInfo; |
|
279 |
des.iCookie = aCookie; |
|
280 |
} |
|
281 |
} |
|
282 |
||
283 |
||
284 |
void TDmac::InitHwDes(const SDmaDesHdr& /*aHdr*/, TUint32 /*aSrc*/, TUint32 /*aDest*/, TInt /*aCount*/, |
|
285 |
TUint /*aFlags*/, TUint32 /*aPslInfo*/, TUint32 /*aCookie*/) |
|
286 |
{ |
|
287 |
// concrete controller must override if KCapsBitHwDes set |
|
288 |
__DMA_CANT_HAPPEN(); |
|
289 |
} |
|
290 |
||
291 |
||
292 |
void TDmac::ChainHwDes(const SDmaDesHdr& /*aHdr*/, const SDmaDesHdr& /*aNextHdr*/) |
|
293 |
{ |
|
294 |
// concrete controller must override if KCapsBitHwDes set |
|
295 |
__DMA_CANT_HAPPEN(); |
|
296 |
} |
|
297 |
||
298 |
||
299 |
void TDmac::AppendHwDes(const TDmaChannel& /*aChannel*/, const SDmaDesHdr& /*aLastHdr*/, |
|
300 |
const SDmaDesHdr& /*aNewHdr*/) |
|
301 |
{ |
|
302 |
// concrete controller must override if KCapsBitHwDes set |
|
303 |
__DMA_CANT_HAPPEN(); |
|
304 |
} |
|
305 |
||
306 |
||
307 |
void TDmac::UnlinkHwDes(const TDmaChannel& /*aChannel*/, SDmaDesHdr& /*aHdr*/) |
|
308 |
{ |
|
309 |
// concrete controller must override if KCapsBitHwDes set |
|
310 |
__DMA_CANT_HAPPEN(); |
|
311 |
} |
|
312 |
||
313 |
||
314 |
TInt TDmac::FailNext(const TDmaChannel& /*aChannel*/) |
|
315 |
{ |
|
316 |
return KErrNotSupported; |
|
317 |
} |
|
318 |
||
319 |
||
320 |
TInt TDmac::MissNextInterrupts(const TDmaChannel& /*aChannel*/, TInt /*aInterruptCount*/) |
|
321 |
{ |
|
322 |
return KErrNotSupported; |
|
323 |
} |
|
324 |
||
325 |
||
326 |
TInt TDmac::Extension(TDmaChannel& /*aChannel*/, TInt /*aCmd*/, TAny* /*aArg*/) |
|
327 |
{ |
|
328 |
// default implementation - NOP |
|
329 |
return KErrNotSupported; |
|
330 |
} |
|
331 |
||
332 |
||
333 |
#ifdef _DEBUG |
|
334 |
||
335 |
void TDmac::Invariant() |
|
336 |
{ |
|
337 |
Wait(); |
|
338 |
__DMA_ASSERTD(0 <= iAvailDesCount && iAvailDesCount <= iMaxDesCount); |
|
339 |
__DMA_ASSERTD(! iFreeHdr || IsValidHdr(iFreeHdr)); |
|
340 |
for (TInt i = 0; i < iMaxDesCount; i++) |
|
341 |
__DMA_ASSERTD(iHdrPool[i].iNext == NULL || IsValidHdr(iHdrPool[i].iNext)); |
|
342 |
Signal(); |
|
343 |
} |
|
344 |
||
345 |
||
346 |
TBool TDmac::IsValidHdr(const SDmaDesHdr* aHdr) |
|
347 |
{ |
|
348 |
return (iHdrPool <= aHdr) && (aHdr < iHdrPool + iMaxDesCount); |
|
349 |
} |
|
350 |
||
351 |
#endif |
|
352 |
||
353 |
////////////////////////////////////////////////////////////////////////////// |
|
354 |
// DDmaRequest |
|
355 |
||
356 |
||
357 |
EXPORT_C DDmaRequest::DDmaRequest(TDmaChannel& aChannel, TCallback aCb, TAny* aCbArg, TInt aMaxTransferSize) |
|
358 |
: iChannel(aChannel), |
|
359 |
iCb(aCb), |
|
360 |
iCbArg(aCbArg), |
|
361 |
iMaxTransferSize(aMaxTransferSize) |
|
362 |
{ |
|
363 |
// iDesCount = 0; |
|
364 |
// iFirstHdr = iLastHdr = NULL; |
|
365 |
// iQueued = EFalse; |
|
366 |
iChannel.iReqCount++; |
|
367 |
__DMA_INVARIANT(); |
|
368 |
} |
|
369 |
||
370 |
||
371 |
||
372 |
EXPORT_C DDmaRequest::~DDmaRequest() |
|
373 |
{ |
|
374 |
__DMA_ASSERTD(!iQueued); |
|
375 |
__DMA_INVARIANT(); |
|
376 |
FreeDesList(); |
|
377 |
iChannel.iReqCount--; |
|
378 |
} |
|
379 |
||
380 |
||
381 |
||
382 |
EXPORT_C TInt DDmaRequest::Fragment(TUint32 aSrc, TUint32 aDest, TInt aCount, TUint aFlags, TUint32 aPslInfo) |
|
383 |
{ |
|
384 |
__KTRACE_OPT(KDMA, Kern::Printf("DDmaRequest::Fragment thread %O " |
|
385 |
"src=0x%08X dest=0x%08X count=%d flags=0x%X psl=0x%08X", |
|
386 |
&Kern::CurrentThread(), aSrc, aDest, aCount, aFlags, aPslInfo)); |
|
387 |
__DMA_ASSERTD(aCount > 0); |
|
388 |
__DMA_ASSERTD(!iQueued); |
|
389 |
||
390 |
const TUint alignMask = iChannel.MemAlignMask(aFlags, aPslInfo); |
|
391 |
const TBool memSrc = aFlags & KDmaMemSrc; |
|
392 |
const TBool memDest = aFlags & KDmaMemDest; |
|
393 |
||
394 |
// Memory buffers must satisfy alignment constraint |
|
395 |
__DMA_ASSERTD(!memSrc || ((aSrc & alignMask) == 0)); |
|
396 |
__DMA_ASSERTD(!memDest || ((aDest & alignMask) == 0)); |
|
397 |
||
398 |
// Ask the PSL what the maximum size possible for this transfer is |
|
399 |
TInt maxTransferSize = iChannel.MaxTransferSize(aFlags, aPslInfo); |
|
400 |
if (!maxTransferSize) |
|
401 |
{ |
|
402 |
__KTRACE_OPT(KPANIC, Kern::Printf("Error: maxTransferSize == 0")); |
|
403 |
return KErrArgument; |
|
404 |
} |
|
405 |
||
406 |
if (iMaxTransferSize) |
|
407 |
{ |
|
408 |
// User has set a size cap |
|
409 |
__DMA_ASSERTA((iMaxTransferSize <= maxTransferSize) || (maxTransferSize == -1)); |
|
410 |
maxTransferSize = iMaxTransferSize; |
|
411 |
} |
|
412 |
else |
|
413 |
{ |
|
414 |
// User doesn't care about max size |
|
415 |
if (maxTransferSize == -1) |
|
416 |
{ |
|
417 |
// No maximum imposed by controller |
|
418 |
maxTransferSize = aCount; |
|
419 |
} |
|
420 |
} |
|
421 |
||
422 |
const TInt maxAlignedSize = (maxTransferSize & ~alignMask); |
|
423 |
__DMA_ASSERTD(maxAlignedSize > 0); // bug in PSL if not true |
|
424 |
||
425 |
FreeDesList(); |
|
426 |
||
427 |
TInt r = KErrNone; |
|
428 |
do |
|
429 |
{ |
|
430 |
// Allocate fragment |
|
431 |
r = ExpandDesList(); |
|
432 |
if (r != KErrNone) |
|
433 |
{ |
|
434 |
FreeDesList(); |
|
435 |
break; |
|
436 |
} |
|
437 |
||
438 |
// Compute fragment size |
|
439 |
TInt c = Min(maxTransferSize, aCount); |
|
440 |
if (memSrc && ((aFlags & KDmaPhysAddrSrc) == 0)) |
|
441 |
c = MaxPhysSize(aSrc, c); |
|
442 |
if (memDest && ((aFlags & KDmaPhysAddrDest) == 0)) |
|
443 |
c = MaxPhysSize(aDest, c); |
|
444 |
if ((memSrc || memDest) && (c < aCount) && (c > maxAlignedSize)) |
|
445 |
{ |
|
446 |
// This is not last fragment of transfer to/from memory. We must |
|
447 |
// round down fragment size so next one is correctly aligned. |
|
448 |
c = maxAlignedSize; |
|
449 |
} |
|
450 |
||
451 |
// Initialise fragment |
|
452 |
__KTRACE_OPT(KDMA, Kern::Printf("fragment: src=0x%08X dest=0x%08X count=%d", aSrc, aDest, c)); |
|
453 |
iChannel.iController->InitDes(*iLastHdr, aSrc, aDest, c, aFlags, aPslInfo, iChannel.PslId()); |
|
454 |
||
455 |
// Update for next iteration |
|
456 |
aCount -= c; |
|
457 |
if (memSrc) |
|
458 |
aSrc += c; |
|
459 |
if (memDest) |
|
460 |
aDest += c; |
|
461 |
} |
|
462 |
while (aCount > 0); |
|
463 |
||
464 |
__DMA_INVARIANT(); |
|
465 |
return r; |
|
466 |
} |
|
467 |
||
468 |
||
469 |
||
470 |
EXPORT_C void DDmaRequest::Queue() |
|
471 |
{ |
|
472 |
__KTRACE_OPT(KDMA, Kern::Printf("DDmaRequest::Queue thread %O", &Kern::CurrentThread())); |
|
473 |
__DMA_ASSERTD(iDesCount > 0); // Not configured? call Fragment() first ! |
|
474 |
__DMA_ASSERTD(!iQueued); |
|
475 |
||
476 |
// append request to queue and link new descriptor list to existing one. |
|
477 |
iChannel.Wait(); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
478 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
479 |
TUint32 req_count = iChannel.iQueuedRequests++; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
480 |
if (req_count == 0) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
iChannel.Signal(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
iChannel.QueuedRequestCountChanged(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
484 |
iChannel.Wait(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
485 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
486 |
|
0 | 487 |
if (!(iChannel.iIsrDfc & (TUint32)TDmaChannel::KCancelFlagMask)) |
488 |
{ |
|
489 |
iQueued = ETrue; |
|
490 |
iChannel.iReqQ.Add(&iLink); |
|
491 |
*iChannel.iNullPtr = iFirstHdr; |
|
492 |
iChannel.iNullPtr = &(iLastHdr->iNext); |
|
493 |
iChannel.DoQueue(*this); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
494 |
iChannel.Signal(); |
0 | 495 |
} |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
497 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
// Someone is cancelling all requests... |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
req_count = --iChannel.iQueuedRequests; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
500 |
iChannel.Signal(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
501 |
if (req_count == 0) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
502 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
503 |
iChannel.QueuedRequestCountChanged(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
504 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
505 |
} |
0 | 506 |
|
507 |
__DMA_INVARIANT(); |
|
508 |
} |
|
509 |
||
510 |
EXPORT_C TInt DDmaRequest::ExpandDesList(TInt aCount) |
|
511 |
{ |
|
512 |
__DMA_ASSERTD(!iQueued); |
|
513 |
__DMA_ASSERTD(aCount > 0); |
|
514 |
||
515 |
if (aCount > iChannel.iAvailDesCount) |
|
516 |
return KErrTooBig; |
|
517 |
||
518 |
iChannel.iAvailDesCount -= aCount; |
|
519 |
iDesCount += aCount; |
|
520 |
||
521 |
TDmac& c = *(iChannel.iController); |
|
522 |
c.Wait(); |
|
523 |
||
524 |
if (iFirstHdr == NULL) |
|
525 |
{ |
|
526 |
// handle empty list specially to simplify following loop |
|
527 |
iFirstHdr = iLastHdr = c.iFreeHdr; |
|
528 |
c.iFreeHdr = c.iFreeHdr->iNext; |
|
529 |
--aCount; |
|
530 |
} |
|
531 |
else |
|
532 |
iLastHdr->iNext = c.iFreeHdr; |
|
533 |
||
534 |
// Remove as many descriptors and headers from free pool as necessary and |
|
535 |
// ensure hardware descriptors are chained together. |
|
536 |
while (aCount-- > 0) |
|
537 |
{ |
|
538 |
__DMA_ASSERTD(c.iFreeHdr != NULL); |
|
539 |
if (c.iCaps & TDmac::KCapsBitHwDes) |
|
540 |
c.ChainHwDes(*iLastHdr, *(c.iFreeHdr)); |
|
541 |
iLastHdr = c.iFreeHdr; |
|
542 |
c.iFreeHdr = c.iFreeHdr->iNext; |
|
543 |
} |
|
544 |
||
545 |
c.Signal(); |
|
546 |
||
547 |
iLastHdr->iNext = NULL; |
|
548 |
||
549 |
__DMA_INVARIANT(); |
|
550 |
return KErrNone; |
|
551 |
} |
|
552 |
||
553 |
||
554 |
||
555 |
||
556 |
EXPORT_C void DDmaRequest::FreeDesList() |
|
557 |
{ |
|
558 |
__DMA_ASSERTD(!iQueued); |
|
559 |
if (iDesCount > 0) |
|
560 |
{ |
|
561 |
iChannel.iAvailDesCount += iDesCount; |
|
562 |
TDmac& c = *(iChannel.iController); |
|
563 |
c.Wait(); |
|
564 |
iLastHdr->iNext = c.iFreeHdr; |
|
565 |
c.iFreeHdr = iFirstHdr; |
|
566 |
c.Signal(); |
|
567 |
iFirstHdr = iLastHdr = NULL; |
|
568 |
iDesCount = 0; |
|
569 |
} |
|
570 |
} |
|
571 |
||
572 |
||
573 |
#ifdef _DEBUG |
|
574 |
||
575 |
void DDmaRequest::Invariant() |
|
576 |
{ |
|
577 |
iChannel.Wait(); |
|
578 |
__DMA_ASSERTD(iChannel.IsOpened()); |
|
579 |
__DMA_ASSERTD(0 <= iMaxTransferSize); |
|
580 |
__DMA_ASSERTD(0 <= iDesCount && iDesCount <= iChannel.iMaxDesCount); |
|
581 |
if (iDesCount == 0) |
|
582 |
{ |
|
583 |
__DMA_ASSERTD(!iQueued); |
|
584 |
__DMA_ASSERTD(!iFirstHdr && !iLastHdr); |
|
585 |
} |
|
586 |
else |
|
587 |
{ |
|
588 |
__DMA_ASSERTD(iChannel.iController->IsValidHdr(iFirstHdr)); |
|
589 |
__DMA_ASSERTD(iChannel.iController->IsValidHdr(iLastHdr)); |
|
590 |
} |
|
591 |
iChannel.Signal(); |
|
592 |
} |
|
593 |
||
594 |
#endif |
|
595 |
||
596 |
||
597 |
////////////////////////////////////////////////////////////////////////////// |
|
598 |
// TDmaChannel |
|
599 |
||
600 |
||
601 |
EXPORT_C TInt TDmaChannel::StaticExtension(TInt aCmd, TAny* aArg) |
|
602 |
{ |
|
603 |
return DmaChannelMgr::StaticExtension(aCmd, aArg); |
|
604 |
} |
|
605 |
||
606 |
||
607 |
TDmaChannel::TDmaChannel() |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
608 |
: iController(NULL), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
609 |
iPslId(0), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
610 |
iCurHdr(NULL), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
611 |
iNullPtr(&iCurHdr), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
612 |
iDfc(Dfc, NULL, 0), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
613 |
iMaxDesCount(0), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
614 |
iAvailDesCount(0), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
615 |
iIsrDfc(0), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
616 |
iReqQ(), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
617 |
iReqCount(0), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
618 |
iQueuedRequests(0), |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
619 |
iCancelInfo(NULL) |
0 | 620 |
{ |
621 |
__DMA_INVARIANT(); |
|
622 |
} |
|
623 |
||
624 |
||
625 |
EXPORT_C TInt TDmaChannel::Open(const SCreateInfo& aInfo, TDmaChannel*& aChannel) |
|
626 |
{ |
|
627 |
__KTRACE_OPT(KDMA, Kern::Printf("TDmaChannel::Open thread %O", &Kern::CurrentThread())); |
|
628 |
__DMA_ASSERTD(aInfo.iDfcQ != NULL); |
|
629 |
__DMA_ASSERTD(aInfo.iDfcPriority < KNumDfcPriorities); |
|
630 |
__DMA_ASSERTD(aInfo.iDesCount >= 1); |
|
631 |
||
632 |
aChannel = NULL; |
|
633 |
||
634 |
DmaChannelMgr::Wait(); |
|
635 |
TDmaChannel* pC = DmaChannelMgr::Open(aInfo.iCookie); |
|
636 |
DmaChannelMgr::Signal(); |
|
637 |
if (!pC) |
|
638 |
return KErrInUse; |
|
639 |
||
640 |
TInt r = pC->iController->ReserveSetOfDes(aInfo.iDesCount); |
|
641 |
if (r != KErrNone) |
|
642 |
{ |
|
643 |
pC->Close(); |
|
644 |
return r; |
|
645 |
} |
|
646 |
pC->iAvailDesCount = pC->iMaxDesCount = aInfo.iDesCount; |
|
647 |
||
648 |
new (&pC->iDfc) TDfc(&Dfc, pC, aInfo.iDfcQ, aInfo.iDfcPriority); |
|
649 |
||
650 |
aChannel = pC; |
|
651 |
||
652 |
#ifdef _DEBUG |
|
653 |
pC->Invariant(); |
|
654 |
#endif |
|
655 |
__KTRACE_OPT(KDMA, Kern::Printf("opened channel %d", pC->iPslId)); |
|
656 |
return KErrNone; |
|
657 |
} |
|
658 |
||
659 |
||
660 |
EXPORT_C void TDmaChannel::Close() |
|
661 |
{ |
|
662 |
__KTRACE_OPT(KDMA, Kern::Printf("TDmaChannel::Close %d", iPslId)); |
|
663 |
__DMA_ASSERTD(IsOpened()); |
|
664 |
__DMA_ASSERTD(IsQueueEmpty()); |
|
665 |
__DMA_ASSERTD(iReqCount == 0); |
|
666 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
667 |
__DMA_ASSERTD(iQueuedRequests == 0); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
668 |
|
0 | 669 |
// descriptor leak? bug in request code |
670 |
__DMA_ASSERTD(iAvailDesCount == iMaxDesCount); |
|
671 |
||
672 |
iController->ReleaseSetOfDes(iMaxDesCount); |
|
673 |
iAvailDesCount = iMaxDesCount = 0; |
|
674 |
||
675 |
DmaChannelMgr::Wait(); |
|
676 |
DmaChannelMgr::Close(this); |
|
677 |
iController = NULL; |
|
678 |
DmaChannelMgr::Signal(); |
|
679 |
||
680 |
__DMA_INVARIANT(); |
|
681 |
} |
|
682 |
||
683 |
||
684 |
EXPORT_C void TDmaChannel::CancelAll() |
|
685 |
{ |
|
686 |
__KTRACE_OPT(KDMA, Kern::Printf("TDmaChannel::CancelAll thread %O channel - %d", |
|
687 |
&Kern::CurrentThread(), iPslId)); |
|
688 |
__DMA_ASSERTD(IsOpened()); |
|
689 |
||
690 |
NThread* nt = NKern::CurrentThread(); |
|
691 |
TBool wait = FALSE; |
|
692 |
TDmaCancelInfo c; |
|
693 |
TDmaCancelInfo* waiters = 0; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
694 |
|
0 | 695 |
NKern::ThreadEnterCS(); |
696 |
Wait(); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
697 |
const TUint32 req_count_before = iQueuedRequests; |
0 | 698 |
NThreadBase* dfcnt = iDfc.Thread(); |
699 |
__e32_atomic_store_ord32(&iIsrDfc, (TUint32)KCancelFlagMask); |
|
700 |
// ISRs after this point will not post a DFC, however a DFC may already be queued or running or both |
|
701 |
if (!IsQueueEmpty()) |
|
702 |
{ |
|
703 |
// There is a transfer in progress. It may complete before the DMAC |
|
704 |
// has stopped, but the resulting ISR will not post a DFC. |
|
705 |
// ISR should not happen after this function returns. |
|
706 |
iController->StopTransfer(*this); |
|
707 |
||
708 |
ResetStateMachine(); |
|
709 |
||
710 |
// Clean-up the request queue. |
|
711 |
SDblQueLink* pL; |
|
712 |
while ((pL = iReqQ.GetFirst()) != NULL) |
|
713 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
714 |
iQueuedRequests--; |
0 | 715 |
DDmaRequest* pR = _LOFF(pL, DDmaRequest, iLink); |
716 |
pR->OnDeque(); |
|
717 |
} |
|
718 |
} |
|
719 |
if (!dfcnt || dfcnt==nt) |
|
720 |
{ |
|
721 |
// no DFC queue or DFC runs in this thread, so just cancel it and we're finished |
|
722 |
iDfc.Cancel(); |
|
723 |
||
724 |
// if other calls to CancelAll() are waiting for the DFC, release them here |
|
725 |
waiters = iCancelInfo; |
|
726 |
iCancelInfo = 0; |
|
727 |
||
728 |
// reset the ISR count |
|
729 |
__e32_atomic_store_rel32(&iIsrDfc, 0); |
|
730 |
} |
|
731 |
else |
|
732 |
{ |
|
733 |
// DFC runs in another thread. Make sure it's queued and then wait for it to run. |
|
734 |
if (iCancelInfo) |
|
735 |
c.InsertBefore(iCancelInfo); |
|
736 |
else |
|
737 |
iCancelInfo = &c; |
|
738 |
wait = TRUE; |
|
739 |
iDfc.Enque(); |
|
740 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
741 |
const TUint32 req_count_after = iQueuedRequests; |
0 | 742 |
Signal(); |
743 |
if (waiters) |
|
744 |
waiters->Signal(); |
|
745 |
if (wait) |
|
746 |
NKern::FSWait(&c.iSem); |
|
747 |
NKern::ThreadLeaveCS(); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
748 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
749 |
// Only call PSL if there were requests queued when we entered AND there |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
750 |
// are now no requests left on the queue. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
751 |
if ((req_count_before != 0) && (req_count_after == 0)) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
752 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
753 |
QueuedRequestCountChanged(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
754 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
755 |
|
0 | 756 |
__DMA_INVARIANT(); |
757 |
} |
|
758 |
||
759 |
||
760 |
/** |
|
761 |
DFC callback function (static member). |
|
762 |
*/ |
|
763 |
||
764 |
void TDmaChannel::Dfc(TAny* aArg) |
|
765 |
{ |
|
766 |
((TDmaChannel*)aArg)->DoDfc(); |
|
767 |
} |
|
768 |
||
769 |
||
770 |
void TDmaChannel::DoDfc() |
|
771 |
{ |
|
772 |
Wait(); |
|
773 |
||
774 |
// Atomically fetch and reset the number of DFC queued by ISR and the error |
|
775 |
// flag. Leave the cancel flag alone for now. |
|
776 |
const TUint32 w = __e32_atomic_and_ord32(&iIsrDfc, (TUint32)KCancelFlagMask); |
|
777 |
TUint32 count = w & KDfcCountMask; |
|
778 |
const TBool error = w & (TUint32)KErrorFlagMask; |
|
779 |
TBool stop = w & (TUint32)KCancelFlagMask; |
|
780 |
__DMA_ASSERTD(count>0 || stop); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
781 |
const TUint32 req_count_before = iQueuedRequests; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
782 |
TUint32 req_count_after = 0; |
0 | 783 |
|
784 |
while(count && !stop) |
|
785 |
{ |
|
786 |
--count; |
|
787 |
||
788 |
// If an error occurred it must have been reported on the last interrupt since transfers are |
|
789 |
// suspended after an error. |
|
790 |
DDmaRequest::TResult res = (count==0 && error) ? DDmaRequest::EError : DDmaRequest::EOk; |
|
791 |
__DMA_ASSERTD(!iReqQ.IsEmpty()); |
|
792 |
DDmaRequest* pCompletedReq = NULL; |
|
793 |
DDmaRequest* pCurReq = _LOFF(iReqQ.First(), DDmaRequest, iLink); |
|
794 |
DDmaRequest::TCallback cb = 0; |
|
795 |
TAny* arg = 0; |
|
796 |
||
797 |
if (res == DDmaRequest::EOk) |
|
798 |
{ |
|
799 |
// Update state machine, current fragment, completed fragment and |
|
800 |
// tell DMAC to transfer next fragment if necessary. |
|
801 |
SDmaDesHdr* pCompletedHdr = NULL; |
|
802 |
DoDfc(*pCurReq, pCompletedHdr); |
|
803 |
||
804 |
// If just completed last fragment from current request, switch to next |
|
805 |
// request (if any). |
|
806 |
if (pCompletedHdr == pCurReq->iLastHdr) |
|
807 |
{ |
|
808 |
pCompletedReq = pCurReq; |
|
809 |
pCurReq->iLink.Deque(); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
810 |
iQueuedRequests--; |
0 | 811 |
if (iReqQ.IsEmpty()) |
812 |
iNullPtr = &iCurHdr; |
|
813 |
pCompletedReq->OnDeque(); |
|
814 |
} |
|
815 |
} |
|
816 |
else if (res == DDmaRequest::EError) |
|
817 |
pCompletedReq = pCurReq; |
|
818 |
else |
|
819 |
__DMA_CANT_HAPPEN(); |
|
820 |
if (pCompletedReq) |
|
821 |
{ |
|
822 |
cb = pCompletedReq->iCb; |
|
823 |
arg = pCompletedReq->iCbArg; |
|
824 |
Signal(); |
|
825 |
__KTRACE_OPT(KDMA, Kern::Printf("notifying DMA client result=%d", res)); |
|
826 |
(*cb)(res,arg); |
|
827 |
Wait(); |
|
828 |
} |
|
829 |
if (pCompletedReq || Flash()) |
|
830 |
stop = __e32_atomic_load_acq32(&iIsrDfc) & (TUint32)KCancelFlagMask; |
|
831 |
} |
|
832 |
||
833 |
// Some interrupts may be missed (double-buffer and scatter-gather |
|
834 |
// controllers only) if two or more transfers complete while interrupts are |
|
835 |
// disabled in the CPU. If this happens, the framework will go out of sync |
|
836 |
// and leave some orphaned requests in the queue. |
|
837 |
// |
|
838 |
// To ensure correctness we handle this case here by checking that the request |
|
839 |
// queue is empty when all transfers have completed and, if not, cleaning up |
|
840 |
// and notifying the client of the completion of the orphaned requests. |
|
841 |
// |
|
842 |
// Note that if some interrupts are missed and the controller raises an |
|
843 |
// error while transferring a subsequent fragment, the error will be reported |
|
844 |
// on a fragment which was successfully completed. There is no easy solution |
|
845 |
// to this problem, but this is okay as the only possible action following a |
|
846 |
// failure is to flush the whole queue. |
|
847 |
if (stop) |
|
848 |
{ |
|
849 |
TDmaCancelInfo* waiters = iCancelInfo; |
|
850 |
iCancelInfo = 0; |
|
851 |
||
852 |
// make sure DFC doesn't run again until a new request completes |
|
853 |
iDfc.Cancel(); |
|
854 |
||
855 |
// reset the ISR count - new requests can now be processed |
|
856 |
__e32_atomic_store_rel32(&iIsrDfc, 0); |
|
857 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
858 |
req_count_after = iQueuedRequests; |
0 | 859 |
Signal(); |
860 |
||
861 |
// release threads doing CancelAll() |
|
862 |
waiters->Signal(); |
|
863 |
} |
|
87
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
81
diff
changeset
|
864 |
#ifndef DISABLE_MISSED_IRQ_RECOVERY |
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
80
diff
changeset
|
865 |
// (iController may be NULL here if the channel was closed in the client callback.) |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
80
diff
changeset
|
866 |
else if (!error && |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
80
diff
changeset
|
867 |
iController && iController->IsIdle(*this) && |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
80
diff
changeset
|
868 |
!iReqQ.IsEmpty() && |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
80
diff
changeset
|
869 |
!iDfc.Queued()) |
0 | 870 |
{ |
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
871 |
// Wait for a bit. If during that time the condition goes away then it |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
872 |
// was a 'spurious missed interrupt', in which case we just do nothing. |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
873 |
TBool spurious = EFalse; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
874 |
const TUint32 nano_secs_per_loop = 1000 * 1000; // 1ms |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
875 |
for (TInt i = 5; i > 0; i--) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
876 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
877 |
if (!iController->IsIdle(*this)) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
878 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
879 |
__KTRACE_OPT(KDMA, Kern::Printf("DMAC no longer idle (i = %d)", i)); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
880 |
spurious = ETrue; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
881 |
break; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
882 |
} |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
883 |
else if (iDfc.Queued()) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
884 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
885 |
__KTRACE_OPT(KDMA, Kern::Printf("DFC now queued (i = %d)", i)); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
886 |
spurious = ETrue; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
887 |
break; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
888 |
} |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
889 |
Kern::NanoWait(nano_secs_per_loop); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
890 |
} |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
891 |
if (!spurious) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
892 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
893 |
__KTRACE_OPT(KDMA, |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
894 |
Kern::Printf("Missed interrupt(s) - draining request queue on ch %d", |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
895 |
PslId())); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
896 |
ResetStateMachine(); |
0 | 897 |
|
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
898 |
// Move orphaned requests to temporary queue so channel queue can |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
899 |
// accept new requests. |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
900 |
SDblQue q; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
901 |
q.MoveFrom(&iReqQ); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
902 |
|
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
903 |
SDblQueLink* pL; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
904 |
while ((pL = q.GetFirst()) != NULL) |
0 | 905 |
{ |
80
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
906 |
iQueuedRequests--; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
907 |
DDmaRequest* pR = _LOFF(pL, DDmaRequest, iLink); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
908 |
__KTRACE_OPT(KDMA, Kern::Printf("Removing request from queue and notifying client")); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
909 |
pR->OnDeque(); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
910 |
DDmaRequest::TCallback cb = pR->iCb; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
911 |
TAny* arg = pR->iCbArg; |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
912 |
if (cb) |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
913 |
{ |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
914 |
Signal(); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
915 |
(*cb)(DDmaRequest::EOk, arg); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
916 |
Wait(); |
597aaf25e343
Revision: 201008
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
917 |
} |
0 | 918 |
} |
919 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
920 |
req_count_after = iQueuedRequests; |
0 | 921 |
Signal(); |
922 |
} |
|
87
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
81
diff
changeset
|
923 |
#endif // #ifndef DISABLE_MISSED_IRQ_RECOVERY |
0 | 924 |
else |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
925 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
926 |
req_count_after = iQueuedRequests; |
0 | 927 |
Signal(); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
928 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
929 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
930 |
// Only call PSL if there were requests queued when we entered AND there |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
931 |
// are now no requests left on the queue (after also having executed all |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
932 |
// client callbacks). |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
933 |
if ((req_count_before != 0) && (req_count_after == 0)) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
934 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
935 |
QueuedRequestCountChanged(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
936 |
} |
0 | 937 |
|
938 |
__DMA_INVARIANT(); |
|
939 |
} |
|
940 |
||
941 |
||
942 |
/** Reset state machine only, request queue is unchanged */ |
|
943 |
||
944 |
void TDmaChannel::ResetStateMachine() |
|
945 |
{ |
|
946 |
DoCancelAll(); |
|
947 |
iCurHdr = NULL; |
|
948 |
iNullPtr = &iCurHdr; |
|
949 |
} |
|
950 |
||
951 |
||
952 |
/** Unlink the last item of a LLI chain from the next chain. |
|
953 |
Default implementation does nothing. This is overridden by scatter-gather channels. */ |
|
954 |
||
955 |
void TDmaChannel::DoUnlink(SDmaDesHdr& /*aHdr*/) |
|
956 |
{ |
|
957 |
} |
|
958 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
959 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
960 |
/** PSL may override */ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
961 |
void TDmaChannel::QueuedRequestCountChanged() |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
962 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
963 |
#ifdef _DEBUG |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
964 |
Wait(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
965 |
__KTRACE_OPT(KDMA, |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
966 |
Kern::Printf("TDmaChannel::QueuedRequestCountChanged() %d", |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
967 |
iQueuedRequests)); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
968 |
__DMA_ASSERTA(iQueuedRequests >= 0); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
969 |
Signal(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
970 |
#endif |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
971 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
972 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
973 |
|
0 | 974 |
#ifdef _DEBUG |
975 |
||
976 |
void TDmaChannel::Invariant() |
|
977 |
{ |
|
978 |
Wait(); |
|
979 |
||
980 |
__DMA_ASSERTD(iReqCount >= 0); |
|
981 |
// should always point to NULL pointer ending fragment queue |
|
982 |
__DMA_ASSERTD(*iNullPtr == NULL); |
|
983 |
||
984 |
__DMA_ASSERTD(0 <= iAvailDesCount && iAvailDesCount <= iMaxDesCount); |
|
985 |
||
986 |
__DMA_ASSERTD(iCurHdr == NULL || iController->IsValidHdr(iCurHdr)); |
|
987 |
||
988 |
if (IsOpened()) |
|
989 |
{ |
|
990 |
__DMA_ASSERTD((iCurHdr && !IsQueueEmpty()) || (!iCurHdr && IsQueueEmpty())); |
|
991 |
if (iCurHdr == NULL) |
|
992 |
__DMA_ASSERTD(iNullPtr == &iCurHdr); |
|
993 |
} |
|
994 |
else |
|
995 |
{ |
|
996 |
__DMA_ASSERTD(iCurHdr == NULL); |
|
997 |
__DMA_ASSERTD(iNullPtr == &iCurHdr); |
|
998 |
__DMA_ASSERTD(IsQueueEmpty()); |
|
999 |
} |
|
1000 |
||
1001 |
Signal(); |
|
1002 |
} |
|
1003 |
||
1004 |
#endif |
|
1005 |
||
1006 |
////////////////////////////////////////////////////////////////////////////// |
|
1007 |
// TDmaSbChannel |
|
1008 |
||
1009 |
void TDmaSbChannel::DoQueue(DDmaRequest& /*aReq*/) |
|
1010 |
{ |
|
1011 |
if (!iTransferring) |
|
1012 |
{ |
|
1013 |
iController->Transfer(*this, *iCurHdr); |
|
1014 |
iTransferring = ETrue; |
|
1015 |
} |
|
1016 |
} |
|
1017 |
||
1018 |
||
1019 |
void TDmaSbChannel::DoCancelAll() |
|
1020 |
{ |
|
1021 |
__DMA_ASSERTD(iTransferring); |
|
1022 |
iTransferring = EFalse; |
|
1023 |
} |
|
1024 |
||
1025 |
||
1026 |
void TDmaSgChannel::DoUnlink(SDmaDesHdr& aHdr) |
|
1027 |
{ |
|
1028 |
iController->UnlinkHwDes(*this, aHdr); |
|
1029 |
} |
|
1030 |
||
1031 |
||
1032 |
void TDmaSbChannel::DoDfc(DDmaRequest& /*aCurReq*/, SDmaDesHdr*& aCompletedHdr) |
|
1033 |
{ |
|
1034 |
__DMA_ASSERTD(iTransferring); |
|
1035 |
aCompletedHdr = iCurHdr; |
|
1036 |
iCurHdr = iCurHdr->iNext; |
|
1037 |
if (iCurHdr != NULL) |
|
1038 |
iController->Transfer(*this, *iCurHdr); |
|
1039 |
else |
|
1040 |
iTransferring = EFalse; |
|
1041 |
} |
|
1042 |
||
1043 |
||
1044 |
////////////////////////////////////////////////////////////////////////////// |
|
1045 |
// TDmaDbChannel |
|
1046 |
||
1047 |
void TDmaDbChannel::DoQueue(DDmaRequest& aReq) |
|
1048 |
{ |
|
1049 |
switch (iState) |
|
1050 |
{ |
|
1051 |
case EIdle: |
|
1052 |
iController->Transfer(*this, *iCurHdr); |
|
1053 |
if (iCurHdr->iNext) |
|
1054 |
{ |
|
1055 |
iController->Transfer(*this, *(iCurHdr->iNext)); |
|
1056 |
iState = ETransferring; |
|
1057 |
} |
|
1058 |
else |
|
1059 |
iState = ETransferringLast; |
|
1060 |
break; |
|
1061 |
case ETransferring: |
|
1062 |
// nothing to do |
|
1063 |
break; |
|
1064 |
case ETransferringLast: |
|
1065 |
iController->Transfer(*this, *(aReq.iFirstHdr)); |
|
1066 |
iState = ETransferring; |
|
1067 |
break; |
|
1068 |
default: |
|
1069 |
__DMA_CANT_HAPPEN(); |
|
1070 |
} |
|
1071 |
} |
|
1072 |
||
1073 |
||
1074 |
void TDmaDbChannel::DoCancelAll() |
|
1075 |
{ |
|
1076 |
iState = EIdle; |
|
1077 |
} |
|
1078 |
||
1079 |
||
1080 |
void TDmaDbChannel::DoDfc(DDmaRequest& /*aCurReq*/, SDmaDesHdr*& aCompletedHdr) |
|
1081 |
{ |
|
1082 |
aCompletedHdr = iCurHdr; |
|
1083 |
iCurHdr = iCurHdr->iNext; |
|
1084 |
switch (iState) |
|
1085 |
{ |
|
1086 |
case ETransferringLast: |
|
1087 |
iState = EIdle; |
|
1088 |
break; |
|
1089 |
case ETransferring: |
|
1090 |
if (iCurHdr->iNext == NULL) |
|
1091 |
iState = ETransferringLast; |
|
1092 |
else |
|
1093 |
iController->Transfer(*this, *(iCurHdr->iNext)); |
|
1094 |
break; |
|
1095 |
default: |
|
1096 |
__DMA_CANT_HAPPEN(); |
|
1097 |
} |
|
1098 |
} |
|
1099 |
||
1100 |
||
1101 |
////////////////////////////////////////////////////////////////////////////// |
|
1102 |
// TDmaSgChannel |
|
1103 |
||
1104 |
void TDmaSgChannel::DoQueue(DDmaRequest& aReq) |
|
1105 |
{ |
|
1106 |
if (iTransferring) |
|
1107 |
{ |
|
1108 |
__DMA_ASSERTD(!aReq.iLink.Alone()); |
|
1109 |
DDmaRequest* pReqPrev = _LOFF(aReq.iLink.iPrev, DDmaRequest, iLink); |
|
1110 |
iController->AppendHwDes(*this, *(pReqPrev->iLastHdr), *(aReq.iFirstHdr)); |
|
1111 |
} |
|
1112 |
else |
|
1113 |
{ |
|
1114 |
iController->Transfer(*this, *(aReq.iFirstHdr)); |
|
1115 |
iTransferring = ETrue; |
|
1116 |
} |
|
1117 |
} |
|
1118 |
||
1119 |
||
1120 |
void TDmaSgChannel::DoCancelAll() |
|
1121 |
{ |
|
1122 |
__DMA_ASSERTD(iTransferring); |
|
1123 |
iTransferring = EFalse; |
|
1124 |
} |
|
1125 |
||
1126 |
||
1127 |
void TDmaSgChannel::DoDfc(DDmaRequest& aCurReq, SDmaDesHdr*& aCompletedHdr) |
|
1128 |
{ |
|
1129 |
__DMA_ASSERTD(iTransferring); |
|
1130 |
aCompletedHdr = aCurReq.iLastHdr; |
|
1131 |
iCurHdr = aCompletedHdr->iNext; |
|
1132 |
iTransferring = (iCurHdr != NULL); |
|
1133 |
} |