diff -r 94f2adf59133 -r b2826f67641f userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbhostmsdevice.cpp --- a/userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbhostmsdevice.cpp Tue Oct 26 11:12:58 2010 +0100 +++ b/userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbhostmsdevice.cpp Tue Oct 26 12:49:20 2010 +0100 @@ -33,100 +33,95 @@ #include "cusbhostmsdevice.h" #include "cusbmssuspendresume.h" -#include "msdebug.h" -#include "debug.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "cusbhostmsdeviceTraces.h" +#endif CUsbHostMsDevice* CUsbHostMsDevice::NewL(THostMassStorageConfig& aConfig) { - __MSFNSLOG - CUsbHostMsDevice* r = new (ELeave) CUsbHostMsDevice(aConfig); - CleanupStack::PushL(r); - r->ConstructL(); - CleanupStack::Pop(); - return r; - } + CUsbHostMsDevice* r = new (ELeave) CUsbHostMsDevice(aConfig); + CleanupStack::PushL(r); + r->ConstructL(); + CleanupStack::Pop(); + return r; + } void CUsbHostMsDevice::ConstructL() { - __MSFNLOG - iTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iTimerRunning = EFalse; + iTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iTimerRunning = EFalse; } CUsbHostMsDevice::CUsbHostMsDevice(THostMassStorageConfig& aConfig) -: iConfig(aConfig), - iState(EReady) +: iConfig(aConfig), + iState(EReady) { - __MSFNLOG - } + } CUsbHostMsDevice::~CUsbHostMsDevice() { - __MSFNLOG - delete iTransport; - delete iDeviceSuspendResume; - if (iTimer && iTimerRunning) - { - iTimer->Cancel(); - } - delete iTimer; - } + delete iTransport; + delete iDeviceSuspendResume; + if (iTimer && iTimerRunning) + { + iTimer->Cancel(); + } + delete iTimer; + } MTransport* CUsbHostMsDevice::InitialiseTransportL(TTransportType aTransportId) { - __MSFNLOG - switch(aTransportId) + switch(aTransportId) { - case BulkOnlyTransport: - return CBulkOnlyTransport::NewL(iConfig.iInterfaceToken); - default: - // Panic; - __HOSTPRINT(_L("Unsupported Transport class requested")); - User::Leave(KErrNotSupported); - return NULL; + case BulkOnlyTransport: + return CBulkOnlyTransport::NewL(iConfig.iInterfaceToken); + default: + // Panic; + OstTrace0(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICE_10, + "Unsupported Transport class requested"); + User::Leave(KErrNotSupported); + return NULL; } } void CUsbHostMsDevice::InitialiseL(const RMessage2& aMessage) - { - __MSFNLOG - iTransport = InitialiseTransportL((TTransportType) iConfig.iTransportId); - TRAPD(r, iDeviceSuspendResume = CUsbMsIfaceSuspendResume::NewL(iTransport, this)); - if(r != KErrNone) - { - delete iTransport; - User::Leave(r); - } - iTransport->GetMaxLun(&iMaxLun, aMessage); - } + { + iTransport = InitialiseTransportL((TTransportType) iConfig.iTransportId); + TRAPD(r, iDeviceSuspendResume = CUsbMsIfaceSuspendResume::NewL(iTransport, this)); + if(r != KErrNone) + { + delete iTransport; + User::Leave(r); + } + iTransport->GetMaxLun(&iMaxLun, aMessage); + } void CUsbHostMsDevice::UnInitialiseL() { - __MSFNLOG - StopTimer(); + StopTimer(); iLuList.RemoveAllLuL(); } TInt CUsbHostMsDevice::AddLunL(TLun aLun) { - __MSFNLOG TInt r = KErrNone; - StartTimer(); + StartTimer(); CUsbHostMsLogicalUnit* lu = CUsbHostMsLogicalUnit::NewL(aLun); CleanupStack::PushL(lu); TRAP(r, lu->InitialiseProtocolL(aLun, iConfig, *iTransport)); - if (r == KErrNone) - { - TRAP(r, iLuList.AddLuL(lu)); - } + if (r == KErrNone) + { + TRAP(r, iLuList.AddLuL(lu)); + } if (r != KErrNone) { @@ -142,24 +137,21 @@ void CUsbHostMsDevice::RemoveLunL(TLun aLun) { - __MSFNLOG - if(iLuList.Count() <= 1) - StopTimer(); - iLuList.RemoveLuL(aLun); + if(iLuList.Count() <= 1) + StopTimer(); + iLuList.RemoveLuL(aLun); } void CUsbHostMsDevice::InitLunL(TLun aLun) - { - __MSFNLOG - CUsbHostMsLogicalUnit& lu = SetLunL(aLun); + { + CUsbHostMsLogicalUnit& lu = SetLunL(aLun); lu.InitL(); - } + } void CUsbHostMsDevice::SuspendLunL(TLun aLun) - { - __MSFNLOG + { if (IsSuspended()) { return; @@ -169,42 +161,40 @@ // check whether all the luns are suspended, if so then request usb // interface suspension to the transport layer - for (TInt i = 0; i < iLuList.Count(); i++) - { - CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); - if (!lu.IsReadyToSuspend() && lu.IsConnected()) - return; - } + for (TInt i = 0; i < iLuList.Count(); i++) + { + CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); + if (!lu.IsReadyToSuspend() && lu.IsConnected()) + return; + } - for (TInt i = 0; i < iLuList.Count(); i++) - { - CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); - SetLunL(lu); - lu.SuspendL(); - } + for (TInt i = 0; i < iLuList.Count(); i++) + { + CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); + SetLunL(lu); + lu.SuspendL(); + } - StopTimer(); - iDeviceSuspendResume->Suspend(); - iState = ESuspended; - } + StopTimer(); + iDeviceSuspendResume->Suspend(); + iState = ESuspended; + } void CUsbHostMsDevice::Resume(TRequestStatus& aStatus) - { - __MSFNLOG - if (iState == ESuspended) - { - StartTimer(); - iDeviceSuspendResume->Resume(aStatus); - } - } + { + if (iState == ESuspended) + { + StartTimer(); + iDeviceSuspendResume->Resume(aStatus); + } + } TLun CUsbHostMsDevice::GetAndSetLunL(const RMessage2& aMessage) - { - __MSFNLOG - // Subssessions need a positive value to store in the handles. We represent Luns as LunId+1 - // We represent LunId in MSC from 0 to MaxLun-1 as represented in BOT so subtract 1 from the Id + { + // Subssessions need a positive value to store in the handles. We represent Luns as LunId+1 + // We represent LunId in MSC from 0 to MaxLun-1 as represented in BOT so subtract 1 from the Id // received from RMessage TInt lun = aMessage.Int3() - 1; @@ -212,9 +202,9 @@ { User::Leave(KErrArgument); } - SetLunL(static_cast(lun)); - return static_cast(lun); - } + SetLunL(static_cast(lun)); + return static_cast(lun); + } CUsbHostMsLogicalUnit& CUsbHostMsDevice::GetLuL(TInt aLunNum) const @@ -224,64 +214,63 @@ void CUsbHostMsDevice::SetLunL(CUsbHostMsLogicalUnit& aLu) - { - __MSFNLOG + { TLun lun = aLu.Lun(); - if (lun <= iMaxLun) + if (lun <= iMaxLun) { - __HOSTPRINT1(_L("SetLun %d"), lun); + OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICE_20, + "SetLun %d", lun); iTransport->SetLun(lun); - if (aLu.IsReadyToSuspend()) - { - aLu.CancelReadyToSuspend(); - } - } - } + if (aLu.IsReadyToSuspend()) + { + aLu.CancelReadyToSuspend(); + } + } + } CUsbHostMsLogicalUnit& CUsbHostMsDevice::SetLunL(TLun aLun) - { - __MSFNLOG + { CUsbHostMsLogicalUnit& lu = iLuList.GetLuL(aLun); SetLunL(lu); return lu; - } + } /** Starts timer to periodically check LUN. If the timer is not yet running then start it. */ void CUsbHostMsDevice::StartTimer() - { - __MSFNLOG - if (!iTimerRunning) - { - // Period of the LUN Ready check - const TTimeIntervalMicroSeconds32 KInterval = iConfig.iStatusPollingInterval * 1000 * 1000; - TCallBack callback(TimerCallback, this); - __HOSTPRINT(_L("Starting timer")); - iTimer->Start(KInterval, KInterval, callback); - iTimerRunning = ETrue; - } - } + { + if (!iTimerRunning) + { + // Period of the LUN Ready check + const TTimeIntervalMicroSeconds32 KInterval = iConfig.iStatusPollingInterval * 1000 * 1000; + TCallBack callback(TimerCallback, this); + OstTrace0(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICE_21, + "Starting timer"); + iTimer->Start(KInterval, KInterval, callback); + iTimerRunning = ETrue; + } + } /** Ensure that the Timer is stopped */ void CUsbHostMsDevice::StopTimer() - { - __MSFNLOG - if (iTimer && iTimerRunning) - { - __HOSTPRINT(_L("Stopping timer")); - if (iTimer->IsActive()) - { - iTimer->Cancel(); - } - iTimerRunning = EFalse; - } - } + { + if (iTimer && iTimerRunning) + { + OstTrace0(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICE_30, + "Stopping timer"); + if (iTimer->IsActive()) + { + iTimer->Cancel(); + } + iTimerRunning = EFalse; + } + } /** A static wrapper for the DoLunReadyCheckEvent member function for use as a timer @@ -291,70 +280,65 @@ @return not used in CPeriodic callback (see TCallback) */ TInt CUsbHostMsDevice::TimerCallback(TAny* obj) - { - __MSFNSLOG + { CUsbHostMsDevice* device = static_cast(obj); - TRAPD(err, device->DoLunReadyCheckEventL()); - return err; - } + TRAPD(err, device->DoLunReadyCheckEventL()); + return err; + } void CUsbHostMsDevice::DoLunReadyCheckEventL() - { - __MSFNLOG - TInt err; - for (TInt i = 0; i < iLuList.Count(); i++) - { - CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); - SetLunL(lu); - TRAP(err, lu.DoLunReadyCheckL()); - } - } + { + TInt err; + for (TInt i = 0; i < iLuList.Count(); i++) + { + CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); + SetLunL(lu); + TRAP(err, lu.DoLunReadyCheckL()); + } + } void CUsbHostMsDevice::DoHandleRemoteWakeupL() - { - __MSFNLOG - DoResumeLogicalUnitsL(); - DoLunReadyCheckEventL(); // For remote wakeup we do not wait for timer to expire + { + DoResumeLogicalUnitsL(); + DoLunReadyCheckEventL(); // For remote wakeup we do not wait for timer to expire // check whether all the luns are suspended, if so then request usb // interface suspension to the transport layer - for (TInt i = 0; i < iLuList.Count(); i++) - { - CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); - // Has any of the logical units have got its state changed? - if ( (lu.IsReadyToSuspend() && !lu.IsConnected()) || - (!lu.IsReadyToSuspend() && lu.IsConnected()) ) - { - StartTimer(); // Now start the timer - return; - } - } + for (TInt i = 0; i < iLuList.Count(); i++) + { + CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); + // Has any of the logical units have got its state changed? + if ( (lu.IsReadyToSuspend() && !lu.IsConnected()) || + (!lu.IsReadyToSuspend() && lu.IsConnected()) ) + { + StartTimer(); // Now start the timer + return; + } + } - for (TInt i = 0; i < iLuList.Count(); i++) - { - CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); - SetLunL(lu); - lu.SuspendL(); - } + for (TInt i = 0; i < iLuList.Count(); i++) + { + CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); + SetLunL(lu); + lu.SuspendL(); + } - iDeviceSuspendResume->Suspend(); - iState = ESuspended; - } + iDeviceSuspendResume->Suspend(); + iState = ESuspended; + } void CUsbHostMsDevice::DoResumeLogicalUnitsL() - { - __MSFNLOG - for (TInt i = 0; i < iLuList.Count(); i++) - { - CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); - SetLunL(lu); - lu.ResumeL(); - } - } + { + for (TInt i = 0; i < iLuList.Count(); i++) + { + CUsbHostMsLogicalUnit& lu = iLuList.GetLu(i); + SetLunL(lu); + lu.ResumeL(); + } + } void CUsbHostMsDevice::ResumeCompletedL() - { - __MSFNLOG - iState = EReady; - DoResumeLogicalUnitsL(); - } + { + iState = EReady; + DoResumeLogicalUnitsL(); + }