os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransport.h
Update contrib.
1 // Copyright (c) 2004-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.
14 // Class declaration for CBulkOnlyTransport.
23 #ifndef __CBULKONLYTRANSPORT_H__
24 #define __CBULKONLYTRANSPORT_H__
27 #include <d32usbcsc.h>
30 #include "cusbmassstoragecontroller.h"
31 #include "mldddevicestatenotification.h"
33 static const TUint KCbwLength = 31;
34 static const TUint KCommandBufferLength = 36;
35 // for control endpoint
36 static const TUint KRequestHdrSize = 8;
39 /** size of buffer for command padding */
40 static const TUint KBOTMaxBufSize = 512;
43 LOCAL_D const TInt KCswLength = 13;
47 Represent Endpoint0 request
58 TInt Decode(const TDesC8& aBuffer);
59 TBool IsDataResponseRequired() const;
70 /** handles the data transport and communications with the SCSI protocol */
71 class CBulkOnlyTransport : public CActive, public MTransportBase
91 static CBulkOnlyTransport* NewL(TInt aNumDrives,CUsbMassStorageController& aController, CUsbMassStorageController::TTransportldd aTransportLddFlag);
92 static CBulkOnlyTransport* NewL(TInt aNumDrives,CUsbMassStorageController& aController);
94 CBulkOnlyTransport(TInt aNumDrives,CUsbMassStorageController& aController);
95 TInt InitialiseTransportL(TInt aTransportLddFlag);
96 ~CBulkOnlyTransport();
100 void RegisterProtocol(MProtocolBase& aProtocol);
102 CUsbMassStorageController& Controller();
104 void SetupReadData(TUint aLength);
105 void SetupWriteData(TPtrC8& aData);
107 void GetCommandBufPtr(TPtr8& aDes, TUint aLength); // Ptr to iCommandBuf to send responses to commands
108 void GetReadDataBufPtr(TPtr8& aDes); // Ptr to DataBuf's
109 void GetWriteDataBufPtr(TPtrC8& aDes);
110 #ifdef MSDC_MULTITHREADED
111 void ProcessReadData(TAny* aAddress);
114 TInt HwStart(TBool aDiscard = EFalse);
116 void StopBulkOnlyEndpoint();
121 virtual void DoCancel();
123 virtual TInt SetupConfigurationDescriptor(TBool aUnset = EFalse) = 0;
124 virtual TInt SetupInterfaceDescriptors() = 0;
125 virtual void ReleaseInterface() = 0;
126 virtual void CancelControlInterface() = 0;
127 virtual TInt StartControlInterface() = 0;
128 virtual void ActivateDeviceStateNotifier() = 0;
129 virtual void CancelDeviceStateNotifier() = 0;
130 virtual void CancelReadWriteRequests() = 0;
131 virtual void AllocateEndpointResources() = 0;
132 virtual TInt GetDeviceStatus(TUsbcDeviceState& deviceStatus) = 0;
133 virtual void FlushData() = 0;
134 virtual void ReadAndDiscardData(TInt aBytes) = 0;
135 virtual void ReadCBW() = 0;
136 virtual void ExpireData(TAny* aAddress = NULL) = 0;
137 virtual void ProcessCbwEvent() = 0;
138 virtual void StallEndpointAndWaitForClear() = 0;
139 virtual void ReadData(TUint aLength = 0) = 0;
140 virtual void WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse) = 0;
141 virtual void SetCbwPtr() = 0;
142 virtual TPtr8& SetCommandBufPtr(TUint aLength) = 0; // pointer to buf for sending responses to commands
143 virtual TPtr8& SetDataBufPtr() = 0; // to swap between the two buffers
144 virtual void SetPaddingBufPtr(TUint aLength) = 0;
145 virtual void SetCswBufPtr(TUint aLength) = 0;
146 virtual void ProcessReadingDataEvent() = 0;
147 virtual void DiscardData(TUint aLength) = 0;
148 virtual void WriteToClient(TUint aLength) = 0;
149 virtual void SetReadDataBufPtr( TUint aLength) = 0;
151 #ifdef MSDC_MULTITHREADED
152 virtual void GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2) = 0;
159 void SendCSW(TUint aTag, TUint aDataResidue, TCswStatus aStatus);
160 void WriteData(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse);
162 void CallReadAndDiscardData(TInt aBytes);
163 void Activate(TInt aReason);
166 /** maximun logic unit number supported (started from 0*/
169 CUsbMassStorageController& iController;
171 MProtocolBase* iProtocol;
173 TTransportState iCurrentState;
175 /** Shows how much data was not send/received */
176 TUint32 iDataResidue;
178 TCswStatus iCmdStatus;
180 /** Indicate if SCSI prot has data to sent */
183 /** Indicate if SCSI prot expected additional data */
186 /** Indicate whether SCSI prot started or not */
191 TBool iInterfaceConfigured;
193 TPtr8 iCommandBufPtr; // Ptr to buffer to write responses to commands
196 TPtr8 iPaddingBufPtr;
198 /** Size of data, Used to tell transport how much protocol/media has to send */
205 /** Internal TPtr to check validity of and decode CBW */
210 #endif // __CBULKONLYTRANSPORT_H__