os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransportusbcscldd.h
Update contrib.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Class declaration for CBulkOnlyTransportUsbcScLdd.
25 #ifndef __CBULKONLYTRANSPORTUSBCSCLDD_H__
26 #define __CBULKONLYTRANSPORTUSBCSCLDD_H__
28 #include "cbulkonlytransport.h"
29 #include "cactivedevicestatenotifierbase.h"
31 // This the length of every buffer corresponding to each Bulk endpoint.
32 // Length is to support double buffering, maximum size of host transfers(64 for Windows/128 for MAC) + 2K (to send CSW(IN ep's) and to recwive CBW's(OUT ep's))
33 LOCAL_D const TUint KMaxScBufferSize = 258 * 1024;
34 LOCAL_D const TUint KMaxScReadSize = 64 * 1024;
38 class CBulkOnlyTransportUsbcScLdd;
41 Represent session with control endpoint (Ep0).
42 handles the control interface, and responds to the class specific commands (RESET and GET_MAX_LUN).
45 class CControlInterfaceUsbcScLdd : public CActive
56 static CControlInterfaceUsbcScLdd* NewL(CBulkOnlyTransportUsbcScLdd& aParent);
57 ~CControlInterfaceUsbcScLdd();
61 virtual void DoCancel();
65 CControlInterfaceUsbcScLdd(CBulkOnlyTransportUsbcScLdd& aParent);
72 TEndpointBuffer iEp0Buf;
77 TUsbRequestHdr iRequestHeader;
79 /** reference to the CBulkOnlyTransport*/
80 CBulkOnlyTransportUsbcScLdd& iParent;
82 /** represent carrent state for state mashine */
83 TControlState iCurrentState;
87 /** Transport Class that accessess the SC LDD */
88 class CBulkOnlyTransportUsbcScLdd : public CBulkOnlyTransport, public MLddDeviceStateNotification
91 CBulkOnlyTransportUsbcScLdd(TInt aNumDrives,CUsbMassStorageController& aController);
93 ~CBulkOnlyTransportUsbcScLdd();
96 RDevUsbcScClient& Ldd();
97 TInt BytesAvailable(); // from Mtransport base class
99 TInt SetupConfigurationDescriptor(TBool aUnset = EFalse);
100 TInt SetupInterfaceDescriptors();
101 void ReleaseInterface();
102 void CancelControlInterface();
103 TInt StartControlInterface();
104 void ActivateDeviceStateNotifier();
105 void CancelDeviceStateNotifier();
106 void CancelReadWriteRequests();
107 void AllocateEndpointResources();
108 TInt GetDeviceStatus(TUsbcDeviceState& deviceStatus);
110 void ReadAndDiscardData(TInt aBytes);
112 void ExpireData(TAny* aAddress = NULL);
113 void ProcessCbwEvent();
114 void StallEndpointAndWaitForClear();
115 void ReadData(TUint aLength = 0);
116 void WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse);
118 TPtr8& SetCommandBufPtr(TUint aLength);
119 TPtr8& SetDataBufPtr();
120 void SetPaddingBufPtr(TUint aLength);
121 void SetCswBufPtr(TUint aLength);
122 void ProcessReadingDataEvent();
123 void DiscardData(TUint aLength);
124 void WriteToClient(TUint aLength);
125 void SetReadDataBufPtr( TUint aLength);
127 #ifdef MSDC_MULTITHREADED
128 virtual void GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2);
131 void Activate(TRequestStatus& aStatus, TUint& aValue);
135 TInt ReadUsb(TUint aLength = 0);
136 TInt OpenEndpoints();
137 void ProcessDataFromHost(); // As USB Read API can return with KErrCompletion saying there is data already and
138 // that we can process the data without queuong a request, this function effectively does
139 // what Runl() did earlier
143 RDevUsbcScClient iLdd;
144 CControlInterfaceUsbcScLdd* iControlInterface;
145 CActiveDeviceStateNotifierBase* iDeviceStateNotifier;
147 /** To remember chunk specifics one defined, instead of walking it every time something required */
150 TEndpointBuffer iSCReadEndpointBuf;
151 TEndpointBuffer iSCWriteEndpointBuf;
153 /** Pointer to the data in chunk which is read from the host */
156 /** Size of data read from the host in a 'transfer' */
159 /** If data read from host was termintated with a ZLP or not */
162 /** Pointer to start of IN buffer in chunk which can be written into by protocol/media */
165 /** Length of IN buffer */
166 TUint iInBufferLength;