williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef SYMBIAN_C32_SERCOMMS_V2 williamr@2: // PLEASE NOTE: This file is part of Version 2 of C32 - that is, the multi-threaded version. williamr@2: // The single-threaded C32 version of this file is in c32\Version1\SCOMM williamr@2: // All defect fixes should be applied to both versions where appropriate. williamr@2: // PLEASE NOTE: This comment is applicable to SercommsV2 but is surrounded by an "#ifndef" williamr@2: // to enable the automatic removal of this comment once non-C32 V2 code is removed. williamr@2: #endif williamr@2: williamr@2: williamr@2: #ifndef CS_PORT_H williamr@2: #define CS_PORT_H williamr@2: williamr@2: #include williamr@2: williamr@2: /** williamr@2: @file williamr@2: defines the classes CPort and CSerial. This file should be included by the CSY williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: /** Delta timer interval */ williamr@2: const TInt KDeltaTimerInterval = 100000; williamr@2: /** The UID for the CSY */ williamr@2: const TInt KUidUnicodeCommServerModuleV02 = 0x10005054; williamr@2: williamr@2: /** williamr@2: Defines the internal port access mode. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: // Important note!: must have the same order as TCommAccess in c32comm.h williamr@2: enum TInternalCommAccess williamr@2: { williamr@2: /** Exclusive mode. Must be first */ williamr@2: EIntCommExclusive = 0, williamr@2: /** Shared mode. Must be second */ williamr@2: EIntCommShared = 1, williamr@2: /** Preemptable mode. Must be third */ williamr@2: EIntCommPreemptable = 2, williamr@2: /** Wait until the port is closed */ williamr@2: EIntCommWaitUntilAvailable = 3 williamr@2: }; williamr@2: williamr@2: class CPortManager; williamr@2: williamr@2: williamr@2: williamr@2: class CommTimer williamr@2: /** williamr@2: Static utility class for global timer handling designed for use by Serial Server plug-ins (CSYs). williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C static void Queue(TTimeIntervalMicroSeconds32 aTimeInMicroSeconds, TDeltaTimerEntry& aHandle); williamr@2: IMPORT_C static void Remove(TDeltaTimerEntry& aHandle); williamr@2: static CDeltaTimer* GetTimer(); williamr@2: }; williamr@2: williamr@2: class CCommSession; williamr@2: class CSerial; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class CPort : public CObject williamr@2: /** Base class for implementations of serial protocol module ports. Its functions williamr@2: are called by the comms server in response to client calls to RComm. williamr@2: williamr@2: The class implements CObject to obtain reference counting behaviour. The reference williamr@2: count is incremented when a port is first created, and, for ports in shared williamr@2: mode, on every later opening. williamr@2: williamr@2: CPort is an abstract class which defines many pure virtual functions which williamr@2: derived classes must implement. Most of these pure virtual functions correspond williamr@2: to the client interface of the RComm class. williamr@2: williamr@2: Created when the first client does an Open request passing its name. williamr@2: Destroyed only when it deletes itself (following a call to Destruct). williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: { williamr@2: // Warning: No CPort::ConstructL, so can't use iExtra members until after construction. williamr@2: private: williamr@2: class CExtra : public CBase williamr@2: { williamr@2: public: williamr@2: CCommSession* iBreakOwner; williamr@2: CCommSession* iPreemptableOwner; williamr@2: CCommSession* iPreemptedSession; williamr@2: CCommSession* iWaitAvailableOwner; // Also the SetAccess owner. williamr@2: RMessagePtr2 iBlockedSetAccess; williamr@2: }; williamr@2: williamr@2: friend class CPortManager; williamr@2: williamr@2: public: williamr@2: typedef TCommAccess TAccess; williamr@2: williamr@2: void CommRead(const RMessage2& aMessage,CCommSession* aClient); // Start read operation williamr@2: void CommReadCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommWrite(const RMessage2& aMessage,CCommSession* aClient); // Start Write opneration williamr@2: void CommWriteCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommBreak(const RMessage2& aMessage,CCommSession* aClient); // Start Break operation williamr@2: void CommBreakCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommCancel(TInt aHandle, CCommSession* aClient); // Cancel all blocked operation. williamr@2: williamr@2: void CommConfig(const RMessage2& aMessage, CCommSession& aSession) const; williamr@2: void CommSetConfig(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommSetServerConfig(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommGetServerConfig(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommCaps(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommSignals(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommSetSignalsToMark(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommSetSignalsToSpace(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommReceiveBufferLength(const RMessage2& aMessage, CCommSession& aSession) const; williamr@2: void CommSetReceiveBufferLength(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommQueryReceiveBuffer(const RMessage2& aMessage, CCommSession& aSession) const; williamr@2: void CommResetBuffers(const RMessage2& aMessage, CCommSession& aSession); williamr@2: void CommSetAccess(const RMessage2& aMessage, CCommSession& aSession); williamr@2: TBool IsBlockedSetAccessWaiting(CCommSession& aClient); williamr@2: void CommSetAccessCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommDebugState(const RMessage2& aMessage, CCommSession& aSession); williamr@2: williamr@2: TBool TakeOwnershipForReading(const RMessage2& aMessage,CCommSession* aClient); // Check if a read request is valid and take ownership of port williamr@2: TBool TakeOwnershipForWriting(const RMessage2& aMessage,CCommSession* aClient); // Check if a Write request is valid and take ownership of port williamr@2: TBool TakeOwnershipForBreaking(const RMessage2& aMessage,CCommSession* aClient); // Check if a Break request is valid and take ownership of port williamr@2: williamr@2: void InitL(TDesC8 &aName); // Not used williamr@2: static TInt WriteTimerExpiredHandler(TAny* aPtr); williamr@2: static TInt ReadTimerExpiredHandler(TAny* aPtr); williamr@2: TBool AreAnyPending(); williamr@2: williamr@2: void CommGetRole(const RMessage2& aMessage, CCommSession* aClient); williamr@2: void CommGetFlowControlStatus(const RMessage2& aMessage, CCommSession* aClient); williamr@2: williamr@2: void CommNotifySignalChange(const RMessage2& aMessage, CCommSession* aClient); williamr@2: TBool TakeOwnershipForSignals(const RMessage2& aMessage,CCommSession* aClient); williamr@2: void CommNotifyFlowControlChange(const RMessage2& aMessage, CCommSession* aClient); williamr@2: TBool TakeOwnershipForFlowControl(const RMessage2& aMessage,CCommSession* aClient); williamr@2: void CommNotifyConfigChange(const RMessage2& aMessage, CCommSession* aClient); williamr@2: TBool TakeOwnershipForConfig(const RMessage2& aMessage,CCommSession* aClient); williamr@2: void CommNotifyBreak(const RMessage2& aMessage, CCommSession* aClient); williamr@2: TBool TakeOwnershipForBreak(const RMessage2& aMessage, CCommSession* aClient); williamr@2: void CommNotifyDataAvailable(const RMessage2& aMessage, CCommSession* aClient); williamr@2: TBool TakeOwnershipForNotifyDataAvailable(const RMessage2 &aMessage,CCommSession* aClient); williamr@2: void CommNotifyOutputEmpty(const RMessage2 &aMessage, CCommSession* aClient); williamr@2: TBool TakeOwnershipForNotifyOutputEmpty(const RMessage2 &aMessage,CCommSession* aClient); williamr@2: williamr@2: void CommNotifySignalChangeCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommNotifyConfigChangeCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommNotifyFlowControlChangeCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommNotifyBreakCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommNotifyDataAvailableCancel(TInt aHandle, CCommSession* aClient); williamr@2: void CommNotifyOutputEmptyCancel(TInt aHandle, CCommSession* aClient); williamr@2: williamr@2: TBool SessionHasBeenPreempted(CCommSession* aSession); williamr@2: TBool SessionIsAwaitingOpen(CCommSession* aSession); williamr@2: void FreeSession(CCommSession* aSession); williamr@2: williamr@2: public: williamr@2: IMPORT_C TInt IPCRead(const TAny* aPtr, TDes8& aDes, TInt aOffset=0) const; williamr@2: IMPORT_C TInt IPCWrite(const TAny* aPtr, const TDesC8& aDes, TInt aOffset=0) const; williamr@2: IMPORT_C CPort(); williamr@2: IMPORT_C void ReadCompleted(TInt anError); // Called by a CPort to complete a read. williamr@2: IMPORT_C void WriteCompleted(TInt anError); // Called by a CPort to complete a write williamr@2: IMPORT_C void BreakCompleted(TInt anError); // Called by a CPort to complete a break williamr@2: IMPORT_C virtual ~CPort(); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C void SignalChangeCompleted(const TUint& aSignals, TInt anError); // Called by a CPort to complete a signal notify williamr@2: IMPORT_C void ConfigChangeCompleted(const TDesC8& aNewConfig, TInt anError); // Called by a CPort to complete a config notify. williamr@2: IMPORT_C void FlowControlChangeCompleted(const TFlowControl& aFlowControl, TInt anError); // Called by a CPort to complete a flow control notify williamr@2: IMPORT_C void BreakNotifyCompleted(TInt anError); // Called by a CPort to complete a break signal notify williamr@2: IMPORT_C void NotifyDataAvailableCompleted(TInt anError); // Called by a CPort to complete a break signal notify williamr@2: IMPORT_C void NotifyOutputEmptyCompleted(TInt anError); // Called by a CPort to complete a break signal notify williamr@2: williamr@2: public: williamr@2: // williamr@2: // Pure virtual methods - to be implemented by the CSY williamr@2: // williamr@2: williamr@2: /// Called by manager when access count is 0 - CSY port must call 'delete this' williamr@2: /** Specifies the protocol for port destruction. It is called by the comms server williamr@2: when the last client-side reference to a CPort object has been closed and williamr@2: the CPort must be deleted. The comms server will not delete a CPort other williamr@2: than by calling Destruct(). williamr@2: williamr@2: The implementation should perform any asynchronous shutdown operations on williamr@2: its own resources and, when these operations have completed, should delete williamr@2: this. */ williamr@2: virtual void Destruct()=0; williamr@2: /// Queue a read - called by CPort when client wants to read williamr@2: /// Note: if the value in aLength is negative, this means williamr@2: /// ReadOneOrMore and the CSY must invert the number williamr@2: /** Specifies the protocol for reading from the port. It is called by the comms williamr@2: server in response to a RComm::Read() or RComm::ReadOneOrMore() request from williamr@2: the client. williamr@2: williamr@2: A negative value for aLength is used to flag that the read request was from williamr@2: RComm::ReadOneOrMore() rather than from RComm::Read(). The maximum length williamr@2: of data to be read is the absolute value of aLength. williamr@2: williamr@2: The implementation should use IPCWrite() to write the data to the client's williamr@2: buffer. When all the data has been read, the function should call ReadCompleted(). williamr@2: williamr@2: williamr@2: @param aClientBuffer Pointer into client address space to the descriptor containing williamr@2: the client's buffer williamr@2: @param aLength The amount of data to be read */ williamr@2: virtual void StartRead(const TAny* aClientBuffer, TInt aLength)=0; williamr@2: /// Cancel a pending read williamr@2: /** Specifies the protocol for cancelling reading from the port. It is called by williamr@2: the comms server in response to a RComm::ReadCancel() request from the client or williamr@2: when the iReadTimer timer expires. williamr@2: williamr@2: The implementation should abort any processing which was taking place as a williamr@2: result of the read request. Do not call ReadCompleted(). */ williamr@2: virtual void ReadCancel()=0; williamr@2: /// Get the size of the receive buffer from the real serial port williamr@2: /** Specifies a protocol for requesting the number of bytes that are currently williamr@2: waiting in the port's receive buffer. It is called by the comms server in williamr@2: response to a RComm::QueryReceiveBuffer() request from the client. williamr@2: williamr@2: @param aLength On return, the number of bytes currently waiting to be read williamr@2: from the receive buffer. williamr@2: @return A system wide error code. */ williamr@2: virtual TInt QueryReceiveBuffer(TInt& aLength) const=0; williamr@2: /// reset Tx and Rx buffers williamr@2: /** Specifies a protocol for resetting the receive and/or transmit buffers to zero williamr@2: length. It is called by the comms server in response to a RComm::ResetBuffers() williamr@2: request from the client. williamr@2: williamr@2: @param aFlags Bitmask of the following flags: KCommResetRx to reset the receive williamr@2: buffer; KCommResetTx to reset the transmit buffer */ williamr@2: virtual void ResetBuffers(TUint aFlags)=0; williamr@2: /// Queue a write - called by CPort when client wants to write williamr@2: /** Specifies the protocol for writing to the port. It is called by the comms server williamr@2: in response to a RComm::Write() request from the client. williamr@2: williamr@2: The implementation should use IPCRead() to get the data to write from the williamr@2: client's buffer. When all the data has been written, the function should call williamr@2: WriteCompleted(). williamr@2: williamr@2: @param aClientBuffer Pointer into client address space to the descriptor containing williamr@2: the client's buffer williamr@2: @param aLength The amount of data to be written */ williamr@2: virtual void StartWrite(const TAny* aClientBuffer, TInt aLength)=0; williamr@2: /// Cancel a pending write williamr@2: /** Specifies the protocol for cancelling writing to the port. It is called by williamr@2: the comms server in response to a RComm::WriteCancel() request from the client. williamr@2: williamr@2: The implementation should abort any processing which was taking place as a williamr@2: result of the write request. Do not call WriteCompleted(). */ williamr@2: virtual void WriteCancel()=0; williamr@2: /// Queue a break williamr@2: /** Specifies the protocol for setting a break condition at the port. It is called williamr@2: by the comms server in response to a RComm::Break() request from the client. williamr@2: williamr@2: When the break is complete, the function should call BreakCompleted(). williamr@2: williamr@2: @param aTime Time period to break for in microseconds */ williamr@2: virtual void Break(TInt aTime)=0; williamr@2: /// Cancel a pending break williamr@2: /** Specifies the protocol for cancelling a break request. It is called by the williamr@2: comms server in response to a RComm::BreakCancel() request from the client. williamr@2: williamr@2: The implementation should abort any processing which was taking place as a williamr@2: result of the break request. Do not call BreakCompleted(). */ williamr@2: virtual void BreakCancel()=0; williamr@2: /// Pass a config request - return in descriptor williamr@2: /** Specifies a protocol for getting the current configuration of the serial port. williamr@2: It is called by the comms server in response to a RComm::GetConfig() request williamr@2: from the client. williamr@2: williamr@2: @param aPackage A packaged TCommConfig buffer, set on return to the current williamr@2: configuration of the serial port williamr@2: @return A system wide error code */ williamr@2: virtual TInt GetConfig(TDes8& aPackage) const=0; williamr@2: /// Set config with package in the descriptor williamr@2: /** Specifies a protocol for setting the configuration of the port. It is called williamr@2: by the comms server in response to a RComm::SetConfig() request from the client. williamr@2: williamr@2: @param aPackage A packaged TCommConfig buffer holding the new configuration williamr@2: values williamr@2: @return A system error code */ williamr@2: virtual TInt SetConfig(const TDesC8& aPackage)=0; williamr@2: /// Set the port to use partial reads/writes williamr@2: /** Specifies a protocol for setting the buffer mode. It is called by the comms williamr@2: server in response to a RComm::SetMode() request from the client. williamr@2: williamr@2: @param aPackage A TCommServerConfig package buffer holding the mode settings williamr@2: @return A system-wide error code */ williamr@2: virtual TInt SetServerConfig(const TDesC8& aPackage)=0; williamr@2: /// Get the server configs from the CSY williamr@2: /** Specifies a protocol for getting the buffer mode. It is called by the comms williamr@2: server in response to a RComm::Mode() request from the client. williamr@2: williamr@2: @param aPackage A TCommServerConfig package buffer that, on return, holds williamr@2: the current buffer mode settings williamr@2: @return A system error code */ williamr@2: virtual TInt GetServerConfig(TDes8& aPackage)=0; williamr@2: /// Read capabilities from the driver williamr@2: /** Specifies a protocol for getting the port capabilities. It is called by the williamr@2: comms server in response to a RComm::Caps() request from the client. williamr@2: williamr@2: @param aPackage A TCommCaps package buffer that, on return, holds the port williamr@2: capabilities williamr@2: @return A system error code */ williamr@2: virtual TInt GetCaps(TDes8& aPackage)=0; williamr@2: /// Get the status of the signal pins williamr@2: /** Specifies a protocol for getting the status of the serial port control lines. williamr@2: It is called by the comms server in response to a RComm::GetSignals() request williamr@2: from the client. williamr@2: williamr@2: @param aSignals An integer with the bits set to reflect the status of the williamr@2: handshaking lines. williamr@2: @return A system error code */ williamr@2: virtual TInt GetSignals(TUint& aSignals)=0; williamr@2: /// Set selected signals to high (logical 1) williamr@2: /** Specifies a protocol for setting serial port control lines. It is called by williamr@2: the comms server in response to a RComm::SetSignals() request from the client. williamr@2: williamr@2: @param aSignals A bitmask of the handshaking lines to set williamr@2: @return A system error code */ williamr@2: virtual TInt SetSignalsToMark(TUint aSignals)=0; williamr@2: /// Set selected signals to low (logical 0) williamr@2: /** Specifies a protocol for clearing serial port control lines. It is called by williamr@2: the comms server in response to a RComm::SetSignals() request from the client. williamr@2: williamr@2: @param aSignals A bitmask of the handshaking lines to clear williamr@2: @return A system error code */ williamr@2: virtual TInt SetSignalsToSpace(TUint aSignals)=0; williamr@2: /// Get size of Tx and Rx buffer williamr@2: /** Specifies a protocol for requesting the size of the serial port buffers. It williamr@2: is called by the comms server in response to a RComm::ReceiveBufferLength() williamr@2: request from the client. williamr@2: williamr@2: @param aLength The current size of the serial port buffers in bytes williamr@2: @return A system error code */ williamr@2: virtual TInt GetReceiveBufferLength(TInt& aLength) const=0; williamr@2: /// Set size of Tx and Rx buffer williamr@2: /** Specifies a protocol for setting the size of the serial port buffers. It is williamr@2: called by the comms server in response to a RComm::SetReceiveBufferLength() williamr@2: request from the client. williamr@2: williamr@2: @param aLength Requested size of the serial port buffers in bytes williamr@2: @return A system error code */ williamr@2: virtual TInt SetReceiveBufferLength(TInt aLength)=0; williamr@2: virtual void FreeMemory(); // csys have their own implementation, e.g. ECUART williamr@2: /// Notify client when the signals change williamr@2: /** Specifies the protocol for setting a "signal change" notification. It is called williamr@2: by the comms server in response to a RComm::NotifySignalChange() request from williamr@2: the client. williamr@2: williamr@2: @param aSignalMask Signal mask passed by client */ williamr@2: virtual void NotifySignalChange(TUint aSignalMask)=0; williamr@2: /// Cancel an outstanding signal change notification williamr@2: /** Specifies the protocol for cancelling a "signal change" notification. It is called williamr@2: by the comms server in response to a RComm::NotifySignalChangeCancel() request williamr@2: from the client. */ williamr@2: virtual void NotifySignalChangeCancel()=0; williamr@2: /// Notify client when the configation changes williamr@2: /** Specifies the protocol for setting a "configuration change" notification. It williamr@2: is called by the comms server in response to a RComm::NotifyConfigChange() williamr@2: request from the client. */ williamr@2: virtual void NotifyConfigChange()=0; williamr@2: /// Cancel an outstanding config change notification williamr@2: /** Specifies the protocol for cancelling a "configuration change" notification. williamr@2: It is called by the comms server in response to a RComm::NotifyConfigChangeCancel() williamr@2: request from the client. */ williamr@2: virtual void NotifyConfigChangeCancel()=0; williamr@2: /// Notify client when the flow control changes williamr@2: /** Specifies the protocol for setting a "flow control change" notification. It is williamr@2: called by the comms server in response to a RComm::NotifyFlowControlChange() williamr@2: request from the client. */ williamr@2: virtual void NotifyFlowControlChange()=0; williamr@2: /// Cancel an outstanding flow control change notification williamr@2: /** Specifies the protocol for cancelling a "flow control change" notification. It williamr@2: is called by the comms server in response to a RComm::NotifyFlowControlChangeCancel() williamr@2: request from the client. */ williamr@2: virtual void NotifyFlowControlChangeCancel()=0; williamr@2: /// Notify client when a break occurs williamr@2: /** Specifies the protocol for setting a "break" notification. It is called by the williamr@2: comms server in response to a RComm::NotifyBreak() request from the client. */ williamr@2: virtual void NotifyBreak()=0; williamr@2: /// Cancel an outstanding break notification williamr@2: /** Specifies the protocol for cancelling a "break" notification. It is called by williamr@2: the comms server in response to a RComm::NotifyBreakCancel() request from williamr@2: the client. */ williamr@2: virtual void NotifyBreakCancel()=0; williamr@2: /// Notify client when data is available williamr@2: /** Specifies the protocol for setting a "data available" notification. It is called williamr@2: williamr@2: by the comms server in response to a RComm::NotifyDataAvailable() request williamr@2: from the client. */ williamr@2: virtual void NotifyDataAvailable()=0; williamr@2: /// Cancel an outstanding data available notification williamr@2: /** Specifies the protocol for cancelling a "data available" notification. It is williamr@2: called by the comms server in response to a RComm::NotifyDataAvailableCancel() williamr@2: request from the client. */ williamr@2: virtual void NotifyDataAvailableCancel()=0; williamr@2: /// Notify client when output buffer is empty williamr@2: /** Specifies the protocol for setting a transmit buffer empty notification. It williamr@2: is called by the comms server in response to a RComm::NotifyOutputEmpty() williamr@2: request from the client. */ williamr@2: virtual void NotifyOutputEmpty()=0; williamr@2: /// Cancel an outstanding output empty notification williamr@2: /** Specifies the protocol for cancelling a transmit buffer empty notification. williamr@2: It is called by the comms server in response to a RComm::NotifyOutputEmptyCancel() williamr@2: request from the client. */ williamr@2: virtual void NotifyOutputEmptyCancel()=0; williamr@2: /// Get the flow control status williamr@2: /** Gets flow control status. It is called by the comms server in response to a williamr@2: RComm::SetMode() request from the client. williamr@2: williamr@2: @param aFlowControl Flow control status to return to the client williamr@2: @return A system-wide error code */ williamr@2: virtual TInt GetFlowControlStatus(TFlowControl& aFlowControl)=0; williamr@2: /// Get the role of this port unit williamr@2: /** Gets DCE/DTE role. It is called by the comms server in response to a RComm::GetRole() williamr@2: request from the client. williamr@2: williamr@2: @param aRole On return, DCE/DTE role to return to the client williamr@2: @return A system-wide error code */ williamr@2: virtual TInt GetRole(TCommRole& aRole)=0; williamr@2: /// Set the role of this port unit williamr@2: /** Sets DCE/DTE role. It is called by the comms server in response to a RComm::Open() williamr@2: request from the client. williamr@2: williamr@2: @param aRole DCE/DTE role williamr@2: @return A system-wide error code */ williamr@2: virtual TInt SetRole(TCommRole aRole)=0; williamr@2: williamr@2: // Accessors williamr@2: #ifdef _DEBUG_DEVCOMM williamr@2: virtual void DoDumpDebugInfo(const RMessage2 &aMessage)=0; williamr@2: #endif williamr@2: private: williamr@2: void DoOpenL(CCommSession* aSession, TInternalCommAccess aMode, TCommRole aRole,TBool aIsNew); williamr@2: void DoPreemption(); williamr@2: williamr@2: TDeltaTimerEntry iReadTimer; ///< delta timer entry for read timeouts williamr@2: TBool iReadTimerPending; ///< true if a read timer is pending williamr@2: TDeltaTimerEntry iWriteTimer; ///< delta timer entry for write timeouts williamr@2: TBool iWriteTimerPending; ///< true if a write timer is pending williamr@2: TInternalCommAccess iMode; ///< access mode for this port williamr@2: CCommSession* iReadOwner; ///< pointer to the read session williamr@2: TInt iReadOwnerHandle; ///< handle to the read session williamr@2: CCommSession* iWriteOwner; ///< pointer to the write session williamr@2: TInt iWriteOwnerHandle; ///< handle to the write session williamr@2: // Binary compatible williamr@2: // Was: CCommSession* iBreakOwner; Replace with: williamr@2: CExtra* iExtra; ///< pointer to the CExtra object for pre-emptable handling williamr@2: #define iBreakOwner (iExtra->iBreakOwner) ///< forwards iBreakOwner to iExtra->iBreakOwner williamr@2: williamr@2: TInt iBreakOwnerHandle; ///< handle to the break owner williamr@2: CCommSession* iSignalOwner; ///< pointer to the signal session williamr@2: TInt iSignalOwnerHandle; ///< handle to the signal session williamr@2: CCommSession* iFlowControlOwner; ///< pointer to the flow control session williamr@2: TInt iFlowControlOwnerHandle; ///< handle to the flow control session williamr@2: CCommSession* iConfigOwner; ///< pointer to the config session williamr@2: TInt iConfigOwnerHandle; ///< handle to the config session williamr@2: CCommSession* iBreakNotifyOwner; ///< pointer to the break notify session williamr@2: TInt iBreakNotifyOwnerHandle; ///< handle to the break notify session williamr@2: CCommSession* iNotifyDataAvailableOwner; ///< pointer to the data available session williamr@2: TInt iNotifyDataAvailableOwnerHandle; ///< handle to the data available session williamr@2: CCommSession* iNotifyOutputEmptyOwner; ///< pointer to the output empty session williamr@2: TInt iNotifyOutputEmptyOwnerHandle; ///< handle to the output empty session williamr@2: williamr@2: RMessagePtr2 iBlockedRead; ///< pointer to the read request message williamr@2: RMessagePtr2 iBlockedWrite; ///< pointer to the write request message williamr@2: RMessagePtr2 iBlockedBreak; ///< pointer to the break request message williamr@2: williamr@2: /**The encapsulated message*/ williamr@2: RMessagePtr2 iBlockedSignalChange; ///< holds the notify signal change message williamr@2: /**Private padding to preserve BC with earlier versions*/ williamr@2: TInt iBlockedSignalChangeDummyPadding[7]; williamr@2: williamr@2: /**The encapsulated message*/ williamr@2: RMessagePtr2 iBlockedConfigChange; ///< holds the notify config change message williamr@2: /**Private padding to preserve BC with earlier versions*/ williamr@2: TInt iBlockedConfigChangeDummyPadding[7]; williamr@2: williamr@2: /**The encapsulated message*/ williamr@2: RMessagePtr2 iBlockedFlowControlChange; ///< holds the notify flow control change message williamr@2: /**Private padding to preserve BC with earlier versions*/ williamr@2: TInt iBlockedFlowControlChangeDummyPadding[7]; williamr@2: williamr@2: RMessagePtr2 iBlockedBreakNotify; ///< pointer to the notify break request message williamr@2: RMessagePtr2 iBlockedNotifyDataAvailable; ///< pointer to the notify data available request message williamr@2: RMessagePtr2 iBlockedNotifyOutputEmpty; ///< pointer to the notify output empty request message williamr@2: williamr@2: CPortManager* iPortManager; ///< Not Used. Not to be exposed to deriving classes of CPort. williamr@2: IMPORT_C virtual void CPort_Reserved1(); williamr@2: TAny* iCPort_Reserved; ///< reserved pointer williamr@2: }; williamr@2: williamr@2: williamr@2: // williamr@2: // forward declaration williamr@2: // williamr@2: class CLibUnloader; williamr@2: williamr@2: williamr@2: class CSerial : public CObject williamr@2: /** williamr@2: Factory for a single CPort object. williamr@2: williamr@2: CSerial is the base class for implementations of serial port factories. It is intended to be williamr@2: overridden by the CSY so that C32 can call in and ask the CSY to create serial ports. In this way williamr@2: the factory is responsible for creating instances of CPort-derived classes williamr@2: for the protocol of the CSY. It also provides query functions, which return general information williamr@2: about the capabilities of the serial protocol implemented by the CSY. williamr@2: williamr@2: Owned by the CPort object it creates. williamr@2: williamr@2: Writing derived classes: williamr@2: williamr@2: The pure virtual NewPortL() and Info() functions must be implemented in derived williamr@2: classes. Serial protocol modules which can take differing action based on williamr@2: the version of the comms server should also override QueryVersionSupported(). williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CSerial(); williamr@2: IMPORT_C ~CSerial(); williamr@2: IMPORT_C virtual TBool QueryVersionSupported(const TVersion& aVersion) const; williamr@2: void ConstructL(RLibrary& aLib); williamr@2: public: williamr@2: // williamr@2: // pure virtuals to be implemented by the CSY williamr@2: // williamr@2: williamr@2: /// Create a new port for the supplied unit number williamr@2: /** Specifies the protocol for creating a new serial port for the protocol. The williamr@2: comms server calls this function in response to a RComm:Open() call. williamr@2: williamr@2: Typically, the implementation would call NewL() on the protocol's CPort-based williamr@2: class. Any resources required by the new port object should be done at this williamr@2: stage. If the serial port object cannot be created for any reason, NewPortL() williamr@2: should leave with an appropriate error code. williamr@2: williamr@2: The interpretation of unit numbers is specific to the particular serial protocol williamr@2: module. However, unit numbers on Symbian OS should be zero-based. For the williamr@2: default built-in serial ports implemented by the serial protocol module ecuart.csy, williamr@2: the unit numbers refer to the hardware ports, with 0 being the first port williamr@2: on the machine. If a second request is made to create a port with a unit number williamr@2: that has already been created and not destroyed, NewPortL() should leave with williamr@2: KErrAlreadyExists. williamr@2: williamr@2: @param aUnit The unit number to be created. */ williamr@2: virtual CPort* NewPortL(const TUint aUnit)=0; williamr@2: /// Get info about this CSY, fill in the supplied structure. williamr@2: /** Specifies the protocol for getting the information about the serial protocol. williamr@2: williamr@2: Implementations should fill in the TSerialInfo structure to reflect the protocol's williamr@2: capabilities. williamr@2: williamr@2: @param aSerialInfo On return, set to indicate the capabilities of the serial williamr@2: protocol. */ williamr@2: virtual void Info(TSerialInfo &aSerialInfo)=0; williamr@2: williamr@2: void ModuleName(TDes& aName); williamr@2: williamr@2: IMPORT_C virtual TSecurityPolicy PortPlatSecCapability(TUint aPort) const; williamr@2: williamr@2: protected: williamr@2: /** Module version number. The class should initialise this member with its version williamr@2: number from its constructor. */ williamr@2: TVersion iVersion; ///< holds the version of the CSY williamr@2: private: williamr@2: CLibUnloader* iLibUnloader; ///< pointer to the library unloader williamr@2: IMPORT_C virtual void CSerial_Reserved1(); williamr@2: TAny* iCSerial_Reserved; ///< reserved pointer for future BC williamr@2: }; williamr@2: williamr@2: /** This typedef defines the form of the ordinal-1 entry point function to a serial williamr@2: protocol module. The function should create and return a concrete CSerial-derived williamr@2: class, which will then be used by the comms server. williamr@2: williamr@2: Each serial protocol module should only ever create a single serial protocol williamr@2: factory object. If the entry point is called twice without the first factory williamr@2: object being destroyed, this function should leave with KErrGeneral. */ williamr@2: typedef CSerial *(*TSerialNewL)(); ///< function type of CSY module entry point williamr@2: williamr@2: #endif // CS_PORT_H