diff -r 000000000000 -r a41df078684a kerneltest/e32test/pccd/t_crrdrv.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/pccd/t_crrdrv.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,313 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\pccd\t_crrdrv.cpp +// Test the Compact Rom (Programmable) card media driver +// +// + +#include +#include +#include +#define TWOMEG + +LOCAL_D RTest test(_L("T_CRRDRV")); + +#if defined (__MARM__) + +const TInt KTestBufLen=0x100; + +#define PDD_NAME _L("MEDCRR") +const TInt KDriveNumber=1; // D: +#if defined (TWOMEG) +const TInt KMaxDriveLen=0x00200000; // 2M +#else +const TInt KMaxDriveLen=0x00600000; // 6M +#endif +const TUint16 KMagicSum=0x1234; +const TInt KCRomPrivateAreaLen=0x800; // 1st 2K of CRom contains CIS + + +const TInt KCRomCisDataLength=0xD0; + +LOCAL_D TBuf8 wrBuf,rdBuf; +#if defined (TWOMEG) +LOCAL_D const TText8 CompactRomCisData[KCRomCisDataLength]={ + 0x01,0xff,0x03,0xff,0x1c,0xff,0x01,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff, + 0x1b,0xff,0x01,0xff,0xff,0xff,0x20,0xff,0x04,0xff,0x00,0xff,0x00,0xff,0x00,0xff, + 0x00,0xff,0x15,0xff,0x24,0xff,0x05,0xff,0x00,0xff,0x50,0xff,0x73,0xff,0x69,0xff, + 0x6f,0xff,0x6e,0xff,0x20,0xff,0x50,0xff,0x4c,0xff,0x43,0xff,0x00,0xff,0x43,0xff, + 0x6f,0xff,0x6d,0xff,0x70,0xff,0x61,0xff,0x63,0xff,0x74,0xff,0x20,0xff,0x52,0xff, + 0x6f,0xff,0x6d,0xff,0x20,0xff,0x43,0xff,0x61,0xff,0x72,0xff,0x64,0xff,0x00,0xff, + 0x56,0xff,0x30,0xff,0x2e,0xff,0x30,0xff,0x30,0xff,0x00,0xff,0xff,0xff,0x80,0xff, + 0x03,0xff,0x58,0xff,0x06,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x01,0xff,0x00,0xff, + 0x40,0xff,0x0b,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x08,0xff,0x00,0xff,0x00,0xff, + 0x00,0xff,0x00,0xff,0x01,0xff,0x00,0xff,0x00,0xff,0x41,0xff,0x0a,0xff,0x01,0xff, + 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xf8,0xff,0x1f,0xff, + 0x00,0xff,0x14,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff + }; +#else +LOCAL_D const TText8 CompactRomCisData[KCRomCisDataLength]={ + 0x01,0xff,0x03,0xff,0x1c,0xff,0x01,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff, + 0x1b,0xff,0x01,0xff,0xff,0xff,0x20,0xff,0x04,0xff,0x00,0xff,0x00,0xff,0x00,0xff, + 0x00,0xff,0x15,0xff,0x24,0xff,0x05,0xff,0x00,0xff,0x50,0xff,0x73,0xff,0x69,0xff, + 0x6f,0xff,0x6e,0xff,0x20,0xff,0x50,0xff,0x4c,0xff,0x43,0xff,0x00,0xff,0x43,0xff, + 0x6f,0xff,0x6d,0xff,0x70,0xff,0x61,0xff,0x63,0xff,0x74,0xff,0x20,0xff,0x52,0xff, + 0x6f,0xff,0x6d,0xff,0x20,0xff,0x43,0xff,0x61,0xff,0x72,0xff,0x64,0xff,0x00,0xff, + 0x56,0xff,0x30,0xff,0x2e,0xff,0x30,0xff,0x30,0xff,0x00,0xff,0xff,0xff,0x80,0xff, + 0x0b,0xff,0x58,0xff,0x06,0xff,0x08,0xff,0x76,0xff,0x58,0xff,0x06,0xff,0x08,0xff, + 0x76,0xff,0x58,0xff,0x06,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x01,0xff,0x00,0xff, + 0x40,0xff,0x0b,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x08,0xff,0x00,0xff,0x00,0xff, + 0x00,0xff,0x00,0xff,0x01,0xff,0x00,0xff,0x00,0xff,0x41,0xff,0x0a,0xff,0x01,0xff, + 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xf8,0xff,0x5f,0xff, + 0x00,0xff,0x14,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff + }; +#endif + +/* A sample multifunction CIS to test out tuple parsing by blowing onto CRom card. +const TInt KMfcCisDataLen=0x180; +LOCAL_D const TText8 MfcCisData[KMfcCisDataLen]={ + 0x13,0xff,0x03,0xff,0x43,0xff,0x49,0xff,0x53,0xff,0x06,0xff,0x10,0xff,0x03,0xff, + 0x00,0xff,0x30,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x60,0xff,0x00,0xff, + 0x00,0xff,0x00,0xff,0x00,0xff,0x90,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0x01,0xff,0x03,0xff,0xda,0xff,0x00,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff, + 0xda,0xff,0x00,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x02,0xff,0x00,0xff,0x1a,0xff, + 0x05,0xff,0x01,0xff,0x01,0xff,0x00,0xff,0x02,0xff,0x0f,0xff,0x1b,0xff,0x07,0xff, + 0xc1,0xff,0x41,0xff,0x09,0xff,0x01,0xff,0xb5,0xff,0x1e,0xff,0x49,0xff,0x14,0xff, + 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0x01,0xff,0x03,0xff,0xda,0xff,0x00,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff, + 0xda,0xff,0x00,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x06,0xff,0x00,0xff,0x1a,0xff, + 0x05,0xff,0x01,0xff,0x02,0xff,0x00,0xff,0x04,0xff,0x0f,0xff,0x1b,0xff,0x06,0xff, + 0xc2,0xff,0x41,0xff,0x09,0xff,0x01,0xff,0x55,0xff,0x49,0xff,0x14,0xff,0x00,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0x01,0xff,0x03,0xff,0xda,0xff,0x00,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff, + 0xda,0xff,0x00,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x03,0xff,0x00,0xff,0x1a,0xff, + 0x05,0xff,0x01,0xff,0x03,0xff,0x00,0xff,0x06,0xff,0x0f,0xff,0x1b,0xff,0x06,0xff, + 0xc3,0xff,0x41,0xff,0x09,0xff,0x01,0xff,0x55,0xff,0x49,0xff,0x14,0xff,0x00,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff + }; */ + + +LOCAL_C void ProgressBar(TInt aPos,TInt anEndPos,TInt anXPos) +// +// Display progress of local drive operation on screen (1-16 dots) +// + { + static TInt prev; + TInt curr; + if ((curr=(aPos-1)/(anEndPos>>4))>prev) + { // Update progress bar + test.Console()->SetPos(anXPos); + for (TInt i=curr;i>=0;i--) + test.Printf(_L(".")); + } + prev=curr; + } + +GLDEF_C TInt E32Main() + { + TInt i; + TBuf<32> b; + + test.Title(); + +// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change (in case normal CROM driver open on target). + User::After(300000); // Allow 0.3s for controller to detect door closed. + + test.Start(_L("Load CROM(repro) Media Driver")); + TInt r=User::LoadPhysicalDevice(PDD_NAME); + test(r==KErrNone||r==KErrAlreadyExists); + + b.Format(_L("Connect to local drive (%c:)"),KDriveNumber+'C'); + test.Next(b); + TBusLocalDrive theCRomDrive; + TBool changeFlag=FALSE; + test(theCRomDrive.Connect(KDriveNumber,changeFlag)==KErrNone); + + test.Next(_L("CROM drive: capabilities")); +// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change (in case normal CROM driver open on target). + User::After(300000); // Allow 0.3s for controller to detect door closed. + TLocalDriveCapsV2Buf info; + test(theCRomDrive.Caps(info)==KErrNone); + test(info().iSize==(TInt64)KMaxDriveLen); + test(info().iType==EMediaFlash); + test(info().iBattery==EBatNotSupported); + test(info().iDriveAtt==(KDriveAttLocal|KDriveAttRemovable)); + test(info().iMediaAtt==KMediaAttFormattable); + test(info().iFileSystemId==KDriveFileSysFAT); + + test.Next(_L("CROM drive: format")); + TFormatInfo fi; + test.Printf(_L("Formatting ")); + TInt ret; + while((ret=theCRomDrive.Format(fi))!=KErrEof) + { + ProgressBar((fi.i512ByteSectorsFormatted<<9),KMaxDriveLen,11); + test(ret==KErrNone); + } + test.Printf(_L("\r\nReading ")); + TInt len; + TInt msgHandle = KLocalMessageHandle; + for (i=0;i>1)),KTestBufLen,&wrBuf,msgHandle,0)==KErrNone); + rdBuf.Fill(0,KTestBufLen); + test(theCRomDrive.Read((0x10000-(KTestBufLen>>1)),KTestBufLen,&rdBuf,msgHandle,0)==KErrNone); + test(rdBuf.Compare(wrBuf)==0); + + test.Next(_L("CROM drive: Write across 28F016 device boundary")); + test(theCRomDrive.Write((0x200000-(KTestBufLen>>1)),KTestBufLen,&wrBuf,msgHandle,0)==KErrNone); + rdBuf.Fill(0,KTestBufLen); + test(theCRomDrive.Read((0x200000-(KTestBufLen>>1)),KTestBufLen,&rdBuf,msgHandle,0)==KErrNone); + test(rdBuf.Compare(wrBuf)==0); +*/ + test.Next(_L("CROM drive: Write/Read the entire disk")); + TInt rdwrTestLen=(KTestBufLen-3); // Test it works off word boundary + TUint *p=(TUint*)&wrBuf[0]; + TInt j; + test.Printf(_L("Writing ")); + for (i=0,j=0;i