serialserver/c32serialserver/INC/CS_PORT.H
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 //
       
    15 
       
    16 
       
    17 
       
    18 #ifndef CS_PORT_H
       
    19 #define CS_PORT_H
       
    20 
       
    21 #include <c32comm.h>
       
    22 
       
    23 /** 
       
    24 @file
       
    25 defines the classes CPort and CSerial. This file should be included by the CSY
       
    26 
       
    27 @publishedAll	
       
    28 @released
       
    29 */
       
    30 
       
    31 /** Delta timer interval */
       
    32 const TInt KDeltaTimerInterval = 100000;     
       
    33 /** The UID for the CSY */          
       
    34 const TInt KUidUnicodeCommServerModuleV02 = 0x10005054;
       
    35 
       
    36 /**
       
    37 Defines the internal port access mode.
       
    38 
       
    39 @publishedAll	
       
    40 @released
       
    41 */
       
    42 // Important note!: must have the same order as TCommAccess in c32comm.h
       
    43 enum TInternalCommAccess
       
    44 	{
       
    45     /**  Exclusive mode. Must be first */
       
    46 	EIntCommExclusive          = 0, 
       
    47 	/**  Shared mode. Must be second */
       
    48 	EIntCommShared             = 1, 
       
    49 	/**  Preemptable mode. Must be third */
       
    50 	EIntCommPreemptable        = 2, 
       
    51 	/**  Wait until the port is closed */
       
    52 	EIntCommWaitUntilAvailable = 3  
       
    53 	};
       
    54 
       
    55 class CPortManager;
       
    56 
       
    57 
       
    58 
       
    59 class CommTimer 
       
    60 /**
       
    61 Static utility class for global timer handling designed for use by Serial Server plug-ins (CSYs).
       
    62 
       
    63 @publishedAll	
       
    64 @released
       
    65 */
       
    66 	{
       
    67 public:
       
    68 	IMPORT_C static void Queue(TTimeIntervalMicroSeconds32 aTimeInMicroSeconds, TDeltaTimerEntry& aHandle);
       
    69 	IMPORT_C static void Remove(TDeltaTimerEntry& aHandle);
       
    70 	static CDeltaTimer* GetTimer();
       
    71 	};
       
    72 
       
    73 class CCommSession;
       
    74 class CSerial;
       
    75 
       
    76 
       
    77 
       
    78 
       
    79 class CPort : public CObject
       
    80 /** Base class for implementations of serial protocol module ports. Its functions 
       
    81 are called by the comms server in response to client calls to RComm. 
       
    82 
       
    83 The class implements CObject to obtain reference counting behaviour. The reference 
       
    84 count is incremented when a port is first created, and, for ports in shared 
       
    85 mode, on every later opening.
       
    86 
       
    87 CPort is an abstract class which defines many pure virtual functions which 
       
    88 derived classes must implement. Most of these pure virtual functions correspond 
       
    89 to the client interface of the RComm class.
       
    90 
       
    91 Created when the first client does an Open request passing its name.
       
    92 Destroyed only when it deletes itself (following a call to Destruct).
       
    93 
       
    94 @publishedAll	
       
    95 @released */
       
    96 	{
       
    97 	// Warning:  No CPort::ConstructL, so can't use iExtra members until after construction.
       
    98 private:
       
    99 	class CExtra : public CBase
       
   100 		{
       
   101 	public:
       
   102 		CCommSession* iBreakOwner;
       
   103 		CCommSession* iPreemptableOwner;
       
   104 		CCommSession* iPreemptedSession;
       
   105 		CCommSession* iWaitAvailableOwner;  // Also the SetAccess owner.
       
   106 		RMessagePtr2   iBlockedSetAccess; 
       
   107 		};
       
   108 
       
   109 friend class CPortManager;
       
   110 
       
   111 public:
       
   112 	typedef TCommAccess TAccess;
       
   113 
       
   114 	void CommRead(const RMessage2& aMessage,CCommSession* aClient); // Start read operation
       
   115 	void CommReadCancel(TInt aHandle, CCommSession* aClient);
       
   116 	void CommWrite(const RMessage2& aMessage,CCommSession* aClient); // Start Write opneration
       
   117 	void CommWriteCancel(TInt aHandle, CCommSession* aClient);
       
   118 	void CommBreak(const RMessage2& aMessage,CCommSession* aClient);	// Start Break operation
       
   119 	void CommBreakCancel(TInt aHandle, CCommSession* aClient);
       
   120 	void CommCancel(TInt aHandle, CCommSession* aClient); // Cancel all blocked operation.
       
   121 
       
   122 	void CommConfig(const RMessage2& aMessage, CCommSession& aSession) const;
       
   123 	void CommSetConfig(const RMessage2& aMessage, CCommSession& aSession);
       
   124 	void CommSetServerConfig(const RMessage2& aMessage, CCommSession& aSession);
       
   125 	void CommGetServerConfig(const RMessage2& aMessage, CCommSession& aSession);
       
   126 	void CommCaps(const RMessage2& aMessage, CCommSession& aSession);
       
   127 	void CommSignals(const RMessage2& aMessage, CCommSession& aSession);
       
   128 	void CommSetSignalsToMark(const RMessage2& aMessage, CCommSession& aSession);
       
   129 	void CommSetSignalsToSpace(const RMessage2& aMessage, CCommSession& aSession);
       
   130 	void CommReceiveBufferLength(const RMessage2& aMessage, CCommSession& aSession) const;
       
   131 	void CommSetReceiveBufferLength(const RMessage2& aMessage, CCommSession& aSession);
       
   132 	void CommQueryReceiveBuffer(const RMessage2& aMessage, CCommSession& aSession) const;
       
   133 	void CommResetBuffers(const RMessage2& aMessage, CCommSession& aSession);
       
   134 	void CommSetAccess(const RMessage2& aMessage, CCommSession& aSession);
       
   135 	TBool IsBlockedSetAccessWaiting(CCommSession& aClient);
       
   136 	void CommSetAccessCancel(TInt aHandle, CCommSession* aClient);
       
   137 	void CommDebugState(const RMessage2& aMessage, CCommSession& aSession);
       
   138 
       
   139 	TBool TakeOwnershipForReading(const RMessage2& aMessage,CCommSession* aClient);		// Check if a read request is valid and take ownership of port
       
   140 	TBool TakeOwnershipForWriting(const RMessage2& aMessage,CCommSession* aClient);		// Check if a Write request is valid and take ownership of port
       
   141 	TBool TakeOwnershipForBreaking(const RMessage2& aMessage,CCommSession* aClient);		// Check if a Break request is valid and take ownership of port
       
   142 
       
   143 	void InitL(TDesC8 &aName);	// Not used
       
   144 	static TInt WriteTimerExpiredHandler(TAny* aPtr);
       
   145 	static TInt ReadTimerExpiredHandler(TAny* aPtr);
       
   146 	TBool AreAnyPending();
       
   147 
       
   148 	void CommGetRole(const RMessage2& aMessage, CCommSession* aClient);
       
   149 	void CommGetFlowControlStatus(const RMessage2& aMessage, CCommSession* aClient);
       
   150 
       
   151 	void CommNotifySignalChange(const RMessage2& aMessage, CCommSession* aClient);
       
   152 	TBool TakeOwnershipForSignals(const RMessage2& aMessage,CCommSession* aClient);
       
   153 	void CommNotifyFlowControlChange(const RMessage2& aMessage, CCommSession* aClient);
       
   154 	TBool TakeOwnershipForFlowControl(const RMessage2& aMessage,CCommSession* aClient);
       
   155 	void CommNotifyConfigChange(const RMessage2& aMessage, CCommSession* aClient);
       
   156 	TBool TakeOwnershipForConfig(const RMessage2& aMessage,CCommSession* aClient);
       
   157 	void CommNotifyBreak(const RMessage2& aMessage, CCommSession* aClient);
       
   158 	TBool TakeOwnershipForBreak(const RMessage2& aMessage, CCommSession* aClient);
       
   159 	void CommNotifyDataAvailable(const RMessage2& aMessage, CCommSession* aClient);
       
   160 	TBool TakeOwnershipForNotifyDataAvailable(const RMessage2 &aMessage,CCommSession* aClient);
       
   161 	void CommNotifyOutputEmpty(const RMessage2 &aMessage, CCommSession* aClient);
       
   162 	TBool TakeOwnershipForNotifyOutputEmpty(const RMessage2 &aMessage,CCommSession* aClient);
       
   163 
       
   164 	void CommNotifySignalChangeCancel(TInt aHandle, CCommSession* aClient);
       
   165 	void CommNotifyConfigChangeCancel(TInt aHandle, CCommSession* aClient);
       
   166 	void CommNotifyFlowControlChangeCancel(TInt aHandle, CCommSession* aClient);
       
   167 	void CommNotifyBreakCancel(TInt aHandle, CCommSession* aClient);
       
   168 	void CommNotifyDataAvailableCancel(TInt aHandle, CCommSession* aClient);
       
   169 	void CommNotifyOutputEmptyCancel(TInt aHandle, CCommSession* aClient);
       
   170 
       
   171 	TBool SessionHasBeenPreempted(CCommSession* aSession);
       
   172 	TBool SessionIsAwaitingOpen(CCommSession* aSession);
       
   173 	void FreeSession(CCommSession* aSession);
       
   174 
       
   175 public:
       
   176 	IMPORT_C TInt IPCRead(const TAny* aPtr, TDes8& aDes, TInt aOffset=0) const;
       
   177 	IMPORT_C TInt IPCWrite(const TAny* aPtr, const TDesC8& aDes, TInt aOffset=0) const;
       
   178 	IMPORT_C CPort();
       
   179 	IMPORT_C void ReadCompleted(TInt anError);		// Called by a CPort to complete a read.
       
   180 	IMPORT_C void WriteCompleted(TInt anError);		// Called by a CPort to complete a write
       
   181 	IMPORT_C void BreakCompleted(TInt anError);		// Called by a CPort to complete a break
       
   182 	IMPORT_C virtual ~CPort();
       
   183 	IMPORT_C void Close();
       
   184 	IMPORT_C void SignalChangeCompleted(const TUint& aSignals, TInt anError);					// Called by a CPort to complete a signal notify
       
   185 	IMPORT_C void ConfigChangeCompleted(const TDesC8& aNewConfig, TInt anError);				// Called by a CPort to complete a config notify.
       
   186 	IMPORT_C void FlowControlChangeCompleted(const TFlowControl& aFlowControl, TInt anError);	// Called by a CPort to complete a flow control notify
       
   187 	IMPORT_C void BreakNotifyCompleted(TInt anError);			// Called by a CPort to complete a break signal notify
       
   188 	IMPORT_C void NotifyDataAvailableCompleted(TInt anError);	// Called by a CPort to complete a break signal notify
       
   189 	IMPORT_C void NotifyOutputEmptyCompleted(TInt anError);		// Called by a CPort to complete a break signal notify
       
   190 
       
   191 public:
       
   192 	//
       
   193 	// Pure virtual methods - to be implemented by the CSY
       
   194 	//
       
   195 
       
   196 	// Called by manager when access count is 0 - CSY port must call 'delete this'
       
   197 	/** Specifies the protocol for port destruction. It is called by the comms server 
       
   198 	when the last client-side reference to a CPort object has been closed and 
       
   199 	the CPort must be deleted. The comms server will not delete a CPort other 
       
   200 	than by calling Destruct().
       
   201 	
       
   202 	The implementation should perform any asynchronous shutdown operations on 
       
   203 	its own resources and, when these operations have completed, should delete 
       
   204 	this. */
       
   205 	virtual void Destruct()=0;
       
   206 	// Queue a read - called by CPort when client wants to read
       
   207 	// Note: if the value in aLength is negative, this means
       
   208 	//       ReadOneOrMore and the CSY must invert the number
       
   209 	/** Specifies the protocol for reading from the port. It is called by the comms 
       
   210 	server in response to a RComm::Read() or RComm::ReadOneOrMore() request from 
       
   211 	the client.
       
   212 	
       
   213 	A negative value for aLength is used to flag that the read request was from 
       
   214 	RComm::ReadOneOrMore() rather than from RComm::Read(). The maximum length 
       
   215 	of data to be read is the absolute value of aLength.
       
   216 	
       
   217 	The implementation should use IPCWrite() to write the data to the client's 
       
   218 	buffer. When all the data has been read, the function should call ReadCompleted(). 
       
   219 	
       
   220 	
       
   221 	@param aClientBuffer Pointer into client address space to the descriptor containing 
       
   222 	the client's buffer 
       
   223 	@param aLength The amount of data to be read */
       
   224 	virtual void StartRead(const TAny* aClientBuffer, TInt aLength)=0;
       
   225 	// Cancel a pending read
       
   226 	/** Specifies the protocol for cancelling reading from the port. It is called by 
       
   227 	the comms server in response to a RComm::ReadCancel() request from the client or
       
   228 	when the iReadTimer timer expires.
       
   229 	
       
   230 	The implementation should abort any processing which was taking place as a 
       
   231 	result of the read request. Do not call ReadCompleted(). */
       
   232 	virtual void ReadCancel()=0;
       
   233 	// Get the size of the receive buffer from the real serial port
       
   234 	/** Specifies a protocol for requesting the number of bytes that are currently 
       
   235 	waiting in the port's receive buffer. It is called by the comms server in 
       
   236 	response to a RComm::QueryReceiveBuffer() request from the client.
       
   237 	
       
   238 	@param aLength On return, the number of bytes currently waiting to be read 
       
   239 	from the receive buffer. 
       
   240 	@return A system wide error code. */
       
   241 	virtual TInt QueryReceiveBuffer(TInt& aLength) const=0;
       
   242 	// reset Tx and Rx buffers
       
   243 	/** Specifies a protocol for resetting the receive and/or transmit buffers to zero 
       
   244 	length. It is called by the comms server in response to a RComm::ResetBuffers() 
       
   245 	request from the client.
       
   246 	
       
   247 	@param aFlags Bitmask of the following flags: KCommResetRx to reset the receive 
       
   248 	buffer; KCommResetTx to reset the transmit buffer */
       
   249 	virtual void ResetBuffers(TUint aFlags)=0;
       
   250 	// Queue a write - called by CPort when client wants to write
       
   251 	/** Specifies the protocol for writing to the port. It is called by the comms server 
       
   252 	in response to a RComm::Write() request from the client.
       
   253 	
       
   254 	The implementation should use IPCRead() to get the data to write from the 
       
   255 	client's buffer. When all the data has been written, the function should call 
       
   256 	WriteCompleted(). 
       
   257 	
       
   258 	@param aClientBuffer Pointer into client address space to the descriptor containing 
       
   259 	the client's buffer 
       
   260 	@param aLength The amount of data to be written */
       
   261 	virtual void StartWrite(const TAny* aClientBuffer, TInt aLength)=0;
       
   262 	// Cancel a pending write
       
   263 	/** Specifies the protocol for cancelling writing to the port. It is called by 
       
   264 	the comms server in response to a RComm::WriteCancel() request from the client.
       
   265 	
       
   266 	The implementation should abort any processing which was taking place as a 
       
   267 	result of the write request. Do not call WriteCompleted(). */
       
   268 	virtual void WriteCancel()=0;
       
   269 	// Queue a break
       
   270 	/** Specifies the protocol for setting a break condition at the port. It is called 
       
   271 	by the comms server in response to a RComm::Break() request from the client.
       
   272 	
       
   273 	When the break is complete, the function should call BreakCompleted(). 
       
   274 	
       
   275 	@param aTime Time period to break for in microseconds */
       
   276 	virtual void Break(TInt aTime)=0;
       
   277 	// Cancel a pending break
       
   278 	/** Specifies the protocol for cancelling a break request. It is called by the 
       
   279 	comms server in response to a RComm::BreakCancel() request from the client.
       
   280 	
       
   281 	The implementation should abort any processing which was taking place as a 
       
   282 	result of the break request. Do not call BreakCompleted(). */
       
   283 	virtual void BreakCancel()=0;
       
   284 	// Pass a config request - return in descriptor
       
   285 	/** Specifies a protocol for getting the current configuration of the serial port. 
       
   286 	It is called by the comms server in response to a RComm::GetConfig() request 
       
   287 	from the client.
       
   288 	
       
   289 	@param aPackage A packaged TCommConfig buffer, set on return to the current 
       
   290 	configuration of the serial port 
       
   291 	@return A system wide error code */
       
   292 	virtual TInt GetConfig(TDes8& aPackage) const=0;
       
   293 	// Set config with package in the descriptor
       
   294 	/** Specifies a protocol for setting the configuration of the port. It is called 
       
   295 	by the comms server in response to a RComm::SetConfig() request from the client.
       
   296 	
       
   297 	@param aPackage A packaged TCommConfig buffer holding the new configuration 
       
   298 	values 
       
   299 	@return A system error code */
       
   300 	virtual TInt SetConfig(const TDesC8& aPackage)=0;
       
   301 	// Set the port to use partial reads/writes
       
   302 	/** Specifies a protocol for setting the buffer mode. It is called by the comms 
       
   303 	server in response to a RComm::SetMode() request from the client.
       
   304 	
       
   305 	@param aPackage A TCommServerConfig package buffer holding the mode settings 
       
   306 	@return A system-wide error code */
       
   307 	virtual TInt SetServerConfig(const TDesC8& aPackage)=0;
       
   308 	// Get the server configs from the CSY
       
   309 	/** Specifies a protocol for getting the buffer mode. It is called by the comms 
       
   310 	server in response to a RComm::Mode() request from the client.
       
   311 	
       
   312 	@param aPackage A TCommServerConfig package buffer that, on return, holds 
       
   313 	the current buffer mode settings 
       
   314 	@return A system error code */
       
   315 	virtual TInt GetServerConfig(TDes8& aPackage)=0;
       
   316 	// Read capabilities from the driver
       
   317 	/** Specifies a protocol for getting the port capabilities. It is called by the 
       
   318 	comms server in response to a RComm::Caps() request from the client.
       
   319 	
       
   320 	@param aPackage A TCommCaps package buffer that, on return, holds the port 
       
   321 	capabilities 
       
   322 	@return A system error code */
       
   323 	virtual TInt GetCaps(TDes8& aPackage)=0;
       
   324 	// Get the status of the signal pins
       
   325 	/** Specifies a protocol for getting the status of the serial port control lines. 
       
   326 	It is called by the comms server in response to a RComm::GetSignals() request 
       
   327 	from the client.
       
   328 	
       
   329 	@param aSignals An integer with the bits set to reflect the status of the 
       
   330 	handshaking lines. 
       
   331 	@return A system error code */
       
   332 	virtual TInt GetSignals(TUint& aSignals)=0;
       
   333 	// Set selected signals to high (logical 1)
       
   334 	/** Specifies a protocol for setting serial port control lines. It is called by 
       
   335 	the comms server in response to a RComm::SetSignals() request from the client.
       
   336 	
       
   337 	@param aSignals A bitmask of the handshaking lines to set 
       
   338 	@return A system error code */
       
   339 	virtual TInt SetSignalsToMark(TUint aSignals)=0;
       
   340 	// Set selected signals to low (logical 0)
       
   341 	/** Specifies a protocol for clearing serial port control lines. It is called by 
       
   342 	the comms server in response to a RComm::SetSignals() request from the client.
       
   343 	
       
   344 	@param aSignals A bitmask of the handshaking lines to clear 
       
   345 	@return A system error code */
       
   346 	virtual TInt SetSignalsToSpace(TUint aSignals)=0;
       
   347 	// Get size of Tx and Rx buffer
       
   348 	/** Specifies a protocol for requesting the size of the serial port buffers. It 
       
   349 	is called by the comms server in response to a RComm::ReceiveBufferLength() 
       
   350 	request from the client.
       
   351 	
       
   352 	@param aLength The current size of the serial port buffers in bytes 
       
   353 	@return A system error code */
       
   354 	virtual TInt GetReceiveBufferLength(TInt& aLength) const=0;
       
   355 	// Set size of Tx and Rx buffer
       
   356 	/** Specifies a protocol for setting the size of the serial port buffers. It is 
       
   357 	called by the comms server in response to a RComm::SetReceiveBufferLength() 
       
   358 	request from the client.
       
   359 	
       
   360 	@param aLength Requested size of the serial port buffers in bytes 
       
   361 	@return A system error code */
       
   362 	virtual TInt SetReceiveBufferLength(TInt aLength)=0;
       
   363 	virtual void FreeMemory();	// csys have their own implementation, e.g. ECUART
       
   364 	// Notify client when the signals change
       
   365 	/** Specifies the protocol for setting a "signal change" notification. It is called 
       
   366 	by the comms server in response to a RComm::NotifySignalChange() request from 
       
   367 	the client.
       
   368 	
       
   369 	@param aSignalMask Signal mask passed by client */
       
   370 	virtual void NotifySignalChange(TUint aSignalMask)=0;
       
   371 	// Cancel an outstanding signal change notification
       
   372 	/** Specifies the protocol for cancelling a "signal change" notification. It is called 
       
   373 	by the comms server in response to a RComm::NotifySignalChangeCancel() request 
       
   374 	from the client. */
       
   375 	virtual void NotifySignalChangeCancel()=0;
       
   376 	// Notify client when the configation changes
       
   377 	/** Specifies the protocol for setting a "configuration change" notification. It 
       
   378 	is called by the comms server in response to a RComm::NotifyConfigChange() 
       
   379 	request from the client. */
       
   380 	virtual void NotifyConfigChange()=0;
       
   381 	// Cancel an outstanding config change notification
       
   382 	/** Specifies the protocol for cancelling a "configuration change" notification. 
       
   383 	It is called by the comms server in response to a RComm::NotifyConfigChangeCancel() 
       
   384 	request from the client. */
       
   385 	virtual void NotifyConfigChangeCancel()=0;
       
   386 	// Notify client when the flow control changes
       
   387 	/** Specifies the protocol for setting a "flow control change" notification. It is 
       
   388 	called by the comms server in response to a RComm::NotifyFlowControlChange() 
       
   389 	request from the client. */
       
   390 	virtual void NotifyFlowControlChange()=0;
       
   391 	// Cancel an outstanding flow control change notification
       
   392 	/** Specifies the protocol for cancelling a "flow control change" notification. It 
       
   393 	is called by the comms server in response to a RComm::NotifyFlowControlChangeCancel() 
       
   394 	request from the client. */
       
   395 	virtual void NotifyFlowControlChangeCancel()=0;
       
   396 	// Notify client when a break occurs
       
   397 	/** Specifies the protocol for setting a "break" notification. It is called by the 
       
   398 	comms server in response to a RComm::NotifyBreak() request from the client. */
       
   399 	virtual void NotifyBreak()=0;
       
   400 	// Cancel an outstanding break notification
       
   401 	/** Specifies the protocol for cancelling a "break" notification. It is called by 
       
   402 	the comms server in response to a RComm::NotifyBreakCancel() request from 
       
   403 	the client. */
       
   404 	virtual void NotifyBreakCancel()=0;
       
   405 	// Notify client when data is available
       
   406 	/** Specifies the protocol for setting a "data available" notification. It is called 
       
   407 	
       
   408 	by the comms server in response to a RComm::NotifyDataAvailable() request 
       
   409 	from the client. */
       
   410 	virtual void NotifyDataAvailable()=0;
       
   411 	// Cancel an outstanding data available notification
       
   412 	/** Specifies the protocol for cancelling a "data available" notification. It is 
       
   413 	called by the comms server in response to a RComm::NotifyDataAvailableCancel() 
       
   414 	request from the client. */
       
   415 	virtual void NotifyDataAvailableCancel()=0;
       
   416 	// Notify client when output buffer is empty
       
   417 	/** Specifies the protocol for setting a transmit buffer empty notification. It 
       
   418 	is called by the comms server in response to a RComm::NotifyOutputEmpty() 
       
   419 	request from the client. */
       
   420 	virtual void NotifyOutputEmpty()=0;
       
   421 	// Cancel an outstanding output empty notification
       
   422 	/** Specifies the protocol for cancelling a transmit buffer empty notification. 
       
   423 	It is called by the comms server in response to a RComm::NotifyOutputEmptyCancel() 
       
   424 	request from the client. */
       
   425 	virtual void NotifyOutputEmptyCancel()=0;
       
   426 	// Get the flow control status
       
   427 	/** Gets flow control status. It is called by the comms server in response to a 
       
   428 	RComm::SetMode() request from the client.
       
   429 	
       
   430 	@param aFlowControl Flow control status to return to the client 
       
   431 	@return A system-wide error code */
       
   432 	virtual TInt GetFlowControlStatus(TFlowControl& aFlowControl)=0;
       
   433 	// Get the role of this port unit
       
   434 	/** Gets DCE/DTE role. It is called by the comms server in response to a RComm::GetRole() 
       
   435 	request from the client.
       
   436 	
       
   437 	@param aRole On return, DCE/DTE role to return to the client 
       
   438 	@return A system-wide error code */
       
   439 	virtual TInt GetRole(TCommRole& aRole)=0;
       
   440 	// Set the role of this port unit
       
   441 	/** Sets DCE/DTE role. It is called by the comms server in response to a RComm::Open() 
       
   442 	request from the client.
       
   443 	
       
   444 	@param aRole DCE/DTE role 
       
   445 	@return A system-wide error code */
       
   446 	virtual TInt SetRole(TCommRole aRole)=0;
       
   447 
       
   448 // Accessors
       
   449 #ifdef _DEBUG_DEVCOMM
       
   450 	virtual void DoDumpDebugInfo(const RMessage2 &aMessage)=0;
       
   451 #endif
       
   452 private:
       
   453 	void DoOpenL(CCommSession* aSession, TInternalCommAccess aMode, TCommRole aRole,TBool aIsNew);
       
   454 	void DoPreemption();
       
   455 
       
   456 	TDeltaTimerEntry iReadTimer;  //< delta timer entry for read timeouts
       
   457 	TBool iReadTimerPending;      //< true if a read timer is pending
       
   458 	TDeltaTimerEntry iWriteTimer; //< delta timer entry for write timeouts
       
   459 	TBool iWriteTimerPending;     //< true if a write timer is pending
       
   460 	TInternalCommAccess iMode;    //< access mode for this port
       
   461 	CCommSession* iReadOwner;     //< pointer to the read session
       
   462 	TInt iReadOwnerHandle;        //< handle to the read session
       
   463 	CCommSession* iWriteOwner;    //< pointer to the write session
       
   464 	TInt iWriteOwnerHandle;       //< handle to the write session
       
   465 	// Binary compatible
       
   466 	// Was: CCommSession* iBreakOwner;  Replace with:
       
   467 	CExtra* iExtra;               //< pointer to the CExtra object for pre-emptable handling
       
   468 #define iBreakOwner (iExtra->iBreakOwner) //< forwards iBreakOwner to iExtra->iBreakOwner
       
   469 
       
   470 	TInt iBreakOwnerHandle;                  //< handle to the break owner
       
   471 	CCommSession* iSignalOwner;              //< pointer to the signal session
       
   472 	TInt iSignalOwnerHandle;                 //< handle to the signal session
       
   473 	CCommSession* iFlowControlOwner;         //< pointer to the flow control session
       
   474 	TInt iFlowControlOwnerHandle;            //< handle to the flow control session
       
   475 	CCommSession* iConfigOwner;              //< pointer to the config session
       
   476 	TInt iConfigOwnerHandle;                 //< handle to the config session
       
   477 	CCommSession* iBreakNotifyOwner;         //< pointer to the break notify session
       
   478 	TInt iBreakNotifyOwnerHandle;            //< handle to the break notify session
       
   479 	CCommSession* iNotifyDataAvailableOwner; //< pointer to the data available session
       
   480 	TInt iNotifyDataAvailableOwnerHandle;    //< handle to the data available session
       
   481 	CCommSession* iNotifyOutputEmptyOwner;   //< pointer to the output empty session
       
   482 	TInt iNotifyOutputEmptyOwnerHandle;      //< handle to the output empty session
       
   483 
       
   484 	RMessagePtr2 iBlockedRead;                //< pointer to the read request message
       
   485 	RMessagePtr2 iBlockedWrite;               //< pointer to the write request message
       
   486 	RMessagePtr2 iBlockedBreak;               //< pointer to the break request message
       
   487 
       
   488 	/**The encapsulated message*/
       
   489 	RMessagePtr2 iBlockedSignalChange;			//< holds the notify signal change message
       
   490 	/**Private padding to preserve BC with earlier versions*/
       
   491 	TInt iBlockedSignalChangeDummyPadding[7];
       
   492 
       
   493 	/**The encapsulated message*/
       
   494 	RMessagePtr2 iBlockedConfigChange;			//< holds the notify config change message
       
   495 	/**Private padding to preserve BC with earlier versions*/
       
   496 	TInt iBlockedConfigChangeDummyPadding[7];
       
   497 
       
   498 	/**The encapsulated message*/
       
   499 	RMessagePtr2 iBlockedFlowControlChange;		//< holds the notify flow control change message
       
   500 	/**Private padding to preserve BC with earlier versions*/
       
   501 	TInt iBlockedFlowControlChangeDummyPadding[7];
       
   502 
       
   503 	RMessagePtr2 iBlockedBreakNotify;         //< pointer to the notify break request message
       
   504 	RMessagePtr2 iBlockedNotifyDataAvailable; //< pointer to the notify data available request message
       
   505 	RMessagePtr2 iBlockedNotifyOutputEmpty;   //< pointer to the notify output empty request message
       
   506 
       
   507 	CPortManager* iPortManager;              //< Not Used. Not to be exposed to deriving classes of CPort.
       
   508 	IMPORT_C virtual void CPort_Reserved1();
       
   509 	TAny* iCPort_Reserved;                   //< reserved pointer
       
   510 	};
       
   511 
       
   512 
       
   513 //
       
   514 // forward declaration
       
   515 //
       
   516 class CLibUnloader;
       
   517 
       
   518 
       
   519 class CSerial : public CObject
       
   520 /** 
       
   521 Factory for a single CPort object.
       
   522 
       
   523 CSerial is the base class for implementations of serial port factories. It is intended to be
       
   524 overridden by the CSY so that C32 can call in and ask the CSY to create serial ports. In this way
       
   525 the factory is responsible for creating instances of CPort-derived classes 
       
   526 for the protocol of the CSY. It also provides query functions, which return general information 
       
   527 about the capabilities of the serial protocol implemented by the CSY.
       
   528 
       
   529 Owned by the CPort object it creates.
       
   530 
       
   531 Writing derived classes:
       
   532 
       
   533 The pure virtual NewPortL() and Info() functions must be implemented in derived 
       
   534 classes. Serial protocol modules which can take differing action based on 
       
   535 the version of the comms server should also override QueryVersionSupported(). 
       
   536 
       
   537 @publishedAll
       
   538 @released
       
   539 */
       
   540 	{
       
   541 public:
       
   542 	IMPORT_C CSerial();
       
   543 	IMPORT_C ~CSerial();
       
   544 	IMPORT_C virtual TBool QueryVersionSupported(const TVersion& aVersion) const;
       
   545 	void ConstructL(RLibrary& aLib);
       
   546 public:
       
   547 	//
       
   548 	// pure virtuals to be implemented by the CSY
       
   549 	//
       
   550 
       
   551 	// Create a new port for the supplied unit number
       
   552 	/** Specifies the protocol for creating a new serial port for the protocol. The 
       
   553 	comms server calls this function in response to a RComm:Open() call.
       
   554 	
       
   555 	Typically, the implementation would call NewL() on the protocol's CPort-based 
       
   556 	class. Any resources required by the new port object should be done at this 
       
   557 	stage. If the serial port object cannot be created for any reason, NewPortL() 
       
   558 	should leave with an appropriate error code.
       
   559 	
       
   560 	The interpretation of unit numbers is specific to the particular serial protocol 
       
   561 	module. However, unit numbers on Symbian OS should be zero-based. For the 
       
   562 	default built-in serial ports implemented by the serial protocol module ecuart.csy, 
       
   563 	the unit numbers refer to the hardware ports, with 0 being the first port 
       
   564 	on the machine. If a second request is made to create a port with a unit number 
       
   565 	that has already been created and not destroyed, NewPortL() should leave with 
       
   566 	KErrAlreadyExists.
       
   567 	
       
   568 	@param aUnit The unit number to be created. */
       
   569 	virtual CPort* NewPortL(const TUint aUnit)=0;
       
   570 	// Get info about this CSY, fill in the supplied structure.
       
   571 	/** Specifies the protocol for getting the information about the serial protocol.
       
   572 	
       
   573 	Implementations should fill in the TSerialInfo structure to reflect the protocol's 
       
   574 	capabilities.
       
   575 	
       
   576 	@param aSerialInfo On return, set to indicate the capabilities of the serial 
       
   577 	protocol. */
       
   578 	virtual void Info(TSerialInfo &aSerialInfo)=0;
       
   579 
       
   580 	void ModuleName(TDes& aName);
       
   581 
       
   582 	IMPORT_C virtual TSecurityPolicy PortPlatSecCapability(TUint aPort) const;
       
   583 
       
   584 protected:
       
   585 	/** Module version number. The class should initialise this member with its version 
       
   586 	number from its constructor. */
       
   587 	TVersion iVersion;                         //< holds the version of the CSY
       
   588 private:
       
   589 	CLibUnloader* iLibUnloader;                //< pointer to the library unloader
       
   590 	IMPORT_C virtual void CSerial_Reserved1();
       
   591 	TAny* iCSerial_Reserved;                   //< reserved pointer for future BC
       
   592 	};
       
   593 
       
   594 /** This typedef defines the form of the ordinal-1 entry point function to a serial 
       
   595 protocol module. The function should create and return a concrete CSerial-derived 
       
   596 class, which will then be used by the comms server.
       
   597 
       
   598 Each serial protocol module should only ever create a single serial protocol 
       
   599 factory object. If the entry point is called twice without the first factory 
       
   600 object being destroyed, this function should leave with KErrGeneral. */
       
   601 typedef CSerial *(*TSerialNewL)(); //< function type of CSY module entry point
       
   602 
       
   603 #endif // CS_PORT_H