author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 19 | 4a8fed1c0ef6 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// |
|
15 |
||
16 |
/** |
|
17 |
@file |
|
18 |
@internalTechnology |
|
19 |
*/ |
|
20 |
||
21 |
#include <e32base.h> |
|
22 |
#include "debug.h" |
|
23 |
#include "msdebug.h" |
|
24 |
#include "msctypes.h" |
|
25 |
#include "mscutils.h" |
|
26 |
||
27 |
#include "mtransport.h" |
|
28 |
#include "mprotocol.h" |
|
29 |
#include "tscsiclientreq.h" |
|
30 |
#include "tscsiblockcmds.h" |
|
31 |
||
32 |
||
33 |
// **** MODE SENSE (6) **** |
|
34 |
void TScsiClientModeSense6Resp::DecodeL(const TDesC8& aPtr) |
|
35 |
{ |
|
36 |
__MSFNSLOG |
|
37 |
__SCSIPRINT(_L("--> SCSI MODE SENSE (6)")); |
|
38 |
__SCSIPRINT1(_L("len=%d"), aPtr.Length()); |
|
39 |
// Mode Parameter List |
|
40 |
// SPC-3 7.4.2 |
|
41 |
// - Mode Parameter Header |
|
42 |
// - Block Descriptor(s) |
|
43 |
// - Mode Page(s) |
|
44 |
||
45 |
// Mode Parameter Header |
|
46 |
// SPC-3 7.4.3 |
|
47 |
// [0] Mode Data Length |
|
48 |
// [1] Medium Type |
|
49 |
// [2] Device-Specific Paramater |
|
50 |
// [3] Block Descriptor Length |
|
51 |
||
52 |
||
53 |
// validate length |
|
54 |
if (aPtr.Length() < KResponseLength) |
|
55 |
{ |
|
56 |
User::Leave(KErrGeneral); |
|
57 |
} |
|
58 |
||
59 |
TInt modeDataLength = aPtr[0]; |
|
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
if (aPtr.Length() - 1 > modeDataLength) |
0 | 61 |
{ |
62 |
User::Leave(KErrGeneral); |
|
63 |
} |
|
64 |
||
65 |
TInt mediumType = aPtr[1]; |
|
66 |
TUint8 deviceSpecificParameter = aPtr[2]; |
|
67 |
// TInt blockDescriptorLength = aPtr[3]; |
|
68 |
||
69 |
__SCSIPRINT2(_L("Medium Type=%d DSP=0x%x"), mediumType, deviceSpecificParameter); |
|
70 |
// [1] Medium Type |
|
71 |
// 0x00 for SBC |
|
72 |
if (mediumType == 0) |
|
73 |
{ |
|
74 |
// [2] Device specific parameter |
|
75 |
// SBC-3 6.3.1 |
|
76 |
// get the WP bit from the Device Specific parameters |
|
77 |
iWriteProtected = (deviceSpecificParameter & 0x80) ? ETrue : EFalse; |
|
78 |
} |
|
79 |
else |
|
80 |
{ |
|
81 |
// unsupported medium type |
|
82 |
iWriteProtected = EFalse; |
|
83 |
} |
|
84 |
||
85 |
// [3] Block Descriptor Length |
|
86 |
// 0x00 for no descriptors |
|
87 |
||
88 |
// No Block Descriptors |
|
89 |
||
90 |
// No Mode Pages |
|
91 |
||
92 |
} |
|
93 |
||
94 |
||
95 |
// **** MODE SENSE (10) **** |
|
96 |
void TScsiClientModeSense10Resp::DecodeL(const TDesC8& aPtr) |
|
97 |
{ |
|
98 |
__MSFNSLOG |
|
99 |
__SCSIPRINT(_L("--> SCSI MODE SENSE (10)")); |
|
100 |
__SCSIPRINT1(_L("len=%d"), aPtr.Length()); |
|
101 |
// Mode Parameter List |
|
102 |
// SPC-3 7.4.2 |
|
103 |
// - Mode Parameter Header |
|
104 |
// - Block Descriptor(s) |
|
105 |
// - Mode Page(s) |
|
106 |
||
107 |
// Mode Parameter Header |
|
108 |
// SPC-3 7.4.3 |
|
109 |
// [0] Mode Data Length |
|
110 |
// [1] Mode Data Length |
|
111 |
// [2] Medium Type |
|
112 |
// [3] Device-Specific Paramater |
|
113 |
// [4] Reserved |
|
114 |
// [5] Reserved |
|
115 |
// [6] Block Descriptor Length |
|
116 |
// [7] Block Descriptor Length |
|
117 |
||
118 |
// validate length |
|
119 |
if (aPtr.Length() < KResponseLength) |
|
120 |
{ |
|
121 |
User::Leave(KErrGeneral); |
|
122 |
} |
|
123 |
||
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
TInt modeDataLength = BigEndian::Get16(&aPtr[0]); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
if (aPtr.Length() - 2 > modeDataLength) |
0 | 126 |
{ |
127 |
User::Leave(KErrGeneral); |
|
128 |
} |
|
129 |
||
130 |
TInt mediumType = aPtr[2]; |
|
131 |
TUint8 deviceSpecificParameter = aPtr[3]; |
|
132 |
// TInt blockDescriptorLength = BigEndian::Get32(&aPtr[6]);; |
|
133 |
||
134 |
__SCSIPRINT2(_L("Medium Type=%d DSP=0x%x"), mediumType, deviceSpecificParameter); |
|
135 |
// [1] Medium Type |
|
136 |
// 0x00 for SBC |
|
137 |
if (mediumType == 0) |
|
138 |
{ |
|
139 |
// [2] Device specific parameter |
|
140 |
// SBC-3 6.3.1 |
|
141 |
// get the WP bit from the Device Specific parameters |
|
142 |
iWriteProtected = (deviceSpecificParameter & 0x80) ? ETrue : EFalse; |
|
143 |
} |
|
144 |
else |
|
145 |
{ |
|
146 |
// unsupported medium type |
|
147 |
iWriteProtected = EFalse; |
|
148 |
} |
|
149 |
||
150 |
// [3] Block Descriptor Length |
|
151 |
// 0x00 for no descriptors |
|
152 |
||
153 |
// No Block Descriptors |
|
154 |
||
155 |
// No Mode Pages |
|
156 |
||
157 |
} |
|
158 |
||
159 |
||
160 |
||
161 |
// **** READ CAPACITY (10) *** |
|
162 |
TInt TScsiClientReadCapacity10Req::EncodeRequestL(TDes8& aBuffer) const |
|
163 |
{ |
|
164 |
__MSFNSLOG |
|
165 |
__SCSIPRINT(_L("<-- READ CAPACITY 10")); |
|
166 |
TInt length = TScsiClientReq::EncodeRequestL(aBuffer); |
|
167 |
||
168 |
if (iLba) |
|
169 |
{ |
|
170 |
// PMI bit |
|
171 |
aBuffer[8] = 0x01; |
|
172 |
// LBA |
|
173 |
BigEndian::Put32(&aBuffer[2], iLba); |
|
174 |
} |
|
175 |
return length; |
|
176 |
} |
|
177 |
||
178 |
||
179 |
void TScsiClientReadCapacity10Resp::DecodeL(const TDesC8& aPtr) |
|
180 |
{ |
|
181 |
__MSFNSLOG |
|
182 |
__SCSIPRINT(_L("--> SCSI READ CAPACITY (10)")); |
|
183 |
iLba = BigEndian::Get32(&aPtr[0]); |
|
184 |
iBlockSize = BigEndian::Get32(&aPtr[4]); |
|
185 |
} |
|
186 |
||
187 |
||
188 |
// **** RdWr10 **** |
|
189 |
TInt TScsiClientRdWr10Req::EncodeRequestL(TDes8& aBuffer) const |
|
190 |
{ |
|
191 |
__MSFNSLOG |
|
192 |
TInt length = TScsiClientReq::EncodeRequestL(aBuffer); |
|
193 |
||
194 |
// PROTECT |
|
195 |
if (iProtect) |
|
196 |
aBuffer[1] = iProtect << 5; |
|
197 |
||
198 |
__SCSIPRINT2(_L("LBA=%08x LEN=%08x"), iLogicalBlockAddress, iBlockTransferLength); |
|
199 |
// LOGICAL BLOCK ADDRESS |
|
200 |
BigEndian::Put32(&aBuffer[2], iLogicalBlockAddress); |
|
201 |
// TRANSFER LENGTH |
|
202 |
BigEndian::Put16(&aBuffer[7], iBlockTransferLength); |
|
203 |
return length; |
|
204 |
} |
|
205 |
||
206 |
// **** READ (10) **** |
|
207 |
TInt TScsiClientRead10Req::EncodeRequestL(TDes8& aBuffer) const |
|
208 |
{ |
|
209 |
__MSFNSLOG |
|
210 |
__SCSIPRINT(_L("<-- SCSI READ (10)")); |
|
211 |
TInt length = TScsiClientRdWr10Req::EncodeRequestL(aBuffer); |
|
212 |
return length; |
|
213 |
} |
|
214 |
||
215 |
||
216 |
// **** START STOP UNIT **** |
|
217 |
TInt TScsiClientStartStopUnitReq::EncodeRequestL(TDes8& aBuffer) const |
|
218 |
{ |
|
219 |
__MSFNSLOG |
|
220 |
__SCSIPRINT(_L("--> SCSI START STOP UNIT")); |
|
221 |
TInt length = TScsiClientReq::EncodeRequestL(aBuffer); |
|
222 |
||
223 |
// byte 1 mask |
|
224 |
const TUint8 KImmedMask = 0x01; |
|
225 |
||
226 |
// byte 4 mask |
|
227 |
const TUint8 KStartMask = 0x01; |
|
228 |
const TUint8 KLoejMask = 0x02; |
|
229 |
||
230 |
if (iImmed) |
|
231 |
aBuffer[1] |= KImmedMask; |
|
232 |
if (iStart) |
|
233 |
aBuffer[4] |= KStartMask; |
|
234 |
if (iLoej) |
|
235 |
aBuffer[4] |= KLoejMask; |
|
236 |
return length; |
|
237 |
} |
|
238 |
||
239 |
||
240 |
// **** WRITE (10) **** |
|
241 |
TInt TScsiClientWrite10Req::EncodeRequestL(TDes8& aBuffer) const |
|
242 |
{ |
|
243 |
__MSFNSLOG |
|
244 |
__SCSIPRINT(_L("<-- SCSI WRITE 10")); |
|
245 |
||
246 |
TInt length = TScsiClientRdWr10Req::EncodeRequestL(aBuffer); |
|
247 |
return length; |
|
248 |
} |
|
249 |