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 |
// 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 |
__SCSIPRINT(_L("--> SCSI INQUIRY"));
|
|
88 |
iPeripheralInfo.iRemovable = (aPtr[1] & 0x80) ? ETrue : EFalse;
|
|
89 |
|
|
90 |
iPeripheralInfo.iPeripheralQualifier = aPtr[0] >> 5;
|
|
91 |
iPeripheralInfo.iPeripheralDeviceType = aPtr[0] & 0x1F;
|
|
92 |
iPeripheralInfo.iVersion = aPtr[2];
|
|
93 |
iPeripheralInfo.iResponseDataFormat = aPtr[3] & 0x0F;
|
|
94 |
|
|
95 |
TPtrC8 vendorId(&aPtr[8], 8);
|
|
96 |
iPeripheralInfo.iIdentification.iVendorId.Copy(vendorId);
|
|
97 |
|
|
98 |
TPtrC8 productId(&aPtr[16], 16);
|
|
99 |
iPeripheralInfo.iIdentification.iProductId.Copy(productId);
|
|
100 |
|
|
101 |
TPtrC8 productRev(&aPtr[32], 4);
|
|
102 |
iPeripheralInfo.iIdentification.iProductRev.Copy(productRev);
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
void TScsiClientInquiryResp::DecodeL(const TDesC8& aPtr)
|
|
107 |
{
|
|
108 |
__MSFNSLOG
|
|
109 |
__SCSIPRINT(_L("--> SCSI INQUIRY"));
|
|
110 |
if (aPtr.Length() < KResponseLength)
|
|
111 |
{
|
|
112 |
// Handle short data.
|
|
113 |
// The data not transferred is assumed to be zero.
|
|
114 |
|
|
115 |
// Create zeroed buffer
|
|
116 |
TBuf8<KResponseLength> buffer;
|
|
117 |
buffer.FillZ(KResponseLength);
|
|
118 |
|
|
119 |
// Copy data into buffer
|
|
120 |
buffer = aPtr;
|
|
121 |
buffer.SetLength(KResponseLength);
|
|
122 |
|
|
123 |
DecodeInquiry(buffer);
|
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
|
127 |
DecodeInquiry(aPtr);
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
|
|
132 |
// **** PREVENT MEDIA REMOVAL ****
|
|
133 |
TInt TScsiClientPreventMediaRemovalReq::EncodeRequestL(TDes8& aBuffer) const
|
|
134 |
{
|
|
135 |
__MSFNSLOG
|
|
136 |
__SCSIPRINT(_L("<-- SCSI PREVENT MEDIA REMOVAL"));
|
|
137 |
TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
|
|
138 |
if (iPrevent)
|
|
139 |
aBuffer[4] |= 0x01;
|
|
140 |
return length;
|
|
141 |
}
|
|
142 |
|