os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/include/general.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/include/general.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,259 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test/usb/t_usb_device/include/general.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __GENERAL_H__
    1.22 +#define __GENERAL_H__
    1.23 +
    1.24 +#define __E32TEST_EXTENSION__
    1.25 +
    1.26 +#include <e32hal.h>
    1.27 +#include <e32uid.h>
    1.28 +#include <hal.h>
    1.29 +
    1.30 +#include <e32cons.h>
    1.31 +#include <e32svr.h>
    1.32 +#include <e32std.h>
    1.33 +#include <e32test.h>
    1.34 +#include <f32file.h>
    1.35 +
    1.36 +#ifdef USB_SC
    1.37 +#include <d32usbcsc.h>
    1.38 +#define RDEVCLIENT RDevUsbcScClient
    1.39 +#define TENDPOINTNUMBER TInt
    1.40 +#else
    1.41 +#include <d32usbc.h>
    1.42 +#define RDEVCLIENT RDevUsbcClient
    1.43 +#define TENDPOINTNUMBER TEndpointNumber
    1.44 +#endif
    1.45 +
    1.46 +static const TInt KHostLogFileSize = 64 * 1024;			// 64kB
    1.47 +
    1.48 +static const TInt KMaxInterfaces = 10;
    1.49 +static const TInt KMaxConcurrentTests = 10;
    1.50 +static const TInt KMaxInterfaceSettings = 10;
    1.51 +
    1.52 +static const TInt KWaitSettingSize = 8;
    1.53 +
    1.54 +static const TUint16 KFirstSettingThreadMask = 0x8000;
    1.55 +static const TUint16 KLastSettingThreadMask = 0x4000;
    1.56 +
    1.57 +static const TUint16 KHostErrorIndex = 0xFFF;
    1.58 +
    1.59 +static const TUint8 stridx1 = 0xCC;
    1.60 +static const TUint8 stridx2 = 0xDD;
    1.61 +static const TUint8 stridx3 = 0xEE;
    1.62 +static const TUint8 stridx4 = 0xFF;
    1.63 +
    1.64 +#ifdef USB_SC
    1.65 +_LIT(KActivePanic, "T_USB_SCDEVICE");
    1.66 +#else
    1.67 +_LIT(KActivePanic, "T_USB_DEVICE");
    1.68 +#endif
    1.69 +
    1.70 +// Descriptor Offset Constants
    1.71 +
    1.72 +static const TInt KUsbDesc_SizeOffset = 0;
    1.73 +static const TInt KUsbDesc_TypeOffset = 1;
    1.74 +static const TInt KDevDesc_SpecOffset = 2;
    1.75 +static const TInt KDevDesc_DevClassOffset = 4;
    1.76 +static const TInt KDevDesc_DevSubClassOffset = 5;
    1.77 +static const TInt KDevDesc_DevProtocolOffset = 6;
    1.78 +static const TInt KDevDesc_Ep0SizeOffset = 7;
    1.79 +static const TInt KDevDesc_VendorIdOffset = 8;
    1.80 +static const TInt KDevDesc_ProductIdOffset = 10;
    1.81 +static const TInt KDevDesc_DevReleaseOffset = 12;
    1.82 +
    1.83 +static const TInt KConfDesc_AttribOffset = 7;
    1.84 +static const TInt KConfDesc_MaxPowerOffset = 8;
    1.85 +
    1.86 +static const TInt KIfcDesc_LengthOffset = 0;
    1.87 +static const TInt KIfcDesc_TypeOffset = 1;
    1.88 +static const TInt KIfcDesc_NumberOffset = 2;
    1.89 +static const TInt KIfcDesc_SettingOffset = 3;
    1.90 +static const TInt KIfcDesc_NumEndpointsOffset = 4;
    1.91 +static const TInt KIfcDesc_ClassOffset = 5;
    1.92 +static const TInt KIfcDesc_SubClassOffset = 6;
    1.93 +static const TInt KIfcDesc_ProtocolOffset = 7;
    1.94 +static const TInt KIfcDesc_InterfaceOffset = 8;
    1.95 +
    1.96 +static const TInt KEpDesc_LengthOffset = 0;
    1.97 +static const TInt KEpDesc_TypeOffset = 1;
    1.98 +static const TInt KEpDesc_AddressOffset = 2;
    1.99 +static const TInt KEpDesc_AttributesOffset = 3;
   1.100 +static const TInt KEpDesc_PacketSizeOffset = 4;
   1.101 +static const TInt KEpDesc_IntervalOffset = 6;
   1.102 +static const TInt KEpDesc_SynchAddressOffset = 8;
   1.103 +
   1.104 +enum TXferMode
   1.105 +	{
   1.106 +	ENone,
   1.107 +	ELoop,
   1.108 +	ELoopComp,
   1.109 +	EReceiveOnly,
   1.110 +	ETransmitOnly
   1.111 +	};
   1.112 +
   1.113 +enum TXferType
   1.114 +	{
   1.115 +	ETxferNone,
   1.116 +	EWaitSetting,
   1.117 +	ESuspend,
   1.118 +	EAltSetting,
   1.119 +	EReadXfer,
   1.120 +	EWriteXfer
   1.121 +	};
   1.122 +
   1.123 +struct TestParam
   1.124 +	{
   1.125 +	TUint32 minSize;
   1.126 +	TUint32 maxSize;
   1.127 +	TUint32 packetNumber;
   1.128 +	TUint8 interfaceNumber;
   1.129 +	TUint8 alternateSetting;
   1.130 +	TUint8 outPipe;
   1.131 +	TUint8 inPipe;
   1.132 +	TUint16 repeat;
   1.133 +	TUint16 settingRepeat;
   1.134 +	TUint8 beforeIndex;
   1.135 +	TUint8 afterIndex;
   1.136 +	};
   1.137 +	
   1.138 +typedef struct TestParam TestParamType;
   1.139 +typedef TestParamType* TestParamPtr;
   1.140 +
   1.141 +//
   1.142 +// Helpful Defines
   1.143 +//
   1.144 +#define HiByte(a) (TUint8)((a)>>8) 	
   1.145 +#define LoByte(a) (TUint8)((a)&0xFF)
   1.146 +
   1.147 +#define TUSB_PRINT(string) \
   1.148 +		do { \
   1.149 +		iConsole->Printf(_L(string)); \
   1.150 +		iConsole->Printf(_L("\n")); \
   1.151 +		RDebug::Print(_L(string)); \
   1.152 +		} while (0)
   1.153 +
   1.154 +#define TUSB_PRINT1(string, a) \
   1.155 +		do { \
   1.156 +		iConsole->Printf(_L(string), (a)); \
   1.157 +		iConsole->Printf(_L("\n")); \
   1.158 +		RDebug::Print(_L(string), (a)); \
   1.159 +		} while (0)
   1.160 +
   1.161 +#define TUSB_PRINT2(string, a, b) \
   1.162 +		do { \
   1.163 +		iConsole->Printf(_L(string), (a), (b)); \
   1.164 +		iConsole->Printf(_L("\n")); \
   1.165 +		RDebug::Print(_L(string), (a), (b)); \
   1.166 +		} while (0)
   1.167 +
   1.168 +#define TUSB_PRINT3(string, a, b, c) \
   1.169 +		do { \
   1.170 +		iConsole->Printf(_L(string), (a), (b), (c)); \
   1.171 +		iConsole->Printf(_L("\n")); \
   1.172 +		RDebug::Print(_L(string), (a), (b), (c)); \
   1.173 +		} while (0)
   1.174 +
   1.175 +#define TUSB_PRINT4(string, a, b, c, d) \
   1.176 +		do { \
   1.177 +		iConsole->Printf(_L(string), (a), (b), (c), (d)); \
   1.178 +		iConsole->Printf(_L("\n")); \
   1.179 +		RDebug::Print(_L(string), (a), (b), (c), (d)); \
   1.180 +		} while (0)
   1.181 +
   1.182 +#define TUSB_PRINT5(string, a, b, c, d, e) \
   1.183 +		do { \
   1.184 +		iConsole->Printf(_L(string), (a), (b), (c), (d), (e)); \
   1.185 +		iConsole->Printf(_L("\n")); \
   1.186 +		RDebug::Print(_L(string), (a), (b), (c), (d), (e)); \
   1.187 +		} while (0)
   1.188 +
   1.189 +#define TUSB_PRINT6(string, a, b, c, d, e, f) \
   1.190 +		do { \
   1.191 +		iConsole->Printf(_L(string), (a), (b), (c), (d), (e), (f)); \
   1.192 +		iConsole->Printf(_L("\n")); \
   1.193 +		RDebug::Print(_L(string), (a), (b), (c), (d), (e), (f)); \
   1.194 +		} while (0)
   1.195 +
   1.196 +#define TUSB_VERBOSE_PRINT(string) \
   1.197 +		do { \
   1.198 +		if (gVerbose) \
   1.199 +			{ \
   1.200 +			TUSB_PRINT(string); \
   1.201 +			} \
   1.202 +		} while (0)
   1.203 +
   1.204 +#define TUSB_VERBOSE_PRINT1(string, a) \
   1.205 +		do { \
   1.206 +		if (gVerbose) \
   1.207 +			{ \
   1.208 +			TUSB_PRINT1(string, a); \
   1.209 +			} \
   1.210 +		} while (0)
   1.211 +
   1.212 +#define TUSB_VERBOSE_PRINT2(string, a, b) \
   1.213 +		do { \
   1.214 +		if (gVerbose) \
   1.215 +			{ \
   1.216 +			TUSB_PRINT2(string, a, b); \
   1.217 +			} \
   1.218 +		} while (0)
   1.219 +
   1.220 +#define TUSB_VERBOSE_PRINT3(string, a, b, c) \
   1.221 +		do { \
   1.222 +		if (gVerbose) \
   1.223 +			{ \
   1.224 +			TUSB_PRINT3(string, a, b, c); \
   1.225 +			} \
   1.226 +		} while (0)
   1.227 +
   1.228 +#define TUSB_VERBOSE_PRINT4(string, a, b, c, d) \
   1.229 +		do { \
   1.230 +		if (gVerbose) \
   1.231 +			{ \
   1.232 +			TUSB_PRINT4(string, a, b, c, d); \
   1.233 +			} \
   1.234 +		} while (0)
   1.235 +
   1.236 +#define TUSB_VERBOSE_PRINT5(string, a, b, c, d, e) \
   1.237 +		do { \
   1.238 +		if (gVerbose) \
   1.239 +			{ \
   1.240 +			TUSB_PRINT5(string, a, b, c, d, e); \
   1.241 +			} \
   1.242 +		} while (0)
   1.243 +
   1.244 +#define TUSB_VERBOSE_APRINT(string) \
   1.245 +		do { \
   1.246 +		if (gVerbose) \
   1.247 +			{ \
   1.248 +			aConsole->Printf(_L(string)); \
   1.249 +			aConsole->Printf(_L("\n")); \
   1.250 +			RDebug::Print(_L(string)); \
   1.251 +			} \
   1.252 +		} while (0)
   1.253 +
   1.254 +#define TUSB_HEAPSIZE(string) \
   1.255 +		do { \
   1.256 +			TInt totalSize = 0; \
   1.257 +			TInt numCells = User::AllocSize (totalSize); \
   1.258 +			RDebug::Print(_L(string)); \
   1.259 +			RDebug::Print(_L(" Heap Cells %d Size %d\n"),numCells,totalSize); \
   1.260 +		} while (0)
   1.261 +	
   1.262 +#endif	// __GENERAL_H__