sl@0
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32test\testusbcldd\inc\dtestusblogdev.h
|
sl@0
|
15 |
// Test USB logical channel classes.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@internalTechnology
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifndef __DTESTUSBCLOGDEVICE_H_
|
sl@0
|
25 |
#define __DTESTUSBCLOGDEVICE_H_
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "kerndefs.h"
|
sl@0
|
28 |
#include "usbcdesc.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
const TInt KTestUsbcMajorVersion = 0;
|
sl@0
|
31 |
const TInt KTestUsbcMinorVersion = 1;
|
sl@0
|
32 |
const TInt KTestUsbcBuildVersion = 1;
|
sl@0
|
33 |
const TInt KTestUsbcMaxRequests = 10;
|
sl@0
|
34 |
|
sl@0
|
35 |
/** The USB version we are compliant with (BCD) */
|
sl@0
|
36 |
const TUint16 KUsbcUsbVersion = 0x0110;
|
sl@0
|
37 |
|
sl@0
|
38 |
/** The Ep0 tx buffer area */
|
sl@0
|
39 |
const TInt KUsbcBufSz_Ep0Tx = 1024;
|
sl@0
|
40 |
|
sl@0
|
41 |
/** Size of buffer for transferring data from client and host */
|
sl@0
|
42 |
const TInt KTransferBufSize = 1024;
|
sl@0
|
43 |
|
sl@0
|
44 |
/** Must correspond to the max enum of TRequest + 1;
|
sl@0
|
45 |
currently this is ERequestEndpointStatusNotify = 9 */
|
sl@0
|
46 |
const TInt KUsbcMaxRequests = 10;
|
sl@0
|
47 |
|
sl@0
|
48 |
/** Maximum number of endpoints an Interface may have */
|
sl@0
|
49 |
const TInt KUsbcMaxEpNumber = 5;
|
sl@0
|
50 |
|
sl@0
|
51 |
/** Size of endpoint buffers */
|
sl@0
|
52 |
const TInt KEndpointBufferSize = 16 * 1024;
|
sl@0
|
53 |
|
sl@0
|
54 |
class DTestUsbcEndpoint;
|
sl@0
|
55 |
class DTestUsbcLogDevice : public DLogicalDevice
|
sl@0
|
56 |
{
|
sl@0
|
57 |
public:
|
sl@0
|
58 |
DTestUsbcLogDevice();
|
sl@0
|
59 |
~DTestUsbcLogDevice();
|
sl@0
|
60 |
TInt Install();
|
sl@0
|
61 |
void GetCaps(TDes8& aDes) const;
|
sl@0
|
62 |
TInt Create(DLogicalChannelBase*& aChannel);
|
sl@0
|
63 |
DLogicalChannel* CreateL();
|
sl@0
|
64 |
|
sl@0
|
65 |
private:
|
sl@0
|
66 |
RPointerArray<DTestUsbcEndpoint> iEndpoints;
|
sl@0
|
67 |
};
|
sl@0
|
68 |
|
sl@0
|
69 |
class TUsbcInterfaceSet;
|
sl@0
|
70 |
class TUsbcLogicalEndpoint;
|
sl@0
|
71 |
|
sl@0
|
72 |
/** This is one 'Alternate Setting' of an interface. */
|
sl@0
|
73 |
class TUsbcInterface
|
sl@0
|
74 |
{
|
sl@0
|
75 |
public:
|
sl@0
|
76 |
TUsbcInterface(TUsbcInterfaceSet* aIfcSet, TUint8 aSetting);
|
sl@0
|
77 |
~TUsbcInterface();
|
sl@0
|
78 |
public:
|
sl@0
|
79 |
/** Array of endpoints making up (belonging to) this setting. */
|
sl@0
|
80 |
RPointerArray<TUsbcLogicalEndpoint> iEndpoints;
|
sl@0
|
81 |
/** 'Back' pointer. */
|
sl@0
|
82 |
TUsbcInterfaceSet* const iInterfaceSet;
|
sl@0
|
83 |
/** bAlternateSetting (zero-based). */
|
sl@0
|
84 |
const TUint8 iSettingCode;
|
sl@0
|
85 |
};
|
sl@0
|
86 |
|
sl@0
|
87 |
/** This is an 'Interface' (owning 1 or more alternate settings TUsbcInterface). */
|
sl@0
|
88 |
class TUsbcInterfaceSet
|
sl@0
|
89 |
{
|
sl@0
|
90 |
public:
|
sl@0
|
91 |
TUsbcInterfaceSet(const DBase* aClientId, TUint8 aIfcNum);
|
sl@0
|
92 |
~TUsbcInterfaceSet();
|
sl@0
|
93 |
const TUsbcInterface* CurrentInterface() const;
|
sl@0
|
94 |
TUsbcInterface* CurrentInterface();
|
sl@0
|
95 |
public:
|
sl@0
|
96 |
/** Array of alternate settings provided by (belonging to) this interface. */
|
sl@0
|
97 |
RPointerArray<TUsbcInterface> iInterfaces;
|
sl@0
|
98 |
/** Pointer to the LDD which created and owns this interface. */
|
sl@0
|
99 |
const DBase* const iClientId;
|
sl@0
|
100 |
/** bInterfaceNumber (zero-based). */
|
sl@0
|
101 |
TUint8 iInterfaceNumber;
|
sl@0
|
102 |
/** bAlternateSetting (zero-based). */
|
sl@0
|
103 |
TUint8 iCurrentInterface;
|
sl@0
|
104 |
};
|
sl@0
|
105 |
|
sl@0
|
106 |
/** This is a logical 'Endpoint', as used by our device configuration model. */
|
sl@0
|
107 |
class TUsbcLogicalEndpoint
|
sl@0
|
108 |
{
|
sl@0
|
109 |
public:
|
sl@0
|
110 |
TUsbcLogicalEndpoint(TUint aEndpointNum, const TUsbcEndpointInfo& aInfo,
|
sl@0
|
111 |
TUsbcInterface* aInterface);
|
sl@0
|
112 |
~TUsbcLogicalEndpoint();
|
sl@0
|
113 |
public:
|
sl@0
|
114 |
/** The virtual (logical) endpoint number. */
|
sl@0
|
115 |
const TInt iLEndpointNum;
|
sl@0
|
116 |
/** This endpoint's info structure. */
|
sl@0
|
117 |
TUsbcEndpointInfo iInfo;
|
sl@0
|
118 |
/** 'Back' pointer. */
|
sl@0
|
119 |
const TUsbcInterface* iInterface;
|
sl@0
|
120 |
};
|
sl@0
|
121 |
|
sl@0
|
122 |
class DLddTestUsbcChannel : public DLogicalChannel
|
sl@0
|
123 |
{
|
sl@0
|
124 |
public:
|
sl@0
|
125 |
DLddTestUsbcChannel(RPointerArray<DTestUsbcEndpoint>& aEndpoints);
|
sl@0
|
126 |
void HandleMsg(TMessageBase* aMsg);
|
sl@0
|
127 |
TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
sl@0
|
128 |
~DLddTestUsbcChannel();
|
sl@0
|
129 |
|
sl@0
|
130 |
private:
|
sl@0
|
131 |
TInt DoCancel(TInt aReqNo);
|
sl@0
|
132 |
void DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
|
sl@0
|
133 |
TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
|
sl@0
|
134 |
TBool ValidateEndpoint(TUsbcEndpointInfo* aEndpointInfo);
|
sl@0
|
135 |
TInt SetInterface(TInt aInterfaceNumber, TUsbcInterfaceInfoBuf *aUserInterfaceInfoBuf, TPtr8* aInterfaceString);
|
sl@0
|
136 |
TInt SetInterface(TInt aInterfaceNumber, TUsbcClassInfo& aClass, TDesC8* aString,
|
sl@0
|
137 |
TInt aTotalEndpointsUsed, const TUsbcEndpointInfo aEndpointData[]);
|
sl@0
|
138 |
TUsbcInterface* CreateInterface(TInt aIfc);
|
sl@0
|
139 |
void DeleteInterface(TInt aIfc);
|
sl@0
|
140 |
void DeleteInterfaceSet();
|
sl@0
|
141 |
TInt CreateEndpoints(TUsbcInterface* aIfc, TInt aEndpointsUsed, const TUsbcEndpointInfo aEndpointData[]);
|
sl@0
|
142 |
TInt SetupIfcDescriptor(TUsbcInterface* aIfc, TUsbcClassInfo& aClass,
|
sl@0
|
143 |
TDesC8* aString, const TUsbcEndpointInfo aEndpointData[]);
|
sl@0
|
144 |
TInt ReleaseInterface(TInt aInterfaceNumber);
|
sl@0
|
145 |
TInt HostEndpointStatusNotify(TInt aEndpointNumber, TRequestStatus* aStatus);
|
sl@0
|
146 |
TInt EndpointStatusNotify(TUint* aEndpointMask, TRequestStatus* aStatus);
|
sl@0
|
147 |
void EndpointStatusNotifyCallback();
|
sl@0
|
148 |
TInt ClearEndpoint(TInt aEndpointNumber);
|
sl@0
|
149 |
TInt DoTransferAsyncReq(TInt aEndpointNumber, TAny* a1, TAny* a2, TRequestStatus& aStatus);
|
sl@0
|
150 |
TBool ValidEndpoint(TInt aEndpointNumber);
|
sl@0
|
151 |
TInt FindRealEndpoint(TInt aEndpointNumber);
|
sl@0
|
152 |
TInt HaltClearEndpoint(TBool aHalt, TInt aEndpointNumber);
|
sl@0
|
153 |
void AlternateDeviceStatusNotify();
|
sl@0
|
154 |
TInt SetAlternateDeviceStatusNotify(TRequestStatus* aStatus, TUint* aValue);
|
sl@0
|
155 |
void CancelAlternateDeviceStatusNotify();
|
sl@0
|
156 |
TInt ReEnumerate(TRequestStatus* aStatus);
|
sl@0
|
157 |
void SetDeviceState(TUsbcDeviceState aState);
|
sl@0
|
158 |
private:
|
sl@0
|
159 |
DThread* iClient;
|
sl@0
|
160 |
TUsbcDescriptorPool iDescriptors;
|
sl@0
|
161 |
TUsbcInterfaceSet iIfcSet;
|
sl@0
|
162 |
RPointerArray<DTestUsbcEndpoint>& iEndpoints;
|
sl@0
|
163 |
TUint* iEndpointStatusMask;
|
sl@0
|
164 |
TRequestStatus* iEndpointStatusNotifyRequest;
|
sl@0
|
165 |
TRequestStatus* iAlternateDeviceStatusNotifyRequest;
|
sl@0
|
166 |
TUint* iAlternateDeviceStatusNotifyValue;
|
sl@0
|
167 |
TUsbcDeviceState iDeviceState;
|
sl@0
|
168 |
|
sl@0
|
169 |
public:
|
sl@0
|
170 |
static const TUsbcEndpointData iEndpointData[];
|
sl@0
|
171 |
|
sl@0
|
172 |
friend class DTestUsbcEndpoint;
|
sl@0
|
173 |
};
|
sl@0
|
174 |
|
sl@0
|
175 |
class DTestUsbcEndpoint : public DBase
|
sl@0
|
176 |
{
|
sl@0
|
177 |
public:
|
sl@0
|
178 |
DTestUsbcEndpoint();
|
sl@0
|
179 |
~DTestUsbcEndpoint();
|
sl@0
|
180 |
TInt Create(const TUsbcEndpointCaps& aCaps);
|
sl@0
|
181 |
TInt TryToComplete();
|
sl@0
|
182 |
TInt CopyData(TInt aSrcOffset, DThread* aDestClient, TDesC8* aDest,
|
sl@0
|
183 |
TInt aDestOffset, TInt aLen);
|
sl@0
|
184 |
TBool SupportsDir(TUint aDir);
|
sl@0
|
185 |
TBool EndpointSuitable(const TUsbcEndpointInfo& aInfo);
|
sl@0
|
186 |
void DoCancel();
|
sl@0
|
187 |
TInt Halt();
|
sl@0
|
188 |
TInt Clear();
|
sl@0
|
189 |
TBool IsHalted();
|
sl@0
|
190 |
void SetClearCallback(DLddTestUsbcChannel* aCallback);
|
sl@0
|
191 |
TInt HostStatusNotify(DThread* aHost, TRequestStatus* aStatus);
|
sl@0
|
192 |
TInt NewRequest(DThread* aClient, TRequestStatus* aStatus, TEndpointTransferInfo& aInfo, TTransferType aType);
|
sl@0
|
193 |
TInt NewHostRequest(DThread* aHost, TRequestStatus* aStatus, TEndpointTransferInfo& aInfo, TTransferType aType);
|
sl@0
|
194 |
private:
|
sl@0
|
195 |
TRequestStatus* iClientStatus;
|
sl@0
|
196 |
TRequestStatus* iHostStatus;
|
sl@0
|
197 |
TRequestStatus* iHostNotifyStatus;
|
sl@0
|
198 |
DThread* iClient;
|
sl@0
|
199 |
DThread* iHost;
|
sl@0
|
200 |
DThread* iNotifyHost;
|
sl@0
|
201 |
TUsbcEndpointCaps iCaps;
|
sl@0
|
202 |
TBool iRequestPending;
|
sl@0
|
203 |
TBool iHostRequestPending;
|
sl@0
|
204 |
TEndpointTransferInfo iClientTransferInfo;
|
sl@0
|
205 |
TEndpointTransferInfo iHostTransferInfo;
|
sl@0
|
206 |
TInt iDataTransferred;
|
sl@0
|
207 |
TInt iHostDataTransferred;
|
sl@0
|
208 |
TTransferType iRequestType;
|
sl@0
|
209 |
TTransferType iHostRequestType;
|
sl@0
|
210 |
HBuf8Plat* iBuffer;
|
sl@0
|
211 |
TBool iHalted;
|
sl@0
|
212 |
DLddTestUsbcChannel* iClearCallback;
|
sl@0
|
213 |
|
sl@0
|
214 |
public:
|
sl@0
|
215 |
TBool iReserve;
|
sl@0
|
216 |
};
|
sl@0
|
217 |
|
sl@0
|
218 |
#endif // __DTESTUSBCLOGDEVICE_H_
|