Update contrib.
1 // Copyright (c) 2005-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\lffs\t_lfsdrvbm.cpp
22 #include "..\misc\prbs.h"
25 LOCAL_D TBuf<16384> DataBuf;
26 LOCAL_D TBusLocalDrive TheDrive;
27 LOCAL_D TBool ChangedFlag;
29 const TInt KBufferSize=4096;
30 const TInt KBigBufferSize=4096*4;
31 TUint8 Buffer[KBigBufferSize];
34 #define LFFS_PDD_NAME _L("MEDLFS")
37 RTest test(_L("LFFS Driver BenchMark Test"));
39 LOCAL_C void DoRead(TInt aReadBlockSize)
44 TInt msgHandle = KLocalMessageHandle;
45 TLocalDriveCapsV7 info;
46 TPckg<TLocalDriveCapsV7> capsPckg(info);
47 TheDrive.Caps(capsPckg);
49 maxSize=I64LOW(info.iSize);
55 TRequestStatus reqStat;
56 timer.After(reqStat,10000000); // After 10 secs
57 while(reqStat==KRequestPending)
59 if (TheDrive.Read(pos,aReadBlockSize,&DataBuf,msgHandle,0)==KErrNone)
64 if (pos>=(maxSize-aReadBlockSize))
67 #if defined (__WINS__)
68 test.Printf(_L("Read %d %d byte blocks in 10 secs\n"),count,aReadBlockSize);
71 TReal32 rate=((TReal32)(count*aReadBlockSize))/10240.0F;
73 buf.Format(_L("Read %d %d byte blocks in 10 secs ("),count,aReadBlockSize);
74 buf.AppendNum(rate,rf);
75 buf.Append(_L("Kb/s)\n"));
78 test.Printf(_L("Errors:%d\n"),err);
81 LOCAL_C void DoWrite(TInt aWriteBlockSize)
86 TLocalDriveCapsV7 info;
87 TPckg<TLocalDriveCapsV7> capsPckg(info);
88 TheDrive.Caps(capsPckg);
90 maxSize=I64LOW(info.iSize);
95 // Erase the first 16 blocks to ensure write completes OK
96 TUint32 EbSz=(TInt)info.iEraseBlockSize;
98 for (pos=0; pos<16*EbSz; pos+=EbSz)
100 TInt64 pos64 = MAKE_TINT64(0, pos);
101 r=TheDrive.Format(pos64,EbSz);
108 TRequestStatus reqStat;
109 TPtrC8 ptr(Buffer,aWriteBlockSize);
110 timer.After(reqStat,10000000); // After 10 secs
111 while(reqStat==KRequestPending)
113 TInt64 pos64 = MAKE_TINT64(0, pos);
114 TInt r=TheDrive.Write(pos64,ptr);
119 pos+=aWriteBlockSize;
120 if ((TInt)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);
139 GLDEF_C TInt E32Main()
144 TDriveInfoV1Buf diBuf;
145 UserHal::DriveInfo(diBuf);
146 TDriveInfoV1 &di=diBuf();
150 test.Printf(_L("DRIVES PRESENT :%d\r\n"),di.iTotalSupportedDrives);
151 test.Printf(_L("C:(1ST) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[0]);
152 test.Printf(_L("D:(2ND) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[1]);
153 test.Printf(_L("E:(3RD) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[2]);
154 test.Printf(_L("F:(4TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[3]);
155 test.Printf(_L("G:(5TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[4]);
156 test.Printf(_L("H:(6TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[5]);
157 test.Printf(_L("I:(7TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[6]);
158 test.Printf(_L("J:(8TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[7]);
159 test.Printf(_L("K:(9TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[8]);
161 test.Printf(_L("Select Local Drive (C-%c):\r\n"),'C'+ 8);
165 c=(TUint)test.Getch();
168 if (drv>=0&&drv<='C'+ 8)
172 r=User::LoadPhysicalDevice(LFFS_PDD_NAME);
173 test(r==KErrNone || r==KErrAlreadyExists);
176 b.Format(_L("Connect to drive %c:"),'C'+drv);
178 TheDrive.Connect(drv,ChangedFlag);
180 TLocalDriveCapsV7 info;
181 TPckg<TLocalDriveCapsV7> capsPckg(info);
182 TheDrive.Caps(capsPckg);
184 test.Start(_L("Starting write tests\n"));
186 // Full buffer write test - pre-load the buffer and write
187 TUint32* pB=(TUint32*)(Buffer);
188 TUint32* pE=(TUint32*)(Buffer+KBufferSize);
195 pB=(TUint32*)(Buffer);
196 if(info.iWriteBufferSize)
197 DoWrite(info.iWriteBufferSize);
200 // Get the current time
201 TInt64 zeroTime=MAKE_TINT64(0, 0);
202 TTime TheTimer=TTime(zeroTime);
204 // Invoke the erase sequuence
206 // Report the time interval
207 TInt64 currentTime=TheTimer.Int64();
208 test.Printf(_L("currentTime now = %d\n"),(TInt)currentTime);
210 currentTime=TheTimer.Int64();
211 test.Printf(_L("currentTime now = %d\n"),(TInt)currentTime);
213 currentTime=TheTimer.Int64();
214 test.Printf(_L("currentTime now = %d\n"),(TInt)currentTime);
217 if ((info.iWriteBufferSize)<1024)
219 these tests would cause errors on M18 Intel Strataflash. this type
220 of Strataflash operates in object and control mode. when writing 16
221 byte blocks the first write puts puts each M18 1024 byte programming
222 region into control mode so that all susequent even numbered writes
223 succeed but all subsequent odd numbered writes fail (in control
224 mode writes to bytes 16 - 31, 48 - 63 aren't allowed). successes match
225 failures. when writing 256 byte blocks only 1 in 4 writes succeeds -
226 the first write in each programming region succeeds and puts the
227 region into object mode so that the subsequent three writes to the
228 same programming region fail (in object mode a programming region may
229 only be written to once). when writing 512 byte blocks 1 in 2 writes
230 fail with the first write to each programming region succeeding and the
231 second failing. with 513 byte writes the analysis is slightly more
232 complex than with 512 byte writes but the failure rate of 1 in 2 still