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