diff -r f92a4f87e424 -r 012cc2ee6408 usbmgmt/usbmgr/host/fdf/production/server/src/fdf.cpp --- a/usbmgmt/usbmgr/host/fdf/production/server/src/fdf.cpp Tue Aug 31 17:01:47 2010 +0300 +++ b/usbmgmt/usbmgr/host/fdf/production/server/src/fdf.cpp Wed Sep 01 12:35:00 2010 +0100 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -25,16 +25,15 @@ #include "utils.h" #include #include "eventqueue.h" -#include "OstTraceDefinitions.h" -#ifdef OST_TRACE_COMPILER_IN_USE -#include "fdfTraces.h" + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, "fdf "); #endif - _LIT(KDriverUsbhubLddFileName,"usbhubdriver"); _LIT(KDriverUsbdiLddFileName,"usbdi"); -_LIT(KPanicCategory, "fdf"); +PANICCATEGORY("fdf"); const TUint KVendorSpecificDeviceClassValue = 0xFF; const TUint KVendorSpecificInterfaceClassValue = 0xFF; @@ -43,26 +42,24 @@ // Factory function for TInterfaceInfo objects. CFdf::TInterfaceInfo* CFdf::TInterfaceInfo::NewL(RPointerArray& aInterfaces) { - OstTraceFunctionEntry0( CFDF_TINTERFACEINFO_NEWL_ENTRY ); + LOG_STATIC_FUNC_ENTRY TInterfaceInfo* self = new(ELeave) TInterfaceInfo; CleanupStack::PushL(self); aInterfaces.AppendL(self); CLEANUPSTACK_POP1(self); - OstTraceFunctionExit0( CFDF_TINTERFACEINFO_NEWL_EXIT ); return self; } CFdf* CFdf::NewL() { - OstTraceFunctionEntry0( CFDF_NEWL_ENTRY ); + LOG_STATIC_FUNC_ENTRY CFdf* self = new(ELeave) CFdf; CleanupStack::PushL(self); self->ConstructL(); CLEANUPSTACK_POP1(self); - OstTraceFunctionExit0( CFDF_NEWL_EXIT ); return self; } @@ -70,30 +67,26 @@ : iDevices(_FOFF(CDeviceProxy, iLink)), iFunctionDrivers(_FOFF(CFdcProxy, iLink)) { - OstTraceFunctionEntry0( CFDF_CFDF_CONS_ENTRY ); + LOG_FUNC } void CFdf::ConstructL() { - OstTraceFunctionEntry0( CFDF_CONSTRUCTL_ENTRY ); - + LOG_FUNC + #ifndef __OVER_DUMMYUSBDI__ // If we're using the DummyUSBDI we don't need the real USBDI. TInt err = User::LoadLogicalDevice(KDriverUsbhubLddFileName); if ( err != KErrAlreadyExists ) { - LEAVEIFERRORL(err,OstTrace1( TRACE_NORMAL, CFDF_CONSTRUCTL, "Error when loading KDriverUsbhubLddFileName OVER DUMMYUSBDI; err=%d", err );); + LEAVEIFERRORL(err); } #endif // __OVER_DUMMYUSBDI__ - TInt errDr=iHubDriver.Open(); - LEAVEIFERRORL(errDr,OstTrace1( TRACE_NORMAL, CFDF_CONSTRUCTL_DUP1, "Error when open iHubDriver; errDr=%d", errDr );); + LEAVEIFERRORL(iHubDriver.Open()); #ifdef __OVER_DUMMYUSBDI__ - //LEAVEIFERRORL(iHubDriver.StartHost()); - TInt errHo=iHubDriver.StartHost(); - LEAVEIFERRORL(errHo,OstTrace1( TRACE_NORMAL, CFDF_CONSTRUCTL_DUP2, "Fail in iHubDriver.StartHost in dummy; errHo=%d", errHo );); - + LEAVEIFERRORL(iHubDriver.StartHost()); #endif iActiveWaitForBusEvent = CActiveWaitForBusEvent::NewL(iHubDriver, iBusEvent, *this); @@ -105,27 +98,24 @@ iActiveWaitForEComEvent->Wait(); iEventQueue = CEventQueue::NewL(*this); - OstTraceFunctionExit0( CFDF_CONSTRUCTL_EXIT ); } void CFdf::CreateFunctionDriverProxiesL() { - OstTraceFunctionEntry0( CFDF_CREATEFUNCTIONDRIVERPROXIESL_ENTRY ); + + LOG_FUNC REComSession::ListImplementationsL(TUid::Uid(KFdcEcomInterfaceUid), iImplInfoArray); const TUint count = iImplInfoArray.Count(); - OstTrace1( TRACE_NORMAL, CFDF_CREATEFUNCTIONDRIVERPROXIESL, "\tiImplInfoArray.Count() upon FDF creation = %d", count ); -#ifdef _DEBUG + LOGTEXT2(_L8("\tiImplInfoArray.Count() upon FDF creation = %d"), count); +#ifdef __FLOG_ACTIVE if ( count == 0 ) { - OstTrace0( TRACE_NORMAL, CFDF_CREATEFUNCTIONDRIVERPROXIESL_DUP1, "\tTHERE ARE NO FUNCTION DRIVERS PRESENT IN THE SYSTEM" ); - } + LOGTEXT(_L8("\tTHERE ARE NO FUNCTION DRIVERS PRESENT IN THE SYSTEM")); + } else { - for (TInt32 kk = 0; kk < count; ++kk) - OstTraceExt2( TRACE_NORMAL, CFDF_CREATEFUNCTIONDRIVERPROXIESL_DUP2, - "FDC implementation UID: 0x%08x Index:%d ", - iImplInfoArray[kk]->ImplementationUid().iUid, kk); - + for (TInt kk = 0; kk < count; ++kk) + LOGTEXT3(_L8("\t\tFDC implementation Index:%d UID: 0x%08x"), kk, iImplInfoArray[kk]->ImplementationUid()); } #endif @@ -141,12 +131,11 @@ else iFunctionDrivers.AddLast(*proxy); } - OstTraceFunctionExit0( CFDF_CREATEFUNCTIONDRIVERPROXIESL_EXIT ); } CFdf::~CFdf() { - OstTraceFunctionEntry0( CFDF_CFDF_DES_ENTRY ); + LOG_FUNC // Mimic the detachment of each attached device. TSglQueIter deviceIter(iDevices); @@ -155,7 +144,7 @@ while ( ( device = deviceIter++ ) != NULL ) { const TUint deviceId = device->DeviceId(); - OstTrace1( TRACE_NORMAL, CFDF_CFDF, "mimicking detachment of device with id %d", device ); + LOGTEXT2(_L8("\tmimicking detachment of device with id %d"), device); TellFdcsOfDeviceDetachment(deviceId); iDevices.Remove(*device); delete device; @@ -185,9 +174,10 @@ #ifndef __OVER_DUMMYUSBDI__ //If we're using the DummyUSBDI the real USBDI isn't loaded. TInt err = User::FreeLogicalDevice(KDriverUsbhubLddFileName); - OstTrace1( TRACE_NORMAL, CFDF_CFDF_DUP1, "FreeLogicalDevice( usbhubdriver ) returned %d", err ); + LOGTEXT2(_L8("\tFreeLogicalDevice( usbhubdriver ) returned %d"), err); + err = User::FreeLogicalDevice(KDriverUsbdiLddFileName); - OstTrace1( TRACE_NORMAL, CFDF_CFDF_DUP2, "FreeLogicalDevice( usbdi ) returned %d", err ); + LOGTEXT2(_L8("\tFreeLogicalDevice( usbdi ) returned %d"), err); #endif // __OVER_DUMMYUSBDI__ delete iEventQueue; @@ -195,33 +185,31 @@ // This is a worthwhile check to do at this point. If we ever don't clean // up iInterfaces at the *right* time, then this will be easier to debug // than a memory leak. - if(!(iInterfaces.Count() == 0)) - { - OstTrace1( TRACE_FATAL, CFDF_CFDF_DUP3, "Memory leak from interface;Interface remains %d", iInterfaces.Count() ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(iInterfaces.Count() == 0); iImplInfoArray.ResetAndDestroy(); REComSession::FinalClose(); - OstTraceFunctionExit0( CFDF_CFDF_DES_EXIT ); } void CFdf::EnableDriverLoading() { - OstTraceFunctionEntry0( CFDF_ENABLEDRIVERLOADING_ENTRY ); + LOG_FUNC + iDriverLoadingEnabled = ETrue; } void CFdf::DisableDriverLoading() { - OstTraceFunctionEntry0( CFDF_DISABLEDRIVERLOADING_ENTRY ); + LOG_FUNC + iDriverLoadingEnabled = EFalse; } void CFdf::SetSession(CFdfSession* aSession) { - OstTraceFunctionEntry0( CFDF_SETSESSION_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_SETSESSION, "aSession = 0x%08x", aSession ); + LOG_FUNC + LOGTEXT2(_L8("\taSession = 0x%08x"), aSession); + iSession = aSession; } @@ -232,27 +220,17 @@ TBool CFdf::GetDeviceEvent(TDeviceEvent& aEvent) { - OstTraceFunctionEntry0( CFDF_GETDEVICEEVENT_ENTRY ); - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_GETDEVICEEVENT, "iEventQueue is empty" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + LOG_FUNC + ASSERT_DEBUG(iEventQueue); return iEventQueue->GetDeviceEvent(aEvent); } TBool CFdf::GetDevmonEvent(TInt& aEvent) { - OstTraceFunctionEntry0( CFDF_GETDEVMONEVENT_ENTRY ); - - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_GETDEVMONEVENT, "iEventQueue is empty" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + LOG_FUNC - + ASSERT_DEBUG(iEventQueue); return iEventQueue->GetDevmonEvent(aEvent); } @@ -268,39 +246,40 @@ void CFdf::HandleEComEventReceivedL() { - OstTraceFunctionEntry0( CFDF_HANDLEECOMEVENTRECEIVEDL_ENTRY ); - + LOG_FUNC + // There is no way to filter ecom notification to only receive ones we are interested in, also there is no way // to query ecom as to what has changed. Hence there is no option but to call ListImplementations(). iImplInfoArray.ResetAndDestroy(); REComSession::ListImplementationsL(TUid::Uid(KFdcEcomInterfaceUid), iImplInfoArray); TUint implementationsCount = iImplInfoArray.Count(); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL, "iImplInfoArray.Count() after ECom notification= %d", implementationsCount ); + LOGTEXT2(_L8("\tiImplInfoArray.Count() after ECom notification= %d"), implementationsCount); +#ifdef __FLOG_ACTIVE if ( implementationsCount == 0 ) { - OstTrace0( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP1, "THERE ARE NO FUNCTION DRIVERS PRESENT IN THE SYSTEM" ); - } + LOGTEXT(_L8("\tTHERE ARE NO FUNCTION DRIVERS PRESENT IN THE SYSTEM")); + } TSglQueIter proxiesIterDebug(iFunctionDrivers); CFdcProxy* fdcDebug = NULL; while ( ( fdcDebug = proxiesIterDebug++ ) != NULL ) { TUid fdcUid = fdcDebug->ImplUid(); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP2, "Old FDC Proxy implementation UID: 0x%08x", fdcUid.iUid ); + LOGTEXT2(_L8("\t\tOld FDC Proxy implementation UID: 0x%08x"), fdcUid.iUid); TInt fdcVersion = fdcDebug->Version(); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP3, "FDC Proxy version UID: %d", fdcVersion ); - } - OstTrace0( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP4, "------------------------------------------------------------------" ); - + LOGTEXT2(_L8("\t\tFDC Proxy version UID: %d"), fdcVersion); + } + LOGTEXT(_L8("\t\t------------------------------------------------------------------")); for (TInt kk = 0; kk < implementationsCount; ++kk) { TUid fdcUid2 = iImplInfoArray[kk]->ImplementationUid(); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP5, "New FDC Proxy implementation UID: 0x%08x", fdcUid2.iUid ); + LOGTEXT2(_L8("\t\tNew FDC Proxy implementation UID: 0x%08x"), fdcUid2.iUid); TInt fdcVersion2 = iImplInfoArray[kk]->Version(); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEECOMEVENTRECEIVEDL_DUP6, "FDC Proxy version UID: %d", fdcVersion2 ); + LOGTEXT2(_L8("\t\tFDC Proxy version UID: %d"), fdcVersion2); } +#endif // See if any relevant FDCs (or upgrades) have been installed or uninstalled: @@ -400,16 +379,15 @@ iFunctionDrivers.AddLast(*proxy); } } - OstTraceFunctionExit0( CFDF_HANDLEECOMEVENTRECEIVEDL_EXIT ); } // A bus event has occurred. void CFdf::MbeoBusEvent() { - OstTraceFunctionEntry0( CFDF_MBEOBUSEVENT_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_MBEOBUSEVENT, "iBusEvent.iEventType = %d", iBusEvent.iEventType ); - OstTrace1( TRACE_NORMAL, CFDF_MBEOBUSEVENT_DUP1, "iBusEvent.iError = %d", iBusEvent.iError ); - OstTrace1( TRACE_NORMAL, CFDF_MBEOBUSEVENT_DUP2, "iBusEvent.iDeviceHandle = %d", iBusEvent.iDeviceHandle ); + LOG_FUNC + LOGTEXT2(_L8("\tiBusEvent.iEventType = %d"), iBusEvent.iEventType); + LOGTEXT2(_L8("\tiBusEvent.iError = %d"), iBusEvent.iError); + LOGTEXT2(_L8("\tiBusEvent.iDeviceHandle = %d"), iBusEvent.iDeviceHandle); switch ( iBusEvent.iEventType ) { @@ -422,11 +400,7 @@ else { // It was an attachment failure. Simply tell the event queue. - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_MBEOBUSEVENT_DUP3, "Empty iEventQueue" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(iEventQueue); iEventQueue->AttachmentFailure(iBusEvent.iError); } break; @@ -436,12 +410,7 @@ // pseudo-detached due to an overcurrent condition (for instance) then // the overcurrent condition is indicated through the devmon API (i.e. // EDevMonEvent) and the detachment is still 'KErrNone'. - if(!(iBusEvent.iError == KErrNone)) - { - OstTrace0( TRACE_NORMAL, CFDF_MBEOBUSEVENT_DUP4, "iBusEvent error" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(iBusEvent.iError == KErrNone); HandleDeviceDetachment(iBusEvent.iDeviceHandle); break; @@ -458,7 +427,6 @@ // TBusEvent from the previous completion. (Otherwise it might get // overwritten.) iActiveWaitForBusEvent->Wait(); - OstTraceFunctionExit0( CFDF_MBEOBUSEVENT_EXIT ); } // This is the central handler for device attachment. @@ -467,21 +435,16 @@ // The second phase is driver loading. void CFdf::HandleDeviceAttachment(TUint aDeviceId) { - OstTraceFunctionEntry0( CFDF_HANDLEDEVICEATTACHMENT_ENTRY ); + LOG_FUNC // This is filled in by HandleDeviceAttachmentL on success. CDeviceProxy* device; TRAPD(err, HandleDeviceAttachmentL(aDeviceId, device)); if ( err ) { - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENT, "err = %d", err ); + LOGTEXT2(_L8("\terr = %d"), err); // There was an attachment failure, so we just increment the count of // attachment failures. - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENT_DUP1, "Empty iEventQueue" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(iEventQueue); iEventQueue->AttachmentFailure(err); // If we failed the attachment phase, we can't try to load drivers for // the device. @@ -493,12 +456,7 @@ // device proxy created by HandleDeviceAttachmentL to the event queue. // This event object is always populated with the correct status and // error. - if(!device) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENT_DUP2, "Empty device" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(device); DoDriverLoading(*device); } @@ -507,90 +465,62 @@ // HandleDeviceAttachmentL. iCurrentDevice = NULL; iInterfaces.ResetAndDestroy(); - OstTraceFunctionExit0( CFDF_HANDLEDEVICEATTACHMENT_EXIT ); } // This does the 'device attachment' phase of the new device attachment only. void CFdf::HandleDeviceAttachmentL(TUint aDeviceId, CDeviceProxy*& aDevice) { - OstTraceFunctionEntry0( CFDF_HANDLEDEVICEATTACHMENTL_ENTRY ); + LOG_FUNC + // Create the device proxy aDevice = CDeviceProxy::NewL(iHubDriver, aDeviceId); CleanupStack::PushL(aDevice); iCurrentDevice = aDevice; // Get necessary descriptors (for this phase) - TInt err=aDevice->GetDeviceDescriptor(iDD); - if (err<0) - { - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL, "GetDeviceDescriptor error=%d", err ); - User::Leave(err); - } + LEAVEIFERRORL(aDevice->GetDeviceDescriptor(iDD)); + LOGTEXT2(_L8("\tiDD.USBBcd = 0x%04x"), iDD.USBBcd()); + LOGTEXT2(_L8("\tiDD.DeviceClass = 0x%02x"), iDD.DeviceClass()); + LOGTEXT2(_L8("\tiDD.DeviceSubClass = 0x%02x"), iDD.DeviceSubClass()); + LOGTEXT2(_L8("\tiDD.DeviceProtocol = 0x%02x"), iDD.DeviceProtocol()); + LOGTEXT2(_L8("\tiDD.MaxPacketSize0 = %d"), iDD.MaxPacketSize0()); + LOGTEXT2(_L8("\tiDD.VendorId = 0x%04x"), iDD.VendorId()); + LOGTEXT2(_L8("\tiDD.ProductId = 0x%04x"), iDD.ProductId()); + LOGTEXT2(_L8("\tiDD.DeviceBcd = 0x%04x"), iDD.DeviceBcd()); + LOGTEXT2(_L8("\tiDD.ManufacturerIndex = %d"), iDD.ManufacturerIndex()); + LOGTEXT2(_L8("\tiDD.ProductIndex = %d"), iDD.ProductIndex()); + LOGTEXT2(_L8("\tiDD.SerialNumberIndex = %d"), iDD.SerialNumberIndex()); + LOGTEXT2(_L8("\tiDD.NumConfigurations = %d"), iDD.NumConfigurations()); + LEAVEIFERRORL(aDevice->GetConfigurationDescriptor(iCD)); + LOGTEXT2(_L8("\tiCD.TotalLength = %d"), iCD.TotalLength()); + LOGTEXT2(_L8("\tiCD.NumInterfaces = %d"), iCD.NumInterfaces()); + LOGTEXT2(_L8("\tiCD.ConfigurationValue = %d"), iCD.ConfigurationValue()); + LOGTEXT2(_L8("\tiCD.ConfigurationIndex = %d"), iCD.ConfigurationIndex()); + LOGTEXT2(_L8("\tiCD.Attributes = %d"), iCD.Attributes()); + LOGTEXT2(_L8("\tiCD.MaxPower = %d"), iCD.MaxPower()); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP1, "iDD.USBBcd = 0x%04x", iDD.USBBcd() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP2, "iDD.DeviceClass = 0x%02x", iDD.DeviceClass() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP3, "iDD.DeviceSubClass = 0x%02x", iDD.DeviceSubClass() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP4, "iDD.DeviceProtocol = 0x%02x", iDD.DeviceProtocol() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP5, "iDD.MaxPacketSize0 = %d", iDD.MaxPacketSize0() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP6, "iDD.VendorId = 0x%04x", iDD.VendorId() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP7, "iDD.ProductId = 0x%04x", iDD.ProductId() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP8, "iDD.DeviceBcd = 0x%04x", iDD.DeviceBcd() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP9, "iDD.ManufacturerIndex = %d", iDD.ManufacturerIndex() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP10, "iDD.ProductIndex = %d", iDD.ProductIndex() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP11, "iDD.SerialNumberIndex = %d", iDD.SerialNumberIndex() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP12, "iDD.NumConfigurations = %d", iDD.NumConfigurations() ); - err=aDevice->GetConfigurationDescriptor(iCD); - if(err<0) - { - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP13, "GetConfigurationDescriptor error=%d", err); - User::Leave(err); - } - - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP14, "iCD.TotalLength = %d", iCD.TotalLength() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP15, "iCD.NumInterfaces = %d", iCD.NumInterfaces() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP16, "iCD.ConfigurationValue = %d", iCD.ConfigurationValue() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP17, "iCD.ConfigurationIndex = %d", iCD.ConfigurationIndex() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP18, "iCD.Attributes = %d", iCD.Attributes() ); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP19, "iCD.MaxPower = %d", iCD.MaxPower() ); - const TUint8 numberOfInterfaces = iCD.NumInterfaces(); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP20, "numberOfInterfaces (field in config descriptor) = %d)", numberOfInterfaces ); + LOGTEXT2(_L8("\tnumberOfInterfaces (field in config descriptor) = %d)"), numberOfInterfaces); if ( numberOfInterfaces == 0 ) { - OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP21, "Error: Usb Configuration Has No Interfaces"); - User::Leave(KErrUsbConfigurationHasNoInterfaces); + LEAVEL(KErrUsbConfigurationHasNoInterfaces); } // Walk the configuration bundle. Collect information on each interface // (its number, class, subclass and protocol). This populates iInterfaces. - if(!(iInterfaces.Count() == 0)) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP22, "Error: Usb Configuration Has No Interfaces"); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - - if(!iCurrentDevice) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP23, "Empty iCurrentDevice"); - User::Panic(KPanicCategory,__LINE__); - } - + ASSERT_DEBUG(iInterfaces.Count() == 0); + ASSERT_ALWAYS(iCurrentDevice); ParseL(iCD); // Log iInterfaces. const TUint interfaceCount = iInterfaces.Count(); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP24, "interfaceCount (parsed from bundle) = %d", interfaceCount ); -#ifdef _DEBUG - OstTrace0( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP25, "Logging iInterfaces:"); + LOGTEXT2(_L8("\tinterfaceCount (parsed from bundle) = %d"), interfaceCount); +#ifdef __FLOG_ACTIVE + LOGTEXT(_L8("\tLogging iInterfaces:")); for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) { const TInterfaceInfo* ifInfo = iInterfaces[ii]; - if(!ifInfo) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP26, "Empty ifInfo"); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - - OstTraceExt5(TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP27, "\t\tiInterfaces[%d]: number %d, interface class 0x%02x subclass 0x%02x protocol 0x%02x", + ASSERT_DEBUG(ifInfo); + LOGTEXT6(_L8("\t\tiInterfaces[%d]: number %d, interface class 0x%02x subclass 0x%02x protocol 0x%02x"), ii, ifInfo->iNumber, ifInfo->iClass, @@ -599,13 +529,12 @@ ); } #endif - + // Check that the config's NumInterfaces is the same as the actual number // of interface descriptors we found. We rely on this later on. if ( numberOfInterfaces != interfaceCount ) { - OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP28, "KErrUsbInterfaceCountMismatch"); - User::Leave(KErrUsbInterfaceCountMismatch); + LEAVEL(KErrUsbInterfaceCountMismatch); } // Check that each interface number in iInterfaces is unique. @@ -614,25 +543,14 @@ for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) { const TInterfaceInfo* lhs = iInterfaces[ii]; - if(!lhs) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP29, "Empty lhs"); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(lhs); for ( TUint jj = ii+1 ; jj < interfaceCount ; ++jj ) { const TInterfaceInfo* rhs = iInterfaces[jj]; - if(!rhs) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP30, "Empty rhs"); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(rhs); if ( lhs->iNumber == rhs->iNumber ) { - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP31, "KErrUsbDuplicateInterfaceNumbers; iNumber=%d", lhs->iNumber); - User::Leave(KErrUsbDuplicateInterfaceNumbers); + LEAVEL(KErrUsbDuplicateInterfaceNumbers); } } } @@ -646,7 +564,7 @@ TInt err = User::LoadLogicalDevice(KDriverUsbdiLddFileName); if ( err != KErrAlreadyExists ) { - LEAVEIFERRORL(err,OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP32, "Load Logical Device error; error=%d", err);); + LEAVEIFERRORL(err); } } #endif // __OVER_DUMMYUSBDI__ @@ -657,31 +575,19 @@ iDevices.AddLast(*aDevice); // Also put an event on the event queue. TDeviceEvent* const attachmentEvent = aDevice->GetAttachmentEventObject(); - - if(!attachmentEvent) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP33, "Empty attachmentEvent"); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(attachmentEvent); attachmentEvent->iInfo.iVid = iDD.VendorId(); attachmentEvent->iInfo.iPid = iDD.ProductId(); attachmentEvent->iInfo.iError = KErrNone; - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEATTACHMENTL_DUP34, "Empty iEventQueue"); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(iEventQueue); iEventQueue->AddDeviceEvent(*attachmentEvent); - OstTrace1( TRACE_DUMP, CFDF_HANDLEDEVICEATTACHMENTL_DUP35, "***USB HOST STACK: SUCCESSFUL ATTACHMENT OF DEVICE (id %d)", aDeviceId ); - - OstTraceFunctionExit0( CFDF_HANDLEDEVICEATTACHMENTL_EXIT ); + LOGTEXT2(_L8("***USB HOST STACK: SUCCESSFUL ATTACHMENT OF DEVICE (id %d)"), aDeviceId); } void CFdf::DoDriverLoading(CDeviceProxy& aDevice) { - OstTraceFunctionEntry0( CFDF_DODRIVERLOADING_ENTRY ); + LOG_FUNC + // Leaving or returning from DoDriverLoadingL is the trigger to put the // 'driver loading' event object on the event queue. It must already have // been populated correctly (the actual error code it left with doesn't @@ -689,12 +595,7 @@ TRAP_IGNORE(DoDriverLoadingL(aDevice)); TDeviceEvent* const driverLoadingEvent = aDevice.GetDriverLoadingEventObject(); - if(!driverLoadingEvent) - { - OstTrace0( TRACE_FATAL, CFDF_DODRIVERLOADING, "Empty driverLoadingEvent" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(driverLoadingEvent); // The driver loading event object says whether driver loading succeeded // (all interfaces were claimed without error), partly succeeded (not all // interfaces were claimed without error), or failed (no interfaces were @@ -707,29 +608,22 @@ // power-saving reasons and is not critical. (void)aDevice.Suspend(); } - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_DODRIVERLOADING_DUP1, "Empty iEventQueue" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + ASSERT_DEBUG(iEventQueue); iEventQueue->AddDeviceEvent(*driverLoadingEvent); - OstTraceFunctionExit0( CFDF_DODRIVERLOADING_EXIT ); } void CFdf::DoDriverLoadingL(CDeviceProxy& aDevice) { - OstTraceFunctionEntry0( CFDF_DODRIVERLOADINGL_ENTRY ); + LOG_FUNC + // Check whether driver loading is enabled. if ( !iDriverLoadingEnabled ) { // Complete driver load failure scenario. aDevice.SetDriverLoadingEventData(EDriverLoadFailure, KErrUsbDriverLoadingDisabled); - - OstTrace1( TRACE_NORMAL, CFDF_DODRIVERLOADINGL, "Leave with error %d", KErrGeneral ); - User::Leave(KErrGeneral); - } + LEAVEL(KErrGeneral); + } // Set this member up so that when the FDC calls TokenForInterface we call @@ -755,8 +649,7 @@ if (aDevice.HasIADFlag() && !functionDriverFound) { aDevice.SetDriverLoadingEventData(EDriverLoadFailure, KErrUsbUnsupportedDevice); - OstTrace0( TRACE_NORMAL, CFDF_DODRIVERLOADINGL_DUP1, "Leave with function Driver not Found" ); - User::Leave(KErrGeneral); + LEAVEL(KErrGeneral); } // If a device FD is found then it is supposed to claim all the interfaces, if it didn't then report // a partial success but don't offer unclaimed interfaces to any other FD. @@ -774,19 +667,14 @@ // Whether all interfaces were taken, some, or none, collectedErr may have // an error in it or KErrNone. We use specific error codes in some cases. TUint unclaimedInterfaces = UnclaimedInterfaceCount(); - OstTrace1( TRACE_DUMP, CFDF_DODRIVERLOADINGL_DUP2, "unclaimedInterfaces = %d", unclaimedInterfaces ); - OstTrace1( TRACE_DUMP, CFDF_DODRIVERLOADINGL_DUP3, "anySuccess = %d", anySuccess ); - OstTrace1( TRACE_DUMP, CFDF_DODRIVERLOADINGL_DUP4, "collectedErr = %d", collectedErr ); - if(!(unclaimedInterfaces <= interfaceCount)) - { - OstTrace0( TRACE_FATAL, CFDF_DODRIVERLOADINGL_DUP5, "interface Count error" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - + LOGTEXT2(_L8("\tunclaimedInterfaces = %d"), unclaimedInterfaces); + LOGTEXT2(_L8("\tanySuccess = %d"), anySuccess); + LOGTEXT2(_L8("\tcollectedErr = %d"), collectedErr); + ASSERT_DEBUG(unclaimedInterfaces <= interfaceCount); if(iDeviceDetachedTooEarly) { - OstTrace0( TRACE_NORMAL, CFDF_DODRIVERLOADINGL_DUP6, "Device has been detached too early!" ); + LOGTEXT(_L8("\tDevice has been detached too early!")); iDeviceDetachedTooEarly = EFalse; // the choice of having the status to be EDriverLoadPartialSuccess // was not to clash with trying to suspend the device because @@ -802,7 +690,6 @@ SetFailureStatus(unclaimedInterfaces, interfaceCount, anySuccess, collectedErr, aDevice); }// iDeviceDetachedTooEarly - OstTraceFunctionExit0( CFDF_DODRIVERLOADINGL_EXIT ); } // Recursive function, originally called with the configuration descriptor. @@ -810,26 +697,26 @@ // bundle. void CFdf::ParseL(TUsbGenericDescriptor& aDesc) { - OstTraceFunctionEntry0( CFDF_PARSEL_ENTRY ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL, "&aDesc = 0x%08x", &aDesc ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP1, "aDesc.ibDescriptorType = %d", aDesc.ibDescriptorType ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP2, "aDesc.iFirstChild = 0x%08x", aDesc.iFirstChild ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP3, "aDesc.iNextPeer = 0x%08x", aDesc.iNextPeer ); - - if ( aDesc.ibDescriptorType == EInterface ) + LOG_FUNC + LOGTEXT2(_L8("\t&aDesc = 0x%08x"), &aDesc); + LOGTEXT2(_L8("\taDesc.ibDescriptorType = %d"), aDesc.ibDescriptorType); + LOGTEXT2(_L8("\taDesc.iFirstChild = 0x%08x"), aDesc.iFirstChild); + LOGTEXT2(_L8("\taDesc.iNextPeer = 0x%08x"), aDesc.iNextPeer); + + if ( aDesc.ibDescriptorType == EInterface ) { // Add interface information to collection, but only if it's alternate // setting 0. const TUsbInterfaceDescriptor& ifDesc = static_cast(aDesc); if ( ifDesc.AlternateSetting() == 0 ) // hard-coded '0' means the default (initial configuration) setting { - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP4, "ifDesc.InterfaceNumber = %d", ifDesc.InterfaceNumber() ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP5, "ifDesc.NumEndpoints = %d", ifDesc.NumEndpoints() ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP6, "ifDesc.InterfaceClass = 0x%02x", ifDesc.InterfaceClass() ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP7, "ifDesc.InterfaceSubClass = 0x%02x", ifDesc.InterfaceSubClass() ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP8, "ifDesc.InterfaceProtocol = 0x%02x", ifDesc.InterfaceProtocol() ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP9, "ifDesc.Interface = %d", ifDesc.Interface() ); - + LOGTEXT2(_L8("\tifDesc.InterfaceNumber = %d"), ifDesc.InterfaceNumber()); + LOGTEXT2(_L8("\tifDesc.NumEndpoints = %d"), ifDesc.NumEndpoints()); + LOGTEXT2(_L8("\tifDesc.InterfaceClass = 0x%02x"), ifDesc.InterfaceClass()); + LOGTEXT2(_L8("\tifDesc.InterfaceSubClass = 0x%02x"), ifDesc.InterfaceSubClass()); + LOGTEXT2(_L8("\tifDesc.InterfaceProtocol = 0x%02x"), ifDesc.InterfaceProtocol()); + LOGTEXT2(_L8("\tifDesc.Interface = %d"), ifDesc.Interface()); + TInterfaceInfo* ifInfo = TInterfaceInfo::NewL(iInterfaces); ifInfo->iNumber = ifDesc.InterfaceNumber(); ifInfo->iClass = ifDesc.InterfaceClass(); @@ -848,9 +735,10 @@ { // OTG descriptor found const TUsbOTGDescriptor& otgDesc = static_cast(aDesc); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP10, "otgDesc.Attributes = %d", otgDesc.Attributes() ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP11, "otgDesc.HNPSupported = %d", otgDesc.HNPSupported() ); - OstTrace1( TRACE_DUMP, CFDF_PARSEL_DUP12, "otgDesc.SRPSupported = %d", otgDesc.SRPSupported() ); + + LOGTEXT2(_L8("\totgDesc.Attributes = %b"), otgDesc.Attributes()); + LOGTEXT2(_L8("\totgDesc.HNPSupported = %d"), otgDesc.HNPSupported()); + LOGTEXT2(_L8("\totgDesc.SRPSupported = %d"), otgDesc.SRPSupported()); iCurrentDevice->SetOtgDescriptorL(otgDesc); } @@ -866,7 +754,6 @@ { ParseL(*nextPeer); } - OstTraceFunctionExit0( CFDF_PARSEL_EXIT ); } // Method that uses only one array to hold the unclaimed interface numbers. @@ -876,17 +763,13 @@ RArray& aInterfacesNumberArray, TInterfaceSearchKeys aKey) { - OstTraceFunctionEntry0( CFDF_FINDDRIVERSFORINTERFACESUSINGSPECIFICKEYL_ENTRY ); - + LOG_FUNC + const TUint interfaceCount = iInterfaces.Count(); for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) { TInterfaceInfo* ifInfo = iInterfaces[ii]; - if(!ifInfo) - { - OstTrace0( TRACE_FATAL, CFDF_FINDDRIVERSFORINTERFACESUSINGSPECIFICKEYL, "Empty ifInfo" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(ifInfo); if ((ifInfo->iClaimed) || (aKey == EVendorInterfacesubclassInterfaceprotocol && ifInfo->iClass != KVendorSpecificInterfaceClassValue)|| @@ -902,7 +785,8 @@ TBuf8 searchKey; FormatInterfaceSearchKey(searchKey, aKey, *ifInfo); - OstTraceExt1( TRACE_NORMAL, CFDF_FINDDRIVERSFORINTERFACESUSINGSPECIFICKEYL_DUP1, "searchKey = \"%S\"", searchKey ); + + LOGTEXT2(_L8("\tsearchKey = \"%S\""), &searchKey); // RArray* array = &aInterfacesNumberArray; FindDriverForInterfaceUsingSpecificKey(aDevice, aCollectedErr, aAnySuccess, aInterfacesNumberArray, searchKey); @@ -911,7 +795,6 @@ // the searching have been done. RebuildUnClaimedInterfacesArrayL(aDevice, aInterfacesNumberArray, ii+1); } - OstTraceFunctionExit0( CFDF_FINDDRIVERSFORINTERFACESUSINGSPECIFICKEYL_EXIT ); } @@ -925,8 +808,9 @@ RArray& aInterfacesGivenToFdc, const TDesC8& aSearchKey) { - OstTraceFunctionEntry0( CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_ENTRY ); - OstTraceExt1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY, "aSearchKey = \"%S\"", aSearchKey ); + + LOG_FUNC + LOGTEXT2(_L8("\taSearchKey = \"%S\""), &aSearchKey); // Find an FDC matching this search key. TSglQueIter iter(iFunctionDrivers); @@ -935,8 +819,7 @@ while ( ( fdc = iter++ ) != NULL ) { - OstTraceExt1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP1, "FDC's default_data field = \"%S\"", fdc->DefaultDataField() ); - + LOGTEXT2(_L8("\tFDC's default_data field = \"%S\""), &fdc->DefaultDataField()); #ifdef _DEBUG // having these two together in the debug window is helpful for interactive debugging TBuf8 fd_key; @@ -963,28 +846,27 @@ { aDevice.SetMultipleDriversFlag(); } - OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP2, "found matching FDC (0x%08x)", fdc ); - + + LOGTEXT2(_L8("\tfound matching FDC (0x%08x)"), fdc); +#ifdef __FLOG_ACTIVE const TUint count = aInterfacesGivenToFdc.Count(); - OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP3, "logging aInterfacesGivenToFdc (interfaces being offered to the FDC): count = %d", count ); + LOGTEXT2(_L8("\tlogging aInterfacesGivenToFdc (interfaces being offered to the FDC): count = %d"), count); for ( TUint ii = 0 ; ii < count ; ++ii ) { - OstTraceExt2( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP4, - "index %u: interface number %u", - ii, aInterfacesGivenToFdc[ii] ); - } + LOGTEXT3(_L8("\t\tindex %d: interface number %d"), ii, aInterfacesGivenToFdc[ii]); + } +#endif TInt err = fdc->NewFunction(aDevice.DeviceId(), aInterfacesGivenToFdc, iDD, iCD); - OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP5, "NewFunction returned %d", err ); - + LOGTEXT2(_L8("\tNewFunction returned %d"), err); // To correctly determine whether the driver load for the whole // configuration was a complete failure, a partial success or a // complete success, we need to collect any non-KErrNone error // from this, and whether any handovers worked at all. if ( err == KErrNone ) { - OstTraceExt2(TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP6, - "***USB HOST STACK: THE FOLLOWING INTERFACES OF DEVICE %u WERE SUCCESSFULLY PASSED TO FUNCTION DRIVER WITH IMPL UID 0x%08x", - (TInt32) aDevice.DeviceId(), fdc->ImplUid().iUid); +#ifdef __FLOG_ACTIVE + LOGTEXT3(_L8("***USB HOST STACK: THE FOLLOWING INTERFACES OF DEVICE %d WERE SUCCESSFULLY PASSED TO FUNCTION DRIVER WITH IMPL UID 0x%08x"), + aDevice.DeviceId(), fdc->ImplUid()); // We want to log each interface that's in // aInterfacesGivenToFdc AND is marked claimed in iInterfaces. for ( TUint ii = 0 ; ii < aInterfacesGivenToFdc.Count() ; ++ii ) @@ -993,20 +875,16 @@ for ( TUint jj = 0 ; jj < iInterfaces.Count() ; ++jj ) { const TInterfaceInfo* ifInfo = iInterfaces[jj]; - - if(!ifInfo) - { - OstTrace0( TRACE_FATAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP7, "Empty ifInfo" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(ifInfo); if ( ifNum == ifInfo->iNumber && ifInfo->iClaimed ) { - OstTrace1( TRACE_NORMAL, CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_DUP8, "***USB HOST STACK: bInterfaceNumber %d", ifNum ); + LOGTEXT2(_L8("***USB HOST STACK: bInterfaceNumber %d"), ifNum); } } } +#endif aAnySuccess = ETrue; } else @@ -1017,13 +895,13 @@ break; } } - OstTraceFunctionExit0( CFDF_FINDDRIVERFORINTERFACEUSINGSPECIFICKEY_EXIT ); } void CFdf::HandleDeviceDetachment(TUint aDeviceId) { - OstTraceFunctionEntry0( CFDF_HANDLEDEVICEDETACHMENT_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT, "aDeviceId = %d", aDeviceId ); + LOG_FUNC + LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); + #ifdef _DEBUG TBool found = EFalse; @@ -1041,24 +919,16 @@ #ifdef _DEBUG found = ETrue; #endif - OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP1, "found matching device proxy" ); - + LOGTEXT(_L8("\tfound matching device proxy")); + iDevices.Remove(*device); // Before destroying the device proxy, take the detachment event // stored in it for the event queue. TDeviceEvent* const detachmentEvent = device->GetDetachmentEventObject(); - if(!detachmentEvent) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEDETACHMENT_DUP2, "Empty detachmentEvent" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVICEDETACHMENT_DUP3, "Empty iEventQueue" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(detachmentEvent); + ASSERT_DEBUG(iEventQueue); iEventQueue->AddDeviceEvent(*detachmentEvent); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP4, "***USB HOST STACK: DETACHMENT OF DEVICE (id %d)", aDeviceId ); + LOGTEXT2(_L8("***USB HOST STACK: DETACHMENT OF DEVICE (id %d)"), aDeviceId); delete device; TellFdcsOfDeviceDetachment(aDeviceId); @@ -1069,7 +939,7 @@ if (iDevices.IsEmpty()) { TInt err = User::FreeLogicalDevice(KDriverUsbdiLddFileName); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP5, "FreeLogicalDevice( usbdi ) returned %d", err ); + LOGTEXT2(_L8("\tFreeLogicalDevice( usbdi ) returned %d"), err); } #endif // __OVER_DUMMYUSBDI__ @@ -1080,32 +950,25 @@ #ifdef _DEBUG if ( !found ) { - OstTrace0( TRACE_NORMAL, CFDF_HANDLEDEVICEDETACHMENT_DUP6, "no matching device proxy found" ); + LOGTEXT(_L8("\tno matching device proxy found")); } #endif - - OstTraceFunctionExit0( CFDF_HANDLEDEVICEDETACHMENT_EXIT ); } void CFdf::HandleDevmonEvent(TInt aEvent) { - OstTraceFunctionEntry0( CFDF_HANDLEDEVMONEVENT_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_HANDLEDEVMONEVENT, "aEvent = %d", aEvent ); + LOG_FUNC + LOGTEXT2(_L8("\taEvent = %d"), aEvent); - if(!iEventQueue) - { - OstTrace0( TRACE_FATAL, CFDF_HANDLEDEVMONEVENT_DUP1, "Empty iEventQueue" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(iEventQueue); iEventQueue->AddDevmonEvent(aEvent); - OstTraceFunctionExit0( CFDF_HANDLEDEVMONEVENT_EXIT ); } void CFdf::TellFdcsOfDeviceDetachment(TUint aDeviceId) { - OstTraceFunctionEntry0( CFDF_TELLFDCSOFDEVICEDETACHMENT_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_TELLFDCSOFDEVICEDETACHMENT, "aDeviceId = %d", aDeviceId ); - + LOG_FUNC + LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); + TSglQueIter iter(iFunctionDrivers); iter.SetToFirst(); CFdcProxy* fdc; @@ -1119,14 +982,12 @@ } } - OstTraceFunctionExit0( CFDF_TELLFDCSOFDEVICEDETACHMENT_EXIT ); } TUint32 CFdf::TokenForInterface(TUint8 aInterface) { - OstTraceFunctionEntry0( CFDF_TOKENFORINTERFACE_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_TOKENFORINTERFACE, "aInterface = %d", aInterface ); - + LOG_FUNC + LOGTEXT2(_L8("\taInterface = %d"), aInterface); TUint32 token = 0; // Check that the interface was in the array given to the FD and mark it @@ -1136,37 +997,21 @@ for ( TUint ii = 0 ; ii < interfaceCount ; ++ii ) { TInterfaceInfo* ifInfo = iInterfaces[ii]; - if(!ifInfo) - { - OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP1, "Empty ifInfo" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(ifInfo); if ( ifInfo->iNumber == aInterface ) { found = ETrue; // The FDC tried to claim an interface that was already claimed. - if(ifInfo->iClaimed) - { - OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP2, "iClaimed error" ); - User::Panic(KPanicCategory,__LINE__); - } + ASSERT_ALWAYS(!ifInfo->iClaimed); ifInfo->iClaimed = ETrue; break; } } // Could not find interface in the interface array- the FDC tried to claim // an interface it had not been offered. - if(!found) - { - OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP3, "not found" ); - User::Panic(KPanicCategory,__LINE__); - } + ASSERT_ALWAYS(found); - if(!iCurrentDevice) - { - OstTrace0( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP4, "Empty iCurrentDevice" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(iCurrentDevice); // GetTokenForInterface will return error in the following cases: // 1/ KErrBadHandle: invalid device handle (the CDeviceProxy asserts that @@ -1194,23 +1039,21 @@ break; default: - OstTraceExt2( TRACE_FATAL, CFDF_TOKENFORINTERFACE_DUP5, "Unexpected error %d when requesting token for aInterface %d",err,aInterface); - User::Panic(KPanicCategory,__LINE__); + LOGTEXT3(_L8("\tUnexpected error %d when requesting token for aInterface %d"),err,aInterface); + ASSERT_ALWAYS(0); break; } - OstTraceExt2( TRACE_NORMAL, CFDF_TOKENFORINTERFACE_DUP6, - "Token for interface %hhu is = %u",aInterface, token); - - OstTraceFunctionExit0( CFDF_TOKENFORINTERFACE_EXIT ); + LOGTEXT3(_L8("\tToken for interface %d is = %d"),aInterface, token); + return token; } CDeviceProxy* CFdf::DeviceProxyL(TUint aDeviceId) const { - OstTraceFunctionEntry0( CFDF_DEVICEPROXYL_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_DEVICEPROXYL, "aDeviceId = %d", aDeviceId ); - + LOG_FUNC + LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); + TSglQueIter iter(const_cast(this)->iDevices); iter.SetToFirst(); CDeviceProxy* device = NULL; @@ -1218,74 +1061,66 @@ { if ( device->DeviceId() == aDeviceId ) { - OstTrace1( TRACE_NORMAL, CFDF_DEVICEPROXYL_DUP1, "device = 0x%08x", device ); - OstTraceFunctionExit0( CFDF_DEVICEPROXYL_EXIT ); + LOGTEXT2(_L8("\tdevice = 0x%08x"), device); return device; } } - OstTrace0( TRACE_NORMAL, CFDF_DEVICEPROXYL_DUP2, "KErrNotFound"); - User::Leave(KErrNotFound); - OstTraceFunctionExit0( CFDF_DEVICEPROXYL_EXIT_DUP1 ); + LEAVEL(KErrNotFound); return NULL; // avoid warning } const RArray& CFdf::GetSupportedLanguagesL(TUint aDeviceId) const { - OstTraceFunctionEntry0( CFDF_GETSUPPORTEDLANGUAGESL_ENTRY ); - OstTrace1( TRACE_NORMAL, CFDF_GETSUPPORTEDLANGUAGESL, "aDeviceId = %d", aDeviceId ); - + LOG_FUNC + LOGTEXT2(_L8("\taDeviceId = %d"), aDeviceId); + CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); return deviceProxy->GetSupportedLanguages(); } void CFdf::GetManufacturerStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const { - OstTraceFunctionEntry0( CFDF_GETMANUFACTURERSTRINGDESCRIPTORL_ENTRY ); - OstTraceExt2( TRACE_NORMAL, CFDF_GETMANUFACTURERSTRINGDESCRIPTORL, - "aDeviceId = %u, aLangId = 0x%08x", (TUint32)aDeviceId, aLangId ); - + LOG_FUNC + LOGTEXT3(_L8("\taDeviceId = %d, aLangId = 0x%04x"), aDeviceId, aLangId); + CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); deviceProxy->GetManufacturerStringDescriptorL(aLangId, aString); - OstTraceExt1( TRACE_NORMAL, CFDF_GETMANUFACTURERSTRINGDESCRIPTORL_DUP1, "aString = \"%S\"", aString ); - OstTraceFunctionExit0( CFDF_GETMANUFACTURERSTRINGDESCRIPTORL_EXIT ); + LOGTEXT2(_L("\taString = \"%S\""), &aString); } void CFdf::GetProductStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const { - OstTraceFunctionEntry0( CFDF_GETPRODUCTSTRINGDESCRIPTORL_ENTRY ); - OstTraceExt2( TRACE_NORMAL, CFDF_GETPRODUCTSTRINGDESCRIPTORL, - "aDeviceId = %u, aLangId = 0x%04x", (TUint32)aDeviceId, aLangId ); + LOG_FUNC + LOGTEXT3(_L8("\taDeviceId = %d, aLangId = 0x%04x"), aDeviceId, aLangId); CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); deviceProxy->GetProductStringDescriptorL(aLangId, aString); - OstTraceExt1( TRACE_NORMAL, CFDF_GETPRODUCTSTRINGDESCRIPTORL_DUP1, "aString = \"%S\"", aString ); - OstTraceFunctionExit0( CFDF_GETPRODUCTSTRINGDESCRIPTORL_EXIT ); + LOGTEXT2(_L("\taString = \"%S\""), &aString); } void CFdf::GetOtgDeviceDescriptorL(TInt aDeviceId, TOtgDescriptor& aDescriptor) const { - OstTraceFunctionEntry0( CFDF_GETOTGDEVICEDESCRIPTORL_ENTRY ); + LOG_FUNC DeviceProxyL(aDeviceId)->GetOtgDescriptorL(aDescriptor); - OstTraceFunctionExit0( CFDF_GETOTGDEVICEDESCRIPTORL_EXIT ); } void CFdf::GetSerialNumberStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const { - OstTraceFunctionEntry0( CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL_ENTRY ); - OstTraceExt2( TRACE_NORMAL, CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL, - "aDeviceId = %u, aLangId = 0x%08x", (TUint32)aDeviceId, aLangId ); + LOG_FUNC + LOGTEXT3(_L8("\taDeviceId = %d, aLangId = 0x%04x"), aDeviceId, aLangId); CDeviceProxy* deviceProxy = DeviceProxyL(aDeviceId); deviceProxy->GetSerialNumberStringDescriptorL(aLangId, aString); - OstTraceExt1( TRACE_NORMAL, CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL_DUP1, "aString = \"%S\"", aString ); - OstTraceFunctionExit0( CFDF_GETSERIALNUMBERSTRINGDESCRIPTORL_EXIT ); + LOGTEXT2(_L("\taString = \"%S\""), &aString); } void CFdf::SearchForInterfaceFunctionDriversL(CDeviceProxy& aDevice, TBool& aAnySuccess, TInt& aCollectedErr) { RArray interfacesNumberArray; CleanupClosePushL(interfacesNumberArray); + + for ( TUint ii = 0 ; ii < iInterfaces.Count() ; ++ii ) { @@ -1337,9 +1172,8 @@ TInt err = aArray.Append(aInterfaceNo); if ( err ) { - aDevice.SetDriverLoadingEventData(EDriverLoadFailure, err); - OstTrace1( TRACE_NORMAL, CFDF_APPENDINTERFACENUMBERTOARRAYL, "Leave with error: %d", err ); - User::Leave(err); + aDevice.SetDriverLoadingEventData(EDriverLoadFailure, err); + LEAVEL(err); } } @@ -1381,15 +1215,15 @@ { if (fdc->MarkedForDeletion()) continue; - OstTraceExt1( TRACE_NORMAL, CFDF_SEARCHFORADEVICEFUNCTIONDRIVERL, "FDC's default_data field = \"%S\"", fdc->DefaultDataField()); - + LOGTEXT2(_L8("\tFDC's default_data field = \"%S\""), &fdc->DefaultDataField()); +#ifdef _DEBUG // having these two together in the debug window is helpful for interactive debugging TBuf8 fd_key; fd_key.Append(fdc->DefaultDataField().Ptr(), fdc->DefaultDataField().Length() > KMaxSearchKeyLength ? KMaxSearchKeyLength : fdc->DefaultDataField().Length()); TBuf8 search_key; search_key.Append(searchKeyString.Ptr(), searchKeyString.Length() > KMaxSearchKeyLength ? KMaxSearchKeyLength : searchKeyString.Length()); TInt version = fdc->Version(); - +#endif if (searchKeyString.CompareF(fdc->DefaultDataField()) == 0) { @@ -1407,9 +1241,9 @@ } foundFdc = ETrue; - OstTrace1( TRACE_NORMAL, CFDF_SEARCHFORADEVICEFUNCTIONDRIVERL_DUP1, "found matching FDC (0x%08x)", fdc ); + LOGTEXT2(_L8("\tfound matching FDC (0x%08x)"), fdc); TInt err = fdc->NewFunction(aDevice.DeviceId(), interfaces, iDD, iCD); - OstTrace1( TRACE_NORMAL, CFDF_SEARCHFORADEVICEFUNCTIONDRIVERL_DUP2, "NewFunction returned %d", err); + LOGTEXT2(_L8("\tNewFunction returned %d"), err); // To correctly determine whether the driver load for the whole // configuration was a complete failure, a partial success or a // complete success, we need to collect any non-KErrNone error @@ -1457,8 +1291,7 @@ // void CFdf::FormatDeviceSearchKey(TDes8& aSearchKey, TDeviceSearchKeys aDeviceSearchKeys) { - OstTraceFunctionEntry0( CFDF_FORMATDEVICESEARCHKEY_ENTRY ); - + LOG_FUNC switch (aDeviceSearchKeys) { case EVendorProductDevice: @@ -1498,13 +1331,12 @@ break; } default: - { - OstTrace1( TRACE_FATAL, CFDF_FORMATDEVICESEARCHKEY, "Invalid aDeviceSearchKeys=%d", aDeviceSearchKeys ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); + { + ASSERT_DEBUG(EFalse); } } - OstTraceExt1( TRACE_NORMAL, CFDF_FORMATDEVICESEARCHKEY_DUP1, "aSearchKey = \"%s\"", aSearchKey ); - OstTraceFunctionExit0( CFDF_FORMATDEVICESEARCHKEY_EXIT ); + + LOGTEXT2(_L8("\taSearchKey = \"%S\""), &aSearchKey); } @@ -1516,8 +1348,7 @@ // void CFdf::FormatInterfaceSearchKey(TDes8& aSearchKey, TInterfaceSearchKeys aSearchKeys, const TInterfaceInfo& aIfInfo) { - OstTraceFunctionEntry0( CFDF_FORMATINTERFACESEARCHKEY_ENTRY ); - + LOG_FUNC switch (aSearchKeys) { case EVendorProductDeviceConfigurationvalueInterfacenumber: @@ -1558,37 +1389,28 @@ } default: { - OstTrace1( TRACE_FATAL, CFDF_FORMATINTERFACESEARCHKEY, "Invalid aSearchKeys=%d", aSearchKeys ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); + ASSERT_DEBUG(EFalse); } } - OstTraceExt1( TRACE_NORMAL, CFDF_FORMATINTERFACESEARCHKEY_DUP1, "aSearchKey = \"%s\"", aSearchKey ); - OstTraceFunctionExit0( CFDF_FORMATINTERFACESEARCHKEY_EXIT ); + LOGTEXT2(_L8("\taSearchKey = \"%S\""), &aSearchKey); } TUint CFdf::UnclaimedInterfaceCount() const { - OstTraceFunctionEntry0( CFDF_UNCLAIMEDINTERFACECOUNT_ENTRY ); - + LOG_FUNC TUint unclaimedInterfaces = 0; for ( TUint ii = 0 ; ii < iInterfaces.Count() ; ++ii ) { TInterfaceInfo* ifInfo = iInterfaces[ii]; - - if(!ifInfo) - { - OstTrace0( TRACE_FATAL, CFDF_UNCLAIMEDINTERFACECOUNT, "Empty ifInfo" ); - __ASSERT_DEBUG(EFalse,User::Panic(KPanicCategory,__LINE__)); - } + ASSERT_DEBUG(ifInfo); if ( !ifInfo->iClaimed ) { - OstTrace1( TRACE_NORMAL, CFDF_UNCLAIMEDINTERFACECOUNT_DUP1, "unclaimed interface: ifInfo->iNumber = %d", ifInfo->iNumber ); + LOGTEXT2(_L8("\tunclaimed interface: ifInfo->iNumber = %d"), ifInfo->iNumber); ++unclaimedInterfaces; } } - OstTrace1( TRACE_NORMAL, CFDF_UNCLAIMEDINTERFACECOUNT_DUP2, "unclaimedInterfaces = \"%d\"", unclaimedInterfaces ); - OstTraceFunctionExit0( CFDF_UNCLAIMEDINTERFACECOUNT_EXIT ); + LOGTEXT2(_L("\tunclaimedInterfaces = \"%d\""), unclaimedInterfaces); return unclaimedInterfaces; }