author | hgs |
Tue, 02 Nov 2010 15:29:23 +0000 | |
changeset 300 | 1d28c8722707 |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
90
947f0dc9f7a8
Revision: 201015
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 |
#include <e32base.h> |
|
22 |
#include <d32usbdi_hubdriver.h> |
|
23 |
#include <d32usbdi.h> |
|
24 |
#include <d32otgdi.h> |
|
25 |
#include <d32usbdescriptors.h> |
|
26 |
#include <d32usbtransfers.h> |
|
27 |
#include "botmsctypes.h" |
|
28 |
#include "msctypes.h" |
|
29 |
#include "mtransport.h" |
|
30 |
#include "mprotocol.h" |
|
31 |
#include "cusbifacehandler.h" |
|
32 |
#include "cbulkonlytransport.h" |
|
300 | 33 |
|
34 |
#include "OstTraceDefinitions.h" |
|
35 |
#ifdef OST_TRACE_COMPILER_IN_USE |
|
36 |
#include "cusbifacehandlerTraces.h" |
|
37 |
#endif |
|
0 | 38 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
39 |
CUsbInterfaceHandler* CUsbInterfaceHandler::NewL(RUsbInterface &aInterface, RUsbPipe& aBulkPipeIn) |
300 | 40 |
{ |
41 |
return new (ELeave) CUsbInterfaceHandler(aInterface, aBulkPipeIn); |
|
42 |
} |
|
0 | 43 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
44 |
CUsbInterfaceHandler::CUsbInterfaceHandler(RUsbInterface &aInterface, RUsbPipe& aBulkPipeIn) |
300 | 45 |
: CActive(EPriorityStandard), |
46 |
iInterface(aInterface), |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
47 |
iBulkPipeIn(aBulkPipeIn) |
300 | 48 |
{ |
49 |
CActiveScheduler::Add(this); |
|
50 |
} |
|
0 | 51 |
|
52 |
CUsbInterfaceHandler::~CUsbInterfaceHandler() |
|
300 | 53 |
{ |
54 |
if (iState != ENone) |
|
55 |
{ |
|
56 |
iState = ENone; |
|
57 |
iBotGetMaxLun.Complete(KErrCancel); |
|
58 |
Cancel(); |
|
59 |
} |
|
60 |
} |
|
0 | 61 |
|
62 |
/** |
|
63 |
Cancellation of outstanding request |
|
64 |
*/ |
|
65 |
void CUsbInterfaceHandler::DoCancel() |
|
300 | 66 |
{ |
67 |
} |
|
0 | 68 |
|
69 |
/** |
|
70 |
Completion of USB transport request. |
|
71 |
*/ |
|
72 |
void CUsbInterfaceHandler::RunL() |
|
73 |
{ |
|
300 | 74 |
TInt error = iStatus.Int(); |
0 | 75 |
|
300 | 76 |
if (error == KErrUsbStalled && iState == EGetMaxLun) |
0 | 77 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
78 |
// Devices that do not support multiple LUNs may STALL this command |
300 | 79 |
OstTrace0(TRACE_SHOSTMASSSTORAGE_BOT, CUSBIFACEHANLDER_10, |
80 |
"...KErrUsbStalled"); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
81 |
iBulkPipeIn.ClearRemoteStall(); |
300 | 82 |
error = KErrNone; |
0 | 83 |
} |
84 |
||
300 | 85 |
else if (error == KErrNone) |
0 | 86 |
{ |
300 | 87 |
OstTrace0(TRACE_SHOSTMASSSTORAGE_BOT, CUSBIFACEHANLDER_11, |
88 |
"...KErrNone"); |
|
89 |
if (iState == EGetMaxLun) |
|
0 | 90 |
{ |
300 | 91 |
OstTrace0(TRACE_SHOSTMASSSTORAGE_BOT, CUSBIFACEHANLDER_12, |
92 |
"...sending GetMaxLun response"); |
|
93 |
*ipGetMaxLun = iBuffer[0]; |
|
0 | 94 |
} |
95 |
} |
|
96 |
else |
|
97 |
{ |
|
300 | 98 |
OstTrace0(TRACE_SHOSTMASSSTORAGE_BOT, CUSBIFACEHANLDER_13, |
99 |
"...completeing with KErrGeneral"); |
|
0 | 100 |
error = KErrGeneral; |
101 |
} |
|
102 |
||
103 |
iState = ENone; |
|
300 | 104 |
iBotGetMaxLun.Complete(error); |
0 | 105 |
} |
106 |
||
107 |
||
108 |
void CUsbInterfaceHandler::GetMaxLun(TLun* aMaxLun, const RMessage2& aMessage) |
|
300 | 109 |
{ |
110 |
/* Send the Get max lun command in the ep0 */ |
|
111 |
RUsbInterface::TUsbTransferRequestDetails reqDetails; |
|
112 |
_LIT8(KNullDesC8,""); |
|
113 |
iBotGetMaxLun = aMessage; |
|
114 |
iState = EGetMaxLun; |
|
115 |
ipGetMaxLun = aMaxLun; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
116 |
*ipGetMaxLun = 0; // default response is MaxLUN=0 |
0 | 117 |
|
300 | 118 |
reqDetails.iRequestType = 0xA1; |
119 |
reqDetails.iRequest = 0xFE; |
|
120 |
reqDetails.iValue = 0x0000; |
|
121 |
reqDetails.iIndex = 0x0000; |
|
122 |
reqDetails.iFlags = 0x04; // Short transfer OK |
|
0 | 123 |
|
300 | 124 |
iBuffer.SetLength(1); |
125 |
iInterface.Ep0Transfer(reqDetails, KNullDesC8, iBuffer, iStatus); |
|
126 |
SetActive(); |
|
127 |
} |
|
0 | 128 |