os/kernelhwsrv/kerneltest/e32test/examples/driver1/driver1_dev.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.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file Kernel side interfaces to example Logical and Physical Device Drivers
sl@0
    18
 @publishedPartner
sl@0
    19
 @released
sl@0
    20
*/
sl@0
    21
sl@0
    22
#ifndef __DRIVER1_DEV_H__
sl@0
    23
#define __DRIVER1_DEV_H__
sl@0
    24
sl@0
    25
/**
sl@0
    26
  Physical Device (factory class) for 'Driver1'
sl@0
    27
*/
sl@0
    28
class DDevice1PddFactory : public DPhysicalDevice
sl@0
    29
	{
sl@0
    30
public:
sl@0
    31
	DDevice1PddFactory();
sl@0
    32
	~DDevice1PddFactory();
sl@0
    33
	// Inherited from DPhysicalDevice
sl@0
    34
	virtual TInt Install();
sl@0
    35
	virtual void GetCaps(TDes8& aDes) const;
sl@0
    36
	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
sl@0
    37
	virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
sl@0
    38
public:
sl@0
    39
	TInt iHardwareInUse;
sl@0
    40
private:
sl@0
    41
	enum TMinimumLDDVersion
sl@0
    42
		{
sl@0
    43
		EMinimumLddMajorVersion=1,
sl@0
    44
		EMinimumLddMinorVersion=0,
sl@0
    45
		EMinimumLddBuild=0 //Not used
sl@0
    46
		};
sl@0
    47
public:
sl@0
    48
	TDynamicDfcQue* iDfcQ;
sl@0
    49
	};
sl@0
    50
sl@0
    51
/**
sl@0
    52
  Logical Device (factory class) for 'Driver1'
sl@0
    53
*/
sl@0
    54
class DDriver1Factory : public DLogicalDevice
sl@0
    55
	{
sl@0
    56
public:
sl@0
    57
	DDriver1Factory();
sl@0
    58
	~DDriver1Factory();
sl@0
    59
	//	Inherited from DLogicalDevice
sl@0
    60
	virtual TInt Install();
sl@0
    61
	virtual void GetCaps(TDes8& aDes) const;
sl@0
    62
	virtual TInt Create(DLogicalChannelBase*& aChannel);
sl@0
    63
	};
sl@0
    64
sl@0
    65
class DDriver1;
sl@0
    66
sl@0
    67
sl@0
    68
/**
sl@0
    69
  Logical Channel class for 'Driver1'
sl@0
    70
*/
sl@0
    71
class DDriver1Channel : public DLogicalChannel
sl@0
    72
	{
sl@0
    73
public:
sl@0
    74
	DDriver1Channel();
sl@0
    75
	virtual ~DDriver1Channel();
sl@0
    76
	//	Inherited from DObject
sl@0
    77
	virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
sl@0
    78
	// Inherited from DLogicalChannelBase
sl@0
    79
	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
sl@0
    80
	// Inherited from DLogicalChannel
sl@0
    81
	virtual void HandleMsg(TMessageBase* aMsg);
sl@0
    82
private:
sl@0
    83
	// Panic reasons
sl@0
    84
	enum TPanic
sl@0
    85
		{
sl@0
    86
		ERequestAlreadyPending = 1
sl@0
    87
		};
sl@0
    88
	// Implementation for the differnt kinds of messages sent through RBusLogicalChannel
sl@0
    89
	TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
sl@0
    90
	TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
sl@0
    91
	void DoCancel(TUint aMask);
sl@0
    92
	// Accessor for the PDD
sl@0
    93
	inline DDriver1* Pdd();
sl@0
    94
	// Methods for configuration
sl@0
    95
	TInt GetConfig(TDes8* aConfigBuf);
sl@0
    96
	TInt SetConfig(const TDesC8* aConfigBuf);
sl@0
    97
	void CurrentConfig(RDriver1::TConfig& aConfig);
sl@0
    98
	// Methods for processing a SendData request
sl@0
    99
	TInt SendData(TRequestStatus* aStatus,const TDesC8* aData);
sl@0
   100
	void SendDataCancel();
sl@0
   101
	void DoSendDataComplete();
sl@0
   102
	static void SendDataDfc(TAny* aPtr);
sl@0
   103
	// Methods for processing a ReceiveData request
sl@0
   104
	TInt ReceiveData(TRequestStatus* aStatus,TDes8* aBuffer);
sl@0
   105
	void ReceiveDataCancel();
sl@0
   106
	void DoReceiveDataComplete();
sl@0
   107
	static void ReceiveDataDfc(TAny* aPtr);
sl@0
   108
public:
sl@0
   109
	// Interface methods for use by PDD
sl@0
   110
	virtual void SendDataComplete(TInt aResult);
sl@0
   111
	virtual void ReceiveDataComplete(TInt aResult);
sl@0
   112
private:
sl@0
   113
	DThread* iClient;
sl@0
   114
	// Members used for processing a SendData request
sl@0
   115
	TRequestStatus* iSendDataStatus;
sl@0
   116
	TDfc iSendDataDfc;
sl@0
   117
	TInt iSendDataResult;
sl@0
   118
	TBuf8<256> iSendDataBuffer;
sl@0
   119
	// Members used for processing a ReceiveData request
sl@0
   120
	TDes8* iReceiveDataDescriptor;
sl@0
   121
	TRequestStatus* iReceiveDataStatus;
sl@0
   122
	TDfc iReceiveDataDfc;
sl@0
   123
	TInt iReceiveDataResult;
sl@0
   124
	TBuf8<256> iReceiveDataBuffer;
sl@0
   125
	};
sl@0
   126
sl@0
   127
inline DDriver1* DDriver1Channel::Pdd()
sl@0
   128
	{ return (DDriver1*)iPdd; }
sl@0
   129
sl@0
   130
/**
sl@0
   131
  Interface to 'Driver1' physical device
sl@0
   132
*/
sl@0
   133
class DDriver1 : public DBase
sl@0
   134
	{
sl@0
   135
public:
sl@0
   136
	/**
sl@0
   137
	Structure for holding PDD capabilities information
sl@0
   138
	*/
sl@0
   139
	class TCaps
sl@0
   140
		{
sl@0
   141
	public:
sl@0
   142
		TVersion iVersion;
sl@0
   143
		};
sl@0
   144
public:
sl@0
   145
	virtual TInt BufferSize() const =0;
sl@0
   146
	virtual TInt Speed() const =0;
sl@0
   147
	virtual TInt SetSpeed(TInt aSpeed) =0;
sl@0
   148
	virtual TInt SendData(const TDesC8& aData) =0;
sl@0
   149
	virtual void SendDataCancel() =0;
sl@0
   150
	virtual TInt ReceiveData(TDes8& aBuffer) =0;
sl@0
   151
	virtual void ReceiveDataCancel() =0;
sl@0
   152
public:
sl@0
   153
	DDriver1Channel* iLdd;
sl@0
   154
	};
sl@0
   155
sl@0
   156
#endif
sl@0
   157