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