1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/inc/testinterfacebase.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,190 @@
1.4 +#ifndef __TEST_INTERFACE_BASE_H
1.5 +#define __TEST_INTERFACE_BASE_H
1.6 +
1.7 +/*
1.8 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.9 +* All rights reserved.
1.10 +* This component and the accompanying materials are made available
1.11 +* under the terms of the License "Eclipse Public License v1.0"
1.12 +* which accompanies this distribution, and is available
1.13 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.14 +*
1.15 +* Initial Contributors:
1.16 +* Nokia Corporation - initial contribution.
1.17 +*
1.18 +* Contributors:
1.19 +*
1.20 +* Description:
1.21 +* @file testinterfacebase.h
1.22 +* @internalComponent
1.23 +*
1.24 +*
1.25 +*/
1.26 +
1.27 +
1.28 +
1.29 +#include <e32base.h>
1.30 +#include "usbclientstatewatcher.h"
1.31 +#include "controlendpointreader.h"
1.32 +#include "endpointwriter.h"
1.33 +#include "endpointstallwatcher.h"
1.34 +
1.35 +
1.36 +namespace NUnitTesting_USBDI
1.37 + {
1.38 +
1.39 +// Forward declarations
1.40 +
1.41 +class RUsbTestDevice;
1.42 +class CInterfaceSettingBase;
1.43 +
1.44 +/**
1.45 +This class represents a test USB interface for the test USB device
1.46 +
1.47 +*/
1.48 +class CInterfaceBase : public CBase, public MAlternateSettingObserver, public MRequestHandler
1.49 + {
1.50 +public:
1.51 + /**
1.52 + Constructor, build an interface for a USB modelled device
1.53 + @param aTestDevice the device that this is an interface for
1.54 + @param aName the name given to the interface
1.55 + */
1.56 +
1.57 + CInterfaceBase(RUsbTestDevice& aTestDevice,const TDesC16& aName);
1.58 +
1.59 + /**
1.60 + Base class 2nd phase construction
1.61 + */
1.62 +
1.63 + void BaseConstructL();
1.64 +
1.65 + /**
1.66 + Destructor
1.67 + */
1.68 +
1.69 + virtual ~CInterfaceBase();
1.70 +
1.71 + /**
1.72 + Adds an alternate interface setting for this interface
1.73 + @param aInterface an alternate interface setting associated with this interface
1.74 + */
1.75 +
1.76 + void AddInterfaceSettingL(CInterfaceSettingBase* aInterfaceSetting);
1.77 +
1.78 + /**
1.79 + Accesses an alternate interface setting with the specified setting number
1.80 + @param aSettingNumber the alternate interface setting number
1.81 + @return a referrence to the alternate setting
1.82 + */
1.83 +
1.84 + CInterfaceSettingBase& AlternateSetting(TInt aSettingNumber) const;
1.85 +
1.86 + /**
1.87 + Query the number of alternate interface settings for this interface
1.88 + @return the number of alternate interface settings
1.89 + */
1.90 +
1.91 + TInt InterfaceSettingCount() const;
1.92 +
1.93 + /**
1.94 + Start the interface reading interface directed control transfers on endpoint 0
1.95 + */
1.96 +
1.97 + void StartEp0Reading();
1.98 +
1.99 + /**
1.100 + Stop the interface from reading interface directed control transfers on endpoint 0
1.101 + */
1.102 +
1.103 + void StopEp0Reading();
1.104 +
1.105 + /**
1.106 + Stall the specified endpoint
1.107 + @param aEndpointNumber the endpoint to stall
1.108 + @return KErrNone if successful
1.109 + */
1.110 +
1.111 + TInt StallEndpoint(TUint16 aEndpointNumber);
1.112 +
1.113 +public: // From MAlternateSettingObserver
1.114 +
1.115 + /**
1.116 + Get notification when the host selects an alternate interface setting on this interface
1.117 + @param aAlternateInterfaceSetting the alternate interface setting number
1.118 + */
1.119 + virtual void AlternateInterfaceSelectedL(TInt aAlternateInterfaceSetting);
1.120 +
1.121 +public: // From MEndpointDataHandler
1.122 +
1.123 + /**
1.124 + Process any Ep0 control transfer requests that are interface directed
1.125 + @param aRequest the request number (id)
1.126 + @param aValue the parameter to the request
1.127 + @param aIndex the interface number that the request is directed at
1.128 + @param aDataReqLength the data size in the transfer DATA1 packet(s)
1.129 + @param aPayload the request content data (i.e. all the data from DATA1 packets)
1.130 + */
1.131 + virtual TInt ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex,TUint16 aDataReqLength,const TDesC8& aPayload);
1.132 +
1.133 +private:
1.134 + TUint32 ExtractNumberL(const TDesC8& aPayload);
1.135 + void ExtractTwoNumbersL(const TDesC8& aPayload, TUint32& aFirstNum, TUint32& aSecondNum);
1.136 +
1.137 +private:
1.138 + /**
1.139 + The test device object that owns this interface
1.140 + */
1.141 + RUsbTestDevice& iDevice;
1.142 +
1.143 + /**
1.144 + The USB client driver
1.145 + Only use interface related API
1.146 + */
1.147 + RDevUsbcClient iClientDriver;
1.148 +
1.149 + /**
1.150 + The alternate settings for this interface
1.151 + */
1.152 + RPointerArray<CInterfaceSettingBase> iAlternateSettings;
1.153 +
1.154 + /**
1.155 + The watcher of alternate interface selection by host
1.156 + */
1.157 + CAlternateInterfaceSelectionWatcher* iSelectionWatcher;
1.158 +
1.159 + /**
1.160 + The watcher of endpoint stalling
1.161 + */
1.162 + CEndpointStallWatcher* iStallWatcher;
1.163 +
1.164 + /**
1.165 + The reader of interface control endpoint 0
1.166 + */
1.167 + CControlEndpointReader* iEp0Reader;
1.168 +
1.169 + /**
1.170 + The writer of interface control endpoint 0
1.171 + */
1.172 + CEndpointWriter* iEp0Writer;
1.173 +
1.174 + /**
1.175 + */
1.176 + TBuf16<64> iInterfaceName;
1.177 +
1.178 + /**
1.179 + An Auxiliary buffer, to be used for anything temporary
1.180 + */
1.181 + HBufC8* iAuxBuffer;
1.182 +
1.183 + /**
1.184 + The current alternate interface setting that is selected (defaults to zero)
1.185 + */
1.186 + TInt iCurrentAlternateInterfaceSetting;
1.187 + };
1.188 +
1.189 +
1.190 + }
1.191 +
1.192 +#endif
1.193 +