os/kernelhwsrv/kerneltest/e32test/examples/exdriver/exdriver_chnk/inc/exchnk.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-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 "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 // This file defines the interface provided by the driver to the user. 
    15 // It will be included both in the application (user) and the driver (kernel). 
    16 // This file typically defines the RBusLogicalChannel derived class that will 
    17 // inturn provide the driver API to the user application.
    18 // ifndef __EXCHNK_H__ will resolve the multiple inclusion of this header 
    19 // file in different source files. If the file is already included, then the 
    20 // following switch will not re-include the file.
    21 // 
    22 //
    23 
    24 #ifndef __EXCHNK_H__
    25 #define __EXCHNK_H__
    26 
    27 // include files
    28 // 
    29 // e32ver.h (for KE32BuildVersionNumber), e32cmn.h and e32std.h are already
    30 // included in d32comm.h and hence not repeating here.
    31 //
    32 #include <d32comm.h>
    33 
    34 // Literal string descriptor constants for driver name. These descriptors 
    35 // are used by the driver to associate a name for registering to the 
    36 // Symbian OS. LDD will have a name to associate with.
    37 //
    38 
    39 _LIT(KDriverName, "d_exchnk");
    40 
    41 // Internal loopback modes
    42 const TInt KIntLoopbackDisable=0;
    43 const TInt KIntLoopbackEnable=1;
    44 
    45 /**
    46  User interface for tutorial driver
    47  
    48  RExDriverChannel class is derived from the RBusLogicalChannel and provides 
    49  the interface for user. User application accesses the driver functionality
    50  using only these API.
    51  */
    52 class RExDriverChannel:public RBusLogicalChannel
    53 	{
    54 public:
    55 	// TVer is an enumeration for the version related information. Driver will 
    56 	// need to set and validate version related information while installing.
    57 	// Version numbers are validated to check if this version of driver as 
    58 	// expected by the client/user application
    59 	//
    60 	enum TVer
    61 		{
    62 		EUartMajorVersionNumber=1,						// Major number for driver
    63 		EUartMinorVersionNumber=0,						// Minor number for device
    64 		EUartBuildVersionNumber=KE32BuildVersionNumber	// Build version number for driver
    65 		};
    66 	// TControl is the enumeration for control and synchronous messages 
    67 	// supported by the driver. User application can request for any of
    68 	// the following control messages to the driver through DoControl() 
    69 	// API provided by the RBusLogicalChannel class.
    70 	//
    71 	enum TControl							// Synchronous control messages used with DoControl()					
    72 		{
    73 		EControlCaps,						// Get the channel capabilities on uart
    74 		EControlSetConfig,					// Configure the device (uart)
    75 		EControlSetIntLoopback,				// Configure the device's internal looback mode
    76 		EGetTxChunkHandle,					// Get handle to transmit chunk
    77 		EGetRxChunkHandle,					// Get handle to Receive chunk
    78 		EPassTxChunkHandle,					// Pass handle to transmit chunk from user side.
    79 		EPassRxChunkHandle					// Pass handle to Receive chunk from user side.
    80 		};
    81 	// TRequest is the enumeration for asynchronous requests supported
    82 	// by the driver. User application can request for any of the 
    83 	// following messages to the driver through DoRequest() API provided
    84 	// by the RBusLogicalChannel class.
    85 	//
    86 	enum TRequest							// Asynchronous request messages used with DoRequest()	
    87 		{
    88 		ERequestTransmitData,				// Transmit data over the device (uart)	
    89 		ERequestReceiveData,				// Receive the data from the device (uart)
    90 		ENumRequests,						// Total number of supported asynchrnous requests
    91 		EAllRequests = (1<<ENumRequests)-1
    92 		};		
    93 public:
    94 	// VersionRequired() will provide the version of the driver. This is made inline
    95 	// function to initialize the TVersion object with driver's Major,Minor and Build
    96 	// version numbers. This is later used to validate the driver version.
    97 	//
    98 #ifndef __KERNEL_MODE__	
    99 	inline static TVersion VersionRequired();		
   100 	
   101 	// These functions are wrappers to the RBusLogicalChannel API and are inline.
   102 	//
   103 	inline TInt Open(TInt aUnit);					// Open the channel to the driver
   104 	inline TInt Caps(TDes8& aCaps);					// Get the channel capabilities
   105 	inline TInt SetIntLoopback(const TInt aMode);	// Configure the device's internal loopback
   106 	inline TInt SetConfig(const TDesC8& aConfig);	// Configure device (UART)	
   107 	inline TInt TransmitData(TRequestStatus& aStatus,TInt aSize,TInt aOffset=0);		// Send data on device (UART)	
   108 	inline TInt ReceiveData(TRequestStatus& aStatus,TInt aSize,TInt aOffset=0);		// Receive data on device (UART)		
   109 	inline void CancelTransmit();			// Cancel pending asynchronous Tx requests
   110 	inline void CancelReceive();			// Cancel pending asynchronous Rx requests
   111 	inline TInt GetTxChunkHandle(RChunk& aChunk);
   112 	inline TInt GetRxChunkHandle(RChunk& aChunk);
   113 	inline TInt PassTxChunkHandle(RChunk& aChunk);
   114 	inline TInt PassRxChunkHandle(RChunk& aChunk);
   115 #endif	
   116 	};
   117 
   118 // All inline functions implementation is provided in a seperate inline file. This file
   119 // is included here to add the inline implementations. Note:these inline functions 
   120 // implementaion is also available only in user space.
   121 // 
   122 
   123 
   124 
   125 #include "exchnk.inl"
   126 
   127 
   128 
   129 #endif  // __EXCHNK_H__
   130 
   131 //
   132 // End of exchnk.h