sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\lffs\t_lfsdrvbm.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "..\misc\prbs.h" sl@0: sl@0: sl@0: LOCAL_D TBuf<16384> DataBuf; sl@0: LOCAL_D TBusLocalDrive TheDrive; sl@0: LOCAL_D TBool ChangedFlag; sl@0: sl@0: const TInt KBufferSize=4096; sl@0: const TInt KBigBufferSize=4096*4; sl@0: TUint8 Buffer[KBigBufferSize]; sl@0: sl@0: sl@0: #define LFFS_PDD_NAME _L("MEDLFS") sl@0: sl@0: sl@0: RTest test(_L("LFFS Driver BenchMark Test")); sl@0: sl@0: LOCAL_C void DoRead(TInt aReadBlockSize) sl@0: // sl@0: // Do Read benchmark sl@0: // sl@0: { sl@0: TInt msgHandle = KLocalMessageHandle; sl@0: TLocalDriveCapsV7 info; sl@0: TPckg capsPckg(info); sl@0: TheDrive.Caps(capsPckg); sl@0: TInt maxSize; sl@0: maxSize=I64LOW(info.iSize); sl@0: TInt count,pos,err; sl@0: count=pos=err=0; sl@0: sl@0: RTimer timer; sl@0: timer.CreateLocal(); sl@0: TRequestStatus reqStat; sl@0: timer.After(reqStat,10000000); // After 10 secs sl@0: while(reqStat==KRequestPending) sl@0: { sl@0: if (TheDrive.Read(pos,aReadBlockSize,&DataBuf,msgHandle,0)==KErrNone) sl@0: count++; sl@0: else sl@0: err++; sl@0: pos+=aReadBlockSize; sl@0: if (pos>=(maxSize-aReadBlockSize)) sl@0: pos=0; sl@0: } sl@0: #if defined (__WINS__) sl@0: test.Printf(_L("Read %d %d byte blocks in 10 secs\n"),count,aReadBlockSize); sl@0: #else sl@0: TBuf<60> buf; sl@0: TReal32 rate=((TReal32)(count*aReadBlockSize))/10240.0F; sl@0: TRealFormat rf(10,2); sl@0: buf.Format(_L("Read %d %d byte blocks in 10 secs ("),count,aReadBlockSize); sl@0: buf.AppendNum(rate,rf); sl@0: buf.Append(_L("Kb/s)\n")); sl@0: test.Printf(buf); sl@0: #endif sl@0: test.Printf(_L("Errors:%d\n"),err); sl@0: } sl@0: sl@0: LOCAL_C void DoWrite(TInt aWriteBlockSize) sl@0: // sl@0: // Do write benchmark sl@0: // sl@0: { sl@0: TLocalDriveCapsV7 info; sl@0: TPckg capsPckg(info); sl@0: TheDrive.Caps(capsPckg); sl@0: TInt maxSize; sl@0: maxSize=I64LOW(info.iSize); sl@0: TInt count,err; sl@0: TUint pos; sl@0: count=pos=err=0; sl@0: sl@0: // Erase the first 16 blocks to ensure write completes OK sl@0: TUint32 EbSz=(TInt)info.iEraseBlockSize; sl@0: TInt r=KErrNone; sl@0: for (pos=0; pos<16*EbSz; pos+=EbSz) sl@0: { sl@0: TInt64 pos64 = MAKE_TINT64(0, pos); sl@0: r=TheDrive.Format(pos64,EbSz); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: pos=0; sl@0: RTimer timer; sl@0: timer.CreateLocal(); sl@0: TRequestStatus reqStat; sl@0: TPtrC8 ptr(Buffer,aWriteBlockSize); sl@0: timer.After(reqStat,10000000); // After 10 secs sl@0: while(reqStat==KRequestPending) sl@0: { sl@0: TInt64 pos64 = MAKE_TINT64(0, pos); sl@0: TInt r=TheDrive.Write(pos64,ptr); sl@0: if (r==KErrNone) sl@0: count++; sl@0: else sl@0: err++; sl@0: pos+=aWriteBlockSize; sl@0: if ((TInt)pos>=(maxSize-aWriteBlockSize)) sl@0: pos=0; sl@0: } sl@0: sl@0: #if defined (__WINS__) sl@0: test.Printf(_L("Write %d %d byte blocks in 10 secs\n"),count,aWriteBlockSize); sl@0: #else sl@0: TBuf<60> buf; sl@0: TReal32 rate=((TReal32)(count*aWriteBlockSize))/10240.0F; sl@0: TRealFormat rf(10,2); sl@0: buf.Format(_L("Write %d %d byte blocks in 10 secs ("),count,aWriteBlockSize); sl@0: buf.AppendNum(rate,rf); sl@0: buf.Append(_L("Kb/s)\n")); sl@0: test.Printf(buf); sl@0: #endif sl@0: test.Printf(_L("Errors:%d\n"),err); sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TBuf<32> b; sl@0: sl@0: test.Title(); sl@0: TDriveInfoV1Buf diBuf; sl@0: UserHal::DriveInfo(diBuf); sl@0: TDriveInfoV1 &di=diBuf(); sl@0: TInt r; sl@0: TInt drv; sl@0: sl@0: test.Printf(_L("DRIVES PRESENT :%d\r\n"),di.iTotalSupportedDrives); sl@0: test.Printf(_L("C:(1ST) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[0]); sl@0: test.Printf(_L("D:(2ND) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[1]); sl@0: test.Printf(_L("E:(3RD) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[2]); sl@0: test.Printf(_L("F:(4TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[3]); sl@0: test.Printf(_L("G:(5TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[4]); sl@0: test.Printf(_L("H:(6TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[5]); sl@0: test.Printf(_L("I:(7TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[6]); sl@0: test.Printf(_L("J:(8TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[7]); sl@0: test.Printf(_L("K:(9TH) DRIVE NAME :%- 16S\r\n"),&di.iDriveName[8]); sl@0: sl@0: test.Printf(_L("Select Local Drive (C-%c):\r\n"),'C'+ 8); sl@0: TChar c; sl@0: FOREVER sl@0: { sl@0: c=(TUint)test.Getch(); sl@0: c.UpperCase(); sl@0: drv=((TUint)c)-'C'; sl@0: if (drv>=0&&drv<='C'+ 8) sl@0: break; sl@0: } sl@0: sl@0: r=User::LoadPhysicalDevice(LFFS_PDD_NAME); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: sl@0: sl@0: b.Format(_L("Connect to drive %c:"),'C'+drv); sl@0: test.Next(b); sl@0: TheDrive.Connect(drv,ChangedFlag); sl@0: sl@0: TLocalDriveCapsV7 info; sl@0: TPckg capsPckg(info); sl@0: TheDrive.Caps(capsPckg); sl@0: sl@0: test.Start(_L("Starting write tests\n")); sl@0: sl@0: // Full buffer write test - pre-load the buffer and write sl@0: TUint32* pB=(TUint32*)(Buffer); sl@0: TUint32* pE=(TUint32*)(Buffer+KBufferSize); sl@0: TUint seed[2]; sl@0: seed[0]=0xb17217f8; sl@0: seed[1]=0; sl@0: while (pB