author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 102 | ef2a444a7410 |
permissions | -rw-r--r-- |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
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 |
// e32test\dma\t_dma.cpp |
|
15 |
// Overview: |
|
16 |
// Test the DMA channel functionality. |
|
17 |
// API Information: |
|
18 |
// RBusLogicalChannel, DLogicalChannelBase, DLogicalDevice |
|
19 |
// Details: |
|
20 |
// - Load the DMA LDD, create a critical section, an active scheduler and |
|
21 |
// a CPeriodic object. |
|
22 |
// - Test one shot single buffer transfers: test simple transfer, request |
|
23 |
// reconfiguration and cancelling. Verify results are as expected. |
|
24 |
// - Test one shot double buffer transfers: test simple transfer, request |
|
25 |
// reconfiguration and cancelling. Verify results are as expected. |
|
26 |
// - Test streaming single buffer transfers: test simple transfer and |
|
27 |
// cancelling. Test that framework behaves correctly if one or more DMA |
|
28 |
// interrupts are missed. Verify results are as expected. |
|
29 |
// - Test streaming double buffer transfers: test simple transfer and |
|
30 |
// cancelling. Test that framework behaves correctly if one or more DMA |
|
31 |
// interrupts are missed. Verify results are as expected. |
|
32 |
// - Test streaming scatter/gather transfers: test simple transfer and |
|
33 |
// cancelling. Test that framework behaves correctly if one or more DMA |
|
34 |
// interrupts are missed. Verify results are as expected. |
|
35 |
// Platforms/Drives/Compatibility: |
|
36 |
// Hardware (Automatic). |
|
37 |
// Assumptions/Requirement/Pre-requisites: |
|
38 |
// Failures and causes: |
|
39 |
// Base Port information: |
|
40 |
// |
|
41 |
// |
|
42 |
||
43 |
#define __E32TEST_EXTENSION__ |
|
44 |
#include <e32test.h> |
|
45 |
#include "d_dma.h" |
|
46 |
#include <e32debug.h> |
|
47 |
#include <e32svr.h> |
|
48 |
#include <e32def.h> |
|
49 |
#include <e32def_private.h> |
|
50 |
#include "u32std.h" |
|
51 |
||
52 |
#ifdef __DMASIM__ |
|
53 |
RTest test(_L("T_DMASIM")); |
|
54 |
#else |
|
55 |
RTest test(_L("T_DMA")); |
|
56 |
#endif |
|
57 |
||
58 |
////////////////////////////////////////////////////////////////////////////// |
|
59 |
// Mini-framework for running tests either in a single thread or in |
|
60 |
// several concurrent ones. |
|
61 |
||
62 |
RTestDma::TInfo Info; |
|
63 |
TBool JitEnabled; |
|
64 |
RCriticalSection TheCriticalSection; // protect following variables |
|
65 |
TInt ThreadCount; // decremented when tester thread dies |
|
66 |
CPeriodic* Bipper; // display dots during tests to detect lock-ups |
|
67 |
||
68 |
// Test macro used inside tester threads |
|
69 |
_LIT(KTestFailure, "XTEST"); |
|
70 |
static void TestPanic(TInt aLine, TUint32 a1, TUint32 a2, TUint32 a3) |
|
71 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
72 |
RDebug::Printf("Line %d test failed a1=%08x (%d) a2=%08x (%d) a3=%08x (%d)", aLine, a1, a1, a2, a2, a3, a3); |
0 | 73 |
RThread().Panic(KTestFailure, aLine); |
74 |
} |
|
75 |
#define XTEST(e) if (!(e)) TestPanic(__LINE__, 0, 0, 0) |
|
76 |
#define XTEST1(e,a1) if (!(e)) TestPanic(__LINE__, (a1), 0, 0) |
|
77 |
#define XTEST2(e,a1,a2) if (!(e)) TestPanic(__LINE__, (a1), (a2), 0) |
|
78 |
#define XTEST3(e,a1,a2,a3) if (!(e)) TestPanic(__LINE__, (a1), (a2), (a3)) |
|
79 |
||
80 |
||
81 |
/** |
|
82 |
Specifies a DMA test |
|
83 |
@note Have not inherited from CBase so that implicit copy ctors are used |
|
84 |
*/ |
|
85 |
class CTest |
|
86 |
{ |
|
87 |
public: |
|
88 |
typedef void (*TTestFunction)(RTestDma aChannel, TInt aMaxFragment, TInt aFragmentSize); |
|
89 |
||
90 |
CTest(TTestFunction aFn, TInt aMaxIter) |
|
91 |
:iTestFn(aFn), iChannelId(0), iMaxIter(aMaxIter) |
|
92 |
{} |
|
93 |
||
94 |
virtual ~CTest() |
|
95 |
{} |
|
96 |
||
97 |
TInt RunTest(); |
|
98 |
||
99 |
virtual TBool OpenChannel(TInt aDesCount, TInt aMaxFragmentSize=0); |
|
100 |
||
101 |
virtual void AnnounceTest(TDes& aDes) |
|
102 |
{aDes.AppendFormat(_L("Channel Id %d, iMaxIter %d"), iChannelId, iMaxIter);} |
|
103 |
virtual void ReportState(TDes& aDes) |
|
104 |
{aDes.AppendFormat(_L("Channel Id %d, iCurIter %d"), iChannelId, iCurIter);} |
|
105 |
||
106 |
||
107 |
void SetChannelId(TUint32 aChannelId) |
|
108 |
{iChannelId = aChannelId;} |
|
109 |
||
110 |
TInt MaxIter() const {return iMaxIter;} |
|
111 |
TInt CurIter() const {return iCurIter;} |
|
112 |
||
113 |
/** |
|
114 |
@return A copy of this test |
|
115 |
*/ |
|
116 |
virtual CTest* Clone() const =0; |
|
117 |
||
118 |
protected: |
|
119 |
TInt virtual DoRunTest() =0; |
|
120 |
||
121 |
const TTestFunction iTestFn; |
|
122 |
TUint32 iChannelId; |
|
123 |
const TInt iMaxIter; |
|
124 |
TInt iCurIter; |
|
125 |
RTestDma iChannel; |
|
126 |
}; |
|
127 |
||
128 |
/** |
|
129 |
Specifies a DMA test where the maximum fragmentation is |
|
130 |
explicitly limited. This tests that requests are split |
|
131 |
in to the number of fragments expected. |
|
132 |
||
133 |
This test also requires that physically contiguous buffers |
|
134 |
are used. For this reason the product of iMaxFragment and |
|
135 |
iMaxFragmentSize should be kept small |
|
136 |
*/ |
|
137 |
class CFragmentationTest : public CTest |
|
138 |
{ |
|
139 |
public: |
|
140 |
CFragmentationTest(TTestFunction aFn, TInt aMaxIter, TInt aMaxFragment, TInt aMaxFragmentSize) |
|
141 |
: CTest(aFn, aMaxIter), iMaxFragment(aMaxFragment), iMaxFragmentSize(aMaxFragmentSize), iCurFragment(0) |
|
142 |
{} |
|
143 |
||
144 |
TInt virtual DoRunTest(); |
|
145 |
||
146 |
virtual void AnnounceTest(TDes& aDes) |
|
147 |
{ |
|
148 |
aDes.AppendFormat(_L("CFragmentationTest: Frag count = [1..%d], Max Frag Size = 0x%08x bytes: "), iMaxFragment, iMaxFragmentSize); |
|
149 |
CTest::AnnounceTest(aDes); |
|
150 |
} |
|
151 |
||
152 |
virtual void ReportState(TDes& aDes) |
|
153 |
{ |
|
154 |
aDes.AppendFormat(_L("CFragmentationTest: Current Fragment %d: "), iCurFragment); |
|
155 |
CTest::ReportState(aDes); |
|
156 |
} |
|
157 |
||
158 |
CTest* Clone() const |
|
159 |
{return new CFragmentationTest(*this);} |
|
160 |
||
161 |
private: |
|
162 |
const TInt iMaxFragment; |
|
163 |
TInt iMaxFragmentSize; |
|
164 |
TInt iCurFragment; |
|
165 |
}; |
|
166 |
||
167 |
/** |
|
168 |
Specifies a DMA test where the maximum fragment size is |
|
169 |
not limited - and we do not care how many fragments are |
|
170 |
used |
|
171 |
||
172 |
- This checks that transfers work correctly with the DMAC's |
|
173 |
default fragment size |
|
174 |
*/ |
|
175 |
class CDefaultFragTest : public CTest |
|
176 |
{ |
|
177 |
public: |
|
178 |
CDefaultFragTest(TTestFunction aFn, TInt aMaxIter, TUint aTotalTransferSize) |
|
179 |
: CTest(aFn, aMaxIter), iTotalTransferSize(aTotalTransferSize) |
|
180 |
{} |
|
181 |
||
182 |
TInt virtual DoRunTest(); |
|
183 |
||
184 |
virtual void AnnounceTest(TDes& aDes) |
|
185 |
{ |
|
186 |
aDes.AppendFormat(_L("CDefaultFragTest: Transfer = 0x%08x bytes: "), iTotalTransferSize); |
|
187 |
CTest::AnnounceTest(aDes); |
|
188 |
} |
|
189 |
||
190 |
CTest* Clone() const |
|
191 |
{return new CDefaultFragTest(*this);} |
|
192 |
||
193 |
const TInt iTotalTransferSize; |
|
194 |
}; |
|
195 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
196 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
197 |
Test that it is possible to close a channel from a callback |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
198 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
199 |
class CCloseInCb : public CTest |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
200 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
201 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
202 |
CCloseInCb() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
203 |
: CTest(NULL, 1), iTransferSize(4 * KKilo) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
204 |
{} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
205 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
206 |
TInt virtual DoRunTest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
207 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
208 |
virtual void AnnounceTest(TDes& aDes) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
209 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
210 |
aDes.AppendFormat(_L("CCloseInCb")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
211 |
CTest::AnnounceTest(aDes); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
212 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
213 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
214 |
CTest* Clone() const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
215 |
{return new CCloseInCb(*this);} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
216 |
private: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
217 |
const TInt iTransferSize; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
218 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
219 |
}; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
220 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
221 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
222 |
Perform multiple transfers with different fragment counts and with smaller |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
223 |
and smaller fragment size |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
224 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
225 |
This checks that the PSL's ISR(s) are properly written, and do not miss interrupts |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
226 |
or notify the PIL spuriously. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
227 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
228 |
class CFragSizeRange : public CTest |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
229 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
230 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
231 |
CFragSizeRange(TInt aMaxIter, TInt aFragCount, TInt aInitialFragmentSize, TInt aInnerIteraions) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
232 |
: CTest(NULL, aMaxIter), iMaxFragCount(aFragCount), iFragCount(1), iInitialFragmentSize(aInitialFragmentSize), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
233 |
iInnerIterations(aInnerIteraions) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
234 |
{} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
235 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
236 |
TInt virtual DoRunTest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
237 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
238 |
virtual void AnnounceTest(TDes& aDes) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
239 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
240 |
aDes.AppendFormat(_L("CFragSizeRange: Fragments %d, intital frag size %d, inner iters %d "), iFragCount, iInitialFragmentSize, iInnerIterations); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
241 |
CTest::AnnounceTest(aDes); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
242 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
243 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
244 |
CTest* Clone() const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
245 |
{return new CFragSizeRange(*this);} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
246 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
247 |
private: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
248 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
249 |
Run the transfer |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
250 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
251 |
TInt Transfer(TInt aFragSize); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
252 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
253 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
254 |
TInt iMaxFragCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
255 |
TInt iFragCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
256 |
const TInt iInitialFragmentSize; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
257 |
const TInt iInnerIterations; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
258 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
259 |
RTimer iTimer; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
260 |
}; |
0 | 261 |
|
262 |
// |
|
263 |
// Active object used to create a tester thread, log on to it and |
|
264 |
// interpret its exit status. |
|
265 |
// |
|
266 |
class CTesterThread : public CActive |
|
267 |
{ |
|
268 |
public: |
|
269 |
CTesterThread(TInt aIdx, CTest* aTest); |
|
270 |
~CTesterThread() |
|
271 |
{ |
|
272 |
delete iTest; |
|
273 |
} |
|
274 |
private: |
|
275 |
static TInt ThreadFunction(TAny* aSelf); |
|
276 |
TInt StartThread(); |
|
277 |
// from CActive |
|
278 |
virtual void DoCancel(); |
|
279 |
virtual void RunL(); |
|
280 |
private: |
|
281 |
RThread iThread; |
|
282 |
CTest* iTest; |
|
283 |
}; |
|
284 |
||
285 |
||
286 |
/** |
|
287 |
Run the test for iMaxIter iterations |
|
288 |
*/ |
|
289 |
TInt CTest::RunTest() |
|
290 |
{ |
|
291 |
TInt r = KErrNone; |
|
292 |
for (iCurIter=0; iCurIter<iMaxIter; ++iCurIter) |
|
293 |
{ |
|
294 |
r = DoRunTest(); |
|
295 |
if(KErrNone != r) |
|
296 |
break; |
|
297 |
} |
|
298 |
return r; |
|
299 |
} |
|
300 |
||
301 |
/** |
|
302 |
Open iChannel |
|
303 |
||
304 |
@pre iChannel is not open |
|
305 |
@return |
|
306 |
- KErrNotSupported Channel does not exist on DMAC |
|
307 |
- KErrNone Success |
|
308 |
- KErrInUse |
|
309 |
*/ |
|
310 |
TInt CTest::OpenChannel(TInt aDesCount, TInt aMaxFragmentSize) |
|
311 |
{ |
|
312 |
ASSERT(!iChannel.Handle()); |
|
313 |
const TInt r = iChannel.Open(iChannelId, aDesCount, aMaxFragmentSize); |
|
314 |
if (r == KErrNotSupported) |
|
315 |
return r; |
|
316 |
XTEST1(KErrNone == r || KErrInUse == r, r); |
|
317 |
||
318 |
if(KErrInUse == r) |
|
319 |
{ |
|
320 |
// Channel is in use. |
|
321 |
RDebug::Printf("\nDMA Channel %d is in use",iChannelId); |
|
322 |
if(0 == iCurIter) |
|
323 |
{ |
|
324 |
// Terminate thread by returning this error code KErrInUse. |
|
325 |
return r; |
|
326 |
} |
|
327 |
else |
|
328 |
{ |
|
329 |
#ifdef __WINS__ |
|
330 |
#pragma warning( disable : 4127 ) // warning C4127: conditional expression is constant |
|
331 |
#endif // __WINS__ |
|
332 |
XTEST1(EFalse, iCurIter); |
|
333 |
#ifdef __WINS__ |
|
334 |
#pragma warning( default : 4127 ) // warning C4127: conditional expression is constant |
|
335 |
#endif // __WINS__ |
|
336 |
} |
|
337 |
} |
|
338 |
return r; |
|
339 |
} |
|
340 |
||
341 |
||
342 |
||
343 |
// Spawn thread. Will auto-delete when thread exits. |
|
344 |
CTesterThread::CTesterThread(TInt aIdx, CTest* aTest) |
|
345 |
: CActive(EPriorityStandard), iTest(aTest) |
|
346 |
{ |
|
347 |
CActiveScheduler::Add(this); |
|
348 |
TBuf<16> name; |
|
349 |
name = _L("TESTER-"); |
|
350 |
name.AppendNum(aIdx); |
|
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
351 |
test(iThread.Create(name, ThreadFunction, 0x2000, NULL, this) == KErrNone); |
0 | 352 |
iThread.SetPriority(EPriorityLess); |
353 |
iThread.Logon(iStatus); |
|
354 |
SetActive(); |
|
355 |
iThread.Resume(); |
|
356 |
} |
|
357 |
||
358 |
||
359 |
TInt CTesterThread::ThreadFunction(TAny* aSelf) |
|
360 |
{ |
|
361 |
CTesterThread* self = (CTesterThread*)aSelf; |
|
362 |
return self->StartThread(); |
|
363 |
} |
|
364 |
||
365 |
TInt CTesterThread::StartThread() |
|
366 |
{ |
|
367 |
return iTest->RunTest(); |
|
368 |
} |
|
369 |
||
370 |
||
371 |
||
372 |
TInt CFragmentationTest::DoRunTest() |
|
373 |
{ |
|
374 |
// In case iMaxFragmentSize was larger than suppported (we need to know what fragment |
|
375 |
// size will actually be used) |
|
376 |
iMaxFragmentSize = Min(iMaxFragmentSize, Info.iMaxTransferSize); |
|
377 |
||
378 |
// Open channel with enough descriptors for 3 open DMA |
|
379 |
// requests (see TestStreaming). |
|
380 |
TInt r = OpenChannel(3* iMaxFragment, iMaxFragmentSize); |
|
381 |
if(r != KErrNone) |
|
382 |
return r; |
|
383 |
||
384 |
//we are controlling fragment size, so we know how |
|
385 |
//many to expect |
|
386 |
for (iCurFragment=1; iCurFragment<=iMaxFragment; iCurFragment*=2) |
|
387 |
{ |
|
388 |
const TInt size = iCurFragment * ( iMaxFragmentSize & ~Info.iMemAlignMask); |
|
389 |
iTestFn(iChannel, iCurFragment, size); |
|
390 |
} |
|
391 |
iChannel.Close(); |
|
392 |
return KErrNone; |
|
393 |
} |
|
394 |
||
395 |
TInt CDefaultFragTest::DoRunTest() |
|
396 |
{ |
|
397 |
// +1 so we don't underestimate maxFragount for inexact division |
|
398 |
const TUint maxFragCount = (iTotalTransferSize / Info.iMaxTransferSize) +1; |
|
399 |
||
400 |
// Open channel with enough descriptors for 3 open DMA |
|
401 |
// requests (see TestStreaming). |
|
402 |
const TUint descriptorCount = 3 * maxFragCount; |
|
403 |
||
404 |
TInt r = OpenChannel(descriptorCount); |
|
405 |
if(r != KErrNone) |
|
406 |
return r; |
|
407 |
||
408 |
iTestFn(iChannel, 0, iTotalTransferSize); |
|
409 |
||
410 |
iChannel.Close(); |
|
411 |
return KErrNone; |
|
412 |
} |
|
413 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
414 |
TInt CCloseInCb::DoRunTest() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
415 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
416 |
TInt r = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
417 |
RTest test(_L("CCloseInCb test")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
418 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
419 |
r = OpenChannel(1); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
420 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
421 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
422 |
const TInt KRequest = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
423 |
const TInt KSrcBuf = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
424 |
const TInt KDestBuf = 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
425 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
426 |
const TInt size = Min(iTransferSize, Info.iMaxTransferSize); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
427 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
428 |
r = iChannel.AllocBuffer(KSrcBuf, size); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
429 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
430 |
iChannel.FillBuffer(KSrcBuf, 'A'); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
431 |
r = iChannel.AllocBuffer(KDestBuf, size); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
432 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
433 |
iChannel.FillBuffer(KDestBuf, '\0'); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
434 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
435 |
TRequestStatus rs = KRequestPending; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
436 |
r = iChannel.Fragment(KRequest, KSrcBuf, KDestBuf, size, &rs); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
437 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
438 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
439 |
// "X" will cause channel to be closed during callback |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
440 |
r = iChannel.Execute(_L8("QX0")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
441 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
442 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
443 |
User::WaitForRequest(rs); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
444 |
test_KErrNone(rs.Int()); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
445 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
446 |
test(iChannel.CheckBuffer(KDestBuf, 'A')); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
447 |
iChannel.FreeAllBuffers(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
448 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
449 |
test.Close(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
450 |
return KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
451 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
452 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
453 |
TInt CFragSizeRange::DoRunTest() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
454 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
455 |
const TInt initialFragmentSize = Min(iInitialFragmentSize, Info.iMaxTransferSize); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
456 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
457 |
TInt r = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
458 |
RTest test(_L("CFragSizeRange test")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
459 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
460 |
r = iTimer.CreateLocal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
461 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
462 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
463 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
464 |
TInt fragSize = initialFragmentSize; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
465 |
TInt step = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
466 |
do |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
467 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
468 |
fragSize -= step; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
469 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
470 |
// Make sure size is aligned |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
471 |
fragSize = fragSize & ~Info.iMemAlignMask; |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
472 |
if(fragSize == 0) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
473 |
break; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
474 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
475 |
r = OpenChannel(iMaxFragCount, fragSize); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
476 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
477 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
478 |
for(iFragCount=1; iFragCount <= iMaxFragCount; iFragCount++) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
479 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
480 |
test.Printf(_L("Chan %d Fragment size %d bytes, %d fragments, %d iters\n"), iChannelId, fragSize, iFragCount, iInnerIterations); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
481 |
for(TInt i=0; i<iInnerIterations; i++) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
482 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
483 |
r = Transfer(fragSize); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
484 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
485 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
486 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
487 |
iChannel.Close(); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
488 |
// Reduce frag size by a quarter each iteration |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
489 |
step = (fragSize/4); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
490 |
} while (step > 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
491 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
492 |
iTimer.Close(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
493 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
494 |
test.Close(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
495 |
return r; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
496 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
497 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
498 |
TInt CFragSizeRange::Transfer(TInt aFragmentSize) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
499 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
500 |
const TInt KRequest = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
501 |
const TInt KSrcBuf = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
502 |
const TInt KDestBuf = 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
503 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
504 |
const TInt size = aFragmentSize * iFragCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
505 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
506 |
TInt r = iChannel.AllocBuffer(KSrcBuf, size); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
507 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
508 |
iChannel.FillBuffer(KSrcBuf, 'A'); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
509 |
r = iChannel.AllocBuffer(KDestBuf, size); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
510 |
XTEST2(r == KErrNone, r, size); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
511 |
iChannel.FillBuffer(KDestBuf, '\0'); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
512 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
513 |
// Test simple transfer |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
514 |
TRequestStatus rs = KRequestPending; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
515 |
r = iChannel.Fragment(KRequest, KSrcBuf, KDestBuf, size, &rs); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
516 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
517 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
518 |
test(iChannel.FragmentCheck(KRequest, iFragCount)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
519 |
r = iChannel.Execute(_L8("Q0")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
520 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
521 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
522 |
const TInt microSecTimeout = 1000000; // 1s |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
523 |
TRequestStatus timerStatus; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
524 |
iTimer.After(timerStatus, microSecTimeout); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
525 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
526 |
User::WaitForRequest(rs, timerStatus); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
527 |
if(rs.Int() == KRequestPending) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
528 |
{ |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
529 |
RDebug::Printf("Chan %d: Transfer timed out!", iChannelId); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
530 |
// timed out |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
531 |
test(EFalse); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
532 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
533 |
iTimer.Cancel(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
534 |
test_KErrNone(rs.Int()); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
535 |
test(iChannel.CheckBuffer(KDestBuf, 'A')); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
536 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
537 |
// Queue, then cancel request - Checks |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
538 |
// that there there is no spurious callback |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
539 |
// to the PIL |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
540 |
r = iChannel.Execute(_L8("Q0C")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
541 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
542 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
543 |
iChannel.FreeAllBuffers(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
544 |
return KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
545 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
546 |
|
0 | 547 |
|
548 |
// Called when thread completed. |
|
549 |
void CTesterThread::RunL() |
|
550 |
{ |
|
551 |
TExitType et = iThread.ExitType(); |
|
552 |
TInt er = iThread.ExitReason(); |
|
553 |
TExitCategoryName ec = iThread.ExitCategory(); |
|
554 |
TName name = iThread.Name(); |
|
555 |
CLOSE_AND_WAIT(iThread); |
|
556 |
||
557 |
switch (et) |
|
558 |
{ |
|
559 |
case EExitKill: |
|
560 |
// nothing to do |
|
561 |
break; |
|
562 |
case EExitPanic: |
|
563 |
{ |
|
564 |
User::SetJustInTime(JitEnabled); |
|
565 |
TBuf<128> buffer; |
|
566 |
iTest->ReportState(buffer); |
|
567 |
test.Printf(_L("Tester Thread Panic: %S: Test: %S\n"), |
|
568 |
&name, &buffer); |
|
569 |
if (ec.Match(KTestFailure) == 0) |
|
570 |
test.Panic(_L("Test failure line %d"), er); |
|
571 |
else |
|
572 |
test.Panic(_L("Unexpected panic: %S-%d"), &ec, er); |
|
573 |
break; |
|
574 |
} |
|
575 |
default: |
|
576 |
test.Panic(_L("Invalid thread exit type")); |
|
577 |
} |
|
578 |
||
579 |
TheCriticalSection.Wait(); |
|
580 |
if (--ThreadCount == 0) |
|
581 |
{ |
|
582 |
Bipper->Cancel(); |
|
583 |
test.Console()->Printf(_L("\n")); |
|
584 |
CActiveScheduler::Stop(); |
|
585 |
} |
|
586 |
TheCriticalSection.Signal(); |
|
587 |
||
588 |
// We commit suicide as the alternative (being deleted by |
|
589 |
// RunTest()) implies keeping a list of all instances in |
|
590 |
// RunTest(). |
|
591 |
delete this; |
|
592 |
} |
|
593 |
||
594 |
||
595 |
void CTesterThread::DoCancel() |
|
596 |
{ |
|
597 |
test.Panic(_L("CTesterThread::DoCancel called")); |
|
598 |
} |
|
599 |
||
600 |
||
601 |
static TInt Bip(TAny*) |
|
602 |
{ |
|
603 |
test.Console()->Printf(_L(".")); |
|
604 |
return 0; |
|
605 |
} |
|
606 |
||
607 |
||
608 |
// Execute provided test object in one or more tester threads. |
|
609 |
void RunTest(TUint32 aChannelIds[], TInt aMaxThread, CTest* aTest) |
|
610 |
{ |
|
611 |
test_NotNull(aTest); |
|
612 |
||
613 |
if (aMaxThread == 0) |
|
614 |
{ |
|
615 |
test.Printf(_L("transfer mode not supported - skipped\n")); |
|
616 |
return; |
|
617 |
} |
|
618 |
||
619 |
test.Printf(_L("Using %d thread(s)\n"), aMaxThread); |
|
620 |
||
621 |
// We don't want JIT debugging here because the tester threads may panic |
|
622 |
JitEnabled = User::JustInTime(); |
|
623 |
User::SetJustInTime(EFalse); |
|
624 |
||
625 |
// must be set before spawning threads to avoid premature active scheduler stop |
|
626 |
ThreadCount = aMaxThread; |
|
627 |
||
628 |
TBuf<128> buffer; |
|
629 |
for (TInt i=0; i<aMaxThread; ++i) |
|
630 |
{ |
|
631 |
//each CTesterThread needs its own CTest object |
|
632 |
CTest* dmaTest = aTest->Clone(); |
|
633 |
test_NotNull(dmaTest); |
|
634 |
||
635 |
dmaTest->SetChannelId(aChannelIds[i]); |
|
636 |
||
637 |
buffer.Zero(); |
|
638 |
dmaTest->AnnounceTest(buffer); |
|
639 |
test.Printf(_L("Thread %d: %S\n"), i, &buffer); |
|
640 |
||
641 |
test(new CTesterThread(i, dmaTest) != NULL); |
|
642 |
dmaTest = NULL; //ownership transferred to CTesterThread |
|
643 |
} |
|
644 |
||
645 |
const TTimeIntervalMicroSeconds32 KPeriod = 1000000; // 1s |
|
646 |
Bipper->Start(KPeriod, KPeriod, Bip); |
|
647 |
||
648 |
CActiveScheduler::Start(); |
|
649 |
||
650 |
User::SetJustInTime(JitEnabled); |
|
651 |
} |
|
652 |
||
653 |
||
654 |
inline void RunSbTest(TInt aMaxThread, CTest* aTest) |
|
655 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
656 |
RunTest(Info.iSbChannels, Min(1,Info.iMaxSbChannels), aTest); |
0 | 657 |
RunTest(Info.iSbChannels, Min(aMaxThread,Info.iMaxSbChannels), aTest); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
658 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
659 |
//the orginal isn't needed |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
660 |
delete aTest; |
0 | 661 |
} |
662 |
||
663 |
inline void RunDbTest(TInt aMaxThread, CTest* aTest) |
|
664 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
665 |
RunTest(Info.iDbChannels, Min(1,Info.iMaxDbChannels), aTest); |
0 | 666 |
RunTest(Info.iDbChannels, Min(aMaxThread,Info.iMaxDbChannels), aTest); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
667 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
668 |
//the orginal isn't needed |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
669 |
delete aTest; |
0 | 670 |
} |
671 |
||
672 |
inline void RunSgTest(TInt aMaxThread, CTest* aTest) |
|
673 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
674 |
RunTest(Info.iSgChannels, Min(1,Info.iMaxSgChannels), aTest); |
0 | 675 |
RunTest(Info.iSgChannels, Min(aMaxThread,Info.iMaxSgChannels), aTest); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
676 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
677 |
//the orginal isn't needed |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
678 |
delete aTest; |
0 | 679 |
} |
680 |
////////////////////////////////////////////////////////////////////////////// |
|
681 |
||
682 |
static void GetChannelInfo() |
|
683 |
{ |
|
684 |
RTestDma channel; |
|
685 |
test(channel.GetInfo(Info) == KErrNone); |
|
686 |
test(Info.iMaxSbChannels>0 || Info.iMaxDbChannels>0 || Info.iMaxSgChannels>0); |
|
687 |
} |
|
688 |
||
689 |
||
690 |
static void TestOneShot(RTestDma aChannel, TInt aFragmentCount, TInt aSize) |
|
691 |
{ |
|
692 |
const TInt KRequest = 0; |
|
693 |
const TInt KSrcBuf = 0; |
|
694 |
const TInt KDestBuf1 = 1; |
|
695 |
const TInt KDestBuf2 = 2; |
|
696 |
||
697 |
TInt r = aChannel.AllocBuffer(KSrcBuf, aSize); |
|
698 |
XTEST2(r == KErrNone, r, aSize); |
|
699 |
aChannel.FillBuffer(KSrcBuf, 'A'); |
|
700 |
r = aChannel.AllocBuffer(KDestBuf1, aSize); |
|
701 |
XTEST2(r == KErrNone, r, aSize); |
|
702 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
703 |
r = aChannel.AllocBuffer(KDestBuf2, aSize); |
|
704 |
XTEST2(r == KErrNone, r, aSize); |
|
705 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
706 |
||
707 |
// Test simple transfer |
|
708 |
TRequestStatus rs; |
|
709 |
r = aChannel.Fragment(KRequest, KSrcBuf, KDestBuf1, aSize, &rs); |
|
710 |
XTEST2(r == KErrNone, r, aSize); |
|
711 |
test(aChannel.FragmentCheck(KRequest, aFragmentCount)); |
|
712 |
r = aChannel.Execute(_L8("Q0")); |
|
713 |
XTEST1(r == KErrNone, r); |
|
714 |
User::WaitForRequest(rs); |
|
715 |
XTEST1(rs == KErrNone, rs.Int()); |
|
716 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'A')); |
|
717 |
||
718 |
// Test request reconfiguration. |
|
719 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
720 |
r = aChannel.Fragment(KRequest, KSrcBuf, KDestBuf2, aSize, &rs); |
|
721 |
XTEST2(r == KErrNone, r, aSize); |
|
722 |
test(aChannel.FragmentCheck(KRequest, aFragmentCount)); |
|
723 |
r = aChannel.Execute(_L8("Q0")); |
|
724 |
XTEST1(r == KErrNone, r); |
|
725 |
User::WaitForRequest(rs); |
|
726 |
XTEST1(rs == KErrNone, rs.Int()); |
|
727 |
XTEST(aChannel.CheckBuffer(KDestBuf1, '\0')); // previous dest unchanged? |
|
728 |
XTEST(aChannel.CheckBuffer(KDestBuf2, 'A')); |
|
729 |
||
730 |
// Test cancelling |
|
731 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
732 |
r = aChannel.Fragment(KRequest, KSrcBuf, KDestBuf1, aSize); |
|
733 |
XTEST2(r == KErrNone, r, aSize); |
|
734 |
test(aChannel.FragmentCheck(KRequest, aFragmentCount)); |
|
735 |
r = aChannel.Execute(_L8("Q0C")); |
|
736 |
XTEST1(r == KErrNone, r); |
|
737 |
// Part of the destination buffer should be unchanged if the |
|
738 |
// cancel occured before the transfer completed. |
|
739 |
#ifdef __DMASIM__ |
|
740 |
// At least part of the last destination buffer should be |
|
741 |
// unchanged if cancel occured before the transfer completed. |
|
742 |
// Assert only on WINS as real DMACs are too fast. |
|
743 |
XTEST(! aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
744 |
#endif |
|
745 |
||
746 |
// Perform another transfer to ensure cancel operation let the |
|
747 |
// framework in a consistent state. |
|
748 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
749 |
r = aChannel.Fragment(KRequest, KSrcBuf, KDestBuf1, aSize, &rs); |
|
750 |
XTEST2(r == KErrNone, r, aSize); |
|
751 |
test(aChannel.FragmentCheck(KRequest, aFragmentCount)); |
|
752 |
r = aChannel.Execute(_L8("Q0")); |
|
753 |
XTEST1(r == KErrNone, r); |
|
754 |
User::WaitForRequest(rs); |
|
755 |
XTEST1(rs == KErrNone, rs.Int()); |
|
756 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'A')); |
|
757 |
||
758 |
// |
|
759 |
// Test failure if the underlying DMA kernel extension allows it. |
|
760 |
// |
|
761 |
// As long as only "CancelAllFragments" is supported, it's okay to |
|
762 |
// always fail on the first fragment. |
|
763 |
// |
|
764 |
||
765 |
if (aChannel.FailNext(1) == KErrNone) |
|
766 |
{ |
|
767 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
768 |
r = aChannel.Fragment(KRequest, KSrcBuf, KDestBuf1, aSize, &rs); |
|
769 |
XTEST2(r == KErrNone, r, aSize); |
|
770 |
test(aChannel.FragmentCheck(KRequest, aFragmentCount)); |
|
771 |
r = aChannel.Execute(_L8("Q0")); |
|
772 |
XTEST1(r == KErrNone, r); |
|
773 |
User::WaitForRequest(rs); |
|
774 |
XTEST1(rs != KErrNone, rs.Int()); |
|
775 |
XTEST(! aChannel.CheckBuffer(KDestBuf1, 'A')); |
|
776 |
r = aChannel.Execute(_L8("C")); |
|
777 |
XTEST1(r == KErrNone, r); |
|
778 |
||
779 |
// Perform another transfer to ensure we are still in a |
|
780 |
// consistent state. |
|
781 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
782 |
r = aChannel.Fragment(KRequest, KSrcBuf, KDestBuf1, aSize, &rs); |
|
783 |
XTEST2(r == KErrNone, r, aSize); |
|
784 |
test(aChannel.FragmentCheck(KRequest, aFragmentCount)); |
|
785 |
r = aChannel.Execute(_L8("Q0")); |
|
786 |
XTEST1(r == KErrNone, r); |
|
787 |
User::WaitForRequest(rs); |
|
788 |
XTEST1(rs == KErrNone, rs.Int()); |
|
789 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'A')); |
|
790 |
} |
|
791 |
||
792 |
aChannel.FreeAllBuffers(); |
|
793 |
} |
|
794 |
||
795 |
||
796 |
static void TestStreaming(RTestDma aChannel, TInt aFragmentCount, TInt aSize) |
|
797 |
{ |
|
798 |
const TInt KRequest0 = 0; |
|
799 |
const TInt KRequest1 = 1; |
|
800 |
const TInt KRequest2 = 2; |
|
801 |
const TInt KSrcBuf0 = 0; |
|
802 |
const TInt KSrcBuf1 = 1; |
|
803 |
const TInt KSrcBuf2 = 2; |
|
804 |
const TInt KDestBuf0 = 3; |
|
805 |
const TInt KDestBuf1 = 4; |
|
806 |
const TInt KDestBuf2 = 5; |
|
807 |
||
808 |
// |
|
809 |
// Allocate and initialise source buffers |
|
810 |
// |
|
811 |
||
812 |
TInt r = aChannel.AllocBuffer(KSrcBuf0, aSize); |
|
813 |
XTEST2(r == KErrNone, r, aSize); |
|
814 |
aChannel.FillBuffer(KSrcBuf0, 'A'); |
|
815 |
||
816 |
r = aChannel.AllocBuffer(KSrcBuf1, aSize); |
|
817 |
XTEST2(r == KErrNone, r, aSize); |
|
818 |
aChannel.FillBuffer(KSrcBuf1, 'B'); |
|
819 |
||
820 |
r = aChannel.AllocBuffer(KSrcBuf2, aSize); |
|
821 |
XTEST2(r == KErrNone, r, aSize); |
|
822 |
aChannel.FillBuffer(KSrcBuf2, 'C'); |
|
823 |
||
824 |
// |
|
825 |
// Allocate destination buffers |
|
826 |
// |
|
827 |
||
828 |
r = aChannel.AllocBuffer(KDestBuf0, aSize); |
|
829 |
XTEST2(r == KErrNone, r, aSize); |
|
830 |
r = aChannel.AllocBuffer(KDestBuf1, aSize); |
|
831 |
XTEST2(r == KErrNone, r, aSize); |
|
832 |
r = aChannel.AllocBuffer(KDestBuf2, aSize); |
|
833 |
XTEST2(r == KErrNone, r, aSize); |
|
834 |
||
835 |
// |
|
836 |
// Test simple transfer. |
|
837 |
// (no need to test for request reconfiguration afterwards because |
|
838 |
// this was exercised in the one-shot test case) |
|
839 |
// |
|
840 |
||
841 |
TRequestStatus rs0; |
|
842 |
r = aChannel.Fragment(KRequest0, KSrcBuf0, KDestBuf0, aSize, &rs0); |
|
843 |
XTEST2(r == KErrNone, r, aSize); |
|
844 |
test(aChannel.FragmentCheck(KRequest0, aFragmentCount)); |
|
845 |
TRequestStatus rs1; |
|
846 |
r = aChannel.Fragment(KRequest1, KSrcBuf1, KDestBuf1, aSize, &rs1); |
|
847 |
XTEST2(r == KErrNone, r, aSize); |
|
848 |
test(aChannel.FragmentCheck(KRequest1, aFragmentCount)); |
|
849 |
TRequestStatus rs2; |
|
850 |
r = aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize, &rs2); |
|
851 |
XTEST2(r == KErrNone, r, aSize); |
|
852 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
853 |
||
854 |
r = aChannel.Execute(_L8("Q0Q1Q2")); |
|
855 |
XTEST1(r == KErrNone, r); |
|
856 |
User::WaitForRequest(rs0); |
|
857 |
XTEST1(rs0 == KErrNone, rs0.Int()); |
|
858 |
XTEST(aChannel.CheckBuffer(KDestBuf0, 'A')); |
|
859 |
User::WaitForRequest(rs1); |
|
860 |
XTEST1(rs1 == KErrNone, rs1.Int()); |
|
861 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'B')); |
|
862 |
User::WaitForRequest(rs2); |
|
863 |
XTEST1(rs2 == KErrNone, rs2.Int()); |
|
864 |
XTEST(aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
865 |
||
866 |
// |
|
867 |
// Test cancel |
|
868 |
// |
|
869 |
||
870 |
aChannel.FillBuffer(KDestBuf0, '\0'); |
|
871 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
872 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
873 |
||
874 |
r = aChannel.Fragment(KRequest0, KSrcBuf0, KDestBuf0, aSize); |
|
875 |
XTEST2(r == KErrNone, r, aSize); |
|
876 |
test(aChannel.FragmentCheck(KRequest0, aFragmentCount)); |
|
877 |
r = aChannel.Fragment(KRequest1, KSrcBuf1, KDestBuf1, aSize); |
|
878 |
XTEST2(r == KErrNone, r, aSize); |
|
879 |
test(aChannel.FragmentCheck(KRequest1, aFragmentCount)); |
|
880 |
r = aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize); |
|
881 |
XTEST2(r == KErrNone, r, aSize); |
|
882 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
883 |
||
884 |
r = aChannel.Execute(_L8("Q0Q1Q2C")); |
|
885 |
XTEST1(r == KErrNone, r); |
|
886 |
#ifdef __DMASIM__ |
|
887 |
// At least part of the last destination buffer should be |
|
888 |
// unchanged if cancel occured before the transfer completed. |
|
889 |
// Assert only on WINS as real DMACs are too fast. |
|
890 |
XTEST(! aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
891 |
#endif |
|
892 |
||
893 |
// |
|
894 |
// Perform another transfer to ensure cancel operation let the |
|
895 |
// framework in a consistent state. |
|
896 |
// |
|
897 |
||
898 |
aChannel.FillBuffer(KDestBuf0, '\0'); |
|
899 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
900 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
901 |
// Reconfigure last request to enable transfer completion notification |
|
902 |
r = aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize, &rs2); |
|
903 |
XTEST2(r == KErrNone, r, aSize); |
|
904 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
905 |
r = aChannel.Execute(_L8("Q0Q1Q2")); |
|
906 |
XTEST1(r == KErrNone, r); |
|
907 |
User::WaitForRequest(rs2); |
|
908 |
XTEST1(rs2 == KErrNone, rs2.Int()); |
|
909 |
XTEST(aChannel.CheckBuffer(KDestBuf0, 'A')); |
|
910 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'B')); |
|
911 |
XTEST(aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
912 |
||
913 |
// |
|
914 |
// Test for proper implementation of UnlinkHwDes() in the PSL. |
|
915 |
// |
|
916 |
||
917 |
aChannel.FillBuffer(KDestBuf0, '\0'); |
|
918 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
919 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
920 |
// Reconfigure last request to enable transfer completion notification |
|
921 |
r = aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize, &rs2); |
|
922 |
XTEST2(r == KErrNone, r, aSize); |
|
923 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
924 |
// Queue first request (Q0) |
|
925 |
r = aChannel.Execute(_L8("Q0")); |
|
926 |
// Wait a second, so next request will be queued on its own |
|
927 |
// (instead of being appended to the previous one) |
|
928 |
User::After(1000000); |
|
929 |
// Queue third request (Q2) |
|
930 |
r = aChannel.Execute(_L8("Q2")); |
|
931 |
XTEST1(r == KErrNone, r); |
|
932 |
User::WaitForRequest(rs2); |
|
933 |
XTEST1(rs2 == KErrNone, rs2.Int()); |
|
934 |
XTEST(aChannel.CheckBuffer(KDestBuf0, 'A')); |
|
935 |
// KDestBuf1 should have been left untouched! |
|
936 |
// If we find all B's in KDestBuf1, that means the last descriptor of the |
|
937 |
// first request (Q0) wasn't properly unlinked and still points to the Q1 |
|
938 |
// descriptor chain from the previous run. |
|
939 |
XTEST(aChannel.CheckBuffer(KDestBuf1, '\0')); |
|
940 |
XTEST(aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
941 |
||
942 |
// |
|
943 |
// Test failure if the underlying DMA kernel extension allows it. |
|
944 |
// |
|
945 |
// As long as only "CancelAllFragments" is supported, it's okay to |
|
946 |
// always fail on the first fragment. |
|
947 |
// |
|
948 |
||
949 |
if (aChannel.FailNext(1) == KErrNone) |
|
950 |
{ |
|
951 |
aChannel.FillBuffer(KDestBuf0, '\0'); |
|
952 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
953 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
954 |
XTEST(aChannel.Fragment(KRequest0, KSrcBuf0, KDestBuf0, aSize, &rs0) == KErrNone); |
|
955 |
test(aChannel.FragmentCheck(KRequest0, aFragmentCount)); |
|
956 |
XTEST(aChannel.Fragment(KRequest1, KSrcBuf1, KDestBuf1, aSize) == KErrNone); |
|
957 |
test(aChannel.FragmentCheck(KRequest1, aFragmentCount)); |
|
958 |
XTEST(aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize) == KErrNone); |
|
959 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
960 |
XTEST(aChannel.Execute(_L8("Q0Q1Q2")) == KErrNone); |
|
961 |
User::WaitForRequest(rs0); |
|
962 |
XTEST(rs0 != KErrNone); |
|
963 |
XTEST(! aChannel.CheckBuffer(KDestBuf0, 'A')); |
|
964 |
XTEST(! aChannel.CheckBuffer(KDestBuf1, 'B')); |
|
965 |
XTEST(! aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
966 |
XTEST(aChannel.Execute(_L8("C")) == KErrNone); |
|
967 |
||
968 |
// Transfer again to ensure cancel cleaned-up correctly |
|
969 |
aChannel.FillBuffer(KDestBuf0, '\0'); |
|
970 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
971 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
972 |
XTEST(aChannel.Fragment(KRequest0, KSrcBuf0, KDestBuf0, aSize, &rs0) == KErrNone); |
|
973 |
test(aChannel.FragmentCheck(KRequest0, aFragmentCount)); |
|
974 |
XTEST(aChannel.Fragment(KRequest1, KSrcBuf1, KDestBuf1, aSize, &rs1) == KErrNone); |
|
975 |
test(aChannel.FragmentCheck(KRequest1, aFragmentCount)); |
|
976 |
XTEST(aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize, &rs2) == KErrNone); |
|
977 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
978 |
XTEST(aChannel.Execute(_L8("Q0Q1Q2")) == KErrNone); |
|
979 |
User::WaitForRequest(rs0); |
|
980 |
XTEST(rs0 == KErrNone); |
|
981 |
User::WaitForRequest(rs1); |
|
982 |
XTEST(rs1 == KErrNone); |
|
983 |
User::WaitForRequest(rs2); |
|
984 |
XTEST(rs2 == KErrNone); |
|
985 |
XTEST(aChannel.CheckBuffer(KDestBuf0, 'A')); |
|
986 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'B')); |
|
987 |
XTEST(aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
988 |
} |
|
989 |
||
990 |
// |
|
991 |
// Test that framework behaves correctly if one or more DMA interrupts are |
|
992 |
// missed. |
|
993 |
// |
|
994 |
||
995 |
if (aChannel.MissNextInterrupts(1) == KErrNone) |
|
996 |
{ |
|
997 |
aChannel.FillBuffer(KDestBuf0, '\0'); |
|
998 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
999 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
1000 |
XTEST(aChannel.Fragment(KRequest0, KSrcBuf0, KDestBuf0, aSize, &rs0) == KErrNone); |
|
1001 |
test(aChannel.FragmentCheck(KRequest0, aFragmentCount)); |
|
1002 |
XTEST(aChannel.Fragment(KRequest1, KSrcBuf1, KDestBuf1, aSize, &rs1) == KErrNone); |
|
1003 |
test(aChannel.FragmentCheck(KRequest1, aFragmentCount)); |
|
1004 |
XTEST(aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize, &rs2) == KErrNone); |
|
1005 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
1006 |
XTEST(aChannel.Execute(_L8("Q0Q1Q2")) == KErrNone); |
|
1007 |
User::WaitForRequest(rs0); |
|
1008 |
XTEST(rs0 == KErrNone); |
|
1009 |
User::WaitForRequest(rs1); |
|
1010 |
XTEST(rs1 == KErrNone); |
|
1011 |
User::WaitForRequest(rs2); |
|
1012 |
XTEST(rs2 == KErrNone); |
|
1013 |
XTEST(aChannel.CheckBuffer(KDestBuf0, 'A')); |
|
1014 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'B')); |
|
1015 |
XTEST(aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
1016 |
} |
|
1017 |
||
1018 |
if (aChannel.MissNextInterrupts(2) == KErrNone) |
|
1019 |
{ |
|
1020 |
aChannel.FillBuffer(KDestBuf0, '\0'); |
|
1021 |
aChannel.FillBuffer(KDestBuf1, '\0'); |
|
1022 |
aChannel.FillBuffer(KDestBuf2, '\0'); |
|
1023 |
XTEST(aChannel.Fragment(KRequest0, KSrcBuf0, KDestBuf0, aSize, &rs0) == KErrNone); |
|
1024 |
test(aChannel.FragmentCheck(KRequest0, aFragmentCount)); |
|
1025 |
XTEST(aChannel.Fragment(KRequest1, KSrcBuf1, KDestBuf1, aSize, &rs1) == KErrNone); |
|
1026 |
test(aChannel.FragmentCheck(KRequest1, aFragmentCount)); |
|
1027 |
XTEST(aChannel.Fragment(KRequest2, KSrcBuf2, KDestBuf2, aSize, &rs2) == KErrNone); |
|
1028 |
test(aChannel.FragmentCheck(KRequest2, aFragmentCount)); |
|
1029 |
XTEST(aChannel.Execute(_L8("Q0Q1Q2")) == KErrNone); |
|
1030 |
User::WaitForRequest(rs0); |
|
1031 |
XTEST(rs0 == KErrNone); |
|
1032 |
User::WaitForRequest(rs1); |
|
1033 |
XTEST(rs1 == KErrNone); |
|
1034 |
User::WaitForRequest(rs2); |
|
1035 |
XTEST(rs2 == KErrNone); |
|
1036 |
XTEST(aChannel.CheckBuffer(KDestBuf0, 'A')); |
|
1037 |
XTEST(aChannel.CheckBuffer(KDestBuf1, 'B')); |
|
1038 |
XTEST(aChannel.CheckBuffer(KDestBuf2, 'C')); |
|
1039 |
} |
|
1040 |
||
1041 |
aChannel.FreeAllBuffers(); |
|
1042 |
} |
|
1043 |
||
1044 |
||
1045 |
static TBool ParseCmdLine(TBool& aCrashDbg, TInt& aMaxfrag, TInt& aMaxIter, TInt& aMaxchannel, TInt& aMaxFragSize) |
|
1046 |
// |
|
1047 |
// The command line. Syntax is: |
|
1048 |
// |
|
1049 |
// t_dma [enableCrashDebugger [aMaxFrag [aMaxIter [aMaxchannel [aMaxFragSize]]]]] |
|
1050 |
// |
|
1051 |
{ |
|
1052 |
TBuf<256> cmdline; |
|
1053 |
User::CommandLine(cmdline); |
|
1054 |
TLex lex(cmdline); |
|
1055 |
||
1056 |
lex.SkipSpace(); |
|
1057 |
||
1058 |
if (lex.Eos()) |
|
1059 |
return ETrue; |
|
1060 |
if (lex.Val(aCrashDbg) != KErrNone) |
|
1061 |
return EFalse; |
|
1062 |
lex.SkipSpace(); |
|
1063 |
if (lex.Eos()) |
|
1064 |
return ETrue; |
|
1065 |
if (lex.Val(aMaxfrag) != KErrNone) |
|
1066 |
return EFalse; |
|
1067 |
lex.SkipSpace(); |
|
1068 |
if (lex.Eos()) |
|
1069 |
return ETrue; |
|
1070 |
if (lex.Val(aMaxIter) != KErrNone) |
|
1071 |
return EFalse; |
|
1072 |
lex.SkipSpace(); |
|
1073 |
if (lex.Eos()) |
|
1074 |
return ETrue; |
|
1075 |
if (lex.Val(aMaxchannel) != KErrNone) |
|
1076 |
return EFalse; |
|
1077 |
lex.SkipSpace(); |
|
1078 |
if (lex.Eos()) |
|
1079 |
return ETrue; |
|
1080 |
||
1081 |
return lex.Val(aMaxFragSize) == KErrNone; |
|
1082 |
} |
|
1083 |
||
1084 |
||
1085 |
TInt E32Main() |
|
1086 |
{ |
|
1087 |
test.Title(); |
|
1088 |
||
1089 |
test.Start(_L("Parsing command-line")); |
|
1090 |
// Default values when run with empty command-line |
|
1091 |
TInt maxfrag = 16; // 5 fragments needed to exercise fully double-buffering state machine |
|
1092 |
TInt maxIter = 3; |
|
1093 |
TInt maxchannel = KMaxTInt; |
|
1094 |
TBool crashDbg = EFalse; |
|
1095 |
TInt maxFragSize = 0x4000; //16k |
|
1096 |
||
1097 |
(void) ParseCmdLine(crashDbg, maxfrag, maxIter, maxchannel, maxFragSize); |
|
1098 |
||
1099 |
if (crashDbg) |
|
1100 |
{ |
|
1101 |
User::SetCritical(User::ESystemCritical); |
|
1102 |
User::SetProcessCritical(User::ESystemCritical); |
|
1103 |
} |
|
1104 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1105 |
|
0 | 1106 |
TInt r; |
1107 |
#if defined(__DMASIM__) && defined(__WINS__) |
|
1108 |
test.Next(_L("Loading DMA simulator")); |
|
1109 |
r = User::LoadLogicalDevice(_L("DMASIM.DLL")); |
|
1110 |
test(r == KErrNone || r == KErrAlreadyExists); |
|
1111 |
#endif |
|
1112 |
||
1113 |
test.Next(_L("Loading test LDD")); |
|
1114 |
#ifdef __DMASIM__ |
|
1115 |
r = User::LoadLogicalDevice(_L("D_DMASIM")); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1116 |
test(r == KErrNone || r == KErrAlreadyExists); |
0 | 1117 |
#else |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1118 |
//load either the original test ldd, d_dma.ldd, |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1119 |
//or d_dma_compat.ldd - an ldd providing the same interface |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1120 |
//but linked against the new MHA dma framework |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1121 |
_LIT(KDma, "D_DMA.LDD"); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1122 |
r = User::LoadLogicalDevice(KDma); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1123 |
const TBool dmaPresent = (r == KErrNone || r == KErrAlreadyExists); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1124 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1125 |
_LIT(KDmaCompat, "D_DMA_COMPAT.LDD"); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1126 |
r = User::LoadLogicalDevice(KDmaCompat); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1127 |
const TBool dmaCompatPresent = (r == KErrNone || r == KErrAlreadyExists); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1128 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1129 |
if (!(dmaPresent || dmaCompatPresent)) |
0 | 1130 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1131 |
test.Printf(_L("DMA test driver not found - test skipped\n")); |
0 | 1132 |
return 0; |
1133 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1134 |
else if (dmaPresent && !dmaCompatPresent) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1135 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1136 |
test.Printf(_L("Loaded %S\n"), &KDma); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1137 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1138 |
else if (!dmaPresent && dmaCompatPresent) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1139 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1140 |
test.Printf(_L("Loaded %S\n"), &KDmaCompat); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1141 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1142 |
else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1143 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1144 |
test.Printf(_L("The ROM contains %S and %S - only one should be present\n"), &KDma, &KDmaCompat); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1145 |
test(EFalse); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1146 |
} |
0 | 1147 |
#endif |
1148 |
||
1149 |
// Turn off evil lazy dll unloading |
|
1150 |
RLoader l; |
|
1151 |
test(l.Connect()==KErrNone); |
|
1152 |
test(l.CancelLazyDllUnload()==KErrNone); |
|
1153 |
l.Close(); |
|
1154 |
||
1155 |
__UHEAP_MARK; |
|
1156 |
__KHEAP_MARK; |
|
1157 |
||
1158 |
test.Next(_L("Creating critical section")); |
|
1159 |
test(TheCriticalSection.CreateLocal() == KErrNone); |
|
1160 |
||
1161 |
test.Next(_L("Creating active scheduler")); |
|
1162 |
CActiveScheduler* pS = new CActiveScheduler; |
|
1163 |
test(pS != NULL); |
|
1164 |
CActiveScheduler::Install(pS); |
|
1165 |
||
1166 |
test.Next(_L("Creating bipper")); |
|
1167 |
Bipper = CPeriodic::New(CActive::EPriorityStandard); |
|
1168 |
test(Bipper != NULL); |
|
1169 |
||
1170 |
test.Next(_L("Getting channel info")); |
|
1171 |
GetChannelInfo(); |
|
1172 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1173 |
test.Next(_L("Test that channel can be closed from callback")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1174 |
test.Next(_L("sb")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1175 |
RunSbTest(maxchannel, new CCloseInCb() ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1176 |
test.Next(_L("db")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1177 |
RunDbTest(maxchannel, new CCloseInCb() ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1178 |
test.Next(_L("sg")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1179 |
RunSgTest(maxchannel, new CCloseInCb() ); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1180 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1181 |
test.Next(_L("Testing different fragment sizes")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1182 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1183 |
const TInt rangeFragSize = 4096; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1184 |
#ifdef __DMASIM__ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1185 |
// Use fewer iterations on the emulator |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1186 |
// since it is slower. Also this test is really |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1187 |
// intended to find errors in PSL implmentations |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1188 |
const TInt iterPerFragSize = 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1189 |
#else |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
1190 |
const TInt iterPerFragSize = 10; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1191 |
#endif |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
1192 |
const TInt rangeMaxFragCount = 5; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1193 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1194 |
test.Next(_L("sb")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1195 |
RunSbTest(maxchannel, new CFragSizeRange(1, rangeMaxFragCount, rangeFragSize, iterPerFragSize)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1196 |
test.Next(_L("db")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1197 |
RunDbTest(maxchannel, new CFragSizeRange(1, rangeMaxFragCount, rangeFragSize, iterPerFragSize)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1198 |
test.Next(_L("sg")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1199 |
RunSgTest(maxchannel, new CFragSizeRange(1, rangeMaxFragCount, rangeFragSize, iterPerFragSize)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1200 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1201 |
|
0 | 1202 |
// Size for the single transfer test |
1203 |
TInt totalTransferSize = 64 * KKilo; |
|
1204 |
||
1205 |
test.Next(_L("Testing one shot single buffer transfer")); |
|
1206 |
RunSbTest(maxchannel, new CFragmentationTest(TestOneShot, maxIter, maxfrag, maxFragSize)); |
|
1207 |
RunSbTest(maxchannel, new CDefaultFragTest(TestOneShot, maxIter, totalTransferSize)); |
|
1208 |
||
1209 |
test.Next(_L("Testing one shot double buffer transfer")); |
|
1210 |
RunDbTest(maxchannel, new CFragmentationTest(TestOneShot, maxIter, maxfrag, maxFragSize)); |
|
1211 |
RunDbTest(maxchannel, new CDefaultFragTest(TestOneShot, maxIter, totalTransferSize)); |
|
1212 |
||
1213 |
test.Next(_L("Testing one shot scatter/gather transfer")); |
|
1214 |
RunSgTest(maxchannel, new CFragmentationTest(TestOneShot, maxIter, maxfrag, maxFragSize)); |
|
1215 |
RunSgTest(maxchannel, new CDefaultFragTest(TestOneShot, maxIter, totalTransferSize)); |
|
1216 |
||
1217 |
test.Next(_L("Testing streaming single buffer transfer")); |
|
1218 |
RunSbTest(maxchannel, new CFragmentationTest(TestStreaming, maxIter, maxfrag, maxFragSize)); |
|
1219 |
RunSbTest(maxchannel, new CDefaultFragTest(TestStreaming, maxIter, totalTransferSize)); |
|
1220 |
||
1221 |
test.Next(_L("Testing streaming double buffer transfer")); |
|
1222 |
RunDbTest(maxchannel, new CFragmentationTest(TestStreaming, maxIter, maxfrag, maxFragSize)); |
|
1223 |
RunDbTest(maxchannel, new CDefaultFragTest(TestStreaming, maxIter, totalTransferSize)); |
|
1224 |
||
1225 |
test.Next(_L("Testing streaming scatter/gather transfer")); |
|
1226 |
RunSgTest(maxchannel, new CFragmentationTest(TestStreaming, maxIter, maxfrag, maxFragSize)); |
|
1227 |
RunSgTest(maxchannel, new CDefaultFragTest(TestStreaming, maxIter, totalTransferSize)); |
|
1228 |
||
1229 |
delete pS; |
|
1230 |
delete Bipper; |
|
1231 |
TheCriticalSection.Close(); |
|
1232 |
||
1233 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); |
|
1234 |
__KHEAP_MARKEND; |
|
1235 |
__UHEAP_MARKEND; |
|
1236 |
||
1237 |
test.End(); |
|
1238 |
return 0; |
|
1239 |
} |