297
|
1 |
// Copyright (c) 2009-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 |
//
|
|
15 |
|
|
16 |
|
|
17 |
#include <e32def.h>
|
|
18 |
#include <e32cmn.h>
|
|
19 |
#include <e32des8.h>
|
|
20 |
#include <e32std.h>
|
|
21 |
#include <e32base.h>
|
|
22 |
|
|
23 |
#include "msctypes.h"
|
|
24 |
#include "tscsiserverreq.h"
|
|
25 |
#include "tscsiservercmds.h"
|
|
26 |
#include "debug.h"
|
|
27 |
|
|
28 |
TScsiServerReq* TScsiServerReq::CreateL(TScsiServerReq::TOperationCode aOperationCode,
|
|
29 |
TDesC8& aDes)
|
|
30 |
{
|
|
31 |
TScsiServerReq* req = NULL;
|
|
32 |
|
|
33 |
__SCSIPRINT1(_L("SCSI CMD 0x%x"), aOperationCode);
|
|
34 |
|
|
35 |
switch (aOperationCode)
|
|
36 |
{
|
|
37 |
case ETestUnitReady:
|
|
38 |
{
|
|
39 |
req = new (ELeave) TScsiServerTestUnitReadyReq;
|
|
40 |
}
|
|
41 |
break;
|
|
42 |
case ERequestSense:
|
|
43 |
{
|
|
44 |
req = new (ELeave) TScsiServerRequestSenseReq;
|
|
45 |
}
|
|
46 |
break;
|
|
47 |
case EInquiry:
|
|
48 |
{
|
|
49 |
req = new (ELeave) TScsiServerInquiryReq;
|
|
50 |
}
|
|
51 |
break;
|
|
52 |
case EModeSense6:
|
|
53 |
{
|
|
54 |
req = new (ELeave) TScsiServerModeSense6Req;
|
|
55 |
}
|
|
56 |
break;
|
|
57 |
case EStartStopUnit:
|
|
58 |
{
|
|
59 |
req = new (ELeave) TScsiServerStartStopUnitReq;
|
|
60 |
}
|
|
61 |
break;
|
|
62 |
case EPreventMediaRemoval:
|
|
63 |
{
|
|
64 |
req = new (ELeave) TScsiServerPreventMediaRemovalReq;
|
|
65 |
}
|
|
66 |
break;
|
|
67 |
case EReadFormatCapacities:
|
|
68 |
{
|
|
69 |
req = new (ELeave) TScsiServerReadFormatCapacitiesReq;
|
|
70 |
}
|
|
71 |
break;
|
|
72 |
case EReadCapacity10:
|
|
73 |
{
|
|
74 |
req = new (ELeave) TScsiServerReadCapacity10Req;
|
|
75 |
}
|
|
76 |
break;
|
|
77 |
|
|
78 |
case ERead10:
|
|
79 |
{
|
|
80 |
req = new (ELeave) TScsiServerRead10Req;
|
|
81 |
}
|
|
82 |
break;
|
|
83 |
case EWrite10:
|
|
84 |
{
|
|
85 |
req = new (ELeave) TScsiServerWrite10Req;
|
|
86 |
}
|
|
87 |
break;
|
|
88 |
default:
|
|
89 |
{
|
|
90 |
__SCSIPRINT(_L("NOT SUPPORTED!"));
|
|
91 |
User::Leave(KErrNotSupported);
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
if (req)
|
|
96 |
{
|
|
97 |
CleanupStack::PushL(req);
|
|
98 |
// got a class into which it can parse itself from the protocol
|
|
99 |
req->DecodeL(aDes);
|
|
100 |
CleanupStack::Pop(req);
|
|
101 |
}
|
|
102 |
return req;
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
void TScsiServerReq::DecodeL(const TDesC8& aPtr)
|
|
107 |
{
|
|
108 |
// OPERATION CODE
|
297
|
109 |
iOperationCode = static_cast<TOperationCode>(aPtr[0]);
|
0
|
110 |
|
|
111 |
// CONTROL byte
|
|
112 |
TInt length = 0;
|
|
113 |
switch (GetGroupCode())
|
|
114 |
{
|
|
115 |
case 0:
|
|
116 |
// 6 byte commands
|
|
117 |
length = 6;
|
|
118 |
break;
|
|
119 |
case 1:
|
|
120 |
case 2:
|
|
121 |
// 10 byte commands
|
|
122 |
length = 10;
|
|
123 |
break;
|
|
124 |
default:
|
|
125 |
User::Leave(KErrNotSupported);
|
|
126 |
break;
|
|
127 |
}
|
|
128 |
|
|
129 |
|
|
130 |
// CONTROL byte is last element of Command
|
|
131 |
TUint8 control = aPtr[length - 1];
|
|
132 |
|
|
133 |
iLink = control & 0x04 ? ETrue : EFalse;
|
|
134 |
iNaca = control & 0x01 ? ETrue : EFalse;
|
|
135 |
}
|