author | hgs |
Tue, 02 Nov 2010 15:29:23 +0000 | |
changeset 300 | 1d28c8722707 |
parent 271 | dc268b18d709 |
permissions | -rw-r--r-- |
124 | 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 |
// Implements a Session of a Symbian OS server for the RUsbMassStorage API |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
/** |
|
19 |
@file |
|
20 |
@internalTechnology |
|
21 |
*/ |
|
22 |
||
23 |
#include <e32base.h> |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
|
0 | 25 |
#include "msctypes.h" |
26 |
#include "shared.h" |
|
27 |
#include "msgservice.h" |
|
28 |
#include "cusbhostmslogicalunit.h" |
|
29 |
#include "cusbhostmsdevice.h" |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#include "cusbhostmssession.h" |
0 | 31 |
#include "cusbhostmsdevicethread.h" |
300 | 32 |
|
33 |
#include "OstTraceDefinitions.h" |
|
34 |
#ifdef OST_TRACE_COMPILER_IN_USE |
|
35 |
#include "cusbhostmsdevicethreadTraces.h" |
|
36 |
#endif |
|
0 | 37 |
|
38 |
/** |
|
39 |
Constructor |
|
40 |
*/ |
|
41 |
TDeviceHandler::TDeviceHandler(CUsbHostMsDevice& aDevice) |
|
42 |
: iDevice(aDevice) |
|
43 |
{ |
|
44 |
} |
|
45 |
||
46 |
||
47 |
/** |
|
48 |
Services messages directed to a device. Messages associated with a single |
|
49 |
Logical Unit contained by the device are forwarded to the Logical Unit |
|
50 |
Handler. |
|
51 |
||
52 |
@param aMessage |
|
53 |
*/ |
|
54 |
void TDeviceHandler::HandleMessageL(const RMessage2& aMessage) |
|
55 |
{ |
|
56 |
TLun lun = iDevice.GetAndSetLunL(aMessage); |
|
57 |
||
300 | 58 |
switch (aMessage.Function()) |
59 |
{ |
|
60 |
case EUsbHostMsSuspendLun: |
|
0 | 61 |
iDevice.SuspendLunL(lun); |
300 | 62 |
break; |
0 | 63 |
case EUsbHostMsUnRegisterLun: |
64 |
iDevice.RemoveLunL(lun); |
|
65 |
break; |
|
66 |
default: |
|
67 |
// Try Logical Unit Handler |
|
68 |
CUsbHostMsLogicalUnit& lu = iDevice.GetLuL(lun); |
|
69 |
TLogicalUnitHandler luHandler(lu); |
|
70 |
luHandler.HandleMessageL(aMessage); |
|
300 | 71 |
break; |
72 |
} |
|
0 | 73 |
} |
74 |
||
75 |
||
76 |
/** |
|
77 |
Constructor |
|
78 |
||
79 |
@param aLu Reference to the logical unit object |
|
80 |
*/ |
|
81 |
TLogicalUnitHandler::TLogicalUnitHandler(CUsbHostMsLogicalUnit& aLu) |
|
82 |
: iLu(aLu) |
|
83 |
{ |
|
84 |
} |
|
85 |
||
86 |
||
87 |
/** |
|
88 |
Services messages directed to a specific Logical Unit. Unrecognized messages |
|
89 |
will cause a PANIC. |
|
90 |
||
91 |
@param aMessage |
|
92 |
*/ |
|
93 |
void TLogicalUnitHandler::HandleMessageL(const RMessage2& aMessage) |
|
300 | 94 |
{ |
95 |
switch (aMessage.Function()) |
|
96 |
{ |
|
97 |
case EUsbHostMsNotifyChange: |
|
0 | 98 |
iLu.NotifyChange(aMessage); |
300 | 99 |
break; |
100 |
case EUsbHostMsCancelChangeNotifier: |
|
0 | 101 |
iLu.CancelChangeNotifierL(); |
300 | 102 |
break; |
103 |
case EUsbHostMsForceRemount: |
|
0 | 104 |
iLu.ForceCompleteNotifyChangeL(); |
300 | 105 |
break; |
106 |
case EUsbHostMsRead: |
|
0 | 107 |
iLu.ReadL(aMessage); |
300 | 108 |
break; |
109 |
case EUsbHostMsWrite: |
|
0 | 110 |
iLu.WriteL(aMessage); |
300 | 111 |
break; |
112 |
case EUsbHostMsErase: |
|
0 | 113 |
iLu.EraseL(aMessage); |
300 | 114 |
break; |
115 |
case EUsbHostMsCapacity: |
|
0 | 116 |
iLu.CapsL(aMessage); |
300 | 117 |
break; |
118 |
default: |
|
119 |
aMessage.Panic(KUsbHostMsSrvPncCat, EUsbMsPanicIllegalIPC); |
|
120 |
break; |
|
121 |
} |
|
122 |
} |
|
0 | 123 |
|
124 |
||
125 |
void CUsbHostMsDeviceThread::DoStartServerL(TAny* aPtr) |
|
126 |
{ |
|
127 |
CActiveScheduler* s = new(ELeave) CActiveScheduler; |
|
128 |
CActiveScheduler::Install(s); |
|
129 |
||
300 | 130 |
CUsbHostMsDeviceThread* iThread = (CUsbHostMsDeviceThread*)aPtr; |
131 |
CActiveScheduler::Add(iThread); |
|
0 | 132 |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
iThread->Start(); |
0 | 134 |
|
300 | 135 |
RThread::Rendezvous(KErrNone); |
0 | 136 |
|
300 | 137 |
// |
0 | 138 |
// Ready to run |
139 |
CActiveScheduler::Start(); |
|
140 |
||
141 |
// |
|
142 |
// Cleanup the scheduler |
|
300 | 143 |
delete s; |
0 | 144 |
} |
145 |
||
146 |
||
147 |
TInt CUsbHostMsDeviceThread::Entry(TAny* aPtr) |
|
300 | 148 |
{ |
149 |
CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
0 | 150 |
if (!cleanup) |
151 |
{ |
|
152 |
return KErrNoMemory; |
|
153 |
} |
|
154 |
||
155 |
TRAPD(error, DoStartServerL(aPtr)); |
|
156 |
delete cleanup; |
|
157 |
return error; |
|
300 | 158 |
} |
0 | 159 |
|
160 |
||
161 |
void CUsbHostMsDeviceThread::RunL() |
|
300 | 162 |
{ |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
// called on completion of MessageRequest() or Resume() |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
User::LeaveIfError(iStatus.Int()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
|
300 | 166 |
Lock(); |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
if (iUsbHostMsDevice) |
0 | 168 |
{ |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
169 |
if (iUsbHostMsDevice->IsSuspended()) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
{ |
271 | 171 |
|
300 | 172 |
RMessage2 msg = iRMessage2[iDequeueIndex]; |
271 | 173 |
if (msg.Function() != EUsbHostMsSuspendLun) |
174 |
{ |
|
300 | 175 |
// request resume |
271 | 176 |
Unlock(); |
177 |
iUsbHostMsDevice->Resume(iStatus); |
|
178 |
SetActive(); |
|
179 |
return; |
|
300 | 180 |
} |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
} |
0 | 182 |
} |
183 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
// process message queue |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
RMessage2 msg = iRMessage2[iDequeueIndex]; |
0 | 186 |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
iDequeueIndex++; |
0 | 188 |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
if(iDequeueIndex >= KMaxNumMessage) |
300 | 190 |
iDequeueIndex = 0; |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
if(iQueueFull) |
300 | 192 |
iQueueFull = EFalse; |
0 | 193 |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
HandleMessage(msg); |
0 | 195 |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
if ((iQueueIndex != iDequeueIndex) || iQueueFull) |
300 | 197 |
{ |
198 |
// self completion |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
TRequestStatus* status = &iStatus; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
User::RequestComplete(status, KErrNone); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
SetActive(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
else |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
iUsbHostMsSession.MessageRequest(iStatus); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
SetActive(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
Unlock(); |
300 | 209 |
} |
0 | 210 |
|
211 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
void CUsbHostMsDeviceThread::DoCancel() |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
TRequestStatus* status = &iStatus; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
User::RequestComplete(status, KErrCancel); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
TInt CUsbHostMsDeviceThread::RunError(TInt aError) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
{ |
300 | 221 |
OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_10, |
222 |
">> HOST RunError returning %d", aError); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
return KErrNone; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
226 |
|
0 | 227 |
TInt CUsbHostMsDeviceThread::QueueMsg(const RMessage2& aMsg) |
300 | 228 |
{ |
229 |
if (iQueueFull) |
|
230 |
{ |
|
231 |
return KErrOverflow; |
|
232 |
} |
|
0 | 233 |
|
234 |
Lock(); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
|
300 | 236 |
iRMessage2[iQueueIndex] = aMsg; |
237 |
iQueueIndex++; |
|
0 | 238 |
|
300 | 239 |
if (iQueueIndex >= KMaxNumMessage) |
240 |
{ |
|
241 |
iQueueIndex = 0; |
|
242 |
} |
|
0 | 243 |
|
300 | 244 |
if (iQueueIndex == iDequeueIndex) |
245 |
{ |
|
246 |
iQueueFull = ETrue; |
|
247 |
} |
|
248 |
Unlock(); |
|
249 |
return KErrNone; |
|
250 |
} |
|
0 | 251 |
|
252 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
CUsbHostMsDeviceThread::CUsbHostMsDeviceThread(CUsbHostMsSession& aUsbHostMsSession, TUint aToken) |
300 | 254 |
: CActive(EPriorityStandard), |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
iUsbHostMsSession(aUsbHostMsSession), |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
256 |
iQueueFull(EFalse) |
300 | 257 |
{ |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
258 |
TBuf<32> nameBuf; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
259 |
nameBuf.Format(_L("Host Ms ThreadMutex%8x"), aToken); |
300 | 260 |
iMutex.CreateGlobal(nameBuf,EOwnerProcess); |
261 |
} |
|
0 | 262 |
|
263 |
CUsbHostMsDeviceThread::~CUsbHostMsDeviceThread() |
|
300 | 264 |
{ |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
Cancel(); |
300 | 266 |
iMutex.Close(); |
267 |
} |
|
0 | 268 |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
CUsbHostMsDeviceThread* CUsbHostMsDeviceThread::NewL(CUsbHostMsSession& aUsbHostMsSession, TUint aToken) |
300 | 270 |
{ |
271 |
CUsbHostMsDeviceThread* r = new (ELeave) CUsbHostMsDeviceThread(aUsbHostMsSession, aToken); |
|
272 |
return r; |
|
273 |
} |
|
0 | 274 |
|
275 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
276 |
void CUsbHostMsDeviceThread::Start() |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
277 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
278 |
iUsbHostMsSession.MessageRequest(iStatus); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
SetActive(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
280 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
282 |
|
0 | 283 |
/** |
284 |
Handles the request (in the form of a message) received from the client |
|
300 | 285 |
@param aMessage The received message |
0 | 286 |
*/ |
287 |
void CUsbHostMsDeviceThread::HandleMessage(const RMessage2& aMessage) |
|
300 | 288 |
{ |
289 |
TInt ret = KErrNotReady; |
|
290 |
OstTraceExt2(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_21, |
|
291 |
">> HOST DispatchMessageL Function=%d %d", |
|
292 |
aMessage.Function(), aMessage.Int3()); |
|
293 |
switch (aMessage.Function()) |
|
294 |
{ |
|
295 |
case EUsbHostMsRegisterInterface: |
|
296 |
TRAP(ret, RegisterInterfaceL(aMessage)); |
|
297 |
break; |
|
0 | 298 |
case EUsbHostMsInitialiseInterface: |
300 | 299 |
TRAP(ret, InitialiseInterfaceL(aMessage)); |
0 | 300 |
// CUsbInterfaceHandler::GetMaxLun() completes asynchronously |
301 |
if (ret) |
|
302 |
{ |
|
303 |
// Error condition needs to be completed |
|
304 |
break; |
|
305 |
} |
|
300 | 306 |
return; |
307 |
case EUsbHostMsUnRegisterInterface: |
|
308 |
// Check whether all luns have got uninitialised. |
|
271 | 309 |
if (iUsbHostMsDevice) |
310 |
{ |
|
311 |
for(TInt i = 0, j = iUsbHostMsDevice->GetMaxLun(); i <= j; i++) |
|
312 |
TRAP_IGNORE(iUsbHostMsDevice->RemoveLunL(i)); |
|
313 |
} |
|
300 | 314 |
TRAP(ret, UnRegisterInterfaceL(aMessage)); |
315 |
break; |
|
316 |
case EUsbHostMsRegisterLun: |
|
317 |
TRAP(ret, RegisterLogicalUnitL(aMessage)); |
|
318 |
break; |
|
319 |
case EUsbHostMsGetNumLun: |
|
320 |
TRAP(ret, GetNumLunL(aMessage)); |
|
321 |
break; |
|
322 |
case EUsbHostMsShutdown: |
|
323 |
ret = Shutdown(); |
|
324 |
break; |
|
0 | 325 |
default: |
326 |
// Try Device Handler and Logical Unit Handler |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
__ASSERT_DEBUG(iUsbHostMsDevice, User::Invariant()); |
0 | 328 |
TDeviceHandler deviceHandler(*iUsbHostMsDevice); |
329 |
TRAP(ret, deviceHandler.HandleMessageL(aMessage)); |
|
300 | 330 |
break; |
331 |
} |
|
332 |
OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_22, |
|
333 |
">> HOST returning %d", ret); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
|
0 | 335 |
if (aMessage.Function() != EUsbHostMsNotifyChange) |
336 |
{ |
|
337 |
aMessage.Complete(ret); |
|
338 |
} |
|
300 | 339 |
} |
0 | 340 |
|
341 |
||
342 |
/** |
|
343 |
Client request to shut down the server |
|
344 |
||
345 |
return KErrNone |
|
346 |
*/ |
|
347 |
TInt CUsbHostMsDeviceThread::Shutdown() |
|
348 |
{ |
|
349 |
CActiveScheduler::Stop(); |
|
300 | 350 |
return KErrNone; |
351 |
} |
|
0 | 352 |
|
353 |
void CUsbHostMsDeviceThread::GetNumLunL(const RMessage2& aMessage) |
|
300 | 354 |
{ |
0 | 355 |
if (!iUsbHostMsDevice) |
356 |
{ |
|
357 |
User::Leave(KErrNotReady); |
|
358 |
} |
|
359 |
||
300 | 360 |
TUint32 maxLun = iUsbHostMsDevice->GetMaxLun() + 1; |
361 |
TPtrC8 pLun((TUint8*)&maxLun,sizeof(TUint32)); |
|
362 |
aMessage.WriteL(0,pLun); |
|
363 |
} |
|
0 | 364 |
|
365 |
||
366 |
void CUsbHostMsDeviceThread::RegisterInterfaceL(const RMessage2& aMessage) |
|
300 | 367 |
{ |
368 |
THostMassStorageConfig msDeviceConfig; |
|
369 |
TPtr8 ptr((TUint8*)&msDeviceConfig,sizeof(THostMassStorageConfig)); |
|
370 |
aMessage.ReadL(0, ptr); |
|
0 | 371 |
|
300 | 372 |
OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_30, |
373 |
"RegisterInterfaceL Token=%d ", msDeviceConfig.iInterfaceToken); |
|
0 | 374 |
|
300 | 375 |
iUsbHostMsDevice = CUsbHostMsDevice::NewL(msDeviceConfig); |
376 |
} |
|
0 | 377 |
|
378 |
||
379 |
void CUsbHostMsDeviceThread::InitialiseInterfaceL(const RMessage2& aMessage) |
|
300 | 380 |
{ |
0 | 381 |
if (!iUsbHostMsDevice) |
382 |
{ |
|
383 |
User::Leave(KErrNotReady); |
|
384 |
} |
|
385 |
||
300 | 386 |
TRAPD(err, iUsbHostMsDevice->InitialiseL(aMessage)); |
0 | 387 |
if (err != KErrNone) |
388 |
{ |
|
389 |
delete iUsbHostMsDevice; |
|
300 | 390 |
iUsbHostMsDevice = NULL; |
0 | 391 |
User::Leave(err); |
392 |
} |
|
300 | 393 |
} |
0 | 394 |
|
395 |
||
396 |
void CUsbHostMsDeviceThread::UnRegisterInterfaceL(const RMessage2& aMessage) |
|
397 |
{ |
|
398 |
if (!iUsbHostMsDevice) |
|
399 |
{ |
|
400 |
User::Leave(KErrNotReady); |
|
401 |
} |
|
402 |
||
300 | 403 |
TRAPD(err, iUsbHostMsDevice->UnInitialiseL()); |
404 |
delete iUsbHostMsDevice; |
|
405 |
iUsbHostMsDevice = NULL; |
|
0 | 406 |
User::LeaveIfError(err); |
407 |
} |
|
408 |
||
409 |
||
410 |
void CUsbHostMsDeviceThread::RegisterLogicalUnitL(const RMessage2& aMessage) |
|
300 | 411 |
{ |
0 | 412 |
if (!iUsbHostMsDevice) |
413 |
{ |
|
414 |
User::Leave(KErrNotReady); |
|
415 |
} |
|
416 |
||
300 | 417 |
TUint32 iLunId = aMessage.Int0() + 1; // Subssessions need a positive value to store in the handles. We represent Luns as LunId+1 |
418 |
TPtrC8 pLun((TUint8*)&iLunId, sizeof(TUint32)); |
|
419 |
aMessage.WriteL(3, pLun); |
|
420 |
iLunId -= 1; // We represent LunId in MSC from 0 to MaxLun-1 as represented in BOT |
|
421 |
OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_31, |
|
422 |
"RegisterLogicalUnitL LUN=%d ", iLunId); |
|
423 |
iUsbHostMsDevice->AddLunL(iLunId); |
|
424 |
iUsbHostMsDevice->InitLunL(iLunId); |
|
425 |
} |
|
0 | 426 |