os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/transport/cusbifacehandler.cpp
First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include <d32usbdi_hubdriver.h>
25 #include <d32usbdescriptors.h>
26 #include <d32usbtransfers.h>
27 #include "botmsctypes.h"
29 #include "mtransport.h"
30 #include "mprotocol.h"
31 #include "cusbifacehandler.h"
32 #include "cbulkonlytransport.h"
36 CUsbInterfaceHandler* CUsbInterfaceHandler::NewL(RUsbInterface &aInterface)
38 return new (ELeave) CUsbInterfaceHandler(aInterface);
41 CUsbInterfaceHandler::CUsbInterfaceHandler(RUsbInterface &aInterface)
42 : CActive(EPriorityStandard),
43 iInterface(aInterface)
46 CActiveScheduler::Add(this);
49 CUsbInterfaceHandler::~CUsbInterfaceHandler()
55 iBotGetMaxLun.Complete(KErrCancel);
61 Cancellation of outstanding request
63 void CUsbInterfaceHandler::DoCancel()
69 Completion of USB transport request.
71 void CUsbInterfaceHandler::RunL()
74 TInt error = iStatus.Int();
76 if (error == KErrUsbStalled && iState == EGetMaxLun)
78 __BOTPRINT(_L("...KErrUsbStalled"));
84 if (error == KErrNone)
86 __BOTPRINT(_L("...KErrNone"));
88 if (iState == EGetMaxLun)
90 __BOTPRINT(_L("...sending GetMaxLun response"));
91 *ipGetMaxLun = iBuffer[0];
95 __BOTPRINT(_L("...defaulting to 0"));
101 __BOTPRINT(_L("...completeing with KErrGeneral"));
106 iBotGetMaxLun.Complete(error);
110 void CUsbInterfaceHandler::GetMaxLun(TLun* aMaxLun, const RMessage2& aMessage)
114 /* Send the Get max lun command in the ep0 */
115 RUsbInterface::TUsbTransferRequestDetails reqDetails;
116 _LIT8(KNullDesC8,"");
117 iBotGetMaxLun = aMessage;
119 ipGetMaxLun = aMaxLun;
121 reqDetails.iRequestType = 0xA1;
122 reqDetails.iRequest = 0xFE;
123 reqDetails.iValue = 0x0000;
124 reqDetails.iIndex = 0x0000;
125 reqDetails.iFlags = 0x04; // Short transfer OK
127 iBuffer.SetLength(1);
128 iInterface.Ep0Transfer(reqDetails, KNullDesC8, iBuffer, iStatus);
133 void CUsbInterfaceHandler::Reset()
136 RUsbInterface::TUsbTransferRequestDetails reqDetails;
137 _LIT8(KNullDesC8,"");
139 reqDetails.iRequestType = 0x21;
140 reqDetails.iRequest = 0xFF;
141 reqDetails.iValue = 0x0000;
142 reqDetails.iIndex = 0x0000;
143 reqDetails.iFlags = 0x04; // Short transfer OK
145 iInterface.Ep0Transfer(reqDetails, KNullDesC8, (TDes8 &) KNullDesC8, iStatus);