connectivitylayer/isce/isirouter_dll/src/isiuserchannel.cpp
changeset 9 8486d82aef45
parent 0 63b37f68c1ce
equal deleted inserted replaced
8:6295dc2169f3 9:8486d82aef45
    18 
    18 
    19 
    19 
    20 #include <kern_priv.h>              // For DMutex
    20 #include <kern_priv.h>              // For DMutex
    21 #include "isiuserchannel.h"         // For DISIUserChanneel
    21 #include "isiuserchannel.h"         // For DISIUserChanneel
    22 #include "isiroutertrace.h"         // For C_TRACE, ASSERT_RESET.. and fault codes
    22 #include "isiroutertrace.h"         // For C_TRACE, ASSERT_RESET.. and fault codes
    23 #include "misichannelrouterif.h"    // For MISIChannelRouterIf
    23 #include "misiobjectrouterif.h"    // For MISIObjectRouterIf
    24 #include "memapi.h"                 // For MemApi
    24 #include "memapi.h"                 // For MemApi
    25 #include "isimsgqueue.h"            // For DISIMsgQueue
    25 #include "isimsgqueue.h"            // For DISIMsgQueue
    26 
    26 
    27 const TInt KFirstParam( 0 );
    27 const TInt KFirstParam( 0 );
    28 const TInt KSecondParam( 1 );
    28 const TInt KSecondParam( 1 );
    77         ) : iThread( &Kern::CurrentThread()),
    77         ) : iThread( &Kern::CurrentThread()),
    78             iObjId( KNotInitializedId ),
    78             iObjId( KNotInitializedId ),
    79             iUID( KNotInitializedUID )
    79             iUID( KNotInitializedUID )
    80     {
    80     {
    81     C_TRACE( ( _T( "DISIUserChannel::DISIUserChannel>" ) ) );
    81     C_TRACE( ( _T( "DISIUserChannel::DISIUserChannel>" ) ) );
    82     iRouterIf = MISIChannelRouterIf::GetIf();
    82     iRouterIf = MISIObjectRouterIf::GetIf();
    83     ASSERT_RESET_ALWAYS( iRouterIf, ( EISIUserChannelMemAllocFail | EDISIUserChannelTraceId << KClassIdentifierShift ) );
    83     ASSERT_RESET_ALWAYS( iRouterIf, ( EISIUserChannelMemAllocFail | EDISIUserChannelTraceId << KClassIdentifierShift ) );
    84     iCompletionThread = iRouterIf->GetDfcThread( MISIChannelRouterIf::EISIUserRequestCompletionThread );
    84     iCompletionThread = iRouterIf->GetDfcThread( MISIObjectRouterIf::EISIUserRequestCompletionThread );
    85     iEmptyRxQueueDfc = new TDfc( EmptyRxQueueDfc, this, iCompletionThread, KISILddEmptyRxQueuePriori );
    85     iEmptyRxQueueDfc = new TDfc( EmptyRxQueueDfc, this, iCompletionThread, KISILddEmptyRxQueuePriori );
    86     ASSERT_RESET_ALWAYS( iEmptyRxQueueDfc, ( EISIUserChannelMemAllocFail2 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
    86     ASSERT_RESET_ALWAYS( iEmptyRxQueueDfc, ( EISIUserChannelMemAllocFail2 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
    87     iCompleteChannelRequestDfc = new TDfc( CompleteChannelRequestDfc, this, iCompletionThread, KISILddCompleteRequestPriori );
    87     iCompleteChannelRequestDfc = new TDfc( CompleteChannelRequestDfc, this, iCompletionThread, KISILddCompleteRequestPriori );
    88     ASSERT_RESET_ALWAYS( iCompleteChannelRequestDfc, ( EISIUserChannelMemAllocFail3 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
    88     ASSERT_RESET_ALWAYS( iCompleteChannelRequestDfc, ( EISIUserChannelMemAllocFail3 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
    89     iRequests = new DISIUserAsyncRequests( EISILastAsyncRequest );   
    89     iRequests = new DISIUserAsyncRequests( EISILastAsyncRequest );   
   145     C_TRACE( ( _T( "DISIUserChannel::DoCreate 0x%x 0x%x>" ), this, iObjId ) );
   145     C_TRACE( ( _T( "DISIUserChannel::DoCreate 0x%x 0x%x>" ), this, iObjId ) );
   146     if( !Kern::CurrentThreadHasCapability( ECapabilityCommDD, __PLATSEC_DIAGNOSTIC_STRING( "Check by: ISI Router" ) ) ) return KErrPermissionDenied;
   146     if( !Kern::CurrentThreadHasCapability( ECapabilityCommDD, __PLATSEC_DIAGNOSTIC_STRING( "Check by: ISI Router" ) ) ) return KErrPermissionDenied;
   147     iRx = new DISIMsgQueue( KISILddRxQueueSize );
   147     iRx = new DISIMsgQueue( KISILddRxQueueSize );
   148     ASSERT_RESET_ALWAYS( iRx, ( EISIUserChannelMemAllocFail1 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
   148     ASSERT_RESET_ALWAYS( iRx, ( EISIUserChannelMemAllocFail1 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
   149     // Other DFC functions handling user<>kernel copying done in ldd DFC. Ldd DFC function priority is 1.
   149     // Other DFC functions handling user<>kernel copying done in ldd DFC. Ldd DFC function priority is 1.
   150     iMainThread = iRouterIf->GetDfcThread( MISIChannelRouterIf::EISIUserMainThread );
   150     iMainThread = iRouterIf->GetDfcThread( MISIObjectRouterIf::EISIUserMainThread );
   151     SetDfcQ( iMainThread );
   151     SetDfcQ( iMainThread );
   152     iMsgQ.Receive();
   152     iMsgQ.Receive();
   153     DObject* thread = reinterpret_cast<DObject*>( iThread );
   153     DObject* thread = reinterpret_cast<DObject*>( iThread );
   154     // Open is needed to increase ref count to calling thread that is decreased in Kern::SafeClose
   154     // Open is needed to increase ref count to calling thread that is decreased in Kern::SafeClose
   155     // Possible returns KErrNone ? KErrGeneral
   155     // Possible returns KErrNone ? KErrGeneral
   294             if( msgLength > 0 && msgLength < KMaxISIMsgSize )
   294             if( msgLength > 0 && msgLength < KMaxISIMsgSize )
   295                 {
   295                 {
   296                 TDes8& sendBlock = MemApi::AllocBlock( msgLength );
   296                 TDes8& sendBlock = MemApi::AllocBlock( msgLength );
   297                 ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), ( EISIUserChannelDesReadFailed | EDISIUserChannelTraceId << KClassIdentifierShift ) );
   297                 ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), ( EISIUserChannelDesReadFailed | EDISIUserChannelTraceId << KClassIdentifierShift ) );
   298                 TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, iObjId << KObjIdShift );
   298                 TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, iObjId << KObjIdShift );
   299                 C_TRACE( ( _T( "DISIUserChannel::HandleAsyncRequest EISISend 0x%x 0x%x" ), this, &sendBlock ) );
   299                 C_TRACE( ( _T( "DISIUserChannel::HandleSyncRequest EISISend 0x%x 0x%x" ), this, &sendBlock ) );
   300                 error = iRouterIf->Send( sendBlock, iObjId );
   300                 error = iRouterIf->Send( sendBlock, iObjId );
   301                 }
   301                 }
   302             else
   302             else
   303                 {
   303                 {
   304                 error = ( msgLength > KMaxISIMsgSize ) ? KErrNoMemory : KErrBadDescriptor;
   304                 error = ( msgLength > KMaxISIMsgSize ) ? KErrNoMemory : KErrBadDescriptor;
   427         }
   427         }
   428     C_TRACE( ( _T( "DISIUserChannel::ResetQueues 0x%x 0x%x<" ), this, iObjId ) );
   428     C_TRACE( ( _T( "DISIUserChannel::ResetQueues 0x%x 0x%x<" ), this, iObjId ) );
   429     }
   429     }
   430 
   430 
   431 // This is called in 1...N thread contextes
   431 // This is called in 1...N thread contextes
   432 void DISIUserChannel::ReceiveMsg(
   432 void DISIUserChannel::Receive(
   433         const TDesC8& aMessage
   433         const TDesC8& aMessage
   434         )
   434         )
   435     {
   435     {
   436     C_TRACE( ( _T( "DISIUserChannel::ReceiveMsg 0x%x 0x%x 0x%x>" ), this, &aMessage, iObjId ) );
   436     C_TRACE( ( _T( "DISIUserChannel::Receive 0x%x 0x%x 0x%x>" ), this, &aMessage, iObjId ) );
   437     // Can only be called from thread context.
   437     // Can only be called from thread context.
   438     ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIUserChannelfNotThreadContext3 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
   438     ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIUserChannelfNotThreadContext3 | EDISIUserChannelTraceId << KClassIdentifierShift ) );
   439     iRx->Add( aMessage );
   439     iRx->Add( aMessage );
   440     iEmptyRxQueueDfc->Enque();
   440     iEmptyRxQueueDfc->Enque();
   441     C_TRACE( ( _T( "DISIUserChannel::ReceiveMsg 0x%x 0x%x 0x%x<" ), this, &aMessage, iObjId ) );
   441     C_TRACE( ( _T( "DISIUserChannel::Receive 0x%x 0x%x 0x%x<" ), this, &aMessage, iObjId ) );
   442     }
   442     }
   443 
   443 
   444 DISIUserChannel::DISIUserAsyncRequests::DISIUserAsyncRequests(
   444 DISIUserChannel::DISIUserAsyncRequests::DISIUserAsyncRequests(
   445         const TInt aSize
   445         const TInt aSize
   446         )
   446         )
   560         TInt aStatusToComplete
   560         TInt aStatusToComplete
   561         )
   561         )
   562     {
   562     {
   563     C_TRACE( ( _T( "DISIUserChannel::EnqueChannelRequestCompleteDfc 0x%x %d %d 0x%x>" ), this, aRequest, aStatusToComplete, iObjId ) );
   563     C_TRACE( ( _T( "DISIUserChannel::EnqueChannelRequestCompleteDfc 0x%x %d %d 0x%x>" ), this, aRequest, aStatusToComplete, iObjId ) );
   564     ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIUserChannelfNotThreadContext | EDISIUserChannelTraceId << KClassIdentifierShift ) );    
   564     ASSERT_THREAD_CONTEXT_ALWAYS( ( EISIUserChannelfNotThreadContext | EDISIUserChannelTraceId << KClassIdentifierShift ) );    
   565     //TODO check the error code
   565 
   566     iRequests->iRequestCompletedList.Append( aRequest ); 
   566     iRequests->iRequestCompletedList.Append( aRequest ); 
   567     iRequests->iRequestCompletionValueList[ aRequest ] = aStatusToComplete;
   567     iRequests->iRequestCompletionValueList[ aRequest ] = aStatusToComplete;
   568     iCompleteChannelRequestDfc->Enque();
   568     iCompleteChannelRequestDfc->Enque();
   569     C_TRACE( ( _T( "DISIUserChannel::EnqueChannelRequestCompleteDfc 0x%x %d %d 0x%x<" ), this, aRequest, aStatusToComplete, iObjId ) );
   569     C_TRACE( ( _T( "DISIUserChannel::EnqueChannelRequestCompleteDfc 0x%x %d %d 0x%x<" ), this, aRequest, aStatusToComplete, iObjId ) );
   570     }
   570     }