First public contribution.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // SCSCI Protocol unit test cases classes
23 #ifndef __T_MS_SCSI_H__
24 #define __T_MS_SCSI_H__
27 #include <f32fsys.h> // for Proxy drive
30 #include "drivemanager.h"
36 class TTestScsiTransport : public MTransportBase
41 // MTransportBase methods
43 inline virtual void SetupReadData(TPtr8& aData);
44 inline virtual void SetupReadData(TUint aLength);
45 inline virtual void SetupWriteData(TPtrC8& aData);
46 inline virtual TInt Start();
47 inline virtual TInt Stop();
48 inline virtual void RegisterProtocol(MProtocolBase& aProtocol);
49 inline virtual TInt BytesAvailable();
51 // test specific methods / members
53 void InitialiseReadBuf();
57 inline virtual TInt InitialiseTransportL(TInt aTransportLddFlag);
58 inline virtual void GetCommandBufPtr(TPtr8& aDes, TUint aLength);
59 inline virtual void GetReadDataBufPtr(TPtr8& aDes);
60 inline virtual void GetWriteDataBufPtr(TPtrC8& aDes);
61 inline virtual void ProcessReadData(TAny* aAddress);
64 /** pointer to the protocol */
65 MProtocolBase* iProtocol;
67 /** reference to Write Data protocol buffer */
70 /** reference to Read Data protocol buffer */
71 TBuf8<KMaxBufSize*2> iBufRead;
73 /**reference to Command protocol buffer */
76 /** Number of bytes available in the protocol buffer */
84 class CTestProxyDrive : public CProxyDrive
88 virtual ~CTestProxyDrive();
91 virtual TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg);
93 virtual TInt Write(TInt64 aPos,const TDesC8& aSrc);
95 virtual TInt Caps(TDes8& anInfo);
97 virtual TInt Initialise();
100 // not implemented methods
101 virtual TInt Dismounted()
102 { ASSERT(EFalse); return KErrNone; }
103 virtual TInt Enlarge(TInt)
104 { ASSERT(EFalse); return KErrNone; }
105 virtual TInt ReduceSize(TInt, TInt)
106 { ASSERT(EFalse); return KErrNone; }
107 virtual TInt Read(TInt64, TInt, const TAny*, TInt, TInt)
108 { ASSERT(EFalse); return KErrNone; }
109 virtual TInt Write(TInt64,TInt,const TAny*,TInt,TInt)
110 { ASSERT(EFalse); return KErrNone; }
111 virtual TInt Format(TFormatInfo&)
112 { ASSERT(EFalse); return KErrNone; }
113 virtual TInt Format(TInt64,TInt)
114 { ASSERT(EFalse); return KErrNone; }
115 virtual TInt SetMountInfo(const TDesC8*, TInt)
116 { ASSERT(EFalse); return KErrNone; }
117 virtual TInt ForceRemount(TUint)
118 { ASSERT(EFalse); return KErrNone; }
119 virtual TInt Unlock(TMediaPassword&, TBool)
120 { ASSERT(EFalse); return KErrNone; }
121 virtual TInt Lock(TMediaPassword&, TMediaPassword&, TBool)
122 { ASSERT(EFalse); return KErrNone; }
123 virtual TInt Clear(TMediaPassword&)
124 { ASSERT(EFalse); return KErrNone; }
125 virtual TInt ControlIO(const RMessagePtr2&,TInt,TAny*,TAny*)
126 { ASSERT(EFalse); return KErrNone; }
127 virtual TInt DeleteNotify(TInt64, TInt)
128 { ASSERT(EFalse); return KErrNone; }
129 virtual TInt ErasePassword()
130 { ASSERT(EFalse); return KErrNone; }
132 // test specific members / methods
134 /** Proxy drive Caps */
135 TLocalDriveCapsV4 iCaps;
137 /** Buffer with data for reading or writing*/
138 TBuf8<KMaxBufSize*2> iMediaBuf;
143 base class to encapsulate a single SCSI protocol test
145 class CScsiTest : public CBase
150 Defines Lun used for testing
155 virtual ~CScsiTest();
156 static CScsiTest* NewLC();
159 TPtrC8& GetSenseCodePtr();
160 void MountTestDrive ();
161 void DismountTestDrive ();
162 CMassStorageDrive* TestDrive();
165 inline TBool DecodePacket(TPtrC8& aCmd);
175 CDriveManager* iDriveManager;
179 CScsiProtocol* iScsiProt;
183 TTestScsiTransport iTransport;
188 CTestProxyDrive iProxyDrive;
193 RArray<TInt> iDriveMap;
202 /** RequestSense wrapper class */
203 class TRequestSenseData
206 inline TRequestSenseData(TPtrC8 aData);
209 inline TInt8 AdditionalCode();
210 inline TInt8 AdditionalCodeQualifier();
213 /** pointer to internal data */
218 /** Inquiry wrapper class */
222 inline TInquiryData(TPtrC8 aData);
224 inline TInt8 DeviceType(); // 5 lower bits in 1st byte
225 inline TBool RMB(); // high bit in 2nd byte
226 inline TInt8 Version(); // 3rd byte
227 inline TInt8 RespDataFrmt(); // 4th byte
229 inline TPtr8 VendorId();
231 inline TPtr8 ProductId();
233 inline TPtr8 RevisionLevel();
234 inline TInt8 PeripheralQualifier(); // 3 highest bits in 1st byte
235 inline TInt8 Length(); // length of Inquiry data
238 /** pointer to internal data */
245 // Notes: Every command wrapper has internal buffer
246 // 11 or 7 bytes long. This buffer is used for
247 // 10 or 6 bytes long commands. An extra byte is
248 // used for the size of an command (see implementation
249 // of scsi protocol).
251 /** Wrapper class for READ(10) WRITE(10) VERIFY(10) command */
252 class TReadWrite10Cmd
257 void SetBlockAddress(TUint32 aAddress);
258 inline void SetTransferLength(TUint16 aLength);
259 inline void SetProtect(TUint8 aProtect);
261 inline void SetRead();
262 inline void SetWrite();
263 inline void SetVerify();
264 inline void SetBytChk (TBool aSet);
267 /** buffer with command data */
271 /** Wrapper class for MODE SENSE(6) command */
276 inline void SetPC (TUint8 aPc);
277 inline void SetPageCode (TUint8 aPc);
280 /** buffer with command data */
284 /** Wrapper class for INQUIRY command */
291 /** buffer with command data */
295 /** Wrapper class for TEST UNIT READY command */
296 class TTestUnitReadyCmd
302 /** buffer with command data */
306 /** Wrapper class for PREVENT ALLOW MEDIA REMOVAL command */
307 class TMediaRemovalCmd
313 /** buffer with command data */
317 /** Wrapper class for READ CAPACITY command */
318 class TReadCapacityCmd
324 /** buffer with command data */
328 /** Wrapper class for READ CAPACITY response */
329 class TReadCapacityResponse : public TPtrC8
332 TReadCapacityResponse(const TDesC8 &aDes);
334 inline TUint32 LBAddress();
335 inline TUint32 BlockLength();
338 #include "t_ms_scsi.inl"
340 #endif //__T_MS_SCSI_H__