sl@0
|
1 |
// Copyright (c) 1997-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 |
// e32test/usb/t_usb_device/include/general.h
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#ifndef __GENERAL_H__
|
sl@0
|
19 |
#define __GENERAL_H__
|
sl@0
|
20 |
|
sl@0
|
21 |
#define __E32TEST_EXTENSION__
|
sl@0
|
22 |
|
sl@0
|
23 |
#include <e32hal.h>
|
sl@0
|
24 |
#include <e32uid.h>
|
sl@0
|
25 |
#include <hal.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
#include <e32cons.h>
|
sl@0
|
28 |
#include <e32svr.h>
|
sl@0
|
29 |
#include <e32std.h>
|
sl@0
|
30 |
#include <e32test.h>
|
sl@0
|
31 |
#include <f32file.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
#ifdef USB_SC
|
sl@0
|
34 |
#include <d32usbcsc.h>
|
sl@0
|
35 |
#define RDEVCLIENT RDevUsbcScClient
|
sl@0
|
36 |
#define TENDPOINTNUMBER TInt
|
sl@0
|
37 |
#else
|
sl@0
|
38 |
#include <d32usbc.h>
|
sl@0
|
39 |
#define RDEVCLIENT RDevUsbcClient
|
sl@0
|
40 |
#define TENDPOINTNUMBER TEndpointNumber
|
sl@0
|
41 |
#endif
|
sl@0
|
42 |
|
sl@0
|
43 |
static const TInt KHostLogFileSize = 64 * 1024; // 64kB
|
sl@0
|
44 |
|
sl@0
|
45 |
static const TInt KMaxInterfaces = 10;
|
sl@0
|
46 |
static const TInt KMaxConcurrentTests = 10;
|
sl@0
|
47 |
static const TInt KMaxInterfaceSettings = 10;
|
sl@0
|
48 |
|
sl@0
|
49 |
static const TInt KWaitSettingSize = 8;
|
sl@0
|
50 |
|
sl@0
|
51 |
static const TUint16 KFirstSettingThreadMask = 0x8000;
|
sl@0
|
52 |
static const TUint16 KLastSettingThreadMask = 0x4000;
|
sl@0
|
53 |
|
sl@0
|
54 |
static const TUint16 KHostErrorIndex = 0xFFF;
|
sl@0
|
55 |
|
sl@0
|
56 |
static const TUint8 stridx1 = 0xCC;
|
sl@0
|
57 |
static const TUint8 stridx2 = 0xDD;
|
sl@0
|
58 |
static const TUint8 stridx3 = 0xEE;
|
sl@0
|
59 |
static const TUint8 stridx4 = 0xFF;
|
sl@0
|
60 |
|
sl@0
|
61 |
#ifdef USB_SC
|
sl@0
|
62 |
_LIT(KActivePanic, "T_USB_SCDEVICE");
|
sl@0
|
63 |
#else
|
sl@0
|
64 |
_LIT(KActivePanic, "T_USB_DEVICE");
|
sl@0
|
65 |
#endif
|
sl@0
|
66 |
|
sl@0
|
67 |
// Descriptor Offset Constants
|
sl@0
|
68 |
|
sl@0
|
69 |
static const TInt KUsbDesc_SizeOffset = 0;
|
sl@0
|
70 |
static const TInt KUsbDesc_TypeOffset = 1;
|
sl@0
|
71 |
static const TInt KDevDesc_SpecOffset = 2;
|
sl@0
|
72 |
static const TInt KDevDesc_DevClassOffset = 4;
|
sl@0
|
73 |
static const TInt KDevDesc_DevSubClassOffset = 5;
|
sl@0
|
74 |
static const TInt KDevDesc_DevProtocolOffset = 6;
|
sl@0
|
75 |
static const TInt KDevDesc_Ep0SizeOffset = 7;
|
sl@0
|
76 |
static const TInt KDevDesc_VendorIdOffset = 8;
|
sl@0
|
77 |
static const TInt KDevDesc_ProductIdOffset = 10;
|
sl@0
|
78 |
static const TInt KDevDesc_DevReleaseOffset = 12;
|
sl@0
|
79 |
|
sl@0
|
80 |
static const TInt KConfDesc_AttribOffset = 7;
|
sl@0
|
81 |
static const TInt KConfDesc_MaxPowerOffset = 8;
|
sl@0
|
82 |
|
sl@0
|
83 |
static const TInt KIfcDesc_LengthOffset = 0;
|
sl@0
|
84 |
static const TInt KIfcDesc_TypeOffset = 1;
|
sl@0
|
85 |
static const TInt KIfcDesc_NumberOffset = 2;
|
sl@0
|
86 |
static const TInt KIfcDesc_SettingOffset = 3;
|
sl@0
|
87 |
static const TInt KIfcDesc_NumEndpointsOffset = 4;
|
sl@0
|
88 |
static const TInt KIfcDesc_ClassOffset = 5;
|
sl@0
|
89 |
static const TInt KIfcDesc_SubClassOffset = 6;
|
sl@0
|
90 |
static const TInt KIfcDesc_ProtocolOffset = 7;
|
sl@0
|
91 |
static const TInt KIfcDesc_InterfaceOffset = 8;
|
sl@0
|
92 |
|
sl@0
|
93 |
static const TInt KEpDesc_LengthOffset = 0;
|
sl@0
|
94 |
static const TInt KEpDesc_TypeOffset = 1;
|
sl@0
|
95 |
static const TInt KEpDesc_AddressOffset = 2;
|
sl@0
|
96 |
static const TInt KEpDesc_AttributesOffset = 3;
|
sl@0
|
97 |
static const TInt KEpDesc_PacketSizeOffset = 4;
|
sl@0
|
98 |
static const TInt KEpDesc_IntervalOffset = 6;
|
sl@0
|
99 |
static const TInt KEpDesc_SynchAddressOffset = 8;
|
sl@0
|
100 |
|
sl@0
|
101 |
enum TXferMode
|
sl@0
|
102 |
{
|
sl@0
|
103 |
ENone,
|
sl@0
|
104 |
ELoop,
|
sl@0
|
105 |
ELoopComp,
|
sl@0
|
106 |
EReceiveOnly,
|
sl@0
|
107 |
ETransmitOnly
|
sl@0
|
108 |
};
|
sl@0
|
109 |
|
sl@0
|
110 |
enum TXferType
|
sl@0
|
111 |
{
|
sl@0
|
112 |
ETxferNone,
|
sl@0
|
113 |
EWaitSetting,
|
sl@0
|
114 |
ESuspend,
|
sl@0
|
115 |
EAltSetting,
|
sl@0
|
116 |
EReadXfer,
|
sl@0
|
117 |
EWriteXfer
|
sl@0
|
118 |
};
|
sl@0
|
119 |
|
sl@0
|
120 |
struct TestParam
|
sl@0
|
121 |
{
|
sl@0
|
122 |
TUint32 minSize;
|
sl@0
|
123 |
TUint32 maxSize;
|
sl@0
|
124 |
TUint32 packetNumber;
|
sl@0
|
125 |
TUint8 interfaceNumber;
|
sl@0
|
126 |
TUint8 alternateSetting;
|
sl@0
|
127 |
TUint8 outPipe;
|
sl@0
|
128 |
TUint8 inPipe;
|
sl@0
|
129 |
TUint16 repeat;
|
sl@0
|
130 |
TUint16 settingRepeat;
|
sl@0
|
131 |
TUint8 beforeIndex;
|
sl@0
|
132 |
TUint8 afterIndex;
|
sl@0
|
133 |
};
|
sl@0
|
134 |
|
sl@0
|
135 |
typedef struct TestParam TestParamType;
|
sl@0
|
136 |
typedef TestParamType* TestParamPtr;
|
sl@0
|
137 |
|
sl@0
|
138 |
//
|
sl@0
|
139 |
// Helpful Defines
|
sl@0
|
140 |
//
|
sl@0
|
141 |
#define HiByte(a) (TUint8)((a)>>8)
|
sl@0
|
142 |
#define LoByte(a) (TUint8)((a)&0xFF)
|
sl@0
|
143 |
|
sl@0
|
144 |
#define TUSB_PRINT(string) \
|
sl@0
|
145 |
do { \
|
sl@0
|
146 |
iConsole->Printf(_L(string)); \
|
sl@0
|
147 |
iConsole->Printf(_L("\n")); \
|
sl@0
|
148 |
RDebug::Print(_L(string)); \
|
sl@0
|
149 |
} while (0)
|
sl@0
|
150 |
|
sl@0
|
151 |
#define TUSB_PRINT1(string, a) \
|
sl@0
|
152 |
do { \
|
sl@0
|
153 |
iConsole->Printf(_L(string), (a)); \
|
sl@0
|
154 |
iConsole->Printf(_L("\n")); \
|
sl@0
|
155 |
RDebug::Print(_L(string), (a)); \
|
sl@0
|
156 |
} while (0)
|
sl@0
|
157 |
|
sl@0
|
158 |
#define TUSB_PRINT2(string, a, b) \
|
sl@0
|
159 |
do { \
|
sl@0
|
160 |
iConsole->Printf(_L(string), (a), (b)); \
|
sl@0
|
161 |
iConsole->Printf(_L("\n")); \
|
sl@0
|
162 |
RDebug::Print(_L(string), (a), (b)); \
|
sl@0
|
163 |
} while (0)
|
sl@0
|
164 |
|
sl@0
|
165 |
#define TUSB_PRINT3(string, a, b, c) \
|
sl@0
|
166 |
do { \
|
sl@0
|
167 |
iConsole->Printf(_L(string), (a), (b), (c)); \
|
sl@0
|
168 |
iConsole->Printf(_L("\n")); \
|
sl@0
|
169 |
RDebug::Print(_L(string), (a), (b), (c)); \
|
sl@0
|
170 |
} while (0)
|
sl@0
|
171 |
|
sl@0
|
172 |
#define TUSB_PRINT4(string, a, b, c, d) \
|
sl@0
|
173 |
do { \
|
sl@0
|
174 |
iConsole->Printf(_L(string), (a), (b), (c), (d)); \
|
sl@0
|
175 |
iConsole->Printf(_L("\n")); \
|
sl@0
|
176 |
RDebug::Print(_L(string), (a), (b), (c), (d)); \
|
sl@0
|
177 |
} while (0)
|
sl@0
|
178 |
|
sl@0
|
179 |
#define TUSB_PRINT5(string, a, b, c, d, e) \
|
sl@0
|
180 |
do { \
|
sl@0
|
181 |
iConsole->Printf(_L(string), (a), (b), (c), (d), (e)); \
|
sl@0
|
182 |
iConsole->Printf(_L("\n")); \
|
sl@0
|
183 |
RDebug::Print(_L(string), (a), (b), (c), (d), (e)); \
|
sl@0
|
184 |
} while (0)
|
sl@0
|
185 |
|
sl@0
|
186 |
#define TUSB_PRINT6(string, a, b, c, d, e, f) \
|
sl@0
|
187 |
do { \
|
sl@0
|
188 |
iConsole->Printf(_L(string), (a), (b), (c), (d), (e), (f)); \
|
sl@0
|
189 |
iConsole->Printf(_L("\n")); \
|
sl@0
|
190 |
RDebug::Print(_L(string), (a), (b), (c), (d), (e), (f)); \
|
sl@0
|
191 |
} while (0)
|
sl@0
|
192 |
|
sl@0
|
193 |
#define TUSB_VERBOSE_PRINT(string) \
|
sl@0
|
194 |
do { \
|
sl@0
|
195 |
if (gVerbose) \
|
sl@0
|
196 |
{ \
|
sl@0
|
197 |
TUSB_PRINT(string); \
|
sl@0
|
198 |
} \
|
sl@0
|
199 |
} while (0)
|
sl@0
|
200 |
|
sl@0
|
201 |
#define TUSB_VERBOSE_PRINT1(string, a) \
|
sl@0
|
202 |
do { \
|
sl@0
|
203 |
if (gVerbose) \
|
sl@0
|
204 |
{ \
|
sl@0
|
205 |
TUSB_PRINT1(string, a); \
|
sl@0
|
206 |
} \
|
sl@0
|
207 |
} while (0)
|
sl@0
|
208 |
|
sl@0
|
209 |
#define TUSB_VERBOSE_PRINT2(string, a, b) \
|
sl@0
|
210 |
do { \
|
sl@0
|
211 |
if (gVerbose) \
|
sl@0
|
212 |
{ \
|
sl@0
|
213 |
TUSB_PRINT2(string, a, b); \
|
sl@0
|
214 |
} \
|
sl@0
|
215 |
} while (0)
|
sl@0
|
216 |
|
sl@0
|
217 |
#define TUSB_VERBOSE_PRINT3(string, a, b, c) \
|
sl@0
|
218 |
do { \
|
sl@0
|
219 |
if (gVerbose) \
|
sl@0
|
220 |
{ \
|
sl@0
|
221 |
TUSB_PRINT3(string, a, b, c); \
|
sl@0
|
222 |
} \
|
sl@0
|
223 |
} while (0)
|
sl@0
|
224 |
|
sl@0
|
225 |
#define TUSB_VERBOSE_PRINT4(string, a, b, c, d) \
|
sl@0
|
226 |
do { \
|
sl@0
|
227 |
if (gVerbose) \
|
sl@0
|
228 |
{ \
|
sl@0
|
229 |
TUSB_PRINT4(string, a, b, c, d); \
|
sl@0
|
230 |
} \
|
sl@0
|
231 |
} while (0)
|
sl@0
|
232 |
|
sl@0
|
233 |
#define TUSB_VERBOSE_PRINT5(string, a, b, c, d, e) \
|
sl@0
|
234 |
do { \
|
sl@0
|
235 |
if (gVerbose) \
|
sl@0
|
236 |
{ \
|
sl@0
|
237 |
TUSB_PRINT5(string, a, b, c, d, e); \
|
sl@0
|
238 |
} \
|
sl@0
|
239 |
} while (0)
|
sl@0
|
240 |
|
sl@0
|
241 |
#define TUSB_VERBOSE_APRINT(string) \
|
sl@0
|
242 |
do { \
|
sl@0
|
243 |
if (gVerbose) \
|
sl@0
|
244 |
{ \
|
sl@0
|
245 |
aConsole->Printf(_L(string)); \
|
sl@0
|
246 |
aConsole->Printf(_L("\n")); \
|
sl@0
|
247 |
RDebug::Print(_L(string)); \
|
sl@0
|
248 |
} \
|
sl@0
|
249 |
} while (0)
|
sl@0
|
250 |
|
sl@0
|
251 |
#define TUSB_HEAPSIZE(string) \
|
sl@0
|
252 |
do { \
|
sl@0
|
253 |
TInt totalSize = 0; \
|
sl@0
|
254 |
TInt numCells = User::AllocSize (totalSize); \
|
sl@0
|
255 |
RDebug::Print(_L(string)); \
|
sl@0
|
256 |
RDebug::Print(_L(" Heap Cells %d Size %d\n"),numCells,totalSize); \
|
sl@0
|
257 |
} while (0)
|
sl@0
|
258 |
|
sl@0
|
259 |
#endif // __GENERAL_H__
|