sl@0: // Copyright (c) 2004-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: // SCSCI Protocol unit test cases classes sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __T_MS_SCSI_H__ sl@0: #define __T_MS_SCSI_H__ sl@0: sl@0: #include sl@0: #include // for Proxy drive sl@0: sl@0: #include "scsiprot.h" sl@0: #include "drivemanager.h" sl@0: sl@0: sl@0: /** sl@0: test scsi transport sl@0: */ sl@0: class TTestScsiTransport : public MTransportBase sl@0: { sl@0: public: sl@0: TTestScsiTransport(); sl@0: sl@0: // MTransportBase methods sl@0: public: sl@0: inline virtual void SetupReadData(TPtr8& aData); sl@0: inline virtual void SetupReadData(TUint aLength); sl@0: inline virtual void SetupWriteData(TPtrC8& aData); sl@0: inline virtual TInt Start(); sl@0: inline virtual TInt Stop(); sl@0: inline virtual void RegisterProtocol(MProtocolBase& aProtocol); sl@0: inline virtual TInt BytesAvailable(); sl@0: sl@0: // test specific methods / members sl@0: public: sl@0: void InitialiseReadBuf(); sl@0: sl@0: public: sl@0: //new sl@0: inline virtual TInt InitialiseTransportL(TInt aTransportLddFlag); sl@0: inline virtual void GetCommandBufPtr(TPtr8& aDes, TUint aLength); sl@0: inline virtual void GetReadDataBufPtr(TPtr8& aDes); sl@0: inline virtual void GetWriteDataBufPtr(TPtrC8& aDes); sl@0: inline virtual void ProcessReadData(TAny* aAddress); sl@0: sl@0: public: sl@0: /** pointer to the protocol */ sl@0: MProtocolBase* iProtocol; sl@0: sl@0: /** reference to Write Data protocol buffer */ sl@0: TPtrC8 iBufWrite; sl@0: sl@0: /** reference to Read Data protocol buffer */ sl@0: TBuf8 iBufRead; sl@0: sl@0: /**reference to Command protocol buffer */ sl@0: TBuf8<36> iBufCmd; sl@0: sl@0: /** Number of bytes available in the protocol buffer */ sl@0: TUint iReadLength; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: test scsi proxy drive sl@0: */ sl@0: class CTestProxyDrive : public CProxyDrive sl@0: { sl@0: public: sl@0: CTestProxyDrive(); sl@0: virtual ~CTestProxyDrive(); sl@0: sl@0: sl@0: virtual TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg); sl@0: sl@0: virtual TInt Write(TInt64 aPos,const TDesC8& aSrc); sl@0: sl@0: virtual TInt Caps(TDes8& anInfo); sl@0: sl@0: virtual TInt Initialise(); sl@0: sl@0: sl@0: // not implemented methods sl@0: virtual TInt Dismounted() sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Enlarge(TInt) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt ReduceSize(TInt, TInt) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Read(TInt64, TInt, const TAny*, TInt, TInt) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Write(TInt64,TInt,const TAny*,TInt,TInt) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Format(TFormatInfo&) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Format(TInt64,TInt) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt SetMountInfo(const TDesC8*, TInt) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt ForceRemount(TUint) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Unlock(TMediaPassword&, TBool) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Lock(TMediaPassword&, TMediaPassword&, TBool) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt Clear(TMediaPassword&) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt ControlIO(const RMessagePtr2&,TInt,TAny*,TAny*) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt DeleteNotify(TInt64, TInt) sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: virtual TInt ErasePassword() sl@0: { ASSERT(EFalse); return KErrNone; } sl@0: sl@0: // test specific members / methods sl@0: public: sl@0: /** Proxy drive Caps */ sl@0: TLocalDriveCapsV4 iCaps; sl@0: sl@0: /** Buffer with data for reading or writing*/ sl@0: TBuf8 iMediaBuf; sl@0: sl@0: }; sl@0: sl@0: /** sl@0: base class to encapsulate a single SCSI protocol test sl@0: */ sl@0: class CScsiTest : public CBase sl@0: { sl@0: // static memebers sl@0: public: sl@0: /** sl@0: Defines Lun used for testing sl@0: */ sl@0: static TInt TestLun; sl@0: sl@0: public: sl@0: virtual ~CScsiTest(); sl@0: static CScsiTest* NewLC(); sl@0: sl@0: public: sl@0: TPtrC8& GetSenseCodePtr(); sl@0: void MountTestDrive (); sl@0: void DismountTestDrive (); sl@0: CMassStorageDrive* TestDrive(); sl@0: sl@0: // decode command sl@0: inline TBool DecodePacket(TPtrC8& aCmd); sl@0: sl@0: private: sl@0: CScsiTest(); sl@0: void ConstructL(); sl@0: sl@0: public: sl@0: /** sl@0: Drive Manager sl@0: */ sl@0: CDriveManager* iDriveManager; sl@0: /** sl@0: SCSI protocol sl@0: */ sl@0: CScsiProtocol* iScsiProt; sl@0: /** sl@0: Transport object sl@0: */ sl@0: TTestScsiTransport iTransport; sl@0: sl@0: /** sl@0: Test proxy drive sl@0: */ sl@0: CTestProxyDrive iProxyDrive; sl@0: sl@0: /** sl@0: drive map sl@0: */ sl@0: RArray iDriveMap; sl@0: sl@0: }; sl@0: sl@0: sl@0: sl@0: // sl@0: // wrapper classes sl@0: // sl@0: /** RequestSense wrapper class */ sl@0: class TRequestSenseData sl@0: { sl@0: public: sl@0: inline TRequestSenseData(TPtrC8 aData); sl@0: sl@0: inline TInt8 Key(); sl@0: inline TInt8 AdditionalCode(); sl@0: inline TInt8 AdditionalCodeQualifier(); sl@0: sl@0: public: sl@0: /** pointer to internal data */ sl@0: TPtrC8 iData; sl@0: }; sl@0: sl@0: sl@0: /** Inquiry wrapper class */ sl@0: class TInquiryData sl@0: { sl@0: public: sl@0: inline TInquiryData(TPtrC8 aData); sl@0: sl@0: inline TInt8 DeviceType(); // 5 lower bits in 1st byte sl@0: inline TBool RMB(); // high bit in 2nd byte sl@0: inline TInt8 Version(); // 3rd byte sl@0: inline TInt8 RespDataFrmt(); // 4th byte sl@0: // TBuf<8> sl@0: inline TPtr8 VendorId(); sl@0: // TBuf<16> sl@0: inline TPtr8 ProductId(); sl@0: // TBuf<4> sl@0: inline TPtr8 RevisionLevel(); sl@0: inline TInt8 PeripheralQualifier(); // 3 highest bits in 1st byte sl@0: inline TInt8 Length(); // length of Inquiry data sl@0: sl@0: public: sl@0: /** pointer to internal data */ sl@0: TPtrC8 iData; sl@0: }; sl@0: sl@0: sl@0: // sl@0: // Command wrappers sl@0: // Notes: Every command wrapper has internal buffer sl@0: // 11 or 7 bytes long. This buffer is used for sl@0: // 10 or 6 bytes long commands. An extra byte is sl@0: // used for the size of an command (see implementation sl@0: // of scsi protocol). sl@0: sl@0: /** Wrapper class for READ(10) WRITE(10) VERIFY(10) command */ sl@0: class TReadWrite10Cmd sl@0: { sl@0: public: sl@0: TReadWrite10Cmd(); sl@0: sl@0: void SetBlockAddress(TUint32 aAddress); sl@0: inline void SetTransferLength(TUint16 aLength); sl@0: inline void SetProtect(TUint8 aProtect); sl@0: sl@0: inline void SetRead(); sl@0: inline void SetWrite(); sl@0: inline void SetVerify(); sl@0: inline void SetBytChk (TBool aSet); sl@0: sl@0: public: sl@0: /** buffer with command data */ sl@0: TBuf8<11> iCmd; sl@0: }; sl@0: sl@0: /** Wrapper class for MODE SENSE(6) command */ sl@0: class TModeSenseCmd sl@0: { sl@0: public: sl@0: TModeSenseCmd(); sl@0: inline void SetPC (TUint8 aPc); sl@0: inline void SetPageCode (TUint8 aPc); sl@0: sl@0: public: sl@0: /** buffer with command data */ sl@0: TBuf8<7> iCmd; sl@0: }; sl@0: sl@0: /** Wrapper class for INQUIRY command */ sl@0: class TInquiryCmd sl@0: { sl@0: public: sl@0: TInquiryCmd(); sl@0: sl@0: public: sl@0: /** buffer with command data */ sl@0: TBuf8<7> iCmd; sl@0: }; sl@0: sl@0: /** Wrapper class for TEST UNIT READY command */ sl@0: class TTestUnitReadyCmd sl@0: { sl@0: public: sl@0: TTestUnitReadyCmd(); sl@0: sl@0: public: sl@0: /** buffer with command data */ sl@0: TBuf8<7> iCmd; sl@0: }; sl@0: sl@0: /** Wrapper class for PREVENT ALLOW MEDIA REMOVAL command */ sl@0: class TMediaRemovalCmd sl@0: { sl@0: public: sl@0: TMediaRemovalCmd(); sl@0: sl@0: public: sl@0: /** buffer with command data */ sl@0: TBuf8<7> iCmd; sl@0: }; sl@0: sl@0: /** Wrapper class for READ CAPACITY command */ sl@0: class TReadCapacityCmd sl@0: { sl@0: public: sl@0: TReadCapacityCmd(); sl@0: sl@0: public: sl@0: /** buffer with command data */ sl@0: TBuf8<11> iCmd; sl@0: }; sl@0: sl@0: /** Wrapper class for READ CAPACITY response */ sl@0: class TReadCapacityResponse : public TPtrC8 sl@0: { sl@0: public: sl@0: TReadCapacityResponse(const TDesC8 &aDes); sl@0: sl@0: inline TUint32 LBAddress(); sl@0: inline TUint32 BlockLength(); sl@0: }; sl@0: sl@0: #include "t_ms_scsi.inl" sl@0: sl@0: #endif //__T_MS_SCSI_H__