diff -r 0659d0e1a03c -r 1d28c8722707 userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbhostmsdevicethread.cpp --- a/userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbhostmsdevicethread.cpp Wed Oct 20 13:58:28 2010 +0100 +++ b/userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbhostmsdevicethread.cpp Tue Nov 02 15:29:23 2010 +0000 @@ -27,10 +27,13 @@ #include "msgservice.h" #include "cusbhostmslogicalunit.h" #include "cusbhostmsdevice.h" -#include "msdebug.h" #include "cusbhostmssession.h" #include "cusbhostmsdevicethread.h" -#include "debug.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "cusbhostmsdevicethreadTraces.h" +#endif /** Constructor @@ -38,7 +41,6 @@ TDeviceHandler::TDeviceHandler(CUsbHostMsDevice& aDevice) : iDevice(aDevice) { - __MSFNLOG } @@ -51,14 +53,13 @@ */ void TDeviceHandler::HandleMessageL(const RMessage2& aMessage) { - __MSFNLOG TLun lun = iDevice.GetAndSetLunL(aMessage); - switch (aMessage.Function()) - { - case EUsbHostMsSuspendLun: + switch (aMessage.Function()) + { + case EUsbHostMsSuspendLun: iDevice.SuspendLunL(lun); - break; + break; case EUsbHostMsUnRegisterLun: iDevice.RemoveLunL(lun); break; @@ -67,8 +68,8 @@ CUsbHostMsLogicalUnit& lu = iDevice.GetLuL(lun); TLogicalUnitHandler luHandler(lu); luHandler.HandleMessageL(aMessage); - break; - } + break; + } } @@ -80,7 +81,6 @@ TLogicalUnitHandler::TLogicalUnitHandler(CUsbHostMsLogicalUnit& aLu) : iLu(aLu) { - __MSFNLOG } @@ -91,65 +91,62 @@ @param aMessage */ void TLogicalUnitHandler::HandleMessageL(const RMessage2& aMessage) - { - __MSFNLOG - switch (aMessage.Function()) - { - case EUsbHostMsNotifyChange: + { + switch (aMessage.Function()) + { + case EUsbHostMsNotifyChange: iLu.NotifyChange(aMessage); - break; - case EUsbHostMsCancelChangeNotifier: + break; + case EUsbHostMsCancelChangeNotifier: iLu.CancelChangeNotifierL(); - break; - case EUsbHostMsForceRemount: + break; + case EUsbHostMsForceRemount: iLu.ForceCompleteNotifyChangeL(); - break; - case EUsbHostMsRead: + break; + case EUsbHostMsRead: iLu.ReadL(aMessage); - break; - case EUsbHostMsWrite: + break; + case EUsbHostMsWrite: iLu.WriteL(aMessage); - break; - case EUsbHostMsErase: + break; + case EUsbHostMsErase: iLu.EraseL(aMessage); - break; - case EUsbHostMsCapacity: + break; + case EUsbHostMsCapacity: iLu.CapsL(aMessage); - break; - default: - aMessage.Panic(KUsbHostMsSrvPncCat, EUsbMsPanicIllegalIPC); - break; - } - } + break; + default: + aMessage.Panic(KUsbHostMsSrvPncCat, EUsbMsPanicIllegalIPC); + break; + } + } void CUsbHostMsDeviceThread::DoStartServerL(TAny* aPtr) { - __MSFNSLOG CActiveScheduler* s = new(ELeave) CActiveScheduler; CActiveScheduler::Install(s); - CUsbHostMsDeviceThread* iThread = (CUsbHostMsDeviceThread*)aPtr; - CActiveScheduler::Add(iThread); + CUsbHostMsDeviceThread* iThread = (CUsbHostMsDeviceThread*)aPtr; + CActiveScheduler::Add(iThread); iThread->Start(); - RThread::Rendezvous(KErrNone); + RThread::Rendezvous(KErrNone); - // + // // Ready to run CActiveScheduler::Start(); // // Cleanup the scheduler - delete s; + delete s; } TInt CUsbHostMsDeviceThread::Entry(TAny* aPtr) - { - __MSFNSLOG - CTrapCleanup* cleanup = CTrapCleanup::New(); + { + CTrapCleanup* cleanup = CTrapCleanup::New(); if (!cleanup) { return KErrNoMemory; @@ -158,31 +155,29 @@ TRAPD(error, DoStartServerL(aPtr)); delete cleanup; return error; - } + } void CUsbHostMsDeviceThread::RunL() - { - __MSFNLOG - + { // called on completion of MessageRequest() or Resume() User::LeaveIfError(iStatus.Int()); - Lock(); + Lock(); if (iUsbHostMsDevice) { if (iUsbHostMsDevice->IsSuspended()) { - RMessage2 msg = iRMessage2[iDequeueIndex]; + RMessage2 msg = iRMessage2[iDequeueIndex]; if (msg.Function() != EUsbHostMsSuspendLun) { - // request resume + // request resume Unlock(); iUsbHostMsDevice->Resume(iStatus); SetActive(); return; - } + } } } @@ -192,15 +187,15 @@ iDequeueIndex++; if(iDequeueIndex >= KMaxNumMessage) - iDequeueIndex = 0; + iDequeueIndex = 0; if(iQueueFull) - iQueueFull = EFalse; + iQueueFull = EFalse; HandleMessage(msg); if ((iQueueIndex != iDequeueIndex) || iQueueFull) - { - // self completion + { + // self completion TRequestStatus* status = &iStatus; User::RequestComplete(status, KErrNone); SetActive(); @@ -211,7 +206,7 @@ SetActive(); } Unlock(); - } + } void CUsbHostMsDeviceThread::DoCancel() @@ -223,63 +218,59 @@ TInt CUsbHostMsDeviceThread::RunError(TInt aError) { - __HOSTPRINT1(_L(">> HOST RunError returning %d"), aError); + OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_10, + ">> HOST RunError returning %d", aError); return KErrNone; } TInt CUsbHostMsDeviceThread::QueueMsg(const RMessage2& aMsg) - { - __MSFNLOG - - if (iQueueFull) - { - return KErrOverflow; - } + { + if (iQueueFull) + { + return KErrOverflow; + } Lock(); - iRMessage2[iQueueIndex] = aMsg; - iQueueIndex++; + iRMessage2[iQueueIndex] = aMsg; + iQueueIndex++; - if (iQueueIndex >= KMaxNumMessage) - { - iQueueIndex = 0; - } + if (iQueueIndex >= KMaxNumMessage) + { + iQueueIndex = 0; + } - if (iQueueIndex == iDequeueIndex) - { - iQueueFull = ETrue; - } - Unlock(); - return KErrNone; - } + if (iQueueIndex == iDequeueIndex) + { + iQueueFull = ETrue; + } + Unlock(); + return KErrNone; + } CUsbHostMsDeviceThread::CUsbHostMsDeviceThread(CUsbHostMsSession& aUsbHostMsSession, TUint aToken) -: CActive(EPriorityStandard), +: CActive(EPriorityStandard), iUsbHostMsSession(aUsbHostMsSession), iQueueFull(EFalse) - { - __MSFNLOG + { TBuf<32> nameBuf; nameBuf.Format(_L("Host Ms ThreadMutex%8x"), aToken); - iMutex.CreateGlobal(nameBuf,EOwnerProcess); - } + iMutex.CreateGlobal(nameBuf,EOwnerProcess); + } CUsbHostMsDeviceThread::~CUsbHostMsDeviceThread() - { - __MSFNLOG + { Cancel(); - iMutex.Close(); - } + iMutex.Close(); + } CUsbHostMsDeviceThread* CUsbHostMsDeviceThread::NewL(CUsbHostMsSession& aUsbHostMsSession, TUint aToken) - { - __MSFNSLOG - CUsbHostMsDeviceThread* r = new (ELeave) CUsbHostMsDeviceThread(aUsbHostMsSession, aToken); - return r; - } + { + CUsbHostMsDeviceThread* r = new (ELeave) CUsbHostMsDeviceThread(aUsbHostMsSession, aToken); + return r; + } void CUsbHostMsDeviceThread::Start() @@ -291,59 +282,61 @@ /** Handles the request (in the form of a message) received from the client -@param aMessage The received message +@param aMessage The received message */ void CUsbHostMsDeviceThread::HandleMessage(const RMessage2& aMessage) - { - __MSFNLOG - TInt ret = KErrNotReady; - __HOSTPRINT2(_L(">> HOST DispatchMessageL Function=%d %d"), aMessage.Function(), aMessage.Int3()); - switch (aMessage.Function()) - { - case EUsbHostMsRegisterInterface: - TRAP(ret, RegisterInterfaceL(aMessage)); - break; + { + TInt ret = KErrNotReady; + OstTraceExt2(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_21, + ">> HOST DispatchMessageL Function=%d %d", + aMessage.Function(), aMessage.Int3()); + switch (aMessage.Function()) + { + case EUsbHostMsRegisterInterface: + TRAP(ret, RegisterInterfaceL(aMessage)); + break; case EUsbHostMsInitialiseInterface: - TRAP(ret, InitialiseInterfaceL(aMessage)); + TRAP(ret, InitialiseInterfaceL(aMessage)); // CUsbInterfaceHandler::GetMaxLun() completes asynchronously if (ret) { // Error condition needs to be completed break; } - return; - case EUsbHostMsUnRegisterInterface: - // Check whether all luns have got uninitialised. + return; + case EUsbHostMsUnRegisterInterface: + // Check whether all luns have got uninitialised. if (iUsbHostMsDevice) { for(TInt i = 0, j = iUsbHostMsDevice->GetMaxLun(); i <= j; i++) TRAP_IGNORE(iUsbHostMsDevice->RemoveLunL(i)); } - TRAP(ret, UnRegisterInterfaceL(aMessage)); - break; - case EUsbHostMsRegisterLun: - TRAP(ret, RegisterLogicalUnitL(aMessage)); - break; - case EUsbHostMsGetNumLun: - TRAP(ret, GetNumLunL(aMessage)); - break; - case EUsbHostMsShutdown: - ret = Shutdown(); - break; + TRAP(ret, UnRegisterInterfaceL(aMessage)); + break; + case EUsbHostMsRegisterLun: + TRAP(ret, RegisterLogicalUnitL(aMessage)); + break; + case EUsbHostMsGetNumLun: + TRAP(ret, GetNumLunL(aMessage)); + break; + case EUsbHostMsShutdown: + ret = Shutdown(); + break; default: // Try Device Handler and Logical Unit Handler __ASSERT_DEBUG(iUsbHostMsDevice, User::Invariant()); TDeviceHandler deviceHandler(*iUsbHostMsDevice); TRAP(ret, deviceHandler.HandleMessageL(aMessage)); - break; - } - __HOSTPRINT1(_L(">> HOST returning %d"), ret); + break; + } + OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_22, + ">> HOST returning %d", ret); if (aMessage.Function() != EUsbHostMsNotifyChange) { aMessage.Complete(ret); } - } + } /** @@ -353,85 +346,81 @@ */ TInt CUsbHostMsDeviceThread::Shutdown() { - __MSFNLOG CActiveScheduler::Stop(); - return KErrNone; - } + return KErrNone; + } void CUsbHostMsDeviceThread::GetNumLunL(const RMessage2& aMessage) - { - __MSFNLOG + { if (!iUsbHostMsDevice) { User::Leave(KErrNotReady); } - TUint32 maxLun = iUsbHostMsDevice->GetMaxLun() + 1; - TPtrC8 pLun((TUint8*)&maxLun,sizeof(TUint32)); - aMessage.WriteL(0,pLun); - } + TUint32 maxLun = iUsbHostMsDevice->GetMaxLun() + 1; + TPtrC8 pLun((TUint8*)&maxLun,sizeof(TUint32)); + aMessage.WriteL(0,pLun); + } void CUsbHostMsDeviceThread::RegisterInterfaceL(const RMessage2& aMessage) - { - __MSFNLOG + { + THostMassStorageConfig msDeviceConfig; + TPtr8 ptr((TUint8*)&msDeviceConfig,sizeof(THostMassStorageConfig)); + aMessage.ReadL(0, ptr); - THostMassStorageConfig msDeviceConfig; - TPtr8 ptr((TUint8*)&msDeviceConfig,sizeof(THostMassStorageConfig)); - aMessage.ReadL(0, ptr); + OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_30, + "RegisterInterfaceL Token=%d ", msDeviceConfig.iInterfaceToken); - __HOSTPRINT1(_L("RegisterInterfaceL Token=%d "), msDeviceConfig.iInterfaceToken); - - iUsbHostMsDevice = CUsbHostMsDevice::NewL(msDeviceConfig); - } + iUsbHostMsDevice = CUsbHostMsDevice::NewL(msDeviceConfig); + } void CUsbHostMsDeviceThread::InitialiseInterfaceL(const RMessage2& aMessage) - { - __MSFNLOG + { if (!iUsbHostMsDevice) { User::Leave(KErrNotReady); } - TRAPD(err, iUsbHostMsDevice->InitialiseL(aMessage)); + TRAPD(err, iUsbHostMsDevice->InitialiseL(aMessage)); if (err != KErrNone) { delete iUsbHostMsDevice; - iUsbHostMsDevice = NULL; + iUsbHostMsDevice = NULL; User::Leave(err); } - } + } void CUsbHostMsDeviceThread::UnRegisterInterfaceL(const RMessage2& aMessage) { - __MSFNLOG if (!iUsbHostMsDevice) { User::Leave(KErrNotReady); } - TRAPD(err, iUsbHostMsDevice->UnInitialiseL()); - delete iUsbHostMsDevice; - iUsbHostMsDevice = NULL; + TRAPD(err, iUsbHostMsDevice->UnInitialiseL()); + delete iUsbHostMsDevice; + iUsbHostMsDevice = NULL; User::LeaveIfError(err); } void CUsbHostMsDeviceThread::RegisterLogicalUnitL(const RMessage2& aMessage) - { + { if (!iUsbHostMsDevice) { User::Leave(KErrNotReady); } - TUint32 iLunId = aMessage.Int0() + 1; // Subssessions need a positive value to store in the handles. We represent Luns as LunId+1 - TPtrC8 pLun((TUint8*)&iLunId, sizeof(TUint32)); - aMessage.WriteL(3, pLun); - iLunId -= 1; // We represent LunId in MSC from 0 to MaxLun-1 as represented in BOT - __HOSTPRINT1(_L("RegisterLogicalUnitL LUN=%d "), iLunId); - iUsbHostMsDevice->AddLunL(iLunId); - iUsbHostMsDevice->InitLunL(iLunId); - } + TUint32 iLunId = aMessage.Int0() + 1; // Subssessions need a positive value to store in the handles. We represent Luns as LunId+1 + TPtrC8 pLun((TUint8*)&iLunId, sizeof(TUint32)); + aMessage.WriteL(3, pLun); + iLunId -= 1; // We represent LunId in MSC from 0 to MaxLun-1 as represented in BOT + OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_31, + "RegisterLogicalUnitL LUN=%d ", iLunId); + iUsbHostMsDevice->AddLunL(iLunId); + iUsbHostMsDevice->InitLunL(iLunId); + }