--- a/usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/AcmPortFactory.cpp Tue Aug 31 17:01:47 2010 +0300
+++ b/usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/AcmPortFactory.cpp Wed Sep 01 12:35:00 2010 +0100
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 1997-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"
@@ -15,20 +15,20 @@
*
*/
-#include <acminterface.h>
#include "AcmPortFactory.h"
#include "AcmUtils.h"
+#include <acminterface.h>
#include "AcmPort.h"
#include "AcmPanic.h"
#include "acmserver.h"
#include "CdcAcmClass.h"
+#include <usb/usblogger.h>
#include "c32comm_internal.h"
-#include "OstTraceDefinitions.h"
-#ifdef OST_TRACE_COMPILER_IN_USE
-#include "AcmPortFactoryTraces.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "ECACM");
#endif
-
// Do not move this into a header file. It must be kept private to the CSY. It
// is the secret information that enables the old (registration port)
// mechanism allowing the USB Manager to set up ACM interfaces.
@@ -41,12 +41,12 @@
* @return Ownership of a newly created CAcmPortFactory object
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_NEWL_ENTRY );
+ LOG_STATIC_FUNC_ENTRY
+
CAcmPortFactory* self = new(ELeave) CAcmPortFactory;
CleanupClosePushL(*self);
self->ConstructL();
CleanupStack::Pop();
- OstTraceFunctionExit0( CACMPORTFACTORY_NEWL_EXIT );
return self;
}
@@ -55,14 +55,12 @@
* Constructor.
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_CACMPORTFACTORY_ENTRY );
iVersion = TVersion(
KEC32MajorVersionNumber,
KEC32MinorVersionNumber,
KEC32BuildVersionNumber);
iConfigBuf().iAcmConfigVersion = 1;
iOwned = EFalse;
- OstTraceFunctionExit0( CACMPORTFACTORY_CACMPORTFACTORY_EXIT );
}
void CAcmPortFactory::ConstructL()
@@ -70,58 +68,29 @@
* Second phase constructor.
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_CONSTRUCTL_ENTRY );
- TInt aReason = SetName(&KAcmSerialName);
- if (aReason < 0)
- {
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_CONSTRUCTL, "CAcmPortFactory::ConstructL;aReason=%d", aReason );
- User::Leave(aReason);
- }
-
+ LEAVEIFERRORL(SetName(&KAcmSerialName));
iAcmServer = CAcmServer::NewL(*this);
TInt err = RProperty::Define(KUidSystemCategory, KAcmKey, RProperty::EByteArray, TPublishedAcmConfigs::KAcmMaxFunctions);
if(err == KErrAlreadyExists)
{
- aReason = iAcmProperty.Attach(KUidSystemCategory, KAcmKey, EOwnerThread);
- if (aReason < 0)
- {
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_CONSTRUCTL_DUP1, "CAcmPortFactory::ConstructL;aReason=%d", aReason );
- User::Leave(aReason);
- }
-
+ LEAVEIFERRORL(iAcmProperty.Attach(KUidSystemCategory, KAcmKey, EOwnerThread));
//Since the P&S data already exists we need to retrieve it
- aReason = iAcmProperty.Get(iConfigBuf);
- if (aReason < 0)
- {
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_CONSTRUCTL_DUP2, "CAcmPortFactory::ConstructL;aReason=%d", aReason );
- User::Leave(aReason);
- }
+ LEAVEIFERRORL(iAcmProperty.Get(iConfigBuf));
}
else if(err == KErrNone)
{
//A blank iConfigBuf already exists at this point to we don't need to do anything to it
//before publishing the P&S data
- aReason = iAcmProperty.Attach(KUidSystemCategory, KAcmKey, EOwnerThread);
- if (aReason < 0)
- {
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_CONSTRUCTL_DUP3, "CAcmPortFactory::ConstructL;aReason=%d", aReason );
- User::Leave(aReason);
- }
+ LEAVEIFERRORL(iAcmProperty.Attach(KUidSystemCategory, KAcmKey, EOwnerThread));
PublishAcmConfig();
iOwned = ETrue;
}
else
{
- if (err < 0)
- {
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_CONSTRUCTL_DUP4, "CAcmPortFactory::ConstructL;err=%d", err );
- User::Leave(err);
- }
- //Here will always leave, but a log will be created at least.
+ LEAVEIFERRORL(err); //This will always leave, but a log will be created at least.
}
- OstTraceFunctionExit0( CACMPORTFACTORY_CONSTRUCTL_EXIT );
}
/**
@@ -132,14 +101,7 @@
{
// Update the publish and subscribe info
TInt err = iAcmProperty.Set(iConfigBuf);
- if (err != KErrNone)
- {
- OstTraceExt3( TRACE_NORMAL, CACMPORTFACTORY_PUBLISHACMCONFIG,
- "CAcmPortFactory::PublishAcmConfig;code=%d;name=%S;line = %d",
- (TInt)EPanicInternalError, KAcmPanicCat, (TInt)__LINE__);
- __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
- }
-
+ __ASSERT_DEBUG(err == KErrNone, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
(void)err;
}
@@ -153,7 +115,8 @@
*/
//return the security policy for the given port number, aPort.
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_PORTPLATSECCAPABILITY_ENTRY );
+ LOG_FUNC
+
TSecurityPolicy securityPolicy;
if ( aPort == KRegistrationPortUnit )
{
@@ -163,7 +126,6 @@
{
securityPolicy = TSecurityPolicy(ECapabilityLocalServices);
}
- OstTraceFunctionExit0( CACMPORTFACTORY_PORTPLATSECCAPABILITY_EXIT );
return securityPolicy;
}
@@ -174,8 +136,9 @@
* @param aUnit The port number of the closing port.
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_ACMPORTCLOSED_ENTRY );
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_ACMPORTCLOSED, "CAcmPortFactory::AcmPortClosed;aUnit=%d", aUnit );
+ LOG_FUNC
+ LOGTEXT2(_L8("\taUnit = %d"), aUnit);
+
// I would assert that the calling port is stored in our array, but if we
// ran out of memory during CAcmPort::NewL, this function would be called
// from the port's destructor, but the slot in the port array would still
@@ -188,7 +151,6 @@
#ifdef _DEBUG
LogPortsAndFunctions();
#endif
- OstTraceFunctionExit0( CACMPORTFACTORY_ACMPORTCLOSED_EXIT );
}
CAcmPortFactory::~CAcmPortFactory()
@@ -196,7 +158,8 @@
* Destructor.
*/
{
- OstTraceFunctionEntry0( DUP1_CACMPORTFACTORY_CACMPORTFACTORY_ENTRY );
+ LOG_FUNC
+
// Delete ACM instances. We could assert that the ACM Class Controller has
// caused them all to be destroyed, but if we do that, and USBSVR panics
// while it's Started, it will result in C32 panicking too, which is
@@ -217,7 +180,6 @@
}
delete iAcmServer;
- OstTraceFunctionExit0( DUP1_CACMPORTFACTORY_CACMPORTFACTORY_EXIT );
}
CPort* CAcmPortFactory::NewPortL(const TUint aUnit)
@@ -227,9 +189,11 @@
* @param aUnit Port unit number
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_NEWPORTL_ENTRY );
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_NEWPORTL, "CAcmPortFactory::NewPortL;aUnit=%d", aUnit );
+ LOG_LINE
+ LOGTEXT2(_L8(">>CAcmPortFactory::NewPortL aUnit=%d"), aUnit);
+
CPort* port = NULL;
+
TUint lowerLimit = KAcmLowUnit; // This non-const TUint avoids compiler remarks (low-level warnings) for the following comparisons..
// ACM ports
if ( (aUnit >= lowerLimit) && aUnit < static_cast<TUint>( iAcmClassArray.Count()) + KAcmLowUnit)
@@ -240,12 +204,7 @@
const TUint index = aUnit - KAcmLowUnit;
if ( iAcmPortArray[index] )
{
- if (KErrInUse < 0)
- {
- OstTrace1( TRACE_ERROR, CACMPORTFACTORY_NEWPORTL_DUP2, "CAcmPortFactory::NewPortL;KErrInUse=%d", KErrInUse );
- User::Leave(KErrInUse);
- }
- // TODO: is this ever executed?
+ LEAVEIFERRORL(KErrInUse); // TODO: is this ever executed?
}
iAcmPortArray[index] = CAcmPort::NewL(aUnit, *this);
iAcmPortArray[index]->SetAcm( iAcmClassArray[index]);
@@ -258,18 +217,14 @@
}
else
{
- if (KErrAccessDenied < 0)
- {
- OstTrace1( TRACE_ERROR, CACMPORTFACTORY_NEWPORTL_DUP3, "CAcmPortFactory::NewPortL;KErrAccessDenied=%d", KErrAccessDenied );
- User::Leave(KErrAccessDenied);
- }
+ LEAVEIFERRORL(KErrAccessDenied);
}
#ifdef _DEBUG
LogPortsAndFunctions();
#endif
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_NEWPORTL_DUP1, "CAcmPortFactory::NewPortL;port=0x%08x", port );
- OstTraceFunctionExit0( CACMPORTFACTORY_NEWPORTL_EXIT );
+
+ LOGTEXT2(_L8("<<CAcmPortFactory::NewPortL port=0x%08x"), port);
return port;
}
@@ -282,8 +237,8 @@
* @param aNoAcms Number of ACM interfaces to destroy.
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_DESTROYFUNCTIONS_ENTRY );
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_DESTROYFUNCTIONS, "CAcmPortFactory::DestroyFunctions;aNoAcms=%d", aNoAcms );
+ LOGTEXT2(_L8(">>CAcmPortFactory::DestroyFunctions aNoAcms = %d"), aNoAcms);
+
#ifdef _DEBUG
CheckAcmArray();
#endif
@@ -315,8 +270,8 @@
CheckAcmArray();
LogPortsAndFunctions();
#endif
- OstTrace0( TRACE_NORMAL, CACMPORTFACTORY_DESTROYFUNCTIONS_DUP1, "CAcmPortFactory::DestroyFunctions;<<CAcmPortFactory::DestroyFunctions" );
- OstTraceFunctionExit0( CACMPORTFACTORY_DESTROYFUNCTIONS_EXIT );
+
+ LOGTEXT(_L8("<<CAcmPortFactory::DestroyFunctions"));
}
void CAcmPortFactory::CheckAcmArray()
@@ -325,16 +280,12 @@
* something valid. NB It is the ACM port array which may contain empty slots.
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_CHECKACMARRAY_ENTRY );
+ LOG_FUNC
+
for ( TUint ii = 0; ii < static_cast<TUint>( iAcmClassArray.Count()) ; ii++ )
{
- if (!iAcmClassArray[ii])
- {
- OstTraceExt2( TRACE_NORMAL, CACMPORTFACTORY_CHECKACMARRAY, "CAcmPortFactory::CheckAcmArray;code=%d;name=%S", (TInt)EPanicInternalError, KAcmPanicCat);
- __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
- }
+ __ASSERT_DEBUG( iAcmClassArray[ii], _USB_PANIC(KAcmPanicCat, EPanicInternalError));
}
- OstTraceFunctionExit0( CACMPORTFACTORY_CHECKACMARRAY_EXIT );
}
TInt CAcmPortFactory::CreateFunctions(const TUint aNoAcms, const TUint8 aProtocolNum, const TDesC16& aAcmControlIfcName, const TDesC16& aAcmDataIfcName)
@@ -347,8 +298,8 @@
* @param aAcmDataIfcName Data Interface Name or a null descriptor
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_CREATEFUNCTIONS_ENTRY );
- OstTraceExt4( TRACE_NORMAL, CACMPORTFACTORY_CREATEFUNCTIONS, "CAcmPortFactory::CreateFunctions;aNoAcms=%d;aProtocolNum=%d;aAcmControlIfcName=%S;aAcmDataIfcName=%S", (TInt)aNoAcms, (TInt)aProtocolNum, aAcmControlIfcName, aAcmDataIfcName );
+ LOGTEXT5(_L("\taNoAcms = %d, aProtocolNum = %d, Control Ifc Name = %S, Data Ifc Name = %S"),
+ aNoAcms, aProtocolNum, &aAcmControlIfcName, &aAcmDataIfcName);
#ifdef _DEBUG
CheckAcmArray();
@@ -359,7 +310,7 @@
// Create the ACM class instances.
for ( TUint ii = 0 ; ii < aNoAcms ; ii++ )
{
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_CREATEFUNCTIONS_DUP1, "CAcmPortFactory::CreateFunctions;\tabout to create ACM instance %d", ii );
+ LOGTEXT2(_L8("\tabout to create ACM instance %d"), ii);
TRAP(ret, CreateFunctionL(aProtocolNum, aAcmControlIfcName, aAcmDataIfcName));
if ( ret != KErrNone )
{
@@ -377,8 +328,7 @@
LogPortsAndFunctions();
#endif
- OstTrace1( TRACE_NORMAL, CACMPORTFACTORY_CREATEFUNCTIONS_DUP2, "CAcmPortFactory::CreateFunctions;ret=%d", ret );
- OstTraceFunctionExit0( CACMPORTFACTORY_CREATEFUNCTIONS_EXIT );
+ LOGTEXT2(_L8("<<CAcmPortFactory::CreateFunctions ret = %d"), ret);
return ret;
}
@@ -387,40 +337,26 @@
* Creates a single ACM function, appending it to the iAcmClassArray array.
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_CREATEFUNCTIONL_ENTRY );
- OstTraceExt2( TRACE_NORMAL, CACMPORTFACTORY_CREATEFUNCTIONL,
- "CAcmPortFactory::CreateFunctionL;\tiAcmPortArray.Count()=%d;iAcmClassArray.Count()=%d",
- iAcmPortArray.Count(), iAcmClassArray.Count() );
-
- OstTraceExt3( TRACE_NORMAL, CACMPORTFACTORY_CREATEFUNCTIONL_DUP1,
- "CAcmPortFactory::CreateFunctionL;aProtocolNum=%d;aAcmControlIfcName=%S;aAcmDataIfcName=%S",
- aProtocolNum, aAcmControlIfcName, aAcmDataIfcName );
+ LOG_FUNC
+
+ LOGTEXT3(_L8("\tiAcmPortArray.Count() = %d, iAcmClassArray.Count() = %d"),
+ iAcmPortArray.Count(), iAcmClassArray.Count());
+
+ LOGTEXT4(_L("\taProtocolNum = %d, Control Ifc Name = %S, Data Ifc Name = %S"),
+ aProtocolNum, &aAcmControlIfcName, &aAcmDataIfcName);
CCdcAcmClass* acm = CCdcAcmClass::NewL(aProtocolNum, aAcmControlIfcName, aAcmDataIfcName);
CleanupStack::PushL(acm);
// If there isn't already a slot in the ACM port array corresponding to
// this ACM interface instance, create one.
- TInt err;
if ( iAcmPortArray.Count() < iAcmClassArray.Count() + 1 )
{
- OstTrace0( TRACE_NORMAL, CACMPORTFACTORY_CREATEFUNCTIONL_DUP2,
- "CAcmPortFactory::CreateFunctionL;\tappending a slot to the ACM port array" );
- err = iAcmPortArray.Append(NULL);
- if (err < 0)
- {
- OstTrace1( TRACE_ERROR, CACMPORTFACTORY_CREATEFUNCTIONL_DUP4, "CAcmPortFactory::CreateFunctionL;err=%d", err );
- User::Leave(err);
- }
+ LOGTEXT(_L8("\tappending a slot to the ACM port array"));
+ LEAVEIFERRORL(iAcmPortArray.Append(NULL));
}
- err = iAcmClassArray.Append(acm);
- if (err < 0)
- {
- OstTrace1( TRACE_ERROR, CACMPORTFACTORY_CREATEFUNCTIONL_DUP5, "CAcmPortFactory::CreateFunctionL;err=%d", err );
- User::Leave(err);
- }
-
+ LEAVEIFERRORL(iAcmClassArray.Append(acm));
CleanupStack::Pop(acm);
// If there's an ACM port at the relevant index (held open from when USB
@@ -428,9 +364,7 @@
// interface.
if ( iAcmPortArray[iAcmClassArray.Count() - 1] )
{
- OstTraceExt2( TRACE_NORMAL, CACMPORTFACTORY_CREATEFUNCTIONL_DUP3,
- "CAcmPortFactory::CreateFunctionL;\tinforming CAcmPort instance %d of acm 0x%p",
- iAcmClassArray.Count() - 1, acm );
+ LOGTEXT3(_L8("\tinforming CAcmPort instance %d of acm 0x%08x"), iAcmClassArray.Count() - 1, acm);
iAcmPortArray[iAcmClassArray.Count() - 1]->SetAcm(acm);
}
@@ -439,7 +373,6 @@
iConfigBuf().iAcmCount++;
//don't update the p&s data here, do it in CreateFunctions after the construction of
//all the requested functions
- OstTraceFunctionExit0( CACMPORTFACTORY_CREATEFUNCTIONL_EXIT );
}
void CAcmPortFactory::Info(TSerialInfo& aSerialInfo)
@@ -449,17 +382,16 @@
* @param aSerialInfo where info will be written to
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_INFO_ENTRY );
// NB Our TSerialInfo does not advertise the existence of the registration
// port.
-
+ LOG_FUNC
+
_LIT(KSerialDescription, "USB Serial Port Emulation via ACM");
aSerialInfo.iDescription = KSerialDescription;
aSerialInfo.iName = KAcmSerialName;
aSerialInfo.iLowUnit = KAcmLowUnit;
aSerialInfo.iHighUnit = (iAcmPortArray.Count()==0) ? 0 : (iAcmPortArray.Count()-1);
// See comments in AcmInterface.h
- OstTraceFunctionExit0( CACMPORTFACTORY_INFO_EXIT );
}
void CAcmPortFactory::LogPortsAndFunctions()
@@ -479,24 +411,18 @@
* port open/closed history of the CSY.
*/
{
- OstTraceFunctionEntry0( CACMPORTFACTORY_LOGPORTSANDFUNCTIONS_ENTRY );
TUint ii;
// Log ACM functions and corresponding ports.
for ( ii = 0 ; ii < static_cast<TUint>( iAcmClassArray.Count()) ; ii++ )
{
- OstTraceExt4( TRACE_NORMAL, CACMPORTFACTORY_LOGPORTSANDFUNCTIONS,
- "CAcmPortFactory::LogPortsAndFunctions;\t iAcmClassArray[%d] = %p, iAcmPortArray[%d] = %p",
- (TInt)ii, iAcmClassArray[ii], (TInt)ii, iAcmPortArray[ii] );
+ LOGTEXT5(_L8("\t iAcmClassArray[%d] = 0x%08x, iAcmPortArray[%d] = 0x%08x"), ii, iAcmClassArray[ii], ii, iAcmPortArray[ii]);
}
// Log any ports extending beyond where we currently have ACM interfaces.
for ( ; ii < static_cast<TUint>(iAcmPortArray.Count()) ; ii++ )
{
- OstTraceExt3( TRACE_NORMAL, CACMPORTFACTORY_LOGPORTSANDFUNCTIONS_DUP1,
- "CAcmPortFactory::LogPortsAndFunctions;\t iAcmClassArray[%d] = <no slot>, iAcmPortArray[%d] = %p",
- (TInt)ii, (TInt)ii, iAcmPortArray[ii] );
+ LOGTEXT4(_L8("\t iAcmClassArray[%d] = <no slot>, iAcmPortArray[%d] = 0x%08x"), ii, ii, iAcmPortArray[ii]);
}
- OstTraceFunctionExit0( CACMPORTFACTORY_LOGPORTSANDFUNCTIONS_EXIT );
}
//