os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransportusbcldd.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransportusbcldd.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,161 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* Class declaration for CBulkOnlyTransportUsbcLdd.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalTechnology
1.26 +*/
1.27 +
1.28 +#ifndef __CBULKONLYTRANSPORTUSBCLDD_H__
1.29 +#define __CBULKONLYTRANSPORTUSBCLDD_H__
1.30 +
1.31 +#include "cbulkonlytransport.h"
1.32 +#include "cactivedevicestatenotifierbase.h"
1.33 +
1.34 +// Maximum size for SCSI Read10 Write10 and Verify10 commands
1.35 +// Windows requests size of 64K whereas MAC requests size of 128K
1.36 +static const TUint32 KMaxBufSize = 128 * 1024;
1.37 +
1.38 +//Forward Declaration
1.39 +class CBulkOnlyTransportUsbcLdd;
1.40 +
1.41 +/**
1.42 +Represent session with control endpoint (Ep0).
1.43 +handles the control interface, and responds to the class specific commands (RESET and GET_MAX_LUN).
1.44 +*/
1.45 +class CControlInterfaceUsbcLdd : public CActive
1.46 + {
1.47 +public:
1.48 + enum TControlState
1.49 + {
1.50 + ENone,
1.51 + EReadEp0Data,
1.52 + ESendMaxLun
1.53 + };
1.54 +
1.55 +public:
1.56 + static CControlInterfaceUsbcLdd* NewL(CBulkOnlyTransportUsbcLdd& aParent);
1.57 + ~CControlInterfaceUsbcLdd();
1.58 + TInt Start();
1.59 + void Stop();
1.60 + virtual void RunL();
1.61 + virtual void DoCancel();
1.62 +
1.63 +private:
1.64 + CControlInterfaceUsbcLdd(CBulkOnlyTransportUsbcLdd& aParent);
1.65 + void ConstructL();
1.66 + TInt ReadEp0Data();
1.67 + void DecodeEp0Data();
1.68 + TInt ReadUsbEp0();
1.69 +
1.70 +private:
1.71 + /** Buffer for request data*/
1.72 + TBuf8<KRequestHdrSize> iData;
1.73 +
1.74 + TUsbRequestHdr iRequestHeader;
1.75 +
1.76 + /** reference to the CBulkOnlyTransport*/
1.77 + CBulkOnlyTransportUsbcLdd& iParent;
1.78 +
1.79 + /** represent carrent state for state mashine */
1.80 + TControlState iCurrentState;
1.81 + };
1.82 +
1.83 +
1.84 +/** Transport Class that accessess the Non-SC LDD */
1.85 +class CBulkOnlyTransportUsbcLdd : public CBulkOnlyTransport, public MLddDeviceStateNotification
1.86 + {
1.87 +public:
1.88 + CBulkOnlyTransportUsbcLdd(TInt aNumDrives,CUsbMassStorageController& aController);
1.89 +
1.90 + ~CBulkOnlyTransportUsbcLdd();
1.91 + void ConstructL();
1.92 +
1.93 + RDevUsbcClient& Ldd();
1.94 + TInt BytesAvailable(); // from Mtransport base class
1.95 +
1.96 + TInt SetupConfigurationDescriptor(TBool aUnset = EFalse);
1.97 + TInt SetupInterfaceDescriptors();
1.98 + void ReleaseInterface();
1.99 + void CancelControlInterface();
1.100 + TInt StartControlInterface();
1.101 + void ActivateDeviceStateNotifier();
1.102 + void CancelDeviceStateNotifier();
1.103 + void CancelReadWriteRequests();
1.104 + void AllocateEndpointResources();
1.105 + TInt GetDeviceStatus(TUsbcDeviceState& deviceStatus);
1.106 + void FlushData();
1.107 + void ReadAndDiscardData(TInt aBytes);
1.108 + void ReadCBW();
1.109 + void ExpireData(TAny* aAddress = NULL);
1.110 + void ProcessCbwEvent();
1.111 + void StallEndpointAndWaitForClear();
1.112 + void ReadData(TUint aLength = 0);
1.113 + void WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse);
1.114 + void SetCbwPtr();
1.115 + TPtr8& SetCommandBufPtr(TUint aLength);
1.116 + TPtr8& SetDataBufPtr();
1.117 + void SetPaddingBufPtr(TUint aLength);
1.118 + void SetCswBufPtr(TUint aLength);
1.119 + void ProcessReadingDataEvent();
1.120 + void DiscardData(TUint aLength);
1.121 + void WriteToClient(TUint aLength);
1.122 + void SetReadDataBufPtr(TUint aLength);
1.123 +
1.124 +#ifdef MSDC_MULTITHREADED
1.125 + virtual void GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2);
1.126 +#endif
1.127 +
1.128 + void Activate(TRequestStatus& aStatus, TUint& aValue);
1.129 + void Cancel();
1.130 +
1.131 +private:
1.132 + TInt ReadUsb(TUint aLength = 0);
1.133 +
1.134 +private:
1.135 + RDevUsbcClient iLdd;
1.136 + CControlInterfaceUsbcLdd* iControlInterface;
1.137 + CActiveDeviceStateNotifierBase* iDeviceStateNotifier;
1.138 +
1.139 + /** buffer for Command Block Wrapper */
1.140 + TBuf8 <KCbwLength> iCbwBuf;
1.141 +
1.142 + TBuf8<KCommandBufferLength> iCommandBuf; // For Responses to commands
1.143 +
1.144 + TBuf8<KMaxBufSize> iDataBuf1; // For data transfers (Reading and Writing)
1.145 +
1.146 + TBuf8<KMaxBufSize> iDataBuf2;
1.147 +
1.148 + TBool iSwap;
1.149 + /** internal buffer for CSW */
1.150 + TBuf8<KCswLength> iCswBuf;
1.151 +
1.152 + /** internal buffer for padding */
1.153 + TBuf8<KBOTMaxBufSize> iBuf;
1.154 +
1.155 + /** internal buffer for garbage */
1.156 + TBuf8<512> iDiscardBuf;
1.157 + };
1.158 +
1.159 +#endif
1.160 +
1.161 +
1.162 +
1.163 +
1.164 +