253
|
1 |
// Copyright (c) 2000-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_usbdev/src/config.cpp
|
|
15 |
// USB Test Program T_USB_DEVICE.
|
|
16 |
// Reading and converting the XML configuration file.
|
253
|
17 |
//
|
0
|
18 |
//
|
|
19 |
|
|
20 |
#include "general.h"
|
253
|
21 |
#include "OstTraceDefinitions.h"
|
|
22 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
23 |
#include "configTraces.h"
|
|
24 |
#endif
|
0
|
25 |
#include "config.h"
|
|
26 |
|
|
27 |
_LIT(KCfgLDD,"LDD");
|
|
28 |
_LIT(KCfgLDD1,"ENDPOINTS");
|
|
29 |
_LIT(KCfgLDD2,"SOFTCONNECT");
|
|
30 |
_LIT(KCfgLDD3,"SELFPOWER");
|
|
31 |
_LIT(KCfgLDD4,"REMOTEWAKEUP");
|
|
32 |
_LIT(KCfgLDD5,"HIGHSPEED");
|
|
33 |
_LIT(KCfgLDD6,"FEATURES");
|
|
34 |
_LIT(KCfgLDD7,"MAXPOWER");
|
|
35 |
_LIT(KCfgLDD8,"EPSTALL");
|
|
36 |
_LIT(KCfgLDD9,"SPEC");
|
|
37 |
_LIT(KCfgLDD10,"VID");
|
|
38 |
_LIT(KCfgLDD11,"PID");
|
|
39 |
_LIT(KCfgLDD12,"RELEASE");
|
|
40 |
_LIT(KCfgLDD13,"MANUFACTURER");
|
|
41 |
_LIT(KCfgLDD14,"PRODUCT");
|
|
42 |
_LIT(KCfgLDD15,"SERIALNUMBER");
|
|
43 |
_LIT(KCfgLDD16,"OTG");
|
|
44 |
_LIT(KCfgIF,"INTERFACE");
|
|
45 |
_LIT(KCfgIFS,"ALT_SETTING");
|
|
46 |
_LIT(KCfgIF1,"CLASS");
|
|
47 |
_LIT(KCfgIF2,"SUBCLASS");
|
|
48 |
_LIT(KCfgIF3,"PROTOCOL");
|
|
49 |
_LIT(KCfgIF4,"DESCRIPTOR");
|
|
50 |
_LIT(KCfgIF5,"BANDWIDTH_IN");
|
|
51 |
_LIT(KCfgIF6,"BANDWIDTH_OUT");
|
|
52 |
_LIT(KCfgEP,"ENDPOINT");
|
|
53 |
_LIT(KCfgEP1,"SIZE");
|
|
54 |
_LIT(KCfgEP2,"INTERVAL");
|
|
55 |
_LIT(KCfgEP3,"HSINTERVAL");
|
|
56 |
_LIT(KCfgEP4,"HSTRANSACTIONS");
|
|
57 |
_LIT(KCfgEP5,"DMA");
|
|
58 |
_LIT(KCfgEP6,"DOUBLEBUFF");
|
|
59 |
_LIT(KCfgEP7,"EXTRA");
|
|
60 |
_LIT(KCfgEP8,"BUFFERSIZE");
|
|
61 |
_LIT(KCfgEP9,"READSIZE");
|
|
62 |
|
|
63 |
|
|
64 |
_LIT(KAttributeName,"name=");
|
|
65 |
_LIT(KAttributeNumber,"number=");
|
|
66 |
_LIT(KAttributeType,"type=");
|
|
67 |
_LIT(KAttributeDirection,"direction=");
|
|
68 |
|
|
69 |
_LIT(KEpBulk,"\"BULK\"");
|
|
70 |
_LIT(KEpInterrupt,"\"INTERRUPT\"");
|
|
71 |
_LIT(KEpIsochronous,"\"ISOCHRONOUS\"");
|
|
72 |
_LIT(KEpIn,"\"IN\"");
|
|
73 |
_LIT(KEpOut,"\"OUT\"");
|
|
74 |
|
|
75 |
static const TInt8 KMaxXMLNesting = 3; // max 3 levels of xml nesting
|
|
76 |
|
253
|
77 |
static const TPtrC xmlKeys[] =
|
0
|
78 |
{
|
|
79 |
(TDesC&)KCfgLDD, (TDesC&)KCfgLDD1, (TDesC&)KCfgLDD2, (TDesC&)KCfgLDD3, (TDesC&)KCfgLDD4, (TDesC&)KCfgLDD5, (TDesC&)KCfgLDD6,
|
|
80 |
(TDesC&)KCfgLDD7, (TDesC&)KCfgLDD8, (TDesC&)KCfgLDD9, (TDesC&)KCfgLDD10, (TDesC&)KCfgLDD11, (TDesC&)KCfgLDD12, (TDesC&)KCfgLDD13,
|
|
81 |
(TDesC&)KCfgLDD14, (TDesC&)KCfgLDD15, (TDesC&)KCfgLDD16,
|
|
82 |
(TDesC&)KCfgIF, (TDesC&)KCfgIFS, (TDesC&)KCfgIF1, (TDesC&)KCfgIF2, (TDesC&)KCfgIF3, (TDesC&)KCfgIF4, (TDesC&)KCfgIF5, (TDesC&)KCfgIF6,
|
|
83 |
(TDesC&)KCfgEP, (TDesC&)KCfgEP1, (TDesC&)KCfgEP2, (TDesC&)KCfgEP3, (TDesC&)KCfgEP4, (TDesC&)KCfgEP5, (TDesC&)KCfgEP6, (TDesC&)KCfgEP7, (TDesC&)KCfgEP8, (TDesC&)KCfgEP9
|
|
84 |
};
|
|
85 |
|
|
86 |
enum xmlIndex
|
|
87 |
{
|
|
88 |
ExiLdd = 0, // xmlKeys index for LDD
|
|
89 |
ExiEndpoints,
|
|
90 |
ExiSoftconnect,
|
|
91 |
ExiSelfPower,
|
|
92 |
ExiRemoteWakeup,
|
|
93 |
ExiHighSpeed,
|
|
94 |
ExiFeatures,
|
|
95 |
ExiMaxPower,
|
|
96 |
ExiEpStall,
|
|
97 |
ExiSpec,
|
|
98 |
ExiVID,
|
|
99 |
ExiPID,
|
|
100 |
ExiRelease,
|
|
101 |
ExiManufacturer,
|
|
102 |
ExiProduct,
|
|
103 |
ExiSerialNumber,
|
|
104 |
ExiOTG,
|
|
105 |
ExiInterface, // xmlKeys index for Interface
|
253
|
106 |
ExiSetting,
|
0
|
107 |
ExiClass,
|
|
108 |
ExiSubclass,
|
|
109 |
ExiProtocol,
|
|
110 |
ExiDescriptor,
|
|
111 |
ExiBandwidthIn,
|
|
112 |
ExiBandwidthOut,
|
|
113 |
ExiEndpoint, // xmlKeys index for Endpoint
|
|
114 |
ExiSize,
|
|
115 |
ExiInterval,
|
|
116 |
ExiHSInterval,
|
|
117 |
ExiHSTransactions,
|
|
118 |
ExiDMA,
|
|
119 |
ExiDoubleBuff,
|
|
120 |
ExiExtra,
|
|
121 |
ExiBufferSize,
|
|
122 |
ExiReadSize,
|
|
123 |
ExiLAST
|
|
124 |
};
|
253
|
125 |
|
0
|
126 |
// This array provides the index into xmlKeys for each level of xml key
|
|
127 |
// the first index for level n being defined by xmlLevels[n]
|
|
128 |
// and the last index for level n being defined by xmlLevels[n+1] - 1
|
|
129 |
// this means this must have two more entries than the number of nesting levels
|
253
|
130 |
// and the last entry must be the size of xmlKeys
|
|
131 |
static const TUint8 xmlLevels[] =
|
0
|
132 |
{
|
|
133 |
ExiLdd,ExiLdd+1,ExiSetting+1,ExiEndpoint+1,ExiLAST
|
|
134 |
};
|
|
135 |
|
|
136 |
LDDConfig::LDDConfig (TPtrC aName)
|
|
137 |
{
|
|
138 |
iPtrNext = NULL;
|
|
139 |
iIFPtr = NULL;
|
|
140 |
iName = aName;
|
|
141 |
iSoftConnect = ETrue;
|
|
142 |
iSelfPower = ETrue;
|
|
143 |
iRemoteWakeup = ETrue;
|
|
144 |
iHighSpeed = ETrue;
|
|
145 |
iEPStall = ETrue;
|
|
146 |
iNumEndpoints = 15;
|
|
147 |
iNumChannels = 0;
|
|
148 |
iFeatures = 1;
|
|
149 |
iMaxPower = 50;
|
|
150 |
iSpec = 0x0200;
|
|
151 |
iVid = 0x0E22;
|
|
152 |
iPid = 0x1111;
|
|
153 |
iRelease = 0x0305;
|
|
154 |
iManufacturer = NULL;
|
|
155 |
iProduct = NULL;
|
|
156 |
iSerialNumber = NULL;
|
|
157 |
iOtg_A = ETrue;
|
|
158 |
iOtg_altA = ETrue;
|
|
159 |
iOtg_altB = ETrue;
|
|
160 |
};
|
|
161 |
|
|
162 |
IFConfig::IFConfig(TUint8 aNumber)
|
|
163 |
{
|
|
164 |
iPtrNext = NULL;
|
|
165 |
iNumber = aNumber;
|
|
166 |
iAlternateSetting = EFalse;
|
|
167 |
#ifdef USB_SC
|
|
168 |
iInfoPtr = new TUsbcScInterfaceInfo(0xFF,0xFF,0xFF);
|
|
169 |
#else
|
|
170 |
iInfoPtr = new TUsbcInterfaceInfo(0xFF,0xFF,0xFF);
|
|
171 |
iBandwidthIn = EUsbcBandwidthINDefault;
|
|
172 |
iBandwidthOut = EUsbcBandwidthOUTDefault;
|
|
173 |
#endif
|
|
174 |
}
|
|
175 |
|
|
176 |
ConfigPtrs::ConfigPtrs (LDDConfigPtr * aLDDPtrPtr)
|
|
177 |
{
|
|
178 |
iNextLDDPtrPtr = aLDDPtrPtr;
|
|
179 |
iThisLDDPtr = * aLDDPtrPtr;
|
|
180 |
iThisIFPtr = NULL;
|
|
181 |
iNextIFPtrPtr = &iThisIFPtr; // initialised to prevent warning
|
|
182 |
}
|
|
183 |
|
|
184 |
extern RTest test;
|
|
185 |
extern TBool gVerbose;
|
|
186 |
extern TBool gSkip;
|
|
187 |
extern TBool gStopOnFail;
|
|
188 |
extern TInt gSoakCount;
|
|
189 |
|
|
190 |
bool ProcessConfigFile (RFile aConfigFile,CConsoleBase* iConsole, LDDConfigPtr * LDDPtrPtr)
|
|
191 |
{
|
|
192 |
TUSB_PRINT ("Processing Configuration File");
|
253
|
193 |
OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS, "Processing Configuration File");
|
|
194 |
|
0
|
195 |
TBuf8<100> configBuf;
|
|
196 |
TBuf<101> stringBuf;
|
|
197 |
bool done = false;
|
|
198 |
bool error = false;
|
|
199 |
TInt rStatus;
|
|
200 |
XMLState state = EEmpty;
|
|
201 |
TChar nextChar(' ');
|
|
202 |
TChar lastChar(' ');
|
|
203 |
TBuf<50> keyString;
|
|
204 |
TBuf<50> endkeyString;
|
|
205 |
TBuf<50> attributeString;
|
|
206 |
TBuf<50> valueString;
|
|
207 |
TInt level = -1;
|
|
208 |
TInt levelKeys[KMaxXMLNesting+1];
|
|
209 |
|
|
210 |
* LDDPtrPtr = NULL;
|
253
|
211 |
ConfigPtrsPtr cpPtr = new ConfigPtrs (LDDPtrPtr);
|
0
|
212 |
|
|
213 |
while (!done && !error)
|
|
214 |
{
|
|
215 |
rStatus = aConfigFile.Read((TDes8&)configBuf);
|
|
216 |
if (rStatus != KErrNone)
|
|
217 |
{
|
|
218 |
error = true;
|
253
|
219 |
TUSB_PRINT1("Config file error %d", rStatus);
|
|
220 |
OstTrace1(TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP01, "Config file error %d", rStatus);
|
0
|
221 |
}
|
|
222 |
else
|
|
223 |
{
|
|
224 |
if (configBuf.Length() == 0)
|
|
225 |
{
|
253
|
226 |
done = true;
|
0
|
227 |
}
|
|
228 |
else
|
|
229 |
{
|
|
230 |
stringBuf.Copy(configBuf);
|
|
231 |
for (TInt i = 0; i < stringBuf.Length() && !error; i++)
|
|
232 |
{
|
|
233 |
lastChar = nextChar;
|
|
234 |
nextChar = stringBuf[i];
|
|
235 |
if (((nextChar == '<') && !((state == EEmpty) || (state == EValue))) ||
|
|
236 |
((nextChar == '>') && ((state == EEmpty) || (state == EValue))) ||
|
|
237 |
((nextChar == '/') && (lastChar != '<')))
|
|
238 |
{
|
|
239 |
error = true;
|
|
240 |
TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
|
253
|
241 |
OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP02, "Config File Syntax Error at index %d of %S",i,stringBuf);
|
0
|
242 |
}
|
|
243 |
switch (state)
|
|
244 |
{
|
|
245 |
case EEmpty:
|
|
246 |
if (nextChar == '<')
|
|
247 |
{
|
|
248 |
state = EStartKey;
|
|
249 |
}
|
|
250 |
else
|
|
251 |
if (!nextChar.IsSpace())
|
|
252 |
{
|
|
253 |
error = true;
|
|
254 |
TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
|
253
|
255 |
OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP03, "Config File Syntax Error at index %d of %S",i,stringBuf);
|
0
|
256 |
}
|
|
257 |
break;
|
253
|
258 |
|
0
|
259 |
case EStartKey:
|
|
260 |
if (nextChar == '/')
|
|
261 |
{
|
|
262 |
state = EEndKey;
|
253
|
263 |
endkeyString.SetLength(0);
|
0
|
264 |
}
|
|
265 |
else
|
|
266 |
{
|
|
267 |
if (nextChar == '>')
|
|
268 |
{
|
|
269 |
level++;
|
|
270 |
if (level > KMaxXMLNesting)
|
|
271 |
{
|
|
272 |
error = true;
|
253
|
273 |
TUSB_PRINT1 ("Config File Too Many levels %s",stringBuf.PtrZ());
|
|
274 |
OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP04, "Config File Too Many levels %S",stringBuf);
|
0
|
275 |
}
|
|
276 |
else
|
|
277 |
{
|
|
278 |
levelKeys[level] = CheckXmlKey (keyString,level);
|
|
279 |
if (levelKeys[level] < 0)
|
|
280 |
{
|
|
281 |
error = true;
|
253
|
282 |
TUSB_PRINT1 ("Invalid XML key %s",keyString.PtrZ());
|
|
283 |
OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP05, "Invalid XML key %S",keyString);
|
0
|
284 |
}
|
|
285 |
else
|
|
286 |
{
|
|
287 |
if (CheckAttribute(iConsole,cpPtr,levelKeys[level],attributeString))
|
|
288 |
{
|
|
289 |
state = EValue;
|
253
|
290 |
TUSB_VERBOSE_PRINT2 ("Start key: %s level %d",keyString.PtrZ(),level);
|
|
291 |
if(gVerbose)
|
|
292 |
{
|
|
293 |
OstTraceExt2 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP06, "Start key: %S level %d",keyString,level);
|
|
294 |
}
|
0
|
295 |
}
|
|
296 |
else
|
|
297 |
{
|
253
|
298 |
error = true;
|
|
299 |
TUSB_PRINT1 ("No attribute for XML key %s",keyString.PtrZ());
|
|
300 |
OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP07, "No attribute for XML key %S",keyString);
|
0
|
301 |
}
|
|
302 |
}
|
|
303 |
}
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
if (lastChar == '<')
|
|
308 |
{
|
|
309 |
keyString.SetLength(0);
|
|
310 |
valueString.SetLength(0);
|
|
311 |
attributeString.SetLength(0);
|
|
312 |
if (nextChar.IsSpace())
|
|
313 |
{
|
|
314 |
error = true;
|
253
|
315 |
TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
|
|
316 |
OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP08, "Config File Syntax Error at index %d of %S",i,stringBuf);
|
0
|
317 |
}
|
|
318 |
}
|
|
319 |
if (nextChar.IsSpace())
|
|
320 |
{
|
|
321 |
state = EAttribute;
|
|
322 |
}
|
|
323 |
else
|
|
324 |
{
|
|
325 |
keyString.Append(nextChar);
|
|
326 |
}
|
|
327 |
}
|
|
328 |
}
|
|
329 |
break;
|
253
|
330 |
|
0
|
331 |
case EEndKey:
|
|
332 |
if (nextChar == '>')
|
|
333 |
{
|
|
334 |
if (levelKeys[level] != CheckXmlKey (endkeyString,level))
|
|
335 |
{
|
|
336 |
error = true;
|
253
|
337 |
TUSB_PRINT1 ("Invalid XML end key %s",endkeyString.PtrZ());
|
|
338 |
OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP09, "Invalid XML end key %S",endkeyString);
|
0
|
339 |
}
|
|
340 |
else
|
253
|
341 |
{
|
0
|
342 |
if (CheckValue(iConsole,cpPtr,levelKeys[level],valueString))
|
|
343 |
{
|
|
344 |
state = EEmpty;
|
|
345 |
TUSB_VERBOSE_PRINT2 ("End Key: %s value %s",endkeyString.PtrZ(),valueString.PtrZ());
|
253
|
346 |
if(gVerbose)
|
|
347 |
{
|
|
348 |
OstTraceExt2 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP10, "End Key: %S value %S",endkeyString,valueString);
|
|
349 |
}
|
0
|
350 |
level--;
|
|
351 |
valueString.SetLength(0);
|
|
352 |
}
|
|
353 |
else
|
|
354 |
{
|
|
355 |
error = true;
|
253
|
356 |
TUSB_PRINT2 ("Incorrect value string %s for XML key %s",valueString.PtrZ(),endkeyString.PtrZ());
|
|
357 |
OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP11, "Incorrect value string %S for XML key %S",valueString,endkeyString);
|
0
|
358 |
}
|
|
359 |
}
|
|
360 |
}
|
|
361 |
if (nextChar.IsSpace())
|
|
362 |
{
|
|
363 |
error = true;
|
|
364 |
TUSB_PRINT2 ("Config File Syntax Error at index %d of %s",i,stringBuf.PtrZ());
|
253
|
365 |
OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP12, "Config File Syntax Error at index %d of %S",i,stringBuf);
|
0
|
366 |
}
|
|
367 |
else
|
|
368 |
{
|
|
369 |
endkeyString.Append(nextChar);
|
|
370 |
}
|
|
371 |
break;
|
253
|
372 |
|
0
|
373 |
case EAttribute:
|
|
374 |
if (nextChar == '>')
|
|
375 |
{
|
|
376 |
level++;
|
|
377 |
if (level > KMaxXMLNesting)
|
|
378 |
{
|
|
379 |
error = true;
|
253
|
380 |
TUSB_PRINT1 ("Config File Too Many levels %s",stringBuf.PtrZ());
|
|
381 |
OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP13, "Config File Too Many levels %s",stringBuf);
|
0
|
382 |
}
|
|
383 |
else
|
|
384 |
{
|
|
385 |
levelKeys[level] = CheckXmlKey (keyString,level);
|
|
386 |
if (levelKeys[level] < 0)
|
|
387 |
{
|
|
388 |
error = true;
|
253
|
389 |
TUSB_PRINT1 ("Invalid XML key %s",keyString.PtrZ());
|
|
390 |
OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP14, "Invalid XML key %s",keyString);
|
0
|
391 |
}
|
|
392 |
else
|
|
393 |
{
|
|
394 |
if (CheckAttribute(iConsole,cpPtr,levelKeys[level],attributeString))
|
|
395 |
{
|
|
396 |
state = EValue;
|
|
397 |
TUSB_VERBOSE_PRINT3 ("Start key: %s level %d attribute %s",keyString.PtrZ(),level,attributeString.PtrZ());
|
253
|
398 |
if(gVerbose)
|
|
399 |
{
|
|
400 |
OstTraceExt3 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP15, "Start key: %S level %d attribute %S",keyString,level,attributeString);
|
|
401 |
}
|
0
|
402 |
}
|
|
403 |
else
|
|
404 |
{
|
253
|
405 |
error = true;
|
|
406 |
TUSB_PRINT2 ("Incorrect attribute %s for XML key %s",attributeString.PtrZ(),keyString.PtrZ());
|
|
407 |
OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP16, "Incorrect attribute %s for XML key %s",attributeString,keyString);
|
0
|
408 |
}
|
|
409 |
}
|
|
410 |
}
|
|
411 |
}
|
|
412 |
else
|
|
413 |
{
|
|
414 |
attributeString.Append(nextChar);
|
|
415 |
}
|
|
416 |
break;
|
253
|
417 |
|
0
|
418 |
case EValue:
|
|
419 |
if (nextChar == '<')
|
|
420 |
{
|
|
421 |
state = EStartKey;
|
|
422 |
}
|
|
423 |
else
|
|
424 |
{
|
|
425 |
// Don't add any leading spaces
|
|
426 |
if (!nextChar.IsSpace() || valueString.Length() != 0)
|
|
427 |
{
|
253
|
428 |
valueString.Append(nextChar);
|
0
|
429 |
}
|
|
430 |
}
|
|
431 |
break;
|
|
432 |
}
|
|
433 |
}
|
|
434 |
}
|
|
435 |
}
|
|
436 |
}
|
253
|
437 |
|
0
|
438 |
delete cpPtr;
|
|
439 |
|
|
440 |
return !error;
|
|
441 |
}
|
|
442 |
|
|
443 |
|
253
|
444 |
|
0
|
445 |
TBool CheckAttribute (CConsoleBase* iConsole, ConfigPtrsPtr cpPtr,TInt aKeyIndex, TPtrC aDes)
|
|
446 |
{
|
|
447 |
TBool retValue = ETrue;
|
|
448 |
TBuf<50> attrib = aDes;
|
|
449 |
TInt typePos;
|
|
450 |
TInt dirPos;
|
|
451 |
TInt typeLen;
|
|
452 |
TInt dirLen;
|
|
453 |
TUint epType = 0;
|
|
454 |
TUint epDir = 0;
|
|
455 |
TUint ifNumber = 0;
|
|
456 |
|
|
457 |
_LIT (KQuote,"\"");
|
|
458 |
|
|
459 |
switch (aKeyIndex)
|
|
460 |
{
|
|
461 |
// level 0 index LDD
|
|
462 |
case ExiLdd :
|
|
463 |
if (attrib.Find(KAttributeName) == 0)
|
|
464 |
{
|
|
465 |
attrib.Delete(0,((TDesC&)KAttributeName).Length());
|
|
466 |
if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0])
|
|
467 |
{
|
|
468 |
TUSB_VERBOSE_PRINT1 ("LDD with attribute name %s",attrib.PtrZ());
|
253
|
469 |
if(gVerbose)
|
|
470 |
{
|
|
471 |
OstTraceExt1 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP17, "LDD with attribute name %s",attrib);
|
|
472 |
}
|
|
473 |
cpPtr->iThisLDDPtr = new LDDConfig (attrib.MidTPtr(1,attrib.Length()-2));
|
0
|
474 |
*cpPtr->iNextLDDPtrPtr = cpPtr->iThisLDDPtr;
|
|
475 |
cpPtr->iNextLDDPtrPtr = &(cpPtr->iThisLDDPtr->iPtrNext);
|
253
|
476 |
cpPtr->iNextIFPtrPtr = &(cpPtr->iThisLDDPtr->iIFPtr);
|
0
|
477 |
}
|
|
478 |
else
|
|
479 |
retValue = EFalse;
|
|
480 |
}
|
|
481 |
else
|
|
482 |
{
|
|
483 |
retValue = EFalse;
|
|
484 |
}
|
|
485 |
break;
|
253
|
486 |
|
0
|
487 |
// level 1 index INTERFACE
|
|
488 |
case ExiInterface :
|
|
489 |
if (attrib.Find(KAttributeNumber) == 0)
|
|
490 |
{
|
|
491 |
attrib.Delete(0,((TDesC&)KAttributeNumber).Length());
|
|
492 |
if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0])
|
|
493 |
{
|
|
494 |
if (TDesToTUint(attrib.MidTPtr(1,attrib.Length()-2), &ifNumber))
|
|
495 |
{
|
|
496 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
497 |
{
|
|
498 |
TUSB_PRINT ("No LDD container for interface");
|
253
|
499 |
OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP18, "No LDD container for interface");
|
|
500 |
retValue = EFalse;
|
0
|
501 |
}
|
|
502 |
}
|
|
503 |
else
|
|
504 |
{
|
|
505 |
TUSB_PRINT2 ("Number conversion error %s %d",attrib.PtrZ(),ifNumber);
|
253
|
506 |
OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP19, "Number conversion error %S %u",attrib,ifNumber);
|
0
|
507 |
retValue = EFalse;
|
|
508 |
}
|
|
509 |
}
|
|
510 |
else
|
|
511 |
{
|
|
512 |
TUSB_PRINT1 ("Attribute number not in \"\" %s",attrib.PtrZ());
|
253
|
513 |
OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP20, "Attribute number not in \"\" %s",attrib);
|
|
514 |
retValue = EFalse;
|
0
|
515 |
}
|
|
516 |
}
|
|
517 |
if (retValue)
|
|
518 |
{
|
|
519 |
TUSB_VERBOSE_PRINT1 ("Interface number %d",ifNumber);
|
253
|
520 |
if(gVerbose)
|
|
521 |
{
|
|
522 |
OstTrace1 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP21, "Interface number %d",ifNumber);
|
|
523 |
}
|
0
|
524 |
cpPtr->iThisIFPtr = new IFConfig ((TUint8)ifNumber);
|
|
525 |
* cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr;
|
|
526 |
cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext;
|
|
527 |
cpPtr->iThisLDDPtr->iNumChannels++;
|
|
528 |
}
|
253
|
529 |
break;
|
|
530 |
|
0
|
531 |
|
|
532 |
// level 1 index Setting
|
|
533 |
case ExiSetting :
|
|
534 |
if (aDes.Length() != 0)
|
|
535 |
{
|
|
536 |
retValue = EFalse;
|
|
537 |
}
|
|
538 |
else
|
|
539 |
{
|
|
540 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
541 |
{
|
|
542 |
TUSB_PRINT ("No LDD container for interface");
|
253
|
543 |
OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP22, "No LDD container for interface");
|
|
544 |
retValue = EFalse;
|
0
|
545 |
}
|
|
546 |
else
|
|
547 |
{
|
253
|
548 |
TUSB_VERBOSE_PRINT ("Alternate Interface Setting");
|
|
549 |
if(gVerbose)
|
|
550 |
{
|
|
551 |
OstTrace0 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP23, "Alternate Interface Setting");
|
|
552 |
}
|
|
553 |
cpPtr->iThisIFPtr = new IFConfig (0);
|
0
|
554 |
* cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr;
|
|
555 |
cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext;
|
|
556 |
cpPtr->iThisIFPtr->iAlternateSetting = ETrue;
|
253
|
557 |
}
|
0
|
558 |
}
|
|
559 |
break;
|
253
|
560 |
|
0
|
561 |
// level 2 index ENDPOINT
|
|
562 |
case ExiEndpoint :
|
|
563 |
typePos = attrib.Find(KAttributeType);
|
|
564 |
dirPos = attrib.Find(KAttributeDirection);
|
253
|
565 |
|
0
|
566 |
if (typePos == KErrNotFound || dirPos == KErrNotFound)
|
|
567 |
{
|
|
568 |
retValue = EFalse;
|
|
569 |
}
|
253
|
570 |
else
|
0
|
571 |
{
|
|
572 |
if (typePos < dirPos)
|
|
573 |
{
|
|
574 |
typePos += ((TDesC&)KAttributeType).Length();
|
|
575 |
typeLen = dirPos - typePos;
|
|
576 |
dirPos += ((TDesC&)KAttributeDirection).Length();
|
253
|
577 |
dirLen = attrib.Length() - dirPos;
|
0
|
578 |
}
|
|
579 |
else
|
|
580 |
{
|
253
|
581 |
dirPos += ((TDesC&)KAttributeDirection).Length();
|
0
|
582 |
dirLen = typePos - dirPos;
|
|
583 |
typePos += ((TDesC&)KAttributeType).Length();
|
253
|
584 |
typeLen = attrib.Length() - typePos;
|
0
|
585 |
}
|
|
586 |
TPtr attribPtr = attrib.MidTPtr(typePos,typeLen);
|
|
587 |
attribPtr.UpperCase();
|
|
588 |
attribPtr.TrimAll();
|
|
589 |
if (attribPtr == KEpBulk)
|
|
590 |
{
|
|
591 |
epType = KUsbEpTypeBulk;
|
|
592 |
}
|
|
593 |
else
|
|
594 |
{
|
|
595 |
if (attribPtr == KEpInterrupt)
|
|
596 |
{
|
|
597 |
epType = KUsbEpTypeInterrupt;
|
|
598 |
}
|
|
599 |
else
|
|
600 |
{
|
|
601 |
if (attribPtr == KEpIsochronous)
|
|
602 |
{
|
|
603 |
epType = KUsbEpTypeIsochronous;
|
|
604 |
}
|
|
605 |
else
|
|
606 |
{
|
253
|
607 |
retValue = EFalse;
|
0
|
608 |
}
|
|
609 |
}
|
|
610 |
}
|
|
611 |
attribPtr = attrib.MidTPtr(dirPos,dirLen);
|
|
612 |
attribPtr.UpperCase();
|
|
613 |
attribPtr.TrimAll();
|
|
614 |
if (attribPtr == KEpIn)
|
|
615 |
{
|
|
616 |
epDir = KUsbEpDirIn;
|
|
617 |
}
|
|
618 |
else
|
|
619 |
{
|
|
620 |
if (attribPtr == KEpOut)
|
|
621 |
{
|
|
622 |
epDir = KUsbEpDirOut;
|
|
623 |
}
|
|
624 |
else
|
|
625 |
{
|
|
626 |
retValue = EFalse;
|
|
627 |
}
|
|
628 |
}
|
|
629 |
if (retValue)
|
|
630 |
{
|
|
631 |
if (cpPtr->iThisIFPtr == NULL)
|
|
632 |
{
|
|
633 |
TUSB_PRINT ("No Interface container for Endpoint");
|
253
|
634 |
OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP24, "No Interface container for Endpoint");
|
|
635 |
retValue = EFalse;
|
0
|
636 |
}
|
|
637 |
else
|
|
638 |
{
|
|
639 |
TUint epIndex = cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed;
|
253
|
640 |
TUSB_VERBOSE_PRINT2 ("Endpoint with type %d %d",epType,epDir);
|
|
641 |
if(gVerbose)
|
|
642 |
{
|
|
643 |
OstTraceExt2 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP25, "Endpoint with type %u %u",(TUint32)epType,(TUint32)epDir);
|
|
644 |
}
|
0
|
645 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType = epType;
|
|
646 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iDir = epDir;
|
|
647 |
#ifdef USB_SC
|
|
648 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iBufferSize = 65536;
|
|
649 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iReadSize = 4096;
|
|
650 |
#endif
|
|
651 |
cpPtr->iThisIFPtr->iEpDMA[epIndex] = EFalse;
|
|
652 |
cpPtr->iThisIFPtr->iEpDoubleBuff[epIndex] = EFalse;
|
|
653 |
cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed++;
|
|
654 |
}
|
|
655 |
}
|
|
656 |
}
|
|
657 |
break;
|
253
|
658 |
|
0
|
659 |
default :
|
|
660 |
if (aDes.Length() != 0)
|
|
661 |
{
|
|
662 |
retValue = EFalse;
|
|
663 |
}
|
|
664 |
}
|
253
|
665 |
|
0
|
666 |
return retValue;
|
|
667 |
}
|
|
668 |
|
|
669 |
TBool CheckValue (CConsoleBase* iConsole, ConfigPtrsPtr cpPtr, TInt aKeyIndex, TPtrC16 aDes)
|
|
670 |
{
|
|
671 |
TBool retValue = ETrue;
|
|
672 |
TBool boolValue;
|
|
673 |
TUint uintValue;
|
|
674 |
TInt epIndex = -1;
|
253
|
675 |
|
0
|
676 |
if (cpPtr->iThisIFPtr != NULL)
|
|
677 |
{
|
|
678 |
epIndex = cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed -1;
|
|
679 |
}
|
253
|
680 |
|
0
|
681 |
TUSB_VERBOSE_PRINT2 ("CheckValue keyIndex %d %s",aKeyIndex,aDes.Ptr());
|
253
|
682 |
if(gVerbose)
|
|
683 |
{
|
|
684 |
OstTraceExt2 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP26, "CheckValue keyIndex %d %s",aKeyIndex,aDes);
|
|
685 |
}
|
0
|
686 |
switch (aKeyIndex)
|
|
687 |
{
|
|
688 |
case ExiLdd: // xmlKeys index for LDD
|
|
689 |
case ExiInterface: // xmlKeys index for Interface
|
|
690 |
case ExiEndpoint: // xmlKeys index for Endpoint
|
|
691 |
if (aDes.Length() != 0)
|
|
692 |
{
|
|
693 |
retValue = EFalse;
|
|
694 |
}
|
|
695 |
break;
|
253
|
696 |
|
0
|
697 |
case ExiEndpoints:
|
|
698 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
699 |
if (uintValue == 0 || uintValue > 128)
|
|
700 |
{
|
253
|
701 |
retValue = EFalse;
|
0
|
702 |
}
|
|
703 |
else
|
|
704 |
{
|
|
705 |
cpPtr->iThisLDDPtr->iNumEndpoints = uintValue;
|
|
706 |
}
|
|
707 |
break;
|
253
|
708 |
|
0
|
709 |
case ExiSoftconnect:
|
|
710 |
retValue = TDesToBool (aDes, &boolValue);
|
|
711 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
712 |
retValue = EFalse;
|
|
713 |
if (retValue)
|
|
714 |
{
|
|
715 |
cpPtr->iThisLDDPtr->iSoftConnect = boolValue;
|
|
716 |
}
|
|
717 |
break;
|
253
|
718 |
|
0
|
719 |
case ExiSelfPower:
|
|
720 |
retValue = TDesToBool (aDes, &boolValue);
|
|
721 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
722 |
retValue = EFalse;
|
|
723 |
if (retValue)
|
|
724 |
{
|
|
725 |
cpPtr->iThisLDDPtr->iSelfPower = boolValue;
|
|
726 |
}
|
|
727 |
break;
|
253
|
728 |
|
0
|
729 |
case ExiRemoteWakeup:
|
|
730 |
retValue = TDesToBool (aDes, &boolValue);
|
|
731 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
732 |
retValue = EFalse;
|
|
733 |
if (retValue)
|
|
734 |
{
|
|
735 |
cpPtr->iThisLDDPtr->iRemoteWakeup = boolValue;
|
|
736 |
}
|
|
737 |
break;
|
253
|
738 |
|
0
|
739 |
case ExiHighSpeed:
|
|
740 |
retValue = TDesToBool (aDes, &boolValue);
|
|
741 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
742 |
retValue = EFalse;
|
|
743 |
if (retValue)
|
|
744 |
{
|
|
745 |
cpPtr->iThisLDDPtr->iHighSpeed = boolValue;
|
|
746 |
}
|
|
747 |
break;
|
253
|
748 |
|
0
|
749 |
case ExiFeatures:
|
|
750 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
751 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
752 |
retValue = EFalse;
|
|
753 |
if (retValue)
|
|
754 |
{
|
|
755 |
cpPtr->iThisLDDPtr->iFeatures = uintValue;
|
|
756 |
}
|
|
757 |
break;
|
253
|
758 |
|
0
|
759 |
case ExiMaxPower:
|
|
760 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
761 |
if (cpPtr->iThisLDDPtr == NULL || uintValue > 50)
|
|
762 |
retValue = EFalse;
|
|
763 |
if (retValue)
|
|
764 |
{
|
|
765 |
cpPtr->iThisLDDPtr->iMaxPower = uintValue;
|
|
766 |
}
|
|
767 |
break;
|
253
|
768 |
|
0
|
769 |
case ExiEpStall:
|
|
770 |
retValue = TDesToBool (aDes, &boolValue);
|
|
771 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
772 |
retValue = EFalse;
|
|
773 |
if (retValue)
|
|
774 |
{
|
|
775 |
cpPtr->iThisLDDPtr->iEPStall = boolValue;
|
|
776 |
}
|
|
777 |
break;
|
253
|
778 |
|
0
|
779 |
case ExiSpec:
|
|
780 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
781 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
782 |
retValue = EFalse;
|
|
783 |
if (retValue)
|
|
784 |
{
|
|
785 |
cpPtr->iThisLDDPtr->iSpec = uintValue;
|
|
786 |
}
|
|
787 |
break;
|
253
|
788 |
|
0
|
789 |
case ExiVID:
|
|
790 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
791 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
792 |
retValue = EFalse;
|
|
793 |
if (retValue)
|
|
794 |
{
|
|
795 |
cpPtr->iThisLDDPtr->iVid = uintValue;
|
|
796 |
}
|
|
797 |
break;
|
253
|
798 |
|
0
|
799 |
case ExiPID:
|
|
800 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
801 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
802 |
retValue = EFalse;
|
|
803 |
if (retValue)
|
|
804 |
{
|
|
805 |
cpPtr->iThisLDDPtr->iPid = uintValue;
|
|
806 |
}
|
|
807 |
break;
|
253
|
808 |
|
0
|
809 |
case ExiRelease:
|
|
810 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
811 |
if (cpPtr->iThisLDDPtr == NULL)
|
|
812 |
retValue = EFalse;
|
|
813 |
if (retValue)
|
|
814 |
{
|
|
815 |
cpPtr->iThisLDDPtr->iRelease = uintValue;
|
|
816 |
}
|
|
817 |
break;
|
253
|
818 |
|
0
|
819 |
case ExiManufacturer:
|
|
820 |
cpPtr->iThisLDDPtr->iManufacturer = aDes.Alloc();
|
|
821 |
break;
|
|
822 |
|
|
823 |
case ExiProduct:
|
|
824 |
cpPtr->iThisLDDPtr->iProduct = aDes.Alloc();
|
|
825 |
break;
|
|
826 |
|
|
827 |
case ExiSerialNumber:
|
|
828 |
cpPtr->iThisLDDPtr->iSerialNumber = aDes.Alloc();
|
|
829 |
break;
|
|
830 |
|
|
831 |
case ExiOTG:
|
|
832 |
break;
|
253
|
833 |
|
0
|
834 |
case ExiClass:
|
|
835 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
836 |
if (cpPtr->iThisIFPtr == NULL || uintValue > 0xFF)
|
|
837 |
retValue = EFalse;
|
|
838 |
if (retValue)
|
|
839 |
{
|
|
840 |
cpPtr->iThisIFPtr->iInfoPtr->iClass.iClassNum = uintValue;
|
|
841 |
}
|
|
842 |
break;
|
253
|
843 |
|
0
|
844 |
case ExiSubclass:
|
|
845 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
846 |
if (cpPtr->iThisIFPtr == NULL || uintValue > 0xFF)
|
|
847 |
retValue = EFalse;
|
|
848 |
if (retValue)
|
|
849 |
{
|
|
850 |
cpPtr->iThisIFPtr->iInfoPtr->iClass.iSubClassNum = uintValue;
|
|
851 |
}
|
|
852 |
break;
|
253
|
853 |
|
0
|
854 |
case ExiProtocol:
|
|
855 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
856 |
if (cpPtr->iThisIFPtr == NULL || uintValue > 0xFF)
|
|
857 |
retValue = EFalse;
|
|
858 |
if (retValue)
|
|
859 |
{
|
|
860 |
cpPtr->iThisIFPtr->iInfoPtr->iClass.iProtocolNum = uintValue;
|
|
861 |
}
|
|
862 |
break;
|
253
|
863 |
|
0
|
864 |
case ExiDescriptor:
|
|
865 |
cpPtr->iThisIFPtr->iInfoPtr->iString = aDes.Alloc();
|
|
866 |
break;
|
253
|
867 |
|
0
|
868 |
case ExiBandwidthIn:
|
|
869 |
#ifdef USB_SC
|
|
870 |
retValue = EFalse;
|
253
|
871 |
#else
|
0
|
872 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
873 |
if (cpPtr->iThisIFPtr == NULL || uintValue > 3)
|
|
874 |
retValue = EFalse;
|
|
875 |
if (retValue)
|
|
876 |
{
|
|
877 |
switch (uintValue)
|
|
878 |
{
|
|
879 |
case 0:
|
|
880 |
cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINDefault;
|
|
881 |
break;
|
|
882 |
case 1:
|
|
883 |
cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINPlus1;
|
|
884 |
break;
|
|
885 |
case 2:
|
|
886 |
cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINPlus2;
|
|
887 |
break;
|
|
888 |
case 3:
|
|
889 |
cpPtr->iThisIFPtr->iBandwidthIn = EUsbcBandwidthINMaximum;
|
|
890 |
break;
|
|
891 |
}
|
|
892 |
}
|
|
893 |
#endif
|
|
894 |
break;
|
253
|
895 |
|
0
|
896 |
case ExiBandwidthOut:
|
|
897 |
#ifdef USB_SC
|
|
898 |
retValue = EFalse;
|
253
|
899 |
#else
|
0
|
900 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
901 |
if (cpPtr->iThisIFPtr == NULL || uintValue > 3)
|
|
902 |
retValue = EFalse;
|
|
903 |
if (retValue)
|
|
904 |
{
|
|
905 |
switch (uintValue)
|
|
906 |
{
|
|
907 |
case 0:
|
|
908 |
cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTDefault;
|
|
909 |
break;
|
|
910 |
case 1:
|
|
911 |
cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTPlus1;
|
|
912 |
break;
|
|
913 |
case 2:
|
|
914 |
cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTPlus2;
|
|
915 |
break;
|
|
916 |
case 3:
|
|
917 |
cpPtr->iThisIFPtr->iBandwidthOut = EUsbcBandwidthOUTMaximum;
|
|
918 |
break;
|
|
919 |
}
|
|
920 |
}
|
|
921 |
#endif
|
|
922 |
break;
|
253
|
923 |
|
0
|
924 |
case ExiSize:
|
|
925 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
926 |
if (epIndex < 0)
|
|
927 |
retValue = EFalse;
|
|
928 |
if (retValue)
|
|
929 |
{
|
|
930 |
TBool defaultIF = cpPtr->iThisLDDPtr->iIFPtr == cpPtr->iThisIFPtr;
|
|
931 |
switch (cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType)
|
|
932 |
{
|
|
933 |
case KUsbEpTypeBulk :
|
|
934 |
if (cpPtr->iThisLDDPtr->iHighSpeed)
|
|
935 |
{
|
|
936 |
if (uintValue != 512)
|
|
937 |
retValue = EFalse;
|
|
938 |
}
|
|
939 |
else
|
|
940 |
{
|
|
941 |
if (!(uintValue == 8 || uintValue == 16 || uintValue == 32 || uintValue == 64))
|
|
942 |
retValue = EFalse;
|
|
943 |
}
|
|
944 |
break;
|
253
|
945 |
|
0
|
946 |
case KUsbEpTypeInterrupt :
|
|
947 |
if ((defaultIF && uintValue > 64) ||
|
|
948 |
(!cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 64) ||
|
|
949 |
(!defaultIF && cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 1024))
|
|
950 |
retValue = EFalse;
|
|
951 |
break;
|
253
|
952 |
|
0
|
953 |
case KUsbEpTypeIsochronous :
|
|
954 |
if ((defaultIF && uintValue > 0) ||
|
|
955 |
(!defaultIF && !cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 1023) ||
|
|
956 |
(!defaultIF && cpPtr->iThisLDDPtr->iHighSpeed && uintValue > 1024))
|
|
957 |
retValue = EFalse;
|
253
|
958 |
break;
|
0
|
959 |
}
|
|
960 |
if (retValue)
|
|
961 |
{
|
|
962 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iSize = uintValue;
|
|
963 |
}
|
|
964 |
}
|
253
|
965 |
|
0
|
966 |
break;
|
253
|
967 |
|
0
|
968 |
case ExiInterval:
|
|
969 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
970 |
if (epIndex < 0)
|
|
971 |
retValue = EFalse;
|
|
972 |
if (retValue)
|
|
973 |
{
|
|
974 |
switch (cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType)
|
|
975 |
{
|
|
976 |
case KUsbEpTypeBulk :
|
|
977 |
retValue = EFalse;
|
|
978 |
break;
|
253
|
979 |
|
0
|
980 |
case KUsbEpTypeInterrupt :
|
|
981 |
if (uintValue < 1 || uintValue > 255)
|
|
982 |
retValue = EFalse;
|
|
983 |
break;
|
253
|
984 |
|
0
|
985 |
case KUsbEpTypeIsochronous :
|
|
986 |
if (uintValue < 1 || uintValue > 16)
|
|
987 |
retValue = EFalse;
|
253
|
988 |
break;
|
0
|
989 |
}
|
|
990 |
if (retValue)
|
|
991 |
{
|
|
992 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iInterval = uintValue;
|
|
993 |
}
|
|
994 |
}
|
|
995 |
break;
|
253
|
996 |
|
0
|
997 |
case ExiHSInterval:
|
|
998 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
999 |
if (epIndex < 0 || !cpPtr->iThisLDDPtr->iHighSpeed)
|
|
1000 |
retValue = EFalse;
|
|
1001 |
if (retValue)
|
|
1002 |
{
|
|
1003 |
switch (cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType)
|
|
1004 |
{
|
|
1005 |
case KUsbEpTypeBulk :
|
|
1006 |
if (uintValue > 255)
|
|
1007 |
retValue = EFalse;
|
|
1008 |
break;
|
253
|
1009 |
|
0
|
1010 |
case KUsbEpTypeInterrupt :
|
|
1011 |
if (uintValue < 1 || uintValue > 16)
|
|
1012 |
retValue = EFalse;
|
|
1013 |
break;
|
253
|
1014 |
|
0
|
1015 |
case KUsbEpTypeIsochronous :
|
|
1016 |
if (uintValue < 1 || uintValue > 16)
|
|
1017 |
retValue = EFalse;
|
253
|
1018 |
break;
|
0
|
1019 |
}
|
|
1020 |
if (retValue)
|
|
1021 |
{
|
|
1022 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iInterval_Hs = uintValue;
|
|
1023 |
}
|
|
1024 |
}
|
|
1025 |
break;
|
253
|
1026 |
|
0
|
1027 |
case ExiHSTransactions:
|
|
1028 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
1029 |
if (epIndex < 0 || !cpPtr->iThisLDDPtr->iHighSpeed)
|
|
1030 |
retValue = EFalse;
|
|
1031 |
if (retValue)
|
|
1032 |
{
|
|
1033 |
if (uintValue > 2)
|
|
1034 |
retValue = EFalse;
|
|
1035 |
if (retValue)
|
|
1036 |
{
|
|
1037 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iTransactions = uintValue;
|
|
1038 |
}
|
|
1039 |
}
|
|
1040 |
break;
|
253
|
1041 |
|
0
|
1042 |
case ExiDMA:
|
|
1043 |
retValue = TDesToBool (aDes, &boolValue);
|
|
1044 |
if (epIndex < 0)
|
|
1045 |
retValue = EFalse;
|
|
1046 |
if (retValue)
|
|
1047 |
{
|
|
1048 |
cpPtr->iThisIFPtr->iEpDMA[epIndex] = boolValue;
|
|
1049 |
}
|
|
1050 |
break;
|
253
|
1051 |
|
0
|
1052 |
case ExiDoubleBuff:
|
|
1053 |
#ifdef USB_SC
|
|
1054 |
retValue = EFalse;
|
|
1055 |
#else
|
|
1056 |
retValue = TDesToBool (aDes, &boolValue);
|
|
1057 |
if (epIndex < 0)
|
|
1058 |
retValue = EFalse;
|
|
1059 |
if (retValue)
|
|
1060 |
{
|
|
1061 |
cpPtr->iThisIFPtr->iEpDoubleBuff[epIndex] = boolValue;
|
|
1062 |
}
|
|
1063 |
#endif
|
|
1064 |
break;
|
253
|
1065 |
|
0
|
1066 |
case ExiExtra:
|
|
1067 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
1068 |
if (epIndex < 0)
|
|
1069 |
retValue = EFalse;
|
|
1070 |
if (retValue)
|
|
1071 |
{
|
|
1072 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iExtra = uintValue;
|
|
1073 |
}
|
|
1074 |
break;
|
|
1075 |
|
|
1076 |
case ExiBufferSize:
|
|
1077 |
#ifdef USB_SC
|
|
1078 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
1079 |
if (epIndex < 0 || uintValue < 4096)
|
|
1080 |
retValue = EFalse;
|
|
1081 |
if (retValue)
|
|
1082 |
{
|
|
1083 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iBufferSize = uintValue;
|
|
1084 |
}
|
253
|
1085 |
#else
|
0
|
1086 |
retValue = EFalse;
|
|
1087 |
#endif
|
|
1088 |
break;
|
|
1089 |
|
|
1090 |
case ExiReadSize:
|
|
1091 |
#ifdef USB_SC
|
|
1092 |
retValue = TDesToTUint (aDes, &uintValue);
|
|
1093 |
if (epIndex < 0 || uintValue < 1024)
|
|
1094 |
retValue = EFalse;
|
|
1095 |
if (retValue)
|
|
1096 |
{
|
|
1097 |
cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iReadSize = uintValue;
|
|
1098 |
}
|
253
|
1099 |
#else
|
0
|
1100 |
retValue = EFalse;
|
|
1101 |
#endif
|
|
1102 |
break;
|
|
1103 |
}
|
|
1104 |
|
|
1105 |
return retValue;
|
|
1106 |
}
|
253
|
1107 |
|
0
|
1108 |
TInt CheckXmlKey (TPtrC aKey,TInt aLevel)
|
|
1109 |
{
|
|
1110 |
TInt keyIndex = -1;
|
253
|
1111 |
|
0
|
1112 |
for (TInt i = xmlLevels[aLevel]; i < xmlLevels[aLevel+1]; i++)
|
|
1113 |
{
|
|
1114 |
if (aKey == xmlKeys[i])
|
|
1115 |
{
|
|
1116 |
keyIndex = i;
|
|
1117 |
break;
|
|
1118 |
}
|
|
1119 |
}
|
|
1120 |
|
253
|
1121 |
|
0
|
1122 |
return keyIndex;
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
TBool TDesToTUint (TPtrC aDes, TUint * aValue)
|
|
1126 |
{
|
|
1127 |
_LIT (KHexPrefix,"0x");
|
|
1128 |
TBuf<50> numDes = aDes;
|
|
1129 |
TBool hexBase = EFalse;
|
|
1130 |
TBool conversionOK = ETrue;
|
|
1131 |
TUint8 desIndex = 0;
|
|
1132 |
* aValue = 0;
|
253
|
1133 |
|
0
|
1134 |
if (numDes.LeftTPtr(((TDesC&)KHexPrefix).Length()) == KHexPrefix)
|
|
1135 |
{
|
|
1136 |
hexBase = ETrue;
|
253
|
1137 |
desIndex = ((TDesC&)KHexPrefix).Length();
|
0
|
1138 |
}
|
253
|
1139 |
|
0
|
1140 |
while (desIndex < numDes.Length() && conversionOK)
|
|
1141 |
{
|
|
1142 |
if (hexBase)
|
|
1143 |
{
|
|
1144 |
TUint maxValue = 0xFFFFFFFF >> 4;
|
|
1145 |
if (((TChar)numDes[desIndex]).IsHexDigit() && * aValue <= maxValue)
|
|
1146 |
{
|
|
1147 |
* aValue <<= 4;
|
|
1148 |
* aValue += ((TChar)numDes[desIndex]).IsDigit() ? numDes[desIndex] - '0' : ((TChar)numDes[desIndex]).GetUpperCase() - 'A' + 10;
|
|
1149 |
}
|
|
1150 |
else
|
|
1151 |
{
|
|
1152 |
conversionOK = EFalse;
|
|
1153 |
* aValue = 111;
|
|
1154 |
}
|
|
1155 |
}
|
|
1156 |
else
|
|
1157 |
{
|
|
1158 |
TUint maxValue = 0xFFFFFFFF / 10;
|
|
1159 |
if (((TChar)numDes[desIndex]).IsDigit())
|
|
1160 |
{
|
|
1161 |
TUint digit = numDes[desIndex] - '0';
|
|
1162 |
if ((* aValue < maxValue) || (* aValue == maxValue && digit <= 5))
|
|
1163 |
{
|
|
1164 |
* aValue *= 10;
|
|
1165 |
* aValue += digit;
|
|
1166 |
}
|
|
1167 |
else
|
|
1168 |
{
|
|
1169 |
conversionOK = EFalse;
|
253
|
1170 |
* aValue = 222;
|
|
1171 |
}
|
0
|
1172 |
}
|
|
1173 |
else
|
|
1174 |
{
|
253
|
1175 |
conversionOK = EFalse;
|
0
|
1176 |
* aValue = 333;
|
|
1177 |
}
|
253
|
1178 |
|
0
|
1179 |
}
|
|
1180 |
desIndex++;
|
|
1181 |
}
|
253
|
1182 |
|
0
|
1183 |
return conversionOK;
|
|
1184 |
}
|
|
1185 |
|
|
1186 |
TBool TDesToBool (TPtrC aDes, TBool * aValue)
|
|
1187 |
{
|
|
1188 |
_LIT (KBoolY,"Y");
|
|
1189 |
_LIT (KBoolN,"N");
|
|
1190 |
TBool conversionOK = ETrue;
|
|
1191 |
TBuf<50> boolDes = aDes;
|
253
|
1192 |
|
0
|
1193 |
boolDes.TrimAll();
|
|
1194 |
boolDes.UpperCase();
|
|
1195 |
if (boolDes == KBoolY)
|
|
1196 |
{
|
|
1197 |
* aValue = ETrue;
|
|
1198 |
}
|
|
1199 |
else
|
|
1200 |
{
|
|
1201 |
if (boolDes == KBoolN)
|
|
1202 |
{
|
|
1203 |
* aValue = EFalse;
|
|
1204 |
}
|
|
1205 |
else
|
|
1206 |
{
|
253
|
1207 |
conversionOK = EFalse;
|
0
|
1208 |
}
|
|
1209 |
}
|
253
|
1210 |
|
0
|
1211 |
return conversionOK;
|
|
1212 |
}
|