toolsandutils/wintunnel/src_cedar/winscomm.h
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 // Copyright (c) 2002-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 "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 // wins/specific/winscomm.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __M32COMM_H__
       
    19 #define __M32COMM_H__
       
    20 #include <platform.h>
       
    21 //#include <kpower.h>
       
    22 #include <d32comm.h>
       
    23 #include <e32ver.h>
       
    24 //
       
    25 const TInt KCommsMajorVersionNumber=1;
       
    26 const TInt KCommsMinorVersionNumber=1;
       
    27 const TInt KCommsBuildVersionNumber=KE32BuildVersionNumber;
       
    28 
       
    29 //
       
    30 enum TStopMode {EStopNormal,EStopPwrDown,EStopEmergency};
       
    31 //
       
    32 //
       
    33 class DChannelComm;
       
    34 class DComm : public DBase
       
    35 	{
       
    36 public:
       
    37 	virtual TInt Start() =0;
       
    38 	virtual void Stop(TStopMode aMode) =0;
       
    39 	virtual void Break(TBool aState) =0;
       
    40 	virtual void Write(DThread*,TAny*,TInt) = 0;
       
    41 	virtual void Read(DThread*,TAny*,TInt) = 0;
       
    42 	virtual void NotifySignals(DThread*, TInt) = 0;
       
    43 	virtual void NotifyDataAvailable() = 0;
       
    44 	virtual TUint Signals() const =0;
       
    45 	virtual void SetSignals(TUint aSetMask,TUint aClearMask) =0;
       
    46 	virtual TInt ValidateConfig(const TCommConfigV01 &aConfig) const =0;
       
    47 	virtual void Configure(TCommConfigV01 &aConfig) =0;
       
    48 	virtual void Caps(TDes8 &aCaps) const =0;
       
    49 	virtual void CheckConfig(TCommConfigV01& aConfig)=0;
       
    50 	virtual TDfcQue* DfcQ(TInt aUnit)=0;
       
    51 	inline void SetCurrent(TInt aCurrent);
       
    52 	inline TBool Transmitting();
       
    53 	virtual TInt RxCount() =0;
       
    54 	virtual void ResetBuffers(TBool) = 0;
       
    55 	virtual TInt SetRxBufferSize(TInt aSize) = 0;
       
    56 	virtual TInt RxBufferSize() =0;
       
    57 	virtual TDes8* RxBuffer() =0;
       
    58 	virtual TBool AreAnyPending() = 0;
       
    59 	virtual void ReadCancel() = 0;
       
    60 	virtual void WriteCancel() = 0;
       
    61 	virtual void SignalChangeCancel() = 0;
       
    62 
       
    63 public:
       
    64 	DChannelComm *iLdd;
       
    65 	TBool iTransmitting;
       
    66 	TUint8 * iInBufPtr;
       
    67 	TUint8 * iOutBufPtr;
       
    68 
       
    69 	};
       
    70 
       
    71 
       
    72 class DDeviceComm : public DLogicalDevice
       
    73 	{
       
    74 public:
       
    75 	DDeviceComm();
       
    76 	virtual TInt Install();
       
    77 	virtual void GetCaps(TDes8 &aDes) const;
       
    78 	virtual TInt Create(DLogicalChannelBase*& aChannel);
       
    79 	};
       
    80 
       
    81 //class DCommPowerHandler;
       
    82 class DChannelComm : public DLogicalChannel
       
    83 	{
       
    84 public:
       
    85 	enum TState {EOpen,EActive,EClosed};
       
    86 	enum TRequest {ERx=1, ETx=2, ESigChg=4, ERxDA=8, EAll=0xff};
       
    87 
       
    88 	DChannelComm();
       
    89 	~DChannelComm();
       
    90 	inline void SetStatus(TState aStatus);
       
    91 	TInt TurnaroundSet(TUint aNewTurnaroundMilliSeconds);
       
    92 	TBool TurnaroundStopTimer();
       
    93 	TInt TurnaroundClear();
       
    94 	static void TurnaroundStartDfc(TAny* aSelf);
       
    95 	void TurnaroundStartDfcImplementation(TBool inIsr);
       
    96 	static void TurnaroundTimeout(TAny* aSelf);
       
    97 	void TurnaroundTimeoutImplementation(void);
       
    98 
       
    99 protected:
       
   100 	virtual TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
       
   101 	virtual void HandleMsg(TMessageBase* aMsg);
       
   102 	void DoCancel(TInt aMask);
       
   103 	TInt DoControl(TInt aId, TAny* a1, TAny* a2);
       
   104 	TInt DoRequest(TInt aId, TRequestStatus* aStatus, TAny* a1, TAny* a2);
       
   105 	void Start();
       
   106 	void Shutdown();
       
   107 	void BreakOn();
       
   108 	void BreakOff();
       
   109 	void ResetBuffers(TBool aResetTx);
       
   110 	void DoCompleteRx();
       
   111 	void DoCompleteTx();
       
   112 	void DoSignalNotify();
       
   113 	void DoRxDataAvailable();
       
   114 	void Complete(TInt aMask, TInt aReason);
       
   115 	inline void CompleteRead()	{ iRxCompleteDfc.Add(); }
       
   116 	inline void CompleteWrite() { iTxCompleteDfc.Add(); }
       
   117 protected:
       
   118 	inline void Write(DThread* aT, TAny* aP, TInt aL) {((DComm*)iPdd)->Write(aT, aP,aL);}
       
   119 	inline void Read(DThread* aT, TAny* aP, TInt aL) {((DComm*)iPdd)->Read(aT, aP,aL);}
       
   120 	inline void NotifySignals(DThread* aThread, TInt aMask) {((DComm*)iPdd)->NotifySignals(aThread, aMask);}
       
   121 	inline void NotifyDataAvailable() {((DComm*)iPdd)->NotifyDataAvailable(); }
       
   122 	inline TInt PddStart();
       
   123 	inline void Stop(TStopMode aMode);
       
   124 	inline void PddBreak(TBool aState);
       
   125 	inline TUint Signals() const;
       
   126 	inline void SetSignals(TUint aSetMask,TUint aClearMask);
       
   127 	inline TInt ValidateConfig(const TCommConfigV01 &aConfig) const;
       
   128 	inline void PddConfigure(TCommConfigV01 &aConfig);
       
   129 	inline void PddCaps(TDes8 &aCaps) const;
       
   130 	inline void PddCheckConfig(TCommConfigV01& aConfig);
       
   131 	inline TBool Transmitting();
       
   132 	inline TInt BufferSize();
       
   133 	inline void ReadCancel();
       
   134 	inline void WriteCancel();
       
   135 	inline void SignalChangeCancel();
       
   136 private:
       
   137 //	static void PowerUpDfc(TAny* aPtr);
       
   138 //	static void PowerDownDfc(TAny* aPtr);
       
   139 	static void CompleteRxDfc(TAny* aPtr);
       
   140 	static void CompleteTxDfc(TAny* aPtr);
       
   141 	static void SignalNotifyDfc(TAny* aPtr);
       
   142 	static void RxDataAvailableDfc(TAny* aPtr);
       
   143 	inline TInt RxCount();
       
   144 	inline TInt RxBufferSize();
       
   145 	inline TDes8* RxBuffer();
       
   146 	inline TInt SetRxBufferSize(TInt aSize);
       
   147 	inline TBool AreAnyPending() const;
       
   148 //	void UpdateSignals();
       
   149 	void UpdateAndProcessSignals();
       
   150 	void InitiateRead(TAny* aRxDes, TInt aLength);
       
   151 	void InitiateWrite(TAny* aTxDes, TInt aLength);
       
   152 	void InitiateNotifySignals(TAny* aResult, TInt aMask);
       
   153 	void NotifyReadDataAvailable();
       
   154 //	TUint FailSignals(TUint aHandshake);
       
   155 //	TUint HoldSignals(TUint aHandshake);
       
   156 //	TUint FlowControlSignals(TUint aHandshake);
       
   157 //	TUint AutoSignals(TUint aHandshake);
       
   158 	TInt SetConfig(TCommConfigV01& aConfig);
       
   159 //	void CheckOutputHeld();
       
   160 //	void ReleaseBuffers();
       
   161 
       
   162 	// Min Turnaround time between Rx and Tx
       
   163 	TUint		iTurnaroundMicroSeconds;		// delay after a receive before transmission in us
       
   164 	TUint		iTurnaroundMinMilliSeconds;		// delay after a receive before transmission in ms
       
   165 	TBool		iTurnaroundTimerRunning;		// a receive has started the timer
       
   166 	TBool		iTurnaroundTransmitDelayed;		// a transmission is held until time elapses after a receive
       
   167 	NTimer		iTurnaroundTimer;				// used to delay transmission after a receive
       
   168 	TDfc		iTurnaroundDfc;					// used in interrupt space, to trigger a call in user space
       
   169 
       
   170 	TAny*		iTurnaroundTxDesPtr;			// client descriptor awaiting transmission
       
   171 	TInt		iTurnaroundTxDesLength;			// initial size of tx descriptor
       
   172 
       
   173 public:
       
   174 	// Port configuration
       
   175 	TCommConfigV01 iConfig;
       
   176 
       
   177 	// General items
       
   178 	DThread* iClient;
       
   179 	TAny* iClientDestPtr;
       
   180 //	DCommPowerHandler* iPowerHandler;
       
   181 //	TDfc iPowerUpDfc;
       
   182 //	TDfc iPowerDownDfc;
       
   183 //	TUint32 iPowerDownMask;
       
   184 	TState iStatus;
       
   185 	TDfc iRxCompleteDfc;
       
   186 	TDfc iTxCompleteDfc;
       
   187 	TDfc iRxDataAvailableDfc;
       
   188 	TDfc iSigNotifyDfc;
       
   189 	TUint iFlags;				//
       
   190 	TUint iSignals;				// State of handshake lines
       
   191 //	TUint iFailSignals;			// 1 bit means line low causes line fail error
       
   192 //	TUint iHoldSignals;			// 1 bit means line low halts TX
       
   193 //	TUint iFlowControlSignals;	// 1 bit means signal is used for RX flow control
       
   194 //	TUint iAutoSignals;			// 1 bit means signal is high when channel is open
       
   195 	TBool iShutdown;			// ETrue means device is being closed
       
   196 	TBool iMsgHeld;				// ETrue means a message has been held up waiting power on
       
   197 
       
   198 	// RX client related items
       
   199 	TInt iRxError;
       
   200 	TRequestStatus* iRxStatus;
       
   201 
       
   202 
       
   203 	// TX client related items
       
   204 	TInt iTxError;
       
   205 	TRequestStatus* iTxStatus;
       
   206 
       
   207 	// DataAvailable client related items
       
   208 	TInt iRxDAError;
       
   209 	TRequestStatus* iRxDAStatus;
       
   210 
       
   211 	// Signal change notification
       
   212 	TInt iSignalError;
       
   213 	TRequestStatus* iSignalStatus;	
       
   214 	TUint* iClientSignalResultPtr;	//ptr to uint in client address space
       
   215 	TUint iSignalResult;			//holds result of the signal (in Symbian OS values)
       
   216 	};
       
   217 
       
   218 //class DCommPowerHandler : public DPowerHandler
       
   219 //	{
       
   220 //public:
       
   221 //	DCommPowerHandler(DChannelComm* aChannel);
       
   222 //	virtual TInt DoPowerUp();
       
   223 //	virtual void DoPowerDown(TUint32 aPowerDownMask);
       
   224 //	virtual void DoEmergencyPowerDown();
       
   225 //public:
       
   226 //	DChannelComm* iChannel;
       
   227 //	};
       
   228 
       
   229 #include "winscomm.inl"
       
   230 
       
   231 #endif