sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\lffs\t_lfsdrvbm.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <e32svr.h>
|
sl@0
|
20 |
#include <e32hal.h>
|
sl@0
|
21 |
#include <e32uid.h>
|
sl@0
|
22 |
#include "..\misc\prbs.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
LOCAL_D TBuf<16384> DataBuf;
|
sl@0
|
26 |
LOCAL_D TBusLocalDrive TheDrive;
|
sl@0
|
27 |
LOCAL_D TBool ChangedFlag;
|
sl@0
|
28 |
|
sl@0
|
29 |
const TInt KBufferSize=4096;
|
sl@0
|
30 |
const TInt KBigBufferSize=4096*4;
|
sl@0
|
31 |
TUint8 Buffer[KBigBufferSize];
|
sl@0
|
32 |
|
sl@0
|
33 |
|
sl@0
|
34 |
#define LFFS_PDD_NAME _L("MEDLFS")
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
RTest test(_L("LFFS Driver BenchMark Test"));
|
sl@0
|
38 |
|
sl@0
|
39 |
LOCAL_C void DoRead(TInt aReadBlockSize)
|
sl@0
|
40 |
//
|
sl@0
|
41 |
// Do Read benchmark
|
sl@0
|
42 |
//
|
sl@0
|
43 |
{
|
sl@0
|
44 |
TInt msgHandle = KLocalMessageHandle;
|
sl@0
|
45 |
TLocalDriveCapsV7 info;
|
sl@0
|
46 |
TPckg<TLocalDriveCapsV7> capsPckg(info);
|
sl@0
|
47 |
TheDrive.Caps(capsPckg);
|
sl@0
|
48 |
TInt maxSize;
|
sl@0
|
49 |
maxSize=I64LOW(info.iSize);
|
sl@0
|
50 |
TInt count,pos,err;
|
sl@0
|
51 |
count=pos=err=0;
|
sl@0
|
52 |
|
sl@0
|
53 |
RTimer timer;
|
sl@0
|
54 |
timer.CreateLocal();
|
sl@0
|
55 |
TRequestStatus reqStat;
|
sl@0
|
56 |
timer.After(reqStat,10000000); // After 10 secs
|
sl@0
|
57 |
while(reqStat==KRequestPending)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
if (TheDrive.Read(pos,aReadBlockSize,&DataBuf,msgHandle,0)==KErrNone)
|
sl@0
|
60 |
count++;
|
sl@0
|
61 |
else
|
sl@0
|
62 |
err++;
|
sl@0
|
63 |
pos+=aReadBlockSize;
|
sl@0
|
64 |
if (pos>=(maxSize-aReadBlockSize))
|
sl@0
|
65 |
pos=0;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
#if defined (__WINS__)
|
sl@0
|
68 |
test.Printf(_L("Read %d %d byte blocks in 10 secs\n"),count,aReadBlockSize);
|
sl@0
|
69 |
#else
|
sl@0
|
70 |
TBuf<60> buf;
|
sl@0
|
71 |
TReal32 rate=((TReal32)(count*aReadBlockSize))/10240.0F;
|
sl@0
|
72 |
TRealFormat rf(10,2);
|
sl@0
|
73 |
buf.Format(_L("Read %d %d byte blocks in 10 secs ("),count,aReadBlockSize);
|
sl@0
|
74 |
buf.AppendNum(rate,rf);
|
sl@0
|
75 |
buf.Append(_L("Kb/s)\n"));
|
sl@0
|
76 |
test.Printf(buf);
|
sl@0
|
77 |
#endif
|
sl@0
|
78 |
test.Printf(_L("Errors:%d\n"),err);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
LOCAL_C void DoWrite(TInt aWriteBlockSize)
|
sl@0
|
82 |
//
|
sl@0
|
83 |
// Do write benchmark
|
sl@0
|
84 |
//
|
sl@0
|
85 |
{
|
sl@0
|
86 |
TLocalDriveCapsV7 info;
|
sl@0
|
87 |
TPckg<TLocalDriveCapsV7> capsPckg(info);
|
sl@0
|
88 |
TheDrive.Caps(capsPckg);
|
sl@0
|
89 |
TInt maxSize;
|
sl@0
|
90 |
maxSize=I64LOW(info.iSize);
|
sl@0
|
91 |
TInt count,err;
|
sl@0
|
92 |
TUint pos;
|
sl@0
|
93 |
count=pos=err=0;
|
sl@0
|
94 |
|
sl@0
|
95 |
// Erase the first 16 blocks to ensure write completes OK
|
sl@0
|
96 |
TUint32 EbSz=(TInt)info.iEraseBlockSize;
|
sl@0
|
97 |
TInt r=KErrNone;
|
sl@0
|
98 |
for (pos=0; pos<16*EbSz; pos+=EbSz)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
TInt64 pos64 = MAKE_TINT64(0, pos);
|
sl@0
|
101 |
r=TheDrive.Format(pos64,EbSz);
|
sl@0
|
102 |
test(r==KErrNone);
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
pos=0;
|
sl@0
|
106 |
RTimer timer;
|
sl@0
|
107 |
timer.CreateLocal();
|
sl@0
|
108 |
TRequestStatus reqStat;
|
sl@0
|
109 |
TPtrC8 ptr(Buffer,aWriteBlockSize);
|
sl@0
|
110 |
timer.After(reqStat,10000000); // After 10 secs
|
sl@0
|
111 |
while(reqStat==KRequestPending)
|
sl@0
|
112 |
{
|
sl@0
|
113 |
TInt64 pos64 = MAKE_TINT64(0, pos);
|
sl@0
|
114 |
TInt r=TheDrive.Write(pos64,ptr);
|
sl@0
|
115 |
if (r==KErrNone)
|
sl@0
|
116 |
count++;
|
sl@0
|
117 |
else
|
sl@0
|
118 |
err++;
|
sl@0
|
119 |
pos+=aWriteBlockSize;
|
sl@0
|
120 |
if ((TInt)pos>=(maxSize-aWriteBlockSize))
|
sl@0
|
121 |
pos=0;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
#if defined (__WINS__)
|
sl@0
|
125 |
test.Printf(_L("Write %d %d byte blocks in 10 secs\n"),count,aWriteBlockSize);
|
sl@0
|
126 |
#else
|
sl@0
|
127 |
TBuf<60> buf;
|
sl@0
|
128 |
TReal32 rate=((TReal32)(count*aWriteBlockSize))/10240.0F;
|
sl@0
|
129 |
TRealFormat rf(10,2);
|
sl@0
|
130 |
buf.Format(_L("Write %d %d byte blocks in 10 secs ("),count,aWriteBlockSize);
|
sl@0
|
131 |
buf.AppendNum(rate,rf);
|
sl@0
|
132 |
buf.Append(_L("Kb/s)\n"));
|
sl@0
|
133 |
test.Printf(buf);
|
sl@0
|
134 |
#endif
|
sl@0
|
135 |
test.Printf(_L("Errors:%d\n"),err);
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
|
sl@0
|
139 |
GLDEF_C TInt E32Main()
|
sl@0
|
140 |
{
|
sl@0
|
141 |
TBuf<32> b;
|
sl@0
|
142 |
|
sl@0
|
143 |
test.Title();
|
sl@0
|
144 |
TDriveInfoV1Buf diBuf;
|
sl@0
|
145 |
UserHal::DriveInfo(diBuf);
|
sl@0
|
146 |
TDriveInfoV1 &di=diBuf();
|
sl@0
|
147 |
TInt r;
|
sl@0
|
148 |
TInt drv;
|
sl@0
|
149 |
|
sl@0
|
150 |
test.Printf(_L("DRIVES PRESENT :%d\r\n"),di.iTotalSupportedDrives);
|
sl@0
|
151 |
test.Printf(_L("C:(1ST) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[0]);
|
sl@0
|
152 |
test.Printf(_L("D:(2ND) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[1]);
|
sl@0
|
153 |
test.Printf(_L("E:(3RD) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[2]);
|
sl@0
|
154 |
test.Printf(_L("F:(4TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[3]);
|
sl@0
|
155 |
test.Printf(_L("G:(5TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[4]);
|
sl@0
|
156 |
test.Printf(_L("H:(6TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[5]);
|
sl@0
|
157 |
test.Printf(_L("I:(7TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[6]);
|
sl@0
|
158 |
test.Printf(_L("J:(8TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[7]);
|
sl@0
|
159 |
test.Printf(_L("K:(9TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[8]);
|
sl@0
|
160 |
|
sl@0
|
161 |
test.Printf(_L("Select Local Drive (C-%c):\r\n"),'C'+ 8);
|
sl@0
|
162 |
TChar c;
|
sl@0
|
163 |
FOREVER
|
sl@0
|
164 |
{
|
sl@0
|
165 |
c=(TUint)test.Getch();
|
sl@0
|
166 |
c.UpperCase();
|
sl@0
|
167 |
drv=((TUint)c)-'C';
|
sl@0
|
168 |
if (drv>=0&&drv<='C'+ 8)
|
sl@0
|
169 |
break;
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
r=User::LoadPhysicalDevice(LFFS_PDD_NAME);
|
sl@0
|
173 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
174 |
|
sl@0
|
175 |
|
sl@0
|
176 |
b.Format(_L("Connect to drive %c:"),'C'+drv);
|
sl@0
|
177 |
test.Next(b);
|
sl@0
|
178 |
TheDrive.Connect(drv,ChangedFlag);
|
sl@0
|
179 |
|
sl@0
|
180 |
TLocalDriveCapsV7 info;
|
sl@0
|
181 |
TPckg<TLocalDriveCapsV7> capsPckg(info);
|
sl@0
|
182 |
TheDrive.Caps(capsPckg);
|
sl@0
|
183 |
|
sl@0
|
184 |
test.Start(_L("Starting write tests\n"));
|
sl@0
|
185 |
|
sl@0
|
186 |
// Full buffer write test - pre-load the buffer and write
|
sl@0
|
187 |
TUint32* pB=(TUint32*)(Buffer);
|
sl@0
|
188 |
TUint32* pE=(TUint32*)(Buffer+KBufferSize);
|
sl@0
|
189 |
TUint seed[2];
|
sl@0
|
190 |
seed[0]=0xb17217f8;
|
sl@0
|
191 |
seed[1]=0;
|
sl@0
|
192 |
while (pB<pE)
|
sl@0
|
193 |
*pB++=Random(seed);
|
sl@0
|
194 |
|
sl@0
|
195 |
pB=(TUint32*)(Buffer);
|
sl@0
|
196 |
if(info.iWriteBufferSize)
|
sl@0
|
197 |
DoWrite(info.iWriteBufferSize);
|
sl@0
|
198 |
|
sl@0
|
199 |
// Erase test
|
sl@0
|
200 |
// Get the current time
|
sl@0
|
201 |
TInt64 zeroTime=MAKE_TINT64(0, 0);
|
sl@0
|
202 |
TTime TheTimer=TTime(zeroTime);
|
sl@0
|
203 |
|
sl@0
|
204 |
// Invoke the erase sequuence
|
sl@0
|
205 |
|
sl@0
|
206 |
// Report the time interval
|
sl@0
|
207 |
TInt64 currentTime=TheTimer.Int64();
|
sl@0
|
208 |
test.Printf(_L("currentTime now = %d\n"),(TInt)currentTime);
|
sl@0
|
209 |
|
sl@0
|
210 |
currentTime=TheTimer.Int64();
|
sl@0
|
211 |
test.Printf(_L("currentTime now = %d\n"),(TInt)currentTime);
|
sl@0
|
212 |
|
sl@0
|
213 |
currentTime=TheTimer.Int64();
|
sl@0
|
214 |
test.Printf(_L("currentTime now = %d\n"),(TInt)currentTime);
|
sl@0
|
215 |
|
sl@0
|
216 |
|
sl@0
|
217 |
if ((info.iWriteBufferSize)<1024)
|
sl@0
|
218 |
/*
|
sl@0
|
219 |
these tests would cause errors on M18 Intel Strataflash. this type
|
sl@0
|
220 |
of Strataflash operates in object and control mode. when writing 16
|
sl@0
|
221 |
byte blocks the first write puts puts each M18 1024 byte programming
|
sl@0
|
222 |
region into control mode so that all susequent even numbered writes
|
sl@0
|
223 |
succeed but all subsequent odd numbered writes fail (in control
|
sl@0
|
224 |
mode writes to bytes 16 - 31, 48 - 63 aren't allowed). successes match
|
sl@0
|
225 |
failures. when writing 256 byte blocks only 1 in 4 writes succeeds -
|
sl@0
|
226 |
the first write in each programming region succeeds and puts the
|
sl@0
|
227 |
region into object mode so that the subsequent three writes to the
|
sl@0
|
228 |
same programming region fail (in object mode a programming region may
|
sl@0
|
229 |
only be written to once). when writing 512 byte blocks 1 in 2 writes
|
sl@0
|
230 |
fail with the first write to each programming region succeeding and the
|
sl@0
|
231 |
second failing. with 513 byte writes the analysis is slightly more
|
sl@0
|
232 |
complex than with 512 byte writes but the failure rate of 1 in 2 still
|
sl@0
|
233 |
applies.
|
sl@0
|
234 |
*/
|
sl@0
|
235 |
{
|
sl@0
|
236 |
DoWrite(16);
|
sl@0
|
237 |
DoWrite(256);
|
sl@0
|
238 |
DoWrite(512);
|
sl@0
|
239 |
DoWrite(513);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
DoWrite(1024);
|
sl@0
|
242 |
DoWrite(2048);
|
sl@0
|
243 |
DoWrite(16384);
|
sl@0
|
244 |
|
sl@0
|
245 |
|
sl@0
|
246 |
DoRead(16);
|
sl@0
|
247 |
DoRead(256);
|
sl@0
|
248 |
DoRead(512);
|
sl@0
|
249 |
DoRead(513);
|
sl@0
|
250 |
DoRead(2048);
|
sl@0
|
251 |
DoRead(16384);
|
sl@0
|
252 |
|
sl@0
|
253 |
test.End();
|
sl@0
|
254 |
|
sl@0
|
255 |
return(0);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|