sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test/usb/t_usb_device/include/general.h sl@0: // sl@0: // sl@0: sl@0: #ifndef __GENERAL_H__ sl@0: #define __GENERAL_H__ sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef USB_SC sl@0: #include sl@0: #define RDEVCLIENT RDevUsbcScClient sl@0: #define TENDPOINTNUMBER TInt sl@0: #else sl@0: #include sl@0: #define RDEVCLIENT RDevUsbcClient sl@0: #define TENDPOINTNUMBER TEndpointNumber sl@0: #endif sl@0: sl@0: static const TInt KHostLogFileSize = 64 * 1024; // 64kB sl@0: sl@0: static const TInt KMaxInterfaces = 10; sl@0: static const TInt KMaxConcurrentTests = 10; sl@0: static const TInt KMaxInterfaceSettings = 10; sl@0: sl@0: static const TInt KWaitSettingSize = 8; sl@0: sl@0: static const TUint16 KFirstSettingThreadMask = 0x8000; sl@0: static const TUint16 KLastSettingThreadMask = 0x4000; sl@0: sl@0: static const TUint16 KHostErrorIndex = 0xFFF; sl@0: sl@0: static const TUint8 stridx1 = 0xCC; sl@0: static const TUint8 stridx2 = 0xDD; sl@0: static const TUint8 stridx3 = 0xEE; sl@0: static const TUint8 stridx4 = 0xFF; sl@0: sl@0: #ifdef USB_SC sl@0: _LIT(KActivePanic, "T_USB_SCDEVICE"); sl@0: #else sl@0: _LIT(KActivePanic, "T_USB_DEVICE"); sl@0: #endif sl@0: sl@0: // Descriptor Offset Constants sl@0: sl@0: static const TInt KUsbDesc_SizeOffset = 0; sl@0: static const TInt KUsbDesc_TypeOffset = 1; sl@0: static const TInt KDevDesc_SpecOffset = 2; sl@0: static const TInt KDevDesc_DevClassOffset = 4; sl@0: static const TInt KDevDesc_DevSubClassOffset = 5; sl@0: static const TInt KDevDesc_DevProtocolOffset = 6; sl@0: static const TInt KDevDesc_Ep0SizeOffset = 7; sl@0: static const TInt KDevDesc_VendorIdOffset = 8; sl@0: static const TInt KDevDesc_ProductIdOffset = 10; sl@0: static const TInt KDevDesc_DevReleaseOffset = 12; sl@0: sl@0: static const TInt KConfDesc_AttribOffset = 7; sl@0: static const TInt KConfDesc_MaxPowerOffset = 8; sl@0: sl@0: static const TInt KIfcDesc_LengthOffset = 0; sl@0: static const TInt KIfcDesc_TypeOffset = 1; sl@0: static const TInt KIfcDesc_NumberOffset = 2; sl@0: static const TInt KIfcDesc_SettingOffset = 3; sl@0: static const TInt KIfcDesc_NumEndpointsOffset = 4; sl@0: static const TInt KIfcDesc_ClassOffset = 5; sl@0: static const TInt KIfcDesc_SubClassOffset = 6; sl@0: static const TInt KIfcDesc_ProtocolOffset = 7; sl@0: static const TInt KIfcDesc_InterfaceOffset = 8; sl@0: sl@0: static const TInt KEpDesc_LengthOffset = 0; sl@0: static const TInt KEpDesc_TypeOffset = 1; sl@0: static const TInt KEpDesc_AddressOffset = 2; sl@0: static const TInt KEpDesc_AttributesOffset = 3; sl@0: static const TInt KEpDesc_PacketSizeOffset = 4; sl@0: static const TInt KEpDesc_IntervalOffset = 6; sl@0: static const TInt KEpDesc_SynchAddressOffset = 8; sl@0: sl@0: enum TXferMode sl@0: { sl@0: ENone, sl@0: ELoop, sl@0: ELoopComp, sl@0: EReceiveOnly, sl@0: ETransmitOnly sl@0: }; sl@0: sl@0: enum TXferType sl@0: { sl@0: ETxferNone, sl@0: EWaitSetting, sl@0: ESuspend, sl@0: EAltSetting, sl@0: EReadXfer, sl@0: EWriteXfer sl@0: }; sl@0: sl@0: struct TestParam sl@0: { sl@0: TUint32 minSize; sl@0: TUint32 maxSize; sl@0: TUint32 packetNumber; sl@0: TUint8 interfaceNumber; sl@0: TUint8 alternateSetting; sl@0: TUint8 outPipe; sl@0: TUint8 inPipe; sl@0: TUint16 repeat; sl@0: TUint16 settingRepeat; sl@0: TUint8 beforeIndex; sl@0: TUint8 afterIndex; sl@0: }; sl@0: sl@0: typedef struct TestParam TestParamType; sl@0: typedef TestParamType* TestParamPtr; sl@0: sl@0: // sl@0: // Helpful Defines sl@0: // sl@0: #define HiByte(a) (TUint8)((a)>>8) sl@0: #define LoByte(a) (TUint8)((a)&0xFF) sl@0: sl@0: #define TUSB_PRINT(string) \ sl@0: do { \ sl@0: iConsole->Printf(_L(string)); \ sl@0: iConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string)); \ sl@0: } while (0) sl@0: sl@0: #define TUSB_PRINT1(string, a) \ sl@0: do { \ sl@0: iConsole->Printf(_L(string), (a)); \ sl@0: iConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string), (a)); \ sl@0: } while (0) sl@0: sl@0: #define TUSB_PRINT2(string, a, b) \ sl@0: do { \ sl@0: iConsole->Printf(_L(string), (a), (b)); \ sl@0: iConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string), (a), (b)); \ sl@0: } while (0) sl@0: sl@0: #define TUSB_PRINT3(string, a, b, c) \ sl@0: do { \ sl@0: iConsole->Printf(_L(string), (a), (b), (c)); \ sl@0: iConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string), (a), (b), (c)); \ sl@0: } while (0) sl@0: sl@0: #define TUSB_PRINT4(string, a, b, c, d) \ sl@0: do { \ sl@0: iConsole->Printf(_L(string), (a), (b), (c), (d)); \ sl@0: iConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string), (a), (b), (c), (d)); \ sl@0: } while (0) sl@0: sl@0: #define TUSB_PRINT5(string, a, b, c, d, e) \ sl@0: do { \ sl@0: iConsole->Printf(_L(string), (a), (b), (c), (d), (e)); \ sl@0: iConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string), (a), (b), (c), (d), (e)); \ sl@0: } while (0) sl@0: sl@0: #define TUSB_PRINT6(string, a, b, c, d, e, f) \ sl@0: do { \ sl@0: iConsole->Printf(_L(string), (a), (b), (c), (d), (e), (f)); \ sl@0: iConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string), (a), (b), (c), (d), (e), (f)); \ sl@0: } while (0) sl@0: sl@0: #define TUSB_VERBOSE_PRINT(string) \ sl@0: do { \ sl@0: if (gVerbose) \ sl@0: { \ sl@0: TUSB_PRINT(string); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TUSB_VERBOSE_PRINT1(string, a) \ sl@0: do { \ sl@0: if (gVerbose) \ sl@0: { \ sl@0: TUSB_PRINT1(string, a); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TUSB_VERBOSE_PRINT2(string, a, b) \ sl@0: do { \ sl@0: if (gVerbose) \ sl@0: { \ sl@0: TUSB_PRINT2(string, a, b); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TUSB_VERBOSE_PRINT3(string, a, b, c) \ sl@0: do { \ sl@0: if (gVerbose) \ sl@0: { \ sl@0: TUSB_PRINT3(string, a, b, c); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TUSB_VERBOSE_PRINT4(string, a, b, c, d) \ sl@0: do { \ sl@0: if (gVerbose) \ sl@0: { \ sl@0: TUSB_PRINT4(string, a, b, c, d); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TUSB_VERBOSE_PRINT5(string, a, b, c, d, e) \ sl@0: do { \ sl@0: if (gVerbose) \ sl@0: { \ sl@0: TUSB_PRINT5(string, a, b, c, d, e); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TUSB_VERBOSE_APRINT(string) \ sl@0: do { \ sl@0: if (gVerbose) \ sl@0: { \ sl@0: aConsole->Printf(_L(string)); \ sl@0: aConsole->Printf(_L("\n")); \ sl@0: RDebug::Print(_L(string)); \ sl@0: } \ sl@0: } while (0) sl@0: sl@0: #define TUSB_HEAPSIZE(string) \ sl@0: do { \ sl@0: TInt totalSize = 0; \ sl@0: TInt numCells = User::AllocSize (totalSize); \ sl@0: RDebug::Print(_L(string)); \ sl@0: RDebug::Print(_L(" Heap Cells %d Size %d\n"),numCells,totalSize); \ sl@0: } while (0) sl@0: sl@0: #endif // __GENERAL_H__