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.
19 inline void TTestScsiTransport::SetupReadData (TPtr8& aData)
21 __FNLOG ("TTestScsiTransport::SetupReadData");
23 // copy data from the begining of a buffer, always
24 iReadLength = aData.Length();
25 aData.Copy (&iBufRead[0], aData.Length());
28 /** setup write data */
29 inline void TTestScsiTransport::SetupWriteData (TPtrC8& aData)
31 __FNLOG ("TTestScsiTransport::SetupWriteData");
35 /** start a transport */
36 inline TInt TTestScsiTransport::Start()
38 __FNLOG ("TTestScsiTransport::Start");
44 /** stop a transport */
45 inline TInt TTestScsiTransport::Stop()
47 __FNLOG ("TTestScsiTransport::Stop");
54 inline void TTestScsiTransport::RegisterProtocol(MProtocolBase& aProtocol)
56 __FNLOG ("TTestScsiTransport::RegisterProtocol\n");
57 iProtocol = &aProtocol;
60 inline TInt TTestScsiTransport::BytesAvailable()
62 __FNLOG ("TTestScsiTransport::BytesAvailable\n");
63 TUint retVal = iReadLength;
68 inline TInt TTestScsiTransport::InitialiseTransportL(TInt /*aTransportLddFlag*/)
73 inline void TTestScsiTransport::GetCommandBufPtr(TPtr8& aDes, TUint aLength)
75 __FNLOG ("TTestScsiTransport::GetCommandBufPtr");
76 aDes.Set((TUint8*)(iBufCmd.Ptr()), aLength, aLength);
79 inline void TTestScsiTransport::GetReadDataBufPtr(TPtr8& aDes)
81 __FNLOG ("TTestScsiTransport::GetReadDataBufPtr");
82 aDes.Set((TUint8*)(iBufRead.Ptr()),KMaxBufSize, KMaxBufSize);
85 inline void TTestScsiTransport::GetWriteDataBufPtr(TPtrC8& aDes)
87 __FNLOG ("TTestScsiTransport::GetWriteDataBufPtr");
88 aDes.Set((TUint8*)(iBufRead.Ptr()),iReadLength);
91 inline void TTestScsiTransport::SetupReadData(TUint aLength)
93 __FNLOG ("TTestScsiTransport::SetupReadData");
94 iReadLength = aLength;
97 inline void TTestScsiTransport::ProcessReadData(TAny* /*aAddress*/)
104 inline TInt CTestProxyDrive::Caps(TDes8& anInfo)
106 anInfo.Copy(TLocalDriveCapsV4Buf(iCaps));
112 A private structure that, when Connected, holds a pair of references to
113 the CProxyDrive and the corresponding TBusLocalDrive's Media Changed flag.
115 struct CMassStorageDrive::CLocalDriveRef : public CBase
117 CLocalDriveRef(CProxyDrive& aProxyDrive, TBool& aMediaChanged)
118 : iProxyDrive(aProxyDrive), iMediaChanged(aMediaChanged)
121 CProxyDrive& iProxyDrive;
122 TBool& iMediaChanged;
123 TDriveState iDriveState;
130 inline TBool CScsiTest::DecodePacket(TPtrC8& aCmd)
132 return iScsiProt->DecodePacket(aCmd, TestLun);
141 TRequestSenseData::TRequestSenseData(TPtrC8 aData)
143 // SCSI-2 spec. p.136
145 ASSERT((iData.Length() >= 17) && (iData[7] + 8 == iData.Length()));
148 inline TInt8 TRequestSenseData::Key()
150 return static_cast<TInt8>(iData[2] & 0x0F);
153 inline TInt8 TRequestSenseData::AdditionalCode()
158 inline TInt8 TRequestSenseData::AdditionalCodeQualifier()
165 // class TInquiryData
167 TInquiryData::TInquiryData(TPtrC8 aData)
172 inline TInt8 TInquiryData::DeviceType() // 5 lower bits in 1st byte
174 return static_cast<TInt8>(iData[0] & 0x1F);
177 inline TBool TInquiryData::RMB() // high bit in 2nd byte
179 return ((iData[1] & 0x80) == 0x80);
182 inline TInt8 TInquiryData::Version() // 3rd byte
187 inline TInt8 TInquiryData::RespDataFrmt() // 4th byte
192 inline TPtr8 TInquiryData::VendorId()
194 return TPtr8(const_cast<TUint8*>(&iData[8]), 8, 8);
197 inline TPtr8 TInquiryData::ProductId()
199 return TPtr8(const_cast<TUint8*>(&iData[16]), 16, 16);
202 inline TPtr8 TInquiryData::RevisionLevel()
204 return TPtr8(const_cast<TUint8*>(&iData[32]), 4, 4);
207 inline TInt8 TInquiryData::PeripheralQualifier() // 3 highest bits in 1st byte
209 return static_cast<TInt8>((iData[0] & 0xE0) >> 5);
212 inline TInt8 TInquiryData::Length() // length of Inquiry data
214 return static_cast<TInt8>(iData[4] + 4);
218 // class TReadWrite10Cmd
220 /** set transfer length */
221 inline void TReadWrite10Cmd::SetTransferLength(TUint16 aLength)
223 iCmd[8] = static_cast<TInt8>((aLength & 0xFF00) >> 8);
224 iCmd[9] = static_cast<TInt8>(aLength & 0x00FF);
227 /** set protect flag */
228 inline void TReadWrite10Cmd::SetProtect(TUint8 aProtect)
230 // Note: used only 3 lower bits
231 // clear flag and set a new one
232 iCmd[2] = static_cast<TInt8>((iCmd[2] & 0x1F) | (aProtect << 5));
235 /** setup read command */
236 inline void TReadWrite10Cmd::SetRead()
238 iCmd[1] = 0x28; // READ(10) cmd
241 /** setup write command */
242 inline void TReadWrite10Cmd::SetWrite()
244 iCmd[1] = 0x2A; // WRITE(10) cmd
247 /** setup verify command */
248 inline void TReadWrite10Cmd::SetVerify()
250 iCmd[1] = 0x2F; // VERIFY(10) cmd
253 /** set BYTCHK fiels. Valid for VERIFY10 cmd only */
254 inline void TReadWrite10Cmd::SetBytChk (TBool aSet)
256 if (0x2F == iCmd[1]) // if VERIFY(10)
258 iCmd[2] = static_cast<TInt8>((iCmd[2] & 0xFD) | (aSet << 1));
263 inline TModeSenseCmd::TModeSenseCmd()
265 iCmd.FillZ (iCmd.MaxLength());
267 iCmd[0] = static_cast<TInt8>(iCmd.MaxLength()-1); // size of the Cmd
271 /** set PC, 2 bits field */
272 inline void TModeSenseCmd::SetPC (TUint8 aPc)
274 iCmd[3] = static_cast<TInt8>((iCmd[3] & 0x3F) | (aPc << 6));
277 /** set page code, 6 bits field */
278 inline void TModeSenseCmd::SetPageCode (TUint8 aPageCode)
280 iCmd[3] = static_cast<TInt8>((iCmd[3] & 0xC0) | aPageCode);
284 inline TInquiryCmd::TInquiryCmd()
286 iCmd.FillZ (iCmd.MaxLength());
287 iCmd[0] = static_cast<TInt8>(iCmd.MaxLength()-1); // size of a command itself
288 iCmd[1] = 0x12; // inquiry operation code
289 iCmd[5] = 36; // min required allocation length
292 inline TTestUnitReadyCmd::TTestUnitReadyCmd()
294 iCmd.FillZ (iCmd.MaxLength());
295 iCmd[0] = static_cast<TInt8>(iCmd.MaxLength()-1); // size of a command itself
296 iCmd[1] = 0x00; // TEST UNIT READY command
299 inline TMediaRemovalCmd::TMediaRemovalCmd()
301 iCmd.FillZ (iCmd.MaxLength());
302 iCmd[0] = static_cast<TInt8>(iCmd.MaxLength()-1); // size of a command itself
303 iCmd[1] = 0x1E; // PREVENT ALLOW MEDIUM REMOVAL command
306 inline TReadCapacityCmd::TReadCapacityCmd()
308 iCmd.FillZ (iCmd.MaxLength());
309 iCmd[0] = static_cast<TInt8>(iCmd.MaxLength()-1); // size of a command itself
310 iCmd[1] = 0x25; // READ CAPACITY command
313 inline TReadCapacityResponse::TReadCapacityResponse(const TDesC8 &aDes)
319 inline TUint32 TReadCapacityResponse::LBAddress()
321 return TUint32(AtC(0)<<24) | (AtC(1)<<16) | AtC(2)<<8 | AtC(3);
325 inline TUint32 TReadCapacityResponse::BlockLength()
327 return TUint32(AtC(4)<<24) | (AtC(5)<<16) | AtC(6)<<8 | AtC(7);