author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 11 May 2010 17:28:22 +0300 | |
branch | RCL_3 |
changeset 26 | c734af59ce98 |
parent 24 | 41f0cfe18c80 |
permissions | -rw-r--r-- |
24
41f0cfe18c80
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
6
diff
changeset
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 |
// scsiprimarycmds.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
/** |
|
19 |
@file |
|
20 |
@internalTechnology |
|
21 |
*/ |
|
22 |
||
23 |
#include <e32base.h> |
|
24 |
||
25 |
#include "msctypes.h" |
|
26 |
#include "debug.h" |
|
27 |
#include "msdebug.h" |
|
28 |
||
29 |
#include "mtransport.h" |
|
30 |
#include "mprotocol.h" |
|
31 |
||
32 |
#include "tscsiclientreq.h" |
|
33 |
#include "tscsiprimarycmds.h" |
|
34 |
||
35 |
||
36 |
// **** TEST UNIT READY **** |
|
37 |
TInt TScsiClientTestUnitReadyReq::EncodeRequestL(TDes8& aBuffer) const |
|
38 |
{ |
|
39 |
__MSFNSLOG |
|
40 |
__SCSIPRINT(_L("<-- SCSI TEST UNIT READY")); |
|
41 |
TInt length = TScsiClientReq::EncodeRequestL(aBuffer); |
|
42 |
return length; |
|
43 |
} |
|
44 |
||
45 |
||
46 |
// **** REQUEST SENSE **** |
|
47 |
void TScsiClientRequestSenseResp::DecodeSenseInfo(const TDesC8& aPtr) |
|
48 |
{ |
|
49 |
__MSFNSLOG |
|
50 |
iResponseCode = static_cast<TResponseCode>(aPtr[0]); |
|
51 |
iSenseInfo.iSenseCode = aPtr[02]; |
|
52 |
iSenseInfo.iAdditional = aPtr[12]; |
|
53 |
iSenseInfo.iQualifier = aPtr[13]; |
|
54 |
} |
|
55 |
||
56 |
||
57 |
void TScsiClientRequestSenseResp::DecodeL(const TDesC8& aPtr) |
|
58 |
{ |
|
59 |
__MSFNSLOG |
|
60 |
__SCSIPRINT(_L("--> SCSI REQUEST SENSE")); |
|
61 |
if (aPtr.Length() < KResponseLength) |
|
62 |
{ |
|
63 |
// Handle short data. |
|
64 |
// The data not transferred is assumed to be zero. |
|
65 |
||
66 |
// Create full size buffer |
|
67 |
TBuf8<KResponseLength> buffer; |
|
68 |
||
69 |
// Copy data into buffer |
|
70 |
buffer = aPtr; |
|
71 |
// Fill remainder with 0's |
|
72 |
buffer.AppendFill(0, KResponseLength - aPtr.Length()); |
|
73 |
||
74 |
DecodeSenseInfo(buffer); |
|
75 |
} |
|
76 |
else |
|
77 |
{ |
|
78 |
DecodeSenseInfo(aPtr); |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
||
83 |
// **** INQUIRY **** |
|
84 |
void TScsiClientInquiryResp::DecodeInquiry(const TDesC8& aPtr) |
|
85 |
{ |
|
86 |
__MSFNSLOG |
|
87 |
iPeripheralInfo.iRemovable = (aPtr[1] & 0x80) ? ETrue : EFalse; |
|
88 |
||
89 |
iPeripheralInfo.iPeripheralQualifier = aPtr[0] >> 5; |
|
90 |
iPeripheralInfo.iPeripheralDeviceType = aPtr[0] & 0x1F; |
|
91 |
iPeripheralInfo.iVersion = aPtr[2]; |
|
92 |
iPeripheralInfo.iResponseDataFormat = aPtr[3] & 0x0F; |
|
93 |
||
94 |
TPtrC8 vendorId(&aPtr[8], 8); |
|
95 |
iPeripheralInfo.iIdentification.iVendorId.Copy(vendorId); |
|
96 |
||
97 |
TPtrC8 productId(&aPtr[16], 16); |
|
98 |
iPeripheralInfo.iIdentification.iProductId.Copy(productId); |
|
99 |
||
100 |
TPtrC8 productRev(&aPtr[32], 4); |
|
101 |
iPeripheralInfo.iIdentification.iProductRev.Copy(productRev); |
|
102 |
} |
|
103 |
||
104 |
||
105 |
void TScsiClientInquiryResp::DecodeL(const TDesC8& aPtr) |
|
106 |
{ |
|
107 |
__MSFNSLOG |
|
108 |
__SCSIPRINT(_L("--> SCSI INQUIRY")); |
|
109 |
if (aPtr.Length() < KResponseLength) |
|
110 |
{ |
|
111 |
// Handle short data. |
|
112 |
// The data not transferred is assumed to be zero. |
|
113 |
||
114 |
// Create zeroed buffer |
|
115 |
TBuf8<KResponseLength> buffer; |
|
116 |
buffer.FillZ(KResponseLength); |
|
117 |
||
118 |
// Copy data into buffer |
|
119 |
buffer = aPtr; |
|
120 |
buffer.SetLength(KResponseLength); |
|
121 |
||
122 |
DecodeInquiry(buffer); |
|
123 |
} |
|
124 |
else |
|
125 |
{ |
|
126 |
DecodeInquiry(aPtr); |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
||
131 |
// **** PREVENT MEDIA REMOVAL **** |
|
132 |
TInt TScsiClientPreventMediaRemovalReq::EncodeRequestL(TDes8& aBuffer) const |
|
133 |
{ |
|
134 |
__MSFNSLOG |
|
135 |
__SCSIPRINT(_L("<-- SCSI PREVENT MEDIA REMOVAL")); |
|
136 |
TInt length = TScsiClientReq::EncodeRequestL(aBuffer); |
|
137 |
if (iPrevent) |
|
138 |
aBuffer[4] |= 0x01; |
|
139 |
return length; |
|
140 |
} |
|
141 |