Update contrib.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 @file Kernel side interfaces to example Logical and Physical Device Drivers
22 #ifndef __DRIVER1_DEV_H__
23 #define __DRIVER1_DEV_H__
26 Physical Device (factory class) for 'Driver1'
28 class DDevice1PddFactory : public DPhysicalDevice
32 ~DDevice1PddFactory();
33 // Inherited from DPhysicalDevice
34 virtual TInt Install();
35 virtual void GetCaps(TDes8& aDes) const;
36 virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
37 virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
41 enum TMinimumLDDVersion
43 EMinimumLddMajorVersion=1,
44 EMinimumLddMinorVersion=0,
45 EMinimumLddBuild=0 //Not used
48 TDynamicDfcQue* iDfcQ;
52 Logical Device (factory class) for 'Driver1'
54 class DDriver1Factory : public DLogicalDevice
59 // Inherited from DLogicalDevice
60 virtual TInt Install();
61 virtual void GetCaps(TDes8& aDes) const;
62 virtual TInt Create(DLogicalChannelBase*& aChannel);
69 Logical Channel class for 'Driver1'
71 class DDriver1Channel : public DLogicalChannel
75 virtual ~DDriver1Channel();
76 // Inherited from DObject
77 virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
78 // Inherited from DLogicalChannelBase
79 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
80 // Inherited from DLogicalChannel
81 virtual void HandleMsg(TMessageBase* aMsg);
86 ERequestAlreadyPending = 1
88 // Implementation for the differnt kinds of messages sent through RBusLogicalChannel
89 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
90 TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
91 void DoCancel(TUint aMask);
92 // Accessor for the PDD
93 inline DDriver1* Pdd();
94 // Methods for configuration
95 TInt GetConfig(TDes8* aConfigBuf);
96 TInt SetConfig(const TDesC8* aConfigBuf);
97 void CurrentConfig(RDriver1::TConfig& aConfig);
98 // Methods for processing a SendData request
99 TInt SendData(TRequestStatus* aStatus,const TDesC8* aData);
100 void SendDataCancel();
101 void DoSendDataComplete();
102 static void SendDataDfc(TAny* aPtr);
103 // Methods for processing a ReceiveData request
104 TInt ReceiveData(TRequestStatus* aStatus,TDes8* aBuffer);
105 void ReceiveDataCancel();
106 void DoReceiveDataComplete();
107 static void ReceiveDataDfc(TAny* aPtr);
109 // Interface methods for use by PDD
110 virtual void SendDataComplete(TInt aResult);
111 virtual void ReceiveDataComplete(TInt aResult);
114 // Members used for processing a SendData request
115 TRequestStatus* iSendDataStatus;
117 TInt iSendDataResult;
118 TBuf8<256> iSendDataBuffer;
119 // Members used for processing a ReceiveData request
120 TDes8* iReceiveDataDescriptor;
121 TRequestStatus* iReceiveDataStatus;
122 TDfc iReceiveDataDfc;
123 TInt iReceiveDataResult;
124 TBuf8<256> iReceiveDataBuffer;
127 inline DDriver1* DDriver1Channel::Pdd()
128 { return (DDriver1*)iPdd; }
131 Interface to 'Driver1' physical device
133 class DDriver1 : public DBase
137 Structure for holding PDD capabilities information
145 virtual TInt BufferSize() const =0;
146 virtual TInt Speed() const =0;
147 virtual TInt SetSpeed(TInt aSpeed) =0;
148 virtual TInt SendData(const TDesC8& aData) =0;
149 virtual void SendDataCancel() =0;
150 virtual TInt ReceiveData(TDes8& aBuffer) =0;
151 virtual void ReceiveDataCancel() =0;
153 DDriver1Channel* iLdd;