connectivitylayer/isce/p2prouter_dll/src/p2pkernelchannel.cpp
changeset 9 8486d82aef45
parent 0 63b37f68c1ce
equal deleted inserted replaced
8:6295dc2169f3 9:8486d82aef45
    65     EP2PKernelChannelSameRequestTwice,
    65     EP2PKernelChannelSameRequestTwice,
    66     EP2PKernelChannelDfcAlreadyQueued,
    66     EP2PKernelChannelDfcAlreadyQueued,
    67     EP2PKernelChannelRxBufferNotReleased,
    67     EP2PKernelChannelRxBufferNotReleased,
    68     };
    68     };
    69 
    69 
    70 // TODO: Create a common Kernel channel FW (P2P, ISI, etc..) after APIs are locked
    70 //  Create a common Kernel channel FW (P2P, ISI, etc..) after APIs are locked
    71 
    71 
    72 DP2PKernelChannel::DP2PKernelChannel(
    72 DP2PKernelChannel::DP2PKernelChannel(
    73         // None
    73         // None
    74         ) :
    74         ) :
    75         iP2PProtocolId( EP2PAmountOfProtocols ),
    75         iP2PProtocolId( EP2PAmountOfProtocols ),
   104     // Only modified in constructor, if not created already reseted.
   104     // Only modified in constructor, if not created already reseted.
   105     delete iRx;
   105     delete iRx;
   106     iRx = NULL;
   106     iRx = NULL;
   107     C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel iEmptyRxDfc 0x%x" ), iEmptyRxDfc ) );
   107     C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel iEmptyRxDfc 0x%x" ), iEmptyRxDfc ) );
   108     // Only modified in constructor, if not created already reseted.
   108     // Only modified in constructor, if not created already reseted.
   109     iEmptyRxDfc->Cancel();
   109     if (iEmptyRxDfc)
       
   110     {	
       
   111        iEmptyRxDfc->Cancel();
       
   112     } 
   110     delete iEmptyRxDfc;
   113     delete iEmptyRxDfc;
   111     iEmptyRxDfc = NULL;
   114     iEmptyRxDfc = NULL;
   112     iPtrPtrToRxBuf = NULL;
   115     iPtrPtrToRxBuf = NULL;
   113     iRouterIf = NULL;
   116     iRouterIf = NULL;
   114     C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel iRequests 0x%x" ), iEmptyRxDfc ) );
   117     C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel iRequests 0x%x" ), iEmptyRxDfc ) );
   125         TThreadMessage& aMsg
   128         TThreadMessage& aMsg
   126         )
   129         )
   127     {
   130     {
   128 
   131 
   129     C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, aMsg.iValue ) );
   132     C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, aMsg.iValue ) );
   130     // TODO : similar__NK_ASSERT_UNLOCKED;
   133 
   131     __ASSERT_CRITICAL;      // From kern_priv.h published partner
   134     __ASSERT_CRITICAL;      // From kern_priv.h published partner
   132     __ASSERT_NO_FAST_MUTEX; // From nk_priv.h published partner.
   135     __ASSERT_NO_FAST_MUTEX; // From nk_priv.h published partner.
   133     ASSERT_THREAD_CONTEXT_ALWAYS( ( EP2PKernelChannelNotThreadContext | EDP2PKernelChannelId << KClassIdentifierShift ) );
   136     ASSERT_THREAD_CONTEXT_ALWAYS( ( EP2PKernelChannelNotThreadContext | EDP2PKernelChannelId << KClassIdentifierShift ) );
   134     C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest 0x%x == 0x%x " ), iP2PProtocolId, EP2PAmountOfProtocols ) );
   137     C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest 0x%x == 0x%x " ), iP2PProtocolId, EP2PAmountOfProtocols ) );
   135     TInt valueToReturn( KErrAlreadyExists );
   138     TInt valueToReturn( KErrAlreadyExists );
   196         )
   199         )
   197     {
   200     {
   198 
   201 
   199     C_TRACE( ( _T( "DP2PKernelChannel::EnqueChannelRequestCompleteDfc 0x%x 0x%x %d %d 0x%x>" ), this, iP2PProtocolId, aRequest, aStatusToComplete ) );
   202     C_TRACE( ( _T( "DP2PKernelChannel::EnqueChannelRequestCompleteDfc 0x%x 0x%x %d %d 0x%x>" ), this, iP2PProtocolId, aRequest, aStatusToComplete ) );
   200     ASSERT_THREAD_CONTEXT_ALWAYS( ( EP2PKernelChannelNotThreadContext2 | EDP2PKernelChannelId << KClassIdentifierShift ) );
   203     ASSERT_THREAD_CONTEXT_ALWAYS( ( EP2PKernelChannelNotThreadContext2 | EDP2PKernelChannelId << KClassIdentifierShift ) );
   201     // TODO: assert router ext thread context
   204     //  assert router ext thread context
   202     if( aRequest == EP2PAsyncOpen )
   205     if( aRequest == EP2PAsyncOpen )
   203         {
   206         {
   204         iP2PProtocolId = ( KErrNone == aStatusToComplete || KErrInUse == aStatusToComplete ) ? ~iP2PProtocolId : EP2PAmountOfProtocols;
   207         iP2PProtocolId = ( KErrNone == aStatusToComplete || KErrInUse == aStatusToComplete ) ? ~iP2PProtocolId : EP2PAmountOfProtocols;
   205         }
   208         }
   206     iRequests->Complete( aRequest, aStatusToComplete );
   209     iRequests->Complete( aRequest, aStatusToComplete );
   346             case EP2PAsyncOpen:
   349             case EP2PAsyncOpen:
   347                 {
   350                 {
   348                 iP2PProtocolId = tablePtr[ KThirdParam ];
   351                 iP2PProtocolId = tablePtr[ KThirdParam ];
   349                 iP2PProtocolId = ~iP2PProtocolId;
   352                 iP2PProtocolId = ~iP2PProtocolId;
   350                 C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest EP2PNokiaKernelOpen 0x%x 0x%x 0x%x" ), this, iP2PProtocolId, ~iP2PProtocolId ) );
   353                 C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest EP2PNokiaKernelOpen 0x%x 0x%x 0x%x" ), this, iP2PProtocolId, ~iP2PProtocolId ) );
   351                 iRouterIf->Open( ~iP2PProtocolId, this );
   354                 iRouterIf->Connect( ~iP2PProtocolId, this );
   352                 break;
   355                 break;
   353                 }
   356                 }
   354             case EP2PAsyncReceive:
   357             case EP2PAsyncReceive:
   355                 {
   358                 {
   356                 ASSERT_RESET_ALWAYS( !iPtrPtrToRxBuf, ( EP2PKernelChannelRxBufferNotReleased | EDP2PKernelChannelId << KClassIdentifierShift ) );
   359                 ASSERT_RESET_ALWAYS( !iPtrPtrToRxBuf, ( EP2PKernelChannelRxBufferNotReleased | EDP2PKernelChannelId << KClassIdentifierShift ) );
   530         // None
   533         // None
   531         )
   534         )
   532     {
   535     {
   533 
   536 
   534     C_TRACE( ( _T( "DP2PKernelChannel::ResetQueues 0x%x 0x%x>" ), this, iP2PProtocolId ) );
   537     C_TRACE( ( _T( "DP2PKernelChannel::ResetQueues 0x%x 0x%x>" ), this, iP2PProtocolId ) );
   535     // TODO: assert router ext thread context
   538     //  assert router ext thread context
   536     if( iRx )
   539     if( iRx )
   537         {
   540         {
   538         C_TRACE( ( _T( "DP2PKernelChannel::ResetQueues 0x%x 0x%x iRx 0x%x" ), this, iP2PProtocolId, iRx ) );
   541         C_TRACE( ( _T( "DP2PKernelChannel::ResetQueues 0x%x 0x%x iRx 0x%x" ), this, iP2PProtocolId, iRx ) );
   539         while( iRx->Count() )
   542         while( iRx->Count() )
   540             {
   543             {