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