Update contrib.
1 // Copyright (c) 2007-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\pccd\t_nandbm.cpp
15 // Test read/write performance for NAND drives accessed directly
16 // through the Local Media Sub-System
17 // When no command parameter is supplied search for first
18 // writeable NAND drive that can be found
19 // If a drive number parameter in the range 0 - F is provided,
20 // interpret this as a local drive number in the range 0 - 15
21 // and test the drive if it is a writeable NAND drive
22 // Please note that local drive numbers at the Local Media Sub-System
23 // level are not the same as drive numbers / drive letters at the
24 // File Server level. File Server drive numbers / drive letters fall
25 // in the range 0 - 25 / a - z. The mapping between local drive numbers
26 // and File Server drive numbers / drive letters is defined in
27 // estart.txt or its equivalent
28 // Use TBusLocalDrive directly and bypass the File Server
29 // Fill NAND user data drive with data prior to executing actual
30 // performance tests. TBusLocalDrive should read from areas that have
31 // been written to and are therefore assigned. Where areas are
32 // unassigned, XSR FTL returns FFs without accessing the NAND flash
33 // hardware. This type of behaviour generates misleadingly quick
34 // performance figures
35 // Test various block sizes in the range 16 - 65536 bytes
47 LOCAL_D TBuf<1048576> DataBuf;
48 LOCAL_D TBusLocalDrive TheDrive;
49 LOCAL_D TBool ChangedFlag;
52 RTest test(_L("Local NAND Drive BenchMark Test"));
54 LOCAL_C void DoRead(TInt aReadBlockSize)
59 TInt msgHandle = KLocalMessageHandle;
60 TLocalDriveCapsV2 info;
61 TPckg<TLocalDriveCapsV2> infoPckg(info);
63 TheDrive.Caps(infoPckg);
64 maxSize=I64LOW(info.iSize);
70 TRequestStatus reqStat;
71 timer.After(reqStat,10000000); // After 10 secs
72 while(reqStat==KRequestPending)
74 if (TheDrive.Read(pos,aReadBlockSize,&DataBuf,msgHandle,0)==KErrNone)
79 if (pos>=(maxSize-aReadBlockSize))
82 #if defined (__WINS__)
83 test.Printf(_L("Read %d %d byte blocks in 10 secs\n"),count,aReadBlockSize);
86 TReal32 rate=((TReal32)(count*aReadBlockSize))/10240.0F;
88 buf.Format(_L("Read %d %d byte blocks in 10 secs ("),count,aReadBlockSize);
89 buf.AppendNum(rate,rf);
90 buf.Append(_L("Kb/s)\n"));
93 test.Printf(_L("Errors:%d\n"),err);
96 LOCAL_C void DoWrite(TInt aWriteBlockSize)
101 TInt msgHandle = KLocalMessageHandle;
102 TLocalDriveCapsV2 info;
103 TPckg<TLocalDriveCapsV2> infoPckg(info);
105 TheDrive.Caps(infoPckg);
106 maxSize=I64LOW(info.iSize);
112 TRequestStatus reqStat;
113 timer.After(reqStat,10000000); // After 10 secs
114 while(reqStat==KRequestPending)
116 if (TheDrive.Write(pos,aWriteBlockSize,&DataBuf,msgHandle,0)==KErrNone)
120 pos+=aWriteBlockSize;
121 if (pos>=(maxSize-aWriteBlockSize))
124 #if defined (__WINS__)
125 test.Printf(_L("Write %d %d byte blocks in 10 secs\n"),count,aWriteBlockSize);
128 TReal32 rate=((TReal32)(count*aWriteBlockSize))/10240.0F;
129 TRealFormat rf(10,2);
130 buf.Format(_L("Write %d %d byte blocks in 10 secs ("),count,aWriteBlockSize);
131 buf.AppendNum(rate,rf);
132 buf.Append(_L("Kb/s)\n"));
135 test.Printf(_L("Errors:%d\n"),err);
138 GLDEF_C TInt E32Main()
143 User::CommandLine(cmd); // put command line into decriptor
145 TPtrC param=lex.NextToken(); // point token at local drive number if any
146 test.Printf(_L("Local Drive = %S\r\n"),¶m);
150 TBusLocalDrive drive;
152 TLocalDriveCapsV4 driveCaps;
153 TPckg<TLocalDriveCapsV4> capsPckg(driveCaps);
156 if (param.Length()==0)
158 // locate writeable NAND drive
159 for (localDrvNum=0; localDrvNum<KMaxLocalDrives; localDrvNum++)
162 r = drive.Connect(localDrvNum,changeFlag);
167 r = drive.Caps(capsPckg);
170 &&(driveCaps.iType==EMediaNANDFlash)
171 &&!(driveCaps.iMediaAtt&KMediaAttWriteProtected)
172 &&(driveCaps.iPartitionType!=KPartitionTypeSymbianCrashLog))
177 test.Printf(_L("Suitable drive could not be found\r\n"));
178 test.Printf(_L("Writeable NAND drive required for test\r\n"));
184 // is selected local drive number in the range 0-15
186 localDrv.UpperCase();
187 if (localDrv>='0'&&localDrv<='9')
189 localDrvNum=((TInt)localDrv-'0');
191 else if (localDrv>='A'&&localDrv<='F')
193 localDrvNum=((TInt)localDrv-'A'+10);
197 test.Printf(_L("Commandline %S invalid\r\n"), &cmd);
198 test.Printf(_L("Usage:\r\n"));
199 test.Printf(_L("t_nandbm with no arguments, test first suitable NAND drive \r\n"));
200 test.Printf(_L("t_nandbm x, where x = 0-F test local drive number 0-15\r\n"));
203 // is selected drive suitable for test
204 r = drive.Connect(localDrvNum,changeFlag);
207 test.Printf(_L("Can't connect to drive %d\r\n"), localDrvNum);
210 r = drive.Caps(capsPckg);
213 test.Printf(_L("Drive %d caps method error\r\n"), localDrvNum);
217 if ((driveCaps.iType!=EMediaNANDFlash)
218 ||(driveCaps.iMediaAtt&KMediaAttWriteProtected)
219 ||(driveCaps.iPartitionType==KPartitionTypeSymbianCrashLog))
221 test.Printf(_L("Drive %d has unsuitable capabilities\r\n"), localDrvNum);
222 test.Printf(_L("Writeable NAND drive required for test\r\n"));
228 // Fill the nand user data drive with data so TBusLocalDrive reads
229 // from areas that have been written to and are therefore assigned.
230 // Where areas are unassigned, XSR FTL returns FFs without accessing
231 // the NAND flash hardware. This type of behaviour generates misleadingly
232 // quick performance figures.
233 TInt writesize=1048576;
235 TInt msgHandle = KLocalMessageHandle;
237 TheDrive.Connect(localDrvNum,ChangedFlag);
238 test.Printf( _L("Fill up NAND drive %d\r\n"),localDrvNum);
241 test.Printf( _L("%d byte write to pos %d of NAND drive\r\n"),writesize,pos);
242 if (TheDrive.Write(pos,writesize,&DataBuf,msgHandle,0)!=KErrNone)
252 test.Start(_L("Start Benchmarking ..."));