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