systemswstubs/examplecommonisc/IscDriver/inc/IscChannel.h
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DISCCHANNEL_H
       
    20 #define DISCCHANNEL_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <kernel.h>
       
    24 #include <IscMultiplexerBase.h> // TIscFrameInfo
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KMajorVersionNumber = 1;
       
    28 const TInt KMinorVersionNumber = 0;
       
    29 const TInt KBuildVersionNumber = 1;
       
    30 
       
    31 const TUint8 KBehaviormask = 15; //bits 00001111
       
    32 
       
    33 // MACROS
       
    34 
       
    35 const TInt KIscEmptyMyBuffersDfcPriority( 4 );
       
    36 // DATA TYPES
       
    37 
       
    38 // FUNCTION PROTOTYPES
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 
       
    42 // CLASS DECLARATION
       
    43 class DIscDevice;
       
    44 class DIscQueue;
       
    45 class IscChannelContainer;
       
    46 
       
    47 /**
       
    48 *  Handles all interraction with the user-side
       
    49 *
       
    50 *  @lib IscDriver.LIB
       
    51 *  @since 2.8
       
    52 */
       
    53 class DIscChannel : public DLogicalChannel
       
    54     {
       
    55 
       
    56     public:  // Constructors and destructor
       
    57        
       
    58         /**
       
    59         * C++ default constructor.
       
    60         * @param pointer to owner device
       
    61         */
       
    62         IMPORT_C DIscChannel( DLogicalDevice* aDevice );
       
    63        
       
    64         /**
       
    65         * Destructor.
       
    66         */
       
    67         ~DIscChannel();
       
    68 
       
    69     public: // Functions from base classes
       
    70         
       
    71         /**
       
    72         * Secondary initialization of channel.
       
    73         * @since 2.8
       
    74         * @param  TInt aUnit Channel number
       
    75         * @param const TDesC8* anInfo pointer to a descriptor containing extra 
       
    76         *                             information for the device. 
       
    77         * @param const TVersion& aVer reference containing the version being 
       
    78         *                             requested by the thread which is opening this channel 
       
    79         * @return virtual TInt KErrNone if succesful. KErrAlreadyExist if channel already open
       
    80         */
       
    81         virtual TInt DoCreate( TInt aUnit, const TDesC8* anInfo, const TVersion& aVer );
       
    82 
       
    83         /**
       
    84         * Message handling ( kernel server context ).
       
    85         * @since 2.8
       
    86         * @param aMsg Thread message to get parameters from user side
       
    87         * @return void 
       
    88         */
       
    89         virtual void HandleMsg( TMessageBase* aMsg );
       
    90 
       
    91         /**
       
    92         * Message handling ( user thread context ).
       
    93         * @since 2.8
       
    94         * @param aReqNo request number called from IscApi
       
    95         * @param a1 pointer array to get parameters from user side
       
    96         * @param a2 not used in ISC
       
    97         * @return TInt KErrNone if succesful
       
    98         */
       
    99         TInt Request( TInt aReqNo, TAny* a1, TAny* a2 );
       
   100 
       
   101     public: // New functions
       
   102         /**
       
   103         * Function to complete clients pending asynchronous request
       
   104         * @since 2.8
       
   105         * @param  TInt aOperation asynchronous operation to complete
       
   106         * @param TInt aCompleteStatus status of request to be completed
       
   107         * @return void 
       
   108         */
       
   109         void CompleteRequest( TInt aOperation, TInt aCompleteStatus );
       
   110 
       
   111         /**
       
   112         * Stores the incoming frame to channels receive queue
       
   113         * @since 2.8
       
   114         * @param TDesC8* aData pointer to storable frame
       
   115         * @return void 
       
   116         */
       
   117         void StoreFrame( TDesC8* aData );
       
   118 
       
   119         /**
       
   120         * Goes through channel's queue and delivers possible frame to client
       
   121         * @since 2.8
       
   122         * @return void 
       
   123         */
       
   124         void EmptyBuffers();
       
   125         
       
   126         /**
       
   127         * Notify user side client that uplink flow control is on/off
       
   128         * @since 2.8
       
   129         * @param const TInt aFlowControlStatus EIscFlowControlOn / EIscFlowControlOff
       
   130         * @return void 
       
   131         */
       
   132         void NotifyFlowControl( const TInt aFlowControlStatus );
       
   133 
       
   134         /**
       
   135         * Notify user side client that status of connection between Symbian side and the Domestic OS has changed
       
   136         * @since 2.8
       
   137         * @param const TInt aConnectionStatus  EIscConnectionOk / EIscConnectionNotOk
       
   138         * @return void 
       
   139         */
       
   140         void NotifyConnectionStatus( const TInt aConnectionStatus );
       
   141     
       
   142         /**
       
   143         * Check if asynchronous request is active
       
   144         * @since 2.8
       
   145         * @param const TUint16 aReqNumber Number of request
       
   146         * @return TInt KRequestPending if request active. Otherwise KErrNone
       
   147         */
       
   148         TInt IsPending( const TUint16 aReqNumber );
       
   149 
       
   150         /**
       
   151         * Copy data from user buffer to kernel side buffer by multiplexer
       
   152         * @since 2.8
       
   153         * @param aUserBuffer pointer to source descriptor
       
   154         * @param aKernelBuffer pointer to destination descriptor
       
   155         * @param aOffset Offset of the source buffer
       
   156         * @return KErrNone if successful
       
   157         */
       
   158         TInt CopyFromUserBuffer( const TDesC8& aUserBuffer,
       
   159                                  TDes8& aKernelBuffer,
       
   160                                  TInt aOffset );
       
   161 
       
   162         /**
       
   163         * Writes data/frames to clients buffer
       
   164         * @since 2.8
       
   165         * @param aDest pointer to destination descriptor
       
   166         * @param aSrc pointer to source descriptor
       
   167         * @param aOffset Offset on where to start writing to target descriptor
       
   168         * @return TInt 
       
   169         */
       
   170         TInt ThreadWrite( TAny* aDest, const TDesC8* aSrc, TInt aOffset );
       
   171 
       
   172         /**
       
   173         * Delete send frames / receive queue for channel in question
       
   174         * @since 2.8
       
   175         * @return void 
       
   176         */
       
   177         void ResetBuffers();
       
   178 
       
   179         /**
       
   180         * Returns the channel number.
       
   181         * @since 3.0
       
   182         * @return TUint16, the number of the channel.
       
   183         */
       
   184         inline TUint16 GetChannelNumber(){return iChannelNumber;};
       
   185 
       
   186         /**
       
   187         * Returns a reference to user side thread of this channel.
       
   188         * @since 3.0
       
   189         * @param None
       
   190         * @return DThread*, user side thread ownership is not given.
       
   191         */
       
   192         inline DThread* GetDThread()
       
   193         	{
       
   194         	return iThread;	
       
   195         	};
       
   196 
       
   197     protected: 
       
   198       
       
   199 		// None
       
   200 
       
   201     private:
       
   202 
       
   203         /**
       
   204         * Call from user side comes to this function
       
   205         * @since 2.8
       
   206         * @param  TInt aFunction request number
       
   207         * @param TAny* a1 pointer to array including info about request
       
   208         * @param TAny* a2 not used
       
   209         * @return TInt KErrNone if succesful
       
   210         */
       
   211         TInt HandleRequest( TInt aFunction, TAny* a1, TAny* a2 );
       
   212         
       
   213         /**
       
   214         * Handles channel destruction.
       
   215         * @since 2.8
       
   216         * @param void
       
   217         * @return void 
       
   218         */        
       
   219         void ChannelDestruction();
       
   220         
       
   221         /**
       
   222         * Handles asynchronous client requests
       
   223         * @since 2.8
       
   224         * @param  TInt aFunction request number
       
   225         * @param TAny* a1 pointer to array including info about request
       
   226         * @return void 
       
   227         */
       
   228         void HandleAsyncRequest( TInt aFunction, TAny* a1 );
       
   229 
       
   230         /**
       
   231         * Handles synchronous client requests
       
   232         * @since 2.8
       
   233         * @param  TInt aFunction
       
   234         * @param TAny* a1 pointer to array including info about request
       
   235         * @return TInt 
       
   236         */
       
   237         TInt HandleSyncRequest( TInt aFunction, TAny* a1 );
       
   238 
       
   239         /**
       
   240         * Cancels active request
       
   241         * @since 2.8
       
   242         * @param  TInt aFunction request number
       
   243         * @param TAny* a1 not used
       
   244         * @return TInt 
       
   245         */
       
   246         TInt HandleCancelRequest( TInt aFunction, TAny* a1 );
       
   247         
       
   248         /**
       
   249         * Copies several data frames to clients buffer if needed before compliting receive request
       
   250         * @since 2.8
       
   251         * @param  TDes8* aPtr pointer to frame
       
   252         * @param TIscFrameInfo& aInfo info needed in frame combining
       
   253         * @return void 
       
   254         */
       
   255         void HandleConcatenatedDataFrame( TDes8* aPtr, TIscFrameInfo& aInfo );
       
   256 
       
   257         /**
       
   258         * Copies several frames to clients buffer if needed before compliting receive request
       
   259         * @since 2.8
       
   260         * @param  TDes8* aPtr pointer to frame
       
   261         * @param TIscFrameInfo& aInfo info needed in frame combining
       
   262         * @return void 
       
   263         */
       
   264         void HandleConcatenatedFrame( TDes8* aPtr, TIscFrameInfo& aInfo );
       
   265 
       
   266         /**
       
   267         * Initialization complete dfc
       
   268         * @since 2.8
       
   269         * @param TAny* aPtr pointer to channel
       
   270         * @return static void.
       
   271         */
       
   272         static void InitializeComplete( TAny* aPtr );
       
   273         
       
   274         /**
       
   275         * Completes the multiplexer initialization
       
   276         * @since 2.8
       
   277         * @return void 
       
   278         */
       
   279         void DoMultiplexerInitialize();
       
   280 
       
   281     private:    // Data
       
   282 
       
   283         TDfc*       iInitializeDfc;
       
   284         TPtr8*      iDataTransmissionIniData;
       
   285         TPtr8*      iMultiplexerIniData;
       
   286         TUint8*     iMultiplexerBuffer;
       
   287         TUint8*     iDataTransmissionBuffer;
       
   288         DIscDevice* iIscDevice;
       
   289         TPtr8*      iIscConnectionStatusPtr;
       
   290         TPtr8*      iIscFlowControlStatusPtr;
       
   291         //Store of Isc requests
       
   292         TRequestStatus* iIscRequests[ EIscAsyncLast ];
       
   293         // Pointers to client message buffers
       
   294         TPtr8*      iReceiveBufPtr;
       
   295         TPtr8*      iDataReceiveBufPtr;
       
   296         TPtr8*      iNeededBufLen;
       
   297         TPtr8*      iNeededDataBufLen;
       
   298         TUint16     iChannelNumber;
       
   299         TBool       iChannelOpen;
       
   300         // Queue for incoming frames
       
   301         TUint32**   iFrameRx;
       
   302         DIscQueue*  iFrameRxQueue;
       
   303 
       
   304         // Queue for incoming data frames
       
   305         TUint32**   iDataFrameRx;
       
   306         DIscQueue*  iDataFrameRxQueue;
       
   307           
       
   308         TInt        iULFlowControlStatus;
       
   309         TInt        iDLFlowControlStatus;
       
   310         // Stores the last notified uplink flowcontrol status.
       
   311         TInt        iLastNotifiedULFlowstatus;
       
   312 
       
   313         TUint16     iIscChannelHighWaterMark;
       
   314         TUint16     iIscChannelLowWaterMark;
       
   315         TBool       iOverFlow;
       
   316         TBool       iClientPanic;
       
   317         TInt        iDataTransmissionErrorCode;
       
   318 
       
   319         DThread*    iThread;
       
   320 
       
   321     };
       
   322 
       
   323 #endif      // DISCCHANNEL_H   
       
   324             
       
   325 // End of File