systemswstubs/examplecommonisc/IscDriver/inc/IscDevice.h
changeset 43 e71858845f73
parent 40 b7e5ed8c1342
child 46 e1758cbb96ac
equal deleted inserted replaced
40:b7e5ed8c1342 43:e71858845f73
     1 /*
       
     2 * Copyright (c) 2007 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 ISCDEVICE_H
       
    20 #define ISCDEVICE_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <kernel.h>
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // MACROS
       
    28 
       
    29 // DATA TYPES
       
    30 
       
    31 // FUNCTION PROTOTYPES
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class DIscDataTransmissionBase;
       
    35 class DIscMultiplexerBase;
       
    36 class DIscChannel;
       
    37 class DIscMainRcvBuffer;
       
    38 class DIscQueue;
       
    39 class DIscSendQueue;
       
    40 class TIscSendFrameInfo;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 /**
       
    45 *  Isc driver ldd factory object
       
    46 *
       
    47 *  @lib IscDriver.LIB
       
    48 *  @since 2.8
       
    49 */
       
    50 class DIscDevice : public DLogicalDevice
       
    51     {
       
    52     public:  // Constructors and destructor
       
    53          /**
       
    54         * C++ default constructor.
       
    55         */
       
    56         IMPORT_C DIscDevice();
       
    57        
       
    58         /**
       
    59         * Destructor.
       
    60         */
       
    61         IMPORT_C virtual ~DIscDevice();
       
    62 
       
    63         
       
    64     public: // Functions from base classes
       
    65 
       
    66         /**
       
    67         * From DLogicalDevice. 
       
    68         * Create a logical channel
       
    69         * @since 2.8
       
    70         * @param DLogicalChannelBase*& aChannel logical channel to be set
       
    71         * @return TInt KErrNone if succesful, otherwise KErrNoMemory
       
    72         */
       
    73         virtual TInt Create( DLogicalChannelBase*& aChannel );
       
    74 
       
    75         /**
       
    76         * Complete the installation of driver
       
    77         * @since 2.8
       
    78         * @return TInt KErrNone if successful 
       
    79         */
       
    80         virtual TInt Install();
       
    81 
       
    82          /**
       
    83         * From DLogicalDevice.
       
    84         * Get capabilities of this logical device
       
    85         * @since 2.8
       
    86         * @param TDes8& aDes a reference which contains return  
       
    87         * information describing the capabilities of this device.
       
    88         * @return void
       
    89         */
       
    90         IMPORT_C virtual void GetCaps( TDes8& aDes ) const;
       
    91 
       
    92     public: // New functions
       
    93     
       
    94         /**
       
    95         * Complete the initialization of driver
       
    96         * @since 2.8
       
    97         * @return void 
       
    98         */
       
    99         void Initialize();
       
   100        
       
   101         /**
       
   102         * Get message block from buffers allocated in IscDataTransmissionBase.dll
       
   103         * @since 2.8
       
   104         * @param TDes8*& aPtr pointer where message block is set
       
   105         * @param TUint16 aSize size of needed memory block
       
   106         * @return void 
       
   107         */
       
   108         IMPORT_C void ReserveMemoryBlock( TDes8*& aPtr, TUint16 aSize );
       
   109 
       
   110         /**
       
   111         * Release memory block allocated with ReserveMemoryBlock
       
   112         * @since 2.8
       
   113         * @param TDes8* aData
       
   114         * @return void 
       
   115         */
       
   116         IMPORT_C void ReleaseMemoryBlock( TDes8* aData );
       
   117 
       
   118         /**
       
   119         * Connection status change function. Can be called from any context.
       
   120         * @since 2.8
       
   121         * @param const TInt aStatus status of driver
       
   122         * @return void 
       
   123         */
       
   124         EXPORT_C void NotifyConnectionStatus( const TInt aStatus );
       
   125 
       
   126         /**
       
   127         * Frames coming from Domestic OS
       
   128         * @since 2.8
       
   129         * @param TDesC8* aData pointer to data
       
   130         * @return void 
       
   131         */
       
   132         IMPORT_C void Receive( TDesC8* aData ) const;
       
   133 
       
   134         /**
       
   135         * Queue frames that will be sent to Domestic OS
       
   136         * @since 2.8
       
   137         * @param aChannelId number of sender channel
       
   138         * @param const TDesC8* aFrame pointer to send frame
       
   139         * @param aChannelPtr DIscChannel pointer
       
   140         * @param aMultiplexerDfc dfc to run by data transmission driver after frame has delivered
       
   141         * @param aMultiplexerErrorCode status how frame transmission succeeded
       
   142         * @return TInt KErrNone if frame added to send queue succesfully
       
   143         */
       
   144         IMPORT_C TInt QueueFrame( const TUint16 aChannelId, 
       
   145                                   const TDesC8* aFrame,
       
   146                                   const TAny* aChannelPtr,
       
   147                                   TAny* aFrameInfo );
       
   148 
       
   149         /**
       
   150         * Cancels sending of frames to Domestic OS of certain channel and deletes queued frames
       
   151         * @since 2.8
       
   152         * @param aChannelId channel number to which canceling is done
       
   153         * @param aChannelPtr DIscChannel pointer
       
   154         * @return TInt KErrNone when canceling is done
       
   155         */
       
   156         IMPORT_C TInt CancelSending( const TUint16 aChannelId,
       
   157                                      const TAny* aChannelPtr );
       
   158 
       
   159         /**
       
   160         * Adds Dfc to empty queues. Can be called from any context.
       
   161         * @since 2.8
       
   162         * @return void 
       
   163         */
       
   164         IMPORT_C void FlushQueues();
       
   165 
       
   166         /**
       
   167         * Function to complete user side asynchronous request. Uses DIscChannel pointer
       
   168         * @since 2.8
       
   169         * @param aOperation operation to complete
       
   170         * @param aCompleteStatus status of operation
       
   171         * @param aChannelPtr pointer to a DIscChannel
       
   172         * @return void 
       
   173         */
       
   174         IMPORT_C void CompleteRequest( TUint16 aOperation, 
       
   175                                        TInt aCompleteStatus, 
       
   176                                        const TAny* aChannelPtr );
       
   177         
       
   178         /**
       
   179         * Function to notify client about uplink flow control status
       
   180         * @since 2.8
       
   181         * @param  aULFlowStatus EIscFlowControlOn / EIscFlowControlOff
       
   182         * @param aChannelId Channel to be affected by the flow control
       
   183         * @param aChannelPtr pointer to DIscChannel
       
   184         * @return void 
       
   185         */
       
   186         IMPORT_C void ULFlowControl( const TInt aULFlowStatus, 
       
   187                                      const TUint16 aChannelId,
       
   188                                      const TAny* aChannelPtr );
       
   189 
       
   190         /**
       
   191         * Function to check if asycnhronous request is active
       
   192         * @since 2.8
       
   193         * @param  const TUint16 aReqNumber request number
       
   194         * @param const TUint16 aChannelId channel number
       
   195         * @return TInt KRequestPending if request active, otherwise KErrNone
       
   196         */
       
   197         IMPORT_C TInt IsPending( const TUint16 aReqNumber, 
       
   198                                  const TAny* aChannelPtr );
       
   199 
       
   200         /**
       
   201         * Copy data from user buffer to kernel side buffer by multiplexer.
       
   202         * This method will be deprecated in the future.
       
   203         * It is preffered to use GetThreadPtr instead.         
       
   204         * @since 2.8
       
   205         * @param aUserBuffer pointer to source descriptor
       
   206         * @param aKernelBuffer pointer to destination descriptor
       
   207         * @param aChannelPtr DIscChannel pointer
       
   208         * @param aOffset Offset of the source buffer
       
   209         * @return KErrNone if successful
       
   210         */
       
   211         IMPORT_C TInt CopyFromUserBuffer( const TDesC8& aUserBuffer,
       
   212                                           TDes8& aKernelBuffer,
       
   213                                           const TAny* aChannelPtr,
       
   214                                           const TInt aOffset );
       
   215 
       
   216         /**
       
   217         * Copy data to user side buffer from kernel side by multiplexer.
       
   218         * This method will be deprecated in the future.
       
   219         * It is preffered to use GetThreadPtr instead.  
       
   220         * @since 2.8
       
   221         * @param aUserBuffer pointer to destination descriptor
       
   222         * @param aKernelBuffer pointer to source descriptor
       
   223         * @param aChannelPtr DIscChannel pointer
       
   224         * @param aOffset Offset of the destination buffer
       
   225         * @return KErrNone if succesful
       
   226         */
       
   227         IMPORT_C TInt CopyToUserBuffer( TAny* aUserBuffer,
       
   228                                         const TDesC8& aKernelBuffer,
       
   229                                         const TAny* aChannelPtr,
       
   230                                         const TInt aOffset );
       
   231                                         
       
   232         /**
       
   233         * Returns a user side thread of a given channel. 
       
   234         * @since 3.0
       
   235         * @param const TAny* aChannelPtr, channel pointer (DIscChannel).
       
   236         * @return DThread*, user side clients thread. Ownership is not given.
       
   237         */
       
   238         IMPORT_C DThread* GetThreadPtr( const TAny* aChannelPtr );                                        
       
   239           
       
   240         /**
       
   241         * Notify multiplexer about down link flow control
       
   242         * @since 2.8
       
   243         * @param  const TInt aDLFlowStatus EIscFlowControlOn / EIscFlowControlOff
       
   244         * @param const TUint16 aChannel channel number
       
   245         * @return void 
       
   246         */
       
   247         void DLFlowControlNotify( const TInt aDLFlowStatus, 
       
   248                                   const TUint16 aChannel,
       
   249                                   const TAny* aChannelPtr );
       
   250 
       
   251         /**
       
   252         * Function to tell current status of connection to Domestic OS
       
   253         * @since 2.8
       
   254         * @return TInt EIscConnectionOk / EIscConnectionNotOk
       
   255         */
       
   256         TInt ConnectionStatus();
       
   257 
       
   258     protected:
       
   259 
       
   260         /**
       
   261         * Function to disable interrupts
       
   262         * @since 2.8
       
   263         * @return TInt KErrNone if succesful
       
   264         */
       
   265         static TInt DisableIrqs();
       
   266 
       
   267         /**
       
   268         * Function to restore interrupts
       
   269         * @since 2.8
       
   270         * @param TInt aLevel level where interrupts should be restored
       
   271         * @return void 
       
   272         */
       
   273         static void RestoreIrqs( TInt aLevel );
       
   274 
       
   275 
       
   276     private:
       
   277 
       
   278         /**
       
   279         * Function to connect to DataTransmission and Multiplexer ldds
       
   280         * @since 2.8
       
   281         * @return TInt KErrNone if succesful
       
   282         */
       
   283         TInt InitializeLdd2LddInterface();
       
   284 
       
   285         /**
       
   286         * Dfc to empty control channel and other send queues
       
   287         * @since 2.8
       
   288         * @param TAny* aPtr pointer to DIscDevice
       
   289         * @return static void
       
   290         */
       
   291         static void Flush( TAny* aPtr );
       
   292 
       
   293         /**
       
   294         * Notifies connection changes.
       
   295         * @since 2.8
       
   296         * @param TAny* aPtr
       
   297         * @return static void
       
   298         */
       
   299         static void NotifyConnection( TAny* aPtr );
       
   300 
       
   301 
       
   302     public:     // Data
       
   303     
       
   304         static DIscMultiplexerBase* iIscMultiplexerInterface;
       
   305         static DIscDataTransmissionBase* iIscDataTransmissionInterface;
       
   306     
       
   307 
       
   308     private:    // Data
       
   309     
       
   310         TUint32**               iSend;
       
   311         TUint32**               iTempSend;
       
   312         TUint32**               iControlSend;        
       
   313         
       
   314         TIscSendFrameInfo**     iSendFrameParameters;
       
   315         TIscSendFrameInfo**     iTempFrameParameters;
       
   316         TIscSendFrameInfo**     iControlFrameParameters;
       
   317         
       
   318         static DIscSendQueue*   iSendQueue;
       
   319         static DIscSendQueue*   iTempQueue;
       
   320         static DIscSendQueue*   iControlSendQueue;
       
   321 
       
   322         static TDfc*            iSendDfc;
       
   323         static TDfc*            iNotifyDfc;
       
   324         
       
   325         DIscMainRcvBuffer*      iIscMainRcvBuffer;
       
   326 
       
   327         static TInt             iConnectionStatus;
       
   328 
       
   329     };
       
   330 
       
   331 #endif      // ISCDEVICE_H
       
   332             
       
   333 // End of File