os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/tscsiblockcmds.cpp
Update contrib.
1 // Copyright (c) 2008-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.
27 #include "mtransport.h"
28 #include "mprotocol.h"
29 #include "tscsiclientreq.h"
30 #include "tscsiblockcmds.h"
33 // **** MODE SENSE (6) ****
34 void TScsiClientModeSense6Resp::DecodeL(const TDesC8& aPtr)
37 __SCSIPRINT(_L("--> SCSI MODE SENSE (6)"));
38 __SCSIPRINT1(_L("len=%d"), aPtr.Length());
39 // Mode Parameter List
41 // - Mode Parameter Header
42 // - Block Descriptor(s)
45 // Mode Parameter Header
47 // [0] Mode Data Length
49 // [2] Device-Specific Paramater
50 // [3] Block Descriptor Length
54 if (aPtr.Length() < KResponseLength)
56 User::Leave(KErrGeneral);
59 TInt modeDataLength = aPtr[0];
60 if (aPtr.Length() - 1 < modeDataLength)
62 User::Leave(KErrGeneral);
65 TInt mediumType = aPtr[1];
66 TUint8 deviceSpecificParameter = aPtr[2];
67 // TInt blockDescriptorLength = aPtr[3];
69 __SCSIPRINT2(_L("Medium Type=%d DSP=0x%x"), mediumType, deviceSpecificParameter);
74 // [2] Device specific parameter
76 // get the WP bit from the Device Specific parameters
77 iWriteProtected = (deviceSpecificParameter & 0x80) ? ETrue : EFalse;
81 // unsupported medium type
82 iWriteProtected = EFalse;
85 // [3] Block Descriptor Length
86 // 0x00 for no descriptors
88 // No Block Descriptors
95 // **** MODE SENSE (10) ****
96 void TScsiClientModeSense10Resp::DecodeL(const TDesC8& aPtr)
99 __SCSIPRINT(_L("--> SCSI MODE SENSE (10)"));
100 __SCSIPRINT1(_L("len=%d"), aPtr.Length());
101 // Mode Parameter List
103 // - Mode Parameter Header
104 // - Block Descriptor(s)
107 // Mode Parameter Header
109 // [0] Mode Data Length
110 // [1] Mode Data Length
112 // [3] Device-Specific Paramater
115 // [6] Block Descriptor Length
116 // [7] Block Descriptor Length
119 if (aPtr.Length() < KResponseLength)
121 User::Leave(KErrGeneral);
124 TInt modeDataLength = BigEndian::Get32(&aPtr[0]);
125 if (aPtr.Length() - 2 < modeDataLength)
127 User::Leave(KErrGeneral);
130 TInt mediumType = aPtr[2];
131 TUint8 deviceSpecificParameter = aPtr[3];
132 // TInt blockDescriptorLength = BigEndian::Get32(&aPtr[6]);;
134 __SCSIPRINT2(_L("Medium Type=%d DSP=0x%x"), mediumType, deviceSpecificParameter);
139 // [2] Device specific parameter
141 // get the WP bit from the Device Specific parameters
142 iWriteProtected = (deviceSpecificParameter & 0x80) ? ETrue : EFalse;
146 // unsupported medium type
147 iWriteProtected = EFalse;
150 // [3] Block Descriptor Length
151 // 0x00 for no descriptors
153 // No Block Descriptors
161 // **** READ CAPACITY (10) ***
162 TInt TScsiClientReadCapacity10Req::EncodeRequestL(TDes8& aBuffer) const
165 __SCSIPRINT(_L("<-- READ CAPACITY 10"));
166 TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
173 BigEndian::Put32(&aBuffer[2], iLba);
179 void TScsiClientReadCapacity10Resp::DecodeL(const TDesC8& aPtr)
182 __SCSIPRINT(_L("--> SCSI READ CAPACITY (10)"));
183 iLba = BigEndian::Get32(&aPtr[0]);
184 iBlockSize = BigEndian::Get32(&aPtr[4]);
189 TInt TScsiClientRdWr10Req::EncodeRequestL(TDes8& aBuffer) const
192 TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
196 aBuffer[1] = iProtect << 5;
198 __SCSIPRINT2(_L("LBA=%08x LEN=%08x"), iLogicalBlockAddress, iBlockTransferLength);
199 // LOGICAL BLOCK ADDRESS
200 BigEndian::Put32(&aBuffer[2], iLogicalBlockAddress);
202 BigEndian::Put16(&aBuffer[7], iBlockTransferLength);
206 // **** READ (10) ****
207 TInt TScsiClientRead10Req::EncodeRequestL(TDes8& aBuffer) const
210 __SCSIPRINT(_L("<-- SCSI READ (10)"));
211 TInt length = TScsiClientRdWr10Req::EncodeRequestL(aBuffer);
216 // **** START STOP UNIT ****
217 TInt TScsiClientStartStopUnitReq::EncodeRequestL(TDes8& aBuffer) const
220 __SCSIPRINT(_L("--> SCSI START STOP UNIT"));
221 TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
224 const TUint8 KImmedMask = 0x01;
227 const TUint8 KStartMask = 0x01;
228 const TUint8 KLoejMask = 0x02;
231 aBuffer[1] |= KImmedMask;
233 aBuffer[4] |= KStartMask;
235 aBuffer[4] |= KLoejMask;
240 // **** WRITE (10) ****
241 TInt TScsiClientWrite10Req::EncodeRequestL(TDes8& aBuffer) const
244 __SCSIPRINT(_L("<-- SCSI WRITE 10"));
246 TInt length = TScsiClientRdWr10Req::EncodeRequestL(aBuffer);