|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
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 { \ |
|
146 iConsole->Printf(_L(string)); \ |
|
147 iConsole->Printf(_L("\n")); \ |
|
148 RDebug::Print(_L(string)); \ |
|
149 } while (0) |
|
150 |
|
151 #define TUSB_PRINT1(string, a) \ |
|
152 do { \ |
|
153 iConsole->Printf(_L(string), (a)); \ |
|
154 iConsole->Printf(_L("\n")); \ |
|
155 RDebug::Print(_L(string), (a)); \ |
|
156 } while (0) |
|
157 |
|
158 #define TUSB_PRINT2(string, a, b) \ |
|
159 do { \ |
|
160 iConsole->Printf(_L(string), (a), (b)); \ |
|
161 iConsole->Printf(_L("\n")); \ |
|
162 RDebug::Print(_L(string), (a), (b)); \ |
|
163 } while (0) |
|
164 |
|
165 #define TUSB_PRINT3(string, a, b, c) \ |
|
166 do { \ |
|
167 iConsole->Printf(_L(string), (a), (b), (c)); \ |
|
168 iConsole->Printf(_L("\n")); \ |
|
169 RDebug::Print(_L(string), (a), (b), (c)); \ |
|
170 } while (0) |
|
171 |
|
172 #define TUSB_PRINT4(string, a, b, c, d) \ |
|
173 do { \ |
|
174 iConsole->Printf(_L(string), (a), (b), (c), (d)); \ |
|
175 iConsole->Printf(_L("\n")); \ |
|
176 RDebug::Print(_L(string), (a), (b), (c), (d)); \ |
|
177 } while (0) |
|
178 |
|
179 #define TUSB_PRINT5(string, a, b, c, d, e) \ |
|
180 do { \ |
|
181 iConsole->Printf(_L(string), (a), (b), (c), (d), (e)); \ |
|
182 iConsole->Printf(_L("\n")); \ |
|
183 RDebug::Print(_L(string), (a), (b), (c), (d), (e)); \ |
|
184 } while (0) |
|
185 |
|
186 #define TUSB_PRINT6(string, a, b, c, d, e, f) \ |
|
187 do { \ |
|
188 iConsole->Printf(_L(string), (a), (b), (c), (d), (e), (f)); \ |
|
189 iConsole->Printf(_L("\n")); \ |
|
190 RDebug::Print(_L(string), (a), (b), (c), (d), (e), (f)); \ |
|
191 } while (0) |
|
192 |
|
193 #define TUSB_VERBOSE_PRINT(string) \ |
|
194 do { \ |
|
195 if (gVerbose) \ |
|
196 { \ |
|
197 TUSB_PRINT(string); \ |
|
198 } \ |
|
199 } while (0) |
|
200 |
|
201 #define TUSB_VERBOSE_PRINT1(string, a) \ |
|
202 do { \ |
|
203 if (gVerbose) \ |
|
204 { \ |
|
205 TUSB_PRINT1(string, a); \ |
|
206 } \ |
|
207 } while (0) |
|
208 |
|
209 #define TUSB_VERBOSE_PRINT2(string, a, b) \ |
|
210 do { \ |
|
211 if (gVerbose) \ |
|
212 { \ |
|
213 TUSB_PRINT2(string, a, b); \ |
|
214 } \ |
|
215 } while (0) |
|
216 |
|
217 #define TUSB_VERBOSE_PRINT3(string, a, b, c) \ |
|
218 do { \ |
|
219 if (gVerbose) \ |
|
220 { \ |
|
221 TUSB_PRINT3(string, a, b, c); \ |
|
222 } \ |
|
223 } while (0) |
|
224 |
|
225 #define TUSB_VERBOSE_PRINT4(string, a, b, c, d) \ |
|
226 do { \ |
|
227 if (gVerbose) \ |
|
228 { \ |
|
229 TUSB_PRINT4(string, a, b, c, d); \ |
|
230 } \ |
|
231 } while (0) |
|
232 |
|
233 #define TUSB_VERBOSE_PRINT5(string, a, b, c, d, e) \ |
|
234 do { \ |
|
235 if (gVerbose) \ |
|
236 { \ |
|
237 TUSB_PRINT5(string, a, b, c, d, e); \ |
|
238 } \ |
|
239 } while (0) |
|
240 |
|
241 #define TUSB_VERBOSE_APRINT(string) \ |
|
242 do { \ |
|
243 if (gVerbose) \ |
|
244 { \ |
|
245 aConsole->Printf(_L(string)); \ |
|
246 aConsole->Printf(_L("\n")); \ |
|
247 RDebug::Print(_L(string)); \ |
|
248 } \ |
|
249 } while (0) |
|
250 |
|
251 #define TUSB_HEAPSIZE(string) \ |
|
252 do { \ |
|
253 TInt totalSize = 0; \ |
|
254 TInt numCells = User::AllocSize (totalSize); \ |
|
255 RDebug::Print(_L(string)); \ |
|
256 RDebug::Print(_L(" Heap Cells %d Size %d\n"),numCells,totalSize); \ |
|
257 } while (0) |
|
258 |
|
259 #endif // __GENERAL_H__ |