author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 27 May 2010 14:17:14 +0300 | |
changeset 139 | 95f71bcdcdb7 |
parent 36 | 538db54a451d |
permissions | -rw-r--r-- |
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1 |
// Copyright (c) 2004-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: |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
14 |
// bsptemplate/asspvariant/template_assp/dmapsl.cpp |
0 | 15 |
// Template DMA Platform Specific Layer (PSL). |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
16 |
// |
0 | 17 |
// |
18 |
||
19 |
||
20 |
#include <kernel/kern_priv.h> |
|
21 |
#include <template_assp.h> // /assp/template_assp/ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
|
0 | 23 |
#include <drivers/dma.h> |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
|
0 | 25 |
|
26 |
// Debug support |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
static const char KDmaPanicCat[] = "DMA PSL - " __FILE__; |
0 | 28 |
|
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
29 |
static const TInt KMaxTransferLen = 0x1FE0; // max transfer length for this DMAC |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
30 |
static const TInt KMemAlignMask = 7; // memory addresses passed to DMAC must be multiple of 8 |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
31 |
static const TInt KChannelCount = 16; // we got 16 channels |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
32 |
static const TInt KDesCount = 1024; // DMA descriptor count |
0 | 33 |
|
34 |
||
35 |
class TDmaDesc |
|
36 |
// |
|
37 |
// Hardware DMA descriptor |
|
38 |
// |
|
39 |
{ |
|
40 |
public: |
|
41 |
enum {KStopBitMask = 1}; |
|
42 |
public: |
|
43 |
TPhysAddr iDescAddr; |
|
44 |
TPhysAddr iSrcAddr; |
|
45 |
TPhysAddr iDestAddr; |
|
46 |
TUint32 iCmd; |
|
47 |
}; |
|
48 |
||
49 |
||
50 |
////////////////////////////////////////////////////////////////////////////// |
|
51 |
// Test Support |
|
52 |
////////////////////////////////////////////////////////////////////////////// |
|
53 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
/** |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
TO DO: Fill in to provide information to the V1 test harness (t_dma.exe) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
*/ |
0 | 57 |
TDmaTestInfo TestInfo = |
58 |
{ |
|
59 |
0, |
|
60 |
0, |
|
61 |
0, |
|
62 |
0, |
|
63 |
NULL, |
|
64 |
0, |
|
65 |
NULL, |
|
66 |
0, |
|
67 |
NULL |
|
68 |
}; |
|
69 |
||
70 |
||
71 |
EXPORT_C const TDmaTestInfo& DmaTestInfo() |
|
72 |
// |
|
73 |
// |
|
74 |
// |
|
75 |
{ |
|
76 |
return TestInfo; |
|
77 |
} |
|
78 |
||
79 |
||
80 |
////////////////////////////////////////////////////////////////////////////// |
|
81 |
// Helper Functions |
|
82 |
////////////////////////////////////////////////////////////////////////////// |
|
83 |
||
84 |
inline TBool IsHwDesAligned(TAny* aDes) |
|
85 |
// |
|
86 |
// Checks whether given hardware descriptor is 16-bytes aligned. |
|
87 |
// |
|
88 |
{ |
|
89 |
return ((TLinAddr)aDes & 0xF) == 0; |
|
90 |
} |
|
91 |
||
92 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
93 |
static TUint32 DcmdReg(TInt aCount, TUint aFlags, TUint32 aPslInfo) |
0 | 94 |
// |
95 |
// Returns value to set in DMA command register or in descriptor command field. |
|
96 |
// |
|
97 |
{ |
|
98 |
// TO DO: Construct CMD word from input values. |
|
99 |
// The return value should reflect the actual control word. |
|
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
100 |
return (aCount | aFlags | aPslInfo); |
0 | 101 |
} |
102 |
||
103 |
||
104 |
////////////////////////////////////////////////////////////////////////////// |
|
105 |
// Derived Channel (Scatter/Gather) |
|
106 |
////////////////////////////////////////////////////////////////////////////// |
|
107 |
||
108 |
class TTemplateSgChannel : public TDmaSgChannel |
|
109 |
{ |
|
110 |
public: |
|
111 |
TDmaDesc* iTmpDes; |
|
112 |
TPhysAddr iTmpDesPhysAddr; |
|
113 |
}; |
|
114 |
||
115 |
||
116 |
////////////////////////////////////////////////////////////////////////////// |
|
117 |
// Derived Controller Class |
|
118 |
////////////////////////////////////////////////////////////////////////////// |
|
119 |
||
120 |
class TTemplateDmac : public TDmac |
|
121 |
{ |
|
122 |
public: |
|
123 |
TTemplateDmac(); |
|
124 |
TInt Create(); |
|
125 |
private: |
|
126 |
// from TDmac (PIL pure virtual) |
|
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
127 |
virtual void Transfer(const TDmaChannel& aChannel, const SDmaDesHdr& aHdr); |
0 | 128 |
virtual void StopTransfer(const TDmaChannel& aChannel); |
129 |
virtual TBool IsIdle(const TDmaChannel& aChannel); |
|
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
130 |
virtual TInt MaxTransferSize(TDmaChannel& aChannel, TUint aFlags, TUint32 aPslInfo); |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
131 |
virtual TUint MemAlignMask(TDmaChannel& aChannel, TUint aFlags, TUint32 aPslInfo); |
0 | 132 |
// from TDmac (PIL virtual) |
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
133 |
virtual void InitHwDes(const SDmaDesHdr& aHdr, TUint32 aSrc, TUint32 aDest, TInt aCount, |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
134 |
TUint aFlags, TUint32 aPslInfo, TUint32 aCookie); |
0 | 135 |
virtual void ChainHwDes(const SDmaDesHdr& aHdr, const SDmaDesHdr& aNextHdr); |
136 |
virtual void AppendHwDes(const TDmaChannel& aChannel, const SDmaDesHdr& aLastHdr, |
|
137 |
const SDmaDesHdr& aNewHdr); |
|
138 |
virtual void UnlinkHwDes(const TDmaChannel& aChannel, SDmaDesHdr& aHdr); |
|
139 |
// other |
|
140 |
static void Isr(TAny* aThis); |
|
141 |
inline TDmaDesc* HdrToHwDes(const SDmaDesHdr& aHdr); |
|
142 |
private: |
|
143 |
static const SCreateInfo KInfo; |
|
144 |
public: |
|
145 |
TTemplateSgChannel iChannels[KChannelCount]; |
|
146 |
}; |
|
147 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
|
0 | 149 |
static TTemplateDmac Controller; |
150 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
|
0 | 152 |
const TDmac::SCreateInfo TTemplateDmac::KInfo = |
153 |
{ |
|
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
154 |
KChannelCount, |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
155 |
KDesCount, |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
156 |
TDmac::KCapsBitHwDes, |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
157 |
sizeof(TDmaDesc), |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
158 |
EMapAttrSupRw | EMapAttrFullyBlocking |
0 | 159 |
}; |
160 |
||
161 |
||
162 |
TTemplateDmac::TTemplateDmac() |
|
163 |
// |
|
164 |
// Constructor. |
|
165 |
// |
|
166 |
: TDmac(KInfo) |
|
167 |
{} |
|
168 |
||
169 |
||
170 |
TInt TTemplateDmac::Create() |
|
171 |
// |
|
172 |
// Second phase construction. |
|
173 |
// |
|
174 |
{ |
|
175 |
TInt r = TDmac::Create(KInfo); // Base class Create() |
|
176 |
if (r == KErrNone) |
|
177 |
{ |
|
178 |
__DMA_ASSERTA(ReserveSetOfDes(KChannelCount) == KErrNone); |
|
179 |
for (TInt i=0; i < KChannelCount; ++i) |
|
180 |
{ |
|
181 |
TDmaDesc* pD = HdrToHwDes(*iFreeHdr); |
|
182 |
iChannels[i].iTmpDes = pD; |
|
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
183 |
iChannels[i].iTmpDesPhysAddr = DesLinToPhys(pD); |
0 | 184 |
iFreeHdr = iFreeHdr->iNext; |
185 |
} |
|
186 |
r = Interrupt::Bind(EAsspIntIdDma, Isr, this); |
|
187 |
if (r == KErrNone) |
|
188 |
{ |
|
189 |
// TO DO: Map DMA clients (requests) to DMA channels here. |
|
190 |
||
191 |
r = Interrupt::Enable(EAsspIntIdDma); |
|
192 |
} |
|
193 |
} |
|
194 |
return r; |
|
195 |
} |
|
196 |
||
197 |
||
198 |
void TTemplateDmac::Transfer(const TDmaChannel& aChannel, const SDmaDesHdr& aHdr) |
|
199 |
// |
|
200 |
// Initiates a (previously constructed) request on a specific channel. |
|
201 |
// |
|
202 |
{ |
|
203 |
const TUint8 i = static_cast<TUint8>(aChannel.PslId()); |
|
204 |
TDmaDesc* pD = HdrToHwDes(aHdr); |
|
205 |
||
206 |
__KTRACE_OPT(KDMA, Kern::Printf(">TTemplateDmac::Transfer channel=%d des=0x%08X", i, pD)); |
|
207 |
||
208 |
// TO DO (for instance): Load the first descriptor address into the DMAC and start it |
|
209 |
// by setting the RUN bit. |
|
210 |
(void) *pD, (void) i; |
|
211 |
||
212 |
} |
|
213 |
||
214 |
||
215 |
void TTemplateDmac::StopTransfer(const TDmaChannel& aChannel) |
|
216 |
// |
|
217 |
// Stops a running channel. |
|
218 |
// |
|
219 |
{ |
|
220 |
const TUint8 i = static_cast<TUint8>(aChannel.PslId()); |
|
221 |
||
222 |
__KTRACE_OPT(KDMA, Kern::Printf(">TTemplateDmac::StopTransfer channel=%d", i)); |
|
223 |
||
224 |
// TO DO (for instance): Clear the RUN bit of the channel. |
|
225 |
(void) i; |
|
226 |
||
227 |
} |
|
228 |
||
229 |
||
230 |
TBool TTemplateDmac::IsIdle(const TDmaChannel& aChannel) |
|
231 |
// |
|
232 |
// Returns the state of a given channel. |
|
233 |
// |
|
234 |
{ |
|
235 |
const TUint8 i = static_cast<TUint8>(aChannel.PslId()); |
|
236 |
||
237 |
__KTRACE_OPT(KDMA, Kern::Printf(">TTemplateDmac::IsIdle channel=%d", i)); |
|
238 |
||
239 |
// TO DO (for instance): Return the state of the RUN bit of the channel. |
|
240 |
// The return value should reflect the actual state. |
|
241 |
(void) i; |
|
242 |
||
243 |
return ETrue; |
|
244 |
} |
|
245 |
||
246 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
247 |
TInt TTemplateDmac::MaxTransferSize(TDmaChannel& /*aChannel*/, TUint /*aFlags*/, TUint32 /*aPslInfo*/) |
0 | 248 |
// |
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
249 |
// Returns the maximum transfer size for a given transfer. |
0 | 250 |
// |
251 |
{ |
|
252 |
// TO DO: Determine the proper return value, based on the arguments. |
|
253 |
||
254 |
// For instance: |
|
255 |
return KMaxTransferLen; |
|
256 |
} |
|
257 |
||
258 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
259 |
TUint TTemplateDmac::MemAlignMask(TDmaChannel& /*aChannel*/, TUint /*aFlags*/, TUint32 /*aPslInfo*/) |
0 | 260 |
// |
261 |
// Returns the memory buffer alignment restrictions mask for a given transfer. |
|
262 |
// |
|
263 |
{ |
|
264 |
// TO DO: Determine the proper return value, based on the arguments. |
|
265 |
||
266 |
// For instance: |
|
267 |
return KMemAlignMask; |
|
268 |
} |
|
269 |
||
270 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
271 |
void TTemplateDmac::InitHwDes(const SDmaDesHdr& aHdr, TUint32 aSrc, TUint32 aDest, TInt aCount, |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
272 |
TUint aFlags, TUint32 aPslInfo, TUint32 /*aCookie*/) |
0 | 273 |
// |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
// Sets up (from a passed in request) the descriptor with that fragment's |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
275 |
// source and destination address, the fragment size, and the (driver/DMA |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
276 |
// controller) specific transfer parameters (mem/peripheral, burst size, |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
277 |
// transfer width). |
0 | 278 |
// |
279 |
{ |
|
280 |
TDmaDesc* pD = HdrToHwDes(aHdr); |
|
281 |
||
282 |
__KTRACE_OPT(KDMA, Kern::Printf("TTemplateDmac::InitHwDes 0x%08X", pD)); |
|
283 |
||
284 |
// Unaligned descriptor? Bug in generic layer! |
|
285 |
__DMA_ASSERTD(IsHwDesAligned(pD)); |
|
286 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
287 |
pD->iSrcAddr = (aFlags & KDmaPhysAddrSrc) ? aSrc : Epoc::LinearToPhysical(aSrc); |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
288 |
__DMA_ASSERTD(pD->iSrcAddr != KPhysAddrInvalid); |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
289 |
pD->iDestAddr = (aFlags & KDmaPhysAddrDest) ? aDest : Epoc::LinearToPhysical(aDest); |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
290 |
__DMA_ASSERTD(pD->iDestAddr != KPhysAddrInvalid); |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
291 |
pD->iCmd = DcmdReg(aCount, aFlags, aPslInfo); |
0 | 292 |
pD->iDescAddr = TDmaDesc::KStopBitMask; |
293 |
} |
|
294 |
||
295 |
||
296 |
void TTemplateDmac::ChainHwDes(const SDmaDesHdr& aHdr, const SDmaDesHdr& aNextHdr) |
|
297 |
// |
|
298 |
// Chains hardware descriptors together by setting the next pointer of the original descriptor |
|
299 |
// to the physical address of the descriptor to be chained. |
|
300 |
// |
|
301 |
{ |
|
302 |
TDmaDesc* pD = HdrToHwDes(aHdr); |
|
303 |
TDmaDesc* pN = HdrToHwDes(aNextHdr); |
|
304 |
||
305 |
__KTRACE_OPT(KDMA, Kern::Printf("TTemplateDmac::ChainHwDes des=0x%08X next des=0x%08X", pD, pN)); |
|
306 |
||
307 |
// Unaligned descriptor? Bug in generic layer! |
|
308 |
__DMA_ASSERTD(IsHwDesAligned(pD) && IsHwDesAligned(pN)); |
|
309 |
||
310 |
// TO DO: Modify pD->iCmd so that no end-of-transfer interrupt gets raised any longer. |
|
311 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
312 |
pD->iDescAddr = DesLinToPhys(pN); |
0 | 313 |
} |
314 |
||
315 |
||
316 |
void TTemplateDmac::AppendHwDes(const TDmaChannel& aChannel, const SDmaDesHdr& aLastHdr, |
|
317 |
const SDmaDesHdr& aNewHdr) |
|
318 |
// |
|
319 |
// Appends a descriptor to the chain while the channel is running. |
|
320 |
// |
|
321 |
{ |
|
322 |
const TUint8 i = static_cast<TUint8>(aChannel.PslId()); |
|
323 |
||
324 |
TDmaDesc* pL = HdrToHwDes(aLastHdr); |
|
325 |
TDmaDesc* pN = HdrToHwDes(aNewHdr); |
|
326 |
||
327 |
__KTRACE_OPT(KDMA, Kern::Printf(">TTemplateDmac::AppendHwDes channel=%d last des=0x%08X new des=0x%08X", |
|
328 |
i, pL, pN)); |
|
329 |
// Unaligned descriptor? Bug in generic layer! |
|
330 |
__DMA_ASSERTD(IsHwDesAligned(pL) && IsHwDesAligned(pN)); |
|
331 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
332 |
TPhysAddr newPhys = DesLinToPhys(pN); |
0 | 333 |
|
334 |
const TInt irq = NKern::DisableAllInterrupts(); |
|
335 |
StopTransfer(aChannel); |
|
336 |
||
337 |
pL->iDescAddr = newPhys; |
|
338 |
const TTemplateSgChannel& channel = static_cast<const TTemplateSgChannel&>(aChannel); |
|
339 |
TDmaDesc* pD = channel.iTmpDes; |
|
340 |
||
341 |
// TO DO: Implement the appropriate algorithm for appending a descriptor here. |
|
342 |
(void) *pD, (void) i; |
|
343 |
||
344 |
NKern::RestoreInterrupts(irq); |
|
345 |
||
346 |
__KTRACE_OPT(KDMA, Kern::Printf("<TTemplateDmac::AppendHwDes")); |
|
347 |
} |
|
348 |
||
349 |
||
350 |
void TTemplateDmac::UnlinkHwDes(const TDmaChannel& /*aChannel*/, SDmaDesHdr& aHdr) |
|
351 |
// |
|
352 |
// Unlink the last item in the h/w descriptor chain from a subsequent chain that it was |
|
353 |
// possibly linked to. |
|
354 |
// |
|
355 |
{ |
|
356 |
__KTRACE_OPT(KDMA, Kern::Printf(">TTemplateDmac::UnlinkHwDes")); |
|
357 |
TDmaDesc* pD = HdrToHwDes(aHdr); |
|
358 |
pD->iDescAddr = TDmaDesc::KStopBitMask; |
|
359 |
||
360 |
// TO DO: Modify pD->iCmd so that an end-of-transfer interrupt will get raised. |
|
361 |
||
362 |
} |
|
363 |
||
364 |
||
365 |
void TTemplateDmac::Isr(TAny* aThis) |
|
366 |
// |
|
367 |
// This ISR reads the interrupt identification and calls back into the base class |
|
368 |
// interrupt service handler with the channel identifier and an indication whether the |
|
369 |
// transfer completed correctly or with an error. |
|
370 |
// |
|
371 |
{ |
|
372 |
TTemplateDmac& me = *static_cast<TTemplateDmac*>(aThis); |
|
373 |
||
374 |
// TO DO: Implement the behaviour described above, call HandleIsr(). |
|
375 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
376 |
HandleIsr(me.iChannels[5], 0); // Example |
0 | 377 |
|
378 |
} |
|
379 |
||
380 |
||
381 |
inline TDmaDesc* TTemplateDmac::HdrToHwDes(const SDmaDesHdr& aHdr) |
|
382 |
// |
|
383 |
// Changes return type of base class call. |
|
384 |
// |
|
385 |
{ |
|
386 |
return static_cast<TDmaDesc*>(TDmac::HdrToHwDes(aHdr)); |
|
387 |
} |
|
388 |
||
389 |
||
390 |
////////////////////////////////////////////////////////////////////////////// |
|
391 |
// Channel Opening/Closing (Channel Allocator) |
|
392 |
////////////////////////////////////////////////////////////////////////////// |
|
393 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
394 |
TDmaChannel* DmaChannelMgr::Open(TUint32 aOpenId) |
0 | 395 |
// |
396 |
// |
|
397 |
// |
|
398 |
{ |
|
399 |
__KTRACE_OPT(KDMA, Kern::Printf(">DmaChannelMgr::Open aOpenId=%d", aOpenId)); |
|
400 |
||
401 |
__DMA_ASSERTA(aOpenId < static_cast<TUint32>(KChannelCount)); |
|
402 |
||
403 |
TDmaChannel* pC = Controller.iChannels + aOpenId; |
|
404 |
if (pC->IsOpened()) |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
405 |
{ |
0 | 406 |
pC = NULL; |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
407 |
} |
0 | 408 |
else |
409 |
{ |
|
410 |
pC->iController = &Controller; |
|
411 |
pC->iPslId = aOpenId; |
|
412 |
} |
|
413 |
||
414 |
return pC; |
|
415 |
} |
|
416 |
||
417 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
418 |
void DmaChannelMgr::Close(TDmaChannel* /*aChannel*/) |
0 | 419 |
// |
420 |
// |
|
421 |
// |
|
422 |
{ |
|
423 |
// NOP |
|
424 |
} |
|
425 |
||
426 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
427 |
TInt DmaChannelMgr::StaticExtension(TInt /*aCmd*/, TAny* /*aArg*/) |
0 | 428 |
// |
429 |
// |
|
430 |
// |
|
431 |
{ |
|
432 |
return KErrNotSupported; |
|
433 |
} |
|
434 |
||
435 |
||
436 |
////////////////////////////////////////////////////////////////////////////// |
|
437 |
// DLL Exported Function |
|
438 |
////////////////////////////////////////////////////////////////////////////// |
|
439 |
||
440 |
DECLARE_STANDARD_EXTENSION() |
|
441 |
// |
|
442 |
// Creates and initializes a new DMA controller object on the kernel heap. |
|
443 |
// |
|
444 |
{ |
|
445 |
__KTRACE_OPT2(KBOOT, KDMA, Kern::Printf("Starting DMA Extension")); |
|
446 |
||
447 |
return Controller.Create(); |
|
448 |
} |