sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* Class declaration for CBulkOnlyTransportUsbcScLdd.
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@internalTechnology
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#ifndef __CBULKONLYTRANSPORTUSBCSCLDD_H__
|
sl@0
|
26 |
#define __CBULKONLYTRANSPORTUSBCSCLDD_H__
|
sl@0
|
27 |
|
sl@0
|
28 |
#include "cbulkonlytransport.h"
|
sl@0
|
29 |
#include "cactivedevicestatenotifierbase.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
// This the length of every buffer corresponding to each Bulk endpoint.
|
sl@0
|
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))
|
sl@0
|
33 |
LOCAL_D const TUint KMaxScBufferSize = 258 * 1024;
|
sl@0
|
34 |
LOCAL_D const TUint KMaxScReadSize = 64 * 1024;
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
//Forward Declaration
|
sl@0
|
38 |
class CBulkOnlyTransportUsbcScLdd;
|
sl@0
|
39 |
|
sl@0
|
40 |
/**
|
sl@0
|
41 |
Represent session with control endpoint (Ep0).
|
sl@0
|
42 |
handles the control interface, and responds to the class specific commands (RESET and GET_MAX_LUN).
|
sl@0
|
43 |
*/
|
sl@0
|
44 |
|
sl@0
|
45 |
class CControlInterfaceUsbcScLdd : public CActive
|
sl@0
|
46 |
{
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
enum TControlState
|
sl@0
|
49 |
{
|
sl@0
|
50 |
ENone,
|
sl@0
|
51 |
EReadEp0Data,
|
sl@0
|
52 |
ESendMaxLun
|
sl@0
|
53 |
};
|
sl@0
|
54 |
|
sl@0
|
55 |
public:
|
sl@0
|
56 |
static CControlInterfaceUsbcScLdd* NewL(CBulkOnlyTransportUsbcScLdd& aParent);
|
sl@0
|
57 |
~CControlInterfaceUsbcScLdd();
|
sl@0
|
58 |
TInt Start();
|
sl@0
|
59 |
void Stop();
|
sl@0
|
60 |
virtual void RunL();
|
sl@0
|
61 |
virtual void DoCancel();
|
sl@0
|
62 |
TInt OpenEp0();
|
sl@0
|
63 |
|
sl@0
|
64 |
private:
|
sl@0
|
65 |
CControlInterfaceUsbcScLdd(CBulkOnlyTransportUsbcScLdd& aParent);
|
sl@0
|
66 |
void ConstructL();
|
sl@0
|
67 |
TInt ReadEp0Data();
|
sl@0
|
68 |
void DecodeEp0Data();
|
sl@0
|
69 |
TInt ReadUsbEp0();
|
sl@0
|
70 |
|
sl@0
|
71 |
private:
|
sl@0
|
72 |
TEndpointBuffer iEp0Buf;
|
sl@0
|
73 |
TAny* iEp0Packet;
|
sl@0
|
74 |
TUint iEp0Size;
|
sl@0
|
75 |
TBool iEp0Zlp;
|
sl@0
|
76 |
|
sl@0
|
77 |
TUsbRequestHdr iRequestHeader;
|
sl@0
|
78 |
|
sl@0
|
79 |
/** reference to the CBulkOnlyTransport*/
|
sl@0
|
80 |
CBulkOnlyTransportUsbcScLdd& iParent;
|
sl@0
|
81 |
|
sl@0
|
82 |
/** represent carrent state for state mashine */
|
sl@0
|
83 |
TControlState iCurrentState;
|
sl@0
|
84 |
};
|
sl@0
|
85 |
|
sl@0
|
86 |
|
sl@0
|
87 |
/** Transport Class that accessess the SC LDD */
|
sl@0
|
88 |
class CBulkOnlyTransportUsbcScLdd : public CBulkOnlyTransport, public MLddDeviceStateNotification
|
sl@0
|
89 |
{
|
sl@0
|
90 |
public:
|
sl@0
|
91 |
CBulkOnlyTransportUsbcScLdd(TInt aNumDrives,CUsbMassStorageController& aController);
|
sl@0
|
92 |
|
sl@0
|
93 |
~CBulkOnlyTransportUsbcScLdd();
|
sl@0
|
94 |
void ConstructL();
|
sl@0
|
95 |
|
sl@0
|
96 |
RDevUsbcScClient& Ldd();
|
sl@0
|
97 |
TInt BytesAvailable(); // from Mtransport base class
|
sl@0
|
98 |
|
sl@0
|
99 |
TInt SetupConfigurationDescriptor(TBool aUnset = EFalse);
|
sl@0
|
100 |
TInt SetupInterfaceDescriptors();
|
sl@0
|
101 |
void ReleaseInterface();
|
sl@0
|
102 |
void CancelControlInterface();
|
sl@0
|
103 |
TInt StartControlInterface();
|
sl@0
|
104 |
void ActivateDeviceStateNotifier();
|
sl@0
|
105 |
void CancelDeviceStateNotifier();
|
sl@0
|
106 |
void CancelReadWriteRequests();
|
sl@0
|
107 |
void AllocateEndpointResources();
|
sl@0
|
108 |
TInt GetDeviceStatus(TUsbcDeviceState& deviceStatus);
|
sl@0
|
109 |
void FlushData();
|
sl@0
|
110 |
void ReadAndDiscardData(TInt aBytes);
|
sl@0
|
111 |
void ReadCBW();
|
sl@0
|
112 |
void ExpireData(TAny* aAddress = NULL);
|
sl@0
|
113 |
void ProcessCbwEvent();
|
sl@0
|
114 |
void StallEndpointAndWaitForClear();
|
sl@0
|
115 |
void ReadData(TUint aLength = 0);
|
sl@0
|
116 |
void WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse);
|
sl@0
|
117 |
void SetCbwPtr();
|
sl@0
|
118 |
TPtr8& SetCommandBufPtr(TUint aLength);
|
sl@0
|
119 |
TPtr8& SetDataBufPtr();
|
sl@0
|
120 |
void SetPaddingBufPtr(TUint aLength);
|
sl@0
|
121 |
void SetCswBufPtr(TUint aLength);
|
sl@0
|
122 |
void ProcessReadingDataEvent();
|
sl@0
|
123 |
void DiscardData(TUint aLength);
|
sl@0
|
124 |
void WriteToClient(TUint aLength);
|
sl@0
|
125 |
void SetReadDataBufPtr( TUint aLength);
|
sl@0
|
126 |
|
sl@0
|
127 |
#ifdef MSDC_MULTITHREADED
|
sl@0
|
128 |
virtual void GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2);
|
sl@0
|
129 |
#endif
|
sl@0
|
130 |
|
sl@0
|
131 |
void Activate(TRequestStatus& aStatus, TUint& aValue);
|
sl@0
|
132 |
void Cancel();
|
sl@0
|
133 |
|
sl@0
|
134 |
private:
|
sl@0
|
135 |
TInt ReadUsb(TUint aLength = 0);
|
sl@0
|
136 |
TInt OpenEndpoints();
|
sl@0
|
137 |
void ProcessDataFromHost(); // As USB Read API can return with KErrCompletion saying there is data already and
|
sl@0
|
138 |
// that we can process the data without queuong a request, this function effectively does
|
sl@0
|
139 |
// what Runl() did earlier
|
sl@0
|
140 |
|
sl@0
|
141 |
private:
|
sl@0
|
142 |
RChunk* iChunk;
|
sl@0
|
143 |
RDevUsbcScClient iLdd;
|
sl@0
|
144 |
CControlInterfaceUsbcScLdd* iControlInterface;
|
sl@0
|
145 |
CActiveDeviceStateNotifierBase* iDeviceStateNotifier;
|
sl@0
|
146 |
|
sl@0
|
147 |
/** To remember chunk specifics one defined, instead of walking it every time something required */
|
sl@0
|
148 |
TUint iInEndpoint;
|
sl@0
|
149 |
TUint iOutEndpoint;
|
sl@0
|
150 |
TEndpointBuffer iSCReadEndpointBuf;
|
sl@0
|
151 |
TEndpointBuffer iSCWriteEndpointBuf;
|
sl@0
|
152 |
|
sl@0
|
153 |
/** Pointer to the data in chunk which is read from the host */
|
sl@0
|
154 |
TAny* iSCReadData;
|
sl@0
|
155 |
|
sl@0
|
156 |
/** Size of data read from the host in a 'transfer' */
|
sl@0
|
157 |
TUint iSCReadSize;
|
sl@0
|
158 |
|
sl@0
|
159 |
/** If data read from host was termintated with a ZLP or not */
|
sl@0
|
160 |
TBool iReadZlp;
|
sl@0
|
161 |
|
sl@0
|
162 |
/** Pointer to start of IN buffer in chunk which can be written into by protocol/media */
|
sl@0
|
163 |
TAny* iDataPtr;
|
sl@0
|
164 |
|
sl@0
|
165 |
/** Length of IN buffer */
|
sl@0
|
166 |
TUint iInBufferLength;
|
sl@0
|
167 |
};
|
sl@0
|
168 |
|
sl@0
|
169 |
#endif
|
sl@0
|
170 |
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
|
sl@0
|
174 |
|