1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/mmu/t_cache.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1008 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\debug\t_cache.cpp
1.18 +// Overview:
1.19 +// Performs cache checking in order to ensure it is running correctly.
1.20 +// Runs automatically or as manual test. (Type "t_cache help" for details.)
1.21 +// API Information:
1.22 +// class Cache
1.23 +// class L2Cache
1.24 +// Details:
1.25 +// -Test1 - Displays cache properties.
1.26 +// -Test2 - Gets thresholds.
1.27 +// -Test3 - Sets thresholds.
1.28 +// -Test4 - Compares different memory mappings of data.
1.29 +// -Test5 - Compares different memory mappings of code.
1.30 +// -Test6 - Tests Write Back mode.
1.31 +// -Test7 - Tests cache maintenance functions
1.32 +// It can also perform more specified tests if run manually:
1.33 +// - t_cache info Test1 only
1.34 +// - t_cache data <size_hex> Runs data chunk test (Test 4) with specified chunk size. For example,
1.35 +// "t_cache data 10000" will run data chunk test against 64KB chunk.
1.36 +// - t_cache code <size_hex> Runs code chunk test (Test 5) for specified chink size. For example,
1.37 +// "t_cache code 10000" will run code chunk test against 64KB chunk.
1.38 +// - t_cache data+<size_hex> Runs data chunk test for specified set of chunk sizes. For example,
1.39 +// "t_cache data+1000" will perform data chunk test for sizes 4K, 8K,... up to 512K.
1.40 +// - t_cache code+<size_hex> Runs code chunk test for specified set of sizes. For example,
1.41 +// "t_cache code+1000" will perform code chunk test for sizes 4K, 8K,... up to 512K.
1.42 +// - t_cache threshold Diplays thresholds for all caches on the platform.
1.43 +// - t_cache threshold T P C H Sets new values for cache thresholds:
1.44 +// - "T" specifies the type of cache to whose threshould are to be chenged:
1.45 +// 1 for Instruction (or Unified) Cache.
1.46 +// 2 for Data Cache (for ARMv7 and later, this is Point-of-Coherency threshold.
1.47 +// 4 for XScale AltData Cache.
1.48 +// 8 for Point-of-Unification Data Cache Threshold for ARMv7 and later platforms.
1.49 +// 10 for L2 (L210 or XScale L2 cache)
1.50 +// - "P" "C" & "H" are hex values for purge, clean & flush thresholds.
1.51 +// For example: "t_cache 1 10000 10000 10000" sets 64KB for all thresholds in Instruction Cache.
1.52 +// - t_cache usecase Runs particular use case tests.
1.53 +// - t_cache help Displays the list of manual commands.
1.54 +// Platforms/Drives/Compatibility:
1.55 +// Hardware - ARM only (Manual). Not supported on emulator.
1.56 +// Assumptions/Requirement/Pre-requisites:
1.57 +// Failures and causes:
1.58 +// Base Port information:
1.59 +// d_cache.mmp to be built from the baseport.
1.60 +//
1.61 +//
1.62 +
1.63 +#include <e32test.h>
1.64 +#include "d_cache.h"
1.65 +
1.66 +//------------globals---------------------
1.67 +LOCAL_D RTest test(_L("T_CACHE"));
1.68 +_LIT(KPrintCacheInfos,"info");
1.69 +_LIT(KTestData,"data");
1.70 +_LIT(KTestCode,"code");
1.71 +_LIT(KHelp,"help");
1.72 +_LIT(KThreshold,"threshold");
1.73 +_LIT(KIncremental,"+");
1.74 +_LIT(KUseCase,"usecase");
1.75 +
1.76 +RCacheTestDevice Device;
1.77 +RCacheTestDevice::TCacheInfo CacheInfo;
1.78 +TBuf<KCacheDescSize> TempBuff;
1.79 +
1.80 +const TInt KDefaultDataSize = 0x20000;
1.81 +const TInt KDefaultCodeSize = 0x804; //2K+4. Should be <= TestCodeFuncSize(). Otherwise, code test won't run against rom image.
1.82 +const TInt KMaxChunkSize = 0x80000; //512KB Incremental tests limit
1.83 +const TInt KWriteBackTestSizeSize = 0x4000; // Shouldn't go over cache thresholds (where purge becomes flush).
1.84 +
1.85 +extern void DataSegmetTestFunct(void* aBase, TInt aSize);
1.86 +
1.87 +/** Loads & opens LDD.*/
1.88 +void StartDriver()
1.89 + {
1.90 + TInt r = User::LoadLogicalDevice(KCacheTestDriverName);
1.91 + test( r==KErrNone || r==KErrAlreadyExists);
1.92 + if((r = Device.Open())!=KErrNone)
1.93 + {
1.94 + User::FreeLogicalDevice(KCacheTestDriverName);
1.95 + test.Printf(_L("Could not open LDD"));
1.96 + test(0);
1.97 + }
1.98 + }
1.99 +
1.100 +/** Closes and unloads LDD.*/
1.101 +void StopDriver()
1.102 + {
1.103 + Device.Close();
1.104 + User::FreeLogicalDevice(KCacheTestDriverName);
1.105 + }
1.106 +
1.107 +/** Get cache info from device driver. This will update CacheInfo global variable.*/
1.108 +void GetCacheInfo()
1.109 + {
1.110 + TInt r = Device.GetCacheInfo(CacheInfo);
1.111 + test(r==KErrNone);
1.112 + }
1.113 +
1.114 +//---------------------------------------------
1.115 +//! @SYMTestCaseID MMU-T_CACHE-01
1.116 +//! @SYMTestType ST
1.117 +//! @SYMPREQ PREQ305
1.118 +//! @SYMREQ REQ5795
1.119 +//! @SYMTestCaseDesc Displays cache properties.
1.120 +//! @SYMTestExpectedResults KErrNone
1.121 +//! @SYMTestPriority Low
1.122 +//! @SYMTestStatus Implemented
1.123 +//---------------------------------------------
1.124 +void Test1()
1.125 + {
1.126 + TInt i;
1.127 +
1.128 + test.Printf(_L("General Info:\n"));
1.129 + TPtr ptr = CacheInfo.iDesc.Expand();
1.130 + test.Printf(ptr);
1.131 + test.Printf(_L("CacheCount:%d, MaxCacheSize:%xH, MemoryRemapping:%d, OuterCache:%d\n"),CacheInfo.iCacheCount, CacheInfo.iMaxCacheSize, CacheInfo.iMemoryRemapping, CacheInfo.iOuterCache);
1.132 + test.Printf(_L("DMAMemoryAlignement:%d\n"),CacheInfo.iDmaBufferAlignment);
1.133 +
1.134 +
1.135 + test.Printf(_L("Per Level Info:\n"));
1.136 + test.Printf(_L("Level\tData\tInstr\tSize(b)\tLine(b)\tWays\tSets\tDescription\n"));
1.137 +
1.138 + for (i = 0; i<CacheInfo.iCacheCount; i++)
1.139 + {
1.140 + TempBuff.SetLength(0);
1.141 + RCacheTestDevice::TCacheSingle& cs = CacheInfo.iCache[i];
1.142 + 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);
1.143 + ptr = cs.iDesc.Expand();
1.144 + TempBuff.Append(ptr);
1.145 + TempBuff.Append(_L("\n"));
1.146 + test.Printf(TempBuff);
1.147 + }
1.148 + }
1.149 +
1.150 +//---------------------------------------------
1.151 +//! @SYMTestCaseID MMU-T_CACHE-02
1.152 +//! @SYMTestType ST
1.153 +//! @SYMPREQ PREQ1068
1.154 +//! @SYMREQ REQ5909
1.155 +//! @SYMTestCaseDesc Gets thresholds.
1.156 +//! @SYMTestActions Fetches Cache Thresholds from the driver.
1.157 +//! @SYMTestExpectedResults KErrNone
1.158 +//! @SYMTestPriority High
1.159 +//! @SYMTestStatus Implemented
1.160 +//---------------------------------------------
1.161 +void Test2()
1.162 + {
1.163 + RCacheTestDevice::TThresholdInfo info;
1.164 +
1.165 + test.Printf(_L("Cache: Purge Clear Flush\n"));
1.166 +
1.167 + info.iCacheType=1;
1.168 + if (KErrNone == Device.GetThreshold(info))
1.169 + test.Printf(_L("Instr:%6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush);
1.170 +
1.171 + info.iCacheType=2;
1.172 + if (KErrNone == Device.GetThreshold(info))
1.173 + test.Printf(_L("Data: %6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush);
1.174 +
1.175 + info.iCacheType=4;
1.176 + if (KErrNone == Device.GetThreshold(info))
1.177 + test.Printf(_L("AltD: %6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush);
1.178 +
1.179 + info.iCacheType=8;
1.180 + if (KErrNone == Device.GetThreshold(info))
1.181 + test.Printf(_L("D_IMB:%6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush);
1.182 +
1.183 + info.iCacheType=16;
1.184 + if (KErrNone == Device.GetThreshold(info))
1.185 + test.Printf(_L("L2: %6x %6x %6x\n"),info.iPurge,info.iClean,info.iFlush);
1.186 + }
1.187 +
1.188 +//---------------------------------------------
1.189 +//! @SYMTestCaseID MMU-T_CACHE-03
1.190 +//! @SYMTestType ST
1.191 +//! @SYMPREQ PREQ1068
1.192 +//! @SYMREQ REQ5909
1.193 +//! @SYMTestCaseDesc Sets thresholds.
1.194 +//! @SYMTestActions Sets new values forr Cache Thresholds. Then, sets back the old values.
1.195 +//! @SYMTestExpectedResults KErrNone
1.196 +//! @SYMTestPriority High
1.197 +//! @SYMTestStatus Implemented
1.198 +//---------------------------------------------
1.199 +void Test3()
1.200 + {
1.201 + TInt i, tested=0;
1.202 + RCacheTestDevice::TThresholdInfo info[5]; //for 5 types og cache
1.203 + TInt returned[5];
1.204 +
1.205 +
1.206 + //Get the old values
1.207 + for (i=0;i<5;i++)
1.208 + {
1.209 + info[i].iCacheType= 1<<i;
1.210 + returned[i] = Device.GetThreshold(info[i]);
1.211 + }
1.212 +
1.213 + //Double them all
1.214 + for (i=0;i<5;i++)
1.215 + {
1.216 + if (returned[i] != KErrNone) continue; //not a valid cache type for running platform
1.217 + tested++;
1.218 + info[i].iPurge <<=1;
1.219 + info[i].iClean <<=1;
1.220 + info[i].iFlush <<=1;
1.221 + test(KErrNone==Device.SetThreshold(info[i]));
1.222 + }
1.223 +
1.224 + //Put back the old values
1.225 + for (i=0;i<5;i++)
1.226 + {
1.227 + if (returned[i] != KErrNone) continue; //not a valid cache type for running platform
1.228 + info[i].iPurge >>=1;
1.229 + info[i].iClean >>=1;
1.230 + info[i].iFlush >>=1;
1.231 + test(KErrNone==Device.SetThreshold(info[i]));
1.232 + }
1.233 + test.Printf(_L(" ... %d caches present & tested\n"), tested);
1.234 + }
1.235 +
1.236 +
1.237 +
1.238 +void DoTest4(RCacheTestDevice::TCacheAttr aCacheAttr, RCacheTestDevice::TChunkTest& aDC, TInt& aTime1, TInt& aTime2)
1.239 + {
1.240 + aDC.iCacheAttr = aCacheAttr;
1.241 +
1.242 + aDC.iShared = EFalse;
1.243 + test(KErrNone==Device.TestDataChunk(aDC));
1.244 + aTime1 = aDC.iTime;
1.245 +
1.246 + aDC.iShared = ETrue;
1.247 + test(KErrNone==Device.TestDataChunk(aDC));
1.248 + aTime2 = aDC.iTime;
1.249 + }
1.250 +//---------------------------------------------
1.251 +//! @SYMTestCaseID MMU-T_CACHE-04
1.252 +//! @SYMTestType ST
1.253 +//! @SYMPREQ PREQ305
1.254 +//! @SYMREQ REQ5795
1.255 +//! @SYMTestCaseDesc Compares different memory mappings of data.
1.256 +//! @SYMTestActions Runs the same performance test against data in the chunks with different cache attributes.
1.257 +//! Also, runs the same test against data from user & kernel heaps.
1.258 +//! @SYMTestExpectedResults KErrNone
1.259 +//! @SYMTestPriority Low
1.260 +//! @SYMTestStatus Implemented
1.261 +//---------------------------------------------
1.262 +void Test4(TInt aSize)
1.263 + {
1.264 + RCacheTestDevice::TChunkTest dC;
1.265 + dC.iSize = aSize;
1.266 + dC.iUseCase = 0; //not used
1.267 + dC.iLoops = 0; //not used
1.268 + TInt timeNS=0, timeS=0;
1.269 +
1.270 + test.Printf(_L(" Time\n"));
1.271 + test.Printf(_L("Mem_Type ActualMapAttr NotShared Shared\n"));
1.272 + test.Printf(_L("----------------------------------------------\n"));
1.273 +
1.274 + DoTest4(RCacheTestDevice::E_FullyBlocking, dC, timeNS, timeS);
1.275 + test.Printf(_L("FullyBlocking %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.276 + DoTest4(RCacheTestDevice::E_Buffered_NC, dC, timeNS, timeS);
1.277 + test.Printf(_L("Buffered_NC %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.278 + DoTest4(RCacheTestDevice::E_Buffered_C, dC, timeNS, timeS);
1.279 + test.Printf(_L("Buffered_C %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.280 +
1.281 +
1.282 + DoTest4(RCacheTestDevice::E_InnerWT, dC, timeNS, timeS);
1.283 + test.Printf(_L("InnerWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.284 + DoTest4(RCacheTestDevice::E_InnerWBRA, dC, timeNS, timeS);
1.285 + test.Printf(_L("InnerWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.286 + DoTest4(RCacheTestDevice::E_InnerWB, dC, timeNS, timeS);
1.287 + test.Printf(_L("InnerWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.288 +
1.289 + if(CacheInfo.iOuterCache)
1.290 + {
1.291 + DoTest4(RCacheTestDevice::E_OuterWT, dC, timeNS, timeS);
1.292 + test.Printf(_L("OuterWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.293 + DoTest4(RCacheTestDevice::E_OuterWBRA, dC, timeNS, timeS);
1.294 + test.Printf(_L("OuterWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.295 + DoTest4(RCacheTestDevice::E_OuterWB, dC, timeNS, timeS);
1.296 + test.Printf(_L("OuterWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.297 +
1.298 + DoTest4(RCacheTestDevice::E_InOutWT, dC, timeNS, timeS);
1.299 + test.Printf(_L("InOutWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.300 + DoTest4(RCacheTestDevice::E_InOutWBRA, dC, timeNS, timeS);
1.301 + test.Printf(_L("InOutWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.302 + DoTest4(RCacheTestDevice::E_InOutWB, dC, timeNS, timeS);
1.303 + test.Printf(_L("InOutWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.304 + }
1.305 +
1.306 +
1.307 + DoTest4(RCacheTestDevice::E_StronglyOrder, dC, timeNS, timeS);
1.308 + test.Printf(_L("StronglyOrder %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.309 + DoTest4(RCacheTestDevice::E_Device, dC, timeNS, timeS);
1.310 + test.Printf(_L("Device %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.311 + DoTest4(RCacheTestDevice::E_Normal_Uncached, dC, timeNS, timeS);
1.312 + test.Printf(_L("Normal_Uncached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.313 + DoTest4(RCacheTestDevice::E_Normal_Cached, dC, timeNS, timeS);
1.314 + test.Printf(_L("Normal_Cached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.315 +
1.316 + if(CacheInfo.iMemoryRemapping)
1.317 + {
1.318 + DoTest4(RCacheTestDevice::E_KernelInternal4, dC, timeNS, timeS);
1.319 + test.Printf(_L("KernelInternal4 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.320 + DoTest4(RCacheTestDevice::E_PlatformSpecific5, dC, timeNS, timeS);
1.321 + test.Printf(_L("PlatSpecific5 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.322 + DoTest4(RCacheTestDevice::E_PlatformSpecific6, dC, timeNS, timeS);
1.323 + test.Printf(_L("PlatSpecific6 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.324 + DoTest4(RCacheTestDevice::E_PlatformSpecific7, dC, timeNS, timeS);
1.325 + test.Printf(_L("PlatSpecific7 %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.326 +
1.327 +
1.328 + DoTest4(RCacheTestDevice::E_InnerWT_Remapped, dC, timeNS, timeS);
1.329 + test.Printf(_L("InnerWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.330 + DoTest4(RCacheTestDevice::E_InnerWBRA_Remapped, dC, timeNS, timeS);
1.331 + test.Printf(_L("InnerWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.332 + DoTest4(RCacheTestDevice::E_InnerWB_Remapped, dC, timeNS, timeS);
1.333 + test.Printf(_L("InnerWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.334 +
1.335 + if(CacheInfo.iOuterCache)
1.336 + {
1.337 + DoTest4(RCacheTestDevice::E_OuterWT_Remapped, dC, timeNS, timeS);
1.338 + test.Printf(_L("OuterWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.339 + DoTest4(RCacheTestDevice::E_OuterWBRA_Remapped, dC, timeNS, timeS);
1.340 + test.Printf(_L("OuterWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.341 + DoTest4(RCacheTestDevice::E_OuterWB_Remapped, dC, timeNS, timeS);
1.342 + test.Printf(_L("OuterWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.343 +
1.344 + DoTest4(RCacheTestDevice::E_InOutWT_Remapped, dC, timeNS, timeS);
1.345 + test.Printf(_L("InOutWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.346 + DoTest4(RCacheTestDevice::E_InOutWBRA_Remapped, dC, timeNS, timeS);
1.347 + test.Printf(_L("InOutWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.348 + DoTest4(RCacheTestDevice::E_InOutWB_Remapped, dC, timeNS, timeS);
1.349 + test.Printf(_L("InOutWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.350 + }
1.351 + }
1.352 +
1.353 + //Run against kernel heap - allow the test to fail due to OOM
1.354 + dC.iCacheAttr = RCacheTestDevice::E_Default;
1.355 + TInt r = Device.TestDataChunk(dC);
1.356 + if (r==KErrNone) test.Printf(_L("Kernel Heap ---------\t%7d\t-------\n"), dC.iTime);
1.357 + else if (r==KErrNoMemory) test.Printf(_L("Kernel Heap Cannot allocate memory\n"));
1.358 + else test(0);//fail
1.359 +
1.360 + //Run against user heap - allow the test to fail due to OOM
1.361 + void* buffer = User::Alloc(dC.iSize);
1.362 + if (buffer == NULL)
1.363 + {
1.364 + test.Printf(_L("User Heap Cannot allocate memory\n"));
1.365 + return;
1.366 + }
1.367 + TInt time = User::NTickCount();
1.368 + DataSegmetTestFunct(buffer , dC.iSize);
1.369 + time = User::NTickCount() - time;
1.370 + User::Free(buffer);
1.371 + test.Printf(_L("User Heap ---------\t%7d\t-------\n"), time);
1.372 +
1.373 + }
1.374 +
1.375 +
1.376 +void DoTest5(RCacheTestDevice::TCacheAttr aCacheAttr, RCacheTestDevice::TChunkTest& aDC, TInt& aTime1, TInt& aTime2)
1.377 + {
1.378 + aDC.iCacheAttr = aCacheAttr;
1.379 +
1.380 + aDC.iShared = EFalse;
1.381 + test(KErrNone==Device.TestCodeChunk(aDC));
1.382 + aTime1 = aDC.iTime;
1.383 +
1.384 + aDC.iShared = ETrue;
1.385 + test(KErrNone==Device.TestCodeChunk(aDC));
1.386 + aTime2 = aDC.iTime;
1.387 + }
1.388 +//---------------------------------------------
1.389 +//! @SYMTestCaseID MMU-T_CACHE-05
1.390 +//! @SYMTestType ST
1.391 +//! @SYMPREQ PREQ305
1.392 +//! @SYMREQ REQ5795
1.393 +//! @SYMTestCaseDesc Compares different memory mappings of code.
1.394 +//! @SYMTestActions Runs the same performance test against code in chunks with different cache attributes.
1.395 +//! Also, runs the same test against code from rom..
1.396 +//! @SYMTestExpectedResults KErrNone
1.397 +//! @SYMTestPriority Low
1.398 +//! @SYMTestStatus Implemented
1.399 +//---------------------------------------------
1.400 +void Test5(TInt aSize)
1.401 + {
1.402 + RCacheTestDevice::TChunkTest dC;
1.403 + dC.iSize = aSize;
1.404 + dC.iUseCase = 0; //not used
1.405 + dC.iLoops = 0; //not used
1.406 + TInt timeNS=0, timeS=0;
1.407 +
1.408 + test.Printf(_L(" Time\n"));
1.409 + test.Printf(_L("Mem_Type AttemptedMapAttr NotShared Shared\n"));
1.410 + test.Printf(_L("----------------------------------------------\n"));
1.411 +
1.412 + DoTest5(RCacheTestDevice::E_FullyBlocking, dC, timeNS, timeS);
1.413 + test.Printf(_L("FullyBlocking %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.414 + DoTest5(RCacheTestDevice::E_Buffered_NC, dC, timeNS, timeS);
1.415 + test.Printf(_L("Buffered_NC %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.416 + DoTest5(RCacheTestDevice::E_Buffered_C, dC, timeNS, timeS);
1.417 + test.Printf(_L("Buffered_C %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.418 +
1.419 +
1.420 + DoTest5(RCacheTestDevice::E_InnerWT, dC, timeNS, timeS);
1.421 + test.Printf(_L("InnerWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.422 + DoTest5(RCacheTestDevice::E_InnerWBRA, dC, timeNS, timeS);
1.423 + test.Printf(_L("InnerWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.424 + DoTest5(RCacheTestDevice::E_InnerWB, dC, timeNS, timeS);
1.425 + test.Printf(_L("InnerWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.426 +
1.427 + if(CacheInfo.iOuterCache)
1.428 + {
1.429 + DoTest5(RCacheTestDevice::E_OuterWT, dC, timeNS, timeS);
1.430 + test.Printf(_L("OuterWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.431 + DoTest5(RCacheTestDevice::E_OuterWBRA, dC, timeNS, timeS);
1.432 + test.Printf(_L("OuterWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.433 + DoTest5(RCacheTestDevice::E_OuterWB, dC, timeNS, timeS);
1.434 + test.Printf(_L("OuterWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.435 +
1.436 + DoTest5(RCacheTestDevice::E_InOutWT, dC, timeNS, timeS);
1.437 + test.Printf(_L("InOutWT %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.438 + DoTest5(RCacheTestDevice::E_InOutWBRA, dC, timeNS, timeS);
1.439 + test.Printf(_L("InOutWBRA %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.440 + DoTest5(RCacheTestDevice::E_InOutWB, dC, timeNS, timeS);
1.441 + test.Printf(_L("InOutWB %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.442 + }
1.443 +
1.444 +
1.445 + DoTest5(RCacheTestDevice::E_StronglyOrder, dC, timeNS, timeS);
1.446 + test.Printf(_L("StronglyOrder %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.447 + DoTest5(RCacheTestDevice::E_Device, dC, timeNS, timeS);
1.448 + test.Printf(_L("Device %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.449 + DoTest5(RCacheTestDevice::E_Normal_Uncached, dC, timeNS, timeS);
1.450 + test.Printf(_L("Normal_Uncached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.451 + DoTest5(RCacheTestDevice::E_Normal_Cached, dC, timeNS, timeS);
1.452 + test.Printf(_L("Normal_Cached %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.453 +
1.454 + if(CacheInfo.iMemoryRemapping)
1.455 + {
1.456 + DoTest5(RCacheTestDevice::E_InnerWT_Remapped, dC, timeNS, timeS);
1.457 + test.Printf(_L("InnerWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.458 + DoTest5(RCacheTestDevice::E_InnerWBRA_Remapped, dC, timeNS, timeS);
1.459 + test.Printf(_L("InnerWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.460 + DoTest5(RCacheTestDevice::E_InnerWB_Remapped, dC, timeNS, timeS);
1.461 + test.Printf(_L("InnerWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.462 +
1.463 + if(CacheInfo.iOuterCache)
1.464 + {
1.465 + DoTest5(RCacheTestDevice::E_OuterWT_Remapped, dC, timeNS, timeS);
1.466 + test.Printf(_L("OuterWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.467 + DoTest5(RCacheTestDevice::E_OuterWBRA_Remapped, dC, timeNS, timeS);
1.468 + test.Printf(_L("OuterWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.469 + DoTest5(RCacheTestDevice::E_OuterWB_Remapped, dC, timeNS, timeS);
1.470 + test.Printf(_L("OuterWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.471 +
1.472 + DoTest5(RCacheTestDevice::E_InOutWT_Remapped, dC, timeNS, timeS);
1.473 + test.Printf(_L("InOutWT_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.474 + DoTest5(RCacheTestDevice::E_InOutWBRA_Remapped, dC, timeNS, timeS);
1.475 + test.Printf(_L("InOutWBRA_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.476 + DoTest5(RCacheTestDevice::E_InOutWB_Remapped, dC, timeNS, timeS);
1.477 + test.Printf(_L("InOutWB_Remap %08xH\t%7d\t%7d\n"),dC.iActualMapAttr, timeNS, timeS);
1.478 + }
1.479 + }
1.480 +
1.481 + //Run against kernel heap - allow the test to fail due to OOM
1.482 + dC.iCacheAttr = RCacheTestDevice::E_Default;
1.483 + TInt r = Device.TestCodeChunk(dC);
1.484 + if (r==KErrNone) test.Printf(_L("Run from rom ---------\t%7d\t-------\n"), dC.iTime);
1.485 + else if (r==KErrNoMemory) test.Printf(_L("Run from rom Cannot allocate memory\n"));
1.486 + else test(0);//fail
1.487 +
1.488 + }
1.489 +
1.490 +
1.491 +
1.492 +//---------------------------------------------
1.493 +//! @SYMTestCaseID MMU-T_CACHE-06
1.494 +//! @SYMTestType ST
1.495 +//! @SYMPREQ PREQ305
1.496 +//! @SYMREQ REQ5795
1.497 +//! @SYMTestCaseDesc Tests Write Back mode.
1.498 +//! @SYMTestActions The driver allocates write back chunk, write data into it and invalidate (aka purge)
1.499 +// the chunk from the cache. Then, it counts the number of bytes of the chunk that
1.500 +// reached the physical memory.
1.501 +//! @SYMTestExpectedResults KErrNone
1.502 +//! @SYMTestPriority Low
1.503 +//! @SYMTestStatus Implemented
1.504 +//---------------------------------------------
1.505 +
1.506 +void Test6()
1.507 + {
1.508 + test.Printf(_L("Test4: Testing WriteBack cache mode...\n"));
1.509 + RCacheTestDevice::TChunkTest dC;
1.510 +
1.511 +
1.512 + test.Printf(_L("Cache\tMemType\tChecking\tSize\tBytesInRAM\tVerdict\n"));
1.513 + test.Printf(_L("-----\t-------\t--------\t----\t----------\t-------\n"));
1.514 +//
1.515 + dC.iSize = KWriteBackTestSizeSize;
1.516 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWBRA_Remapped;
1.517 + else dC.iCacheAttr = RCacheTestDevice::E_InnerWBRA;
1.518 + test(Device.TestWriteBackReadAllocate(dC)==KErrNone);
1.519 + if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Inner\tWBRA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize);
1.520 + else test.Printf(_L("Inner\tWBRA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize);
1.521 +//
1.522 + dC.iSize = KWriteBackTestSizeSize;
1.523 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped;
1.524 + else dC.iCacheAttr = RCacheTestDevice::E_InnerWB;
1.525 + test(Device.TestWriteBackReadAllocate(dC)==KErrNone);
1.526 + if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Inner\tWBWA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize);
1.527 + else test.Printf(_L("Inner\tWBWA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize);
1.528 +//
1.529 + dC.iSize = KWriteBackTestSizeSize;
1.530 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped;
1.531 + else dC.iCacheAttr = RCacheTestDevice::E_InnerWB;
1.532 + test(Device.TestWriteBackWriteAllocate(dC)==KErrNone);
1.533 + if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Inner\tWBWA\tWriteAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize);
1.534 + else test.Printf(_L("Inner\tWBWA\tWriteAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize);
1.535 +
1.536 + if(!CacheInfo.iOuterCache) return;
1.537 +
1.538 + dC.iSize = KWriteBackTestSizeSize;
1.539 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWBRA_Remapped;
1.540 + else dC.iCacheAttr = RCacheTestDevice::E_OuterWBRA;
1.541 + test(Device.TestWriteBackReadAllocate(dC)==KErrNone);
1.542 + if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Outer\tWBRA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize);
1.543 + else test.Printf(_L("Outer\tWBRA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize);
1.544 +//
1.545 + dC.iSize = KWriteBackTestSizeSize;
1.546 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped;
1.547 + else dC.iCacheAttr = RCacheTestDevice::E_OuterWB;
1.548 + test(Device.TestWriteBackReadAllocate(dC)==KErrNone);
1.549 + if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Outer\tWBWA\tReadAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize);
1.550 + else test.Printf(_L("Outer\tWBWA\tReadAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize);
1.551 +//
1.552 + dC.iSize = KWriteBackTestSizeSize;
1.553 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped;
1.554 + else dC.iCacheAttr = RCacheTestDevice::E_OuterWB;
1.555 + test(Device.TestWriteBackWriteAllocate(dC)==KErrNone);
1.556 + if (dC.iSize<KWriteBackTestSizeSize)test.Printf(_L("Outer\tWBWA\tWriteAlloc\t%xH\t%xH\tOK\n"), KWriteBackTestSizeSize, dC.iSize);
1.557 + else test.Printf(_L("Outer\tWBWA\tWriteAlloc\t%xH\t%xH\tWarning: Didn't pass\n"), KWriteBackTestSizeSize, dC.iSize);
1.558 + }
1.559 +
1.560 +
1.561 +
1.562 +//---------------------------------------------
1.563 +//! @SYMTestCaseID MMU-T_CACHE-07
1.564 +//! @SYMTestType UT
1.565 +//! @SYMPREQ PREQ305
1.566 +//! @SYMREQ REQ5795
1.567 +//! @SYMTestCaseDesc Tests Cache Maintanence Functions.
1.568 +//! @SYMTestActions Does not do any sort of functional test. Just makes sure nothing panics.
1.569 +//! @SYMTestExpectedResults KErrNone
1.570 +//! @SYMTestPriority High
1.571 +//! @SYMTestStatus Implemented
1.572 +//---------------------------------------------
1.573 +void Test7()
1.574 + {
1.575 + test(KErrNone== Device.TestL2Maintenance());
1.576 + }
1.577 +
1.578 +// The main function of automatic test.
1.579 +void AutoTestL()
1.580 + {
1.581 + test.Start(_L("Test1: Display cache attributes:"));
1.582 + test.Printf(_L("Starting Driver...\n"));
1.583 + StartDriver();
1.584 + test.Printf(_L("Getting CacheInfo...\n"));
1.585 + GetCacheInfo();
1.586 + Test1();
1.587 +
1.588 + test.Next(_L("Test2:Thresholds (hex)..."));
1.589 + Test2();
1.590 +
1.591 + test.Next(_L("Test3:Setting Cache Thresholds..."));
1.592 + Test3();
1.593 +
1.594 + test.Next(_L("Test4: Data chunk test..."));
1.595 + test.Printf(_L("chunk size=%xH \n"),KDefaultDataSize);
1.596 + Test4(KDefaultDataSize);
1.597 +
1.598 + test.Next(_L("Test5: Code chunk test..."));
1.599 + test.Printf(_L("chunk size=%xH \n"),KDefaultCodeSize);
1.600 + Test5(KDefaultCodeSize);
1.601 +
1.602 + test.Next(_L("Test6: Testing WriteBack cache mode..."));
1.603 + Test6();
1.604 +
1.605 + test.Next(_L("Test7: Testing L2 cache maintenance..."));
1.606 + Test7();
1.607 +
1.608 + StopDriver();
1.609 + test.End();
1.610 + }
1.611 +
1.612 +//////////////////////Manual tests start here///////////////////////////////
1.613 +
1.614 +// Gets the size of the chunk from the command line
1.615 +TInt GetSizeFromCommandLine(TBuf<64>& command)
1.616 + {
1.617 + TUint arg;
1.618 + TInt length = command.Length()-5;
1.619 + if (length <=0)
1.620 + return KErrArgument;
1.621 + TPtrC ptr = command.Mid(5,length);
1.622 + TLex lex(ptr);
1.623 + lex.Val(arg, EHex);
1.624 + return arg;
1.625 + }
1.626 +
1.627 +/** Invoked by "t_cache info"*/
1.628 +void ManualCacheInfo()
1.629 + {
1.630 +
1.631 + test.Start(_L("Cache Info:"));
1.632 + StartDriver();
1.633 + GetCacheInfo();
1.634 + Test1();
1.635 + test.Printf(_L("Press any key...\n"));
1.636 + test.Getch();
1.637 + StopDriver();
1.638 + test.End();
1.639 + return;
1.640 + }
1.641 +
1.642 +/** Invoked by "t_cache code threshold [<C> <P> <C> <F>]"*/
1.643 +TInt ManualThresholds(TBuf<64>& command)
1.644 + {
1.645 + TUint arg[4];
1.646 + TInt argCurrent=0;
1.647 + TInt argStart = 9; //jump over "threshold"
1.648 + TInt argEnd;
1.649 + TChar c;
1.650 +
1.651 + test.Start(_L("Thresholds:"));
1.652 + StartDriver();
1.653 + GetCacheInfo();
1.654 +
1.655 +
1.656 + // Decode input arguments from the command line
1.657 + while (argCurrent<4)
1.658 + {
1.659 + find_arg_start:
1.660 + if (argStart >= command.Length()) break;
1.661 + c = command[argStart];
1.662 + if (c.IsSpace())
1.663 + {
1.664 + argStart++;
1.665 + goto find_arg_start;
1.666 + }
1.667 +
1.668 + argEnd = argStart+1;
1.669 + find_arg_end:
1.670 + if (argEnd >= command.Length()) goto get_arg;
1.671 + c = command[argEnd];
1.672 + if (c.IsSpace()) goto get_arg;
1.673 + argEnd++;
1.674 + goto find_arg_end;
1.675 +
1.676 + get_arg:
1.677 + TPtrC ptr = command.Mid(argStart,argEnd-argStart);
1.678 + TLex lex(ptr);
1.679 + lex.Val(arg[argCurrent++], EHex);
1.680 + argStart=argEnd;
1.681 + }
1.682 +
1.683 + test.Printf(_L("%d argument(s) decoded\n"),argCurrent);
1.684 +
1.685 + RCacheTestDevice::TThresholdInfo info;
1.686 +
1.687 + //If te values are provided in the command line, set thresholds with the given paramaters.
1.688 + if (argCurrent == 4)
1.689 + {
1.690 + test.Printf(_L("Setting thresholds: ...\n"));
1.691 + test.Printf(_L("Cache Type:%xh P:%xh C:%xh F:%xh\n"),arg[0], arg[1], arg[2], arg[3]);
1.692 + info.iCacheType=arg[0];
1.693 + info.iPurge = arg[1];
1.694 + info.iClean = arg[2];
1.695 + info.iFlush = arg[3];
1.696 + TInt r = Device.SetThreshold(info);
1.697 + test.Printf(_L("... returned %d\n"),r);
1.698 + }
1.699 +
1.700 + //Read thresholds from Kernel.
1.701 + test.Printf(_L("Reading thresholds(hex)...\n"));
1.702 + Test2();
1.703 +
1.704 + test.Printf(_L("Press any key...\n"));
1.705 + test.Getch();
1.706 + StopDriver();
1.707 + test.End();
1.708 + return 0;
1.709 + }
1.710 +
1.711 +
1.712 +/** Invoked by "t_cache data <size>"*/
1.713 +void ManualDataTest(TInt aSize)
1.714 + {
1.715 + StartDriver();
1.716 + GetCacheInfo();
1.717 +
1.718 + Test4(aSize);
1.719 +
1.720 + test.Printf(_L("Press any key...\n"));
1.721 + test.Getch();
1.722 + StopDriver();
1.723 + test.End();
1.724 + }
1.725 +
1.726 +/** Invoked by "t_cache code <size>"*/
1.727 +void ManualCodeTest(TInt aSize)
1.728 + {
1.729 + StartDriver();
1.730 + GetCacheInfo();
1.731 +
1.732 + Test5(aSize);
1.733 +
1.734 + test.Printf(_L("Press any key...\n"));
1.735 + test.Getch();
1.736 + StopDriver();
1.737 + test.End();
1.738 + }
1.739 +
1.740 +void DoUseCase(TInt aUseCase, TInt aMaxSize, TInt aLoops )
1.741 + {
1.742 + RCacheTestDevice::TChunkTest dC(aUseCase, 0x1000, aLoops);
1.743 +
1.744 + TInt time[5];
1.745 +
1.746 + test.Printf(_L("size(H)\tloops\tNormal/NC\tNormal/WT\tFullyCached\n"));
1.747 + test.Printf(_L("-------\t-----\t---------\t---------\t-----------\n"));
1.748 +
1.749 + while (dC.iSize<=aMaxSize)
1.750 + {
1.751 + dC.iCacheAttr = RCacheTestDevice::E_Normal_Cached;
1.752 + test(Device.TestUseCase(dC)==KErrNone);
1.753 + time[2]=dC.iTime;
1.754 +
1.755 + if(time[2] < 20)
1.756 + {dC.iLoops *=2; continue;} //Time too short. Double the loops and try the same chunk size.
1.757 +
1.758 + dC.iCacheAttr = RCacheTestDevice::E_Normal_Uncached;
1.759 + test(Device.TestUseCase(dC)==KErrNone);
1.760 + time[0]=dC.iTime;
1.761 +
1.762 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InOutWT_Remapped;
1.763 + else dC.iCacheAttr = RCacheTestDevice::E_InOutWT;
1.764 + test(Device.TestUseCase(dC)==KErrNone);
1.765 + time[1]=dC.iTime;
1.766 +
1.767 +
1.768 + test.Printf(_L("%6xH\t%5d\t%9d\t%9d\t%11d\n"),dC.iSize,dC.iLoops,time[0],time[1],time[2]);
1.769 +
1.770 + if ((time[2] > 100) && (dC.iLoops >= 8))
1.771 + dC.iLoops /=2; //Time too long. Half the loops.
1.772 +
1.773 + dC.iSize+=0x1000; // Next chunk size.
1.774 + }
1.775 + }
1.776 +
1.777 +/** Invoked by "t_cache usecase"*/
1.778 +void ManualUseCase()
1.779 + {
1.780 + test.Start(_L("Use Case manual tests"));
1.781 + StartDriver();
1.782 + GetCacheInfo();
1.783 +
1.784 + test.Printf(_L("\nUseCase: Read From Chunk\n"));
1.785 + DoUseCase(0,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32);
1.786 +
1.787 + test.Printf(_L("\nUseCase: Read From Chunk & Read From Heap\n"));
1.788 + DoUseCase(1,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32);
1.789 +
1.790 + test.Printf(_L("\nUseCase: Write To Chunk\n"));
1.791 + DoUseCase(2,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32);
1.792 +
1.793 + test.Printf(_L("\nUseCase: Write To Chunk & Read From Heap\n"));
1.794 + DoUseCase(3,Min(CacheInfo.iMaxCacheSize*4, 0x40000),32);
1.795 +
1.796 +
1.797 + test.Printf(_L("Press any key...\n"));
1.798 + test.Getch();
1.799 + StopDriver();
1.800 + test.End();
1.801 + }
1.802 +
1.803 +
1.804 +// Invoked by "t_cache data+<size_hex>"
1.805 +void ManualDataTestIncremental(TInt aIncrement)
1.806 + {
1.807 + TInt time[4];
1.808 + TInt r = KErrNone;
1.809 + TInt size = aIncrement;
1.810 + RCacheTestDevice::TChunkTest dC;
1.811 +
1.812 + StartDriver();
1.813 + GetCacheInfo();
1.814 +
1.815 + test.Printf(_L("Chunk\t\tTime(KernelTicks):\n"));
1.816 + test.Printf(_L("Size(KB)\tUnCached\tInner\tOuter\tIn&Out\n"));
1.817 +
1.818 + while(size < KMaxChunkSize)
1.819 + {
1.820 + dC.iSize = size;
1.821 +
1.822 + dC.iCacheAttr = RCacheTestDevice::E_Buffered_C;
1.823 + r = Device.TestDataChunk(dC);
1.824 + if (r!=KErrNone) break;
1.825 + time[0] = dC.iTime;
1.826 +
1.827 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped;
1.828 + else dC.iCacheAttr = RCacheTestDevice::E_InnerWB;
1.829 + r = Device.TestDataChunk(dC);
1.830 + if (r!=KErrNone) break;
1.831 + time[1] = dC.iTime;
1.832 +
1.833 + if(CacheInfo.iOuterCache)
1.834 + {
1.835 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped;
1.836 + else dC.iCacheAttr = RCacheTestDevice::E_OuterWB;
1.837 + r = Device.TestDataChunk(dC);
1.838 + if (r!=KErrNone) break;
1.839 + time[2] = dC.iTime;
1.840 +
1.841 + dC.iCacheAttr = RCacheTestDevice::E_InOutWB;
1.842 + r = Device.TestDataChunk(dC);
1.843 + if (r!=KErrNone) break;
1.844 + time[3] = dC.iTime;
1.845 + }
1.846 + else
1.847 + {
1.848 + time[2]= time[3]=0;
1.849 + }
1.850 + test.Printf(_L("%d\t%d\t%d\t%d\t%d\n"),size/0x400, time[0],time[1],time[2],time[3]);
1.851 + size += aIncrement;
1.852 + }
1.853 +
1.854 + test.Printf(_L("The test exited with %d\n"), r);
1.855 + test.Printf(_L("Press any key...\n"));
1.856 + test.Getch();
1.857 + StopDriver();
1.858 + test.End();
1.859 + }
1.860 +
1.861 +// Invoked by "t_cache code+<size_hex>"
1.862 +void ManualCodeTestIncremental(TInt aIncrement)
1.863 + {
1.864 + TInt time[4];
1.865 + TInt r = KErrNone;
1.866 + TInt size = aIncrement;
1.867 + RCacheTestDevice::TChunkTest dC;
1.868 +
1.869 + StartDriver();
1.870 + GetCacheInfo();
1.871 +
1.872 + test.Printf(_L("Chunk\t\tTime(KernelTicks):\n"));
1.873 + test.Printf(_L("Size(KB)\tUnCached\tInner\tOuter\tIn&Out\n"));
1.874 +
1.875 + while(size < KMaxChunkSize)
1.876 + {
1.877 + TempBuff.SetLength(0);
1.878 +
1.879 + dC.iSize = size;
1.880 +
1.881 + dC.iCacheAttr = RCacheTestDevice::E_Buffered_C;
1.882 + r = Device.TestCodeChunk(dC);
1.883 + if (r!=KErrNone) break;
1.884 + time[0] = dC.iTime;
1.885 +
1.886 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_InnerWB_Remapped;
1.887 + else dC.iCacheAttr = RCacheTestDevice::E_InnerWB;
1.888 + r = Device.TestCodeChunk(dC);
1.889 + if (r!=KErrNone) break;
1.890 + time[1] = dC.iTime;
1.891 +
1.892 + if(CacheInfo.iOuterCache)
1.893 + {
1.894 + if(CacheInfo.iMemoryRemapping) dC.iCacheAttr = RCacheTestDevice::E_OuterWB_Remapped;
1.895 + else dC.iCacheAttr = RCacheTestDevice::E_OuterWB;
1.896 + r = Device.TestCodeChunk(dC);
1.897 + if (r!=KErrNone) break;
1.898 + time[2] = dC.iTime;
1.899 + //
1.900 + dC.iCacheAttr = RCacheTestDevice::E_InOutWB;
1.901 + r = Device.TestCodeChunk(dC);
1.902 + if (r!=KErrNone) break;
1.903 + time[3] = dC.iTime;
1.904 + }
1.905 + else
1.906 + {
1.907 + time[2]=time[3] = 0;
1.908 + }
1.909 +
1.910 + test.Printf(_L("%d\t%d\t%d\t%d\t%d\n"),size/0x400, time[0],time[1],time[2],time[3]);
1.911 + size += aIncrement;
1.912 + }
1.913 +
1.914 + test.Printf(_L("The test exited with %d\n"), r);
1.915 + test.Printf(_L("Press any key...\n"));
1.916 + test.Getch();
1.917 + StopDriver();
1.918 + test.End();
1.919 + }
1.920 +
1.921 +TInt E32Main()
1.922 + {
1.923 +
1.924 + TBuf<64> c;
1.925 + TInt size;
1.926 + User::CommandLine(c);
1.927 + if (c.FindF(KPrintCacheInfos) >= 0) {ManualCacheInfo(); return 0;}
1.928 + if (c.FindF(KUseCase) >= 0) {ManualUseCase(); return 0;}
1.929 + if (c.FindF(KThreshold) >= 0) {ManualThresholds(c); return 0;}
1.930 +
1.931 + if (c.FindF(KTestData) >= 0)
1.932 + {
1.933 + test.Start(_L("Data Chunk"));
1.934 + size = GetSizeFromCommandLine(c);
1.935 + // Always round up the size to 1K boundary (because of DataSegmetTestFunct)
1.936 + size +=0x3ff; size &=~0x3ff;
1.937 +
1.938 + if (c.FindF(KIncremental) >= 0)
1.939 + {
1.940 + // Invoked by "t_cache data+<size>"
1.941 + test.Printf(_L(" size + %xH\n"),size);
1.942 + if (size<=0)
1.943 + return KErrArgument;
1.944 + ManualDataTestIncremental(size);
1.945 + }
1.946 + else
1.947 + {
1.948 + // Invoked by "t_cache data <size>"
1.949 + test.Printf(_L("chunk size %xH\n"),size);
1.950 + if (size<=0)
1.951 + return KErrArgument;
1.952 + ManualDataTest(size);
1.953 + }
1.954 + return 0;
1.955 + }
1.956 +
1.957 + if (c.FindF(KTestCode) >= 0)
1.958 + {
1.959 + test.Start(_L("Code Chunk"));
1.960 + size = GetSizeFromCommandLine(c);
1.961 + // Always round up the size to 1K boundary
1.962 + size +=0x3ff; size &=~0x3ff;
1.963 + if (c.FindF(KIncremental) >= 0)
1.964 + {
1.965 + // Invoked by "t_cache code+<size>"
1.966 + test.Printf(_L(" size + %xH\n"),size);
1.967 + if (size<=0)
1.968 + return KErrArgument;
1.969 + ManualCodeTestIncremental(size);
1.970 + }
1.971 + else
1.972 + {
1.973 + // Invoked by "t_cache code <size>"
1.974 + test.Printf(_L("chunk size %xH\n"),size);
1.975 + if (size<=0)
1.976 + return KErrArgument;
1.977 + ManualCodeTest(size);
1.978 + }
1.979 + return 0;
1.980 + }
1.981 +
1.982 + if (c.FindF(KHelp) >= 0)
1.983 + {
1.984 + // Invoked by "t_cache help"
1.985 + test.Start(_L("t_cache usage:\n"));
1.986 + test.Printf(_L("t_cache info\n"));
1.987 + test.Printf(_L("t_cache data <size_hex>\n"));
1.988 + test.Printf(_L("t_cache code <size_hex>\n"));
1.989 + test.Printf(_L("t_cache data+<size_hex>\n"));
1.990 + test.Printf(_L("t_cache code+<size_hex>\n"));
1.991 + test.Printf(_L("t_cache usecase\n\n"));
1.992 + test.Printf(_L("t_cache threshold [<cache> <purge> <clean> <flush>]\n\n"));
1.993 + test.Printf(_L("... where <cache>= 1,2,4,8 or 10\n\n"));
1.994 + test.Printf(_L("Press any key...\n"));
1.995 + test.Getch();
1.996 + test.End();
1.997 + return 0;
1.998 + }
1.999 +
1.1000 +
1.1001 + // auto test starts here
1.1002 + CTrapCleanup* trap = CTrapCleanup::New();
1.1003 + if (!trap)
1.1004 + return KErrNoMemory;
1.1005 + test.Title();
1.1006 + __UHEAP_MARK;
1.1007 + TRAPD(r,AutoTestL());
1.1008 + __UHEAP_MARKEND;
1.1009 + delete trap;
1.1010 + return r;
1.1011 + }