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: // TTestScsiTransport sl@0: // setup read data sl@0: // sl@0: // sl@0: sl@0: inline void TTestScsiTransport::SetupReadData (TPtr8& aData) sl@0: { sl@0: __FNLOG ("TTestScsiTransport::SetupReadData"); sl@0: sl@0: // copy data from the begining of a buffer, always sl@0: iReadLength = aData.Length(); sl@0: aData.Copy (&iBufRead[0], aData.Length()); sl@0: } sl@0: sl@0: /** setup write data */ sl@0: inline void TTestScsiTransport::SetupWriteData (TPtrC8& aData) sl@0: { sl@0: __FNLOG ("TTestScsiTransport::SetupWriteData"); sl@0: iBufWrite.Set(aData); sl@0: } sl@0: sl@0: /** start a transport */ sl@0: inline TInt TTestScsiTransport::Start() sl@0: { sl@0: __FNLOG ("TTestScsiTransport::Start"); sl@0: // not implemented sl@0: ASSERT(EFalse); sl@0: return 0; sl@0: } sl@0: sl@0: /** stop a transport */ sl@0: inline TInt TTestScsiTransport::Stop() sl@0: { sl@0: __FNLOG ("TTestScsiTransport::Stop"); sl@0: // not implemented sl@0: ASSERT(EFalse); sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: inline void TTestScsiTransport::RegisterProtocol(MProtocolBase& aProtocol) sl@0: { sl@0: __FNLOG ("TTestScsiTransport::RegisterProtocol\n"); sl@0: iProtocol = &aProtocol; sl@0: } sl@0: sl@0: inline TInt TTestScsiTransport::BytesAvailable() sl@0: { sl@0: __FNLOG ("TTestScsiTransport::BytesAvailable\n"); sl@0: TUint retVal = iReadLength; sl@0: iReadLength = 0; sl@0: return(retVal); sl@0: } sl@0: sl@0: inline TInt TTestScsiTransport::InitialiseTransportL(TInt /*aTransportLddFlag*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline void TTestScsiTransport::GetCommandBufPtr(TPtr8& aDes, TUint aLength) sl@0: { sl@0: __FNLOG ("TTestScsiTransport::GetCommandBufPtr"); sl@0: aDes.Set((TUint8*)(iBufCmd.Ptr()), aLength, aLength); sl@0: } sl@0: sl@0: inline void TTestScsiTransport::GetReadDataBufPtr(TPtr8& aDes) sl@0: { sl@0: __FNLOG ("TTestScsiTransport::GetReadDataBufPtr"); sl@0: aDes.Set((TUint8*)(iBufRead.Ptr()),KMaxBufSize, KMaxBufSize); sl@0: } sl@0: sl@0: inline void TTestScsiTransport::GetWriteDataBufPtr(TPtrC8& aDes) sl@0: { sl@0: __FNLOG ("TTestScsiTransport::GetWriteDataBufPtr"); sl@0: aDes.Set((TUint8*)(iBufRead.Ptr()),iReadLength); sl@0: } sl@0: sl@0: inline void TTestScsiTransport::SetupReadData(TUint aLength) sl@0: { sl@0: __FNLOG ("TTestScsiTransport::SetupReadData"); sl@0: iReadLength = aLength; sl@0: } sl@0: sl@0: inline void TTestScsiTransport::ProcessReadData(TAny* /*aAddress*/) sl@0: { sl@0: return; sl@0: } sl@0: // sl@0: // CTestProxyDrive sl@0: // sl@0: inline TInt CTestProxyDrive::Caps(TDes8& anInfo) sl@0: { sl@0: anInfo.Copy(TLocalDriveCapsV4Buf(iCaps)); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: /** sl@0: A private structure that, when Connected, holds a pair of references to sl@0: the CProxyDrive and the corresponding TBusLocalDrive's Media Changed flag. sl@0: */ sl@0: struct CMassStorageDrive::CLocalDriveRef : public CBase sl@0: { sl@0: CLocalDriveRef(CProxyDrive& aProxyDrive, TBool& aMediaChanged) sl@0: : iProxyDrive(aProxyDrive), iMediaChanged(aMediaChanged) sl@0: { sl@0: } sl@0: CProxyDrive& iProxyDrive; sl@0: TBool& iMediaChanged; sl@0: TDriveState iDriveState; sl@0: }; sl@0: sl@0: sl@0: // sl@0: // CScsiTest sl@0: // sl@0: inline TBool CScsiTest::DecodePacket(TPtrC8& aCmd) sl@0: { sl@0: return iScsiProt->DecodePacket(aCmd, TestLun); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: // command wrappers sl@0: // sl@0: TRequestSenseData::TRequestSenseData(TPtrC8 aData) sl@0: : iData(aData) sl@0: // SCSI-2 spec. p.136 sl@0: { sl@0: ASSERT((iData.Length() >= 17) && (iData[7] + 8 == iData.Length())); sl@0: } sl@0: sl@0: inline TInt8 TRequestSenseData::Key() sl@0: { sl@0: return static_cast(iData[2] & 0x0F); sl@0: } sl@0: sl@0: inline TInt8 TRequestSenseData::AdditionalCode() sl@0: { sl@0: return iData[12]; sl@0: } sl@0: sl@0: inline TInt8 TRequestSenseData::AdditionalCodeQualifier() sl@0: { sl@0: return iData[13]; sl@0: } sl@0: sl@0: sl@0: // sl@0: // class TInquiryData sl@0: // sl@0: TInquiryData::TInquiryData(TPtrC8 aData) sl@0: { sl@0: iData.Set(aData); sl@0: } sl@0: sl@0: inline TInt8 TInquiryData::DeviceType() // 5 lower bits in 1st byte sl@0: { sl@0: return static_cast(iData[0] & 0x1F); sl@0: } sl@0: sl@0: inline TBool TInquiryData::RMB() // high bit in 2nd byte sl@0: { sl@0: return ((iData[1] & 0x80) == 0x80); sl@0: } sl@0: sl@0: inline TInt8 TInquiryData::Version() // 3rd byte sl@0: { sl@0: return iData[2]; sl@0: } sl@0: sl@0: inline TInt8 TInquiryData::RespDataFrmt() // 4th byte sl@0: { sl@0: return (iData[3]); sl@0: } sl@0: sl@0: inline TPtr8 TInquiryData::VendorId() sl@0: { sl@0: return TPtr8(const_cast(&iData[8]), 8, 8); sl@0: } sl@0: sl@0: inline TPtr8 TInquiryData::ProductId() sl@0: { sl@0: return TPtr8(const_cast(&iData[16]), 16, 16); sl@0: } sl@0: sl@0: inline TPtr8 TInquiryData::RevisionLevel() sl@0: { sl@0: return TPtr8(const_cast(&iData[32]), 4, 4); sl@0: } sl@0: sl@0: inline TInt8 TInquiryData::PeripheralQualifier() // 3 highest bits in 1st byte sl@0: { sl@0: return static_cast((iData[0] & 0xE0) >> 5); sl@0: } sl@0: sl@0: inline TInt8 TInquiryData::Length() // length of Inquiry data sl@0: { sl@0: return static_cast(iData[4] + 4); sl@0: } sl@0: sl@0: // sl@0: // class TReadWrite10Cmd sl@0: // sl@0: /** set transfer length */ sl@0: inline void TReadWrite10Cmd::SetTransferLength(TUint16 aLength) sl@0: { sl@0: iCmd[8] = static_cast((aLength & 0xFF00) >> 8); sl@0: iCmd[9] = static_cast(aLength & 0x00FF); sl@0: } sl@0: sl@0: /** set protect flag */ sl@0: inline void TReadWrite10Cmd::SetProtect(TUint8 aProtect) sl@0: { sl@0: // Note: used only 3 lower bits sl@0: // clear flag and set a new one sl@0: iCmd[2] = static_cast((iCmd[2] & 0x1F) | (aProtect << 5)); sl@0: } sl@0: sl@0: /** setup read command */ sl@0: inline void TReadWrite10Cmd::SetRead() sl@0: { sl@0: iCmd[1] = 0x28; // READ(10) cmd sl@0: } sl@0: sl@0: /** setup write command */ sl@0: inline void TReadWrite10Cmd::SetWrite() sl@0: { sl@0: iCmd[1] = 0x2A; // WRITE(10) cmd sl@0: } sl@0: sl@0: /** setup verify command */ sl@0: inline void TReadWrite10Cmd::SetVerify() sl@0: { sl@0: iCmd[1] = 0x2F; // VERIFY(10) cmd sl@0: } sl@0: sl@0: /** set BYTCHK fiels. Valid for VERIFY10 cmd only */ sl@0: inline void TReadWrite10Cmd::SetBytChk (TBool aSet) sl@0: { sl@0: if (0x2F == iCmd[1]) // if VERIFY(10) sl@0: { sl@0: iCmd[2] = static_cast((iCmd[2] & 0xFD) | (aSet << 1)); sl@0: } sl@0: } sl@0: sl@0: /** c'or */ sl@0: inline TModeSenseCmd::TModeSenseCmd() sl@0: { sl@0: iCmd.FillZ (iCmd.MaxLength()); sl@0: sl@0: iCmd[0] = static_cast(iCmd.MaxLength()-1); // size of the Cmd sl@0: iCmd[1] = 0x1A; sl@0: } sl@0: sl@0: /** set PC, 2 bits field */ sl@0: inline void TModeSenseCmd::SetPC (TUint8 aPc) sl@0: { sl@0: iCmd[3] = static_cast((iCmd[3] & 0x3F) | (aPc << 6)); sl@0: } sl@0: sl@0: /** set page code, 6 bits field */ sl@0: inline void TModeSenseCmd::SetPageCode (TUint8 aPageCode) sl@0: { sl@0: iCmd[3] = static_cast((iCmd[3] & 0xC0) | aPageCode); sl@0: } sl@0: sl@0: sl@0: inline TInquiryCmd::TInquiryCmd() sl@0: { sl@0: iCmd.FillZ (iCmd.MaxLength()); sl@0: iCmd[0] = static_cast(iCmd.MaxLength()-1); // size of a command itself sl@0: iCmd[1] = 0x12; // inquiry operation code sl@0: iCmd[5] = 36; // min required allocation length sl@0: } sl@0: sl@0: inline TTestUnitReadyCmd::TTestUnitReadyCmd() sl@0: { sl@0: iCmd.FillZ (iCmd.MaxLength()); sl@0: iCmd[0] = static_cast(iCmd.MaxLength()-1); // size of a command itself sl@0: iCmd[1] = 0x00; // TEST UNIT READY command sl@0: } sl@0: sl@0: inline TMediaRemovalCmd::TMediaRemovalCmd() sl@0: { sl@0: iCmd.FillZ (iCmd.MaxLength()); sl@0: iCmd[0] = static_cast(iCmd.MaxLength()-1); // size of a command itself sl@0: iCmd[1] = 0x1E; // PREVENT ALLOW MEDIUM REMOVAL command sl@0: } sl@0: sl@0: inline TReadCapacityCmd::TReadCapacityCmd() sl@0: { sl@0: iCmd.FillZ (iCmd.MaxLength()); sl@0: iCmd[0] = static_cast(iCmd.MaxLength()-1); // size of a command itself sl@0: iCmd[1] = 0x25; // READ CAPACITY command sl@0: } sl@0: sl@0: inline TReadCapacityResponse::TReadCapacityResponse(const TDesC8 &aDes) sl@0: : TPtrC8(aDes) sl@0: { sl@0: } sl@0: sl@0: /** accessor */ sl@0: inline TUint32 TReadCapacityResponse::LBAddress() sl@0: { sl@0: return TUint32(AtC(0)<<24) | (AtC(1)<<16) | AtC(2)<<8 | AtC(3); sl@0: } sl@0: sl@0: /** accessor */ sl@0: inline TUint32 TReadCapacityResponse::BlockLength() sl@0: { sl@0: return TUint32(AtC(4)<<24) | (AtC(5)<<16) | AtC(6)<<8 | AtC(7); sl@0: } sl@0: