author | hgs |
Fri, 23 Apr 2010 22:08:41 +0100 | |
changeset 121 | 661475905584 |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
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\debug\t_cache.cpp |
|
15 |
// Overview: |
|
16 |
// Performs cache checking in order to ensure it is running correctly. |
|
17 |
// Runs automatically or as manual test. (Type "t_cache help" for details.) |
|
18 |
// API Information: |
|
19 |
// class Cache |
|
20 |
// class L2Cache |
|
21 |
// Details: |
|
22 |
// -Test1 - Displays cache properties. |
|
23 |
// -Test2 - Gets thresholds. |
|
24 |
// -Test3 - Sets thresholds. |
|
25 |
// -Test4 - Compares different memory mappings of data. |
|
26 |
// -Test5 - Compares different memory mappings of code. |
|
27 |
// -Test6 - Tests Write Back mode. |
|
28 |
// -Test7 - Tests cache maintenance functions |
|
29 |
// It can also perform more specified tests if run manually: |
|
30 |
// - t_cache info Test1 only |
|
31 |
// - t_cache data <size_hex> Runs data chunk test (Test 4) with specified chunk size. For example, |
|
32 |
// "t_cache data 10000" will run data chunk test against 64KB chunk. |
|
33 |
// - t_cache code <size_hex> Runs code chunk test (Test 5) for specified chink size. For example, |
|
34 |
// "t_cache code 10000" will run code chunk test against 64KB chunk. |
|
35 |
// - t_cache data+<size_hex> Runs data chunk test for specified set of chunk sizes. For example, |
|
36 |
// "t_cache data+1000" will perform data chunk test for sizes 4K, 8K,... up to 512K. |
|
37 |
// - t_cache code+<size_hex> Runs code chunk test for specified set of sizes. For example, |
|
38 |
// "t_cache code+1000" will perform code chunk test for sizes 4K, 8K,... up to 512K. |
|
39 |
// - t_cache threshold Diplays thresholds for all caches on the platform. |
|
40 |
// - t_cache threshold T P C H Sets new values for cache thresholds: |
|
41 |
// - "T" specifies the type of cache to whose threshould are to be chenged: |
|
42 |
// 1 for Instruction (or Unified) Cache. |
|
43 |
// 2 for Data Cache (for ARMv7 and later, this is Point-of-Coherency threshold. |
|
44 |
// 4 for XScale AltData Cache. |
|
45 |
// 8 for Point-of-Unification Data Cache Threshold for ARMv7 and later platforms. |
|
46 |
// 10 for L2 (L210 or XScale L2 cache) |
|
47 |
// - "P" "C" & "H" are hex values for purge, clean & flush thresholds. |
|
48 |
// For example: "t_cache 1 10000 10000 10000" sets 64KB for all thresholds in Instruction Cache. |
|
49 |
// - t_cache usecase Runs particular use case tests. |
|
50 |
// - t_cache help Displays the list of manual commands. |
|
51 |
// Platforms/Drives/Compatibility: |
|
52 |
// Hardware - ARM only (Manual). Not supported on emulator. |
|
53 |
// Assumptions/Requirement/Pre-requisites: |
|
54 |
// Failures and causes: |
|
55 |
// Base Port information: |
|
56 |
// d_cache.mmp to be built from the baseport. |
|
57 |
// |
|
58 |
// |
|
59 |
||
60 |
#include <e32test.h> |
|
61 |
#include "d_cache.h" |
|
62 |
||
63 |
//------------globals--------------------- |
|
64 |
LOCAL_D RTest test(_L("T_CACHE")); |
|
65 |
_LIT(KPrintCacheInfos,"info"); |
|
66 |
_LIT(KTestData,"data"); |
|
67 |
_LIT(KTestCode,"code"); |
|
68 |
_LIT(KHelp,"help"); |
|
69 |
_LIT(KThreshold,"threshold"); |
|
70 |
_LIT(KIncremental,"+"); |
|
71 |
_LIT(KUseCase,"usecase"); |
|
72 |
||
73 |
RCacheTestDevice Device; |
|
74 |
RCacheTestDevice::TCacheInfo CacheInfo; |
|
75 |
TBuf<KCacheDescSize> TempBuff; |
|
76 |
||
77 |
const TInt KDefaultDataSize = 0x20000; |
|
78 |
const TInt KDefaultCodeSize = 0x804; //2K+4. Should be <= TestCodeFuncSize(). Otherwise, code test won't run against rom image. |
|
79 |
const TInt KMaxChunkSize = 0x80000; //512KB Incremental tests limit |
|
80 |
const TInt KWriteBackTestSizeSize = 0x4000; // Shouldn't go over cache thresholds (where purge becomes flush). |
|
81 |
||
82 |
extern void DataSegmetTestFunct(void* aBase, TInt aSize); |
|
83 |
||
84 |
/** Loads & opens LDD.*/ |
|
85 |
void StartDriver() |
|
86 |
{ |
|
87 |
TInt r = User::LoadLogicalDevice(KCacheTestDriverName); |
|
88 |
test( r==KErrNone || r==KErrAlreadyExists); |
|
89 |
if((r = Device.Open())!=KErrNone) |
|
90 |
{ |
|
91 |
User::FreeLogicalDevice(KCacheTestDriverName); |
|
92 |
test.Printf(_L("Could not open LDD")); |
|
93 |
test(0); |
|
94 |
} |
|
95 |
} |
|
96 |
||
97 |
/** Closes and unloads LDD.*/ |
|
98 |
void StopDriver() |
|
99 |
{ |
|
100 |
Device.Close(); |
|
101 |
User::FreeLogicalDevice(KCacheTestDriverName); |
|
102 |
} |
|
103 |
||
104 |
/** Get cache info from device driver. This will update CacheInfo global variable.*/ |
|
105 |
void GetCacheInfo() |
|
106 |
{ |
|
107 |
TInt r = Device.GetCacheInfo(CacheInfo); |
|
108 |
test(r==KErrNone); |
|
109 |
} |
|
110 |
||
111 |
//--------------------------------------------- |
|
112 |
//! @SYMTestCaseID MMU-T_CACHE-01 |
|
113 |
//! @SYMTestType ST |
|
114 |
//! @SYMPREQ PREQ305 |
|
115 |
//! @SYMREQ REQ5795 |
|
116 |
//! @SYMTestCaseDesc Displays cache properties. |
|
117 |
//! @SYMTestExpectedResults KErrNone |
|
118 |
//! @SYMTestPriority Low |
|
119 |
//! @SYMTestStatus Implemented |
|
120 |
//--------------------------------------------- |
|
121 |
void Test1() |
|
122 |
{ |
|
123 |
TInt i; |
|
124 |
||
125 |
test.Printf(_L("General Info:\n")); |
|
126 |
TPtr ptr = CacheInfo.iDesc.Expand(); |
|
127 |
test.Printf(ptr); |
|
128 |
test.Printf(_L("CacheCount:%d, MaxCacheSize:%xH, MemoryRemapping:%d, OuterCache:%d\n"),CacheInfo.iCacheCount, CacheInfo.iMaxCacheSize, CacheInfo.iMemoryRemapping, CacheInfo.iOuterCache); |
|
129 |
test.Printf(_L("DMAMemoryAlignement:%d\n"),CacheInfo.iDmaBufferAlignment); |
|
130 |
||
131 |
||
132 |
test.Printf(_L("Per Level Info:\n")); |
|
133 |
test.Printf(_L("Level\tData\tInstr\tSize(b)\tLine(b)\tWays\tSets\tDescription\n")); |
|
134 |
||
135 |
for (i = 0; i<CacheInfo.iCacheCount; i++) |
|
136 |
{ |
|
137 |
TempBuff.SetLength(0); |
|
138 |
RCacheTestDevice::TCacheSingle& cs = CacheInfo.iCache[i]; |
|
139 |
TempBuff.Format(_L("%d\t%d\t%d\t%xH\t%xH\t%xH\t%xH\t"), cs.iLevel, cs.iData, cs.iCode, cs.iSize, cs.iLineSize, cs.iWays, cs.iSets); |
|
140 |
ptr = cs.iDesc.Expand(); |
|
141 |
TempBuff.Append(ptr); |
|
142 |
TempBuff.Append(_L("\n")); |
|
143 |
test.Printf(TempBuff); |
|
144 |
} |
|
145 |
} |
|
146 |
||
147 |
//--------------------------------------------- |
|
148 |
//! @SYMTestCaseID MMU-T_CACHE-02 |
|
149 |
//! @SYMTestType ST |
|
150 |
//! @SYMPREQ PREQ1068 |
|
151 |
//! @SYMREQ REQ5909 |
|
152 |
//! @SYMTestCaseDesc Gets thresholds. |
|
153 |
//! @SYMTestActions Fetches Cache Thresholds from the driver. |
|
154 |
//! @SYMTestExpectedResults KErrNone |
|
155 |
//! @SYMTestPriority High |
|
156 |
//! @SYMTestStatus Implemented |
|
157 |
//--------------------------------------------- |
|
158 |
void Test2() |
|
159 |
{ |
|
160 |
RCacheTestDevice::TThresholdInfo info; |
|
161 |
||
162 |
test.Printf(_L("Cache: Purge Clear Flush\n")); |
|
163 |
||
164 |
info.iCacheType=1; |
|
165 |
if (KErrNone == Device.GetThreshold(info)) |
|
166 |
test.Printf(_L("Instr:%6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush); |
|
167 |
||
168 |
info.iCacheType=2; |
|
169 |
if (KErrNone == Device.GetThreshold(info)) |
|
170 |
test.Printf(_L("Data: %6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush); |
|
171 |
||
172 |
info.iCacheType=4; |
|
173 |
if (KErrNone == Device.GetThreshold(info)) |
|
174 |
test.Printf(_L("AltD: %6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush); |
|
175 |
||
176 |
info.iCacheType=8; |
|
177 |
if (KErrNone == Device.GetThreshold(info)) |
|
178 |
test.Printf(_L("D_IMB:%6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush); |
|
179 |
||
180 |
info.iCacheType=16; |
|
181 |
if (KErrNone == Device.GetThreshold(info)) |
|
182 |
test.Printf(_L("L2: %6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush); |
|
183 |
} |
|
184 |
||
185 |
//--------------------------------------------- |
|
186 |
//! @SYMTestCaseID MMU-T_CACHE-03 |
|
187 |
//! @SYMTestType ST |
|
188 |
//! @SYMPREQ PREQ1068 |
|
189 |
//! @SYMREQ REQ5909 |
|
190 |
//! @SYMTestCaseDesc Sets thresholds. |
|
191 |
//! @SYMTestActions Sets new values forr Cache Thresholds. Then, sets back the old values. |
|
192 |
//! @SYMTestExpectedResults KErrNone |
|
193 |
//! @SYMTestPriority High |
|
194 |
//! @SYMTestStatus Implemented |
|
195 |
//--------------------------------------------- |
|
196 |
void Test3() |
|
197 |
{ |
|
198 |
TInt i, tested=0; |
|
199 |
RCacheTestDevice::TThresholdInfo info[5]; //for 5 types og cache |
|
200 |
TInt returned[5]; |
|
201 |
||
202 |
||
203 |
//Get the old values |
|
204 |
for (i=0;i<5;i++) |
|
205 |
{ |
|
206 |
info[i].iCacheType= 1<<i; |
|
207 |
returned[i] = Device.GetThreshold(info[i]); |
|
208 |
} |
|
209 |
||
210 |
//Double them all |
|
211 |
for (i=0;i<5;i++) |
|
212 |
{ |
|
213 |
if (returned[i] != KErrNone) continue; //not a valid cache type for running platform |
|
214 |
tested++; |
|
215 |
info[i].iPurge <<=1; |
|
216 |
info[i].iClean <<=1; |
|
217 |
info[i].iFlush <<=1; |
|
218 |
test(KErrNone==Device.SetThreshold(info[i])); |
|
219 |
} |
|
220 |
||
221 |
//Put back the old values |
|
222 |
for (i=0;i<5;i++) |
|
223 |
{ |
|
224 |
if (returned[i] != KErrNone) continue; //not a valid cache type for running platform |
|
225 |
info[i].iPurge >>=1; |
|
226 |
info[i].iClean >>=1; |
|
227 |
info[i].iFlush >>=1; |
|
228 |
test(KErrNone==Device.SetThreshold(info[i])); |
|
229 |
} |
|
230 |
test.Printf(_L(" ... %d caches present & tested\n"), tested); |
|
231 |
} |
|
232 |
||
233 |
||
234 |
||
235 |
void DoTest4(RCacheTestDevice::TCacheAttr aCacheAttr, RCacheTestDevice::TChunkTest& aDC, TInt& aTime1, TInt& aTime2) |
|
236 |
{ |
|
237 |
aDC.iCacheAttr = aCacheAttr; |
|
238 |
||
239 |
aDC.iShared = EFalse; |
|
240 |
test(KErrNone==Device.TestDataChunk(aDC)); |
|
241 |
aTime1 = aDC.iTime; |
|
242 |
||
243 |
aDC.iShared = ETrue; |
|
244 |
test(KErrNone==Device.TestDataChunk(aDC)); |
|
245 |
aTime2 = aDC.iTime; |
|
246 |
} |
|
247 |
//--------------------------------------------- |
|
248 |
//! @SYMTestCaseID MMU-T_CACHE-04 |
|
249 |
//! @SYMTestType ST |
|
250 |
//! @SYMPREQ PREQ305 |
|
251 |
//! @SYMREQ REQ5795 |
|
252 |
//! @SYMTestCaseDesc Compares different memory mappings of data. |
|
253 |
//! @SYMTestActions Runs the same performance test against data in the chunks with different cache attributes. |
|
254 |
//! Also, runs the same test against data from user & kernel heaps. |
|
255 |
//! @SYMTestExpectedResults KErrNone |
|
256 |
//! @SYMTestPriority Low |
|
257 |
//! @SYMTestStatus Implemented |
|
258 |
//--------------------------------------------- |
|
259 |
void Test4(TInt aSize) |
|
260 |
{ |
|
261 |
RCacheTestDevice::TChunkTest dC; |
|
262 |
dC.iSize = aSize; |
|
263 |
dC.iUseCase = 0; //not used |
|
264 |
dC.iLoops = 0; //not used |
|
265 |
TInt timeNS=0, timeS=0; |
|
266 |
||
267 |
test.Printf(_L(" Time\n")); |
|
268 |
test.Printf(_L("Mem_Type ActualMapAttr NotShared Shared\n")); |
|
269 |
test.Printf(_L("----------------------------------------------\n")); |
|
270 |
||
271 |
DoTest4(RCacheTestDevice::E_FullyBlocking, dC, timeNS, timeS); |
|
272 |
test.Printf(_L("FullyBlocking %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
273 |
DoTest4(RCacheTestDevice::E_Buffered_NC, dC, timeNS, timeS); |
|
274 |
test.Printf(_L("Buffered_NC %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
275 |
DoTest4(RCacheTestDevice::E_Buffered_C, dC, timeNS, timeS); |
|
276 |
test.Printf(_L("Buffered_C %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
277 |
||
278 |
||
279 |
DoTest4(RCacheTestDevice::E_InnerWT, dC, timeNS, timeS); |
|
280 |
test.Printf(_L("InnerWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
281 |
DoTest4(RCacheTestDevice::E_InnerWBRA, dC, timeNS, timeS); |
|
282 |
test.Printf(_L("InnerWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
283 |
DoTest4(RCacheTestDevice::E_InnerWB, dC, timeNS, timeS); |
|
284 |
test.Printf(_L("InnerWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
285 |
||
286 |
if(CacheInfo.iOuterCache) |
|
287 |
{ |
|
288 |
DoTest4(RCacheTestDevice::E_OuterWT, dC, timeNS, timeS); |
|
289 |
test.Printf(_L("OuterWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
290 |
DoTest4(RCacheTestDevice::E_OuterWBRA, dC, timeNS, timeS); |
|
291 |
test.Printf(_L("OuterWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
292 |
DoTest4(RCacheTestDevice::E_OuterWB, dC, timeNS, timeS); |
|
293 |
test.Printf(_L("OuterWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
294 |
||
295 |
DoTest4(RCacheTestDevice::E_InOutWT, dC, timeNS, timeS); |
|
296 |
test.Printf(_L("InOutWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
297 |
DoTest4(RCacheTestDevice::E_InOutWBRA, dC, timeNS, timeS); |
|
298 |
test.Printf(_L("InOutWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
299 |
DoTest4(RCacheTestDevice::E_InOutWB, dC, timeNS, timeS); |
|
300 |
test.Printf(_L("InOutWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
301 |
} |
|
302 |
||
303 |
||
304 |
DoTest4(RCacheTestDevice::E_StronglyOrder, dC, timeNS, timeS); |
|
305 |
test.Printf(_L("StronglyOrder %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
306 |
DoTest4(RCacheTestDevice::E_Device, dC, timeNS, timeS); |
|
307 |
test.Printf(_L("Device %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
308 |
DoTest4(RCacheTestDevice::E_Normal_Uncached, dC, timeNS, timeS); |
|
309 |
test.Printf(_L("Normal_Uncached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
310 |
DoTest4(RCacheTestDevice::E_Normal_Cached, dC, timeNS, timeS); |
|
311 |
test.Printf(_L("Normal_Cached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
312 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
DoTest4(RCacheTestDevice::E_KernelInternal4, dC, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
test.Printf(_L("KernelInternal4 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
315 |
DoTest4(RCacheTestDevice::E_PlatformSpecific5, dC, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
test.Printf(_L("PlatSpecific5 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
317 |
DoTest4(RCacheTestDevice::E_PlatformSpecific6, dC, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
test.Printf(_L("PlatSpecific6 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
DoTest4(RCacheTestDevice::E_PlatformSpecific7, dC, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
test.Printf(_L("PlatSpecific7 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
|
0 | 322 |
if(CacheInfo.iMemoryRemapping) |
323 |
{ |
|
324 |
DoTest4(RCacheTestDevice::E_InnerWT_Remapped, dC, timeNS, timeS); |
|
325 |
test.Printf(_L("InnerWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
326 |
DoTest4(RCacheTestDevice::E_InnerWBRA_Remapped, dC, timeNS, timeS); |
|
327 |
test.Printf(_L("InnerWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
328 |
DoTest4(RCacheTestDevice::E_InnerWB_Remapped, dC, timeNS, timeS); |
|
329 |
test.Printf(_L("InnerWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
330 |
||
331 |
if(CacheInfo.iOuterCache) |
|
332 |
{ |
|
333 |
DoTest4(RCacheTestDevice::E_OuterWT_Remapped, dC, timeNS, timeS); |
|
334 |
test.Printf(_L("OuterWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
335 |
DoTest4(RCacheTestDevice::E_OuterWBRA_Remapped, dC, timeNS, timeS); |
|
336 |
test.Printf(_L("OuterWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
337 |
DoTest4(RCacheTestDevice::E_OuterWB_Remapped, dC, timeNS, timeS); |
|
338 |
test.Printf(_L("OuterWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
339 |
||
340 |
DoTest4(RCacheTestDevice::E_InOutWT_Remapped, dC, timeNS, timeS); |
|
341 |
test.Printf(_L("InOutWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
342 |
DoTest4(RCacheTestDevice::E_InOutWBRA_Remapped, dC, timeNS, timeS); |
|
343 |
test.Printf(_L("InOutWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
344 |
DoTest4(RCacheTestDevice::E_InOutWB_Remapped, dC, timeNS, timeS); |
|
345 |
test.Printf(_L("InOutWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
346 |
} |
|
347 |
} |
|
348 |
||
349 |
//Run against kernel heap - allow the test to fail due to OOM |
|
350 |
dC.iCacheAttr = RCacheTestDevice::E_Default; |
|
351 |
TInt r = Device.TestDataChunk(dC); |
|
352 |
if (r==KErrNone) test.Printf(_L("Kernel Heap ---------\t%7d\t-------\n"), dC.iTime); |
|
353 |
else if (r==KErrNoMemory) test.Printf(_L("Kernel Heap Cannot allocate memory\n")); |
|
354 |
else test(0);//fail |
|
355 |
||
356 |
//Run against user heap - allow the test to fail due to OOM |
|
357 |
void* buffer = User::Alloc(dC.iSize); |
|
358 |
if (buffer == NULL) |
|
359 |
{ |
|
360 |
test.Printf(_L("User Heap Cannot allocate memory\n")); |
|
361 |
return; |
|
362 |
} |
|
363 |
TInt time = User::NTickCount(); |
|
364 |
DataSegmetTestFunct(buffer , dC.iSize); |
|
365 |
time = User::NTickCount() - time; |
|
366 |
User::Free(buffer); |
|
367 |
test.Printf(_L("User Heap ---------\t%7d\t-------\n"), time); |
|
368 |
||
369 |
} |
|
370 |
||
371 |
||
372 |
void DoTest5(RCacheTestDevice::TCacheAttr aCacheAttr, RCacheTestDevice::TChunkTest& aDC, TInt& aTime1, TInt& aTime2) |
|
373 |
{ |
|
374 |
aDC.iCacheAttr = aCacheAttr; |
|
375 |
||
376 |
aDC.iShared = EFalse; |
|
377 |
test(KErrNone==Device.TestCodeChunk(aDC)); |
|
378 |
aTime1 = aDC.iTime; |
|
379 |
||
380 |
aDC.iShared = ETrue; |
|
381 |
test(KErrNone==Device.TestCodeChunk(aDC)); |
|
382 |
aTime2 = aDC.iTime; |
|
383 |
} |
|
384 |
//--------------------------------------------- |
|
385 |
//! @SYMTestCaseID MMU-T_CACHE-05 |
|
386 |
//! @SYMTestType ST |
|
387 |
//! @SYMPREQ PREQ305 |
|
388 |
//! @SYMREQ REQ5795 |
|
389 |
//! @SYMTestCaseDesc Compares different memory mappings of code. |
|
390 |
//! @SYMTestActions Runs the same performance test against code in chunks with different cache attributes. |
|
391 |
//! Also, runs the same test against code from rom.. |
|
392 |
//! @SYMTestExpectedResults KErrNone |
|
393 |
//! @SYMTestPriority Low |
|
394 |
//! @SYMTestStatus Implemented |
|
395 |
//--------------------------------------------- |
|
396 |
void Test5(TInt aSize) |
|
397 |
{ |
|
398 |
RCacheTestDevice::TChunkTest dC; |
|
399 |
dC.iSize = aSize; |
|
400 |
dC.iUseCase = 0; //not used |
|
401 |
dC.iLoops = 0; //not used |
|
402 |
TInt timeNS=0, timeS=0; |
|
403 |
||
404 |
test.Printf(_L(" Time\n")); |
|
405 |
test.Printf(_L("Mem_Type AttemptedMapAttr NotShared Shared\n")); |
|
406 |
test.Printf(_L("----------------------------------------------\n")); |
|
407 |
||
408 |
DoTest5(RCacheTestDevice::E_FullyBlocking, dC, timeNS, timeS); |
|
409 |
test.Printf(_L("FullyBlocking %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
410 |
DoTest5(RCacheTestDevice::E_Buffered_NC, dC, timeNS, timeS); |
|
411 |
test.Printf(_L("Buffered_NC %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
412 |
DoTest5(RCacheTestDevice::E_Buffered_C, dC, timeNS, timeS); |
|
413 |
test.Printf(_L("Buffered_C %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
414 |
||
415 |
||
416 |
DoTest5(RCacheTestDevice::E_InnerWT, dC, timeNS, timeS); |
|
417 |
test.Printf(_L("InnerWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
418 |
DoTest5(RCacheTestDevice::E_InnerWBRA, dC, timeNS, timeS); |
|
419 |
test.Printf(_L("InnerWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
420 |
DoTest5(RCacheTestDevice::E_InnerWB, dC, timeNS, timeS); |
|
421 |
test.Printf(_L("InnerWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
422 |
||
423 |
if(CacheInfo.iOuterCache) |
|
424 |
{ |
|
425 |
DoTest5(RCacheTestDevice::E_OuterWT, dC, timeNS, timeS); |
|
426 |
test.Printf(_L("OuterWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
427 |
DoTest5(RCacheTestDevice::E_OuterWBRA, dC, timeNS, timeS); |
|
428 |
test.Printf(_L("OuterWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
429 |
DoTest5(RCacheTestDevice::E_OuterWB, dC, timeNS, timeS); |
|
430 |
test.Printf(_L("OuterWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
431 |
||
432 |
DoTest5(RCacheTestDevice::E_InOutWT, dC, timeNS, timeS); |
|
433 |
test.Printf(_L("InOutWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
434 |
DoTest5(RCacheTestDevice::E_InOutWBRA, dC, timeNS, timeS); |
|
435 |
test.Printf(_L("InOutWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
436 |
DoTest5(RCacheTestDevice::E_InOutWB, dC, timeNS, timeS); |
|
437 |
test.Printf(_L("InOutWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
438 |
} |
|
439 |
||
440 |
||
441 |
DoTest5(RCacheTestDevice::E_StronglyOrder, dC, timeNS, timeS); |
|
442 |
test.Printf(_L("StronglyOrder %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
443 |
DoTest5(RCacheTestDevice::E_Device, dC, timeNS, timeS); |
|
444 |
test.Printf(_L("Device %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
445 |
DoTest5(RCacheTestDevice::E_Normal_Uncached, dC, timeNS, timeS); |
|
446 |
test.Printf(_L("Normal_Uncached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
447 |
DoTest5(RCacheTestDevice::E_Normal_Cached, dC, timeNS, timeS); |
|
448 |
test.Printf(_L("Normal_Cached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
449 |
||
450 |
if(CacheInfo.iMemoryRemapping) |
|
451 |
{ |
|
452 |
DoTest5(RCacheTestDevice::E_InnerWT_Remapped, dC, timeNS, timeS); |
|
453 |
test.Printf(_L("InnerWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
454 |
DoTest5(RCacheTestDevice::E_InnerWBRA_Remapped, dC, timeNS, timeS); |
|
455 |
test.Printf(_L("InnerWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
456 |
DoTest5(RCacheTestDevice::E_InnerWB_Remapped, dC, timeNS, timeS); |
|
457 |
test.Printf(_L("InnerWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
458 |
||
459 |
if(CacheInfo.iOuterCache) |
|
460 |
{ |
|
461 |
DoTest5(RCacheTestDevice::E_OuterWT_Remapped, dC, timeNS, timeS); |
|
462 |
test.Printf(_L("OuterWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
463 |
DoTest5(RCacheTestDevice::E_OuterWBRA_Remapped, dC, timeNS, timeS); |
|
464 |
test.Printf(_L("OuterWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
465 |
DoTest5(RCacheTestDevice::E_OuterWB_Remapped, dC, timeNS, timeS); |
|
466 |
test.Printf(_L("OuterWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
467 |
||
468 |
DoTest5(RCacheTestDevice::E_InOutWT_Remapped, dC, timeNS, timeS); |
|
469 |
test.Printf(_L("InOutWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
470 |
DoTest5(RCacheTestDevice::E_InOutWBRA_Remapped, dC, timeNS, timeS); |
|
471 |
test.Printf(_L("InOutWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
472 |
DoTest5(RCacheTestDevice::E_InOutWB_Remapped, dC, timeNS, timeS); |
|
473 |
test.Printf(_L("InOutWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS); |
|
474 |
} |
|
475 |
} |
|
476 |
||
477 |
//Run against kernel heap - allow the test to fail due to OOM |
|
478 |
dC.iCacheAttr = RCacheTestDevice::E_Default; |
|
479 |
TInt r = Device.TestCodeChunk(dC); |
|
480 |
if (r==KErrNone) test.Printf(_L("Run from rom ---------\t%7d\t-------\n"), dC.iTime); |
|
481 |
else if (r==KErrNoMemory) test.Printf(_L("Run from rom Cannot allocate memory\n")); |
|
482 |
else test(0);//fail |
|
483 |
||
484 |
} |
|
485 |
||
486 |
||
487 |
||
488 |
//--------------------------------------------- |
|
489 |
//! @SYMTestCaseID MMU-T_CACHE-06 |
|
490 |
//! @SYMTestType ST |
|
491 |
//! @SYMPREQ PREQ305 |
|
492 |
//! @SYMREQ REQ5795 |
|
493 |
//! @SYMTestCaseDesc Tests Write Back mode. |
|
494 |
//! @SYMTestActions The driver allocates write back chunk, write data into it and invalidate (aka purge) |
|
495 |
// the chunk from the cache. Then, it counts the number of bytes of the chunk that |
|
496 |
// reached the physical memory. |
|
497 |
//! @SYMTestExpectedResults KErrNone |
|
498 |
//! @SYMTestPriority Low |
|
499 |
//! @SYMTestStatus Implemented |
|
500 |
//--------------------------------------------- |
|
501 |
||
502 |
void Test6() |
|
503 |
{ |
|
504 |
test.Printf(_L("Test4: Testing WriteBack cache mode...\n")); |
|
505 |
RCacheTestDevice::TChunkTest dC; |
|
506 |
||
507 |
||
508 |
test.Printf(_L("Cache\tMemType\tChecking\tSize\tBytesInRAM\tVerdict\n")); |
|
509 |
test.Printf(_L("-----\t-------\t--------\t----\t----------\t-------\n")); |
|
510 |
// |
|
511 |
dC.iSize = KWriteBackTestSizeSize; |
|
512 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWBRA_Remapped; |
|
513 |
else dC.iCacheAttr = RCacheTestDevice::E_InnerWBRA; |
|
514 |
test(Device.TestWriteBackReadAllocate(dC)==KErrNone); |
|
515 |
if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Inner\tWBRA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize); |
|
516 |
else test.Printf(_L("Inner\tWBRA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize); |
|
517 |
// |
|
518 |
dC.iSize = KWriteBackTestSizeSize; |
|
519 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped; |
|
520 |
else dC.iCacheAttr = RCacheTestDevice::E_InnerWB; |
|
521 |
test(Device.TestWriteBackReadAllocate(dC)==KErrNone); |
|
522 |
if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Inner\tWBWA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize); |
|
523 |
else test.Printf(_L("Inner\tWBWA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize); |
|
524 |
// |
|
525 |
dC.iSize = KWriteBackTestSizeSize; |
|
526 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped; |
|
527 |
else dC.iCacheAttr = RCacheTestDevice::E_InnerWB; |
|
528 |
test(Device.TestWriteBackWriteAllocate(dC)==KErrNone); |
|
529 |
if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Inner\tWBWA\tWriteAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize); |
|
530 |
else test.Printf(_L("Inner\tWBWA\tWriteAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize); |
|
531 |
||
532 |
if(!CacheInfo.iOuterCache) return; |
|
533 |
||
534 |
dC.iSize = KWriteBackTestSizeSize; |
|
535 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWBRA_Remapped; |
|
536 |
else dC.iCacheAttr = RCacheTestDevice::E_OuterWBRA; |
|
537 |
test(Device.TestWriteBackReadAllocate(dC)==KErrNone); |
|
538 |
if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Outer\tWBRA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize); |
|
539 |
else test.Printf(_L("Outer\tWBRA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize); |
|
540 |
// |
|
541 |
dC.iSize = KWriteBackTestSizeSize; |
|
542 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped; |
|
543 |
else dC.iCacheAttr = RCacheTestDevice::E_OuterWB; |
|
544 |
test(Device.TestWriteBackReadAllocate(dC)==KErrNone); |
|
545 |
if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Outer\tWBWA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize); |
|
546 |
else test.Printf(_L("Outer\tWBWA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize); |
|
547 |
// |
|
548 |
dC.iSize = KWriteBackTestSizeSize; |
|
549 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped; |
|
550 |
else dC.iCacheAttr = RCacheTestDevice::E_OuterWB; |
|
551 |
test(Device.TestWriteBackWriteAllocate(dC)==KErrNone); |
|
552 |
if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Outer\tWBWA\tWriteAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize); |
|
553 |
else test.Printf(_L("Outer\tWBWA\tWriteAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize); |
|
554 |
} |
|
555 |
||
556 |
||
557 |
||
558 |
//--------------------------------------------- |
|
559 |
//! @SYMTestCaseID MMU-T_CACHE-07 |
|
560 |
//! @SYMTestType UT |
|
561 |
//! @SYMPREQ PREQ305 |
|
562 |
//! @SYMREQ REQ5795 |
|
563 |
//! @SYMTestCaseDesc Tests Cache Maintanence Functions. |
|
564 |
//! @SYMTestActions Does not do any sort of functional test. Just makes sure nothing panics. |
|
565 |
//! @SYMTestExpectedResults KErrNone |
|
566 |
//! @SYMTestPriority High |
|
567 |
//! @SYMTestStatus Implemented |
|
568 |
//--------------------------------------------- |
|
569 |
void Test7() |
|
570 |
{ |
|
571 |
test(KErrNone== Device.TestL2Maintenance()); |
|
572 |
} |
|
573 |
||
574 |
// The main function of automatic test. |
|
575 |
void AutoTestL() |
|
576 |
{ |
|
577 |
test.Start(_L("Test1: Display cache attributes:")); |
|
578 |
test.Printf(_L("Starting Driver...\n")); |
|
579 |
StartDriver(); |
|
580 |
test.Printf(_L("Getting CacheInfo...\n")); |
|
581 |
GetCacheInfo(); |
|
582 |
Test1(); |
|
583 |
||
584 |
test.Next(_L("Test2:Thresholds (hex)...")); |
|
585 |
Test2(); |
|
586 |
||
587 |
test.Next(_L("Test3:Setting Cache Thresholds...")); |
|
588 |
Test3(); |
|
589 |
||
590 |
test.Next(_L("Test4: Data chunk test...")); |
|
591 |
test.Printf(_L("chunk size=%xH \n"),KDefaultDataSize); |
|
592 |
Test4(KDefaultDataSize); |
|
593 |
||
594 |
test.Next(_L("Test5: Code chunk test...")); |
|
595 |
test.Printf(_L("chunk size=%xH \n"),KDefaultCodeSize); |
|
596 |
Test5(KDefaultCodeSize); |
|
597 |
||
598 |
test.Next(_L("Test6: Testing WriteBack cache mode...")); |
|
599 |
Test6(); |
|
600 |
||
601 |
test.Next(_L("Test7: Testing L2 cache maintenance...")); |
|
602 |
Test7(); |
|
603 |
||
604 |
StopDriver(); |
|
605 |
test.End(); |
|
606 |
} |
|
607 |
||
608 |
//////////////////////Manual tests start here/////////////////////////////// |
|
609 |
||
610 |
// Gets the size of the chunk from the command line |
|
611 |
TInt GetSizeFromCommandLine(TBuf<64>& command) |
|
612 |
{ |
|
613 |
TUint arg; |
|
614 |
TInt length = command.Length()-5; |
|
615 |
if (length <=0) |
|
616 |
return KErrArgument; |
|
617 |
TPtrC ptr = command.Mid(5,length); |
|
618 |
TLex lex(ptr); |
|
619 |
lex.Val(arg, EHex); |
|
620 |
return arg; |
|
621 |
} |
|
622 |
||
623 |
/** Invoked by "t_cache info"*/ |
|
624 |
void ManualCacheInfo() |
|
625 |
{ |
|
626 |
||
627 |
test.Start(_L("Cache Info:")); |
|
628 |
StartDriver(); |
|
629 |
GetCacheInfo(); |
|
630 |
Test1(); |
|
631 |
test.Printf(_L("Press any key...\n")); |
|
632 |
test.Getch(); |
|
633 |
StopDriver(); |
|
634 |
test.End(); |
|
635 |
return; |
|
636 |
} |
|
637 |
||
638 |
/** Invoked by "t_cache code threshold [<C> <P> <C> <F>]"*/ |
|
639 |
TInt ManualThresholds(TBuf<64>& command) |
|
640 |
{ |
|
641 |
TUint arg[4]; |
|
642 |
TInt argCurrent=0; |
|
643 |
TInt argStart = 9; //jump over "threshold" |
|
644 |
TInt argEnd; |
|
645 |
TChar c; |
|
646 |
||
647 |
test.Start(_L("Thresholds:")); |
|
648 |
StartDriver(); |
|
649 |
GetCacheInfo(); |
|
650 |
||
651 |
||
652 |
// Decode input arguments from the command line |
|
653 |
while (argCurrent<4) |
|
654 |
{ |
|
655 |
find_arg_start: |
|
656 |
if (argStart >= command.Length()) break; |
|
657 |
c = command[argStart]; |
|
658 |
if (c.IsSpace()) |
|
659 |
{ |
|
660 |
argStart++; |
|
661 |
goto find_arg_start; |
|
662 |
} |
|
663 |
||
664 |
argEnd = argStart+1; |
|
665 |
find_arg_end: |
|
666 |
if (argEnd >= command.Length()) goto get_arg; |
|
667 |
c = command[argEnd]; |
|
668 |
if (c.IsSpace()) goto get_arg; |
|
669 |
argEnd++; |
|
670 |
goto find_arg_end; |
|
671 |
||
672 |
get_arg: |
|
673 |
TPtrC ptr = command.Mid(argStart,argEnd-argStart); |
|
674 |
TLex lex(ptr); |
|
675 |
lex.Val(arg[argCurrent++], EHex); |
|
676 |
argStart=argEnd; |
|
677 |
} |
|
678 |
||
679 |
test.Printf(_L("%d argument(s) decoded\n"),argCurrent); |
|
680 |
||
681 |
RCacheTestDevice::TThresholdInfo info; |
|
682 |
||
683 |
//If te values are provided in the command line, set thresholds with the given paramaters. |
|
684 |
if (argCurrent == 4) |
|
685 |
{ |
|
686 |
test.Printf(_L("Setting thresholds: ...\n")); |
|
687 |
test.Printf(_L("Cache Type:%xh P:%xh C:%xh F:%xh\n"),arg[0], arg[1], arg[2], arg[3]); |
|
688 |
info.iCacheType=arg[0]; |
|
689 |
info.iPurge = arg[1]; |
|
690 |
info.iClean = arg[2]; |
|
691 |
info.iFlush = arg[3]; |
|
692 |
TInt r = Device.SetThreshold(info); |
|
693 |
test.Printf(_L("... returned %d\n"),r); |
|
694 |
} |
|
695 |
||
696 |
//Read thresholds from Kernel. |
|
697 |
test.Printf(_L("Reading thresholds(hex)...\n")); |
|
698 |
Test2(); |
|
699 |
||
700 |
test.Printf(_L("Press any key...\n")); |
|
701 |
test.Getch(); |
|
702 |
StopDriver(); |
|
703 |
test.End(); |
|
704 |
return 0; |
|
705 |
} |
|
706 |
||
707 |
||
708 |
/** Invoked by "t_cache data <size>"*/ |
|
709 |
void ManualDataTest(TInt aSize) |
|
710 |
{ |
|
711 |
StartDriver(); |
|
712 |
GetCacheInfo(); |
|
713 |
||
714 |
Test4(aSize); |
|
715 |
||
716 |
test.Printf(_L("Press any key...\n")); |
|
717 |
test.Getch(); |
|
718 |
StopDriver(); |
|
719 |
test.End(); |
|
720 |
} |
|
721 |
||
722 |
/** Invoked by "t_cache code <size>"*/ |
|
723 |
void ManualCodeTest(TInt aSize) |
|
724 |
{ |
|
725 |
StartDriver(); |
|
726 |
GetCacheInfo(); |
|
727 |
||
728 |
Test5(aSize); |
|
729 |
||
730 |
test.Printf(_L("Press any key...\n")); |
|
731 |
test.Getch(); |
|
732 |
StopDriver(); |
|
733 |
test.End(); |
|
734 |
} |
|
735 |
||
736 |
void DoUseCase(TInt aUseCase, TInt aMaxSize, TInt aLoops ) |
|
737 |
{ |
|
738 |
RCacheTestDevice::TChunkTest dC(aUseCase, 0x1000, aLoops); |
|
739 |
||
740 |
TInt time[5]; |
|
741 |
||
742 |
test.Printf(_L("size(H)\tloops\tNormal/NC\tNormal/WT\tFullyCached\n")); |
|
743 |
test.Printf(_L("-------\t-----\t---------\t---------\t-----------\n")); |
|
744 |
||
745 |
while (dC.iSize<=aMaxSize) |
|
746 |
{ |
|
747 |
dC.iCacheAttr = RCacheTestDevice::E_Normal_Cached; |
|
748 |
test(Device.TestUseCase(dC)==KErrNone); |
|
749 |
time[2]=dC.iTime; |
|
750 |
||
751 |
if(time[2] < 20) |
|
752 |
{dC.iLoops *=2; continue;} //Time too short. Double the loops and try the same chunk size. |
|
753 |
||
754 |
dC.iCacheAttr = RCacheTestDevice::E_Normal_Uncached; |
|
755 |
test(Device.TestUseCase(dC)==KErrNone); |
|
756 |
time[0]=dC.iTime; |
|
757 |
||
758 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InOutWT_Remapped; |
|
759 |
else dC.iCacheAttr = RCacheTestDevice::E_InOutWT; |
|
760 |
test(Device.TestUseCase(dC)==KErrNone); |
|
761 |
time[1]=dC.iTime; |
|
762 |
||
763 |
||
764 |
test.Printf(_L("%6xH\t%5d\t%9d\t%9d\t%11d\n"),dC.iSize,dC.iLoops,time[0],time[1],time[2]); |
|
765 |
||
766 |
if ((time[2] > 100) && (dC.iLoops >= 8)) |
|
767 |
dC.iLoops /=2; //Time too long. Half the loops. |
|
768 |
||
769 |
dC.iSize+=0x1000; // Next chunk size. |
|
770 |
} |
|
771 |
} |
|
772 |
||
773 |
/** Invoked by "t_cache usecase"*/ |
|
774 |
void ManualUseCase() |
|
775 |
{ |
|
776 |
test.Start(_L("Use Case manual tests")); |
|
777 |
StartDriver(); |
|
778 |
GetCacheInfo(); |
|
779 |
||
780 |
test.Printf(_L("\nUseCase: Read From Chunk\n")); |
|
781 |
DoUseCase(0,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32); |
|
782 |
||
783 |
test.Printf(_L("\nUseCase: Read From Chunk & Read From Heap\n")); |
|
784 |
DoUseCase(1,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32); |
|
785 |
||
786 |
test.Printf(_L("\nUseCase: Write To Chunk\n")); |
|
787 |
DoUseCase(2,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32); |
|
788 |
||
789 |
test.Printf(_L("\nUseCase: Write To Chunk & Read From Heap\n")); |
|
790 |
DoUseCase(3,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32); |
|
791 |
||
792 |
||
793 |
test.Printf(_L("Press any key...\n")); |
|
794 |
test.Getch(); |
|
795 |
StopDriver(); |
|
796 |
test.End(); |
|
797 |
} |
|
798 |
||
799 |
||
800 |
// Invoked by "t_cache data+<size_hex>" |
|
801 |
void ManualDataTestIncremental(TInt aIncrement) |
|
802 |
{ |
|
803 |
TInt time[4]; |
|
804 |
TInt r = KErrNone; |
|
805 |
TInt size = aIncrement; |
|
806 |
RCacheTestDevice::TChunkTest dC; |
|
807 |
||
808 |
StartDriver(); |
|
809 |
GetCacheInfo(); |
|
810 |
||
811 |
test.Printf(_L("Chunk\t\tTime(KernelTicks):\n")); |
|
812 |
test.Printf(_L("Size(KB)\tUnCached\tInner\tOuter\tIn&Out\n")); |
|
813 |
||
814 |
while(size < KMaxChunkSize) |
|
815 |
{ |
|
816 |
dC.iSize = size; |
|
817 |
||
818 |
dC.iCacheAttr = RCacheTestDevice::E_Buffered_C; |
|
819 |
r = Device.TestDataChunk(dC); |
|
820 |
if (r!=KErrNone) break; |
|
821 |
time[0] = dC.iTime; |
|
822 |
||
823 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped; |
|
824 |
else dC.iCacheAttr = RCacheTestDevice::E_InnerWB; |
|
825 |
r = Device.TestDataChunk(dC); |
|
826 |
if (r!=KErrNone) break; |
|
827 |
time[1] = dC.iTime; |
|
828 |
||
829 |
if(CacheInfo.iOuterCache) |
|
830 |
{ |
|
831 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped; |
|
832 |
else dC.iCacheAttr = RCacheTestDevice::E_OuterWB; |
|
833 |
r = Device.TestDataChunk(dC); |
|
834 |
if (r!=KErrNone) break; |
|
835 |
time[2] = dC.iTime; |
|
836 |
||
837 |
dC.iCacheAttr = RCacheTestDevice::E_InOutWB; |
|
838 |
r = Device.TestDataChunk(dC); |
|
839 |
if (r!=KErrNone) break; |
|
840 |
time[3] = dC.iTime; |
|
841 |
} |
|
842 |
else |
|
843 |
{ |
|
844 |
time[2]= time[3]=0; |
|
845 |
} |
|
846 |
test.Printf(_L("%d\t%d\t%d\t%d\t%d\n"),size/0x400, time[0],time[1],time[2],time[3]); |
|
847 |
size += aIncrement; |
|
848 |
} |
|
849 |
||
850 |
test.Printf(_L("The test exited with %d\n"), r); |
|
851 |
test.Printf(_L("Press any key...\n")); |
|
852 |
test.Getch(); |
|
853 |
StopDriver(); |
|
854 |
test.End(); |
|
855 |
} |
|
856 |
||
857 |
// Invoked by "t_cache code+<size_hex>" |
|
858 |
void ManualCodeTestIncremental(TInt aIncrement) |
|
859 |
{ |
|
860 |
TInt time[4]; |
|
861 |
TInt r = KErrNone; |
|
862 |
TInt size = aIncrement; |
|
863 |
RCacheTestDevice::TChunkTest dC; |
|
864 |
||
865 |
StartDriver(); |
|
866 |
GetCacheInfo(); |
|
867 |
||
868 |
test.Printf(_L("Chunk\t\tTime(KernelTicks):\n")); |
|
869 |
test.Printf(_L("Size(KB)\tUnCached\tInner\tOuter\tIn&Out\n")); |
|
870 |
||
871 |
while(size < KMaxChunkSize) |
|
872 |
{ |
|
873 |
TempBuff.SetLength(0); |
|
874 |
||
875 |
dC.iSize = size; |
|
876 |
||
877 |
dC.iCacheAttr = RCacheTestDevice::E_Buffered_C; |
|
878 |
r = Device.TestCodeChunk(dC); |
|
879 |
if (r!=KErrNone) break; |
|
880 |
time[0] = dC.iTime; |
|
881 |
||
882 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped; |
|
883 |
else dC.iCacheAttr = RCacheTestDevice::E_InnerWB; |
|
884 |
r = Device.TestCodeChunk(dC); |
|
885 |
if (r!=KErrNone) break; |
|
886 |
time[1] = dC.iTime; |
|
887 |
||
888 |
if(CacheInfo.iOuterCache) |
|
889 |
{ |
|
890 |
if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped; |
|
891 |
else dC.iCacheAttr = RCacheTestDevice::E_OuterWB; |
|
892 |
r = Device.TestCodeChunk(dC); |
|
893 |
if (r!=KErrNone) break; |
|
894 |
time[2] = dC.iTime; |
|
895 |
// |
|
896 |
dC.iCacheAttr = RCacheTestDevice::E_InOutWB; |
|
897 |
r = Device.TestCodeChunk(dC); |
|
898 |
if (r!=KErrNone) break; |
|
899 |
time[3] = dC.iTime; |
|
900 |
} |
|
901 |
else |
|
902 |
{ |
|
903 |
time[2]=time[3] = 0; |
|
904 |
} |
|
905 |
||
906 |
test.Printf(_L("%d\t%d\t%d\t%d\t%d\n"),size/0x400, time[0],time[1],time[2],time[3]); |
|
907 |
size += aIncrement; |
|
908 |
} |
|
909 |
||
910 |
test.Printf(_L("The test exited with %d\n"), r); |
|
911 |
test.Printf(_L("Press any key...\n")); |
|
912 |
test.Getch(); |
|
913 |
StopDriver(); |
|
914 |
test.End(); |
|
915 |
} |
|
916 |
||
917 |
TInt E32Main() |
|
918 |
{ |
|
919 |
||
920 |
TBuf<64> c; |
|
921 |
TInt size; |
|
922 |
User::CommandLine(c); |
|
923 |
if (c.FindF(KPrintCacheInfos) >= 0) {ManualCacheInfo(); return 0;} |
|
924 |
if (c.FindF(KUseCase) >= 0) {ManualUseCase(); return 0;} |
|
925 |
if (c.FindF(KThreshold) >= 0) {ManualThresholds(c); return 0;} |
|
926 |
||
927 |
if (c.FindF(KTestData) >= 0) |
|
928 |
{ |
|
929 |
test.Start(_L("Data Chunk")); |
|
930 |
size = GetSizeFromCommandLine(c); |
|
931 |
// Always round up the size to 1K boundary (because of DataSegmetTestFunct) |
|
932 |
size +=0x3ff; size &=~0x3ff; |
|
933 |
||
934 |
if (c.FindF(KIncremental) >= 0) |
|
935 |
{ |
|
936 |
// Invoked by "t_cache data+<size>" |
|
937 |
test.Printf(_L(" size + %xH\n"),size); |
|
938 |
if (size<=0) |
|
939 |
return KErrArgument; |
|
940 |
ManualDataTestIncremental(size); |
|
941 |
} |
|
942 |
else |
|
943 |
{ |
|
944 |
// Invoked by "t_cache data <size>" |
|
945 |
test.Printf(_L("chunk size %xH\n"),size); |
|
946 |
if (size<=0) |
|
947 |
return KErrArgument; |
|
948 |
ManualDataTest(size); |
|
949 |
} |
|
950 |
return 0; |
|
951 |
} |
|
952 |
||
953 |
if (c.FindF(KTestCode) >= 0) |
|
954 |
{ |
|
955 |
test.Start(_L("Code Chunk")); |
|
956 |
size = GetSizeFromCommandLine(c); |
|
957 |
// Always round up the size to 1K boundary |
|
958 |
size +=0x3ff; size &=~0x3ff; |
|
959 |
if (c.FindF(KIncremental) >= 0) |
|
960 |
{ |
|
961 |
// Invoked by "t_cache code+<size>" |
|
962 |
test.Printf(_L(" size + %xH\n"),size); |
|
963 |
if (size<=0) |
|
964 |
return KErrArgument; |
|
965 |
ManualCodeTestIncremental(size); |
|
966 |
} |
|
967 |
else |
|
968 |
{ |
|
969 |
// Invoked by "t_cache code <size>" |
|
970 |
test.Printf(_L("chunk size %xH\n"),size); |
|
971 |
if (size<=0) |
|
972 |
return KErrArgument; |
|
973 |
ManualCodeTest(size); |
|
974 |
} |
|
975 |
return 0; |
|
976 |
} |
|
977 |
||
978 |
if (c.FindF(KHelp) >= 0) |
|
979 |
{ |
|
980 |
// Invoked by "t_cache help" |
|
981 |
test.Start(_L("t_cache usage:\n")); |
|
982 |
test.Printf(_L("t_cache info\n")); |
|
983 |
test.Printf(_L("t_cache data <size_hex>\n")); |
|
984 |
test.Printf(_L("t_cache code <size_hex>\n")); |
|
985 |
test.Printf(_L("t_cache data+<size_hex>\n")); |
|
986 |
test.Printf(_L("t_cache code+<size_hex>\n")); |
|
987 |
test.Printf(_L("t_cache usecase\n\n")); |
|
988 |
test.Printf(_L("t_cache threshold [<cache> <purge> <clean> <flush>]\n\n")); |
|
989 |
test.Printf(_L("... where <cache>= 1,2,4,8 or 10\n\n")); |
|
990 |
test.Printf(_L("Press any key...\n")); |
|
991 |
test.Getch(); |
|
992 |
test.End(); |
|
993 |
return 0; |
|
994 |
} |
|
995 |
||
996 |
||
997 |
// auto test starts here |
|
998 |
CTrapCleanup* trap = CTrapCleanup::New(); |
|
999 |
if (!trap) |
|
1000 |
return KErrNoMemory; |
|
1001 |
test.Title(); |
|
1002 |
__UHEAP_MARK; |
|
1003 |
TRAPD(r,AutoTestL()); |
|
1004 |
__UHEAP_MARKEND; |
|
1005 |
delete trap; |
|
1006 |
return r; |
|
1007 |
} |