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