sl@0: // Copyright (c) 1998-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\pccd\t_meddrv.cpp sl@0: // General media driver tests sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: const TInt KHeapSize=0x4000; sl@0: const TInt KTestDriverMediaSize=0x1000; // 4K sl@0: const TInt KShortBufferSize=0x100; sl@0: sl@0: #define MEDDRV_ATA_NAME _L("MEDATA") sl@0: #define MEDDRV_SINGLE_REQ_NAME _L("MEDT1") sl@0: #define MEDDRV_SIMULTANEOUS_REQ_NAME _L("MEDT2") sl@0: sl@0: LOCAL_D RTest test(_L("T_MEDDRV")); sl@0: LOCAL_D TInt TheDriveNumber=3; sl@0: sl@0: sl@0: LOCAL_C TInt formatThread(TAny*) sl@0: { sl@0: sl@0: TBusLocalDrive anotherDrive; sl@0: RTest ftest(_L("Formatting thread")); sl@0: ftest.Title(); sl@0: sl@0: ftest.Start(_L("Connect to local drive")); sl@0: TBool changeFlag=EFalse; sl@0: ftest(anotherDrive.Connect(TheDriveNumber,changeFlag)==KErrNone); sl@0: sl@0: ftest.Next(_L("Format disk")); sl@0: ftest(anotherDrive.Format(0,KTestDriverMediaSize)==KErrNone); sl@0: anotherDrive.Disconnect(); sl@0: sl@0: ftest.End(); sl@0: return(KErrNone); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TBuf<64> b; sl@0: TInt r; sl@0: TInt i; sl@0: sl@0: test.Title(); sl@0: test.Start(_L("Check loader running")); sl@0: sl@0: #if !defined (__WINS__) sl@0: test.Next(_L("Read drive information")); sl@0: TDriveInfoV1Buf dinfo; sl@0: r=UserHal::DriveInfo(dinfo); sl@0: test(r==KErrNone); sl@0: if (dinfo().iTotalSockets==2) sl@0: TheDriveNumber=3; sl@0: else if (dinfo().iTotalSockets==1) sl@0: TheDriveNumber=2; sl@0: else sl@0: { sl@0: test.Printf(_L("Test not supported on this platform")); sl@0: test.End(); sl@0: return(0); sl@0: } sl@0: #else sl@0: TheDriveNumber=3; sl@0: #endif sl@0: sl@0: test.Next(_L("Load 1st Media Driver")); sl@0: r=User::LoadPhysicalDevice(MEDDRV_ATA_NAME); sl@0: test(r==KErrNone||r==KErrAlreadyExists); sl@0: r=User::LoadPhysicalDevice(MEDDRV_SINGLE_REQ_NAME); sl@0: test(r==KErrNone||r==KErrAlreadyExists); sl@0: test.Printf(_L("Media drivers installed:\n\r")); sl@0: TFindPhysicalDevice findMediaDrv(_L("Media.*")); sl@0: TFullName findResult; sl@0: r=findMediaDrv.Next(findResult); sl@0: while (r==KErrNone) sl@0: { sl@0: test.Printf(_L(" %S\n\r"),&findResult); sl@0: r=findMediaDrv.Next(findResult); sl@0: } sl@0: sl@0: b.Format(_L("Connect to local drive %d"),TheDriveNumber); sl@0: test.Next(b); sl@0: TBusLocalDrive theDrive; sl@0: TBool changeFlag=EFalse; sl@0: test(theDrive.Connect(TheDriveNumber,changeFlag)==KErrNone); sl@0: sl@0: test.Next(_L("Local drive: Capabilities")); sl@0: // Generate a media change to open the profiler media driver rather than the standard one sl@0: // UserSvr::ForceRemountMedia(ERemovableMedia0); sl@0: User::After(300000); // Wait 0.3Sec sl@0: TLocalDriveCapsV2Buf info; sl@0: test(theDrive.Caps(info)==KErrNone); sl@0: test(I64LOW(info().iSize)==(TUint)KTestDriverMediaSize); sl@0: test(info().iType==EMediaRam); sl@0: sl@0: test.Next(_L("Local drive: Write/Read")); sl@0: TInt len; sl@0: TBuf8 rdBuf,wrBuf; sl@0: wrBuf.SetLength(KShortBufferSize); sl@0: for (i=0;i