1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/examples/driver1/driver1_dev.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,157 @@
1.4 +// Copyright (c) 2003-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 +//
1.18 +
1.19 +/**
1.20 + @file Kernel side interfaces to example Logical and Physical Device Drivers
1.21 + @publishedPartner
1.22 + @released
1.23 +*/
1.24 +
1.25 +#ifndef __DRIVER1_DEV_H__
1.26 +#define __DRIVER1_DEV_H__
1.27 +
1.28 +/**
1.29 + Physical Device (factory class) for 'Driver1'
1.30 +*/
1.31 +class DDevice1PddFactory : public DPhysicalDevice
1.32 + {
1.33 +public:
1.34 + DDevice1PddFactory();
1.35 + ~DDevice1PddFactory();
1.36 + // Inherited from DPhysicalDevice
1.37 + virtual TInt Install();
1.38 + virtual void GetCaps(TDes8& aDes) const;
1.39 + virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
1.40 + virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
1.41 +public:
1.42 + TInt iHardwareInUse;
1.43 +private:
1.44 + enum TMinimumLDDVersion
1.45 + {
1.46 + EMinimumLddMajorVersion=1,
1.47 + EMinimumLddMinorVersion=0,
1.48 + EMinimumLddBuild=0 //Not used
1.49 + };
1.50 +public:
1.51 + TDynamicDfcQue* iDfcQ;
1.52 + };
1.53 +
1.54 +/**
1.55 + Logical Device (factory class) for 'Driver1'
1.56 +*/
1.57 +class DDriver1Factory : public DLogicalDevice
1.58 + {
1.59 +public:
1.60 + DDriver1Factory();
1.61 + ~DDriver1Factory();
1.62 + // Inherited from DLogicalDevice
1.63 + virtual TInt Install();
1.64 + virtual void GetCaps(TDes8& aDes) const;
1.65 + virtual TInt Create(DLogicalChannelBase*& aChannel);
1.66 + };
1.67 +
1.68 +class DDriver1;
1.69 +
1.70 +
1.71 +/**
1.72 + Logical Channel class for 'Driver1'
1.73 +*/
1.74 +class DDriver1Channel : public DLogicalChannel
1.75 + {
1.76 +public:
1.77 + DDriver1Channel();
1.78 + virtual ~DDriver1Channel();
1.79 + // Inherited from DObject
1.80 + virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
1.81 + // Inherited from DLogicalChannelBase
1.82 + virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
1.83 + // Inherited from DLogicalChannel
1.84 + virtual void HandleMsg(TMessageBase* aMsg);
1.85 +private:
1.86 + // Panic reasons
1.87 + enum TPanic
1.88 + {
1.89 + ERequestAlreadyPending = 1
1.90 + };
1.91 + // Implementation for the differnt kinds of messages sent through RBusLogicalChannel
1.92 + TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
1.93 + TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
1.94 + void DoCancel(TUint aMask);
1.95 + // Accessor for the PDD
1.96 + inline DDriver1* Pdd();
1.97 + // Methods for configuration
1.98 + TInt GetConfig(TDes8* aConfigBuf);
1.99 + TInt SetConfig(const TDesC8* aConfigBuf);
1.100 + void CurrentConfig(RDriver1::TConfig& aConfig);
1.101 + // Methods for processing a SendData request
1.102 + TInt SendData(TRequestStatus* aStatus,const TDesC8* aData);
1.103 + void SendDataCancel();
1.104 + void DoSendDataComplete();
1.105 + static void SendDataDfc(TAny* aPtr);
1.106 + // Methods for processing a ReceiveData request
1.107 + TInt ReceiveData(TRequestStatus* aStatus,TDes8* aBuffer);
1.108 + void ReceiveDataCancel();
1.109 + void DoReceiveDataComplete();
1.110 + static void ReceiveDataDfc(TAny* aPtr);
1.111 +public:
1.112 + // Interface methods for use by PDD
1.113 + virtual void SendDataComplete(TInt aResult);
1.114 + virtual void ReceiveDataComplete(TInt aResult);
1.115 +private:
1.116 + DThread* iClient;
1.117 + // Members used for processing a SendData request
1.118 + TRequestStatus* iSendDataStatus;
1.119 + TDfc iSendDataDfc;
1.120 + TInt iSendDataResult;
1.121 + TBuf8<256> iSendDataBuffer;
1.122 + // Members used for processing a ReceiveData request
1.123 + TDes8* iReceiveDataDescriptor;
1.124 + TRequestStatus* iReceiveDataStatus;
1.125 + TDfc iReceiveDataDfc;
1.126 + TInt iReceiveDataResult;
1.127 + TBuf8<256> iReceiveDataBuffer;
1.128 + };
1.129 +
1.130 +inline DDriver1* DDriver1Channel::Pdd()
1.131 + { return (DDriver1*)iPdd; }
1.132 +
1.133 +/**
1.134 + Interface to 'Driver1' physical device
1.135 +*/
1.136 +class DDriver1 : public DBase
1.137 + {
1.138 +public:
1.139 + /**
1.140 + Structure for holding PDD capabilities information
1.141 + */
1.142 + class TCaps
1.143 + {
1.144 + public:
1.145 + TVersion iVersion;
1.146 + };
1.147 +public:
1.148 + virtual TInt BufferSize() const =0;
1.149 + virtual TInt Speed() const =0;
1.150 + virtual TInt SetSpeed(TInt aSpeed) =0;
1.151 + virtual TInt SendData(const TDesC8& aData) =0;
1.152 + virtual void SendDataCancel() =0;
1.153 + virtual TInt ReceiveData(TDes8& aBuffer) =0;
1.154 + virtual void ReceiveDataCancel() =0;
1.155 +public:
1.156 + DDriver1Channel* iLdd;
1.157 + };
1.158 +
1.159 +#endif
1.160 +