os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/include/activecontrol.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32test/usb/t_usb_device/include/activecontrol.h
    15 // 
    16 //
    17 
    18 #ifndef __ACTIVECONSOLE_H__
    19 #define __ACTIVECONSOLE_H__
    20 
    21 #include "activestallnotifier.h"
    22 #include "activedevicestatenotifier.h"
    23 
    24 static const TInt KSetupPacketSize = 8;
    25 static const TInt KMaxControlBufferSize = 256;
    26 static const TInt KMaxControlPacketSize = 64;
    27 
    28 static const TInt KUsb_Ep0RequestTypeOffset = 0;
    29 static const TInt KUsb_Ep0RequestOffset = 1;
    30 static const TInt KUsb_Ep0wValueOffset = 2;
    31 static const TInt KUsb_Ep0wIndexOffset = 4;
    32 static const TInt KUsb_Ep0wLengthOffset = 6;
    33 
    34 static const TUint32 KDeviceVersionMajor = 2;				// The version for t_usb_device
    35 static const TUint32 KDeviceVersionMinor = 0;
    36 static const TUint32 KDeviceVersionMicro = 0;
    37 static const TUint8 KHostVersionMajor = 1;					// the host version we're compatible with
    38 static const TUint8 KHostVersionMinor = 1;
    39 static const TUint8 KHostVersionMicro = 0;
    40 
    41 static const TUint32 KMSFinishedDelay = 5000000;			// 5 second delay after mass storage finishing
    42 
    43 enum PendingRequest
    44 	{
    45 	EPendingNone,
    46 	EPendingEp0Read,
    47 	EPendingTimer,
    48 	EPendingEject,
    49 	EPendingCancel,
    50 	};
    51 
    52 class CActiveRW;
    53 
    54 class CActiveControl : public CActive
    55 	{
    56 public:
    57 	static CActiveControl* NewLC(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile);
    58 	static CActiveControl* NewL(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile);
    59 	void ConstructL();
    60 	~CActiveControl();
    61 	void RequestEp0ControlPacket();
    62 	void SetMSFinished(TBool aState);
    63 	void AllocateEndpointDMA(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
    64 	void AllocateDoubleBuffering(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
    65 	void DeAllocateEndpointDMA(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
    66 	void DeAllocateDoubleBuffering(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
    67 
    68 private:
    69 	CActiveControl(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile);
    70 	// Defined as pure virtual by CActive;
    71 	// implementation provided by this class.
    72 	virtual void DoCancel();
    73 	// Defined as pure virtual by CActive;
    74 	// implementation provided by this class,
    75 	virtual void RunL();
    76 	void CActiveControl::ReConnect();
    77 	void SetupInterface(IFConfigPtr* aIfPtr, TInt aPortNumber);
    78 	void QueryUsbClientL(LDDConfigPtr aLddPtr,RDEVCLIENT* aPort);
    79 	void QueryEndpointState(RDEVCLIENT* aPort,TENDPOINTNUMBER aEndpoint);
    80 	TInt ReEnumerate();
    81 	TInt ProcessEp0ControlPacket();
    82 	void PrintHostLog();
    83 
    84 private:
    85 	CConsoleBase* iConsole;											// a console to read from
    86 	CActiveStallNotifier* iStallNotifier[KMaxInterfaces];
    87 	CActiveDeviceStateNotifier* iDeviceStateNotifier[KMaxInterfaces];
    88 	RDEVCLIENT iPort[KMaxInterfaces];
    89 	RTimer iTimer;
    90 	TUint iPending;
    91 	TInt iNumInterfaceSettings[KMaxInterfaces];
    92 	TInt iTotalChannels;
    93 	TBool iSoftwareConnect;
    94 	TBool iHighSpeed;
    95 	RFs iFs;
    96 	RFile iConfigFile;
    97 	TDes * iConfigFileName;
    98 	TDes * iScriptFileName;
    99 	LDDConfigPtr iLddPtr;
   100 	#ifdef USB_SC
   101 	TEndpointBuffer iEp0Buf;
   102 	TAny * iEp0Packet;
   103 	TUint iEp0Size;
   104 	TBool iEp0Zlp;	
   105 	#endif
   106 	TBuf8<KSetupPacketSize> iEp0SetUpPacket;
   107 	TBuf8<KMaxControlBufferSize> iEp0DataBuffer;
   108 	TUint iEp0PacketSize;
   109 	RThread iIdleCounterThread;
   110 	RChunk iIdleCounterChunk;
   111 	struct TTestIdleCounter* iIdleCounter;
   112 	};
   113 
   114 #endif	// __ACTIVECONTROL_H__