author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 11 May 2010 17:28:22 +0300 | |
branch | RCL_3 |
changeset 110 | c734af59ce98 |
parent 87 | 2f92ad2dc5db |
permissions | -rw-r--r-- |
87
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
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 |
// |
|
15 |
||
16 |
/** |
|
17 |
@file |
|
18 |
@internalTechnology |
|
19 |
*/ |
|
20 |
||
21 |
#ifndef CSCSIPROTOCOL_H |
|
22 |
#define CSCSIPROTOCOL_H |
|
23 |
||
24 |
class CMassStorageFsm; |
|
25 |
||
26 |
class TSbcClientInterface; |
|
27 |
||
28 |
class RMediaChangeNotifier |
|
29 |
{ |
|
30 |
public: |
|
31 |
RMediaChangeNotifier(); |
|
32 |
~RMediaChangeNotifier(); |
|
33 |
||
34 |
void Register(const RMessage2& aMessage); |
|
35 |
void DoNotifyL(); |
|
36 |
void DoCancelL(); |
|
37 |
||
38 |
private: |
|
87
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
39 |
void CompleteNotifierL(TInt aReason); |
0 | 40 |
|
41 |
private: |
|
42 |
/** Notification service */ |
|
43 |
RMessage2 iNotifier; |
|
44 |
/** Flag to indicate that media change notification is active */ |
|
45 |
TBool iRegistered; |
|
46 |
}; |
|
47 |
||
48 |
||
49 |
/** |
|
50 |
SCSI Protocol procedures |
|
51 |
*/ |
|
52 |
class CScsiProtocol: public CBase, public MProtocol, public MBlockTransferProtocol |
|
53 |
{ |
|
54 |
public: |
|
55 |
/** SCSI state */ |
|
56 |
enum TScsiState |
|
57 |
{ |
|
87
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
58 |
EEntry, |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
59 |
EMediaNotPresent, |
0 | 60 |
EConnected, |
61 |
EDisconnected |
|
62 |
}; |
|
63 |
||
64 |
static CScsiProtocol* NewL(TLun aLun, MTransport& aTransport); |
|
65 |
~CScsiProtocol(); |
|
66 |
private: |
|
67 |
void ConstructL(TLun aLun); |
|
68 |
CScsiProtocol(MTransport& aTransport); |
|
69 |
||
70 |
public: |
|
71 |
void InitialiseUnitL(); |
|
72 |
||
73 |
// Stop unit command to uninitialise the lun |
|
74 |
void UninitialiseUnitL(); |
|
75 |
||
76 |
// Read command to read the media |
|
77 |
void ReadL(TPos aPos, TDes8& aCopybuf, TInt aLen); |
|
78 |
||
79 |
// Write command to write to the media |
|
80 |
void WriteL(TPos aPos, TDesC8& aCopybuf, TInt aLen); |
|
81 |
||
82 |
// ReadCapacity command to find the capacity of the media |
|
83 |
void GetCapacityL(TCapsInfo& aCapsInfo); |
|
84 |
||
85 |
// unit testing |
|
86 |
void CreateSbcInterfaceL(TUint32 aBlockLen, TUint32 aLastLba); |
|
87 |
||
110
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
87
diff
changeset
|
88 |
TBool DoScsiReadyCheckEventL(); |
0 | 89 |
|
90 |
void NotifyChange(const RMessage2& aMessage); |
|
91 |
void ForceCompleteNotifyChangeL(); |
|
92 |
void CancelChangeNotifierL(); |
|
87
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
93 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
94 |
void SuspendL(); |
0 | 95 |
void ResumeL(); |
96 |
TBool IsConnected(); |
|
97 |
||
98 |
// Supported Mass Storage commands |
|
99 |
TInt MsInquiryL(); |
|
100 |
TInt MsTestUnitReadyL(); |
|
101 |
TInt MsStartStopUnitL(TBool aStart); |
|
102 |
TInt MsPreventAllowMediaRemovalL(TBool aPrevent); |
|
103 |
||
104 |
TInt MsReadCapacityL(); |
|
105 |
TInt MsModeSense10L(); |
|
106 |
TInt MsModeSense6L(); |
|
107 |
||
108 |
TInt MsRequestSenseL(); |
|
109 |
||
110 |
TBool MsIsSbcSet() const; |
|
111 |
TBool MsIsRemovableMedia() const; |
|
112 |
const TSenseInfo& MsSenseInfo() const; |
|
113 |
||
114 |
// MBlockTransferProtocol interface |
|
115 |
void BlockReadL(TPos aPos, TDes8& aBuf, TInt aLength); |
|
116 |
void BlockWriteL(TPos aPos, TDesC8& aBuf, TUint aOffset, TInt aLength); |
|
117 |
||
118 |
private: |
|
119 |
void ResetSbc(); |
|
120 |
||
87
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
121 |
TInt DoCheckConditionL(); |
0 | 122 |
|
123 |
TInt GetSystemWideSenseError(const TSenseInfo& aSenseInfo); |
|
124 |
TInt ProcessAsCodes(const TSenseInfo& aSenseInfo); |
|
125 |
||
126 |
private: |
|
127 |
||
128 |
/** State machine for device initialisation protocol */ |
|
129 |
CMassStorageFsm* iFsm; |
|
130 |
||
131 |
/** SCSI SPC interface methods */ |
|
132 |
TSpcClientInterface iSpcInterface; |
|
133 |
/** SCSI SBC interface methods */ |
|
134 |
TSbcClientInterface* iSbcInterface; |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
// buffers for block manipulation (for use in iSbcInterface) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
RBuf8 iHeadbuf; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
RBuf8 iTailbuf; |
0 | 138 |
|
139 |
// Logical Unit properties |
|
140 |
/** LU removable */ |
|
141 |
TBool iRemovableMedia; |
|
142 |
/** LU write protected */ |
|
143 |
TBool iWriteProtect; |
|
144 |
||
145 |
/** Result of the last SCSI command */ |
|
146 |
TSenseInfo iSenseInfo; |
|
147 |
||
148 |
/** State of the LUN represented by this object */ |
|
149 |
TScsiState iState; |
|
150 |
||
151 |
/** Notifier for media changes */ |
|
152 |
RMediaChangeNotifier iMediaChangeNotifier; |
|
153 |
}; |
|
154 |
||
155 |
||
156 |
/** |
|
157 |
Returns the state of the SBC interface. INQUIRY command is used to detect if |
|
158 |
device supports SBC and initialise the SBC interface. |
|
159 |
||
160 |
@return TBool ETrue is SBC interface is initialised |
|
161 |
*/ |
|
162 |
inline TBool CScsiProtocol::MsIsSbcSet() const |
|
163 |
{ |
|
164 |
return iSbcInterface ? ETrue : EFalse; |
|
165 |
} |
|
166 |
||
167 |
/** |
|
168 |
Returns the device removable property. MODE SENSE command is used to detect if |
|
169 |
the device is removable. |
|
170 |
||
171 |
@return TBool ETrue if device is removable |
|
172 |
*/ |
|
173 |
inline TBool CScsiProtocol::MsIsRemovableMedia() const |
|
174 |
{ |
|
175 |
return iRemovableMedia; |
|
176 |
} |
|
177 |
||
178 |
||
179 |
/** |
|
180 |
Helper to return current SenseInfo. SCSI REQUEST SENSE command sets the sense |
|
181 |
info. The protocol will retrieve device's sense info in the event of a SCSI |
|
182 |
command error. |
|
183 |
||
184 |
@return const TSenseInfo& |
|
185 |
*/ |
|
186 |
inline const TSenseInfo& CScsiProtocol::MsSenseInfo() const |
|
187 |
{ |
|
188 |
return iSenseInfo; |
|
189 |
} |
|
190 |
||
191 |
#endif // CSCSIPROTOCOL_H |