connectivitylayer/isce/isaaccessldd_ldd/src/isauserchannel.cpp
changeset 8 6295dc2169f3
parent 5 8ccc39f9d787
equal deleted inserted replaced
7:fa67e03b87df 8:6295dc2169f3
   214         {
   214         {
   215         C_TRACE( ( _T( "DISAUserChannel::~DISAUserChannel iDataRxDeAllocate 0x%x" ), iDataRxDeAllocate ) );
   215         C_TRACE( ( _T( "DISAUserChannel::~DISAUserChannel iDataRxDeAllocate 0x%x" ), iDataRxDeAllocate ) );
   216         delete iDataRxDeAllocate;
   216         delete iDataRxDeAllocate;
   217         iDataRxDeAllocate = NULL;
   217         iDataRxDeAllocate = NULL;
   218         }
   218         }
       
   219     if( iCleanDfc )
       
   220         {
       
   221         C_TRACE( ( _T( "DISAUserChannel::~DISAUserChannel iCleanDfc 0x%x" ), iCleanDfc ) );
       
   222         iCleanDfc->Cancel();
       
   223         delete iCleanDfc;
       
   224         iCleanDfc = NULL;
       
   225         }
       
   226     if( iCleanDataDfc )
       
   227         {
       
   228         C_TRACE( ( _T( "DISAUserChannel::~DISAUserChannel iCleanDataDfc 0x%x" ), iCleanDataDfc ) );
       
   229         iCleanDataDfc->Cancel();
       
   230         delete iCleanDataDfc;
       
   231         iCleanDataDfc = NULL;
       
   232         }
       
   233 
   219     // Not owned
   234     // Not owned
   220     OstTraceExt4( TRACE_NORMAL, DUP9_DISAUSERCHANNEL_DISAUSERCHANNEL, "DISAUserChannel::~DISAUserChannel;iIADConnectionStatusPtr=%x;iIADFlowControlStatusPtr=%x;iReceiveBufPtr=%x;iDataReceiveBufPtr=%x", (TUint)iIADConnectionStatusPtr, (TUint)iIADFlowControlStatusPtr, (TUint)iReceiveBufPtr, (TUint)iDataReceiveBufPtr );
   235     OstTraceExt4( TRACE_NORMAL, DUP9_DISAUSERCHANNEL_DISAUSERCHANNEL, "DISAUserChannel::~DISAUserChannel;iIADConnectionStatusPtr=%x;iIADFlowControlStatusPtr=%x;iReceiveBufPtr=%x;iDataReceiveBufPtr=%x", (TUint)iIADConnectionStatusPtr, (TUint)iIADFlowControlStatusPtr, (TUint)iReceiveBufPtr, (TUint)iDataReceiveBufPtr );
   221     
   236     
   222     if( iIADConnectionStatusPtr )
   237     if( iIADConnectionStatusPtr )
   223         {
   238         {
   288 
   303 
   289     C_TRACE( ( _T( "DISAUserChannel::DoCreate 0x%x 0x%x ->" ), iChannelNumber, anInfo ) );
   304     C_TRACE( ( _T( "DISAUserChannel::DoCreate 0x%x 0x%x ->" ), iChannelNumber, anInfo ) );
   290     if( !Kern::CurrentThreadHasCapability( ECapabilityCommDD, __PLATSEC_DIAGNOSTIC_STRING( "Check by: ISAAccessDriver" ) ) ) return KErrPermissionDenied;  
   305     if( !Kern::CurrentThreadHasCapability( ECapabilityCommDD, __PLATSEC_DIAGNOSTIC_STRING( "Check by: ISAAccessDriver" ) ) ) return KErrPermissionDenied;  
   291     ASSERT_RESET_ALWAYS( anInfo, EIADChannelNumberNotSpecifiedInInfo | EIADFaultIdentifier1 << KFaultIdentifierShift );
   306     ASSERT_RESET_ALWAYS( anInfo, EIADChannelNumberNotSpecifiedInInfo | EIADFaultIdentifier1 << KFaultIdentifierShift );
   292     // Check for channel number inside anInfo.
   307     // Check for channel number inside anInfo.
   293     ASSERT_RESET_ALWAYS( anInfo->Length() > 0 , EIADOverTheLimits | EIADFaultIdentifier39 << KFaultIdentifierShift );                                                
   308     TUint8* buffer = reinterpret_cast<TUint8*>( Kern::Alloc( 1 ) );
   294     TUint16 channel = static_cast<TUint16>( ( *anInfo )[ 0 ] );
   309     ASSERT_RESET_ALWAYS( buffer, EIADMemoryAllocationFailure | EIADFaultIdentifier25 << KFaultIdentifierShift );
       
   310     
       
   311     TPtr8* bufferPtr = new TPtr8( buffer, 1 );    
       
   312     ASSERT_RESET_ALWAYS( bufferPtr, EIADMemoryAllocationFailure | EIADFaultIdentifier26 << KFaultIdentifierShift );
       
   313     
       
   314     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, anInfo, *bufferPtr, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier10 << KFaultIdentifierShift );
       
   315     ASSERT_RESET_ALWAYS( bufferPtr->Length() > 0 , EIADOverTheLimits | EIADFaultIdentifier39 << KFaultIdentifierShift );
       
   316     
       
   317     TUint16 channel = static_cast<TUint16>( ( *bufferPtr )[ 0 ] );
   295     ASSERT_RESET_ALWAYS( ( channel < EIADNokiaLastUserChannel ),EIADWrongParameter | EIADFaultIdentifier19 << KFaultIdentifierShift );
   318     ASSERT_RESET_ALWAYS( ( channel < EIADNokiaLastUserChannel ),EIADWrongParameter | EIADFaultIdentifier19 << KFaultIdentifierShift );
   296     iChannelNumber = ~channel; // In user thread context thread in CS, cannot be pre-empted.
   319     iChannelNumber = ~channel; // In user thread context thread in CS, cannot be pre-empted.
   297     C_TRACE( ( _T( "DISAUserChannel::DoCreate channelnumber 0x%x 0x%x" ), iChannelNumber, this ) );
   320     C_TRACE( ( _T( "DISAUserChannel::DoCreate channelnumber 0x%x 0x%x" ), iChannelNumber, this ) );
   298     iRx = new DQueue( KIADLddRxQueuSize );
   321     iRx = new DQueue( KIADLddRxQueuSize );
   299     iDataRx =new DQueue( KIADLddDataRxQueuSize );
   322     iDataRx =new DQueue( KIADLddDataRxQueuSize );
   311     // Open is needed to increase ref count to calling thread that is decreased in Kern::SafeClose
   334     // Open is needed to increase ref count to calling thread that is decreased in Kern::SafeClose
   312     // Possible returns KErrNone ? KErrGeneral
   335     // Possible returns KErrNone ? KErrGeneral
   313     TInt threadOpen( thread->Open() );
   336     TInt threadOpen( thread->Open() );
   314     TRACE_ASSERT_INFO( threadOpen == KErrNone, (TUint8)iChannelNumber << KChannelNumberShift );
   337     TRACE_ASSERT_INFO( threadOpen == KErrNone, (TUint8)iChannelNumber << KChannelNumberShift );
   315     C_TRACE( ( _T( "DISAUserChannel::DoCreate 0x%x %d <-" ), iChannelNumber, threadOpen ) );
   338     C_TRACE( ( _T( "DISAUserChannel::DoCreate 0x%x %d <-" ), iChannelNumber, threadOpen ) );
   316 
   339     
       
   340     Kern::Free( buffer );
       
   341     delete bufferPtr;
       
   342     
   317     OstTraceExt3( TRACE_NORMAL, DISAUSERCHANNEL_DOCREATE_EXIT, "<DISAUserChannel::DoCreate;iChannelNumber=%hx;this=%x;retVal=%d", iChannelNumber, (TUint)this, threadOpen );    
   343     OstTraceExt3( TRACE_NORMAL, DISAUSERCHANNEL_DOCREATE_EXIT, "<DISAUserChannel::DoCreate;iChannelNumber=%hx;this=%x;retVal=%d", iChannelNumber, (TUint)this, threadOpen );    
   318     return threadOpen;
   344     return threadOpen;
   319     }
   345     }
   320 
   346 
   321 void DISAUserChannel::HandleMsg
   347 void DISAUserChannel::HandleMsg
  1166                 break;
  1192                 break;
  1167                 }
  1193                 }
  1168             case EIADAsyncSend:
  1194             case EIADAsyncSend:
  1169                 {
  1195                 {
  1170                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSend" ) ) );
  1196                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSend" ) ) );
  1171                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1197                 TInt error(KErrNotReady);
  1172                 TAny* secondParam = reinterpret_cast<TAny*>( tablePtr[ KSecondParam ] );
  1198                 if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1173                 ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier23 << KFaultIdentifierShift  );
  1199                     {
  1174                 TInt msgLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1200                     TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1175                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSend 0x%x %d" ), secondParam, msgLength ) );
  1201                     TAny* secondParam = reinterpret_cast<TAny*>( tablePtr[ KSecondParam ] );
  1176                 OstTraceExt2( TRACE_NORMAL, DUP10_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSend;secondParam=%x;msgLength=%d", (TUint)secondParam, msgLength );
  1202                     ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier23 << KFaultIdentifierShift  );
  1177                 
  1203                     TInt msgLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1178                 TInt error( KErrBadDescriptor );
  1204                     C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSend 0x%x %d" ), secondParam, msgLength ) );
  1179                 if( msgLength > 0 )
  1205                     OstTraceExt2( TRACE_NORMAL, DUP10_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSend;secondParam=%x;msgLength=%d", (TUint)secondParam, msgLength );
  1180                     {
       
  1181                     // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
       
  1182                     // one copy from user to allocated block that is to be send.
       
  1183                     TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
       
  1184                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier2 << KFaultIdentifierShift );
       
  1185                     TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
       
  1186                     C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
       
  1187                     OstTraceExt2( TRACE_NORMAL, DUP16_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSend;sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );
       
  1188                     
  1206                     
  1189                     error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
  1207                     error = KErrBadDescriptor;
  1190                     }
  1208                     if( msgLength > 0 )
  1191                 else
  1209                         {
  1192                     {
  1210                         // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
  1193                     error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
  1211                         // one copy from user to allocated block that is to be send.
  1194                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
  1212                         TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
       
  1213                         ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier2 << KFaultIdentifierShift );
       
  1214                         TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
       
  1215                         C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
       
  1216                         OstTraceExt2( TRACE_NORMAL, DUP16_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSend;sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );
       
  1217                         
       
  1218                         error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
       
  1219                         }
       
  1220                     else
       
  1221                         {
       
  1222                         error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
       
  1223                         TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
       
  1224                         }
  1195                     }
  1225                     }
  1196                 CompleteChannelRequest( aRequest, error );
  1226                 CompleteChannelRequest( aRequest, error );
  1197                 break;
  1227                 break;
  1198                 }
  1228                 }
  1199             case EIADAsyncDataSend:
  1229             case EIADAsyncDataSend:
  1200                 {
  1230                 {
  1201                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend" ) ) );
  1231                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend" ) ) );
  1202                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1232                 TInt error(KErrNotReady);
  1203                 TAny* secondParam = reinterpret_cast<TAny*>( tablePtr[ KSecondParam ] );
  1233                 if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1204                 ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier24 << KFaultIdentifierShift  );
  1234                     {
  1205                 TInt msgLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1235                     TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1206                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADAsyncDataSend 0x%x %d" ), secondParam, msgLength ) );
  1236                     TAny* secondParam = reinterpret_cast<TAny*>( tablePtr[ KSecondParam ] );
  1207                 OstTraceExt2( TRACE_NORMAL, DUP9_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend;secondParam=%x;msgLength=%d", (TUint)secondParam, msgLength );                
  1237                     ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier24 << KFaultIdentifierShift  );
  1208                 TInt error( KErrBadDescriptor );
  1238                     TInt msgLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1209                 if( msgLength > KErrNone )
  1239                     C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADAsyncDataSend 0x%x %d" ), secondParam, msgLength ) );
  1210                     {
  1240                     OstTraceExt2( TRACE_NORMAL, DUP9_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend;secondParam=%x;msgLength=%d", (TUint)secondParam, msgLength );                
  1211                     // Allocate a block for data. Allocation adds +11 to the msglength for pipe headers
  1241                     error = KErrBadDescriptor;
  1212                     TDes8& sendBlock = iExtensionApi->AllocateDataBlock( msgLength );
  1242                     if( msgLength > KErrNone )
  1213                     C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend max %d length %d" ), sendBlock.MaxLength(), sendBlock.Length() ) );
  1243                         {
  1214                     // Use pre-allocated TPtr (no memory allocation from heap nor stack).
  1244                         // Allocate a block for data. Allocation adds +11 to the msglength for pipe headers
  1215                     // Set it to point to +11 from sendblock and to be as long as data to be send
  1245                         TDes8& sendBlock = iExtensionApi->AllocateDataBlock( msgLength );
  1216                     TInt tmpMaxLength( sendBlock.MaxLength() - KPipeDataHeader );
  1246                         C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend max %d length %d" ), sendBlock.MaxLength(), sendBlock.Length() ) );
  1217                     TUint8* tmpPtr( const_cast<TUint8*>( ( sendBlock.Ptr() + KPipeDataHeader ) ) );
  1247                         // Use pre-allocated TPtr (no memory allocation from heap nor stack).
  1218                     TPtr* test = static_cast<TPtr8*>( &sendBlock );
  1248                         // Set it to point to +11 from sendblock and to be as long as data to be send
  1219                     test->Set( tmpPtr, 0, tmpMaxLength );
  1249                         TInt tmpMaxLength( sendBlock.MaxLength() - KPipeDataHeader );
  1220                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, *test, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier3 << KFaultIdentifierShift );
  1250                         TUint8* tmpPtr( const_cast<TUint8*>( ( sendBlock.Ptr() + KPipeDataHeader ) ) );
  1221                     TInt tmpMaxLength2( sendBlock.MaxLength() + KPipeDataHeader );
  1251                         TPtr* test = static_cast<TPtr8*>( &sendBlock );
  1222                     TInt tmpLength2( sendBlock.Length() + KPipeDataHeader );
  1252                         test->Set( tmpPtr, 0, tmpMaxLength );
  1223                     TUint8* tmpPtr2( const_cast<TUint8*>( ( sendBlock.Ptr() - KPipeDataHeader ) ) );
  1253                         ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, *test, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier3 << KFaultIdentifierShift );
  1224                     test->Set( tmpPtr2, tmpLength2, tmpMaxLength2 );
  1254                         TInt tmpMaxLength2( sendBlock.MaxLength() + KPipeDataHeader );
  1225                     TRACE_ASSERT_INFO( sendBlock.Length() > msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1255                         TInt tmpLength2( sendBlock.Length() + KPipeDataHeader );
  1226                     C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
  1256                         TUint8* tmpPtr2( const_cast<TUint8*>( ( sendBlock.Ptr() - KPipeDataHeader ) ) );
  1227                     OstTraceExt4( TRACE_NORMAL, DUP15_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend;sendBlock=%x;sendBlock.MaxLength()=%d;sendBlock.Length()=%d;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.MaxLength(), sendBlock.Length(), iChannelNumber );
  1257                         test->Set( tmpPtr2, tmpLength2, tmpMaxLength2 );
  1228                     
  1258                         TRACE_ASSERT_INFO( sendBlock.Length() > msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1229                     error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
  1259                         C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
  1230                     }
  1260                         OstTraceExt4( TRACE_NORMAL, DUP15_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncDataSend;sendBlock=%x;sendBlock.MaxLength()=%d;sendBlock.Length()=%d;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.MaxLength(), sendBlock.Length(), iChannelNumber );
  1231                 else
  1261                         
  1232                     {
  1262                         error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
  1233                     error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
  1263                         }
  1234                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
  1264                     else
       
  1265                         {
       
  1266                         error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
       
  1267                         TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
       
  1268                         }
  1235                     }
  1269                     }
  1236                 CompleteChannelRequest( aRequest, error );
  1270                 CompleteChannelRequest( aRequest, error );
  1237                 break;
  1271                 break;
  1238                 }
  1272                 }
  1239             case EIADAsyncSubscribeIndications:
  1273             case EIADAsyncSubscribeIndications:
  1240             case EIADAsyncSubscribeIndications32Bit:
  1274             case EIADAsyncSubscribeIndications32Bit:
  1241                 {
  1275                 {
  1242                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications | EIADAsyncSubscribeIndications32Bit" ) ) );
  1276                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications | EIADAsyncSubscribeIndications32Bit" ) ) );
  1243                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1277                 TInt error(KErrNotReady);
  1244                 TAny* secondParam = reinterpret_cast<TAny*>(tablePtr[ KSecondParam ]);
  1278                 if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1245                 ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier25 << KFaultIdentifierShift  );
  1279                     {
  1246                 TInt orderLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1280                     TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1247                 C_TRACE( ( _T( "DISAUserChannel::DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications | EIADAsyncSubscribeIndications32Bit 0x%x %d" ), secondParam, orderLength ) );
  1281                     TAny* secondParam = reinterpret_cast<TAny*>(tablePtr[ KSecondParam ]);
  1248                 OstTraceExt2( TRACE_NORMAL, DUP12_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications(8/32bit);secondParam=%x;orderLength=%d", (TUint)secondParam, orderLength );
  1282                     ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier25 << KFaultIdentifierShift  );
  1249                 
  1283                     TInt orderLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1250                 TInt error( KErrBadDescriptor );
  1284                     C_TRACE( ( _T( "DISAUserChannel::DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications | EIADAsyncSubscribeIndications32Bit 0x%x %d" ), secondParam, orderLength ) );
  1251                 if( orderLength > 0 )
  1285                     OstTraceExt2( TRACE_NORMAL, DUP12_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications(8/32bit);secondParam=%x;orderLength=%d", (TUint)secondParam, orderLength );
  1252                     {
       
  1253                     // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
       
  1254                     // one copy from user to allocated block that is to be send.
       
  1255                     TDes8& sendBlock = iExtensionApi->AllocateBlock( ( orderLength ) );
       
  1256                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier4 << KFaultIdentifierShift );
       
  1257                     C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications | EIADAsyncSubscribeIndications32Bit 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
       
  1258                     OstTraceExt2( TRACE_NORMAL, DUP14_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications(8/32bit);sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );
       
  1259                     
  1286                     
  1260                     TRACE_ASSERT_INFO( sendBlock.Length() == orderLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1287                     error = KErrBadDescriptor;
  1261                     // No return values check needed. Request completed with error value by multiplexer
  1288                     if( orderLength > 0 )
  1262                     TBool thirtyTwoBit( ( EIADSubscribeIndications32Bit == aRequest ) ? ETrue : EFalse );
  1289                         {
  1263                     error = iExtensionApi->OrderIndication( sendBlock, iChannelNumber, thirtyTwoBit );
  1290                         // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
  1264                     iExtensionApi->DeAllocateBlock( sendBlock );
  1291                         // one copy from user to allocated block that is to be send.
  1265                     }
  1292                         TDes8& sendBlock = iExtensionApi->AllocateBlock( ( orderLength ) );
  1266                 else
  1293                         ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier4 << KFaultIdentifierShift );
  1267                     {
  1294                         C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications | EIADAsyncSubscribeIndications32Bit 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
  1268                     error = orderLength;
  1295                         OstTraceExt2( TRACE_NORMAL, DUP14_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSubscribeIndications(8/32bit);sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );
  1269                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error );                    
  1296                         
       
  1297                         TRACE_ASSERT_INFO( sendBlock.Length() == orderLength, (TUint8)iChannelNumber << KChannelNumberShift );
       
  1298                         // No return values check needed. Request completed with error value by multiplexer
       
  1299                         TBool thirtyTwoBit( ( EIADSubscribeIndications32Bit == aRequest ) ? ETrue : EFalse );
       
  1300                         error = iExtensionApi->OrderIndication( sendBlock, iChannelNumber, thirtyTwoBit );
       
  1301                         iExtensionApi->DeAllocateBlock( sendBlock );
       
  1302                         }
       
  1303                     else
       
  1304                         {
       
  1305                         error = orderLength;
       
  1306                         TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error );                    
       
  1307                         }
  1270                     }
  1308                     }
  1271                 CompleteChannelRequest( aRequest, error );
  1309                 CompleteChannelRequest( aRequest, error );
  1272                 break;
  1310                 break;
  1273                 }
  1311                 }
  1274             case EIADAsyncSendIndication:
  1312             case EIADAsyncSendIndication:
  1275                 {
  1313                 {
  1276                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication" ) ) );
  1314                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication" ) ) );
  1277                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1315                 TInt error(KErrNotReady);
  1278                 TAny* secondParam = reinterpret_cast<TAny*>(tablePtr[ KSecondParam ]);
  1316                 if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1279                 ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier26 << KFaultIdentifierShift  );
  1317                     {
  1280                 TInt msgLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1318                     TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1281                 C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication TBR 0x%x %d" ), secondParam, msgLength ) );
  1319                     TAny* secondParam = reinterpret_cast<TAny*>(tablePtr[ KSecondParam ]);
  1282                 OstTraceExt2( TRACE_NORMAL, DUP11_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication;secondParam=%x;msgLength=%d", (TUint)secondParam, msgLength );                
  1320                     ASSERT_RESET_ALWAYS( secondParam, EIADNullParameter | EIADFaultIdentifier26 << KFaultIdentifierShift  );
  1283                 TInt error( KErrBadDescriptor );
  1321                     TInt msgLength( Kern::ThreadGetDesLength( iThread, secondParam ) );
  1284                 if( msgLength > 0 )
  1322                     C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication TBR 0x%x %d" ), secondParam, msgLength ) );
  1285                     {
  1323                     OstTraceExt2( TRACE_NORMAL, DUP11_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication;secondParam=%x;msgLength=%d", (TUint)secondParam, msgLength );                
  1286                     // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made now only
  1324                     error = KErrBadDescriptor;
  1287                     // one copy from user to allocated block that is to be send.
  1325                     if( msgLength > 0 )
  1288                     TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
  1326                         {
  1289                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier5 << KFaultIdentifierShift );
  1327                         // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made now only
  1290                     TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1328                         // one copy from user to allocated block that is to be send.
  1291                     C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication 0x%x %d %d 0x%x" ), &sendBlock, sendBlock.Length(), msgLength, iChannelNumber ) );
  1329                         TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
  1292                     OstTraceExt5( TRACE_NORMAL, DUP13_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication;sendBlock=%x;sendBlock.Length()=%d;sendBlock.MaxLength()=%d;msgLength=%d;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.Length(), sendBlock.MaxLength(), msgLength, iChannelNumber );
  1330                         ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, secondParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier5 << KFaultIdentifierShift );
  1293                     
  1331                         TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1294                     error = iExtensionApi->SendIndication( sendBlock, iChannelNumber );
  1332                         C_TRACE( ( _T( "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication 0x%x %d %d 0x%x" ), &sendBlock, sendBlock.Length(), msgLength, iChannelNumber ) );
  1295                     }
  1333                         OstTraceExt5( TRACE_NORMAL, DUP13_DISAUSERCHANNEL_HANDLEASYNCREQUEST, "DISAUserChannel::HandleAsyncRequest EIADAsyncSendIndication;sendBlock=%x;sendBlock.Length()=%d;sendBlock.MaxLength()=%d;msgLength=%d;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.Length(), sendBlock.MaxLength(), msgLength, iChannelNumber );
  1296                 else
  1334                         
  1297                     {
  1335                         error = iExtensionApi->SendIndication( sendBlock, iChannelNumber );
  1298                     error = msgLength;
  1336                         }
  1299                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error );
  1337                     else
       
  1338                         {
       
  1339                         error = msgLength;
       
  1340                         TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error );
       
  1341                         }
  1300                     }
  1342                     }
  1301                 CompleteChannelRequest( aRequest, error );
  1343                 CompleteChannelRequest( aRequest, error );
  1302                 break;
  1344                 break;
  1303                 }
  1345                 }
  1304             default:
  1346             default:
  1393            break;
  1435            break;
  1394             }
  1436             }
  1395         case EIADSend:
  1437         case EIADSend:
  1396             {
  1438             {
  1397             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSend" ) ) );
  1439             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSend" ) ) );
  1398             TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1440             error = KErrNotReady;
  1399             TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1441             if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1400             ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier27 << KFaultIdentifierShift  );
  1442                 {                
  1401             TInt msgLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1443                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1402             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSend 0x%x %d" ), firstParam, msgLength ) );
  1444                 TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1403             OstTraceExt2( TRACE_NORMAL, DUP2_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSend;firstParam=%x;msgLength=%d", (TUint)firstParam, msgLength );
  1445                 ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier27 << KFaultIdentifierShift  );
  1404             
  1446                 TInt msgLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1405             if( msgLength > 0 )
  1447                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSend 0x%x %d" ), firstParam, msgLength ) );
  1406                 {
  1448                 OstTraceExt2( TRACE_NORMAL, DUP2_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSend;firstParam=%x;msgLength=%d", (TUint)firstParam, msgLength );
  1407                 // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
       
  1408                 // one copy from user to allocated block that is to be send.
       
  1409                 TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
       
  1410                 ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier6 << KFaultIdentifierShift );
       
  1411                 TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
       
  1412                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
       
  1413                 OstTraceExt2( TRACE_NORMAL, DUP13_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSend;sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );
       
  1414                 
  1449                 
  1415                 error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
  1450                 if( msgLength > 0 )
  1416                 }
  1451                     {
  1417             else
  1452                     // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
  1418                 {
  1453                     // one copy from user to allocated block that is to be send.
  1419                 error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
  1454                     TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
  1420                 TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
  1455                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier6 << KFaultIdentifierShift );
       
  1456                     TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
       
  1457                     C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
       
  1458                     OstTraceExt2( TRACE_NORMAL, DUP13_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSend;sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );
       
  1459                     
       
  1460                     error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
       
  1461                     }
       
  1462                 else
       
  1463                     {
       
  1464                     error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
       
  1465                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
       
  1466                     }
  1421                 }
  1467                 }
  1422             break;
  1468             break;
  1423             }
  1469             }
  1424         case EIADDataSend:
  1470         case EIADDataSend:
  1425             {
  1471             {
  1426             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADDataSend" ) ) );
  1472             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADDataSend" ) ) );
  1427             TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1473             error = KErrNotReady;
  1428             TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1474             if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1429             ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier32 << KFaultIdentifierShift  );
  1475                 {                
  1430             TInt msgLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1476                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1431             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADDataSend 0x%x %d" ), firstParam, msgLength ) );
  1477                 TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1432             OstTraceExt2( TRACE_NORMAL, DUP3_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADDataSend;firstParam=%x;msgLength=%d", (TUint)firstParam, msgLength );            
  1478                 ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier32 << KFaultIdentifierShift  );
  1433             if( msgLength > 0 )
  1479                 TInt msgLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1434                 {
  1480                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADDataSend 0x%x %d" ), firstParam, msgLength ) );
  1435                 // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
  1481                 OstTraceExt2( TRACE_NORMAL, DUP3_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADDataSend;firstParam=%x;msgLength=%d", (TUint)firstParam, msgLength );            
  1436                 // one copy from user to allocated block that is to be send.
  1482                 if( msgLength > 0 )
  1437                 
  1483                     {
  1438                 // Allocate a block for data. Allocation adds +11 to the msglength for pipe headers
  1484                     // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
  1439                 TDes8& sendBlock = iExtensionApi->AllocateDataBlock( msgLength );
  1485                     // one copy from user to allocated block that is to be send.
  1440                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest max %d length %d" ), sendBlock.MaxLength(), sendBlock.Length() ) );
  1486                     
  1441                 // Use pre-allocated TPtr (no memory allocation from heap nor stack).
  1487                     // Allocate a block for data. Allocation adds +11 to the msglength for pipe headers
  1442                 // Set it to point to +11 from sendblock and to be as long as data to be send
  1488                     TDes8& sendBlock = iExtensionApi->AllocateDataBlock( msgLength );
  1443                 TInt tmpMaxLength( sendBlock.MaxLength() - KPipeDataHeader );
  1489                     C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest max %d length %d" ), sendBlock.MaxLength(), sendBlock.Length() ) );
  1444                 TUint8* tmpPtr( const_cast<TUint8*>( ( sendBlock.Ptr() + KPipeDataHeader ) ) );
  1490                     // Use pre-allocated TPtr (no memory allocation from heap nor stack).
  1445                 TPtr* test = static_cast<TPtr8*>( &sendBlock );
  1491                     // Set it to point to +11 from sendblock and to be as long as data to be send
  1446                 test->Set( tmpPtr, 0, tmpMaxLength );
  1492                     TInt tmpMaxLength( sendBlock.MaxLength() - KPipeDataHeader );
  1447                 ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, *test, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier7 << KFaultIdentifierShift );
  1493                     TUint8* tmpPtr( const_cast<TUint8*>( ( sendBlock.Ptr() + KPipeDataHeader ) ) );
  1448                 TInt tmpMaxLength2( sendBlock.MaxLength() + KPipeDataHeader );
  1494                     TPtr* test = static_cast<TPtr8*>( &sendBlock );
  1449                 TInt tmpLength2( sendBlock.Length() + KPipeDataHeader );
  1495                     test->Set( tmpPtr, 0, tmpMaxLength );
  1450                 TUint8* tmpPtr2( const_cast<TUint8*>( ( sendBlock.Ptr() - KPipeDataHeader ) ) );
  1496                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, *test, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier7 << KFaultIdentifierShift );
  1451                 test->Set( tmpPtr2, tmpLength2, tmpMaxLength2 );
  1497                     TInt tmpMaxLength2( sendBlock.MaxLength() + KPipeDataHeader );
  1452                 TRACE_ASSERT_INFO( sendBlock.Length() > msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1498                     TInt tmpLength2( sendBlock.Length() + KPipeDataHeader );
  1453                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADDataSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
  1499                     TUint8* tmpPtr2( const_cast<TUint8*>( ( sendBlock.Ptr() - KPipeDataHeader ) ) );
  1454                 OstTraceExt4( TRACE_NORMAL, DUP4_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADDataSend;sendBlock=%x;Length=%x;MaxLength=%x;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.Length(), sendBlock.MaxLength(), iChannelNumber );
  1500                     test->Set( tmpPtr2, tmpLength2, tmpMaxLength2 );
  1455                 
  1501                     TRACE_ASSERT_INFO( sendBlock.Length() > msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1456                 error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
  1502                     C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADDataSend 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
  1457                 }
  1503                     OstTraceExt4( TRACE_NORMAL, DUP4_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADDataSend;sendBlock=%x;Length=%x;MaxLength=%x;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.Length(), sendBlock.MaxLength(), iChannelNumber );
  1458             else
  1504                     
  1459                 {
  1505                     error = iExtensionApi->SendMessage( sendBlock, iChannelNumber );
  1460                 error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
  1506                     }
  1461                 TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
  1507                 else
       
  1508                     {
       
  1509                     error = ( msgLength == KErrNone ) ? KErrBadDescriptor : msgLength;
       
  1510                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)msgLength );
       
  1511                     }
  1462                 }
  1512                 }
  1463             break;
  1513             break;
  1464             }
  1514             }
  1465         case EIADSubscribeIndications:
  1515         case EIADSubscribeIndications:
  1466         case EIADSubscribeIndications32Bit:
  1516         case EIADSubscribeIndications32Bit:
  1467             {
  1517             {
  1468             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications | EIADSubscribeIndications32Bit" ) ) );
  1518             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications | EIADSubscribeIndications32Bit" ) ) );
  1469             TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1519             error = KErrNotReady;
  1470             TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1520             if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1471             ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier29 << KFaultIdentifierShift  );
  1521                 {
  1472             TInt orderLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1522                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1473             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications | EIADSubscribeIndications32Bit 0x%x %d" ), firstParam, orderLength ) );
  1523                 TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1474             OstTraceExt2( TRACE_NORMAL, DUP5_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications(8/32bit);firstParam=%x;orderLength=%d", (TUint)firstParam, orderLength );
  1524                 ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier29 << KFaultIdentifierShift  );
  1475             
  1525                 TInt orderLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1476             if( orderLength > KErrNone )
  1526                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications | EIADSubscribeIndications32Bit 0x%x %d" ), firstParam, orderLength ) );
  1477                 {
  1527                 OstTraceExt2( TRACE_NORMAL, DUP5_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications(8/32bit);firstParam=%x;orderLength=%d", (TUint)firstParam, orderLength );
  1478                 // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
  1528                 
  1479                 // one copy from user to allocated block that is to be send.
  1529                 if( orderLength > KErrNone )
  1480                 TDes8& sendBlock = iExtensionApi->AllocateBlock( ( orderLength ) );
  1530                     {
  1481                 ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier8 << KFaultIdentifierShift );
  1531                     // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made no only
  1482                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
  1532                     // one copy from user to allocated block that is to be send.
  1483                 OstTraceExt2( TRACE_NORMAL, DUP7_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications(8/32bit);sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );                
  1533                     TDes8& sendBlock = iExtensionApi->AllocateBlock( ( orderLength ) );
  1484                 TRACE_ASSERT_INFO( sendBlock.Length() == orderLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1534                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier8 << KFaultIdentifierShift );
  1485                 // No return values check needed. Request completed with error value by multiplexer
  1535                     C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications 0x%x 0x%x" ), &sendBlock, iChannelNumber ) );
  1486                 TBool thirtyTwoBit( ( EIADSubscribeIndications32Bit == aRequest ) ? ETrue : EFalse );
  1536                     OstTraceExt2( TRACE_NORMAL, DUP7_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSubscribeIndications(8/32bit);sendBlock=%x;iChannelNumber=%hx", (TUint)&sendBlock, iChannelNumber );                
  1487                 error = iExtensionApi->OrderIndication( sendBlock, iChannelNumber, thirtyTwoBit );
  1537                     TRACE_ASSERT_INFO( sendBlock.Length() == orderLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1488                 iExtensionApi->DeAllocateBlock( sendBlock );
  1538                     // No return values check needed. Request completed with error value by multiplexer
  1489                 }
  1539                     TBool thirtyTwoBit( ( EIADSubscribeIndications32Bit == aRequest ) ? ETrue : EFalse );
  1490             else
  1540                     error = iExtensionApi->OrderIndication( sendBlock, iChannelNumber, thirtyTwoBit );
  1491                 {
  1541                     iExtensionApi->DeAllocateBlock( sendBlock );
  1492                 error = orderLength;
  1542                     }
  1493                 TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error);
  1543                 else
       
  1544                     {
       
  1545                     error = orderLength;
       
  1546                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error);
       
  1547                     }
  1494                 }
  1548                 }
  1495             break;
  1549             break;
  1496             }
  1550             }
  1497         case EIADSendIndication:
  1551         case EIADSendIndication:
  1498             {
  1552             {
  1499             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSendIndication" ) ) );
  1553             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSendIndication" ) ) );
  1500             TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1554             error = KErrNotReady;
  1501             TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1555             if ( iExtensionApi->GetConnectionStatus() == EIADConnectionOk )
  1502             ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier30 << KFaultIdentifierShift  );
  1556                 {
  1503             TInt msgLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1557                 TUint32* tablePtr = reinterpret_cast<TUint32*>( a1 );
  1504             C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSendIndication TBR 0x%x %d" ), firstParam, msgLength ) );
  1558                 TAny* firstParam = reinterpret_cast<TAny*>(tablePtr[ KFirstParam ]);
  1505             OstTraceExt2( TRACE_NORMAL, DUP6_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSendIndication;firstParam=%x;msgLength=%d", (TUint)firstParam, msgLength );
  1559                 ASSERT_RESET_ALWAYS( firstParam, EIADNullParameter | EIADFaultIdentifier30 << KFaultIdentifierShift  );
  1506             if( msgLength > KErrNone )
  1560                 TInt msgLength( Kern::ThreadGetDesLength( iThread, firstParam ) );
  1507                 {
  1561                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSendIndication TBR 0x%x %d" ), firstParam, msgLength ) );
  1508                 // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made now only
  1562                 OstTraceExt2( TRACE_NORMAL, DUP6_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSendIndication;firstParam=%x;msgLength=%d", (TUint)firstParam, msgLength );
  1509                 // one copy from user to allocated block that is to be send.
  1563                 if( msgLength > KErrNone )
  1510                 TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
  1564                     {
  1511                 ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier9 << KFaultIdentifierShift );
  1565                     // Previously there were Kern::Alloc (allocating from kernel memory a block where copy from user was made now only
  1512                 TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1566                     // one copy from user to allocated block that is to be send.
  1513                 C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSendIndication 0x%x %d %d 0x%x" ), &sendBlock, sendBlock.Length(), msgLength, iChannelNumber ) );
  1567                     TDes8& sendBlock = iExtensionApi->AllocateBlock( msgLength );
  1514                 OstTraceExt4( TRACE_NORMAL, DUP8_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSendIndication;sendBlock=%x;sendBlock.Length()=%d;msgLength=%d;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.Length(), msgLength, iChannelNumber );
  1568                     ASSERT_RESET_ALWAYS( KErrNone == Kern::ThreadDesRead( iThread, firstParam, sendBlock, 0, KChunkShiftBy0 ), EIADDesReadFailed | EIADFaultIdentifier9 << KFaultIdentifierShift );
  1515                 // No return values check needed. Request completed with error value by multiplexer
  1569                     TRACE_ASSERT_INFO( sendBlock.Length() == msgLength, (TUint8)iChannelNumber << KChannelNumberShift );
  1516                 error = iExtensionApi->SendIndication( sendBlock, iChannelNumber );
  1570                     C_TRACE( ( _T( "DISAUserChannel::HandleSyncRequest EIADSendIndication 0x%x %d %d 0x%x" ), &sendBlock, sendBlock.Length(), msgLength, iChannelNumber ) );
  1517                 }
  1571                     OstTraceExt4( TRACE_NORMAL, DUP8_DISAUSERCHANNEL_HANDLESYNCREQUEST, "DISAUserChannel::HandleSyncRequest EIADSendIndication;sendBlock=%x;sendBlock.Length()=%d;msgLength=%d;iChannelNumber=%hx", (TUint)&sendBlock, sendBlock.Length(), msgLength, iChannelNumber );
  1518             else
  1572                     // No return values check needed. Request completed with error value by multiplexer
  1519                 {
  1573                     error = iExtensionApi->SendIndication( sendBlock, iChannelNumber );
  1520                 error = msgLength;
  1574                     }
  1521                 TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error );
  1575                 else
       
  1576                     {
       
  1577                     error = msgLength;
       
  1578                     TRACE_ASSERT_INFO( 0, (TUint8)iChannelNumber << KChannelNumberShift | (TUint16)error );
       
  1579                     }
  1522                 }
  1580                 }
  1523             break;
  1581             break;
  1524             }
  1582             }
  1525         case EIADGetMaxDataSize:
  1583         case EIADGetMaxDataSize:
  1526             {
  1584             {