--- a/kernel/eka/drivers/pbus/mmc/stack.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/drivers/pbus/mmc/stack.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1082,7 +1082,7 @@
* Constructor
*/
: iPMark(NULL),iPoint(NULL),iPrevP(NULL),iSize(0)
- {OstTraceFunctionEntry1( TMMCSESSRING_TMMCSESSRING_ENTRY, this );}
+ {}
void TMMCSessRing::Erase()
@@ -1090,9 +1090,7 @@
* Erases all the ring content
*/
{
- OstTraceFunctionEntry1( TMMCSESSRING_ERASE_ENTRY, this );
iPMark = iPoint = iPrevP = NULL; iSize = 0;
- OstTraceFunctionExit1( TMMCSESSRING_ERASE_EXIT, this );
}
@@ -1118,19 +1116,16 @@
* Finds aSessP and sets Point to that position
*/
{
- OstTraceFunctionEntryExt( TMMCSESSRING_POINT_ENTRY, this );
Point();
while( iPoint != NULL )
if( iPoint == aSessP )
{
- OstTraceFunctionExitExt( TMMCSESSRING_POINT_EXIT1, this, (TUint) ETrue );
return ETrue;
}
else
this->operator++(0);
- OstTraceFunctionExitExt( TMMCSESSRING_POINT_EXIT2, this, (TUint) EFalse );
return EFalse;
}
@@ -1139,13 +1134,11 @@
* Inserts aSessP before Marker. Point is moved into the Marker position.
*/
{
- OstTraceFunctionEntryExt( TMMCSESSRING_ADD1_ENTRY, this );
if( iSize == 0 )
{
iPMark = iPrevP = iPoint = aSessP;
aSessP->iLinkP = aSessP;
iSize = 1;
- OstTraceFunctionExit1( TMMCSESSRING_ADD1_EXIT1, this );
return;
}
@@ -1154,7 +1147,6 @@
aSessP->iLinkP = iPoint;
iPMark = iPrevP = aSessP;
iSize++;
- OstTraceFunctionExit1( TMMCSESSRING_ADD1_EXIT2, this );
}
@@ -1165,12 +1157,10 @@
* Erases aRing.
*/
{
- OstTraceFunctionEntry1( TMMCSESSRING_ADD2_ENTRY, this );
Point();
if( aRing.iSize == 0 )
{
- OstTraceFunctionExit1( TMMCSESSRING_ADD2_EXIT1, this );
return;
}
@@ -1189,7 +1179,6 @@
}
aRing.Erase();
- OstTraceFunctionExit1( TMMCSESSRING_ADD2_EXIT2, this );
}
DMMCSession* TMMCSessRing::Remove()
@@ -1198,7 +1187,6 @@
* Point (and possibly Marker) move forward as in operator++
*/
{
- OstTraceFunctionEntry1( TMMCSESSRING_REMOVE1_ENTRY, this );
DMMCSession* remS = iPrevP;
if( iSize < 2 )
@@ -1219,7 +1207,6 @@
}
}
- OstTraceFunctionExitExt( TMMCSESSRING_REMOVE1_EXIT, this, ( TUint )( remS ) );
return remS;
}
@@ -1229,12 +1216,10 @@
* Removes a specified session from the ring
*/
{
- OstTraceFunctionEntryExt( TMMCSESSRING_REMOVE2_ENTRY, this );
if( Point(aSessP) )
Remove();
else
DMMCSocket::Panic(DMMCSocket::EMMCSessRingNoSession);
- OstTraceFunctionExit1( TMMCSESSRING_REMOVE2_EXIT, this );
}
--- a/kernel/eka/include/e32uid.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/e32uid.h Mon Oct 11 17:54:41 2010 +0100
@@ -1,128 +1,130 @@
-// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-// e32\include\e32uid.h
-//
-// WARNING: This file contains some APIs which are internal and are subject
-// to change without notice. Such APIs should therefore not be used
-// outside the Kernel and Hardware Services package.
-//
-
-/**
- @file
- @publishedPartner
- @released
-*/
-
-#ifndef __E32UID_H__
-#define __E32UID_H__
-#include <e32cmn.h>
-
-const TInt KDynamicLibraryUidValue=0x10000079;
-const TInt KExecutableImageUidValue=0x1000007a;
-const TUid KDynamicLibraryUid={KDynamicLibraryUidValue};
-const TUid KExecutableImageUid={KExecutableImageUidValue};
-
-#if defined(_UNICODE)
-#define KLogicalDeviceDriverUidValue KLogicalDeviceDriverUidValue16
-#define KLogicalDeviceDriverUid KLogicalDeviceDriverUid16
-#else
-#define KLogicalDeviceDriverUidValue KLogicalDeviceDriverUidValue8
-#define KLogicalDeviceDriverUid KLogicalDeviceDriverUid8
-#endif
-const TInt KLogicalDeviceDriverUidValue16=0x100000af;
-const TUid KLogicalDeviceDriverUid16={KLogicalDeviceDriverUidValue16};
-const TInt KLogicalDeviceDriverUidValue8=0x100000ae;
-const TUid KLogicalDeviceDriverUid8={KLogicalDeviceDriverUidValue8};
-
-#if defined(_UNICODE)
-#define KPhysicalDeviceDriverUidValue KPhysicalDeviceDriverUidValue16
-#define KPhysicalDeviceDriverUid KPhysicalDeviceDriverUid16
-#else
-#define KPhysicalDeviceDriverUidValue KPhysicalDeviceDriverUidValue8
-#define KPhysicalDeviceDriverUid KPhysicalDeviceDriverUid8
-#endif
-const TInt KPhysicalDeviceDriverUidValue16=0x100039d0;
-const TUid KPhysicalDeviceDriverUid16={KPhysicalDeviceDriverUidValue16};
-const TInt KPhysicalDeviceDriverUidValue8=0x100000ad;
-const TUid KPhysicalDeviceDriverUid8={KPhysicalDeviceDriverUidValue8};
-
-const TInt KMachineConfigurationUidValue=0x100000f4;
-const TUid KMachineConfigurationUid={KMachineConfigurationUidValue};
-
-#if defined(_UNICODE)
-#define KLocaleDllUidValue KLocaleDllUidValue16
-#define KLocaleDllUid KLocaleDllUid16
-#else
-#define KLocaleDllUidValue KLocaleDllUidValue8
-#define KLocaleDllUid KLocaleDllUid8
-#endif
-const TInt KLocaleDllUidValue16=0x100039e6;
-const TUid KLocaleDllUid16={KLocaleDllUidValue16};
-const TInt KLocaleDllUidValue8=0x100000c3;
-const TUid KLocaleDllUid8={KLocaleDllUidValue8};
-
-const TInt KSharedLibraryUidValue=0x1000008d;
-const TUid KSharedLibraryUid={KSharedLibraryUidValue};
-
-const TInt KKeyboardUidValue=0x100000db;
-const TUid KKeyboardUid={KKeyboardUidValue};
-
-/** @internalComponent */
-const TInt KEka1EntryStubUidValue=0x101fdf0f;
-/** @internalComponent */
-const TUid KEka1EntryStubUid={KEka1EntryStubUidValue};
-
-#if defined(_UNICODE)
-#define KKeyboardDataUidValue KKeyboardDataUidValue16
-#define KKeyboardDataUid KKeyboardDataUid16
-#else
-#define KKeyboardDataUidValue KKeyboardDataUidValue8
-#define KKeyboardDataUid KKeyboardDataUid8
-#endif
-const TInt KKeyboardDataUidValue16=0x100039e0;
-const TUid KKeyboardDataUid16={KKeyboardDataUidValue16};
-const TInt KKeyboardDataUidValue8=0x100000dc;
-const TUid KKeyboardDataUid8={KKeyboardDataUidValue8};
-
-#if defined(_UNICODE)
-#define KKeyboardTranUidValue KKeyboardTranUidValue16
-#define KKeyboardTranUid KKeyboardTranUid16
-#else
-#define KKeyboardTranUidValue KKeyboardTranUidValue8
-#define KKeyboardTranUid KKeyboardTranUid8
-#endif
-const TInt KKeyboardTranUidValue16=0x100039e1;
-const TUid KKeyboardTranUid16={KKeyboardTranUidValue16};
-const TInt KKeyboardTranUidValue8=0x100000dd;
-const TUid KKeyboardTranUid8={KKeyboardTranUidValue8};
-
-
-#if defined(_UNICODE)
-#define KConsoleDllUidValue KConsoleDllUidValue16
-#define KConsoleDllUid KConsoleDllUid16
-#else
-#define KConsoleDllUidValue KConsoleDllUidValue8
-#define KConsoleDllUid KConsoleDllUid8
-#endif
-const TInt KConsoleDllUidValue16=0x100039e7;
-const TUid KConsoleDllUid16={KConsoleDllUidValue16};
-const TInt KConsoleDllUidValue8=0x100000c5;
-const TUid KConsoleDllUid8={KConsoleDllUidValue8};
-
-const TUint KSystemStartupModeKey=0x10204BB5;
-
-const TUint KSystemEmulatorOrientationKey=0x10204BB6;
-
-#endif
-
+// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32\include\e32uid.h
+//
+// WARNING: This file contains some APIs which are internal and are subject
+// to change without notice. Such APIs should therefore not be used
+// outside the Kernel and Hardware Services package.
+//
+
+/**
+ @file
+ @publishedPartner
+ @released
+*/
+
+#ifndef __E32UID_H__
+#define __E32UID_H__
+#include <e32cmn.h>
+
+const TInt KDynamicLibraryUidValue=0x10000079;
+const TInt KExecutableImageUidValue=0x1000007a;
+const TUid KDynamicLibraryUid={KDynamicLibraryUidValue};
+const TUid KExecutableImageUid={KExecutableImageUidValue};
+
+#if defined(_UNICODE)
+#define KLogicalDeviceDriverUidValue KLogicalDeviceDriverUidValue16
+#define KLogicalDeviceDriverUid KLogicalDeviceDriverUid16
+#else
+#define KLogicalDeviceDriverUidValue KLogicalDeviceDriverUidValue8
+#define KLogicalDeviceDriverUid KLogicalDeviceDriverUid8
+#endif
+const TInt KLogicalDeviceDriverUidValue16=0x100000af;
+const TUid KLogicalDeviceDriverUid16={KLogicalDeviceDriverUidValue16};
+const TInt KLogicalDeviceDriverUidValue8=0x100000ae;
+const TUid KLogicalDeviceDriverUid8={KLogicalDeviceDriverUidValue8};
+
+#if defined(_UNICODE)
+#define KPhysicalDeviceDriverUidValue KPhysicalDeviceDriverUidValue16
+#define KPhysicalDeviceDriverUid KPhysicalDeviceDriverUid16
+#else
+#define KPhysicalDeviceDriverUidValue KPhysicalDeviceDriverUidValue8
+#define KPhysicalDeviceDriverUid KPhysicalDeviceDriverUid8
+#endif
+const TInt KPhysicalDeviceDriverUidValue16=0x100039d0;
+const TUid KPhysicalDeviceDriverUid16={KPhysicalDeviceDriverUidValue16};
+const TInt KPhysicalDeviceDriverUidValue8=0x100000ad;
+const TUid KPhysicalDeviceDriverUid8={KPhysicalDeviceDriverUidValue8};
+
+const TInt KMachineConfigurationUidValue=0x100000f4;
+const TUid KMachineConfigurationUid={KMachineConfigurationUidValue};
+
+#if defined(_UNICODE)
+#define KLocaleDllUidValue KLocaleDllUidValue16
+#define KLocaleDllUid KLocaleDllUid16
+#else
+#define KLocaleDllUidValue KLocaleDllUidValue8
+#define KLocaleDllUid KLocaleDllUid8
+#endif
+const TInt KLocaleDllUidValue16=0x100039e6;
+const TUid KLocaleDllUid16={KLocaleDllUidValue16};
+const TInt KLocaleDllUidValue8=0x100000c3;
+const TUid KLocaleDllUid8={KLocaleDllUidValue8};
+
+const TInt KSharedLibraryUidValue=0x1000008d;
+const TUid KSharedLibraryUid={KSharedLibraryUidValue};
+
+const TInt KKeyboardUidValue=0x100000db;
+const TUid KKeyboardUid={KKeyboardUidValue};
+
+/** @internalComponent */
+const TInt KEka1EntryStubUidValue=0x101fdf0f;
+/** @internalComponent */
+const TUid KEka1EntryStubUid={KEka1EntryStubUidValue};
+
+#if defined(_UNICODE)
+#define KKeyboardDataUidValue KKeyboardDataUidValue16
+#define KKeyboardDataUid KKeyboardDataUid16
+#else
+#define KKeyboardDataUidValue KKeyboardDataUidValue8
+#define KKeyboardDataUid KKeyboardDataUid8
+#endif
+const TInt KKeyboardDataUidValue16=0x100039e0;
+const TUid KKeyboardDataUid16={KKeyboardDataUidValue16};
+const TInt KKeyboardDataUidValue8=0x100000dc;
+const TUid KKeyboardDataUid8={KKeyboardDataUidValue8};
+
+#if defined(_UNICODE)
+#define KKeyboardTranUidValue KKeyboardTranUidValue16
+#define KKeyboardTranUid KKeyboardTranUid16
+#else
+#define KKeyboardTranUidValue KKeyboardTranUidValue8
+#define KKeyboardTranUid KKeyboardTranUid8
+#endif
+const TInt KKeyboardTranUidValue16=0x100039e1;
+const TUid KKeyboardTranUid16={KKeyboardTranUidValue16};
+const TInt KKeyboardTranUidValue8=0x100000dd;
+const TUid KKeyboardTranUid8={KKeyboardTranUidValue8};
+
+
+#if defined(_UNICODE)
+#define KConsoleDllUidValue KConsoleDllUidValue16
+#define KConsoleDllUid KConsoleDllUid16
+#else
+#define KConsoleDllUidValue KConsoleDllUidValue8
+#define KConsoleDllUid KConsoleDllUid8
+#endif
+const TInt KConsoleDllUidValue16=0x100039e7;
+const TUid KConsoleDllUid16={KConsoleDllUidValue16};
+const TInt KConsoleDllUidValue8=0x100000c5;
+const TUid KConsoleDllUid8={KConsoleDllUidValue8};
+
+const TUint KSystemStartupModeKey=0x10204BB5;
+const TUint KSystemEmulatorOrientationKey=0x10204BB6;
+
+/** @internalComponent */
+const TUint KPlatformTestExclusionKey=0x20033F19;
+
+#endif
+
--- a/kernel/eka/include/e32ver.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/e32ver.h Mon Oct 11 17:54:41 2010 +0100
@@ -28,7 +28,7 @@
const TInt KE32MajorVersionNumber=2;
const TInt KE32MinorVersionNumber=0;
-const TInt KE32BuildVersionNumber=4007;
+const TInt KE32BuildVersionNumber=4008;
const TInt KMachineConfigurationMajorVersionNumber=1;
const TInt KMachineConfigurationMinorVersionNumber=0;
--- a/kernel/eka/include/memmodel/epoc/mmubase/mmubase.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/memmodel/epoc/mmubase/mmubase.h Mon Oct 11 17:54:41 2010 +0100
@@ -464,7 +464,7 @@
virtual void RemapPage(TInt aId, TUint32 aAddr, TPhysAddr aOldAddr, TPhysAddr aNewAddr, TPte aPtePerm, DProcess* aProcess)=0;
virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0;
virtual void ClearRamDrive(TLinAddr aStart)=0;
- virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)=0;
+ virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal)=0;
virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift)=0;
virtual void Unmap(TLinAddr aLinAddr, TInt aSize)=0;
virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0;
--- a/kernel/eka/include/memmodel/epoc/moving/arm/arm_mem.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/memmodel/epoc/moving/arm/arm_mem.h Mon Oct 11 17:54:41 2010 +0100
@@ -285,7 +285,7 @@
virtual void RemapPage(TInt aId, TUint32 aAddr, TPhysAddr aOldAddr, TPhysAddr aNewAddr, TPte aPtePerm, DProcess* aProcess);
virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
virtual void ClearRamDrive(TLinAddr aStart);
- virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte);
+ virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal);
virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift);
virtual void Unmap(TLinAddr aLinAddr, TInt aSize);
virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys);
--- a/kernel/eka/include/memmodel/epoc/moving/memmodel.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/memmodel/epoc/moving/memmodel.h Mon Oct 11 17:54:41 2010 +0100
@@ -318,7 +318,7 @@
// virtual void MapPhysicalPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, TPhysAddr aPhysAddr, TInt aNumPages, TPte aPtePerm)=0;
// virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0;
// virtual void ClearRamDrive(TLinAddr aStart)=0;
-// virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)=0;
+// virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal)=0;
// virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift)=0;
// virtual void Unmap(TLinAddr aLinAddr, TInt aSize)=0;
// virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0;
--- a/kernel/eka/include/memmodel/epoc/multiple/arm/arm_mem.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/memmodel/epoc/multiple/arm/arm_mem.h Mon Oct 11 17:54:41 2010 +0100
@@ -161,7 +161,7 @@
virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
virtual TInt UnmapUnownedPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
virtual void ClearRamDrive(TLinAddr aStart);
- virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte);
+ virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal);
virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift);
virtual void Unmap(TLinAddr aLinAddr, TInt aSize);
virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys);
--- a/kernel/eka/include/memmodel/epoc/multiple/memmodel.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/memmodel/epoc/multiple/memmodel.h Mon Oct 11 17:54:41 2010 +0100
@@ -405,7 +405,7 @@
// virtual void MapPhysicalPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, TPhysAddr aPhysAddr, TInt aNumPages, TPte aPtePerm)=0;
// virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess)=0;
// virtual void ClearRamDrive(TLinAddr aStart)=0;
-// virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)=0;
+// virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal)=0;
// virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift)=0;
// virtual void Unmap(TLinAddr aLinAddr, TInt aSize)=0;
// virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys)=0;
--- a/kernel/eka/include/memmodel/epoc/multiple/x86/x86_mem.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/memmodel/epoc/multiple/x86/x86_mem.h Mon Oct 11 17:54:41 2010 +0100
@@ -100,7 +100,7 @@
virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
virtual TInt UnmapUnownedPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
virtual void ClearRamDrive(TLinAddr aStart);
- virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte);
+ virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal);
virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift);
virtual void Unmap(TLinAddr aLinAddr, TInt aSize);
virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys);
--- a/kernel/eka/include/u32hal.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/include/u32hal.h Mon Oct 11 17:54:41 2010 +0100
@@ -1171,6 +1171,14 @@
- TAny* a2 : NULL.
*/
EPowerHalAcessoryPowerPresent,
+
+
+ /**
+ Used for testing purposes.
+
+ Sets a member in the power manager depending on which testing of some API's are skipped
+ */
+ EPowerHalPowerManagerTestMode,
};
--- a/kernel/eka/kernel/power.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/kernel/power.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -25,6 +25,7 @@
#include <nkern/nk_trace.h>
//#define _DEBUG_POWER
#endif
+const TUint KDisableControllerShutdown = 0x1;
/******************************************************************************
* Power Manager - a Power Model implementation
@@ -62,7 +63,8 @@
DBatteryMonitor* iBatteryMonitor;
DPowerHal* iPowerHal;
- TUint iPslShutdownTimeoutMs; // default = 0
+ TUint iPslShutdownTimeoutMs; // default = 0
+ TInt iTestMode;
private:
#ifndef _DEBUG_POWER
@@ -188,6 +190,16 @@
TInt DPowerManager::PowerHalFunction(TInt aFunction, TAny* a1, TAny* a2)
{ // from DPowerModel
__KTRACE_OPT(KPOWER,Kern::Printf(">DPowerManager::PowerHalFunction() func=0x%x, a1=0x%x, a2=0x%x", aFunction, a1, a2));
+ if (aFunction == EPowerHalPowerManagerTestMode)
+ {
+ if ((!Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by PowerHalFunction EPowerHalPowerManagerTestMode"))) ||
+ (!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by PowerHalFunction EPowerHalPowerManagerTestMode"))))
+ {
+ return KErrPermissionDenied;
+ }
+ iTestMode = (TInt) a1;
+ return KErrNone;
+ }
TInt r;
if (iPowerHal)
r = iPowerHal->PowerHalFunction(aFunction, a1, a2);
@@ -445,8 +457,9 @@
#endif
TTickQ::Wait();
+ if(!(iTestMode & KDisableControllerShutdown))
+ iPowerController->PowerDown(K::SecondQ->WakeupTime());
- iPowerController->PowerDown(K::SecondQ->WakeupTime());
__PM_ASSERT(iPowerController->iTargetState != EPwOff);
iPowerController->iTargetState = EPwActive;
--- a/kernel/eka/kernel/stimer.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/kernel/stimer.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1994-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -1824,7 +1824,8 @@
if (aTimeSetMode & Kern::ETimeSet_SetHwRtc)
{
r = A::SetSystemTimeInSecondsFrom2000(s);
- if (r!=KErrNone)
+ // Set SW RTC even if HW RTC is not supported
+ if ((r!=KErrNone) && (r != KErrNotSupported))
{
TTickQ::Signal();
return r;
--- a/kernel/eka/memmodel/epoc/mmubase/mmubase.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/memmodel/epoc/mmubase/mmubase.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -2527,7 +2527,7 @@
TUint mapattr=aMapAttr;
TPde pdePerm=0;
TPte ptePerm=0;
- TInt r=m.PdePtePermissions(mapattr, pdePerm, ptePerm);
+ TInt r=m.PdePtePermissions(mapattr, pdePerm, ptePerm, ETrue);
if (r==KErrNone)
{
pC->iAllocator=m.MappingRegion(mapattr);
--- a/kernel/eka/memmodel/epoc/moving/arm/xkernel.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/memmodel/epoc/moving/arm/xkernel.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -143,7 +143,7 @@
// override map attributes for shared kernel chunks
TUint ma = (iMapAttr &~ EMapAttrAccessMask) | EMapAttrSupRw;
TPde pde;
- TInt r = m.PdePtePermissions(ma, pde, iPtePermissions);
+ TInt r = m.PdePtePermissions(ma, pde, iPtePermissions, ETrue);
if (r != KErrNone)
return r;
iMapAttr = ma;
--- a/kernel/eka/memmodel/epoc/moving/arm/xmmu.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/memmodel/epoc/moving/arm/xmmu.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1447,7 +1447,7 @@
return r;
}
-TInt ArmMmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)
+TInt ArmMmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool /*aGlobal*/)
{
__KTRACE_OPT(KMMU,Kern::Printf(">ArmMmu::PdePtePermissions, mapattr=%08x",aMapAttr));
TUint read=aMapAttr & EMapAttrReadMask;
--- a/kernel/eka/memmodel/epoc/multiple/arm/xkernel.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/memmodel/epoc/multiple/arm/xkernel.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -159,8 +159,9 @@
if(iChunkType==ESharedKernelSingle || iChunkType==ESharedKernelMultiple || iChunkType==ESharedIo || iChunkType==ESharedKernelMirror)
{
// override map attributes for shared kernel chunks
- TUint ma = (iMapAttr &~ EMapAttrAccessMask) | (iChunkType==ESharedKernelMirror?EMapAttrSupRw:EMapAttrUserRw);
- TInt r = m.PdePtePermissions(ma, iPdePermissions, iPtePermissions);
+ TBool kernelMirror = iChunkType == ESharedKernelMirror;
+ TUint ma = (iMapAttr &~ EMapAttrAccessMask) | ((kernelMirror)? EMapAttrSupRw : EMapAttrUserRw);
+ TInt r = m.PdePtePermissions(ma, iPdePermissions, iPtePermissions, kernelMirror);
if (r != KErrNone)
return r;
iMapAttr = ma;
--- a/kernel/eka/memmodel/epoc/multiple/arm/xmmu.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/memmodel/epoc/multiple/arm/xmmu.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1937,7 +1937,7 @@
#if defined(__CPU_MEMORY_TYPE_REMAPPING) //arm1176, arm11mcore, armv7
/**
Calculates page directory/table entries for memory type described in aMapAttr.
-Global, small page (4KB) mapping is assumed.
+Small page (4KB) mapping is assumed.
(All magic numbers come from ARM page table descriptions.)
@param aMapAttr On entry, holds description(memory type, access permisions,...) of the memory.
It is made up of TMappingAttributes constants or TMappingAttributes2 object. If TMappingAttributes,
@@ -1946,10 +1946,11 @@
for given type of memory, with base address set to 0.
@param aPte On exit, holds small-page-entry (4K) for the 2nd level descriptor
for given type of memory, with base address set to 0.
+@param aGlobal Set to ETrue when the mapping should be global.
@return KErrNotSupported If memory described in aMapAttr is not supported
KErrNone Otherwise
*/
-TInt ArmMmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)
+TInt ArmMmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal)
{
__KTRACE_OPT(KMMU,Kern::Printf(">ArmMmu::PdePtePermissions, mapattr=%08x",aMapAttr));
@@ -1977,10 +1978,11 @@
#if defined (__CPU_USE_SHARED_MEMORY)
KArmV6PteS | // Memory is always shared.
#else
- (memory.Shared() ? KArmV6PteS : 0) | // Shared bit
-#endif
- (memory.Writable() ? 0 : KArmV6PteAPX) | // APX = !Writable
- (memory.UserAccess() ? KArmV6PteAP1: 0); // AP1 = UserAccess
+ (memory.Shared() ? KArmV6PteS : 0) | // Shared bit
+#endif
+ (memory.Writable() ? 0 : KArmV6PteAPX) | // APX = !Writable
+ (memory.UserAccess()? KArmV6PteAP1 : 0) | // AP1 = UserAccess
+ (aGlobal ? 0 : KArmV6PteNG); // Not Global bit
// aMapAttr remains the same
}
else
@@ -2060,7 +2062,7 @@
aPde=((aMapAttr&EMapAttrUseECC)>>8)|KArmV6PdePageTable;
// 5. Calculate small-page-entry for the 2nd level (aka page table) descriptor
- aPte=SP_PTE(apxap, tex0_c_b, exec, 1); // always global
+ aPte=SP_PTE(apxap, tex0_c_b, exec, aGlobal);
if (aMapAttr&EMapAttrShared)
aPte |= KArmV6PteS;
@@ -2150,7 +2152,7 @@
WBRA, WBRA, WBRA, WBRA //111
};
-TInt ArmMmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)
+TInt ArmMmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal)
{
__KTRACE_OPT(KMMU,Kern::Printf(">ArmMmu::PdePtePermissions, mapattr=%08x",aMapAttr));
@@ -2191,7 +2193,7 @@
apxap=(read>=4)?KArmV6PermRWRO:KArmV6PermRWNO;
else
apxap=KArmV6PermRWRW;
- TPte pte=SP_PTE(apxap, cbtex, exec, 1); // always global
+ TPte pte=SP_PTE(apxap, cbtex, exec, aGlobal);
if (aMapAttr&EMapAttrShared)
pte |= KArmV6PteS;
--- a/kernel/eka/memmodel/epoc/multiple/x86/xkernel.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/memmodel/epoc/multiple/x86/xkernel.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -158,8 +158,9 @@
if(iChunkType==ESharedKernelSingle || iChunkType==ESharedKernelMultiple || iChunkType==ESharedIo || iChunkType==ESharedKernelMirror)
{
// override map attributes for shared kernel chunks
- TUint ma = (iMapAttr &~ EMapAttrAccessMask) | (iChunkType==ESharedKernelMirror?EMapAttrSupRw:EMapAttrUserRw);
- TInt r = m.PdePtePermissions(ma, iPdePermissions, iPtePermissions);
+ TBool kernelMirror = iChunkType == ESharedKernelMirror;
+ TUint ma = (iMapAttr &~ EMapAttrAccessMask) | ((kernelMirror)? EMapAttrSupRw : EMapAttrUserRw);
+ TInt r = m.PdePtePermissions(ma, iPdePermissions, iPtePermissions, kernelMirror);
if (r != KErrNone)
return r;
iMapAttr = ma;
--- a/kernel/eka/memmodel/epoc/multiple/x86/xmmu.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/memmodel/epoc/multiple/x86/xmmu.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1323,7 +1323,7 @@
static const TUint8 ActualReadPrivilegeLevel[4]={1,1,4,4}; // RONO,RWNO,RORO,RWRW
static const TUint8 ActualWritePrivilegeLevel[4]={0,1,0,4}; // RONO,RWNO,RORO,RWRW
-TInt X86Mmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte)
+TInt X86Mmu::PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal)
{
__KTRACE_OPT(KMMU,Kern::Printf(">X86Mmu::PdePtePermissions, mapattr=%08x",aMapAttr));
TUint read=aMapAttr & EMapAttrReadMask;
@@ -1363,10 +1363,10 @@
r=KErrNotSupported;
if (r==KErrNone)
{
- cache=CacheBuffActual[cache];
- aPde=KPdePtePresent|KPdePteWrite|KPdePteUser;
- aPte=pte|cbatt|iPteGlobal; // HW chunks can always be global
- aMapAttr=read|(write<<4)|(read<<8)|(cache<<12);
+ cache = CacheBuffActual[cache];
+ aPde = KPdePtePresent | KPdePteWrite | KPdePteUser;
+ aPte = pte | cbatt | ((aGlobal)? iPteGlobal : 0);
+ aMapAttr = read | (write<<4) | (read<<8) | (cache<<12);
}
__KTRACE_OPT(KMMU,Kern::Printf("<X86Mmu::PdePtePermissions, r=%d, mapattr=%08x, pde=%08x, pte=%08x",
r,aMapAttr,aPde,aPte));
--- a/kernel/eka/release.txt Wed Oct 06 17:13:14 2010 +0100
+++ b/kernel/eka/release.txt Mon Oct 11 17:54:41 2010 +0100
@@ -1,3 +1,23 @@
+Version 2.00.4008
+=================
+(Made by fadhliM 05/10/2010)
+
+1. gayarama
+ 1. ou1cimx1#577332 ENV t_power, t_domain, t_switchoff, t_timer, t_suser, t_lddpowerseqtest : Tests cause reboot, preventing testing.
+
+2. dogunjum
+ 1. MINOR_CHANGE Documentation on how to use the Domain Manager Notification Interface With Deferrals
+
+3. martai
+ 1. ou1cimx1#594087 t_sharedio fails at line 544
+
+4. paconway
+ 1. ou1cimx1#586853 Fault observed on Bridge with MMC stack OST tracing enabled over XTI
+
+5. necliffo
+ 1. MINOR_CHANGE D_MMCTEST - Fix x86 rombuild
+
+
Version 2.00.4007
=================
(Made by fadhliM 30/09/2010)
Binary file kernelhwsrv_info/doc_pub/Base_How_To_Domain_Manager_Notification_Interface.docx has changed
--- a/kerneltest/e32test/domainmgr/t_domain.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/domainmgr/t_domain.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -51,6 +51,7 @@
//
//
+
#define __E32TEST_EXTENSION__
#include <e32test.h>
#include <e32debug.h>
@@ -59,7 +60,7 @@
#include "domainpolicytest.h"
#include "t_domain.h"
-
+#include "testexclusions.h"
RTest test(_L(" T_DOMAIN "));
_LIT(KThreadName, "t_domain_panic_thread");
@@ -2126,6 +2127,14 @@
delete hb;
}
+ TInt testExclusions = 0;
+ test_KErrNone(GetTestExclusionSettings(testExclusions));
+
+ if (testExclusions & KDisableControllerShutdown)
+ {
+ UserSvr::HalFunction(EHalGroupPower, EPowerHalPowerManagerTestMode, (TAny*)KDisableControllerShutdown, NULL);
+ }
+
test.Title();
test.Printf(_L("Go for %d iterations\n"), iter);
--- a/kerneltest/e32test/domainmgr/t_domain.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/domainmgr/t_domain.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -17,14 +17,15 @@
TARGET t_domain.exe
TARGETTYPE EXE
+USERINCLUDE ../misc
SOURCEPATH .
SOURCE t_domain.cpp t_domain_cmn.cpp
-LIBRARY euser.lib domaincli.lib
+LIBRARY euser.lib domaincli.lib efsrv.lib
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
USERINCLUDE ../../../userlibandfileserver/domainmgr/inc
-CAPABILITY WriteDeviceData PowerMgmt
+CAPABILITY WriteDeviceData PowerMgmt AllFiles
VENDORID 0x70000001
--- a/kerneltest/e32test/group/d_mmctest.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/group/d_mmctest.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -30,4 +30,8 @@
capability all
VENDORID 0x70000001
+// Don't put this in ROM here since it would stop ROMs building on platforms
+// without MMC support.
+romtarget
+
SMPSAFE
--- a/kerneltest/e32test/group/t_lddpowerseqtest.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/group/t_lddpowerseqtest.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -17,9 +17,10 @@
TARGET t_lddpowerseqtest.exe
TARGETTYPE EXE
+USERINCLUDE ../misc
SOURCEPATH ../power
SOURCE t_lddpowerseqtest.cpp
-LIBRARY euser.lib
+LIBRARY euser.lib efsrv.lib
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
USERINCLUDE ../power
--- a/kerneltest/e32test/group/t_power.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/group/t_power.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -17,12 +17,13 @@
TARGET t_power.exe
TARGETTYPE EXE
+USERINCLUDE ../misc
SOURCEPATH ../power
SOURCE t_power.cpp
-LIBRARY euser.lib
+LIBRARY euser.lib efsrv.lib
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-CAPABILITY PowerMgmt
+CAPABILITY PowerMgmt WriteDeviceData AllFiles
VENDORID 0x70000001
--- a/kerneltest/e32test/group/t_suser.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/group/t_suser.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -17,9 +17,10 @@
target t_suser.exe
targettype exe
+USERINCLUDE ../misc
sourcepath ../secure
source t_suser.cpp
-library euser.lib hal.lib
+library euser.lib hal.lib efsrv.lib
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
ROMTARGET
RAMTARGET \sys\bin\ //
--- a/kerneltest/e32test/group/t_switchoff.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/group/t_switchoff.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -17,12 +17,13 @@
TARGET t_switchoff.exe
TARGETTYPE EXE
+USERINCLUDE ../misc
SOURCEPATH ../power
SOURCE t_switchoff.cpp
-LIBRARY euser.lib
+LIBRARY euser.lib efsrv.lib
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-CAPABILITY PowerMgmt SwEvent
+CAPABILITY PowerMgmt SwEvent WriteDeviceData AllFiles
VENDORID 0x70000001
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/e32test/misc/testexclusions.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,84 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32test\misc\testexclusions.h
+// Gets the test exclusion property which is set by reading a file provided by base port and
+// based on this property some tests can be excluded
+//
+//
+
+#ifndef __TESTEXCLUSIONS_H__
+#define __TESTEXCLUSIONS_H__
+
+#include <e32svr.h>
+#include <u32hal.h>
+#include <e32property.h>
+#include <e32uid.h>
+#include <f32file.h>
+
+_LIT(KLitPlatformTestExclusionFile, "Z:\\sys\\data\\platformtestexclusion.txt");
+
+// Bit masks to disable different tests
+
+// To disable invoking PowerController::PowerDown
+const TUint KDisableControllerShutdown = 0x1;
+
+TInt GetExclusionFromFile(TUint& aTestExclusion)
+ {
+ RFs theFs;
+ TInt r = KErrNone;
+ r = theFs.Connect();
+ if (r != KErrNone)
+ return r;
+
+ RFile file;
+ TFileName filename(KLitPlatformTestExclusionFile);
+ r = file.Open(theFs, filename, EFileRead);
+ if (r == KErrNone)
+ {
+ TBuf8<8> data;
+ file.Read(data);
+ TLex8 lexData(data);
+ r = lexData.Val(aTestExclusion, EHex);
+ file.Close();
+ }
+
+ theFs.Close();
+ return r;
+ }
+
+
+TInt GetTestExclusionSettings(TInt& aTestExclusion)
+ {
+ TInt r = RProperty::Get(KUidSystemCategory, KPlatformTestExclusionKey, aTestExclusion);
+ if (r != KErrNotFound)
+ return r;
+
+ _LIT_SECURITY_POLICY_PASS(KTestPropPolicy);
+ r = RProperty::Define(KUidSystemCategory, KPlatformTestExclusionKey, RProperty::EInt, KTestPropPolicy, KTestPropPolicy);
+ if (r != KErrNone)
+ return r;
+
+
+ TUint testExclusion = 0;
+ r = GetExclusionFromFile(testExclusion);
+ if ((r != KErrNotFound) && (r != KErrNone)) // All platforms need not have test exclusions file defined
+ return r;
+
+ aTestExclusion = testExclusion;
+ r = RProperty::Set(KUidSystemCategory, KPlatformTestExclusionKey, testExclusion);
+ return r;
+ }
+
+#endif // __TESTEXCLUSIONS_H__
+
--- a/kerneltest/e32test/power/t_lddpowerseqtest.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/power/t_lddpowerseqtest.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -20,6 +20,7 @@
#include "d_lddpowerseqtest.h"
#include <e32power.h>
+#include "testexclusions.h"
_LIT(KLddFileName, "D_LDDPOWERSEQTEST.LDD");
RLddTest1 ldd;
@@ -39,6 +40,15 @@
RTimer timer;
TRequestStatus tstatus;
+ TInt testExclusions = 0;
+ r = GetTestExclusionSettings(testExclusions);
+ test(r == KErrNone);
+
+ if (testExclusions & KDisableControllerShutdown)
+ {
+ UserSvr::HalFunction(EHalGroupPower, EPowerHalPowerManagerTestMode, (TAny*)KDisableControllerShutdown, NULL);
+ }
+
test.Printf(_L("Loading logical device \n"));
r=User::LoadLogicalDevice(KLddFileName);
test(r == KErrNone);
--- a/kerneltest/e32test/power/t_power.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/power/t_power.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -41,6 +41,7 @@
#include <f32file.h>
#include <e32ldr.h>
#include <e32ldr_private.h>
+#include "testexclusions.h"
LOCAL_D RTest test(_L(" T_POWER "));
@@ -55,6 +56,14 @@
void PowerTests()
{
test.Next(_L("test PowerDown()"));
+
+ TInt testExclusions = 0;
+ test_KErrNone(GetTestExclusionSettings(testExclusions));
+
+ if (testExclusions & KDisableControllerShutdown)
+ {
+ UserSvr::HalFunction(EHalGroupPower, EPowerHalPowerManagerTestMode, (TAny*)KDisableControllerShutdown, NULL);
+ }
TInt r = Power::PowerDown();
test (r == KErrNotReady);
--- a/kerneltest/e32test/power/t_switchoff.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/power/t_switchoff.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -15,10 +15,13 @@
//
//
+#define __E32TEST_EXTENSION__
+
#include <e32event.h>
#include <e32event_private.h>
#include <e32svr.h>
#include <e32test.h>
+#include "testexclusions.h"
LOCAL_D RTest test(_L(" T_SWITCHOFF "));
@@ -61,6 +64,15 @@
test.Title();
test.Start(_L("Testing"));
+ TInt testExclusions = 0;
+ test_KErrNone(GetTestExclusionSettings(testExclusions));
+
+ if (testExclusions & KDisableControllerShutdown)
+ {
+ UserSvr::HalFunction(EHalGroupPower, EPowerHalPowerManagerTestMode, (TAny*)KDisableControllerShutdown, NULL);
+ }
+
+
SwittchOffTests();
test.End();
--- a/kerneltest/e32test/secure/t_suser.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/e32test/secure/t_suser.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -44,11 +44,14 @@
#include <nkern/nk_trace.h>
#include <e32hal.h>
#include <hal.h>
+#include "testexclusions.h"
LOCAL_D RTest test(_L("T_SUSER"));
_LIT(KSyncSemaphoreName,"T_SUSER-SyncSemaphore");
RSemaphore SyncSemaphore;
+TBool gControllerShutdownDisabled = EFalse;
+TInt gTestExclusions = 0;
void SlaveWait()
@@ -319,7 +322,9 @@
ETestProcessSetCurrencySymbol,
ETestProcessAddEventESwitchOff,
ETestProcessAddEventECaseOpen,
- ETestProcessAddEventECaseClose
+ ETestProcessAddEventECaseClose,
+ ETestProcessPowerHalTestMode,
+ ETestProcessGetTestExclusions
};
#include "testprocess.h"
@@ -532,6 +537,16 @@
return UserSvr::AddEvent(event);
}
+ case ETestProcessPowerHalTestMode:
+ {
+ return UserSvr::HalFunction(EHalGroupPower, EPowerHalPowerManagerTestMode, (TAny*)KDisableControllerShutdown, NULL);
+ }
+
+ case ETestProcessGetTestExclusions:
+ {
+ return GetTestExclusionSettings(gTestExclusions);
+ }
+
default:
User::Panic(_L("T_SUSER"),1);
}
@@ -822,6 +837,60 @@
TUint KTestUid = 0x87654321;
+void GetTestExclusions()
+ {
+ RTestProcess process;
+ TRequestStatus logonStatus;
+
+ test.Start(_L("Get Test exclusions"));
+ TInt caps = 1u<<ECapabilityWriteDeviceData | 1u<<ECapabilityAllFiles;
+ process.Create(caps, ETestProcessGetTestExclusions, KTestUid);
+ process.Logon(logonStatus);
+ process.Resume();
+ User::WaitForRequest(logonStatus);
+ test(process.ExitType()==EExitKill);
+ test(logonStatus==KErrNone);
+ CLOSE_AND_WAIT(process);
+ test.End();
+ }
+
+void TestPowerHalTestMode()
+ {
+ RTestProcess process;
+ TRequestStatus logonStatus;
+
+ test.Start(_L("Try calling PowerHal without ECapabilityWriteDeviceData"));
+ process.Create(~(1u<<ECapabilityWriteDeviceData), ETestProcessPowerHalTestMode, KTestUid);
+ process.Logon(logonStatus);
+ process.Resume();
+ User::WaitForRequest(logonStatus);
+ test(process.ExitType()==EExitKill);
+ test(logonStatus==KErrPermissionDenied);
+ CLOSE_AND_WAIT(process);
+
+ test.Start(_L("Try calling PowerHal without ECapabilityPowerMgmt"));
+ process.Create(~(1u<<ECapabilityPowerMgmt), ETestProcessPowerHalTestMode, KTestUid);
+ process.Logon(logonStatus);
+ process.Resume();
+ User::WaitForRequest(logonStatus);
+ test(process.ExitType()==EExitKill);
+ test(logonStatus==KErrPermissionDenied);
+ CLOSE_AND_WAIT(process);
+
+ test.Next(_L("Call PowerHal with ECapabilityWriteDeviceData and ECapabilityPowerMgmt"));
+ TInt caps = 1u<<ECapabilityWriteDeviceData | 1u<<ECapabilityPowerMgmt;
+ process.Create(caps,ETestProcessPowerHalTestMode, KTestUid);
+ process.Logon(logonStatus);
+ process.Resume();
+ User::WaitForRequest(logonStatus);
+ test(process.ExitType()==EExitKill);
+ test(logonStatus==KErrNone);
+ gControllerShutdownDisabled = ETrue;
+ CLOSE_AND_WAIT(process);
+
+ test.End();
+ }
+
void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus)
{
TTime wakeup;
@@ -950,7 +1019,7 @@
TInt muid = 0;
HAL::Get(HAL::EMachineUid, muid);
- if(muid==HAL::EMachineUid_OmapH2 || muid==HAL::EMachineUid_OmapH4 || muid==HAL::EMachineUid_OmapH6 || muid==HAL::EMachineUid_NE1_TB || muid==HAL::EMachineUid_X86PC || muid==HAL::EMachineUid_Win32Emulator)
+ if(gControllerShutdownDisabled || muid==HAL::EMachineUid_OmapH2 || muid==HAL::EMachineUid_OmapH4 || muid==HAL::EMachineUid_OmapH6 || muid==HAL::EMachineUid_NE1_TB || muid==HAL::EMachineUid_X86PC || muid==HAL::EMachineUid_Win32Emulator)
{
test.Next(_L("Calling UserSvr::AddEvent(ESwitchOff) with ECapabilityPowerMgmt & ECapabilitySwEvent"));
TRequestStatus absstatus;
@@ -1232,8 +1301,13 @@
test_KErrNone(SyncSemaphore.CreateGlobal(KSyncSemaphoreName,0));
test.Start(_L("Test MachineConfiguration()"));
+
TestMachineConfiguration();
+ GetTestExclusions();
+
+ TestPowerHalTestMode();
+
test.Next(_L("Test SetCritical()"));
TestSetCritical();
--- a/kerneltest/f32test/demandpaging/t_clamp.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/demandpaging/t_clamp.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -216,6 +216,26 @@
+void RemountFileSystem(TInt aDriveNo, TDesC& aFsName, TDesC& aFsExtName0, TDesC& aFsExtName1)
+ {
+ TInt r;
+ if(aFsExtName0.Length() > 0)
+ {
+ r=TheFs.MountFileSystem(aFsName,aFsExtName0,aDriveNo);
+ test(r==KErrNone);
+ }
+ else if(aFsExtName1.Length() > 0) // untested !
+ {
+ r=TheFs.MountFileSystem(aFsName,aFsExtName1,aDriveNo);
+ test(r==KErrNone);
+ }
+ else
+ {
+ r=TheFs.MountFileSystem(aFsName,aDriveNo);
+ test(r==KErrNone);
+ }
+ }
+
LOCAL_C void TestDeferredDismount(TDesC& aRoot, TDesC& aFileName, RFileClamp* handlePtr)
{
// Open and clamp file, register for dismount notification, then issue
@@ -231,26 +251,23 @@
TBuf<KMaxFileSystemNameLength> fsName;
TBuf<KMaxFileSystemExtNameLength> fsExtName_0;
TBuf<KMaxFileSystemExtNameLength> fsExtName_1;
- TBool fsExt0Present=EFalse;
- TBool fsExt1Present=EFalse;
TInt driveNo, r;
r=TheFs.CharToDrive(aRoot[0], driveNo);
test(r==KErrNone);
r=TheFs.FileSystemName(fsName, driveNo);
test(r==KErrNone);
- r=TheFs.ExtensionName(fsExtName_0,driveNo,0);
- if(r==KErrNone)
- fsExt0Present=ETrue;
- r=TheFs.ExtensionName(fsExtName_1,driveNo,1);
- if(r==KErrNone)
- fsExt1Present=ETrue;
+ //*******************************************************************************************************
// Create a file & write to it so that we can test whether dismounting works correctly with dirty data
+ //*******************************************************************************************************
+ test.Next(_L("T_Clamp - TestDeferredDismount(), testing unmounting with dirty data, registered clients & clamped files"));
+
TDriveInfo driveInfo;
test(TheFs.Drive(driveInfo, driveNo) == KErrNone);
TFileName dirtyFileName(_L("dirtyFile.tst"));
RFile dirtyFile;
- if (!(driveInfo.iMediaAtt & KMediaAttWriteProtected))
+ TBool writeProtectedMedia = driveInfo.iMediaAtt & KMediaAttWriteProtected;
+ if (!writeProtectedMedia)
{
r=dirtyFile.Replace(TheFs, dirtyFileName, EFileWrite);
test(r==KErrNone);
@@ -268,9 +285,16 @@
TRequestStatus clientNotify=KErrNone;
TRequestStatus clientDismount=KErrNone;
- TheFs.NotifyDismount(driveNo, clientNotify); // Register for notification
+ TheFs.NotifyDismount(driveNo, clientNotify); // Register for dismount notification
test(clientNotify == KRequestPending);
+
+ // register for disk change notifcation, so we can detect when dismount has actually taken place
+ TRequestStatus diskChangeStatus;
+ TheFs.NotifyChange(ENotifyDisk, diskChangeStatus);
+ test.Printf(_L("diskChangeStatus %d"), diskChangeStatus.Int());
+ test(diskChangeStatus == KRequestPending); // no disk change yet
+
TheFs.NotifyDismount(driveNo, clientDismount, EFsDismountNotifyClients);
test(clientDismount == KRequestPending);
User::WaitForRequest(clientNotify);
@@ -279,6 +303,7 @@
r=TheFs.AllowDismount(driveNo); // Respond to dismount notification
test(r == KErrNone);
test(clientDismount == KRequestPending); // Dismount is deferred
+ test(diskChangeStatus == KRequestPending); // no disk change yet
//
// Now unclamp the file, and check that the deferred dismount is performed.
@@ -287,33 +312,38 @@
User::WaitForRequest(clientDismount);
test(clientDismount == KErrNone);
+ // wait for disk change notification following dismount
+ User::WaitForRequest(diskChangeStatus);
+ test(diskChangeStatus == KErrNone); // should have got a disk change notification after dismount
+ r = TheFs.Drive(driveInfo, driveNo);
+ test (r==KErrNone);
+ test (driveInfo.iType == EMediaNotPresent);
+
+ // re-register for disk change notifcation, so we can detect when remount has actually taken place
+ TheFs.NotifyChange(ENotifyDisk, diskChangeStatus);
+ test.Printf(_L("diskChangeStatus %d"), diskChangeStatus.Int());
+ test(diskChangeStatus == KRequestPending); // no disk change yet
+
// Try to write to the opened file: this should return KErrNotReady as there is no drive thread
- if (!(driveInfo.iMediaAtt & KMediaAttWriteProtected))
+ if (!writeProtectedMedia)
{
r=dirtyFile.Write(_L8("My name isn't really Michael Caine"));
test(r==KErrNotReady);
}
// Re-mount the file system
- if(fsExt0Present)
- {
- r=TheFs.MountFileSystem(fsName,fsExtName_0,driveNo);
- test(r==KErrNone);
- }
- else if(fsExt1Present) // untested !
- {
- r=TheFs.MountFileSystem(fsName,fsExtName_1,driveNo);
- test(r==KErrNone);
- }
- else
- {
- r=TheFs.MountFileSystem(fsName,driveNo);
- test_KErrNone(r);
- }
+ RemountFileSystem(driveNo, fsName, fsExtName_0, fsExtName_1);
+
+ // wait for disk change notification following remount
+ User::WaitForRequest(diskChangeStatus);
+ test(diskChangeStatus == KErrNone); // should have got a disk change notification after dismount
+ r = TheFs.Drive(driveInfo, driveNo);
+ test (r==KErrNone);
+ test (driveInfo.iType != EMediaNotPresent);
// create some more dirty data to verify that the file server can cope with the drive thread
// having gone & come back again
- if (!(driveInfo.iMediaAtt & KMediaAttWriteProtected))
+ if (!writeProtectedMedia)
{
r=dirtyFile.Write(_L8("My name is Michael Phelps and I'm a fish."));
test(r==KErrDisMounted);
@@ -323,8 +353,12 @@
test(r == KErrNone);
}
+ //*******************************************************************************************************
// Issue a EFsDismountNotifyClients with no clients but with files clamped
// & verify that the dismount request completes when clamps are removed
+ //*******************************************************************************************************
+ test.Next(_L("T_Clamp - TestDeferredDismount(), testing unmounting with no registered clients & clamped files"));
+
r=testFile.Open(TheFs,aFileName,EFileRead);
test(r==KErrNone);
r=handlePtr->Clamp(testFile);
@@ -338,21 +372,7 @@
User::WaitForRequest(clientDismount);
test(clientDismount == KErrNone);
// Re-mount the file system again
- if(fsExt0Present)
- {
- r=TheFs.MountFileSystem(fsName,fsExtName_0,driveNo);
- test(r==KErrNone);
- }
- else if(fsExt1Present) // untested !
- {
- r=TheFs.MountFileSystem(fsName,fsExtName_1,driveNo);
- test(r==KErrNone);
- }
- else
- {
- r=TheFs.MountFileSystem(fsName,driveNo);
- test_KErrNone(r);
- }
+ RemountFileSystem(driveNo, fsName, fsExtName_0, fsExtName_1);
// Issue a EFsDismountForceDismount with no clients but with files clamped
@@ -369,23 +389,239 @@
test(r==KErrNone);
User::WaitForRequest(clientDismount);
test(clientDismount == KErrNone);
+
+
// Re-mount the file system again
- if(fsExt0Present)
+ RemountFileSystem(driveNo, fsName, fsExtName_0, fsExtName_1);
+
+
+ const TInt KNumClients = 5;
+ RFs clientFs[KNumClients];
+ TRequestStatus clientNotifies[KNumClients];
+ TRequestStatus clientDiskChanges[KNumClients];
+ TRequestStatus clientComplete;
+
+ #define LOG_AND_TEST(a, e) {if (a!=e) {test.Printf(_L("lvalue %d, rvalue%d\n\r"), a,e); test(EFalse);}}
+
+ //*******************************************************************************************************
+ // Test unmounting with multiple registered clients which do not respond & close their sessions
+ //*******************************************************************************************************
+ test.Next(_L("T_Clamp - TestDeferredDismount(), testing unmounting with multiple registered clients which do not respond & close their sessions"));
+
+ TheFs.NotifyChange(ENotifyDisk, diskChangeStatus);
+ test.Printf(_L("diskChangeStatus %d"), diskChangeStatus.Int());
+
+ TInt i;
+ for (i=0; i< KNumClients; i++)
{
- r=TheFs.MountFileSystem(fsName,fsExtName_0,driveNo);
+ LOG_AND_TEST(KErrNone, clientFs[i].Connect());
+ clientFs[i].NotifyDismount(driveNo, clientNotifies[i]);
+ test(clientNotifies[i] == KRequestPending);
+ }
+
+ test.Next(_L("Close all but one client sessions with outstanding notifiers"));
+ for (i=0; i< KNumClients-1; i++)
+ clientFs[i].Close();
+
+ // Since all clients have NOT been closed, the next stage should not yet complete
+ test.Next(_L("Notify clients of pending media removal and check status - should not complete"));
+ TheFs.NotifyDismount(driveNo, clientComplete, EFsDismountNotifyClients);
+ test(clientComplete == KRequestPending);
+
+
+ test.Next(_L("Close the remaining sessions with an outstanding notifier"));
+ clientFs[KNumClients-1].Close();
+
+ // Check that the dismount completes now that all session have been closed
+ test.Next(_L("Check that the dismount completes"));
+ User::WaitForRequest(clientComplete);
+ test_KErrNone(clientComplete.Int());
+
+ // wait for disk change notification following dismount
+ User::WaitForRequest(diskChangeStatus);
+ test(diskChangeStatus == KErrNone); // should have got a disk change notification after dismount
+ r = TheFs.Drive(driveInfo, driveNo);
+ test (r==KErrNone);
+ test (driveInfo.iType == EMediaNotPresent);
+
+ // re-register for disk change notifcation, so we can detect when remount has actually taken place
+ TheFs.NotifyChange(ENotifyDisk, diskChangeStatus);
+ test.Printf(_L("diskChangeStatus %d"), diskChangeStatus.Int());
+ test(diskChangeStatus == KRequestPending); // no disk change yet
+
+
+ // Re-mount the file system again
+ RemountFileSystem(driveNo, fsName, fsExtName_0, fsExtName_1);
+
+ // wait for disk change notification following remount
+ User::WaitForRequest(diskChangeStatus);
+ test(diskChangeStatus == KErrNone); // should have got a disk change notification after dismount
+ r = TheFs.Drive(driveInfo, driveNo);
+ test (r==KErrNone);
+ test (driveInfo.iType != EMediaNotPresent);
+
+
+
+ //*******************************************************************************************************
+ // Issue a EFsDismountNotifyClients with multiple clients
+ // Verify that the dismount completes if a client re-registers for dismount notifications BEFORE calling AllowDismount
+ //*******************************************************************************************************
+
+ test.Next(_L("T_Clamp - TestDeferredDismount(), testing unmounting with multiple registered clients & a re-registration"));
+
+ for(i=0; i< KNumClients; i++)
+ {
+ r=clientFs[i].Connect();
+ test(r==KErrNone);
+ }
+ // Cancel any deferred dismount in preparation for the next test
+ TheFs.NotifyDismountCancel();
+
+ // All clients register for dismount notification
+ for(i=0; i< KNumClients; i++)
+ {
+ clientNotifies[i] = KErrNone;
+ clientFs[i].NotifyDismount(driveNo, clientNotifies[i]);
+ test(clientNotifies[i] == KRequestPending);
+ }
+
+ // Issue a EFsDismountNotifyClients & wait for clients to respond
+ clientDismount = KErrNone;
+ TheFs.NotifyDismount(driveNo, clientDismount, EFsDismountNotifyClients);
+ test(clientDismount == KRequestPending);
+
+ // Check all clients have received the notification
+ for(i=0; i< KNumClients; i++)
+ {
+ User::WaitForRequest(clientNotifies[i]);
+ test(clientNotifies[i] == KErrNone);
+ }
+ // All clients - except first one - invoke AllowDismount
+ for(i=1; i< KNumClients; i++)
+ {
+ r=clientFs[i].AllowDismount(driveNo);
test(r==KErrNone);
}
- else if(fsExt1Present) // untested !
+
+
+ // verify dismount has not yet completed
+ test(clientDismount == KRequestPending);
+
+
+ // first client re-registers for dismount notifications
+ clientFs[0].NotifyDismount(driveNo, clientNotifies[0]);
+ test(clientNotifies[0] == KRequestPending);
+
+ // first client allows dismount
+ clientFs[0].AllowDismount(driveNo);
+ test(r==KErrNone);
+
+ // Wait for dismount
+ User::WaitForRequest(clientDismount);
+ test(clientDismount == KErrNone);
+
+
+ // verify the first client's re-issued dismount notification is still pending
+ test(clientNotifies[0] == KRequestPending);
+
+
+ // Re-mount the file system again
+ RemountFileSystem(driveNo, fsName, fsExtName_0, fsExtName_1);
+
+
+ // Issue a EFsDismountNotifyClients again & check previously re-registered notification completes
+ test(clientNotifies[0] == KRequestPending);
+ clientDismount = KErrNone;
+ TheFs.NotifyDismount(driveNo, clientDismount, EFsDismountNotifyClients);
+ test(clientDismount == KRequestPending);
+
+ // wait for notification
+ User::WaitForRequest(clientNotifies[0]);
+
+ // first client allows dismount
+ clientFs[0].AllowDismount(driveNo);
+ test(r==KErrNone);
+
+ // Wait for dismount
+ User::WaitForRequest(clientDismount);
+ test(clientDismount == KErrNone);
+
+
+
+ // Re-mount the file system again
+ RemountFileSystem(driveNo, fsName, fsExtName_0, fsExtName_1);
+
+
+
+ //*******************************************************************************************************
+ // Issue a EFsDismountNotifyClients again with a multiple clients & then call RFs::NotifyDismountCancel()
+ // Verify that all clients receive a disk change notification
+ //*******************************************************************************************************
+ test.Next(_L("T_Clamp - TestDeferredDismount(), testing unmounting with registered clients, a re-registration & a cancel"));
+
+ // All clients register for dismount notification & disk change notification
+ for(i=0; i< KNumClients; i++)
{
- r=TheFs.MountFileSystem(fsName,fsExtName_1,driveNo);
+ clientNotifies[i] = KErrNone;
+ clientFs[i].NotifyDismount(driveNo, clientNotifies[i], EFsDismountRegisterClient);
+ test(clientNotifies[i] == KRequestPending);
+
+ clientFs[i].NotifyChange(ENotifyDisk, clientDiskChanges[i]);
+ test.Printf(_L("diskChangeStatus %d"), clientDiskChanges[i].Int());
+ test(clientDiskChanges[i] == KRequestPending);
+ }
+
+
+ // Issue a EFsDismountNotifyClients
+ TheFs.NotifyDismount(driveNo, clientComplete, EFsDismountNotifyClients);
+ test(clientComplete == KRequestPending);
+
+
+ // Check all clients have received the notification
+ for(i=0; i< KNumClients; i++)
+ {
+ User::WaitForRequest(clientNotifies[i]);
+ test(clientNotifies[i] == KErrNone);
+
+ test.Printf(_L("diskChangeStatus %d"), clientDiskChanges[i].Int());
+ test(clientDiskChanges[i] == KRequestPending);
+ }
+
+ // verify dismount has not yet completed
+ test(clientComplete == KRequestPending);
+
+
+ // first client re-registers for dismount notifications
+ clientFs[0].NotifyDismount(driveNo, clientNotifies[0]);
+ test(clientNotifies[0] == KRequestPending);
+
+ // first client acknowledges the dismount request
+ r = clientFs[0].AllowDismount(driveNo);
+ test(r == KErrNone);
+
+
+ // cancel dismount
+// TheFs.NotifyDismountCancel(clientComplete);
+ TheFs.NotifyDismountCancel();
+ test(clientComplete == KErrCancel);
+ User::WaitForRequest(clientComplete);
+
+ // Check all clients have received a disk change notification -
+ // the file server should send a disk change notification when RFs::NotifyDismountCancel() is called
+ for(i=0; i< KNumClients; i++)
+ {
+ User::WaitForRequest(clientDiskChanges[i]);
+ test.Printf(_L("diskChangeStatus %d"), clientDiskChanges[i].Int());
+ test(clientDiskChanges[i] == KErrNone);
+ }
+
+
+ // cleanup
+ for(i=0; i< KNumClients; i++)
+ {
+ clientFs[i].Close();
test(r==KErrNone);
}
- else
- {
- r=TheFs.MountFileSystem(fsName,driveNo);
- test_KErrNone(r);
- }
-
}
--- a/kerneltest/f32test/server/t_format.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/server/t_format.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -741,34 +741,6 @@
test_Value(nRes, nRes == KErrDisMounted);
file1.Close(); //-- this will make the previously "Dismounted" mount die.
- //---------------------------------------------------------------------------------
- //-- 3. check that forced formatting will complete NotifyDismount
- test.Printf(_L("Test forced formatting completes NotifyDismount\n"));
- TRequestStatus stat1;
-
- nRes = file1.Replace(TheFs, KFname, EFileWrite);
- test_KErrNone(nRes);
-
- TheFs.NotifyDismount(gDrive, stat1, EFsDismountRegisterClient);
- test(stat1.Int() == KRequestPending);
-
- fmtMode = EQuickFormat;
- nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
- test_Value(nRes, nRes == KErrInUse);
- format.Close();
-
- test(stat1.Int() == KRequestPending);
-
- fmtMode = EQuickFormat | EForceFormat;
- nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
- test_KErrNone(nRes);
- format.Close();
-
- User::WaitForRequest(stat1);
- test(stat1.Int() == KErrNone);
-
- buf8.SetLength(22);
- nRes = file1.Write(buf8);
test_Value(nRes, nRes == KErrDisMounted);
file1.Close();
--- a/kerneltest/f32test/smassstorage/group/t_13cases.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/group/t_13cases.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -28,6 +28,7 @@
USERINCLUDE ../t_13cases/inc
+USERINCLUDE ../t_13cases/traces
USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
--- a/kerneltest/f32test/smassstorage/group/t_gml_tur.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/group/t_gml_tur.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -27,6 +27,7 @@
SOURCE cactivedevicestatenotifierbase.cpp
USERINCLUDE ../inc
+USERINCLUDE ../traces
USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
--- a/kerneltest/f32test/smassstorage/group/t_ms_mocksvr.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/group/t_ms_mocksvr.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -22,7 +22,8 @@
UID 0x1000007B 0x101F7774
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-USERINCLUDE ../inc
+USERINCLUDE ../inc
+USERINCLUDE ../traces
USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
SOURCEPATH ../src
--- a/kerneltest/f32test/smassstorage/group/t_msdrive.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/group/t_msdrive.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -25,6 +25,7 @@
SOURCE drivepublisher.cpp
LIBRARY euser.lib
+USERINCLUDE ../traces
USERINCLUDE ../../../../userlibandfileserver/fileserver/inc
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
--- a/kerneltest/f32test/smassstorage/group/t_msfs.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/group/t_msfs.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -47,8 +47,9 @@
#endif
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
-USERINCLUDE ../inc
+USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
+USERINCLUDE ../traces
+USERINCLUDE ../inc
capability NetworkControl DiskAdmin
--- a/kerneltest/f32test/smassstorage/group/t_msfs_scsi.mmp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/group/t_msfs_scsi.mmp Mon Oct 11 17:54:41 2010 +0100
@@ -29,8 +29,10 @@
LIBRARY euser.lib efsrv.lib hal.lib
OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
-USERINCLUDE ../scsiprot
+USERINCLUDE ../../../../userlibandfileserver/fileserver/smassstorage/inc
+USERINCLUDE ../inc
+USERINCLUDE ../traces
+USERINCLUDE ../scsiprot
SMPSAFE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/f32test/smassstorage/inc/massstoragedebug.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,77 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Class declaration for MassStorageDebug
+*
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __MASSSTORAGEDEBUG_H__
+#define __MASSSTORAGEDEBUG_H__
+
+#include <e32std.h>
+#include <e32svr.h>
+
+//#define _USBMS_DEBUG_PRINT_
+
+// Display some info during IN double-buffering
+//#define PRINT_MSDC_MULTITHREADED_READ_INFO
+
+
+#if defined(_USBMS_DEBUG_PRINT_) && (defined(_DEBUG) || defined(_DEBUG_RELEASE))
+#define __PRINT(t) {RDebug::Print(t);}
+#define __PRINT1(t,a) {RDebug::Print(t,a);}
+#define __PRINT2(t,a,b) {RDebug::Print(t,a,b);}
+#define __PRINT3(t,a,b,c) {RDebug::Print(t,a,b,c);}
+#define __PRINT4(t,a,b,c,d) {RDebug::Print(t,a,b,c,d);}
+#define __PRINT5(t,a,b,c,d,e) {RDebug::Print(t,a,b,c,d,e);}
+#define __PRINT8BIT1(t,a) {TFileName temp;temp.Copy(a);RDebug::Print(t,&temp);}
+#define __PRINT1TEMP(t,a) {TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}
+#define __PRINTERR(txt, err) {if(KErrNone != err) __PRINT1(txt, err);}
+
+_LIT(KMsgIn, ">>%S\n");
+_LIT(KMsgOut,"<<%S\n");
+
+class TMSLogFn
+{
+ protected:
+ TBuf<100> iName;
+
+ public:
+ TMSLogFn(const TDesC& aName){iName = aName; RDebug::Print(KMsgIn, &iName);};
+ ~TMSLogFn(){RDebug::Print(KMsgOut, &iName);};
+};
+
+#define __FNLOG(name) TMSLogFn __fn_log__(_L(name))
+
+#else
+#define __PRINT(t)
+#define __PRINT1(t,a)
+#define __PRINT2(t,a,b)
+#define __PRINT3(t,a,b,c)
+#define __PRINT4(t,a,b,c,d)
+#define __PRINT5(t,a,b,c,d,e)
+#define __PRINT8BIT1(t,a)
+#define __PRINT1TEMP(t,a)
+#define __PRINTERR(txt,err)
+#define __FNLOG(name)
+#endif
+
+#endif // __MASSSTORAGEDEBUG_H__
--- a/kerneltest/f32test/smassstorage/inc/t_cusbmassstoragecontroller.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/inc/t_cusbmassstoragecontroller.h Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -25,7 +25,7 @@
#include <e32base.h>
#include "cusbmassstorageserver.h"
-#include "protocol.h"
+#include "mprotocol.h"
#include "massstoragedebug.h"
/**
--- a/kerneltest/f32test/smassstorage/inc/t_gml_tur_protocol.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/inc/t_gml_tur_protocol.h Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -23,10 +23,6 @@
#ifndef __T_GML_TUR_PROTOCOL_H__
#define __T_GML_TUR_PROTOCOL_H__
-#include <e32base.h> // C Class Definitions, Cleanup Stack
-#include <e32def.h> // T Type Definitions
-#include <e32std.h> // ELeave definition
-#include "protocol.h"
class CScsiProtocol : public CBase, public MProtocolBase
{
--- a/kerneltest/f32test/smassstorage/scsiprot/t_ms_scsi.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/scsiprot/t_ms_scsi.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -23,7 +23,15 @@
#include <e32test.h>
#include <f32fsys.h>
#include <e32std.h>
-#include <e32std_private.h> // Caps.iMediaAtt
+//#include <e32std_private.h> // Caps.iMediaAtt
+
+#include <e32def.h>
+#include <f32fsys.h> // for Proxy drive
+
+#include "mprotocol.h"
+#include "mtransport.h"
+#include "scsiprot.h"
+#include "drivemanager.h"
#include "massstoragedebug.h"
--- a/kerneltest/f32test/smassstorage/scsiprot/t_ms_scsi.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/scsiprot/t_ms_scsi.h Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -23,11 +23,6 @@
#ifndef __T_MS_SCSI_H__
#define __T_MS_SCSI_H__
-#include <e32def.h>
-#include <f32fsys.h> // for Proxy drive
-
-#include "scsiprot.h"
-#include "drivemanager.h"
/**
--- a/kerneltest/f32test/smassstorage/scsiprot/t_ms_scsi_steps.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/scsiprot/t_ms_scsi_steps.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -29,6 +29,9 @@
#include "massstoragedebug.h"
+#include "mtransport.h"
+#include "mprotocol.h"
+#include "scsiprot.h"
#include "t_ms_main.h"
#include "t_ms_scsi.h"
--- a/kerneltest/f32test/smassstorage/src/t_cusbmassstoragescheduler.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/src/t_cusbmassstoragescheduler.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -13,6 +13,7 @@
// Description:
//
+#include "massstoragedebug.h"
#include "cusbmassstoragescheduler.h"
#include "cusbmassstorageserver.h"
--- a/kerneltest/f32test/smassstorage/src/t_gml_tur.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/src/t_gml_tur.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -17,9 +17,10 @@
#include <e32std.h>
#include <e32test.h>
#include <testusbc.h>
+#include "mtransport.h"
+#include "mprotocol.h"
#include "t_gml_tur_protocol.h"
#include "t_gml_tur_controller.h"
-#include "protocol.h"
#include "cbulkonlytransport.h"
LOCAL_D RTest test(_L("t_gml_tur"));
--- a/kerneltest/f32test/smassstorage/src/t_gml_tur_controller.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/src/t_gml_tur_controller.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -13,8 +13,10 @@
// Description:
//
-#include "e32base.h"
-#include "e32base_private.h"
+
+
+#include <e32std.h>
+#include "mprotocol.h"
#include "t_gml_tur_controller.h"
/**
--- a/kerneltest/f32test/smassstorage/src/t_gml_tur_protocol.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/src/t_gml_tur_protocol.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -13,6 +13,8 @@
// Description:
//
+#include <e32base.h>
+#include "mprotocol.h"
#include "t_gml_tur_protocol.h"
/**
--- a/kerneltest/f32test/smassstorage/src/t_ms_mountstart.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/src/t_ms_mountstart.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -52,10 +52,10 @@
@internalTechnology
*/
+#define __E32TEST_EXTENSION__
#include <f32file.h>
#include <e32test.h>
#include <e32std.h>
-#include <e32std_private.h>
#include <e32svr.h>
#include <hal.h>
#include <massstorage.h>
@@ -571,7 +571,9 @@
test(trsClientComplete == KErrCancel);
test.Next(_L("...issuing a forced dismount request"));
fs.NotifyDismount(removalDrvNo, trsClientComplete, EFsDismountForceDismount);
- test(trsClientComplete == KErrNone);
+
+ User::WaitForRequest(trsClientComplete);
+ test_KErrNone(trsClientComplete.Int());
expectedAllowDismountRet = KErrNotReady;
expectedCompletionCode = KErrNone;
}
@@ -689,7 +691,8 @@
// Since all clients have been closed, the next stage should result in a dismount
test.Next(_L("Notify clients of pending media removal and check status"));
fs.NotifyDismount(removalDrvNo, trsClientComplete, EFsDismountNotifyClients);
- test(trsClientComplete == KErrNone);
+ User::WaitForRequest(trsClientComplete);
+ test_KErrNone(trsClientComplete.Int());
test.Next(_L("Mount FAT FS on to the removal drive"));
LOG_AND_TEST(KErrNone, fs.MountFileSystem(fsName, removalDrvNo));
--- a/kerneltest/f32test/smassstorage/t_13cases/inc/cusbmassstoragecontroller.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/t_13cases/inc/cusbmassstoragecontroller.h Mon Oct 11 17:54:41 2010 +0100
@@ -28,15 +28,6 @@
class CBulkOnlyTransport;
-/**
-Stub drive manager for bulk-only transport testing.
-*/
-class CDriveManager
- {
-public:
- TInt Connect(TUint aLun);
- TInt Disconnect(TUint aLun);
- };
/**
Stub Mass Storage Controller class for bulk-only transport testing.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/f32test/smassstorage/t_13cases/inc/drivemanager.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,35 @@
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+/** @file
+@internalTechnology
+*/
+
+#ifndef __DRIVEMANAGER_H__
+#define __DRIVEMANAGER_H__
+
+/**
+Stub drive manager for bulk-only transport testing.
+*/
+class CDriveManager
+ {
+public:
+ TInt Connect(TUint aLun);
+ TInt Disconnect(TUint aLun);
+ };
+
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/f32test/smassstorage/t_13cases/inc/massstoragedebug.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,77 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Class declaration for MassStorageDebug
+*
+*
+*/
+
+
+
+/**
+ @file
+*/
+
+#ifndef __MASSSTORAGEDEBUG_H__
+#define __MASSSTORAGEDEBUG_H__
+
+#include <e32std.h>
+#include <e32svr.h>
+
+//#define _USBMS_DEBUG_PRINT_
+
+// Display some info during IN double-buffering
+//#define PRINT_MSDC_MULTITHREADED_READ_INFO
+
+
+#if defined(_USBMS_DEBUG_PRINT_) && (defined(_DEBUG) || defined(_DEBUG_RELEASE))
+#define __PRINT(t) {RDebug::Print(t);}
+#define __PRINT1(t,a) {RDebug::Print(t,a);}
+#define __PRINT2(t,a,b) {RDebug::Print(t,a,b);}
+#define __PRINT3(t,a,b,c) {RDebug::Print(t,a,b,c);}
+#define __PRINT4(t,a,b,c,d) {RDebug::Print(t,a,b,c,d);}
+#define __PRINT5(t,a,b,c,d,e) {RDebug::Print(t,a,b,c,d,e);}
+#define __PRINT8BIT1(t,a) {TFileName temp;temp.Copy(a);RDebug::Print(t,&temp);}
+#define __PRINT1TEMP(t,a) {TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}
+#define __PRINTERR(txt, err) {if(KErrNone != err) __PRINT1(txt, err);}
+
+_LIT(KMsgIn, ">>%S\n");
+_LIT(KMsgOut,"<<%S\n");
+
+class TMSLogFn
+{
+ protected:
+ TBuf<100> iName;
+
+ public:
+ TMSLogFn(const TDesC& aName){iName = aName; RDebug::Print(KMsgIn, &iName);};
+ ~TMSLogFn(){RDebug::Print(KMsgOut, &iName);};
+};
+
+#define __FNLOG(name) TMSLogFn __fn_log__(_L(name))
+
+#else
+#define __PRINT(t)
+#define __PRINT1(t,a)
+#define __PRINT2(t,a,b)
+#define __PRINT3(t,a,b,c)
+#define __PRINT4(t,a,b,c,d)
+#define __PRINT5(t,a,b,c,d,e)
+#define __PRINT8BIT1(t,a)
+#define __PRINT1TEMP(t,a)
+#define __PRINTERR(txt,err)
+#define __FNLOG(name)
+#endif
+
+#endif // __MASSSTORAGEDEBUG_H__
--- a/kerneltest/f32test/smassstorage/t_13cases/inc/t_13cases_protocol.h Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/t_13cases/inc/t_13cases_protocol.h Mon Oct 11 17:54:41 2010 +0100
@@ -24,11 +24,7 @@
#ifndef __T_13CASES_PROTOCOL_H__
#define __T_13CASES_PROTOCOL_H__
-#include <e32base.h>
-#include <e32def.h>
-#include <e32std.h>
-
-#include "protocol.h"
+#include "mprotocol.h"
class CScsiProtocol : public CBase, public MProtocolBase
{
--- a/kerneltest/f32test/smassstorage/t_13cases/src/controller.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/t_13cases/src/controller.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -14,7 +14,10 @@
//
-#include "protocol.h"
+#include <e32std.h>
+#include "mprotocol.h"
+#include "mtransport.h"
+#include "drivemanager.h"
#include "cusbmassstoragecontroller.h"
#include "cbulkonlytransport.h"
--- a/kerneltest/f32test/smassstorage/t_13cases/src/protocol.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/t_13cases/src/protocol.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -13,7 +13,10 @@
// Description:
//
-
+#include <e32std.h>
+#include <e32base.h>
+#include "mtransport.h"
+#include "mprotocol.h"
#include "t_13cases_protocol.h"
/**
--- a/kerneltest/f32test/smassstorage/t_13cases/src/t_13cases.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/kerneltest/f32test/smassstorage/t_13cases/src/t_13cases.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -22,7 +22,10 @@
#include <e32std.h>
#include <e32test.h>
#include <testusbc.h>
+#include "mtransport.h"
+#include "mprotocol.h"
#include "t_13cases_protocol.h"
+#include "drivemanager.h"
#include "cusbmassstoragecontroller.h"
#include "cbulkonlytransport.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/f32test/smassstorage/t_13cases/traces/OstTraceDefinitions.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+// OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
+// REMOVE BEFORE CHECK-IN TO VERSION CONTROL
+//#define OST_TRACE_COMPILER_IN_USE
+#include <opensystemtrace.h>
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/kerneltest/f32test/smassstorage/traces/OstTraceDefinitions.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+// OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
+// REMOVE BEFORE CHECK-IN TO VERSION CONTROL
+//#define OST_TRACE_COMPILER_IN_USE
+#include <opensystemtrace.h>
+#endif
--- a/userlibandfileserver/fileserver/group/release.txt Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/group/release.txt Mon Oct 11 17:54:41 2010 +0100
@@ -1,3 +1,14 @@
+Version 2.00.4005
+=================
+(Made by fadhliM 04/10/2010)
+
+1. niccox
+ 1. ou1cimx1#597260 smassstorage trace compiler
+
+2. migubarr
+ 1. ou1cimx1#598134 RFs::NotifyDismount(,,EFsDismountNotifyClients) doesn't always complete as expected
+
+
Version 2.00.4004
=================
(Made by vfebvre 24/09/2010)
--- a/userlibandfileserver/fileserver/inc/f32fsys.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/inc/f32fsys.h Mon Oct 11 17:54:41 2010 +0100
@@ -251,7 +251,6 @@
IMPORT_C TName Name() const;
IMPORT_C virtual TBool IsCorrectThread();
inline CFsObjectCon* Container() const;
- inline TInt AccessCount() const;
protected:
void DoClose();
TInt UniqueID() const;
@@ -469,7 +468,11 @@
TInt DismountProxyDrive();
TInt ForceUnmountFileSystemForFormatting();
-public:
+ void DismountClientAdded();
+ void DismountClientRemoved();
+ TInt DismountClientCount();
+ TInt DeferredDismountCheck();
+
void DismountLock();
TInt DismountUnlock();
TInt DismountLocked() const;
@@ -518,7 +521,6 @@
IMPORT_C TBool IsMainThread() const;
IMPORT_C void DriveFault(TBool aDriveError) const;
void DoDismount();
- void DoCompleteDismountNotify(TInt aCompletionCode);
private:
@@ -526,7 +528,7 @@
enum
{
ENotifyOff = 0x01,
- EDismountDeferred= 0x02,
+ EDismountDeferred= 0x02, // Dismount initiated, waiting for clients to respond with EFsAllowDismount or files to become unclamped
ENotRugged = 0x04,
EClampPresent = 0x08,
EDriveIsSynch = 0x10, //-- is set on mount when the drive is synchronous (doesn't have its own thread)
@@ -550,9 +552,9 @@
TInt iDismountLock;
TInt iMountFailures; // number of times the mount has failed
TInt iLastMountError;
-
- TInt iSpare1;
- TInt iSpare2;
+
+ TInt iDismountClientCount; // number of EFsAllowDismount requests pending following a EFsDismountNotifyClients request
+ CFsInternalRequest* iDeferredDismountRequest;
friend class LocalDrives; // for access to iChanged flag
@@ -2039,9 +2041,6 @@
void InitL();
inline CFileCB& File();
- // override CFsDispatchObject::Close() so that we can flush dirty data
- void Close();
-
// For serialising aync requests
TBool RequestStart(CFsMessageRequest* aRequest);
void RequestEnd(CFsMessageRequest* aRequest);
--- a/userlibandfileserver/fileserver/inc/f32fsys.inl Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/inc/f32fsys.inl Mon Oct 11 17:54:41 2010 +0100
@@ -1347,6 +1347,4 @@
inline TInt CFsObject::Dec()
{ return __e32_atomic_tas_ord32(&iAccessCount, 1, -1, 0); }
-inline TInt CFsObject::AccessCount() const
- {return iAccessCount;}
--- a/userlibandfileserver/fileserver/inc/f32ver.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/inc/f32ver.h Mon Oct 11 17:54:41 2010 +0100
@@ -58,6 +58,6 @@
@see TVersion
*/
-const TInt KF32BuildVersionNumber=4004;
+const TInt KF32BuildVersionNumber=4005;
//
#endif
--- a/userlibandfileserver/fileserver/sfile/sf_drv.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_drv.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -130,6 +130,10 @@
iMount=TheContainer->CreateL();
TInt r=iLock.CreateLocal();
User::LeaveIfError(r);
+
+ iDeferredDismountRequest = new(ELeave) CFsInternalRequest;
+ iDeferredDismountRequest->Set(DeferredDismountOp,NULL);
+ iDeferredDismountRequest->SetDriveNumber(aDriveNumber);
}
TInt TDrive::CheckMountAndEntryName(const TDesC& aName)
@@ -2345,10 +2349,66 @@
{ return(iDismountLock); }
+/**
+DismountClientAdded() -
+
+Increments the count of clients which need to respond to a dismount request - by calling RFs::AllowDismount() -
+before the dismount can process
+
+Called when a EFsDismountRegisterClient request is completed by RFs::NotifyDismount(,,EFsDismountNotifyClients)
+*/
+void TDrive::DismountClientAdded()
+ {
+ __e32_atomic_add_ord32(&iDismountClientCount, (TUint32) 1);
+ }
+
+/**
+DismountClientRemoved() -
+Called when a EFsDismountRegisterClient request is deleted. E.g. by RFs::AllowDismount()
+*/
+void TDrive::DismountClientRemoved()
+ {
+ ASSERT(iDismountClientCount > 0);
+ if ((__e32_atomic_add_ord32(&iDismountClientCount, (TUint32) -1) == 1) &&
+ (!FsThreadManager::IsDriveThread(iDriveNumber,EFalse)) &&
+ DismountDeferred())
+ {
+ iDeferredDismountRequest->Dispatch();
+ }
+ }
+
+TInt TDrive::DismountClientCount()
+ {
+ return iDismountClientCount;
+ }
+
+
+/*
+Dismount the file system if a deferred dismount has been schedulued and there are no waiting clients and no clamps
+*/
+TInt TDrive::DeferredDismountCheck()
+ {
+ // Don't dismount if no deferred dismount is scheduled
+ if (!DismountDeferred())
+ return KErrNone;
+
+ // Don't dismount if clients are waiting
+ if (DismountClientCount() > 0)
+ return KErrNone;
+
+ // Don't dismount if files are clamped
+ TInt clampErr = ClampsOnDrive();
+ if (clampErr != 0 && clampErr != KErrNotSupported)
+ return KErrNone;
+
+ // Nothing to wait for, so dismount immediately
+ __ASSERT_DEBUG(GetFSys(), Fault(EAllowDismount));
+ return DeferredDismount();
+ }
/**
-Pending flag - set while waiting for clients to accept the dismount
+Dismount deferred flag - set while waiting for clients to accept the dismount or files to become unclamped
*/
void TDrive::SetDismountDeferred(TBool aPending)
{
@@ -2529,19 +2589,7 @@
//----------------------------------------------------------------------------
/**
- Complete, remove and delete notification requests
- @param aCompletionCode completion code for some notifications
-*/
-void TDrive::DoCompleteDismountNotify(TInt aCompletionCode)
- {
- FsNotify::HandleDismount(EFsDismountRegisterClient, iDriveNumber, ETrue, KErrNone);
- FsNotify::HandleDismount(EFsDismountNotifyClients, iDriveNumber, ETrue, aCompletionCode);
- FsNotify::HandleDismount(EFsDismountForceDismount, iDriveNumber, ETrue, aCompletionCode);
- }
-
-//----------------------------------------------------------------------------
-/**
- a helper method that allows forced dismounting current mount for volume formatting.
+ a helper method that allows forced unmounting current mount for volume formatting.
*/
TInt TDrive::ForceUnmountFileSystemForFormatting()
{
@@ -2566,8 +2614,6 @@
ForceDismount();
- DoCompleteDismountNotify(KErrDisMounted); //-- complete all dismount notifications
-
return KErrNone;
}
--- a/userlibandfileserver/fileserver/sfile/sf_file.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_file.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -2772,22 +2772,6 @@
iFile->Close();
}
-void CFileShare::Close()
- {
-
- // Flush the write cache before closing the file share
- // NB If there is any dirty data, then a new request will be allocated which will increase
- // the reference count on this file share, thus preventing it from being deleted untill all
- // data has been flushed
- if (AccessCount() == 1)
- {
- CFileCache* fileCache = File().FileCache();
- if (fileCache)
- fileCache->FlushDirty();
- }
-
- CFsDispatchObject::Close();
- }
/**
@@ -3267,8 +3251,8 @@
{
ASSERT(NoOfClamps() == 0);
drive.SetClampFlag(EFalse);
- if (drive.DismountDeferred())
- r = drive.DeferredDismount();
+ // dismount now if no clients waiting...
+ r = drive.DeferredDismountCheck();
}
return r;
--- a/userlibandfileserver/fileserver/sfile/sf_file_cache.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_file_cache.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -2117,7 +2117,13 @@
// Remember the last session which caused the file to become dirty
// Always record whether any session has reserved access so the CheckDiskSpace() behaves correctly
if (iDirtyDataOwner == NULL || session->ReservedAccess(iDriveNum))
+ {
+ if (iDirtyDataOwner)
+ iDirtyDataOwner->Close();
iDirtyDataOwner = session;
+ // open the session to prevent it from being deleted while there is dirty data
+ iDirtyDataOwner->Open();
+ }
// start a timer after which file will be flushed
CDriveThread* driveThread=NULL;
@@ -2132,6 +2138,9 @@
*/
void CFileCache::MarkFileClean()
{
+ if (iDirtyDataOwner)
+ iDirtyDataOwner->Close();
+
iDirtyDataOwner = NULL;
if (!iDriveThread)
--- a/userlibandfileserver/fileserver/sfile/sf_func.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_func.h Mon Oct 11 17:54:41 2010 +0100
@@ -1068,6 +1068,13 @@
static TInt DoRequestL(CFsRequest* aRequest);
};
+class TFsDeferredDismount
+ {
+public:
+ static TInt Initialise(CFsRequest* aRequest);
+ static TInt DoRequestL(CFsRequest* aRequest);
+ };
+
void GetFileFromScratch(CFsRequest* aRequest, CFileShare*& aShare, CFileCB*& aFile);
#endif // __SF_FUNC_H
--- a/userlibandfileserver/fileserver/sfile/sf_notify.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_notify.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -40,7 +40,11 @@
//
//
{
- __ASSERT_DEBUG(!iLink.iNext,Fault(ENotifyInfoDestructor));
+ // message should have been completed already
+ __ASSERT_DEBUG(iMessage.IsNull(), Fault(ENotifyInfoDestructor));
+
+ __ASSERT_DEBUG(iLink.iNext,Fault(ENotifyInfoDestructor));
+ iLink.Deque();
}
void CNotifyInfo::Complete(TInt aError)
@@ -49,10 +53,8 @@
//
{
__PRINT2(_L("CNotifyInfo::Complete 0x%x error=%d"),this,aError);
- if (!iMessage.IsNull()) // Dismount notifiers may be completed but remain in the list
- { // until handled by the client or the session is closed.
+ if (!iMessage.IsNull())
iMessage.Complete(aError);
- }
}
@@ -259,12 +261,27 @@
break;
case EFsDismountRegisterClient:
__ASSERT_ALWAYS(TheDrives[iDriveNumber].DismountUnlock() >= 0, Fault(ENotifyDismountCancel));
+ __ASSERT_ALWAYS(iMessage.IsNull(), Fault(ENotifyDismountCancel));
+ TheDrives[iDriveNumber].DismountClientRemoved();
break;
default:
break;
}
}
+void CDismountNotifyInfo::Complete(TInt aError)
+ {
+ __PRINT2(_L("CDismountNotifyInfo::Complete 0x%x error=%d"),this,aError);
+ if (!iMessage.IsNull())
+ {
+ iMessage.Complete(aError);
+ // inc count of messages completed by EFsDismountNotifyClients & waiting for an EFsAllowDismount request from client
+ if (iMode == EFsDismountRegisterClient)
+ TheDrives[iDriveNumber].DismountClientAdded();
+ }
+ }
+
+
void CDismountNotifyInfo::Initialise(TNotifyDismountMode aMode, TInt aDriveNumber, TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession)
{
iMode = aMode;
@@ -324,7 +341,6 @@
{
isFound=ETrue;
info->Complete(aCompletionCode);
- info->iLink.Deque();
delete(info);
if(aStatus)
break;
@@ -333,18 +349,6 @@
return(isFound);
}
-CNotifyInfo* TBaseQue::DoFindEntry(CSessionFs* aSession, TRequestStatus* aStatus)
- {
- TDblQueIter<CNotifyInfo> q(iHeader);
- CNotifyInfo* info;
- while((info=q++)!=NULL)
- {
- if(info->Session()==aSession && (!aStatus || aStatus==info->Status()))
- return info;
- }
- return NULL;
- }
-
void TBaseQue::DoCancelAll(TInt aCompletionCode)
//
// Cancel all notifications
@@ -356,7 +360,6 @@
while((info=q++)!=NULL)
{
info->Complete(aCompletionCode);
- info->iLink.Deque();
delete(info);
}
__ASSERT_DEBUG(iHeader.IsEmpty(),Fault(EBaseQueCancel));
@@ -433,7 +436,6 @@
{
__PRINT1(_L("TChangeQue::CheckChange()-Matching info=0x%x"),info);
info->Complete(KErrNone);
- info->iLink.Deque();
delete(info);
}
}
@@ -530,7 +532,6 @@
{
__PRINT1(_L("TDiskSpaceQue::CheckDiskSpace()-Matching info=0x%x"),info);
info->Complete(KErrNone);
- info->iLink.Deque();
delete(info);
}
}
@@ -579,7 +580,6 @@
{
__PRINT1(_L("TDiskSpaceQue::CheckDiskSpace()-Matching info=0x%x"),info);
info->Complete(KErrNone);
- info->iLink.Deque();
delete(info);
}
}
@@ -646,7 +646,6 @@
{
__PRINT1(_L("TDebugQue::CheckDebug()-Matching info=0x%x"),info);
info->Complete(KErrNone);
- info->iLink.Deque();
delete(info);
}
}
@@ -664,22 +663,41 @@
return(KErrNone);
}
-TInt TDismountNotifyQue::CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus)
+void TDismountNotifyQue::CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus)
//
-// Returns the drive number or KErrNotFound
//
{
iQLock.Wait();
- // return the drive number
- CDismountNotifyInfo* info = (CDismountNotifyInfo*) DoFindEntry(aSession, aStatus);
- TInt driveNumber = info ? info->DriveNumber() : KErrNotFound;
+ TDblQueIter<CDismountNotifyInfo> q(iHeader);
+ CDismountNotifyInfo* info;
+ while((info=q++)!=NULL)
+ {
+ if(info->Session()==aSession && (!aStatus || aStatus==info->Status()))
+ {
+ TInt driveNumber = info->DriveNumber();
+
+ info->Complete(aCompletionCode);
+ TInt mode = info->Mode();
+
+ delete info;
+ info = NULL;
- TBaseQue::DoCancelSession(aSession,aCompletionCode,aStatus);
+ // if we're cancelling a dismount request (EFsDismountNotifyClients or EFsDismountForceDismount),
+ // then we need to cancel the deferred dismount and issue a disk change notification as observers
+ // may be expecting one...
+ if (mode == EFsDismountNotifyClients || mode == EFsDismountForceDismount)
+ {
+ TheDrives[driveNumber].SetDismountDeferred(EFalse);
+ FsNotify::DiskChange(driveNumber);
+ }
+
+ if(aStatus)
+ break;
+ }
+ }
iQLock.Signal();
-
- return(driveNumber);
}
void TDismountNotifyQue::CancelAll(TInt aCompletionCode)
@@ -708,40 +726,43 @@
__PRINT1(_L("TDismountNotifyQue::CheckDismount()-Matching info=0x%x"),info);
info->Complete(aError);
if(aRemove)
- {
- info->iLink.Deque();
- delete(info);
- }
+ delete info;
}
}
- __ASSERT_ALWAYS(!aRemove || TheDrives[aDrive].DismountLocked() == 0, Fault(EDismountLocked));
+ __ASSERT_ALWAYS(!(aRemove && aMode == EFsDismountRegisterClient && TheDrives[aDrive].DismountLocked() > 0), Fault(EDismountLocked));
iQLock.Signal();
}
TBool TDismountNotifyQue::HandlePendingDismount(CSessionFs* aSession, TInt aDrive)
//
-// Determine if the session has any outstanding dismount notifications on the specified drive.
+// Determine if the session has any outstanding *completed* dismount notifications on the specified drive
+// and delete them. Called from TFsAllowDismount::DoRequestL()
//
{
iQLock.Wait();
- TDblQueIter<CNotifyInfo> q(iHeader);
- CNotifyInfo* info;
+ TDblQueIter<CDismountNotifyInfo> q(iHeader);
+ CDismountNotifyInfo* info;
+
+ TBool entryFound = EFalse;
+
while((info=q++)!=NULL)
{
__ASSERT_DEBUG(info->Type()==CNotifyInfo::EDismount,Fault(EBadDismountNotifyType));
if(((CDismountNotifyInfo*)info)->IsMatching(EFsDismountRegisterClient, aDrive, aSession))
{
- __PRINT1(_L("TDismountNotifyQue::CheckDismount()-Pending info=0x%x"),info);
- info->iLink.Deque();
- delete(info);
- iQLock.Signal();
- return ETrue;
+ __PRINT1(_L("TDismountNotifyQue::HandlePendingDismount()-Pending info=0x%x"),info);
+
+ if (info->Completed())
+ delete info;
+
+ entryFound = ETrue;
}
}
iQLock.Signal();
- return EFalse;
+
+ return entryFound;
}
void FsNotify::Initialise()
@@ -948,15 +969,14 @@
iDebugQue.CancelSession(aSession,KErrCancel,aStatus);
}
-TInt FsNotify::CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus)
+void FsNotify::CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus)
//
// Cancel all media removal notification(s) setup by aSession (if aStatus == NULL)
// else cancels all outstanding notifications(s) for the session
//
{
__PRINT2(_L("FsNotify::CancelDismountNotifySession() aSession=0x%x aStatus=0x%x"),aSession,aStatus);
- TInt drive = iDismountNotifyQue.CancelSession(aSession,KErrCancel,aStatus);
- return drive;
+ iDismountNotifyQue.CancelSession(aSession,KErrCancel,aStatus);
}
void FsNotify::CancelSession(CSessionFs* aSession)
--- a/userlibandfileserver/fileserver/sfile/sf_request.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_request.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -2212,6 +2212,9 @@
Free();
}
}
+ else if(func==KDeferredDismount)
+ {
+ }
else
Fault(EInternalRequestComplete3);
}
--- a/userlibandfileserver/fileserver/sfile/sf_ses.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_ses.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -40,9 +40,12 @@
return new(ELeave) CSessionFs;
}
-CSessionFs::~CSessionFs()
+
+void CSessionFs::Cleanup()
{
__PRINT1(_L("CSessionFs::~CSessionFs() deleting... = 0x%x"),this);
+
+ CancelAsyncRequests(this);
FsNotify::CancelSession(this);
@@ -74,41 +77,28 @@
delete iPath;
- iSessionFlagsLock.Close();
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
__e32_atomic_add_ord32(&SessionCount, (TUint32) -1);
#endif
}
+CSessionFs::~CSessionFs()
+ {
+ }
+
void CSessionFs::Close()
{
- TheFileServer->SessionQueueLockWait();
-
- if (iAccessCount == 1)
- {
- // close the objects owned by this session
- // NB closing a CFileShare may allocate a request to flush dirty data which will
- // in turn increment iAccessCount on this session
- if (iHandles)
- {
- // Cancel any ASYNC requests belonging to this session BEFORE
- // CSessionFs is deleted to avoid a KERN-EXEC 44 (EBadMessageHandle)
- CancelAsyncRequests(this);
- delete iHandles;
- iHandles = NULL;
- }
- }
-
if (__e32_atomic_tas_ord32(&iAccessCount, 1, -1, 0) == 1)
{
RMessage2 message = iMessage;
+ Cleanup();
+ TheFileServer->SessionQueueLockWait();
delete this;
+ TheFileServer->SessionQueueLockSignal();
// NB Must complete the message AFTER the session has been deleted...
message.Complete(KErrNone);
}
-
- TheFileServer->SessionQueueLockSignal();
}
void CSessionFs::CreateL()
@@ -119,8 +109,6 @@
__PRINT1(_L("CSessionFs::CreateL 0x%x"),this);
iHandles=CFsObjectIx::NewL();
- TInt r = iSessionFlagsLock.CreateLocal();
- User::LeaveIfError(r);
}
TInt CSessionFs::CurrentDrive()
@@ -231,35 +219,27 @@
TBool CSessionFs::TestSessionFlags(TUint32 aFlags)
{
- iSessionFlagsLock.Wait();
- TBool b = (iSessionFlags & aFlags) == aFlags;
- iSessionFlagsLock.Signal();
- return(b);
+ return (TBool) ((iSessionFlags & aFlags) == aFlags);
}
void CSessionFs::SetSessionFlags(TUint32 aBitsToSet, TUint32 aBitsToClear)
{
- iSessionFlagsLock.Wait();
+ // currently this only called from the main thread.
+ __CHECK_MAINTHREAD();
- iSessionFlags &= ~aBitsToClear;
- iSessionFlags |= aBitsToSet;
-
- iSessionFlagsLock.Signal();
+ __e32_atomic_ior_ord_ptr(&iSessionFlags, aBitsToSet);
+ __e32_atomic_and_ord_ptr(&iSessionFlags, ~aBitsToClear);
}
void CSessionFs::CloseRequestCountInc()
{
- iSessionFlagsLock.Wait();
- iCloseRequestCount++;
- iSessionFlagsLock.Signal();
+ __e32_atomic_add_ord32(&iCloseRequestCount, (TUint32) 1);
}
void CSessionFs::CloseRequestCountDec()
{
- iSessionFlagsLock.Wait();
- iCloseRequestCount--;
- iSessionFlagsLock.Signal();
+ __e32_atomic_add_ord32(&iCloseRequestCount, (TUint32) -1);
}
//
--- a/userlibandfileserver/fileserver/sfile/sf_std.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_std.h Mon Oct 11 17:54:41 2010 +0100
@@ -922,12 +922,12 @@
private:
CSessionFs();
~CSessionFs();
+ void Cleanup();
private:
TInt iResourceCountMark;
TInt iResourceCount;
TInt iSessionFlags;
- RFastLock iSessionFlagsLock;
CFsObjectIx* iHandles;
HBufC* iPath;
RArray<TReservedDriveAccess> iReservedDriveAccess;
@@ -1466,11 +1466,12 @@
public:
~CNotifyInfo();
void Initialise(TInfoType aType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
- void Complete(TInt aError);
+ virtual void Complete(TInt aError);
//
inline CSessionFs* Session();
inline TRequestStatus* Status();
- inline TInfoType Type() const {return(iType);}
+ inline TInfoType Type() {return(iType);}
+ inline TBool Completed() {return iMessage.IsNull();}
public:
TDblQueLink iLink;
protected:
@@ -1522,9 +1523,12 @@
{
public:
~CDismountNotifyInfo();
+ virtual void Complete(TInt aError);
void Initialise(TNotifyDismountMode aMode, TInt aDriveNumber,TRequestStatus* iStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
TBool IsMatching(TNotifyDismountMode aMode, TInt aDriveNumber, CSessionFs* aSession);
inline TInt DriveNumber() {return iDriveNumber;}
+ inline TNotifyDismountMode Mode() {return iMode;}
+
private:
TNotifyDismountMode iMode;
TInt iDriveNumber;
@@ -1541,7 +1545,6 @@
void DoAddNotify(CNotifyInfo* aInfo);
TBool DoCancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
void DoCancelAll(TInt aCompletionCode);
- CNotifyInfo* DoFindEntry(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
TBool IsEmpty();
protected:
TDblQue<CNotifyInfo> iHeader;
@@ -1589,7 +1592,7 @@
{
public:
TInt AddNotify(CNotifyInfo* aInfo);
- TInt CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
+ void CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
void CancelAll(TInt aCompletionCode);
void CheckDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt aError);
TBool HandlePendingDismount(CSessionFs* aSession, TInt aDrive);
@@ -1612,7 +1615,7 @@
static void CancelChangeSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
static void CancelDiskSpaceSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
static void CancelDebugSession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
- static TInt CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
+ static void CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
static void CancelSession(CSessionFs* aSession);
static TBool HandlePendingDismount(CSessionFs* aSession, TInt aDriveNumber);
static TBool IsChangeQueEmpty(TInt aDrive);
@@ -1704,12 +1707,13 @@
const TInt KDispatchObjectClose=KMaxTInt-1;
const TInt KSessionInternalReserved2=KMaxTInt-2; // not used any more - placeholder
const TInt KSessionInternalReserved3=KMaxTInt-3; // not used any more - placeholder
-const TInt KSessionInternalReserved4=KMaxTInt-4; // not used any more - placeholder
+const TInt KDeferredDismount=KMaxTInt-4;
const TInt KFileShareClose=KMaxTInt-5;
const TInt KFlushDirtyData=KMaxTInt-6;
const TOperation DispatchObjectCloseOp= {KDispatchObjectClose, EInternalRequest, &TFsCloseObject::Initialise, NULL, &TFsCloseObject::DoRequestL };
const TOperation FileShareCloseOp= {KFileShareClose, EInternalRequest, &TFsCloseFileShare::Initialise, NULL, &TFsCloseFileShare::DoRequestL };
+const TOperation DeferredDismountOp= {KDeferredDismount, EInternalRequest, &TFsDeferredDismount::Initialise, NULL, &TFsDeferredDismount::DoRequestL };
extern TBool OpenOnDriveZOnly;
extern TBool LocalFileSystemInitialized;
--- a/userlibandfileserver/fileserver/sfile/sf_sys.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_sys.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1181,7 +1181,9 @@
if (err == CFsRequest::EReqActionBusy)
return err;
- DoCompleteDismountNotify(err);
+ // Complete, remove and delete notification requests
+ FsNotify::HandleDismount(EFsDismountNotifyClients, iDriveNumber, ETrue, err);
+ FsNotify::HandleDismount(EFsDismountForceDismount, iDriveNumber, ETrue, err);
SetDismountDeferred(EFalse);
@@ -1358,9 +1360,8 @@
//
{
CSessionFs* session = aRequest->Session();
- TInt drive = FsNotify::CancelDismountNotifySession(session, (TRequestStatus*)aRequest->Message().Ptr0());
- if (drive >= 0)
- TheDrives[drive].SetDismountDeferred(EFalse);
+ FsNotify::CancelDismountNotifySession(session, (TRequestStatus*)aRequest->Message().Ptr0());
+
return KErrNone;
}
@@ -1385,22 +1386,7 @@
if(!FsNotify::HandlePendingDismount(aRequest->Session(), driveNumber))
return KErrNotFound;
- if(theDrive->DismountLocked())
- return KErrNone;
-
- TInt clampErr = theDrive->ClampsOnDrive();
- TInt err = KErrNone;
-
- if ((theDrive->DismountDeferred()) && (clampErr == 0 || clampErr == KErrNotSupported))
- {
- // No clamps to worry about, so dismount immediately and complete the request
- __ASSERT_DEBUG(aRequest->Drive()->GetFSys(), Fault(EAllowDismount));
-
- // When the last client has responded, allow the media to be forcibly dismounted
- err = theDrive->DeferredDismount();
- }
-
- return err;
+ return theDrive->DeferredDismountCheck();
}
TInt TFsAllowDismount::Initialise(CFsRequest* aRequest)
@@ -1412,6 +1398,23 @@
}
+TInt TFsDeferredDismount::Initialise(CFsRequest* /*aRequest*/)
+ {
+ return KErrNone;
+ }
+
+/*
+Dismount the file system - this internal request is queued when one client issues a EFsDismountNotifyClients
+request and another client with an outstanding EFsDismountRegisterClient closes their session (in the context
+of the main file server thread) without sending a EFsAllowDismount request.
+
+*/
+TInt TFsDeferredDismount::DoRequestL(CFsRequest* aRequest)
+ {
+ return TheDrives[aRequest->DriveNumber()].DeferredDismountCheck();
+ }
+
+
TInt TFsMountProxyDrive::DoRequestL(CFsRequest* aRequest)
{
return LocalDrives::MountProxyDrive(aRequest);
--- a/userlibandfileserver/fileserver/smassstorage/cactivedevicestatenotifierbase.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cactivedevicestatenotifierbase.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
@@ -11,157 +11,147 @@
*
* Contributors:
*
-* Description:
+* Description:
* Class definition for Device State Notifier Base Class
*
*/
-/**
+/**
@file
@internalTechnology
*/
#include <e32base.h>
+#include "mtransport.h"
+#include "mldddevicestatenotification.h"
+#include "drivemanager.h"
+#include "cusbmassstoragecontroller.h"
+#include "cbulkonlytransport.h"
+
#include "cactivedevicestatenotifierbase.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cactivedevicestatenotifierbaseTraces.h"
+#endif
+
+
CActiveDeviceStateNotifierBase::CActiveDeviceStateNotifierBase(CBulkOnlyTransport& aBot,
MLddDeviceStateNotification& aLddDeviceStateNotification)
-/**
- *
- */
- : CActive(EPriorityStandard),
- iBot(aBot),
+ : CActive(EPriorityStandard),
+ iBot(aBot),
iLddDeviceStateNotification(aLddDeviceStateNotification),
- iDeviceState(EUsbcNoState),
- iOldDeviceState(EUsbcNoState)
- {
+ iDeviceState(EUsbcNoState),
+ iOldDeviceState(EUsbcNoState)
+ {
- }
+ }
CActiveDeviceStateNotifierBase* CActiveDeviceStateNotifierBase::NewL(CBulkOnlyTransport& aBot,
MLddDeviceStateNotification& aLddDeviceStateNotification)
-/**
- *
- */
- {
- CActiveDeviceStateNotifierBase* self = new (ELeave) CActiveDeviceStateNotifierBase(aBot, aLddDeviceStateNotification);
- CleanupStack::PushL(self);
- self->ConstructL();
- CActiveScheduler::Add(self);
- CleanupStack::Pop(); // self
- return (self);
- }
+ {
+ CActiveDeviceStateNotifierBase* self = new (ELeave) CActiveDeviceStateNotifierBase(aBot, aLddDeviceStateNotification);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CActiveScheduler::Add(self);
+ CleanupStack::Pop(); // self
+ return (self);
+ }
void CActiveDeviceStateNotifierBase::ConstructL()
-/**
- *
- */
- {
- __FNLOG("CActiveDeviceStateNotifierBase::ConstructL");
- }
+ {
+ }
CActiveDeviceStateNotifierBase::~CActiveDeviceStateNotifierBase()
-/**
- *
- */
- {
- __PRINT(_L("CActiveDeviceStateNotifierBase::~CActiveDeviceStateNotifierBase()"));
- Cancel(); // base class
- }
+ {
+ Cancel(); // base class
+ }
void CActiveDeviceStateNotifierBase::DoCancel()
-/**
- *
- */
- {
- __PRINT(_L("CActiveDeviceStateNotifierBase::DoCancel()"));
- iLddDeviceStateNotification.Cancel();
- }
+ {
+ iLddDeviceStateNotification.Cancel();
+ }
void CActiveDeviceStateNotifierBase::RunL()
-/**
- *
- */
- {
- __FNLOG("CActiveDeviceStateNotifierBase::RunL");
- // This displays the device state.
- // In a real world program, the user could take here appropriate action (cancel a
- // transfer request or whatever).
- __PRINT1(_L("DeviceState Notification = %d"), iDeviceState);
+ {
+ // This displays the device state.
+ // In a real world program, the user could take here appropriate action (cancel a
+ // transfer request or whatever).
+
+ OstTrace1(TRACE_SMASSSTORAGE_STATE, CACTIVEDEVICESTATENOTIFIERBASE_100,
+ "DeviceState Notification = %d", iDeviceState);
- if (!(iDeviceState & KUsbAlternateSetting))
- {
- switch (iDeviceState)
- {
- case EUsbcDeviceStateUndefined: //0
- case EUsbcDeviceStateDefault: //3
- iBot.HwStop();
- break;
+ if (!(iDeviceState & KUsbAlternateSetting))
+ {
+ switch (iDeviceState)
+ {
+ case EUsbcDeviceStateUndefined: //0
+ case EUsbcDeviceStateDefault: //3
+ iBot.HwStop();
+ break;
- case EUsbcDeviceStateAttached: //1
- case EUsbcDeviceStatePowered: //2
+ case EUsbcDeviceStateAttached: //1
+ case EUsbcDeviceStatePowered: //2
// do nothing
break;
- case EUsbcDeviceStateAddress: //4
- if (iOldDeviceState == EUsbcDeviceStateConfigured)
+ case EUsbcDeviceStateAddress: //4
+ if (iOldDeviceState == EUsbcDeviceStateConfigured)
{
iBot.StopBulkOnlyEndpoint();
}
- break;
+ break;
- case EUsbcDeviceStateConfigured: //5
- if (iOldDeviceState == EUsbcDeviceStateSuspended)
- {
- iBot.HwResume();
- }
- else
- {
- iBot.HwStart();
- }
- break;
- case EUsbcDeviceStateSuspended: //6
- if (iOldDeviceState == EUsbcDeviceStateConfigured)
- {
- iBot.HwSuspend();
- }
- break;
- default:
- __PRINT(_L("Device State notifier: ***BAD***\n"));
- iBot.HwStop();
- break;
- }
- iOldDeviceState = iDeviceState;
- }
- else if (iDeviceState & KUsbAlternateSetting)
- {
- __PRINT1(_L("Device State notifier: Alternate interface setting has changed: now %d\n"), iDeviceState & ~KUsbAlternateSetting);
- }
- Activate();
- }
+ case EUsbcDeviceStateConfigured: //5
+ if (iOldDeviceState == EUsbcDeviceStateSuspended)
+ {
+ iBot.HwResume();
+ }
+ else
+ {
+ iBot.HwStart();
+ }
+ break;
+ case EUsbcDeviceStateSuspended: //6
+ if (iOldDeviceState == EUsbcDeviceStateConfigured)
+ {
+ iBot.HwSuspend();
+ }
+ break;
+ default:
+ OstTrace0(TRACE_SMASSSTORAGE_STATE, CACTIVEDEVICESTATENOTIFIERBASE_101,
+ "Device State notifier: ***BAD***");
+ iBot.HwStop();
+ break;
+ }
+ iOldDeviceState = iDeviceState;
+ }
+ else if (iDeviceState & KUsbAlternateSetting)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_STATE, CACTIVEDEVICESTATENOTIFIERBASE_102,
+ "Device State notifier: Alternate interface setting has changed: now %d",
+ iDeviceState & ~KUsbAlternateSetting);
+ }
+ Activate();
+ }
void CActiveDeviceStateNotifierBase::Activate()
-/**
- *
- */
- {
- __FNLOG("CActiveDeviceStateNotifierBase::Activate");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- return;
- }
- iLddDeviceStateNotification.Activate(iStatus, iDeviceState);
- SetActive();
- }
+ {
+ if (IsActive())
+ {
+ return;
+ }
+ iLddDeviceStateNotification.Activate(iStatus, iDeviceState);
+ SetActive();
+ }
--- a/userlibandfileserver/fileserver/smassstorage/cbulkonlytransport.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cbulkonlytransport.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -17,32 +17,44 @@
@file
@internalTechnology
*/
+
+#include <e32std.h>
+#include "mtransport.h"
+#include "mprotocol.h"
+#include "mldddevicestatenotification.h"
+#include "tbulkmm.h"
+
+#include "drivemanager.h"
+#include "cusbmassstoragecontroller.h"
+
#include "cbulkonlytransport.h"
#include "cbulkonlytransportusbcldd.h"
#if !defined(__WINS__) && !defined(__X86__)
#include "cbulkonlytransportusbcscldd.h"
#endif
-#include "usbmsshared.h"
-#include "massstoragedebug.h"
-#include "cusbmassstorageserver.h"
+#include "smassstorage.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cbulkonlytransportTraces.h"
+#endif
//CBW offsets
-LOCAL_D const TInt KCbwSignatureOffset = 0;
-LOCAL_D const TInt KCbwTagOffset = 4;
-LOCAL_D const TInt KCbwDataTransferLengthOffset = 8;
-LOCAL_D const TInt KCbwFlagOffset = 12;
-LOCAL_D const TInt KCbwLunOffset = 13;
-LOCAL_D const TInt KCbwCbLengthOffset = 14;
+static const TInt KCbwSignatureOffset = 0;
+static const TInt KCbwTagOffset = 4;
+static const TInt KCbwDataTransferLengthOffset = 8;
+static const TInt KCbwFlagOffset = 12;
+static const TInt KCbwLunOffset = 13;
+static const TInt KCbwCbLengthOffset = 14;
-LOCAL_D const TInt KMaxCbwcbLength = 16;
+static const TInt KMaxCbwcbLength = 16;
// CSW offsets
-LOCAL_D const TInt KCswSingnatureOffset = 0;
-LOCAL_D const TInt KCswTagOffset = 4;
-LOCAL_D const TInt KCswDataResidueOffset = 8;
-LOCAL_D const TInt KCswStatusOffset = 12;
-
+static const TInt KCswSingnatureOffset = 0;
+static const TInt KCswTagOffset = 4;
+static const TInt KCswDataResidueOffset = 8;
+static const TInt KCswStatusOffset = 12;
/**
@@ -54,35 +66,38 @@
@return Error.
*/
TInt TUsbRequestHdr::Decode(const TDesC8& aBuffer)
- {
- if (aBuffer.Length() < static_cast<TInt>(KRequestHdrSize))
- {
- __PRINT1(_L("TUsbRequestHdr::Decode buffer invalid length %d"), aBuffer.Length());
- return KErrGeneral;
- }
+ {
+ if (aBuffer.Length() < static_cast<TInt>(KRequestHdrSize))
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_USB, TUSBREQUESTHDR_DECODE_ERR,
+ "ERROR: USB DEVICE REQUEST invalid length 0x%x", aBuffer.Length());
+ return KErrGeneral;
+ }
- iRequestType = aBuffer[0];
- iRequest = static_cast<TEp0Request>(aBuffer[1]);
- iValue = static_cast<TUint16>(aBuffer[2] + (aBuffer[3] << 8));
- iIndex = static_cast<TUint16>(aBuffer[4] + (aBuffer[5] << 8));
- iLength = static_cast<TUint16>(aBuffer[6] + (aBuffer[7] << 8));
- __PRINT5(_L("type=%d request=%d value=%d index=%d length=%d"), iRequestType,iRequest,iValue,iIndex,iLength);
+ iRequestType = aBuffer[0];
+ iRequest = static_cast<TEp0Request>(aBuffer[1]);
+ iValue = static_cast<TUint16>(aBuffer[2] + (aBuffer[3] << 8));
+ iIndex = static_cast<TUint16>(aBuffer[4] + (aBuffer[5] << 8));
+ iLength = static_cast<TUint16>(aBuffer[6] + (aBuffer[7] << 8));
+ OstTraceExt5(TRACE_SMASSSTORAGE_USB, TUSBREQUESTHDR_DECODE,
+ "USB DEVICE REQUEST type=0x%x request=0x%x value=%d index=%d length=%d",
+ iRequestType, iRequest, iValue, iIndex, iLength);
- return KErrNone;
- }
+ return KErrNone;
+ }
/**
This function determines whether data is required by the host in response
to a message header.
-@return TBool Flag indicating whether a data response required.
+@return TBool Flag indicating whether a data response required.
*/
TBool TUsbRequestHdr::IsDataResponseRequired() const
- {
- return (iRequestType & 0x80) ? (TBool)ETrue : (TBool)EFalse;
- }
+ {
+ return (iRequestType & 0x80) ? (TBool)ETrue : (TBool)EFalse;
+ }
//-------------------------------------
/**
@@ -92,92 +107,89 @@
@return pointer to newly created derived class object
*/
CBulkOnlyTransport* CBulkOnlyTransport::NewL(TInt aNumDrives,CUsbMassStorageController& aController)
- {
- __FNLOG("CBulkOnlyTransport::NewL()");
-
- return NewL(aNumDrives,aController, (CUsbMassStorageController::TTransportldd) 1);
- }
+ {
+ return NewL(aNumDrives,aController, (CUsbMassStorageController::TTransportldd) 1);
+ }
/**
-Create an object of a class derived from CBulkOnlyTransport
+Create an object of a class derived from CBulkOnlyTransport
@param aNumDrives - The number of drives available for MS
@param aController - reference to the parent
@param aTransportLddFlag - Type of usb client ldd
@return pointer to newly created derived class object
*/
CBulkOnlyTransport* CBulkOnlyTransport::NewL(TInt aNumDrives,CUsbMassStorageController& aController, CUsbMassStorageController::TTransportldd aTransportLddFlag)
- {
- __FNLOG("CBulkOnlyTransport::NewL()");
-
- if (aNumDrives <=0 || static_cast<TUint>(aNumDrives) > KUsbMsMaxDrives)
- {
- User::Leave(KErrArgument);
- }
+ {
+ if (aNumDrives <=0 || static_cast<TUint>(aNumDrives) > KUsbMsMaxDrives)
+ {
+ User::Leave(KErrArgument);
+ }
#if !defined(__WINS__) && !defined(__X86__)
- CBulkOnlyTransportUsbcScLdd* scTransport;
+ CBulkOnlyTransportUsbcScLdd* scTransport;
#endif
- CBulkOnlyTransportUsbcLdd* nonscTransport;
- switch (aTransportLddFlag)
- {
- case 1:
- nonscTransport = new(ELeave) CBulkOnlyTransportUsbcLdd(aNumDrives, aController);
- return nonscTransport;
+ CBulkOnlyTransportUsbcLdd* nonscTransport;
+ switch (aTransportLddFlag)
+ {
+ case 1:
+ nonscTransport = new(ELeave) CBulkOnlyTransportUsbcLdd(aNumDrives, aController);
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_NEWL1, "CBulkOnlyTransportUsbcLdd created.");
+ return nonscTransport;
#if !defined(__WINS__) && !defined(__X86__)
- case 2:
- scTransport = new(ELeave) CBulkOnlyTransportUsbcScLdd(aNumDrives, aController);
- return scTransport;
+ case 2:
+ scTransport = new(ELeave) CBulkOnlyTransportUsbcScLdd(aNumDrives, aController);
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_NEWL2, "CBulkOnlyTransportUsbcScLdd created.");
+ return scTransport;
#endif
default:
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsCBulkOnlyTransportNull));
- return NULL;
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsCBulkOnlyTransportNull));
+ return NULL;
- }
- }
+ }
+ }
TInt CBulkOnlyTransport::InitialiseTransportL(TInt aTransportLddFlag)
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::InitialiseTransportL()");
- TInt ret = KErrNone;
- MTransportBase* transport;
- iController.GetTransport(transport);
- switch (aTransportLddFlag)
- {
+ {
+ TInt ret = KErrNone;
+ MTransportBase* transport;
+ iController.GetTransport(transport);
+ switch (aTransportLddFlag)
+ {
#if !defined(__WINS__) && !defined(__X86__)
- case 2:
- ret = ((CBulkOnlyTransportUsbcScLdd*) transport)->Ldd().Open(0);
- if (ret != KErrNone)
- {
- return ret;
- }
- else
- {
- ((CBulkOnlyTransportUsbcScLdd*) transport)->Ldd().Close();
- CleanupStack::PushL(transport);
- ((CBulkOnlyTransportUsbcScLdd*) transport)->ConstructL();
- CleanupStack::Pop(transport);
- return ret;
- }
+ case 2:
+ ret = ((CBulkOnlyTransportUsbcScLdd*) transport)->Ldd().Open(0);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
+ else
+ {
+ ((CBulkOnlyTransportUsbcScLdd*) transport)->Ldd().Close();
+ CleanupStack::PushL(transport);
+ ((CBulkOnlyTransportUsbcScLdd*) transport)->ConstructL();
+ CleanupStack::Pop(transport);
+ return ret;
+ }
#endif
- case 1:
- ret = ((CBulkOnlyTransportUsbcLdd*) transport)->Ldd().Open(0);
- if (ret != KErrNone)
- {
- return ret;
- }
- else
- {
- ((CBulkOnlyTransportUsbcLdd*) transport)->Ldd().Close();
- CleanupStack::PushL(transport);
- ((CBulkOnlyTransportUsbcLdd*) transport)->ConstructL();
- CleanupStack::Pop(transport);
- return ret;
- }
- default:
- return KErrNotFound;
- }
- }
+ case 1:
+ ret = ((CBulkOnlyTransportUsbcLdd*) transport)->Ldd().Open(0);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
+ else
+ {
+ ((CBulkOnlyTransportUsbcLdd*) transport)->Ldd().Close();
+ CleanupStack::PushL(transport);
+ ((CBulkOnlyTransportUsbcLdd*) transport)->ConstructL();
+ CleanupStack::Pop(transport);
+ return ret;
+ }
+ default:
+ return KErrNotFound;
+ }
+ }
/**
c'tor
@@ -185,28 +197,27 @@
@param aController - reference to the parent
*/
CBulkOnlyTransport::CBulkOnlyTransport(TInt aNumDrives,CUsbMassStorageController& aController):
- CActive(EPriorityStandard),
- iMaxLun(aNumDrives-1),
- iController(aController),
- iStallAllowed(ETrue),
- iInterfaceConfigured(EFalse),
- iCommandBufPtr(NULL,0),
- iDataBufPtr(NULL,0),
- iCswBufPtr(NULL,0),
- iPaddingBufPtr(NULL,0),
- iWriteBufPtr(NULL,0),
- iReadBufPtr(NULL, 0),
- iCbwBufPtr(NULL,0)
- {
- __FNLOG("CBulkOnlyTransport::CBulkOnlyTransport");
- }
+ CActive(EPriorityStandard),
+ iMaxLun(aNumDrives-1),
+ iController(aController),
+ iStallAllowed(ETrue),
+ iInterfaceConfigured(EFalse),
+ iCommandBufPtr(NULL,0),
+ iDataBufPtr(NULL,0),
+ iCswBufPtr(NULL,0),
+ iPaddingBufPtr(NULL,0),
+ iWriteBufPtr(NULL,0),
+ iReadBufPtr(NULL, 0),
+ iCbwBufPtr(NULL,0)
+ {
+ }
/**
Destructor
*/
CBulkOnlyTransport::~CBulkOnlyTransport()
- {
- }
+ {
+ }
/**
@@ -215,12 +226,12 @@
@param aData reference to the data buffer.
*/
void CBulkOnlyTransport::SetupReadData(TUint aLength)
- {
- __FNLOG("CBulkOnlyTransport::SetupReadData");
- __PRINT1(_L("Length = %d (bytes)\n"), aLength);
- iBufSize = aLength;
- iReadSetUp = ETrue;
- }
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOTDATA, CBULKONLYTRANSPORT_SETUPREADDATA,
+ "BOT SetupReadData Length = 0x%x bytes", aLength);
+ iBufSize = aLength;
+ iReadSetUp = ETrue;
+ }
/**
@@ -229,64 +240,126 @@
@param aData reference to the data buffer.
*/
void CBulkOnlyTransport::SetupWriteData(TPtrC8& aData)
- {
- __FNLOG("CBulkOnlyTransport::SetupWriteData");
- __PRINT1(_L("Length = %d (bytes)\n"), aData.Length());
- iWriteBufPtr.Set(aData);
- iWriteSetUp = ETrue;
- }
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOTDATA, CBULKONLYTRANSPORT_SETUPWRITEDATA,
+ "BOT SetupWriteData Length = 0x%x bytes", aData.Length());
+ iWriteBufPtr.Set(aData);
+ iWriteSetUp = ETrue;
+ }
TInt CBulkOnlyTransport::Start()
- {
- __FNLOG("CBulkOnlyTransport::Start");
-
- TInt err = KErrNone;
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_START, "Start...");
+ if (!iProtocol)
+ {
+ return KErrBadHandle; //protocol should be set up before start
+ }
- if (!iProtocol)
- {
- return KErrBadHandle; //protocol should be set up before start
- }
-
- if (IsActive())
- {
- __PRINT(_L("CBulkOnlyTransport::Start - active before start!\n"));
- return KErrInUse;
- }
+ if (IsActive())
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_START1, "Error: active before start!");
+ return KErrInUse;
+ }
- if ((err = SetupConfigurationDescriptor()) != KErrNone ||
- (err = SetupInterfaceDescriptors()) != KErrNone )
- {
- __PRINT(_L("CBulkOnlyTransport::Start - Error during descriptors setup!\n"));
- return err;
- }
+ TInt err = KErrNone;
+ if ((err = SetupConfigurationDescriptor()) != KErrNone ||
+ (err = SetupInterfaceDescriptors()) != KErrNone )
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_START2, "Error: descriptors setup failed %d", err);
+ return err;
+ }
- AllocateEndpointResources();
- ActivateDeviceStateNotifier(); // activate notifier wich will wait until USB became configured
- TUsbcDeviceState deviceStatus = EUsbcDeviceStateDefault;
- err = GetDeviceStatus(deviceStatus);
- __PRINT1(_L("CBulkOnlyTransport::Start - Device status = %d\n"), deviceStatus);
- if (err == KErrNone && deviceStatus == EUsbcDeviceStateConfigured)
- {
- __PRINT(_L("CBulkOnlyTransport::Start - Starting bulk only transport\n"));
- err = HwStart();
- }
+ AllocateEndpointResources();
+ ActivateDeviceStateNotifier(); // activate notifier wich will wait until USB became configured
+ TUsbcDeviceState deviceStatus = EUsbcDeviceStateDefault;
+ err = GetDeviceStatus(deviceStatus);
+ if (err == KErrNone && deviceStatus == EUsbcDeviceStateConfigured)
+ {
+ err = HwStart();
+ }
#ifdef MSDC_MULTITHREADED
- TPtr8 aDes1(NULL,0);
- TPtr8 aDes2(NULL,0);
- GetBufferPointers(aDes1, aDes2);
- iProtocol->InitializeBufferPointers(aDes1, aDes2); // have to pass pointer to memory not offsets to initialise TPtr, and lengths
+ TPtr8 aDes1(NULL,0);
+ TPtr8 aDes2(NULL,0);
+ GetBufferPointers(aDes1, aDes2);
+ iProtocol->InitializeBufferPointers(aDes1, aDes2); // have to pass pointer to memory not offsets to initialise TPtr, and lengths
#endif
- iInterfaceConfigured = ETrue;
- return err;
- }
+ iInterfaceConfigured = ETrue;
+ return err;
+ }
TInt CBulkOnlyTransport::HwStart(TBool aDiscard)
- {
- __FNLOG("CBulkOnlyTransport::HwStart");
+ {
+ TInt lun = MaxLun();
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_HWSTART, "HwStart MAX LUN=%d", lun);
+ do
+ {
+ Controller().DriveManager().Connect(lun);
+ }
+ while(--lun >= 0);
+
+ TInt res = StartControlInterface();
+
+ iCurrentState = ENone;
+ iWriteSetUp=EFalse;
+ iReadSetUp=EFalse;
+ iStarted = ETrue;
+
+ if (aDiscard)
+ {
+ FlushData();
+ }
+
+ ReadCBW();
+ return res;
+ }
+
+TInt CBulkOnlyTransport::HwStop()
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_HWSTOP, "HwStop");
+ if (iStarted)
+ {
+ StopBulkOnlyEndpoint();
+ CancelControlInterface();
+ iStarted = EFalse;
+ }
+ return KErrNone;
+ }
+
+
+void CBulkOnlyTransport::StopBulkOnlyEndpoint()
+ {
+ TInt lun = MaxLun();
+ do
+ {
+ Controller().DriveManager().Disconnect(lun);
+ }
+ while(--lun >= 0);
+ Cancel();
+ iProtocol->Cancel();
+ }
+
+
+TInt CBulkOnlyTransport::HwSuspend()
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_HWSUSPEND, "HwSuspend");
+ TInt lun = MaxLun();
+ do
+ {
+ Controller().DriveManager().Disconnect(lun);
+ }
+ while(--lun >= 0);
+
+ return KErrNone;
+ }
+
+
+TInt CBulkOnlyTransport::HwResume()
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_HWRESUME, "HwResume");
TInt lun = MaxLun();
do
{
@@ -294,107 +367,35 @@
}
while(--lun >= 0);
- TInt res = StartControlInterface();
-
- iCurrentState = ENone;
- iWriteSetUp=EFalse;
- iReadSetUp=EFalse;
- iStarted = ETrue;
-
- if (aDiscard)
- {
- FlushData();
- }
-
- ReadCBW();
- return res;
- }
-
-
-TInt CBulkOnlyTransport::HwStop()
- {
- __FNLOG("CBulkOnlyTransport::HwStop");
- if (iStarted)
- {
- StopBulkOnlyEndpoint();
- CancelControlInterface();
- iStarted = EFalse;
- }
- return KErrNone;
- }
-
-
-void CBulkOnlyTransport::StopBulkOnlyEndpoint()
- {
- __FNLOG("CBulkOnlyTransport::StopBulkOnlyEndpoint");
-
- TInt lun = MaxLun();
- do
- {
- Controller().DriveManager().Disconnect(lun);
- }
- while(--lun >= 0);
- Cancel();
- iProtocol->Cancel();
- }
-
-
-TInt CBulkOnlyTransport::HwSuspend()
- {
- __FNLOG("CBulkOnlyTransport::HwSuspend");
-
- TInt lun = MaxLun();
- do
- {
- Controller().DriveManager().Disconnect(lun);
- }
- while(--lun >= 0);
-
- return KErrNone;
- }
-
-
-TInt CBulkOnlyTransport::HwResume()
- {
- __FNLOG("CBulkOnlyTransport::HwResume");
-
- TInt lun = MaxLun();
- do
- {
- Controller().DriveManager().Connect(lun);
- }
- while(--lun >= 0);
-
- return KErrNone;
- }
+ return KErrNone;
+ }
/**
Stops the Bulk Only Transport
*/
TInt CBulkOnlyTransport::Stop()
- {
- __FNLOG("CBulkOnlyTransport::Stop");
- CancelControlInterface();
- CancelDeviceStateNotifier();
- Cancel();
- if (iInterfaceConfigured)
- {
- ReleaseInterface();
- SetupConfigurationDescriptor(ETrue);
- }
- iCurrentState = ENone;
- iInterfaceConfigured = EFalse;
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_STOP, "Stop");
+ CancelControlInterface();
+ CancelDeviceStateNotifier();
+ Cancel();
+ if (iInterfaceConfigured)
+ {
+ ReleaseInterface();
+ SetupConfigurationDescriptor(ETrue);
+ }
+ iCurrentState = ENone;
+ iInterfaceConfigured = EFalse;
- return KErrNone;
- }
+ return KErrNone;
+ }
void CBulkOnlyTransport::DoCancel()
- {
- __FNLOG("CBulkOnlyTransport::DoCancel");
- CancelReadWriteRequests();
- }
+ {
+ CancelReadWriteRequests();
+ }
void CBulkOnlyTransport::Activate(TInt aReason)
@@ -406,55 +407,53 @@
void CBulkOnlyTransport::RunL()
- {
- __FNLOG("CBulkOnlyTransport::RunL");
- if (iStatus != KErrNone)
- {
- __PRINT1(_L("Error %d in RunL, halt endpoints \n"), iStatus.Int());
- SetPermError(); //halt endpoints for reset recovery
- return;
- }
- switch (iCurrentState)
- {
- case EWaitForCBW:
- __PRINT(_L("EWaitForCBW"));
- ProcessCbwEvent();
- break;
+ {
+ if (iStatus != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_RUNL, "Error %d in RunL, halt endpoints", iStatus.Int());
+ SetPermError(); //halt endpoints for reset recovery
+ return;
+ }
+ switch (iCurrentState)
+ {
+ case EWaitForCBW:
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_RUNL1, "EWaitForCBW");
+ ProcessCbwEvent();
+ break;
- case EWritingData:
- __PRINT(_L("EWritingData"));
- iWriteSetUp = EFalse; //the buffer was used
+ case EWritingData:
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_RUNL2, "EWritingData");
+ iWriteSetUp = EFalse; //the buffer was used
- if (iDataResidue && iStallAllowed)
- {
- StallEndpointAndWaitForClear();
- }
+ if (iDataResidue && iStallAllowed)
+ {
+ StallEndpointAndWaitForClear();
+ }
- SendCSW(iCbwTag, iDataResidue, iCmdStatus);
- break;
+ SendCSW(iCbwTag, iDataResidue, iCmdStatus);
+ break;
- case EReadingData:
- {
- __PRINT(_L("EReadingData"));
+ case EReadingData:
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_RUNL3, "EReadingData");
+ ProcessReadingDataEvent();
+ }
+ break;
- ProcessReadingDataEvent();
- }
- break;
-
- case ESendingCSW:
- __PRINT(_L("ESendingCSW"));
- ReadCBW();
- break;
+ case ESendingCSW:
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_RUNL4, "ESendingCSW");
+ ReadCBW();
+ break;
case EPermErr:
- __PRINT(_L("EPermErr"));
- StallEndpointAndWaitForClear();
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_RUNL5, "EPermErr");
+ StallEndpointAndWaitForClear();
break;
default:
- SetPermError(); // unexpected state
- }
- }
+ SetPermError(); // unexpected state
+ }
+ }
/**
@@ -466,243 +465,249 @@
*/
void CBulkOnlyTransport::DecodeCBW()
- {
- __FNLOG("CBulkOnlyTransport::DecodeCBW");
+ {
+ SetCbwPtr();
- SetCbwPtr();
-
- if (!CheckCBW()) //check if CBW valid and meaningful
- {
+ if (!CheckCBW()) //check if CBW valid and meaningful
+ {
// CBW not valid or meaningful
// Specification says: "If the CBW is not valid, the device shall STALL
// the Bulk-In pipe. Also, the device shall either STALL the Bulk-Out pipe,
// or the device shall accept and discard any Bulk-Out data. The device
// shall maintain this state until a Reset Recovery."
// Here we keep bulk-in ep stalled and ignore bulk-out ep.
- SetPermError();
- ExpireData((TAny*) (iCbwBufPtr.Ptr()));
- return;
- }
+ SetPermError();
+ ExpireData((TAny*) (iCbwBufPtr.Ptr()));
+ return;
+ }
- TPtrC8 aData;
- aData.Set(&iCbwBufPtr[KCbwCbLengthOffset], KMaxCbwcbLength+1); //prepare data for protocol starting form Length
- TUint8 lun = static_cast<TUint8>(iCbwBufPtr[13] & 0x0f);
+ TPtrC8 aData;
+ aData.Set(&iCbwBufPtr[KCbwCbLengthOffset], KMaxCbwcbLength+1); //prepare data for protocol starting form Length
+ TUint lun = static_cast<TUint8>(iCbwBufPtr[13] & 0x0f);
- iCbwTag = static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset]) |
- static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset+1]) <<8 |
- static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset+2]) <<16|
- static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset+3]) <<24;
+ iCbwTag = static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset]) |
+ static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset+1]) <<8 |
+ static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset+2]) <<16|
+ static_cast<TUint32>(iCbwBufPtr[KCbwTagOffset+3]) <<24;
- TInt i = KCbwDataTransferLengthOffset;
- TUint hostDataLength = static_cast<TUint32>(iCbwBufPtr[i ]) |
- static_cast<TUint32>(iCbwBufPtr[i+1]) <<8 |
- static_cast<TUint32>(iCbwBufPtr[i+2]) <<16 |
- static_cast<TUint32>(iCbwBufPtr[i+3]) <<24;
+ TInt i = KCbwDataTransferLengthOffset;
+ TUint32 hostDataLength = static_cast<TUint32>(iCbwBufPtr[i ]) |
+ static_cast<TUint32>(iCbwBufPtr[i+1]) <<8 |
+ static_cast<TUint32>(iCbwBufPtr[i+2]) <<16 |
+ static_cast<TUint32>(iCbwBufPtr[i+3]) <<24;
- TBool dataToHost = iCbwBufPtr[KCbwFlagOffset] & 0x80;
+ TBool dataToHost = iCbwBufPtr[KCbwFlagOffset] & 0x80;
- __PRINT4(_L("lun =%d, hostDataLength=%d, CBWtag = 0x%x, dataToHost=%d\n"), lun, hostDataLength, iCbwTag, dataToHost);
- //////////////////////////////////////////////
- TBool ret = iProtocol->DecodePacket(aData, lun);
- //////////////////////////////////////////////
- ExpireData((TAny*) (iCbwBufPtr.Ptr()));
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_DECODECBW,
+ "CBW LUN=%d", lun);
+ OstTraceExt3(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_DECODECBW0,
+ "CBW hostDataLength=0x%x, CBWtag = 0x%x, dataToHost=%d",
+ hostDataLength, iCbwTag, (TUint32)dataToHost);
+ //////////////////////////////////////////////
+ TBool ret = iProtocol->DecodePacket(aData, lun);
+ //////////////////////////////////////////////
+ ExpireData((TAny*) (iCbwBufPtr.Ptr()));
-
- iStallAllowed = ETrue;
+ iStallAllowed = ETrue;
- if (!ret)
- {
- __PRINT(_L("Command Failed\n"));
- iCmdStatus = ECommandFailed;
- }
- else
- {
- __PRINT(_L("Command Passed\n"));
- iCmdStatus = ECommandPassed;
- }
+ if (!ret)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_DECODECBW1, "ERROR: DecodePacket err=%d", ret);
+ iCmdStatus = ECommandFailed;
+ }
+ else
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW2, "ERROR: DecodePacket OK");
+ iCmdStatus = ECommandPassed;
+ }
- if (hostDataLength) // Host expected data transfer
- {
- if (dataToHost) // send data to host
- {
- if (!iWriteSetUp) //write buffer was not set up
- {
- __PRINT(_L("Write buffer was not setup\n"));
- iDataResidue =hostDataLength;
- __PRINT1(_L("DataResidue (write to host)=%d\n"),iDataResidue);
+ if (hostDataLength) // Host expected data transfer
+ {
+ if (dataToHost) // send data to host
+ {
+ if (!iWriteSetUp) //write buffer was not set up
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW3, "Write buffer was not setup");
+ iDataResidue =hostDataLength;
+ OstTrace1(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW4, "DataResidue (write to host)=%d", iDataResidue);
//------------------------------------
- if (hostDataLength <= KBOTMaxBufSize)
- {
- __PRINT(_L("Case 4 or 8\n"));
- SetPaddingBufPtr(hostDataLength);
- iPaddingBufPtr.FillZ(hostDataLength);
- TPtrC8 ptr(NULL, 0);
- ptr.Set((TUint8*)iPaddingBufPtr.Ptr(), hostDataLength);
- WriteData(iStatus, ptr, hostDataLength, EFalse);
- iStallAllowed = EFalse;
- if (iReadSetUp) //read buffer WAS set up - case (8)
- {
- __PRINT(_L("It is Case 8\n"));
- iCmdStatus = EPhaseError;
- }
- return;
- }
- else
+ if (hostDataLength <= KBOTMaxBufSize)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW5, "Case 4 or 8");
+ SetPaddingBufPtr(hostDataLength);
+ iPaddingBufPtr.FillZ(hostDataLength);
+ TPtrC8 ptr(NULL, 0);
+ ptr.Set((TUint8*)iPaddingBufPtr.Ptr(), hostDataLength);
+ WriteData(iStatus, ptr, hostDataLength, EFalse);
+ iStallAllowed = EFalse;
+ if (iReadSetUp) //read buffer WAS set up - case (8)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW6, "It is Case 8");
+ iCmdStatus = EPhaseError;
+ }
+ return;
+ }
+ else
//------------------------------------
-// Use next block instead of StallEndpointAndWaitForClear(InEndpoint);
- {
- SetPaddingBufPtr(hostDataLength);
- iPaddingBufPtr.FillZ(KBOTMaxBufSize);
- TUint c =0;
- TRequestStatus status;
- while (c<hostDataLength)
- {
- TInt len;
- if (hostDataLength - c > KBOTMaxBufSize)
- {
- len = KBOTMaxBufSize;
- }
- else
- {
- len = hostDataLength - c;
- }
+// Use next block instead of StallEndpointAndWaitForClear(InEndpoint);
+ {
+ SetPaddingBufPtr(hostDataLength);
+ iPaddingBufPtr.FillZ(KBOTMaxBufSize);
+ TUint c =0;
+ TRequestStatus status;
+ while (c<hostDataLength)
+ {
+ TInt len;
+ if (hostDataLength - c > KBOTMaxBufSize)
+ {
+ len = KBOTMaxBufSize;
+ }
+ else
+ {
+ len = hostDataLength - c;
+ }
- TPtrC8 ptr(NULL, 0);
- ptr.Set((TUint8*)iPaddingBufPtr.Ptr(), len);
- WriteUsb(status, ptr, len);
- User::WaitForRequest(status);
- c += KBOTMaxBufSize;
- }
- }
+ TPtrC8 ptr(NULL, 0);
+ ptr.Set((TUint8*)iPaddingBufPtr.Ptr(), len);
+ WriteUsb(status, ptr, len);
+ User::WaitForRequest(status);
+ c += KBOTMaxBufSize;
+ }
+ }
- if (iReadSetUp) //read buffer WAS set up - case (8)
- {
- __PRINT(_L("Case 8\n"));
- SendCSW(iCbwTag, hostDataLength, EPhaseError);
- //don't care to reset any flag - should get reset recovery
- }
- else // case (4)
- {
- __PRINT(_L("Case 4\n"));
- SendCSW(iCbwTag, hostDataLength, iCmdStatus);
- }
- return;
- } // if (!iWriteSetUp)
+ if (iReadSetUp) //read buffer WAS set up - case (8)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW7, "Case 8");
+ SendCSW(iCbwTag, hostDataLength, EPhaseError);
+ //don't care to reset any flag - should get reset recovery
+ }
+ else // case (4)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW8, "Case 4");
+ SendCSW(iCbwTag, hostDataLength, iCmdStatus);
+ }
+ return;
+ } // if (!iWriteSetUp)
//==================
- TUint deviceDataLength = static_cast<TUint>(iWriteBufPtr.Length());
- iDataResidue =hostDataLength - deviceDataLength ;
- __PRINT2(_L("Device data length = %d, DataResidue (write to host)=%d\n"), deviceDataLength, iDataResidue);
+ TUint32 deviceDataLength = iWriteBufPtr.Length();
+ iDataResidue =hostDataLength - deviceDataLength ;
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW9,
+ "Device data length = 0x%x, DataResidue (write to host)=0x%x", deviceDataLength, iDataResidue);
- if (deviceDataLength < hostDataLength &&
- hostDataLength < KBOTMaxBufSize )
- {
- __PRINT(_L("Case 5 (padding)\n"));
- SetPaddingBufPtr(hostDataLength);
- iPaddingBufPtr.Zero();
- iPaddingBufPtr.Append(iWriteBufPtr);
- iStallAllowed = EFalse;
- __PRINT1(_L("iPaddingBufPtr.Length = %d\n"),iPaddingBufPtr.Length());
- TPtrC8 ptr(NULL, 0);
- ptr.Set((TUint8*)iPaddingBufPtr.Ptr(), hostDataLength);
- WriteData(iStatus, ptr, hostDataLength, EFalse);
- return;
- }
+ if (deviceDataLength < hostDataLength &&
+ hostDataLength < KBOTMaxBufSize )
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW10, "Case 5 (padding)");
+ SetPaddingBufPtr(hostDataLength);
+ iPaddingBufPtr.Zero();
+ iPaddingBufPtr.Append(iWriteBufPtr);
+ iStallAllowed = EFalse;
+ OstTrace1(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW11,
+ "iPaddingBufPtr.Length = 0x%x",
+ iPaddingBufPtr.Length());
+ TPtrC8 ptr(NULL, 0);
+ ptr.Set((TUint8*)iPaddingBufPtr.Ptr(), hostDataLength);
+ WriteData(iStatus, ptr, hostDataLength, EFalse);
+ return;
+ }
//===================
- if (deviceDataLength == hostDataLength) //case (6)[==]
- {
- __PRINT(_L("Case 6\n"));
- WriteData(iStatus, iWriteBufPtr, deviceDataLength);
- return;
- }
- else if (deviceDataLength < hostDataLength) //case (5)[<]
- {
- __PRINT(_L("Case 5\n"));
- WriteData(iStatus, iWriteBufPtr, deviceDataLength, ETrue); // Send ZLP
- return;
- }
- else // deviceDataLength > hostDataLength - case (7)
- {
- __PRINT(_L("Case 7\n"));
- iCmdStatus = EPhaseError;
- iDataResidue = 0;
- WriteData(iStatus, iWriteBufPtr, hostDataLength);
- return;
- }
- }
- else //read data from host
- {
- if (!iReadSetUp)
- {
- iDataResidue = hostDataLength;
- __PRINT(_L("Read buffer was not setup\n"));
-// Use next block instead of StallEndpointAndWaitForClear(OutEndpoint);
- DiscardData(hostDataLength);
+ if (deviceDataLength == hostDataLength) //case (6)[==]
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW12, "Case 6");
+ WriteData(iStatus, iWriteBufPtr, deviceDataLength);
+ return;
+ }
+ else if (deviceDataLength < hostDataLength) //case (5)[<]
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW13, "Case 5");
+ WriteData(iStatus, iWriteBufPtr, deviceDataLength, ETrue); // Send ZLP
+ return;
+ }
+ else // deviceDataLength > hostDataLength - case (7)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW14, "Case 7");
+ iCmdStatus = EPhaseError;
+ iDataResidue = 0;
+ WriteData(iStatus, iWriteBufPtr, hostDataLength);
+ return;
+ }
+ }
+ else //read data from host
+ {
+ if (!iReadSetUp)
+ {
+ iDataResidue = hostDataLength;
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_DECODECBW15, "Read buffer was not setup");
+// Use next block instead of StallEndpointAndWaitForClear(OutEndpoint);
+ DiscardData(hostDataLength);
- if (iWriteSetUp) //case (10)
- {
- __PRINT(_L("case 10\n"));
- SendCSW(iCbwTag, hostDataLength, EPhaseError);
- }
- else // case (9)
- {
- __PRINT(_L("Case 9\n"));
- SendCSW(iCbwTag, hostDataLength, iCmdStatus);
- }
+ if (iWriteSetUp) //case (10)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW16, "case 10");
+ SendCSW(iCbwTag, hostDataLength, EPhaseError);
+ }
+ else // case (9)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW17, "Case 9");
+ SendCSW(iCbwTag, hostDataLength, iCmdStatus);
+ }
- return;
- }
+ return;
+ }
- TUint deviceDataLength = iBufSize;
- iDataResidue = hostDataLength; // calculate residue later
+ TUint32 deviceDataLength = iBufSize;
+ iDataResidue = hostDataLength; // calculate residue later
- __PRINT2(_L("deviceDataLength = iBufSize = %d, DataResidue = HDL for now (read from host) =%d\n"),deviceDataLength,iDataResidue);
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW18,
+ "deviceDataLength = iBufSize = 0x%x, DataResidue = HDL for now (read from host) =0x%x",
+ deviceDataLength, iDataResidue);
- if (deviceDataLength <= hostDataLength) // case (11) and (12)
- {
- __PRINT(_L("Case 11 or 12\n"));
- ReadData(deviceDataLength);
- return;
- }
- if (deviceDataLength > hostDataLength) // case (13)
- {
- __PRINT(_L("Case 13\n"));
+ if (deviceDataLength <= hostDataLength) // case (11) and (12)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW19, "Case 11 or 12");
+ ReadData(deviceDataLength);
+ return;
+ }
+ if (deviceDataLength > hostDataLength) // case (13)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW20, "Case 13");
/**
* Comment following line in order to pass compliant test.
* As spec said in case 13:"The device may receive data up to a
* total of dCBWDataTransferLength."
* Here we choose to ignore incoming data.
*/
- //StallEndpointAndWaitForClear(OutEndpoint); //Stall Out endpoint
+ //StallEndpointAndWaitForClear(OutEndpoint); //Stall Out endpoint
if (iReadSetUp)
{
- WriteToClient(hostDataLength);
+ WriteToClient(hostDataLength);
iReadSetUp = EFalse;
}
SendCSW(iCbwTag, hostDataLength, EPhaseError);
- return;
- }
- }
- }
- else // Host expected no data transfer
- {
- __PRINT(_L("No data transfer expected\n"));
- iDataResidue = 0;
- if (iWriteSetUp || iReadSetUp) // case (2) and (3)
- {
- __PRINT(_L("Case 2 or 3\n"));
- SendCSW(iCbwTag, 0, EPhaseError);
- }
- else
- {
- __PRINT(_L("Case 1\n"));
- SendCSW(iCbwTag, 0, iCmdStatus); //case (1)
- }
- }
- }
+ return;
+ }
+ }
+ }
+ else // Host expected no data transfer
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW21, "No data transfer expected");
+ iDataResidue = 0;
+ if (iWriteSetUp || iReadSetUp) // case (2) and (3)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW22, "Case 2 or 3");
+ SendCSW(iCbwTag, 0, EPhaseError);
+ }
+ else
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_DECODECBW23, "Case 1");
+ SendCSW(iCbwTag, 0, iCmdStatus); //case (1)
+ }
+ }
+ }
/**
@@ -711,9 +716,7 @@
@return ETrue if CBW is Valid and Meaningful, EFalse otherwise
*/
TBool CBulkOnlyTransport::CheckCBW()
- {
- __FNLOG("CBulkOnlyTransport::CheckCBW");
-
+ {
//
// Check valid
//
@@ -721,21 +724,21 @@
// Check length
if ((TUint) (iCbwBufPtr.Length()) != KCbwLength)
{
- __PRINT2(_L("Bad length: %d != KCbwLength"), iCbwBufPtr.Length(), KCbwLength);
- return EFalse;
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_CHECKCBW, "ERROR Bad length: 0x%x != KCbwLength", iCbwBufPtr.Length());
+ return EFalse;
}
// Check signature
- TInt i = KCbwSignatureOffset;
- if (iCbwBufPtr[i ] != 0x55 || // CBW Singature from USB Bulk-Only Transport spec
- iCbwBufPtr[i+1] != 0x53 ||
- iCbwBufPtr[i+2] != 0x42 ||
- iCbwBufPtr[i+3] != 0x43)
- {
- __PRINT(_L("Bad signature"));
- __PRINT4(_L(" 0x%x, 0x%x, 0x%x, 0x%x \n"), iCbwBufPtr[i], iCbwBufPtr[i+1], iCbwBufPtr[i+2],iCbwBufPtr[i+3])
- return EFalse;
- }
+ TInt i = KCbwSignatureOffset;
+ if (iCbwBufPtr[i ] != 0x55 || // CBW Singature from USB Bulk-Only Transport spec
+ iCbwBufPtr[i+1] != 0x53 ||
+ iCbwBufPtr[i+2] != 0x42 ||
+ iCbwBufPtr[i+3] != 0x43)
+ {
+ OstTraceData(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_CHECKCBW1,
+ "CBW ERROR: Bad signature %s", &iCbwBufPtr[i], 4);
+ return EFalse;
+ }
//
// Check meaningful
@@ -743,29 +746,29 @@
// Check reserved bits ( must be zero )
if ((iCbwBufPtr[KCbwLunOffset] & 0xF0) || (iCbwBufPtr[KCbwCbLengthOffset] & 0xE0))
- {
- __PRINT(_L("Reserved bits not zero\n"));
- return EFalse;
- }
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_CHECKCBW2, "CBW ERROR: Reserved bits not zero");
+ return EFalse;
+ }
- // check command block length
- TInt cbwcbLength = iCbwBufPtr[KCbwCbLengthOffset] & 0x1F;
- if (cbwcbLength >KMaxCbwcbLength)
- {
- __PRINT(_L("Incorrect block length\n"));
- return EFalse;
- }
+ // check command block length
+ TInt cbwcbLength = iCbwBufPtr[KCbwCbLengthOffset] & 0x1F;
+ if (cbwcbLength >KMaxCbwcbLength)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_CHECKCBW3, "CBW ERROR: Incorrect block length");
+ return EFalse;
+ }
- //check LUN
- TInt8 lun = static_cast<TUint8>(iCbwBufPtr[KCbwLunOffset] & 0x0f);
- if (iMaxLun < lun)
- {
- RDebug::Print(_L("bad lun: %d"), lun);
- return EFalse;
- }
+ //check LUN
+ TInt8 lun = static_cast<TUint8>(iCbwBufPtr[KCbwLunOffset] & 0x0f);
+ if (iMaxLun < lun)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CBULKONLYTRANSPORT_CHECKCBW4, "CBW ERROR: bad lun: %d", lun);
+ return EFalse;
+ }
- return ETrue;
- }
+ return ETrue;
+ }
/**
@@ -773,11 +776,10 @@
Used when protocol wants to force host to initiate a reset recovery.
*/
void CBulkOnlyTransport::SetPermError()
- {
- __FNLOG("CBulkOnlyTransport::SetPermError");
+ {
iCurrentState = EPermErr;
Activate(KErrNone);
- }
+ }
/**
@@ -786,19 +788,16 @@
@param aLength amount of data (in bytes) to be send to host
*/
void CBulkOnlyTransport::WriteData(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired)
- {
- __FNLOG("CBulkOnlyTransport::WriteData");
-
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
- return;
- }
- WriteUsb(aStatus, aDes, aLength, aZlpRequired);
- iCurrentState = EWritingData;
- SetActive();
- }
+ {
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+ return;
+ }
+ WriteUsb(aStatus, aDes, aLength, aZlpRequired);
+ iCurrentState = EWritingData;
+ SetActive();
+ }
/**
@@ -810,48 +809,47 @@
@param aStatus indicates the success or failure of the command.
*/
void CBulkOnlyTransport::SendCSW(TUint aTag, TUint aDataResidue, TCswStatus aStatus)
- {
- __FNLOG("CBulkOnlyTransport::SendCSW");
- __PRINT2(_L("DataResidue = %d, Status = %d \n"), aDataResidue, aStatus);
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT1, CBULKONLYTRANSPORT_SENDCSW,
+ "CSW DataResidue = 0x%x, Status = %d", aDataResidue, aStatus);
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
- return;
- }
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+ return;
+ }
- SetCswBufPtr(KCswLength);
- TInt i = KCswSingnatureOffset;
- iCswBufPtr[i ] = 0x55; // CSW Singature from USB Bulk-Only Transport spec
- iCswBufPtr[i+1] = 0x53;
- iCswBufPtr[i+2] = 0x42;
- iCswBufPtr[i+3] = 0x53;
+ SetCswBufPtr(KCswLength);
+ TInt i = KCswSingnatureOffset;
+ iCswBufPtr[i ] = 0x55; // CSW Singature from USB Bulk-Only Transport spec
+ iCswBufPtr[i+1] = 0x53;
+ iCswBufPtr[i+2] = 0x42;
+ iCswBufPtr[i+3] = 0x53;
- i = KCswTagOffset;
+ i = KCswTagOffset;
- iCswBufPtr[i ] = static_cast<TUint8>((aTag & 0x000000FF));
- iCswBufPtr[i+1] = static_cast<TUint8>((aTag & 0x0000FF00) >> 8);
- iCswBufPtr[i+2] = static_cast<TUint8>((aTag & 0x00FF0000) >> 16);
- iCswBufPtr[i+3] = static_cast<TUint8>((aTag & 0xFF000000) >> 24);
+ iCswBufPtr[i ] = static_cast<TUint8>((aTag & 0x000000FF));
+ iCswBufPtr[i+1] = static_cast<TUint8>((aTag & 0x0000FF00) >> 8);
+ iCswBufPtr[i+2] = static_cast<TUint8>((aTag & 0x00FF0000) >> 16);
+ iCswBufPtr[i+3] = static_cast<TUint8>((aTag & 0xFF000000) >> 24);
- i = KCswDataResidueOffset;
- iCswBufPtr[i ] = static_cast<TUint8>((aDataResidue & 0x000000FF));
- iCswBufPtr[i+1] = static_cast<TUint8>((aDataResidue & 0x0000FF00) >> 8);
- iCswBufPtr[i+2] = static_cast<TUint8>((aDataResidue & 0x00FF0000) >> 16);
- iCswBufPtr[i+3] = static_cast<TUint8>((aDataResidue & 0xFF000000) >> 24);
+ i = KCswDataResidueOffset;
+ iCswBufPtr[i ] = static_cast<TUint8>((aDataResidue & 0x000000FF));
+ iCswBufPtr[i+1] = static_cast<TUint8>((aDataResidue & 0x0000FF00) >> 8);
+ iCswBufPtr[i+2] = static_cast<TUint8>((aDataResidue & 0x00FF0000) >> 16);
+ iCswBufPtr[i+3] = static_cast<TUint8>((aDataResidue & 0xFF000000) >> 24);
- iCswBufPtr[KCswStatusOffset] = static_cast<TUint8>(aStatus);
+ iCswBufPtr[KCswStatusOffset] = static_cast<TUint8>(aStatus);
- TPtrC8 ptr(NULL, 0);
- ptr.Set((const TUint8*)iCswBufPtr.Ptr(), KCswLength);
+ TPtrC8 ptr(NULL, 0);
+ ptr.Set((const TUint8*)iCswBufPtr.Ptr(), KCswLength);
- WriteUsb(iStatus, ptr, KCswLength);
+ WriteUsb(iStatus, ptr, KCswLength);
- iCurrentState = ESendingCSW;
+ iCurrentState = ESendingCSW;
- SetActive();
- }
+ SetActive();
+ }
/**
@@ -860,10 +858,9 @@
@param aProtocol reference to the protocol
*/
void CBulkOnlyTransport::RegisterProtocol(MProtocolBase& aProtocol)
- {
- __FNLOG("CBulkOnlyTransport::RegisterProtocol");
- iProtocol = &aProtocol;
- }
+ {
+ iProtocol = &aProtocol;
+ }
/**
@@ -872,9 +869,9 @@
@return reference to the controller which instantiate the CBulkOnlyTransport
*/
CUsbMassStorageController& CBulkOnlyTransport::Controller()
- {
- return iController;
- }
+ {
+ return iController;
+ }
/**
@@ -883,32 +880,32 @@
0 to a maximum LUN of 15 (Fh).
*/
TInt CBulkOnlyTransport::MaxLun()
- {
- return iMaxLun;
- }
+ {
+ return iMaxLun;
+ }
void CBulkOnlyTransport::GetCommandBufPtr(TPtr8& aDes, TUint aLength) // Set pointer to buffer of specified aLength for command
- {
- aDes.Set(SetCommandBufPtr(aLength));
- }
+ {
+ aDes.Set(SetCommandBufPtr(aLength));
+ }
void CBulkOnlyTransport::GetReadDataBufPtr(TPtr8& aDes) // Set pointer to buffer into which data is to be read from drive (Read10)
- {
- aDes.Set(SetDataBufPtr());
- }
+ {
+ aDes.Set(SetDataBufPtr());
+ }
void CBulkOnlyTransport::GetWriteDataBufPtr(TPtrC8& aDes) // Set pointer to buffer from which data is to be written to drive (Write10)
- {
- aDes.Set(iReadBufPtr);
- }
+ {
+ aDes.Set(iReadBufPtr);
+ }
#ifdef MSDC_MULTITHREADED
void CBulkOnlyTransport::ProcessReadData(TAny* aAddress)
- {
- ExpireData(aAddress);
- }
+ {
+ ExpireData(aAddress);
+ }
#endif
--- a/userlibandfileserver/fileserver/smassstorage/cbulkonlytransportusbcldd.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cbulkonlytransportusbcldd.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -21,19 +21,33 @@
@internalTechnology
*/
+#include <e32std.h>
+#include "mtransport.h"
+#include "mprotocol.h"
+#include "mldddevicestatenotification.h"
+#include "tbulkmm.h"
+
+#include "drivemanager.h"
+#include "cusbmassstoragecontroller.h"
+
#include "cbulkonlytransport.h"
#include "cbulkonlytransportusbcldd.h"
-#include "usbmsshared.h"
-#include "massstoragedebug.h"
-#include "cusbmassstorageserver.h"
+#include "smassstorage.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cbulkonlytransportusbclddTraces.h"
+#endif
+
+
#define InEndpoint EEndpoint1
#define OutEndpoint EEndpoint2
//This value defined in USB Mass Storage Bulk Only Transrt spec and not supposed to be changed
-LOCAL_D const TInt KRequiredNumberOfEndpoints = 2; // in addition to endpoint 0.
+static const TInt KRequiredNumberOfEndpoints = 2; // in addition to endpoint 0.
-LOCAL_D const TInt KUsbNumInterfacesOffset = 4;
+static const TInt KUsbNumInterfacesOffset = 4;
////////////////////////////////////
/**
@@ -44,19 +58,19 @@
CControlInterfaceUsbcLdd* CControlInterfaceUsbcLdd::NewL(CBulkOnlyTransportUsbcLdd& aParent)
- {
- CControlInterfaceUsbcLdd* self = new(ELeave) CControlInterfaceUsbcLdd(aParent);
- CleanupStack::PushL(self);
- self->ConstructL();
- CActiveScheduler::Add(self);
- CleanupStack::Pop();
- return self;
- }
+ {
+ CControlInterfaceUsbcLdd* self = new(ELeave) CControlInterfaceUsbcLdd(aParent);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CActiveScheduler::Add(self);
+ CleanupStack::Pop();
+ return self;
+ }
void CControlInterfaceUsbcLdd::ConstructL()
- {
- }
+ {
+ }
/**
@@ -65,210 +79,194 @@
@param aParent reference to the CBulkOnlyTransportUsbcLdd
*/
CControlInterfaceUsbcLdd::CControlInterfaceUsbcLdd(CBulkOnlyTransportUsbcLdd& aParent)
- :CActive(EPriorityStandard),
- iParent(aParent),
- iCurrentState(ENone)
- {
- }
+ :CActive(EPriorityStandard),
+ iParent(aParent),
+ iCurrentState(ENone)
+ {
+ }
/**
d'tor
*/
CControlInterfaceUsbcLdd::~CControlInterfaceUsbcLdd()
- {
- __FNLOG("CControlInterfaceUsbcLdd::~CControlInterfaceUsbcLdd ");
- Cancel();
- }
+ {
+ Cancel();
+ }
/**
Called by CBulkOnlyTransport HwStart to start control interface
*/
TInt CControlInterfaceUsbcLdd::Start()
- {
- __FNLOG("CControlInterfaceUsbcLdd::Start ");
- TInt res = ReadEp0Data();
- return (res);
- }
+ {
+ TInt res = ReadEp0Data();
+ return (res);
+ }
/**
Called by desctructor of CBulkOnlyTransportUsbcLdd to stop control interface
*/
void CControlInterfaceUsbcLdd::Stop()
- {
- __FNLOG("CControlInterfaceUsbcLdd::Stop ");
- if (!IsActive())
- {
- __PRINT(_L("Not active\n"));
- return;
- }
-
- __PRINT(_L("\nStopping...\n"));
-
-
- iCurrentState = ENone;
-
- Cancel();
- }
+ {
+ if (!IsActive())
+ {
+ return;
+ }
+ iCurrentState = ENone;
+ Cancel();
+ }
/**
Cancel outstanding request (if any)
*/
void CControlInterfaceUsbcLdd::DoCancel()
- {
- __FNLOG("CControlInterfaceUsbcLdd::DoCancel ");
- switch(iCurrentState)
- {
- case EReadEp0Data:
- iParent.Ldd().ReadCancel(EEndpoint0);
- break;
- case ESendMaxLun:
- iParent.Ldd().WriteCancel(EEndpoint0);
- break;
- default:
- __PRINT(_L("\nWrong state !\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
- }
- }
+ {
+ switch(iCurrentState)
+ {
+ case EReadEp0Data:
+ iParent.Ldd().ReadCancel(EEndpoint0);
+ break;
+ case ESendMaxLun:
+ iParent.Ldd().WriteCancel(EEndpoint0);
+ break;
+ default:
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
+ break;
+ }
+ }
/**
Implement CControlInterfaceUsbcLdd state machine
*/
void CControlInterfaceUsbcLdd::RunL()
- {
- __FNLOG("CControlInterfaceUsbcLdd::RunL ");
- if (iStatus != KErrNone)
- {
- __PRINT1(_L("Error %d in RunL\n"), iStatus.Int());
+ {
+ if (iStatus != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CCONTROLINTERFACEUSBCLDD,
+ "ERROR %d in RunL", iStatus.Int());
- //read EP0 again
- ReadEp0Data();
- return;
- }
+ //read EP0 again
+ ReadEp0Data();
+ return;
+ }
- switch (iCurrentState)
- {
- case ESendMaxLun:
- ReadEp0Data();
- break;
+ switch (iCurrentState)
+ {
+ case ESendMaxLun:
+ ReadEp0Data();
+ break;
- case EReadEp0Data:
- DecodeEp0Data();
- break;
+ case EReadEp0Data:
+ DecodeEp0Data();
+ break;
- default:
- __PRINT(_L(" error: (Shouldn't end up here...)\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
- break;
- }
- return;
- }
+ default:
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
+ break;
+ }
+ return;
+ }
/**
Post a read request to EEndpoint0 to read request header
*/
TInt CControlInterfaceUsbcLdd::ReadEp0Data()
- {
- __FNLOG("CControlInterfaceUsbcLdd::ReadEp0Data ");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- return KErrServerBusy;
- }
- iParent.Ldd().Read(iStatus, EEndpoint0, iData, KRequestHdrSize);
+ {
+ if (IsActive())
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, READEP0DATA, "Still active");
+ return KErrServerBusy;
+ }
+ iParent.Ldd().Read(iStatus, EEndpoint0, iData, KRequestHdrSize);
- iCurrentState = EReadEp0Data;
+ iCurrentState = EReadEp0Data;
- SetActive();
- return KErrNone;
- }
+ SetActive();
+ return KErrNone;
+ }
/**
Decode request header and do appropriate action - get max LUN info or post a reset request
*/
void CControlInterfaceUsbcLdd::DecodeEp0Data()
- {
- __FNLOG("CControlInterfaceUsbcLdd::DecodeEp0Data ");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceStillActive));
- return;
- }
+ {
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceStillActive));
+ return;
+ }
- TInt err = iRequestHeader.Decode(iData);
+ TInt err = iRequestHeader.Decode(iData);
- if(err != KErrNone)
- return;
+ if(err != KErrNone)
+ return;
switch(iRequestHeader.iRequest)
- {
- //
- // GET MAX LUN (0xFE)
- //
- case TUsbRequestHdr::EReqGetMaxLun:
- {
- __PRINT1(_L("DecodeEp0Data : 'Get Max LUN' Request MaxLun = %d"),iParent.MaxLun() );
-
+ {
+ //
+ // GET MAX LUN (0xFE)
+ //
+ case TUsbRequestHdr::EReqGetMaxLun:
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA, ">>> EP0 GetMaxLun = %d", iParent.MaxLun());
if ( iRequestHeader.iRequestType != 0xA1 //value from USB MS BOT spec
|| iRequestHeader.iIndex > 15
|| iRequestHeader.iValue != 0
|| iRequestHeader.iLength != 1)
{
- __PRINT(_L("GetMaxLun command packet check error"));
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA1, "ERROR: GetMaxLun command packet check error");
iParent.Ldd().EndpointZeroRequestError();
break;
}
- iData.FillZ(1); //Return only 1 byte to host
- iData[0] = static_cast<TUint8>(iParent.MaxLun()); // Supported Units
- iParent.Ldd().Write(iStatus, EEndpoint0, iData, 1);
+ iData.FillZ(1); //Return only 1 byte to host
+ iData[0] = static_cast<TUint8>(iParent.MaxLun()); // Supported Units
+ iParent.Ldd().Write(iStatus, EEndpoint0, iData, 1);
- iCurrentState = ESendMaxLun;
- SetActive();
+ iCurrentState = ESendMaxLun;
+ SetActive();
- return;
- }
- //
- // RESET (0xFF)
- //
- case TUsbRequestHdr::EReqReset:
- {
- __PRINT(_L("DecodeEp0Data : 'Mass Storage Reset' Request"));
+ return;
+ }
+ //
+ // RESET (0xFF)
+ //
+ case TUsbRequestHdr::EReqReset:
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA2, ">>> EP0 BulkOnlyMassStorageReset");
if ( iRequestHeader.iRequestType != 0x21 //value from USB MS BOT spec
|| iRequestHeader.iIndex > 15
|| iRequestHeader.iValue != 0
|| iRequestHeader.iLength != 0)
{
- __PRINT(_L("MSC Reset command packet check error"));
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA3, "BulkOnlyMassStorageReset command packet check error");
iParent.Ldd().EndpointZeroRequestError();
break;
}
- iParent.HwStop();
- iParent.Controller().Reset();
- iParent.HwStart(ETrue);
+ iParent.HwStop();
+ iParent.Controller().Reset();
+ iParent.HwStart(ETrue);
err = iParent.Ldd().SendEp0StatusPacket();
- return;
- }
- //
- // Unknown?
- //
- default:
- {
- __PRINT(_L("DecodeEp0Data : Unknown Request"));
-
- }
- }
- ReadEp0Data(); //try to get another request
- }
+ return;
+ }
+ //
+ // Unknown?
+ //
+ default:
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA4, ">>> EP0 DecodeEp0Data : Unknown Request");
+ }
+ }
+ ReadEp0Data(); //try to get another request
+ }
//
@@ -276,38 +274,34 @@
//
CBulkOnlyTransportUsbcLdd::CBulkOnlyTransportUsbcLdd(TInt aNumDrives,CUsbMassStorageController& aController)
- :CBulkOnlyTransport(aNumDrives, aController),
- iSwap(ETrue)
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::CBulkOnlyTransportUsbcLdd");
- }
+ :CBulkOnlyTransport(aNumDrives, aController)
+ {
+ }
/**
Constructs the CBulkOnlyTransportUsbcLdd object
*/
void CBulkOnlyTransportUsbcLdd::ConstructL()
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::ConstructL()");
- iControlInterface = CControlInterfaceUsbcLdd::NewL(*this);
- iDeviceStateNotifier = CActiveDeviceStateNotifierBase::NewL(*this, *this);
- CActiveScheduler::Add(this);
- }
+ {
+ iControlInterface = CControlInterfaceUsbcLdd::NewL(*this);
+ iDeviceStateNotifier = CActiveDeviceStateNotifierBase::NewL(*this, *this);
+ CActiveScheduler::Add(this);
+ }
CBulkOnlyTransportUsbcLdd::~CBulkOnlyTransportUsbcLdd()
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::~CBulkOnlyTransportUsbcLdd");
- if (iInterfaceConfigured)
- {
- Stop();
- delete iControlInterface ;
- delete iDeviceStateNotifier;
- }
- }
+ {
+ if (iInterfaceConfigured)
+ {
+ Stop();
+ delete iControlInterface ;
+ delete iDeviceStateNotifier;
+ }
+ }
RDevUsbcClient& CBulkOnlyTransportUsbcLdd::Ldd()
- {
- return iLdd;
- }
+ {
+ return iLdd;
+ }
/**
@@ -317,44 +311,43 @@
@return KErrNone if operation was completed successfully, errorcode otherwise
*/
TInt CBulkOnlyTransportUsbcLdd::SetupConfigurationDescriptor(TBool aUnset)
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::SetupConfigurationDescriptor");
- TInt ret(KErrNone);
-
- if ((ret = iLdd.Open(0)) != KErrNone)
- return ret;
+ {
+ TInt ret(KErrNone);
+
+ if ((ret = iLdd.Open(0)) != KErrNone)
+ return ret;
- TInt configDescriptorSize(0);
- iLdd.GetConfigurationDescriptorSize(configDescriptorSize);
- if (static_cast<TUint>(configDescriptorSize) != KUsbDescSize_Config)
- {
- return KErrCorrupt;
- }
+ TInt configDescriptorSize(0);
+ iLdd.GetConfigurationDescriptorSize(configDescriptorSize);
+ if (static_cast<TUint>(configDescriptorSize) != KUsbDescSize_Config)
+ {
+ return KErrCorrupt;
+ }
- TBuf8<KUsbDescSize_Config> configDescriptor;
- ret = iLdd.GetConfigurationDescriptor(configDescriptor);
- if (ret != KErrNone)
- {
- return ret;
- }
+ TBuf8<KUsbDescSize_Config> configDescriptor;
+ ret = iLdd.GetConfigurationDescriptor(configDescriptor);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
- // I beleive that other fields setted up during LDD initialisation
- if (aUnset)
- {
- --configDescriptor[KUsbNumInterfacesOffset];
- }
- else
- {
- ++configDescriptor[KUsbNumInterfacesOffset];
- }
- ret = iLdd.SetConfigurationDescriptor(configDescriptor);
+ // I beleive that other fields setted up during LDD initialisation
+ if (aUnset)
+ {
+ --configDescriptor[KUsbNumInterfacesOffset];
+ }
+ else
+ {
+ ++configDescriptor[KUsbNumInterfacesOffset];
+ }
+ ret = iLdd.SetConfigurationDescriptor(configDescriptor);
- if (aUnset)
- {
- iLdd.Close();
- }
- return ret;
- }
+ if (aUnset)
+ {
+ iLdd.Close();
+ }
+ return ret;
+ }
/**
Set up interface descriptor
@@ -362,211 +355,208 @@
@return KErrNone if operation was completed successfully, errorcode otherwise
*/
TInt CBulkOnlyTransportUsbcLdd::SetupInterfaceDescriptors()
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::SetupInterfaceDescriptors");
- // Device caps
- TUsbDeviceCaps d_caps;
- TInt ret = iLdd.DeviceCaps(d_caps);
- if (ret != KErrNone)
- {
- return ret;
- }
- TInt totalEndpoints = d_caps().iTotalEndpoints;
- if (totalEndpoints < KRequiredNumberOfEndpoints)
- {
- return KErrHardwareNotAvailable;
- }
+ {
+ // Device caps
+ TUsbDeviceCaps d_caps;
+ TInt ret = iLdd.DeviceCaps(d_caps);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
+ TInt totalEndpoints = d_caps().iTotalEndpoints;
+ if (totalEndpoints < KRequiredNumberOfEndpoints)
+ {
+ return KErrHardwareNotAvailable;
+ }
- // Endpoint caps
- TUsbcEndpointData data[KUsbcMaxEndpoints];
- TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
- ret = iLdd.EndpointCaps(dataptr);
- if (ret != KErrNone)
- {
- return ret;
- }
+ // Endpoint caps
+ TUsbcEndpointData data[KUsbcMaxEndpoints];
+ TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
+ ret = iLdd.EndpointCaps(dataptr);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
- // Set the active interface
- TUsbcInterfaceInfoBuf ifc;
- TInt ep_found = 0;
- TBool foundBulkIN = EFalse;
- TBool foundBulkOUT = EFalse;
+ // Set the active interface
+ TUsbcInterfaceInfoBuf ifc;
+ TInt ep_found = 0;
+ TBool foundBulkIN = EFalse;
+ TBool foundBulkOUT = EFalse;
- for (TInt i = 0; i < totalEndpoints ; i++)
- {
- const TUsbcEndpointCaps* caps = &data[i].iCaps;
- const TInt maxPacketSize = caps->MaxPacketSize();
- if (!foundBulkIN &&
- (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == (KUsbEpTypeBulk | KUsbEpDirIn))
- {
- // InEndpoint is going to be our TX (IN, write) endpoint
- ifc().iEndpointData[0].iType = KUsbEpTypeBulk;
- if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
- ifc().iEndpointData[0].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
- ifc().iEndpointData[0].iDir = KUsbEpDirIn;
- ifc().iEndpointData[0].iSize = maxPacketSize;
- ifc().iEndpointData[0].iInterval_Hs = 0;
- foundBulkIN = ETrue;
- if (++ep_found == KRequiredNumberOfEndpoints)
- {
- break;
- }
- continue;
- }
- if (!foundBulkOUT &&
- (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == (KUsbEpTypeBulk | KUsbEpDirOut))
- {
- // OutEndpoint is going to be our RX (OUT, read) endpoint
- ifc().iEndpointData[1].iType = KUsbEpTypeBulk;
- if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
- ifc().iEndpointData[1].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
- ifc().iEndpointData[1].iDir = KUsbEpDirOut;
- ifc().iEndpointData[1].iSize = maxPacketSize;
- ifc().iEndpointData[1].iInterval_Hs = 0;
- foundBulkOUT = ETrue;
- if (++ep_found == KRequiredNumberOfEndpoints)
- {
- break;
- }
- continue;
- }
- }
- if (ep_found != KRequiredNumberOfEndpoints)
- {
- return KErrHardwareNotAvailable;
- }
+ for (TInt i = 0; i < totalEndpoints ; i++)
+ {
+ const TUsbcEndpointCaps* caps = &data[i].iCaps;
+ const TInt maxPacketSize = caps->MaxPacketSize();
+ if (!foundBulkIN &&
+ (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == (KUsbEpTypeBulk | KUsbEpDirIn))
+ {
+ // InEndpoint is going to be our TX (IN, write) endpoint
+ ifc().iEndpointData[0].iType = KUsbEpTypeBulk;
+ if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
+ ifc().iEndpointData[0].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
+ ifc().iEndpointData[0].iDir = KUsbEpDirIn;
+ ifc().iEndpointData[0].iSize = maxPacketSize;
+ ifc().iEndpointData[0].iInterval_Hs = 0;
+ foundBulkIN = ETrue;
+ if (++ep_found == KRequiredNumberOfEndpoints)
+ {
+ break;
+ }
+ continue;
+ }
+ if (!foundBulkOUT &&
+ (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == (KUsbEpTypeBulk | KUsbEpDirOut))
+ {
+ // OutEndpoint is going to be our RX (OUT, read) endpoint
+ ifc().iEndpointData[1].iType = KUsbEpTypeBulk;
+ if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
+ ifc().iEndpointData[1].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
+ ifc().iEndpointData[1].iDir = KUsbEpDirOut;
+ ifc().iEndpointData[1].iSize = maxPacketSize;
+ ifc().iEndpointData[1].iInterval_Hs = 0;
+ foundBulkOUT = ETrue;
+ if (++ep_found == KRequiredNumberOfEndpoints)
+ {
+ break;
+ }
+ continue;
+ }
+ }
+ if (ep_found != KRequiredNumberOfEndpoints)
+ {
+ return KErrHardwareNotAvailable;
+ }
- _LIT16(string, "USB Mass Storage Interface");
- ifc().iString = const_cast<TDesC16*>(&string);
- ifc().iTotalEndpointsUsed = KRequiredNumberOfEndpoints;
- ifc().iClass.iClassNum = 0x08; // Mass Storage
- ifc().iClass.iSubClassNum = 0x06; // SCSI Transparent Command Set
- ifc().iClass.iProtocolNum = 0x50; // Bulk Only Transport
+ _LIT16(string, "USB Mass Storage Interface");
+ ifc().iString = const_cast<TDesC16*>(&string);
+ ifc().iTotalEndpointsUsed = KRequiredNumberOfEndpoints;
+ ifc().iClass.iClassNum = 0x08; // Mass Storage
+ ifc().iClass.iSubClassNum = 0x06; // SCSI Transparent Command Set
+ ifc().iClass.iProtocolNum = 0x50; // Bulk Only Transport
- TUint bandwidth_priority = (EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault);
- if (d_caps().iHighSpeed)
- {
- // If this device supports USB High-speed, then we request 64KB buffers
- // (otherwise the default 4KB ones will do).
- bandwidth_priority = (EUsbcBandwidthOUTPlus2 | EUsbcBandwidthINPlus2);
- // Also, tell the Protocol about it, because it might want to do some
- // optimizing too.
- iProtocol->ReportHighSpeedDevice();
- }
- ret = iLdd.SetInterface(0, ifc, bandwidth_priority);
- return ret;
- }
+ TUint bandwidth_priority = (EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault);
+ if (d_caps().iHighSpeed)
+ {
+ // If this device supports USB High-speed, then we request 64KB buffers
+ // (otherwise the default 4KB ones will do).
+ bandwidth_priority = (EUsbcBandwidthOUTPlus2 | EUsbcBandwidthINPlus2);
+ // Also, tell the Protocol about it, because it might want to do some
+ // optimizing too.
+ iProtocol->ReportHighSpeedDevice();
+ }
+ ret = iLdd.SetInterface(0, ifc, bandwidth_priority);
+ return ret;
+ }
void CBulkOnlyTransportUsbcLdd::ReleaseInterface()
- {
- iLdd.ReleaseInterface(0);
- }
+ {
+ iLdd.ReleaseInterface(0);
+ }
TInt CBulkOnlyTransportUsbcLdd::StartControlInterface()
- {
- return iControlInterface->Start();
- }
+ {
+ return iControlInterface->Start();
+ }
void CBulkOnlyTransportUsbcLdd::CancelControlInterface()
- {
- iControlInterface->Cancel();
- }
+ {
+ iControlInterface->Cancel();
+ }
void CBulkOnlyTransportUsbcLdd::ActivateDeviceStateNotifier()
- {
+ {
__ASSERT_DEBUG(iDeviceStateNotifier, User::Panic(KUsbMsSvrPncCat, EMsCDeviceStateNotifierNull));
- iDeviceStateNotifier->Activate();
- }
+ iDeviceStateNotifier->Activate();
+ }
void CBulkOnlyTransportUsbcLdd::CancelDeviceStateNotifier()
- {
- iDeviceStateNotifier->Cancel();
- }
+ {
+ iDeviceStateNotifier->Cancel();
+ }
void CBulkOnlyTransportUsbcLdd::CancelReadWriteRequests()
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::CancelReadWriteRequests");
- iLdd.WriteCancel(InEndpoint);
- iLdd.ReadCancel(OutEndpoint);
- }
+ {
+ iLdd.WriteCancel(InEndpoint);
+ iLdd.ReadCancel(OutEndpoint);
+ }
void CBulkOnlyTransportUsbcLdd::AllocateEndpointResources()
- {
- TUsbDeviceCaps d_caps;
- TInt ret = iLdd.DeviceCaps(d_caps);
- if (ret == KErrNone)
- {
- if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
- {
- // Set up DMA if possible (errors are non-critical)
- TInt err = iLdd.AllocateEndpointResource(OutEndpoint, EUsbcEndpointResourceDMA);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set DMA on OUT endpoint failed with error code: %d"), err);
- }
- err = iLdd.AllocateEndpointResource(InEndpoint, EUsbcEndpointResourceDMA);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set DMA on IN endpoint failed with error code: %d"), err);
- }
+ {
+ TUsbDeviceCaps d_caps;
+ TInt ret = iLdd.DeviceCaps(d_caps);
+ if (ret == KErrNone)
+ {
+ if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
+ {
+ // Set up DMA if possible (errors are non-critical)
+ TInt err = iLdd.AllocateEndpointResource(OutEndpoint, EUsbcEndpointResourceDMA);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A1, "Set DMA on OUT endpoint failed with error code: %d", err);
+ }
+ err = iLdd.AllocateEndpointResource(InEndpoint, EUsbcEndpointResourceDMA);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A2, "Set DMA on IN endpoint failed with error code: %d", err);
+ }
- // Set up Double Buffering if possible (errors are non-critical)
- err = iLdd.AllocateEndpointResource(OutEndpoint, EUsbcEndpointResourceDoubleBuffering);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set Double Buffering on OUT endpoint failed with error code: %d"), err);
- }
- err = iLdd.AllocateEndpointResource(InEndpoint, EUsbcEndpointResourceDoubleBuffering);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set Double Buffering on IN endpoint failed with error code: %d"), err);
- }
- }
- }
- }
+ // Set up Double Buffering if possible (errors are non-critical)
+ err = iLdd.AllocateEndpointResource(OutEndpoint, EUsbcEndpointResourceDoubleBuffering);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A3, "Set Double Buffering on OUT endpoint failed with error code: %d", err);
+ }
+ err = iLdd.AllocateEndpointResource(InEndpoint, EUsbcEndpointResourceDoubleBuffering);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A4, "Set Double Buffering on IN endpoint failed with error code: %d", err);
+ }
+ }
+ }
+ }
TInt CBulkOnlyTransportUsbcLdd::GetDeviceStatus(TUsbcDeviceState& deviceStatus)
- {
- return iLdd.DeviceStatus(deviceStatus);
- }
+ {
+ return iLdd.DeviceStatus(deviceStatus);
+ }
void CBulkOnlyTransportUsbcLdd::FlushData()
- {
- TInt bytes;
- const TInt err = iLdd.QueryReceiveBuffer(OutEndpoint, bytes);
- if (err != KErrNone || bytes <= 0)
- {
- __PRINT1(_L("Error: err=%d bytes=%d"), bytes);
- }
- else
- {
- __PRINT1(_L("RxBuffer has %d bytes"), bytes);
- ReadAndDiscardData(bytes);
- }
- }
+ {
+ TInt bytes;
+ const TInt err = iLdd.QueryReceiveBuffer(OutEndpoint, bytes);
+ if (err != KErrNone || bytes <= 0)
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT, B1, "ERROR: err=%d bytes=0x%x", err, bytes);
+ }
+ else
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT1, B2, "RxBuffer has %d bytes", bytes);
+ ReadAndDiscardData(bytes);
+ }
+ }
/**
* Read out rest data from OutEndpoint and discard them
*/
void CBulkOnlyTransportUsbcLdd::ReadAndDiscardData(TInt aBytes)
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::ReadAndDiscardData");
- iDiscardBuf.SetMax();
- const TUint bufsize = static_cast<TUint>(iDiscardBuf.Length());
- TRequestStatus status;
- while (aBytes > 0)
- {
- __PRINT1(_L("Bytes still to be read: %d\n"), aBytes);
- iLdd.ReadOneOrMore(status, OutEndpoint, iDiscardBuf, bufsize);
- User::WaitForRequest(status);
- TInt err = status.Int();
- if (err != KErrNone)
- {
- // Bad.
- break;
- }
- aBytes -= iDiscardBuf.Length();
- }
- }
+ {
+ iDiscardBuf.SetMax();
+ const TUint bufsize = static_cast<TUint>(iDiscardBuf.Length());
+ TRequestStatus status;
+ while (aBytes > 0)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT1, C1, "Bytes still to be read: 0x%x", aBytes);
+ iLdd.ReadOneOrMore(status, OutEndpoint, iDiscardBuf, bufsize);
+ User::WaitForRequest(status);
+ TInt err = status.Int();
+ if (err != KErrNone)
+ {
+ // Bad.
+ break;
+ }
+ aBytes -= iDiscardBuf.Length();
+ }
+ }
/**
Called by the protocol to determine how many bytes of data are available in the read buffer.
@@ -574,74 +564,70 @@
@return The number of bytes available in the read buffer
*/
TInt CBulkOnlyTransportUsbcLdd::BytesAvailable()
- {
- TInt bytes = 0;
- TInt err = iLdd.QueryReceiveBuffer(OutEndpoint, bytes);
- if (err != KErrNone)
- bytes = 0;
- return bytes;
- }
+ {
+ TInt bytes = 0;
+ TInt err = iLdd.QueryReceiveBuffer(OutEndpoint, bytes);
+ if (err != KErrNone)
+ bytes = 0;
+ return bytes;
+ }
void CBulkOnlyTransportUsbcLdd::StallEndpointAndWaitForClear()
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::StallEndpointAndWaitForClear");
-
- // Now stall this endpoint
- __PRINT1(_L("Stalling endpoint %d"), InEndpoint);
- TInt r = iLdd.HaltEndpoint(InEndpoint);
- if (r != KErrNone)
- {
- __PRINT2(_L("Error: stalling ep %d failed: %d"), InEndpoint, r);
- }
- TEndpointState ep_state;
- TInt i = 0;
- do
- {
- // Wait for 10ms before checking the ep status
- User::After(10000);
- iLdd.EndpointStatus(InEndpoint, ep_state);
- if (++i >= 550)
- {
- // 5.5 secs should be enough (see 9.2.6.1 Request Processing Timing)
- __PRINT1(_L("Error: Checked for ep %d de-stall for 5.5s - giving up now"), InEndpoint);
- // We can now only hope for a Reset Recovery
- return;
- }
- } while ((ep_state == EEndpointStateStalled) && iStarted);
- __PRINT2(_L("Checked for ep %d de-stall: %d time(s)"), InEndpoint, i);
- }
+ {
+ // Now stall this endpoint
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, D1, "Stalling endpoint %d", InEndpoint);
+ TInt r = iLdd.HaltEndpoint(InEndpoint);
+ if (r != KErrNone)
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT, D2, "Error: stalling ep %d failed: %d", InEndpoint, r);
+ }
+ TEndpointState ep_state;
+ TInt i = 0;
+ do
+ {
+ // Wait for 10ms before checking the ep status
+ User::After(10000);
+ iLdd.EndpointStatus(InEndpoint, ep_state);
+ if (++i >= 550)
+ {
+ // 5.5 secs should be enough (see 9.2.6.1 Request Processing Timing)
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, D3, "Error: Checked for ep %d de-stall for 5.5s - giving up now", InEndpoint);
+ // We can now only hope for a Reset Recovery
+ return;
+ }
+ } while ((ep_state == EEndpointStateStalled) && iStarted);
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT, D4, "Checked for ep %d de-stall: %d time(s)", InEndpoint, i);
+ }
/**
Read CBW data (KCbwLength) from the host into the read buffer.
*/
void CBulkOnlyTransportUsbcLdd::ReadCBW()
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::ReadCBW");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
- return;
- }
+ {
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+ return;
+ }
- iCbwBuf.SetMax();
- iLdd.ReadUntilShort(iStatus, OutEndpoint, iCbwBuf, KCbwLength);
+ iCbwBuf.SetMax();
+ iLdd.ReadUntilShort(iStatus, OutEndpoint, iCbwBuf, KCbwLength);
- iCurrentState = EWaitForCBW;
- SetActive();
- }
+ iCurrentState = EWaitForCBW;
+ SetActive();
+ }
void CBulkOnlyTransportUsbcLdd::ExpireData(TAny* /*aAddress*/)
- {
- // Intentionally left blank
- }
+ {
+ // Intentionally left blank
+ }
void CBulkOnlyTransportUsbcLdd::ProcessCbwEvent()
- {
- DecodeCBW();
- }
+ {
+ DecodeCBW();
+ }
/**
@@ -650,193 +636,172 @@
@param aLength amount of data (in bytes) to be received from the host
*/
void CBulkOnlyTransportUsbcLdd::ReadData(TUint aLength)
- {
- __FNLOG("CBulkOnlyTransportUsbcLdd::ReadData");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
- return;
- }
-
- SetReadDataBufPtr(aLength);
- iLdd.Read(iStatus, OutEndpoint, iReadBufPtr, aLength);
+ {
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+ return;
+ }
- iCurrentState = EReadingData;
- SetActive();
- }
+ SetReadDataBufPtr(aLength);
+ iLdd.Read(iStatus, OutEndpoint, iReadBufPtr, aLength);
+
+ iCurrentState = EReadingData;
+ SetActive();
+ }
void CBulkOnlyTransportUsbcLdd::WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired)
- {
- iLdd.Write(aStatus, InEndpoint, aDes, aLength, aZlpRequired);
- }
+ {
+ iLdd.Write(aStatus, InEndpoint, aDes, aLength, aZlpRequired);
+ }
void CBulkOnlyTransportUsbcLdd::SetCbwPtr()
- {
- iCbwBufPtr.Set(iCbwBuf.Ptr(), iCbwBuf.Length());
- }
+ {
+ iCbwBufPtr.Set(iCbwBuf.Ptr(), iCbwBuf.Length());
+ }
TPtr8& CBulkOnlyTransportUsbcLdd::SetCommandBufPtr(TUint aLength)
- {
- iCommandBufPtr.Set((TUint8*) iCommandBuf.Ptr(), aLength, aLength );
- return iCommandBufPtr;
- }
+ {
+ iCommandBufPtr.Set((TUint8*) iCommandBuf.Ptr(), aLength, aLength );
+ return iCommandBufPtr;
+ }
void CBulkOnlyTransportUsbcLdd::SetReadDataBufPtr(TUint aLength) //Write10(Host->Device
- {
- if (iSwap)
- {
- iDataBuf1.SetLength(aLength);
- iReadBufPtr.Set(iDataBuf1.LeftTPtr(iDataBuf1.Length()));
- iSwap = EFalse;
- }
- else
- {
- iDataBuf2.SetLength(aLength);
- iReadBufPtr.Set(iDataBuf2.LeftTPtr(iDataBuf2.Length()));
- iSwap = ETrue;
- }
- }
+ {
+ iBulkMm.GetNextTransferBuffer(aLength, iReadBufPtr);
+ }
+
TPtr8& CBulkOnlyTransportUsbcLdd::SetDataBufPtr() //Read10(Device->Host)
- {
- if (iSwap)
- {
- iDataBufPtr.Set((TUint8*) iDataBuf1.Ptr(), KMaxBufSize, KMaxBufSize);
- iSwap = EFalse;
- }
- else
- {
- iDataBufPtr.Set((TUint8*) iDataBuf2.Ptr(), KMaxBufSize, KMaxBufSize);
- iSwap = ETrue;
- }
- return iDataBufPtr;
- }
+ {
+ iBulkMm.GetNextTransferBuffer(iDataBufPtr);
+ return iDataBufPtr;
+ }
void CBulkOnlyTransportUsbcLdd::SetPaddingBufPtr(TUint aLength)
- {
- iPaddingBufPtr.Set((TUint8*) iBuf.Ptr(), aLength, aLength );
- }
+ {
+ iPaddingBufPtr.Set((TUint8*) iBuf.Ptr(), aLength, aLength );
+ }
void CBulkOnlyTransportUsbcLdd::SetCswBufPtr(TUint aLength)
- {
- iCswBufPtr.Set((TUint8*) iCswBuf.Ptr(), aLength, aLength );
- }
+ {
+ iCswBufPtr.Set((TUint8*) iCswBuf.Ptr(), aLength, aLength );
+ }
void CBulkOnlyTransportUsbcLdd::ProcessReadingDataEvent()
- {
- TInt ret = KErrNone;
+ {
+ TInt ret = KErrNone;
FOREVER
- {
- if (iReadSetUp)
- {
- ret = iProtocol->ReadComplete(KErrNone);
- }
+ {
+ if (iReadSetUp)
+ {
+ ret = iProtocol->ReadComplete(KErrNone);
+ }
- TUint deviceDataLength = iBufSize; // This is the amount (maximum in case of SC Ldd) to be read next.
+ TUint deviceDataLength = iBufSize; // This is the amount (maximum in case of SC Ldd) to be read next.
- if(ret == KErrCompletion)
- {
- // The protocol has indicated with KErrCompletion that sufficient
- // data is available in the buffer to process the transfer immediately.
+ if(ret == KErrCompletion)
+ {
+ // The protocol has indicated with KErrCompletion that sufficient
+ // data is available in the buffer to process the transfer immediately.
- iDataResidue -= iReadBufPtr.Length();
- SetReadDataBufPtr(deviceDataLength);
+ iDataResidue -= iReadBufPtr.Length();
+ SetReadDataBufPtr(deviceDataLength);
- iLdd.Read(iStatus, OutEndpoint, iReadBufPtr, deviceDataLength);
- User::WaitForRequest(iStatus);
- if (iStatus != KErrNone)
- {
- // An error occurred - halt endpoints for reset recovery
- __PRINT1(_L("Error %d in EReadingData, halt endpoints \n"), iStatus.Int());
- SetPermError();
- return;
- }
- }
- else if(ret == KErrNotReady)
- {
- // The protocol has indicated with KErrNotReady that insufficient
- // data is available in the buffer, so should wait for it to arrive
+ iLdd.Read(iStatus, OutEndpoint, iReadBufPtr, deviceDataLength);
+ User::WaitForRequest(iStatus);
+ if (iStatus != KErrNone)
+ {
+ // An error occurred - halt endpoints for reset recovery
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, E1, "Error %d in EReadingData, halt endpoints", iStatus.Int());
+ SetPermError();
+ return;
+ }
+ }
+ else if(ret == KErrNotReady)
+ {
+ // The protocol has indicated with KErrNotReady that insufficient
+ // data is available in the buffer, so should wait for it to arrive
iDataResidue -= iReadBufPtr.Length();
- ReadData(deviceDataLength);
- break;
- }
- else
- {
- // The protocol has indicated that transfer is
- // complete, so send the CSW response to the host.
- iDataResidue -= iReadBufPtr.Length();
- iReadSetUp = EFalse;
+ ReadData(deviceDataLength);
+ break;
+ }
+ else
+ {
+ // The protocol has indicated that transfer is
+ // complete, so send the CSW response to the host.
+ iDataResidue -= iReadBufPtr.Length();
+ iReadSetUp = EFalse;
- if (ret != KErrNone)
- {
- iCmdStatus = ECommandFailed;
- }
+ if (ret != KErrNone)
+ {
+ iCmdStatus = ECommandFailed;
+ }
- if (iDataResidue)
- {
- __PRINT(_L("Discarding residue"));
- // we have to read as much data as available that host PC sends;
- // otherwise, bulk-out endpoint will need to keep sending NAK back.
- ReadAndDiscardData(iDataResidue);
- }
- SendCSW(iCbwTag, iDataResidue, iCmdStatus);
- break;
- }
- }
+ if (iDataResidue)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, E2, "Discarding residue");
+ // we have to read as much data as available that host PC sends;
+ // otherwise, bulk-out endpoint will need to keep sending NAK back.
+ ReadAndDiscardData(iDataResidue);
+ }
+ SendCSW(iCbwTag, iDataResidue, iCmdStatus);
+ break;
+ }
+ }
- }
+ }
void CBulkOnlyTransportUsbcLdd::DiscardData(TUint aLength)
- {
- iBuf.SetLength(KBOTMaxBufSize);
- TUint c = 0;
- TRequestStatus status;
- while (c < aLength)
- {
- TInt len;
- if (aLength - c > KBOTMaxBufSize)
- {
- len = KBOTMaxBufSize;
- }
- else
- {
- len = aLength - c;
- }
+ {
+ iBuf.SetLength(KBOTMaxBufSize);
+ TUint c = 0;
+ TRequestStatus status;
+ while (c < aLength)
+ {
+ TInt len;
+ if (aLength - c > KBOTMaxBufSize)
+ {
+ len = KBOTMaxBufSize;
+ }
+ else
+ {
+ len = aLength - c;
+ }
- iLdd.Read(status, OutEndpoint, iBuf, len);
- User::WaitForRequest(status);
- c += KBOTMaxBufSize;
- }
- }
+ iLdd.Read(status, OutEndpoint, iBuf, len);
+ User::WaitForRequest(status);
+ c += KBOTMaxBufSize;
+ }
+ }
void CBulkOnlyTransportUsbcLdd::WriteToClient(TUint aLength)
- {
- SetDataBufPtr();
- iLdd.Read(iStatus, OutEndpoint, iDataBufPtr, aLength);
+ {
+ SetDataBufPtr();
+ iLdd.Read(iStatus, OutEndpoint, iDataBufPtr, aLength);
User::WaitForRequest(iStatus);
iProtocol->ReadComplete(KErrGeneral);
- }
+ }
#ifdef MSDC_MULTITHREADED
void CBulkOnlyTransportUsbcLdd::GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2)
- {
- aDes1.Set((TUint8*) iDataBuf1.Ptr(), KMaxBufSize, KMaxBufSize);
- aDes2.Set((TUint8*) iDataBuf2.Ptr(), KMaxBufSize, KMaxBufSize);
- }
+ {
+ aDes1.Set(iBulkMm.Buf1(), KMaxBufSize, KMaxBufSize);
+ aDes2.Set(iBulkMm.Buf2(), KMaxBufSize, KMaxBufSize);
+ }
#endif
void CBulkOnlyTransportUsbcLdd::Activate(TRequestStatus& aStatus, TUint& aDeviceState)
{
- iLdd.AlternateDeviceStatusNotify(aStatus, aDeviceState);
+ iLdd.AlternateDeviceStatusNotify(aStatus, aDeviceState);
}
void CBulkOnlyTransportUsbcLdd::Cancel()
{
- iLdd.AlternateDeviceStatusNotifyCancel();
+ iLdd.AlternateDeviceStatusNotifyCancel();
}
--- a/userlibandfileserver/fileserver/smassstorage/cbulkonlytransportusbcscldd.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cbulkonlytransportusbcscldd.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -21,20 +21,32 @@
@internalTechnology
*/
+#include <e32std.h>
+#include "mtransport.h"
+#include "mprotocol.h"
+#include "mldddevicestatenotification.h"
+
+#include "drivemanager.h"
+#include "cusbmassstoragecontroller.h"
+
#include "cbulkonlytransport.h"
#include "cbulkonlytransportusbcscldd.h"
-#include "usbmsshared.h"
-#include "massstoragedebug.h"
-#include "cusbmassstorageserver.h"
+#include "smassstorage.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cbulkonlytransportusbcsclddTraces.h"
+#endif
+
//This value defined in USB Mass Storage Bulk Only Transrt spec and not supposed to be changed
-LOCAL_D const TInt KRequiredNumberOfEndpoints = 2; // in addition to endpoint 0.
+static const TInt KRequiredNumberOfEndpoints = 2; // in addition to endpoint 0.
-LOCAL_D const TInt KUsbNumInterfacesOffset = 4;
+static const TInt KUsbNumInterfacesOffset = 4;
#ifdef MSDC_MULTITHREADED
-//Only used in DB. The first 2K of KMaxScBufferSize for sending CSW
+//Only used in DB. The first 2K of KMaxScBufferSize for sending CSW
static const TUint32 KCswBufferSize = 2 * 1024;
#endif
@@ -47,19 +59,19 @@
CControlInterfaceUsbcScLdd* CControlInterfaceUsbcScLdd::NewL(CBulkOnlyTransportUsbcScLdd& aParent)
- {
- CControlInterfaceUsbcScLdd* self = new(ELeave) CControlInterfaceUsbcScLdd(aParent);
- CleanupStack::PushL(self);
- self->ConstructL();
- CActiveScheduler::Add(self);
- CleanupStack::Pop();
- return self;
- }
+ {
+ CControlInterfaceUsbcScLdd* self = new(ELeave) CControlInterfaceUsbcScLdd(aParent);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CActiveScheduler::Add(self);
+ CleanupStack::Pop();
+ return self;
+ }
void CControlInterfaceUsbcScLdd::ConstructL()
- {
- }
+ {
+ }
/**
@@ -68,229 +80,212 @@
@param aParent reference to the CBulkOnlyTransportUsbcScLdd
*/
CControlInterfaceUsbcScLdd::CControlInterfaceUsbcScLdd(CBulkOnlyTransportUsbcScLdd& aParent)
- :CActive(EPriorityStandard),
- iParent(aParent),
- iCurrentState(ENone)
- {
- }
+ :CActive(EPriorityStandard),
+ iParent(aParent),
+ iCurrentState(ENone)
+ {
+ }
/**
d'tor
*/
CControlInterfaceUsbcScLdd::~CControlInterfaceUsbcScLdd()
- {
- __FNLOG("CControlInterfaceUsbcScLdd::~CControlInterfaceUsbcScLdd ");
- Cancel();
- iEp0Buf.Close();
- }
+ {
+ Cancel();
+ iEp0Buf.Close();
+ }
TInt CControlInterfaceUsbcScLdd::OpenEp0()
- {
- TInt res = iParent.Ldd().OpenEndpoint(iEp0Buf,0);
- return res;
- }
+ {
+ TInt res = iParent.Ldd().OpenEndpoint(iEp0Buf,0);
+ return res;
+ }
/**
Called by CBulkOnlyTransport HwStart to start control interface
*/
TInt CControlInterfaceUsbcScLdd::Start()
- {
- __FNLOG("CControlInterfaceUsbcScLdd::Start ");
- TInt res = ReadEp0Data();
- return (res);
- }
+ {
+ TInt res = ReadEp0Data();
+ return (res);
+ }
/**
Called by desctructor of CBulkOnlyTransportUsbcScLdd to stop control interface
*/
void CControlInterfaceUsbcScLdd::Stop()
- {
- __FNLOG("CControlInterfaceUsbcScLdd::Stop ");
- if (!IsActive())
- {
- __PRINT(_L("Not active\n"));
- return;
- }
-
- __PRINT(_L("\nStopping...\n"));
-
-
- iCurrentState = ENone;
-
- Cancel();
- }
+ {
+ if (!IsActive())
+ {
+ return;
+ }
+ iCurrentState = ENone;
+ Cancel();
+ }
/**
Cancel outstanding request (if any)
*/
void CControlInterfaceUsbcScLdd::DoCancel()
- {
- __FNLOG("CControlInterfaceUsbcScLdd::DoCancel ");
- switch(iCurrentState)
- {
- case EReadEp0Data:
- iParent.Ldd().ReadCancel(KUsbcScEndpointZero);
- break;
- case ESendMaxLun:
- iParent.Ldd().WriteCancel(KUsbcScEndpointZero);
- break;
- default:
- __PRINT(_L("\nWrong state !\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
- }
- }
+ {
+ switch(iCurrentState)
+ {
+ case EReadEp0Data:
+ iParent.Ldd().ReadCancel(KUsbcScEndpointZero);
+ break;
+ case ESendMaxLun:
+ iParent.Ldd().WriteCancel(KUsbcScEndpointZero);
+ break;
+ default:
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceBadState));
+ }
+ }
/**
Implement CControlInterfaceUsbcScLdd state machine
*/
void CControlInterfaceUsbcScLdd::RunL()
- {
- __FNLOG("CControlInterfaceUsbcScLdd::RunL ");
- if (iStatus != KErrNone)
- {
- __PRINT1(_L("Error %d in RunL\n"), iStatus.Int());
+ {
+ if (iStatus != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, CCONTROLINTERFACEUSBCSCLDD,
+ "ERROR %d in RunL", iStatus.Int());
+ //read EP0 again
+ ReadEp0Data();
+ return;
+ }
- //read EP0 again
- ReadEp0Data();
- return;
- }
-
- ReadEp0Data();
- }
+ ReadEp0Data();
+ }
/**
Actual Read to RDevUsbcScClient BIL
*/
TInt CControlInterfaceUsbcScLdd::ReadUsbEp0()
- {
- iCurrentState = EReadEp0Data;
- iStatus = KRequestPending;
- return iEp0Buf.GetBuffer (iEp0Packet,iEp0Size,iEp0Zlp,iStatus);
- }
+ {
+ iCurrentState = EReadEp0Data;
+ iStatus = KRequestPending;
+ return iEp0Buf.GetBuffer (iEp0Packet,iEp0Size,iEp0Zlp,iStatus);
+ }
/**
Post a read request to EEndpoint0 to read request header
*/
TInt CControlInterfaceUsbcScLdd::ReadEp0Data()
- {
- __FNLOG("CControlInterfaceUsbcScLdd::ReadEp0Data ");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- return KErrServerBusy;
- }
+ {
+ if (IsActive())
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, READEP0DATA_SC, "Still active");
+ return KErrServerBusy;
+ }
- TInt r = KErrNone;
- do
- {
- r = ReadUsbEp0();
- if (r == KErrCompletion)
- {
- iStatus = KErrNone;
- DecodeEp0Data();
- }
- else if (r == KErrNone)
- {
- SetActive();
- }
- } while (((r == KErrCompletion) || (r == TEndpointBuffer::KStateChange)) && (!IsActive()));
- return KErrNone;
- }
+ TInt r = KErrNone;
+ do
+ {
+ r = ReadUsbEp0();
+ if (r == KErrCompletion)
+ {
+ iStatus = KErrNone;
+ DecodeEp0Data();
+ }
+ else if (r == KErrNone)
+ {
+ SetActive();
+ }
+ } while (((r == KErrCompletion) || (r == TEndpointBuffer::KStateChange)) && (!IsActive()));
+ return KErrNone;
+ }
/**
Decode request header and do appropriate action - get max LUN info or post a reset request
*/
void CControlInterfaceUsbcScLdd::DecodeEp0Data()
- {
- __FNLOG("CControlInterfaceUsbcScLdd::DecodeEp0Data ");
+ {
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceStillActive));
+ return;
+ }
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsControlInterfaceStillActive));
- return;
- }
+ TPtrC8 ep0ReadDataPtr((TUint8*)iEp0Packet, iEp0Size);
+ TInt err = iRequestHeader.Decode(ep0ReadDataPtr);
- TPtrC8 ep0ReadDataPtr((TUint8*)iEp0Packet, iEp0Size);
- TInt err = iRequestHeader.Decode(ep0ReadDataPtr);
-
- if(err != KErrNone)
- return;
+ if(err != KErrNone)
+ return;
switch(iRequestHeader.iRequest)
- {
- //
- // GET MAX LUN (0xFE)
- //
- case TUsbRequestHdr::EReqGetMaxLun:
- {
- __PRINT1(_L("DecodeEp0Data : 'Get Max LUN' Request MaxLun = %d"),iParent.MaxLun() );
+ {
+ //
+ // GET MAX LUN (0xFE)
+ //
+ case TUsbRequestHdr::EReqGetMaxLun:
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA_SC, ">>> EP0 GetMaxLun = %d", iParent.MaxLun());
if ( iRequestHeader.iRequestType != 0xA1 //value from USB MS BOT spec
|| iRequestHeader.iIndex > 15
|| iRequestHeader.iValue != 0
|| iRequestHeader.iLength != 1)
{
- __PRINT(_L("GetMaxLun command packet check error"));
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA1_SC, "ERROR: GetMaxLun command packet check error");
iParent.Ldd().EndpointZeroRequestError();
break;
}
- TPtr8* ep0WriteDataPtr = NULL;
- TUint ep0Length;
- iEp0Buf.GetInBufferRange(((TAny*&)ep0WriteDataPtr),ep0Length);
- ep0WriteDataPtr->SetLength(1); //Return only 1 byte to host
- ep0WriteDataPtr->Fill(0);
- ep0WriteDataPtr->Fill(iParent.MaxLun()); // Supported Units
- TInt length = ep0WriteDataPtr->Length();
- err = iEp0Buf.WriteBuffer((TPtr8*)(ep0WriteDataPtr->Ptr()),length,ETrue,iStatus);
+ TPtr8* ep0WriteDataPtr = NULL;
+ TUint ep0Length;
+ iEp0Buf.GetInBufferRange(((TAny*&)ep0WriteDataPtr),ep0Length);
+ ep0WriteDataPtr->SetLength(1); //Return only 1 byte to host
+ ep0WriteDataPtr->Fill(0);
+ ep0WriteDataPtr->Fill(iParent.MaxLun()); // Supported Units
+ TInt length = ep0WriteDataPtr->Length();
+ err = iEp0Buf.WriteBuffer((TPtr8*)(ep0WriteDataPtr->Ptr()),length,ETrue,iStatus);
- iCurrentState = ESendMaxLun;
- SetActive();
+ iCurrentState = ESendMaxLun;
+ SetActive();
- return;
- }
- //
- // RESET (0xFF)
- //
- case TUsbRequestHdr::EReqReset:
- {
- __PRINT(_L("DecodeEp0Data : 'Mass Storage Reset' Request"));
+ return;
+ }
+ //
+ // RESET (0xFF)
+ //
+ case TUsbRequestHdr::EReqReset:
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA2_SC, ">>> EP0 BulkOnlyMassStorageReset");
if ( iRequestHeader.iRequestType != 0x21 //value from USB MS BOT spec
|| iRequestHeader.iIndex > 15
|| iRequestHeader.iValue != 0
|| iRequestHeader.iLength != 0)
{
- __PRINT(_L("MSC Reset command packet check error"));
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA3_SC, "BulkOnlyMassStorageReset command packet check error");
iParent.Ldd().EndpointZeroRequestError();
break;
}
- iParent.HwStop();
- iParent.Controller().Reset();
- iParent.HwStart(ETrue);
+ iParent.HwStop();
+ iParent.Controller().Reset();
+ iParent.HwStart(ETrue);
err = iParent.Ldd().SendEp0StatusPacket();
- return;
- }
- //
- // Unknown?
- //
- default:
- {
- __PRINT(_L("DecodeEp0Data : Unknown Request"));
-
- }
- }
- ReadEp0Data(); //try to get another request
- }
+ return;
+ }
+ //
+ // Unknown?
+ //
+ default:
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, DECODEEP0DATA4_SC, ">>> EP0 DecodeEp0Data : Unknown Request");
+ }
+ }
+ ReadEp0Data(); //try to get another request
+ }
//
@@ -298,42 +293,39 @@
//
CBulkOnlyTransportUsbcScLdd::CBulkOnlyTransportUsbcScLdd(TInt aNumDrives,CUsbMassStorageController& aController)
- :CBulkOnlyTransport(aNumDrives, aController)
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::CBulkOnlyTransportUsbcScLdd");
- }
+ :CBulkOnlyTransport(aNumDrives, aController)
+ {
+ }
/**
Constructs the CBulkOnlyTransportUsbcScLdd object
*/
void CBulkOnlyTransportUsbcScLdd::ConstructL()
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::ConstructL()");
- iControlInterface = CControlInterfaceUsbcScLdd::NewL(*this);
- iDeviceStateNotifier = CActiveDeviceStateNotifierBase::NewL(*this, *this);
- iChunk = new RChunk();
- CActiveScheduler::Add(this);
- }
+ {
+ iControlInterface = CControlInterfaceUsbcScLdd::NewL(*this);
+ iDeviceStateNotifier = CActiveDeviceStateNotifierBase::NewL(*this, *this);
+ iChunk = new RChunk();
+ CActiveScheduler::Add(this);
+ }
CBulkOnlyTransportUsbcScLdd::~CBulkOnlyTransportUsbcScLdd()
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::~CBulkOnlyTransportUsbcScLdd");
- if (iInterfaceConfigured)
- {
+ {
+ if (iInterfaceConfigured)
+ {
Stop();
- TInt err = iSCReadEndpointBuf.Close();
- err = iSCWriteEndpointBuf.Close();
- delete iControlInterface ;
- delete iDeviceStateNotifier;
- delete iChunk;
- }
- }
+ TInt err = iSCReadEndpointBuf.Close();
+ err = iSCWriteEndpointBuf.Close();
+ delete iControlInterface ;
+ delete iDeviceStateNotifier;
+ delete iChunk;
+ }
+ }
RDevUsbcScClient& CBulkOnlyTransportUsbcScLdd::Ldd()
- {
- return iLdd;
- }
+ {
+ return iLdd;
+ }
/**
Set or unset configuration descriptor for USB MassStorage Bulk Only transport
@@ -342,45 +334,44 @@
@return KErrNone if operation was completed successfully, errorcode otherwise
*/
TInt CBulkOnlyTransportUsbcScLdd::SetupConfigurationDescriptor(TBool aUnset)
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::SetupConfigurationDescriptor");
- TInt ret(KErrNone);
+ {
+ TInt ret(KErrNone);
- if ((ret = iLdd.Open(0)) != KErrNone)
- return ret;
+ if ((ret = iLdd.Open(0)) != KErrNone)
+ return ret;
- TInt configDescriptorSize(0);
- iLdd.GetConfigurationDescriptorSize(configDescriptorSize);
- if (static_cast<TUint>(configDescriptorSize) != KUsbDescSize_Config)
- {
- return KErrCorrupt;
- }
+ TInt configDescriptorSize(0);
+ iLdd.GetConfigurationDescriptorSize(configDescriptorSize);
+ if (static_cast<TUint>(configDescriptorSize) != KUsbDescSize_Config)
+ {
+ return KErrCorrupt;
+ }
- TBuf8<KUsbDescSize_Config> configDescriptor;
- ret = iLdd.GetConfigurationDescriptor(configDescriptor);
- if (ret != KErrNone)
- {
- return ret;
- }
+ TBuf8<KUsbDescSize_Config> configDescriptor;
+ ret = iLdd.GetConfigurationDescriptor(configDescriptor);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
- // I beleive that other fields setted up during LDD initialisation
- if (aUnset)
- {
- --configDescriptor[KUsbNumInterfacesOffset];
- }
- else
- {
- ++configDescriptor[KUsbNumInterfacesOffset];
- }
- ret = iLdd.SetConfigurationDescriptor(configDescriptor);
+ // I beleive that other fields setted up during LDD initialisation
+ if (aUnset)
+ {
+ --configDescriptor[KUsbNumInterfacesOffset];
+ }
+ else
+ {
+ ++configDescriptor[KUsbNumInterfacesOffset];
+ }
+ ret = iLdd.SetConfigurationDescriptor(configDescriptor);
- if (aUnset)
- {
- iLdd.Close();
- }
+ if (aUnset)
+ {
+ iLdd.Close();
+ }
- return ret;
- }
+ return ret;
+ }
/**
Set up interface descriptor
@@ -388,265 +379,261 @@
@return KErrNone if operation was completed successfully, errorcode otherwise
*/
TInt CBulkOnlyTransportUsbcScLdd::SetupInterfaceDescriptors()
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::SetupInterfaceDescriptors");
- // Device caps
- TUsbDeviceCaps d_caps;
- TInt ret = iLdd.DeviceCaps(d_caps);
- if (ret != KErrNone)
- {
- return ret;
- }
- TInt totalEndpoints = d_caps().iTotalEndpoints;
- if (totalEndpoints < KRequiredNumberOfEndpoints)
- {
- return KErrHardwareNotAvailable;
- }
+ {
+ // Device caps
+ TUsbDeviceCaps d_caps;
+ TInt ret = iLdd.DeviceCaps(d_caps);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
+ TInt totalEndpoints = d_caps().iTotalEndpoints;
+ if (totalEndpoints < KRequiredNumberOfEndpoints)
+ {
+ return KErrHardwareNotAvailable;
+ }
- // Endpoint caps
- TUsbcEndpointData data[KUsbcMaxEndpoints];
- TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
- ret = iLdd.EndpointCaps(dataptr);
- if (ret != KErrNone)
- {
- return ret;
- }
+ // Endpoint caps
+ TUsbcEndpointData data[KUsbcMaxEndpoints];
+ TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
+ ret = iLdd.EndpointCaps(dataptr);
+ if (ret != KErrNone)
+ {
+ return ret;
+ }
- // Set the active interface
- TUsbcScInterfaceInfoBuf ifc;
- TInt ep_found = 0;
- TBool foundBulkIN = EFalse;
- TBool foundBulkOUT = EFalse;
+ // Set the active interface
+ TUsbcScInterfaceInfoBuf ifc;
+ TInt ep_found = 0;
+ TBool foundBulkIN = EFalse;
+ TBool foundBulkOUT = EFalse;
- for (TInt i = 0; i < totalEndpoints ; i++)
- {
- const TUsbcEndpointCaps* caps = &data[i].iCaps;
- const TInt maxPacketSize = caps->MaxPacketSize();
- if (!foundBulkIN &&
- (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == (KUsbEpTypeBulk | KUsbEpDirIn))
- {
- // InEndpoint is going to be our TX (IN, write) endpoint
- ifc().iEndpointData[0].iType = KUsbEpTypeBulk;
- if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
- ifc().iEndpointData[0].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
- ifc().iEndpointData[0].iDir = KUsbEpDirIn;
- ifc().iEndpointData[0].iSize = maxPacketSize;
- ifc().iEndpointData[0].iInterval_Hs = 0;
- ifc().iEndpointData[0].iBufferSize = KMaxScBufferSize;
- foundBulkIN = ETrue;
- if (++ep_found == KRequiredNumberOfEndpoints)
- {
- break;
- }
- continue;
- }
- if (!foundBulkOUT &&
- (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == (KUsbEpTypeBulk | KUsbEpDirOut))
- {
- // OutEndpoint is going to be our RX (OUT, read) endpoint
- ifc().iEndpointData[1].iType = KUsbEpTypeBulk;
- if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
- ifc().iEndpointData[1].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
- ifc().iEndpointData[1].iDir = KUsbEpDirOut;
- ifc().iEndpointData[1].iSize = maxPacketSize;
- ifc().iEndpointData[1].iInterval_Hs = 0;
- ifc().iEndpointData[1].iBufferSize = KMaxScBufferSize;
- ifc().iEndpointData[1].iReadSize = KMaxScReadSize;
+ for (TInt i = 0; i < totalEndpoints ; i++)
+ {
+ const TUsbcEndpointCaps* caps = &data[i].iCaps;
+ const TInt maxPacketSize = caps->MaxPacketSize();
+ if (!foundBulkIN &&
+ (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == (KUsbEpTypeBulk | KUsbEpDirIn))
+ {
+ // InEndpoint is going to be our TX (IN, write) endpoint
+ ifc().iEndpointData[0].iType = KUsbEpTypeBulk;
+ if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
+ ifc().iEndpointData[0].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
+ ifc().iEndpointData[0].iDir = KUsbEpDirIn;
+ ifc().iEndpointData[0].iSize = maxPacketSize;
+ ifc().iEndpointData[0].iInterval_Hs = 0;
+ ifc().iEndpointData[0].iBufferSize = KMaxScBufferSize;
+ foundBulkIN = ETrue;
+ if (++ep_found == KRequiredNumberOfEndpoints)
+ {
+ break;
+ }
+ continue;
+ }
+ if (!foundBulkOUT &&
+ (caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == (KUsbEpTypeBulk | KUsbEpDirOut))
+ {
+ // OutEndpoint is going to be our RX (OUT, read) endpoint
+ ifc().iEndpointData[1].iType = KUsbEpTypeBulk;
+ if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) == KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
+ ifc().iEndpointData[1].iFeatureWord1 = KUsbcEndpointInfoFeatureWord1_DMA|KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
+ ifc().iEndpointData[1].iDir = KUsbEpDirOut;
+ ifc().iEndpointData[1].iSize = maxPacketSize;
+ ifc().iEndpointData[1].iInterval_Hs = 0;
+ ifc().iEndpointData[1].iBufferSize = KMaxScBufferSize;
+ ifc().iEndpointData[1].iReadSize = KMaxScReadSize;
- foundBulkOUT = ETrue;
- if (++ep_found == KRequiredNumberOfEndpoints)
- {
- break;
- }
- continue;
- }
- }
- if (ep_found != KRequiredNumberOfEndpoints)
- {
- return KErrHardwareNotAvailable;
- }
+ foundBulkOUT = ETrue;
+ if (++ep_found == KRequiredNumberOfEndpoints)
+ {
+ break;
+ }
+ continue;
+ }
+ }
+ if (ep_found != KRequiredNumberOfEndpoints)
+ {
+ return KErrHardwareNotAvailable;
+ }
- _LIT16(string, "USB Mass Storage Interface");
- ifc().iString = const_cast<TDesC16*>(&string);
- ifc().iTotalEndpointsUsed = KRequiredNumberOfEndpoints;
- ifc().iClass.iClassNum = 0x08; // Mass Storage
- ifc().iClass.iSubClassNum = 0x06; // SCSI Transparent Command Set
- ifc().iClass.iProtocolNum = 0x50; // Bulk Only Transport
+ _LIT16(string, "USB Mass Storage Interface");
+ ifc().iString = const_cast<TDesC16*>(&string);
+ ifc().iTotalEndpointsUsed = KRequiredNumberOfEndpoints;
+ ifc().iClass.iClassNum = 0x08; // Mass Storage
+ ifc().iClass.iSubClassNum = 0x06; // SCSI Transparent Command Set
+ ifc().iClass.iProtocolNum = 0x50; // Bulk Only Transport
- if (d_caps().iHighSpeed)
- {
- // Tell the Protocol about it, because it might want to do some
- // optimizing too.
- iProtocol->ReportHighSpeedDevice();
- }
+ if (d_caps().iHighSpeed)
+ {
+ // Tell the Protocol about it, because it might want to do some
+ // optimizing too.
+ iProtocol->ReportHighSpeedDevice();
+ }
- if ((ret = iLdd.SetInterface(0, ifc)) == KErrNone)
- {
- return (iLdd.FinalizeInterface(iChunk));
- }
- return ret;
- }
+ if ((ret = iLdd.SetInterface(0, ifc)) == KErrNone)
+ {
+ return (iLdd.FinalizeInterface(iChunk));
+ }
+ return ret;
+ }
void CBulkOnlyTransportUsbcScLdd::ReleaseInterface()
- {
- iLdd.ReleaseInterface(0);
- }
+ {
+ iLdd.ReleaseInterface(0);
+ }
TInt CBulkOnlyTransportUsbcScLdd::StartControlInterface()
- {
- return iControlInterface->Start();
- }
+ {
+ return iControlInterface->Start();
+ }
void CBulkOnlyTransportUsbcScLdd::CancelControlInterface()
- {
- iControlInterface->Cancel();
- }
+ {
+ iControlInterface->Cancel();
+ }
void CBulkOnlyTransportUsbcScLdd::ActivateDeviceStateNotifier()
- {
- iDeviceStateNotifier->Activate();
- }
+ {
+ iDeviceStateNotifier->Activate();
+ }
void CBulkOnlyTransportUsbcScLdd::CancelDeviceStateNotifier()
- {
- iDeviceStateNotifier->Cancel();
- }
+ {
+ iDeviceStateNotifier->Cancel();
+ }
void CBulkOnlyTransportUsbcScLdd::CancelReadWriteRequests()
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::CancelReadWriteRequests");
- TUsbcScChunkHeader chunkHeader(*iChunk);
- for (TInt i = 0; i < chunkHeader.iAltSettings->iNumOfAltSettings; i++)
- {
- TInt8* endpoint = (TInt8*) (chunkHeader.iAltSettings->iAltTableOffset[i] + (TInt) iChunk->Base());
- TInt numOfEps = chunkHeader.GetNumberOfEndpoints(i);
+ {
+ TUsbcScChunkHeader chunkHeader(*iChunk);
+ for (TInt i = 0; i < chunkHeader.iAltSettings->iNumOfAltSettings; i++)
+ {
+ TInt8* endpoint = (TInt8*) (chunkHeader.iAltSettings->iAltTableOffset[i] + (TInt) iChunk->Base());
+ TInt numOfEps = chunkHeader.GetNumberOfEndpoints(i);
__ASSERT_DEBUG(numOfEps >= 0, User::Invariant());
- for (TInt j = 1; j <= numOfEps; j++)
- {
- TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(endpoint[j * chunkHeader.iAltSettings->iEpRecordSize]);
- if (endpointInf->Direction() == KUsbScHdrEpDirectionOut)
- {
- iLdd.ReadCancel(endpointInf->iBufferNo);
- }
- if (endpointInf->Direction() == KUsbScHdrEpDirectionIn)
- {
- iLdd.WriteCancel(endpointInf->iBufferNo);
- }
- }
- }
- }
+ for (TInt j = 1; j <= numOfEps; j++)
+ {
+ TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(endpoint[j * chunkHeader.iAltSettings->iEpRecordSize]);
+ if (endpointInf->Direction() == KUsbScHdrEpDirectionOut)
+ {
+ iLdd.ReadCancel(endpointInf->iBufferNo);
+ }
+ if (endpointInf->Direction() == KUsbScHdrEpDirectionIn)
+ {
+ iLdd.WriteCancel(endpointInf->iBufferNo);
+ }
+ }
+ }
+ }
void CBulkOnlyTransportUsbcScLdd::AllocateEndpointResources()
- {
- TUsbcScChunkHeader chunkHeader(*iChunk);
- for (TInt i = 0; i < chunkHeader.iAltSettings->iNumOfAltSettings; i++)
- {
- TInt8* endpoint = (TInt8*) (chunkHeader.iAltSettings->iAltTableOffset[i] + (TInt) iChunk->Base());
+ {
+ TUsbcScChunkHeader chunkHeader(*iChunk);
+ for (TInt i = 0; i < chunkHeader.iAltSettings->iNumOfAltSettings; i++)
+ {
+ TInt8* endpoint = (TInt8*) (chunkHeader.iAltSettings->iAltTableOffset[i] + (TInt) iChunk->Base());
- for (TInt j = 1; j <= chunkHeader.GetNumberOfEndpoints(i); j++)
- {
- TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(endpoint[j * chunkHeader.iAltSettings->iEpRecordSize]);
- if (endpointInf->Direction() == KUsbScHdrEpDirectionOut)
- {
- iOutEndpoint = j;
- }
- if (endpointInf->Direction() == KUsbScHdrEpDirectionIn)
- {
- iInEndpoint = j;
- }
- }
- }
+ for (TInt j = 1; j <= chunkHeader.GetNumberOfEndpoints(i); j++)
+ {
+ TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(endpoint[j * chunkHeader.iAltSettings->iEpRecordSize]);
+ if (endpointInf->Direction() == KUsbScHdrEpDirectionOut)
+ {
+ iOutEndpoint = j;
+ }
+ if (endpointInf->Direction() == KUsbScHdrEpDirectionIn)
+ {
+ iInEndpoint = j;
+ }
+ }
+ }
- TUsbDeviceCaps d_caps;
- TInt err;
- TInt ret = iLdd.DeviceCaps(d_caps);
- if (ret == KErrNone)
- {
- if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
- {
- __PRINT(_L("CBulkOnlyTransportUsbcScLdd::Start - Setting up DMA and double buffering\n"));
- // Set up DMA if possible (errors are non-critical)
- err = iLdd.AllocateEndpointResource(iOutEndpoint, EUsbcEndpointResourceDMA);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set DMA on OUT endpoint failed with error code: %d"), err);
- }
- err = iLdd.AllocateEndpointResource(iInEndpoint, EUsbcEndpointResourceDMA);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set DMA on IN endpoint failed with error code: %d"), err);
- }
+ TUsbDeviceCaps d_caps;
+ TInt err;
+ TInt ret = iLdd.DeviceCaps(d_caps);
+ if (ret == KErrNone)
+ {
+ if((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != KUsbDevCapsFeatureWord1_EndpointResourceAllocV2)
+ {
+ // Set up DMA if possible (errors are non-critical)
+ err = iLdd.AllocateEndpointResource(iOutEndpoint, EUsbcEndpointResourceDMA);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A1_SC, "Set DMA on OUT endpoint failed with error code: %d", err);
+ }
+ err = iLdd.AllocateEndpointResource(iInEndpoint, EUsbcEndpointResourceDMA);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A2_SC, "Set DMA on IN endpoint failed with error code: %d", err);
+ }
- // Set up Double Buffering if possible (errors are non-critical)
- err = iLdd.AllocateEndpointResource(iOutEndpoint, EUsbcEndpointResourceDoubleBuffering);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set Double Buffering on OUT endpoint failed with error code: %d"), err);
- }
- err = iLdd.AllocateEndpointResource(iInEndpoint, EUsbcEndpointResourceDoubleBuffering);
- if (err != KErrNone)
- {
- __PRINT1(_L("Set Double Buffering on IN endpoint failed with error code: %d"), err);
- }
- }
- }
-
- err = OpenEndpoints();
- }
+ // Set up Double Buffering if possible (errors are non-critical)
+ err = iLdd.AllocateEndpointResource(iOutEndpoint, EUsbcEndpointResourceDoubleBuffering);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A3_SC, "Set Double Buffering on OUT endpoint failed with error code: %d", err);
+ }
+ err = iLdd.AllocateEndpointResource(iInEndpoint, EUsbcEndpointResourceDoubleBuffering);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, A4_SC, "Set Double Buffering on IN endpoint failed with error code: %d", err);
+ }
+ }
+ }
+
+ err = OpenEndpoints();
+ }
TInt CBulkOnlyTransportUsbcScLdd::OpenEndpoints()
- {
- TInt res = iLdd.OpenEndpoint(iSCReadEndpointBuf, iOutEndpoint);
- if (res == KErrNone)
- {
- res = iLdd.OpenEndpoint(iSCWriteEndpointBuf, iInEndpoint);
- if (res == KErrNone)
- {
- iSCWriteEndpointBuf.GetInBufferRange((TAny*&)iDataPtr, iInBufferLength);
- res = iControlInterface->OpenEp0();
- }
- return res;
- }
+ {
+ TInt res = iLdd.OpenEndpoint(iSCReadEndpointBuf, iOutEndpoint);
+ if (res == KErrNone)
+ {
+ res = iLdd.OpenEndpoint(iSCWriteEndpointBuf, iInEndpoint);
+ if (res == KErrNone)
+ {
+ iSCWriteEndpointBuf.GetInBufferRange((TAny*&)iDataPtr, iInBufferLength);
+ res = iControlInterface->OpenEp0();
+ }
+ return res;
+ }
- return res;
- }
+ return res;
+ }
TInt CBulkOnlyTransportUsbcScLdd::GetDeviceStatus(TUsbcDeviceState& deviceStatus)
- {
- return iLdd.DeviceStatus(deviceStatus);
- }
+ {
+ return iLdd.DeviceStatus(deviceStatus);
+ }
void CBulkOnlyTransportUsbcScLdd::FlushData()
- {
- // Intentionally Left Blank Do Nothing
- }
+ {
+ // Intentionally Left Blank Do Nothing
+ }
/**
* Read out rest data from OutEndpoint and discard them
*/
void CBulkOnlyTransportUsbcScLdd::ReadAndDiscardData(TInt /*aBytes*/)
- {
- __FNLOG("CBulkOnlyTransport::ReadAndDiscardData");
- TRequestStatus status;
- TInt r = KErrNone; // Lets assume there is no data
- do
- {
- iSCReadSize = 0;
- status = KErrNone;
- r = iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,status);
- iSCReadEndpointBuf.Expire();
- }
- while (r == KErrCompletion);
+ {
+ TRequestStatus status;
+ TInt r = KErrNone; // Lets assume there is no data
+ do
+ {
+ iSCReadSize = 0;
+ status = KErrNone;
+ r = iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,status);
+ iSCReadEndpointBuf.Expire();
+ }
+ while (r == KErrCompletion);
- if (r == KErrNone)
- {
- TRequestStatus* stat = &status;
- User::RequestComplete(stat, KErrNone);
- }
- }
+ if (r == KErrNone)
+ {
+ TRequestStatus* stat = &status;
+ User::RequestComplete(stat, KErrNone);
+ }
+ }
/**
Called by the protocol to determine how many bytes of data are available in the read buffer.
@@ -654,91 +641,87 @@
@return The number of bytes available in the read buffer
*/
TInt CBulkOnlyTransportUsbcScLdd::BytesAvailable()
- {
- // Intentionally Left Blank Do Nothing
- return 0;
- }
+ {
+ // Intentionally Left Blank Do Nothing
+ return 0;
+ }
void CBulkOnlyTransportUsbcScLdd::StallEndpointAndWaitForClear()
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::StallEndpointAndWaitForClear");
-
- // Now stall this endpoint
- __PRINT1(_L("Stalling endpoint %d"), iInEndpoint);
- TInt r = iLdd.HaltEndpoint(iInEndpoint);
- if (r != KErrNone)
- {
- __PRINT2(_L("Error: stalling ep %d failed: %d"), iInEndpoint, r);
- }
- TEndpointState ep_state;
- TInt i = 0;
- do
- {
- // Wait for 10ms before checking the ep status
- User::After(10000);
- iLdd.EndpointStatus(iInEndpoint, ep_state);
- if (++i >= 550)
- {
- // 5.5 secs should be enough (see 9.2.6.1 Request Processing Timing)
- __PRINT1(_L("Error: Checked for ep %d de-stall for 5.5s - giving up now"), iInEndpoint);
- // We can now only hope for a Reset Recovery
- return;
- }
- } while ((ep_state == EEndpointStateStalled) && iStarted);
- __PRINT2(_L("Checked for ep %d de-stall: %d time(s)"), iInEndpoint, i);
- }
+ {
+ // Now stall this endpoint
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, D1_SC, "Stalling endpoint %d", iInEndpoint);
+ TInt r = iLdd.HaltEndpoint(iInEndpoint);
+ if (r != KErrNone)
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT, D2_SC, "Error: stalling ep %d failed: %d", iInEndpoint, r);
+ }
+ TEndpointState ep_state;
+ TInt i = 0;
+ do
+ {
+ // Wait for 10ms before checking the ep status
+ User::After(10000);
+ iLdd.EndpointStatus(iInEndpoint, ep_state);
+ if (++i >= 550)
+ {
+ // 5.5 secs should be enough (see 9.2.6.1 Request Processing Timing)
+ OstTrace1(TRACE_SMASSSTORAGE_BOT, D3_SC, "Error: Checked for ep %d de-stall for 5.5s - giving up now", iInEndpoint);
+ // We can now only hope for a Reset Recovery
+ return;
+ }
+ } while ((ep_state == EEndpointStateStalled) && iStarted);
+ OstTraceExt2(TRACE_SMASSSTORAGE_BOT, D4_SC, "Checked for ep %d de-stall: %d time(s)", iInEndpoint, i);
+ }
/**
Read CBW data from the host and decode it.
*/
void CBulkOnlyTransportUsbcScLdd::ReadCBW()
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::ReadCBW");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
- return;
- }
- TInt r = KErrNone;
- do
- {
- r = ReadUsb();
- if ((r == KErrCompletion) && (iSCReadSize == KCbwLength))
- {
- iCurrentState = EWaitForCBW;
- iStatus = KErrNone;
- DecodeCBW();
- iSCReadSize = 0;
- }
- else if (r == KErrNone)
- {
- iCurrentState = EWaitForCBW;
- SetActive();
- }
- else if ((r == KErrCompletion) && (iSCReadSize != KCbwLength))
- {
- ExpireData(iSCReadData);
- }
- }while ((r == KErrCompletion) && (!IsActive()));
- }
+ {
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+ return;
+ }
+ TInt r = KErrNone;
+ do
+ {
+ r = ReadUsb();
+ if ((r == KErrCompletion) && (iSCReadSize == KCbwLength))
+ {
+ iCurrentState = EWaitForCBW;
+ iStatus = KErrNone;
+ DecodeCBW();
+ iSCReadSize = 0;
+ }
+ else if (r == KErrNone)
+ {
+ iCurrentState = EWaitForCBW;
+ SetActive();
+ }
+ else if ((r == KErrCompletion) && (iSCReadSize != KCbwLength))
+ {
+ ExpireData(iSCReadData);
+ }
+ }while ((r == KErrCompletion) && (!IsActive()));
+ }
void CBulkOnlyTransportUsbcScLdd::ExpireData(TAny* aAddress)
- {
- if (aAddress)
- {
- iSCReadEndpointBuf.Expire(aAddress);
- }
- else
- {
- iSCReadEndpointBuf.Expire();
- }
- }
+ {
+ if (aAddress)
+ {
+ iSCReadEndpointBuf.Expire(aAddress);
+ }
+ else
+ {
+ iSCReadEndpointBuf.Expire();
+ }
+ }
void CBulkOnlyTransportUsbcScLdd::ProcessCbwEvent()
- {
- ReadCBW();
- }
+ {
+ ReadCBW();
+ }
/**
Request data form the host for the protocol
@@ -746,201 +729,198 @@
@param aLength amount of data (in bytes) to be received from the host
*/
void CBulkOnlyTransportUsbcScLdd::ReadData(TUint /*aLength*/)
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::ReadData");
- if (IsActive())
- {
- __PRINT(_L("Still active\n"));
- __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
- return;
- }
- TInt r = KErrNone;
- do
- {
- r = ReadUsb();
- iCurrentState = EReadingData;
- if (r == KErrCompletion)
- {
- iReadBufPtr.Set((TUint8*) iSCReadData, iSCReadSize, iSCReadSize);
- iStatus = KErrNone;
- ProcessDataFromHost();
- iSCReadSize = 0;
- }
- else if (r == KErrNone)
- {
- iSCReadSize = 0;
- SetActive();
- }
+ {
+ if (IsActive())
+ {
+ __ASSERT_DEBUG(EFalse, User::Panic(KUsbMsSvrPncCat, EMsBulkOnlyStillActive));
+ return;
+ }
+ TInt r = KErrNone;
+ do
+ {
+ r = ReadUsb();
+ iCurrentState = EReadingData;
+ if (r == KErrCompletion)
+ {
+ iReadBufPtr.Set((TUint8*) iSCReadData, iSCReadSize, iSCReadSize);
+ iStatus = KErrNone;
+ ProcessDataFromHost();
+ iSCReadSize = 0;
+ }
+ else if (r == KErrNone)
+ {
+ iSCReadSize = 0;
+ SetActive();
+ }
- }while ((r == KErrCompletion) && (!IsActive()));
- }
+ }while ((r == KErrCompletion) && (!IsActive()));
+ }
void CBulkOnlyTransportUsbcScLdd::ProcessDataFromHost()
- {
- TInt ret = KErrNone;
- {
- if (iReadSetUp)
- {
- ret = iProtocol->ReadComplete(KErrNone);
- }
+ {
+ TInt ret = KErrNone;
+ {
+ if (iReadSetUp)
+ {
+ ret = iProtocol->ReadComplete(KErrNone);
+ }
#ifndef MSDC_MULTITHREADED
- ExpireData(iSCReadData);
+ ExpireData(iSCReadData);
#endif
- TUint deviceDataLength = iSCReadSize; // What was written to the disk // static_cast<TUint>(iReadBuf.Length());
- if(ret == KErrCompletion)
- {
- // The protocol has indicated with KErrCompletion that sufficient
- // data is available in the buffer to process the transfer immediately.
+ TUint deviceDataLength = iSCReadSize; // What was written to the disk // static_cast<TUint>(iReadBuf.Length());
+ if(ret == KErrCompletion)
+ {
+ // The protocol has indicated with KErrCompletion that sufficient
+ // data is available in the buffer to process the transfer immediately.
- //iDataResidue is initially set to host data length as we do not know how much data is there in the 'LDD transfer'.
- //After a TakeBuffer call, iSCReadSize in updated and set to deviceDataLength
- iDataResidue -= deviceDataLength;
- }
- else
- {
- iDataResidue -= deviceDataLength;
+ //iDataResidue is initially set to host data length as we do not know how much data is there in the 'LDD transfer'.
+ //After a TakeBuffer call, iSCReadSize in updated and set to deviceDataLength
+ iDataResidue -= deviceDataLength;
+ }
+ else
+ {
+ iDataResidue -= deviceDataLength;
- // The protocol has indicated that transfer is
- // complete, so send the CSW response to the host.
- iReadSetUp = EFalse;
+ // The protocol has indicated that transfer is
+ // complete, so send the CSW response to the host.
+ iReadSetUp = EFalse;
- if (ret != KErrNone)
- {
- iCmdStatus = ECommandFailed;
- }
+ if (ret != KErrNone)
+ {
+ iCmdStatus = ECommandFailed;
+ }
- if (iDataResidue)
- {
- __PRINT(_L("Discarding residue"));
- // we have to read as much data as available that host PC sends;
- // otherwise, bulk-out endpoint will need to keep sending NAK back.
- ReadAndDiscardData(iDataResidue);
- }
+ if (iDataResidue)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_BOT, E2_SC, "Discarding residue");
+ // we have to read as much data as available that host PC sends;
+ // otherwise, bulk-out endpoint will need to keep sending NAK back.
+ ReadAndDiscardData(iDataResidue);
+ }
- SendCSW(iCbwTag, iDataResidue, iCmdStatus);
- }
- }
- }
+ SendCSW(iCbwTag, iDataResidue, iCmdStatus);
+ }
+ }
+ }
void CBulkOnlyTransportUsbcScLdd::WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired)
- {
- TUint aOffset = (TUint) aDes.Ptr() - (TUint) iChunk->Base();
- iSCWriteEndpointBuf.WriteBuffer(aOffset, aLength, aZlpRequired, aStatus);
- }
+ {
+ TUint aOffset = (TUint) aDes.Ptr() - (TUint) iChunk->Base();
+ iSCWriteEndpointBuf.WriteBuffer(aOffset, aLength, aZlpRequired, aStatus);
+ }
void CBulkOnlyTransportUsbcScLdd::SetCbwPtr()
- {
- iCbwBufPtr.Set((TUint8*)iSCReadData, iSCReadSize);
- }
+ {
+ iCbwBufPtr.Set((TUint8*)iSCReadData, iSCReadSize);
+ }
TPtr8& CBulkOnlyTransportUsbcScLdd::SetCommandBufPtr(TUint aLength)
- {
- TPtr8 writeBuf((TUint8*) iDataPtr, aLength);
- iCommandBufPtr.Set(writeBuf);
- return iCommandBufPtr;
- }
+ {
+ TPtr8 writeBuf((TUint8*) iDataPtr, aLength);
+ iCommandBufPtr.Set(writeBuf);
+ return iCommandBufPtr;
+ }
void CBulkOnlyTransportUsbcScLdd::SetReadDataBufPtr(TUint /*aLength*/)
- {
- // Do nothing for now
- }
+ {
+ // Do nothing for now
+ }
TPtr8& CBulkOnlyTransportUsbcScLdd::SetDataBufPtr()
- {
- TPtr8 writeBuf((TUint8*) iDataPtr, iInBufferLength);
- iDataBufPtr.Set(writeBuf);
- return iDataBufPtr;
- }
+ {
+ TPtr8 writeBuf((TUint8*) iDataPtr, iInBufferLength);
+ iDataBufPtr.Set(writeBuf);
+ return iDataBufPtr;
+ }
void CBulkOnlyTransportUsbcScLdd::SetPaddingBufPtr(TUint aLength)
- {
- TPtr8 writeBuf((TUint8*) iDataPtr, aLength, aLength);
- iPaddingBufPtr.Set(writeBuf);
- }
+ {
+ TPtr8 writeBuf((TUint8*) iDataPtr, aLength, aLength);
+ iPaddingBufPtr.Set(writeBuf);
+ }
void CBulkOnlyTransportUsbcScLdd::SetCswBufPtr(TUint aLength)
- {
- TPtr8 writeBuf((TUint8*) iDataPtr, aLength, aLength);
- iCswBufPtr.Set(writeBuf);
- }
+ {
+ TPtr8 writeBuf((TUint8*) iDataPtr, aLength, aLength);
+ iCswBufPtr.Set(writeBuf);
+ }
void CBulkOnlyTransportUsbcScLdd::ProcessReadingDataEvent()
- {
- ReadData();
- }
+ {
+ ReadData();
+ }
TInt CBulkOnlyTransportUsbcScLdd::ReadUsb(TUint /*aLength*/)
- {
- __FNLOG("CBulkOnlyTransportUsbcScLdd::ReadUSB");
- return iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,iStatus);
- }
+ {
+ return iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,iStatus);
+ }
void CBulkOnlyTransportUsbcScLdd::DiscardData(TUint aLength)
- {
- TUint c = 0;
- TRequestStatus status;
- TInt r = KErrNone;
- while (c < aLength)
- {
- iSCReadSize = 0;
- status = KErrNone;
- r = iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,status);
- c += iSCReadSize;
- if (r == KErrNone)
- User::WaitForRequest(status);
- if (r == KErrCompletion)
- {
- iSCReadEndpointBuf.Expire();
- }
- iSCReadSize = 0;
- }
- }
+ {
+ TUint c = 0;
+ TRequestStatus status;
+ TInt r = KErrNone;
+ while (c < aLength)
+ {
+ iSCReadSize = 0;
+ status = KErrNone;
+ r = iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,status);
+ c += iSCReadSize;
+ if (r == KErrNone)
+ User::WaitForRequest(status);
+ if (r == KErrCompletion)
+ {
+ iSCReadEndpointBuf.Expire();
+ }
+ iSCReadSize = 0;
+ }
+ }
void CBulkOnlyTransportUsbcScLdd::WriteToClient(TUint aLength)
- {
- TUint c = 0;
- TRequestStatus status;
- TInt r = KErrNone;
- while (c < aLength)
- {
- iSCReadSize = 0;
- status = KErrNone;
- r = iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,status);
- c += iSCReadSize;
- iProtocol->ReadComplete(KErrGeneral);
- if (r == KErrNone)
- User::WaitForRequest(status);
- if (r == KErrCompletion)
- {
- iSCReadEndpointBuf.Expire();
- }
- iSCReadSize = 0;
- }
- }
+ {
+ TUint c = 0;
+ TRequestStatus status;
+ TInt r = KErrNone;
+ while (c < aLength)
+ {
+ iSCReadSize = 0;
+ status = KErrNone;
+ r = iSCReadEndpointBuf.TakeBuffer(iSCReadData,iSCReadSize,iReadZlp,status);
+ c += iSCReadSize;
+ iProtocol->ReadComplete(KErrGeneral);
+ if (r == KErrNone)
+ User::WaitForRequest(status);
+ if (r == KErrCompletion)
+ {
+ iSCReadEndpointBuf.Expire();
+ }
+ iSCReadSize = 0;
+ }
+ }
#ifdef MSDC_MULTITHREADED
void CBulkOnlyTransportUsbcScLdd::GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2)
- {
- //for DB
- TUint length = (TUint) (iInBufferLength - KCswBufferSize) / 2;
+ {
+ //for DB
+ TUint length = (TUint) (iInBufferLength - KCswBufferSize) / 2;
- TUint8* start = (TUint8*) (iDataPtr) + KCswBufferSize ; // 'first' buffer
- aDes1.Set(start, length, length);
+ TUint8* start = (TUint8*) (iDataPtr) + KCswBufferSize ; // 'first' buffer
+ aDes1.Set(start, length, length);
- start = (TUint8*) (iDataPtr) + KCswBufferSize + length; // 'second' buffer
- aDes2.Set(start, length, length);
- }
+ start = (TUint8*) (iDataPtr) + KCswBufferSize + length; // 'second' buffer
+ aDes2.Set(start, length, length);
+ }
#endif
void CBulkOnlyTransportUsbcScLdd::Activate(TRequestStatus& aStatus, TUint& aDeviceState)
{
- iLdd.AlternateDeviceStatusNotify(aStatus, aDeviceState);
+ iLdd.AlternateDeviceStatusNotify(aStatus, aDeviceState);
}
void CBulkOnlyTransportUsbcScLdd::Cancel()
{
- iLdd.AlternateDeviceStatusNotifyCancel();
+ iLdd.AlternateDeviceStatusNotifyCancel();
}
--- a/userlibandfileserver/fileserver/smassstorage/cmassstoragefilesystem.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cmassstoragefilesystem.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// CMassStorageFileSystem implementation.
-//
+//
//
/**
@@ -22,51 +22,57 @@
#include <f32file.h>
#include <f32ver.h>
+#include "drivemanager.h"
#include "cusbmassstoragecontroller.h"
#include "cmassstoragefilesystem.h"
#include "cmassstoragemountcb.h"
-#include "massstoragedebug.h"
#include "massstorage.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cmassstoragefilesystemTraces.h"
+#endif
+
+
_LIT(KMsFsyName, "MassStorageFileSystem");
_LIT(KMsThreadName, "MassStorageThread");
_LIT(KMsDeadThreadName, "MassStorageDeadThread");
_LIT(KMsFsysSemName, "MassStorageSemaphore");
-LOCAL_D const TInt KMsFsyMajorVersionNumber=1;
-LOCAL_D const TInt KMsFsyMinorVersionNumber=0;
+static const TInt KMsFsyMajorVersionNumber=1;
+static const TInt KMsFsyMinorVersionNumber=0;
CMassStorageFileSystem::CMassStorageFileSystem()
- {
- }
+ {
+ }
CMassStorageFileSystem::~CMassStorageFileSystem()
- {
- //Kill the controller thread if it exists
- delete iMassStorageController;
- delete iMediaChanged;
- RThread thread;
- TInt err = thread.Open(KMsThreadName);
- if (err == KErrNone)
- {
- thread.Kill(1); //Parameter is irrelevant
- }
- thread.Close();
- iMsDrives.Close();
- }
+ {
+ //Kill the controller thread if it exists
+ delete iMassStorageController;
+ delete iMediaChanged;
+ RThread thread;
+ TInt err = thread.Open(KMsThreadName);
+ if (err == KErrNone)
+ {
+ thread.Kill(1); //Parameter is irrelevant
+ }
+ thread.Close();
+ iMsDrives.Close();
+ }
CMassStorageFileSystem* CMassStorageFileSystem::NewL()
- {
- CMassStorageFileSystem* self = new (ELeave) CMassStorageFileSystem();
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
-
+ {
+ CMassStorageFileSystem* self = new (ELeave) CMassStorageFileSystem();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
void CMassStorageFileSystem::ConstructL()
- {
- iMediaChanged = new(ELeave) CArrayFixFlat<TBool>(KMaxDrives);
- }
+ {
+ iMediaChanged = new(ELeave) CArrayFixFlat<TBool>(KMaxDrives);
+ }
/**
Set the file system version and name
@@ -74,47 +80,47 @@
@return Any of the standard Symbian error codes.
*/
TInt CMassStorageFileSystem::Install()
- {
- __PRINT(_L("CMassStorageFileSystem::Install In\n"));
- iVersion=TVersion(KMsFsyMajorVersionNumber, KMsFsyMinorVersionNumber, KF32BuildVersionNumber);
- TInt err = SetName(&KMsFsyName);
- __PRINT(_L("CMassStorageFileSystem::Install Out\n"));
- return err;
- }
+ {
+ OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_100);
+ iVersion=TVersion(KMsFsyMajorVersionNumber, KMsFsyMinorVersionNumber, KF32BuildVersionNumber);
+ TInt err = SetName(&KMsFsyName);
+ return err;
+ }
TInt CMassStorageFileSystem::Remove()
- {
- __PRINT(_L("CMassStorageFileSystem::Remove In\n"));
- TInt err = KErrNone;
- if (iInstalled)
- {
- // Try connecting to the server to send a shutdown message.
- // - If the class controller has a session in use, this will return KErrInUse
- RUsbMassStorage usbMs;
- err = usbMs.Connect();
- if(err == KErrNone)
- {
- err = usbMs.Shutdown();
- usbMs.Close();
+ {
+ OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_101);
+ TInt err = KErrNone;
+ if (iInstalled)
+ {
+ // Try connecting to the server to send a shutdown message.
+ // - If the class controller has a session in use, this will return KErrInUse
+ RUsbMassStorage usbMs;
+ err = usbMs.Connect();
+ if(err == KErrNone)
+ {
+ err = usbMs.Shutdown();
+ usbMs.Close();
- if(err == KErrNone)
- {
- User::WaitForRequest(iThreadStat);
- err = iThreadStat.Int();
- }
- else
- {
- __PRINT1(_L("CMassStorageFileSystem::Remove Shutdown Error %d\n"),err);
- }
- }
- else
- {
- __PRINT1(_L("CMassStorageFileSystem::Remove Connect Error %d\n"),err);
- }
- }
- __PRINT(_L("CMassStorageFileSystem::Remove Out\n"));
- return(err);
- }
+ if(err == KErrNone)
+ {
+ User::WaitForRequest(iThreadStat);
+ err = iThreadStat.Int();
+ }
+ else
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_102,
+ "Shutdown Error %d", err);
+ }
+ }
+ else
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_103,
+ "Connect Error %d", err);
+ }
+ }
+ return(err);
+ }
/**
Creates a new Mass Storage mount object.
@@ -123,13 +129,13 @@
@leave KErrNotReady if the Mass Storage controller is not running.
*/
CMountCB* CMassStorageFileSystem::NewMountL() const
- {
- if (!iRunning)
- {
- User::Leave(KErrNotReady);
- }
- return CMassStorageMountCB::NewL(iMsDrives);
- }
+ {
+ if (!iRunning)
+ {
+ User::Leave(KErrNotReady);
+ }
+ return CMassStorageMountCB::NewL(iMsDrives);
+ }
/**
Sets the media attributes and type in the aInfo parameter to those of the specified drive.
@@ -138,20 +144,19 @@
@param aDriveNumber The number of the drive to get the information from.
*/
void CMassStorageFileSystem::DriveInfo(TDriveInfo& aInfo, TInt aDriveNumber) const
- {
- __PRINT(_L("CMassStorageFileSystem::DriveInfo In\n"));
- TLocalDriveCapsV2Buf caps;
- if (!IsValidLocalDriveMapping(aDriveNumber))
- {
- return;
- }
- (void)GetLocalDrive(aDriveNumber).Caps(caps);
+ {
+ OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_104);
+ TLocalDriveCapsV2Buf caps;
+ if (!IsValidLocalDriveMapping(aDriveNumber))
+ {
+ return;
+ }
+ (void)GetLocalDrive(aDriveNumber).Caps(caps);
// error ignored as Caps always returns valid Media and Drive attributes
- aInfo.iMediaAtt=caps().iMediaAtt;
+ aInfo.iMediaAtt=caps().iMediaAtt;
aInfo.iType = ::EMediaNotPresent; // Media is not available to the file system
- aInfo.iDriveAtt=caps().iDriveAtt;
- __PRINT(_L("CMassStorageFileSystem::DriveInfo Out\n"));
- }
+ aInfo.iDriveAtt=caps().iDriveAtt;
+ }
/**
Returns a reference to the Mass Storage controller.
@@ -159,65 +164,66 @@
@return Reference to the Mass Storage controller.
*/
CUsbMassStorageController& CMassStorageFileSystem::Controller()
- {
- return *iMassStorageController;
- }
+ {
+ return *iMassStorageController;
+ }
/**
Fill iMsDrives with a mapping of lun->drive number for supported mass storage drives
*/
TInt CMassStorageFileSystem::EnumerateMsDrivesL()
- {
- __PRINT(_L("CMassStorageFileSystem::EnumerateMsDrives In\n"));
- iMsDrives.Reset();
- TInt driveCount = 0;
+ {
+ OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_105);
+ iMsDrives.Reset();
+ TInt driveCount = 0;
+
+ TLocalDriveCapsV2Buf caps;
+ for (TInt i = EDriveC; i < KMaxDrives; i++)
+ {
+ caps.FillZ();
+
+ if (IsValidLocalDriveMapping(i))
+ {
+ TInt err = GetLocalDrive(i).Caps(caps);
+ TInt locDrvNum = DriveNumberToLocalDriveNumber(i);
+ OstTraceExt2(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_106,
+ "Caps: err=%d, att=%d", err, caps().iDriveAtt);
+
+ TBool isRemovable = err==KErrNotReady || (caps().iDriveAtt & KDriveAttRemovable);
+ OstTraceExt2(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_107,
+ "EnumerateMsDrives: Drive %c: removable %d", 'A'+i-EDriveA, isRemovable);
- TLocalDriveCapsV2Buf caps;
- for (TInt i = EDriveC; i < KMaxDrives; i++)
- {
- caps.FillZ();
-
- if (IsValidLocalDriveMapping(i))
- {
- TInt err = GetLocalDrive(i).Caps(caps);
- TInt locDrvNum = DriveNumberToLocalDriveNumber(i);
- __PRINT2(_L("Caps: err=%d, att=%d\n"), err, caps().iDriveAtt);
-
- TBool isRemovable = err==KErrNotReady || (caps().iDriveAtt & KDriveAttRemovable);
- __PRINT2(_L("EnumerateMsDrives: Drive %c: is %sremovable\n"),
- 'A'+i-EDriveA,
- isRemovable?_S(""):_S("NOT "));
-
- if (isRemovable)
- {
- //
- // STF: Connect to the local drive here. This gives us the media changed flag, and
- // our own TBusLocalDrive object for use by the proxy drive and controller.
- //
- TBool& mediaChanged = (*iMediaChanged).ExtendL();
- mediaChanged = EFalse;
- TBusLocalDrive* localDrive = new(ELeave) TBusLocalDrive;
- iLocalDriveForMediaFlag.Append(*localDrive);
-
- TInt err=iLocalDriveForMediaFlag[driveCount].Connect(locDrvNum, mediaChanged);
- if(err == KErrNone)
- {
- iMsDrives.Append(i);
- }
- driveCount++;
- }
- }
- }
+ if (isRemovable)
+ {
+ //
+ // STF: Connect to the local drive here. This gives us the media changed flag, and
+ // our own TBusLocalDrive object for use by the proxy drive and controller.
+ //
+ TBool& mediaChanged = (*iMediaChanged).ExtendL();
+ mediaChanged = EFalse;
+ TBusLocalDrive* localDrive = new(ELeave) TBusLocalDrive;
+ iLocalDriveForMediaFlag.Append(*localDrive);
- __PRINT1(_L("CMassStorageFileSystem::EnumerateMsDrives Out, %d MS drives found\n"), driveCount);
- return driveCount;
- }
+ TInt err=iLocalDriveForMediaFlag[driveCount].Connect(locDrvNum, mediaChanged);
+ if(err == KErrNone)
+ {
+ iMsDrives.Append(i);
+ }
+ driveCount++;
+ }
+ }
+ }
+
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_108,
+ "%d MS drives found", driveCount);
+ return driveCount;
+ }
TBool CMassStorageFileSystem::IsExtensionSupported() const
- {
- return ETrue;
- }
+ {
+ return ETrue;
+ }
/**
Creates a TrapCleanup and ActiveScheduler and initializes the Mass Storage controller.
@@ -226,103 +232,104 @@
@return Any of the standard Symbian error codes.
*/
TInt CMassStorageFileSystem::InitThread()
- {
- __PRINT(_L("CMassStorageFileSystem::InitThread In\n"));
-
- //Give the thread a name so we can kill it later
- User::RenameThread(KMsThreadName);
-
- CTrapCleanup* cleanup = CTrapCleanup::New();
- if (cleanup == NULL)
- {
- return KErrNoMemory;
- }
+ {
+ OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_109);
+
+ //Give the thread a name so we can kill it later
+ User::RenameThread(KMsThreadName);
- TRAPD(err, InitThreadL());
-
- delete cleanup;
-
- __PRINT1(_L("CMassStorageFileSystem::InitThread Out, error=%d\n"), err);
- return err;
- }
+ CTrapCleanup* cleanup = CTrapCleanup::New();
+ if (cleanup == NULL)
+ {
+ return KErrNoMemory;
+ }
+
+ TRAPD(err, InitThreadL());
+
+ delete cleanup;
+
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_110,
+ "error=%d", err);
+ return err;
+ }
TInt CMassStorageFileSystem::InitThreadL()
- {
- __PRINT(_L("CMassStorageFileSystem::InitThreadL In\n"));
-
- RSemaphore gSemThreadReady;
+ {
+ OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_111);
- TInt ret = gSemThreadReady.OpenGlobal(KMsFsysSemName);
+ RSemaphore gSemThreadReady;
+
+ TInt ret = gSemThreadReady.OpenGlobal(KMsFsysSemName);
- if (ret != KErrNone && ret != KErrAlreadyExists)
- {
- User::Leave(ret);
- }
+ if (ret != KErrNone && ret != KErrAlreadyExists)
+ {
+ User::Leave(ret);
+ }
- // Determine which drives are available for Mass Storage.
- // (this also creates a local TBusLocalDrive for use by the drive controller)
- EnumerateMsDrivesL();
+ // Determine which drives are available for Mass Storage.
+ // (this also creates a local TBusLocalDrive for use by the drive controller)
+ EnumerateMsDrivesL();
- CActiveScheduler* sched = new CActiveScheduler;
- if (sched == NULL)
- {
- gSemThreadReady.Signal();
- User::Leave(KErrNoMemory);
- }
- CleanupStack::PushL(sched);
- CActiveScheduler::Install(sched);
+ CActiveScheduler* sched = new CActiveScheduler;
+ if (sched == NULL)
+ {
+ gSemThreadReady.Signal();
+ User::Leave(KErrNoMemory);
+ }
+ CleanupStack::PushL(sched);
+ CActiveScheduler::Install(sched);
+
+ iMassStorageController = new CUsbMassStorageController;
+ if (iMassStorageController == NULL)
+ {
+ gSemThreadReady.Signal();
+ User::Leave(KErrNoMemory);
+ }
- iMassStorageController = new CUsbMassStorageController;
- if (iMassStorageController == NULL)
- {
- gSemThreadReady.Signal();
- User::Leave(KErrNoMemory);
- }
-
- __PRINT(_L("CMassStorageFileSystem::InitThread: Creating Mass Storage Controller\n"));
- TRAPD(err, iMassStorageController->CreateL(iMsDrives));
- if (err != KErrNone)
- {
- gSemThreadReady.Signal();
- CActiveScheduler::Install(NULL);
- User::Leave(err);
- }
-
- CleanupStack::Pop(sched);
+ OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_112,
+ "Creating Mass Storage Controller");
+ TRAPD(err, iMassStorageController->CreateL(iMsDrives));
+ if (err != KErrNone)
+ {
+ gSemThreadReady.Signal();
+ CActiveScheduler::Install(NULL);
+ User::Leave(err);
+ }
- iRunning = ETrue;
- gSemThreadReady.Signal();
- gSemThreadReady.Close();
- CActiveScheduler::Start();
+ CleanupStack::Pop(sched);
+
+ iRunning = ETrue;
+ gSemThreadReady.Signal();
+ gSemThreadReady.Close();
+ CActiveScheduler::Start();
//========= stop thread ================
- delete iMassStorageController;
- iMassStorageController = NULL;
- TInt i=0;
- for (;i<iLocalDriveForMediaFlag.Count();i++)
- {
- iLocalDriveForMediaFlag[i].Disconnect();
- }
- iLocalDriveForMediaFlag.Reset();
- (*iMediaChanged).Reset();
- delete sched;
- iRunning = EFalse;
-
- __PRINT(_L("CMassStorageFileSystem::InitThread Out\n"));
- return KErrNone;
- }
-
+ OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_113,"thread stopping...");
+ delete iMassStorageController;
+ iMassStorageController = NULL;
+ TInt i=0;
+ for (;i<iLocalDriveForMediaFlag.Count();i++)
+ {
+ iLocalDriveForMediaFlag[i].Disconnect();
+ }
+ iLocalDriveForMediaFlag.Reset();
+ (*iMediaChanged).Reset();
+ delete sched;
+ iRunning = EFalse;
+ OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_114,"thread stopped.");
+ return KErrNone;
+ }
+
/**
Not supported in Mass Storage file system.
@leave KErrNotReady
*/
CFileCB* CMassStorageFileSystem::NewFileL() const
- {
- __PRINT(_L("CMassStorageFileSystem::NewFileL In\n"));
- User::Leave(KErrNotReady);
- return NULL;
- }
+ {
+ User::Leave(KErrNotReady);
+ return NULL;
+ }
/**
Not supported in Mass Storage file system.
@@ -330,10 +337,10 @@
@leave KErrNotReady
*/
CDirCB* CMassStorageFileSystem::NewDirL() const
- {
- User::Leave(KErrNotReady);
- return NULL;
- }
+ {
+ User::Leave(KErrNotReady);
+ return NULL;
+ }
/**
Not supported in Mass Storage file system.
@@ -341,10 +348,10 @@
@leave KErrNotReady
*/
CFormatCB* CMassStorageFileSystem::NewFormatL() const
- {
- User::Leave(KErrNotReady);
- return NULL;
- }
+ {
+ User::Leave(KErrNotReady);
+ return NULL;
+ }
/**
Not supported in Mass Storage file system.
@@ -352,9 +359,9 @@
@return KErrNotSupported
*/
TInt CMassStorageFileSystem::DefaultPath(TDes& /*aPath*/) const
- {
- return KErrNotSupported;
- }
+ {
+ return KErrNotSupported;
+ }
/**
Not supported in Mass Storage file system.
@@ -362,66 +369,67 @@
@return KErrNotSupported
*/
TInt CMassStorageFileSystem::DriveList(TDriveList& /*aList*/) const
- {
- return KErrNotSupported;
- }
+ {
+ return KErrNotSupported;
+ }
/**
Thread entry point.
*/
-LOCAL_C TInt MsInitThreadFn(TAny* aPtr)
- {
- User::SetCritical(User::ESystemCritical);
- ((CMassStorageFileSystem*)aPtr)->InitThread();
- //Rename the thread so we can create a new one with the same original name later
- User::RenameThread(KMsDeadThreadName);
- return KErrNone;
- }
+static TInt MsInitThreadFn(TAny* aPtr)
+ {
+ User::SetCritical(User::ESystemCritical);
+ ((CMassStorageFileSystem*)aPtr)->InitThread();
+ //Rename the thread so we can create a new one with the same original name later
+ User::RenameThread(KMsDeadThreadName);
+ return KErrNone;
+ }
/**
Standard entry point for file systems.
Creates a new file system object and starts a new thread for the Mass Storage controller.
*/
extern "C" EXPORT_C CFileSystem* CreateFileSystem()
- {
- __PRINT(_L("CMassStorageFileSystem::CreateFileSystem In\n"));
- RSemaphore gSemThreadReady;
- TInt err = gSemThreadReady.CreateGlobal(KMsFsysSemName, 0);
- if (err != KErrNone)
- {
- __PRINT1(_L("CMassStorageFileSystem::CreateFileSystem Out Semaphore Error %d\n"),err);
- return NULL;
- }
+ {
+ OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_115);
+ RSemaphore gSemThreadReady;
+ TInt err = gSemThreadReady.CreateGlobal(KMsFsysSemName, 0);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_116,
+ "Semaphore CreateGlobal Error %d", err);
+ return NULL;
+ }
- CFileSystem* msFsys = NULL;
- TRAP(err, msFsys = CMassStorageFileSystem::NewL());
- if (err != KErrNone)
- {
- __PRINT1(_L("CMassStorageFileSystem::CreateFileSystem Out MSFS Error %d\n"),err);
- gSemThreadReady.Close();
- return NULL;
- }
+ CFileSystem* msFsys = NULL;
+ TRAP(err, msFsys = CMassStorageFileSystem::NewL());
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_117,
+ "MSFS Error %d",err);
+ gSemThreadReady.Close();
+ return NULL;
+ }
- RThread msThread;
- __PRINT(_L("CMassStorageFileSystem::CreateFileSystem: Creating Mass Storage thread\n"));
- err = msThread.Create(KMsThreadName, MsInitThreadFn, KDefaultStackSize, NULL, msFsys);
- if (err != KErrNone)
- {
- __PRINT1(_L("CMassStorageFileSystem::CreateFileSystem Out Thread Error %d\n"),err);
- gSemThreadReady.Close();
- return msFsys;
- }
- ((CMassStorageFileSystem*)msFsys)->iInstalled=ETrue;
+ RThread msThread;
+ OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_118,
+ "Creating Mass Storage thread...");
+ err = msThread.Create(KMsThreadName, MsInitThreadFn, KDefaultStackSize, NULL, msFsys);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_119,
+ "Thread Error %d", err);
+ gSemThreadReady.Close();
+ return msFsys;
+ }
+ ((CMassStorageFileSystem*)msFsys)->iInstalled=ETrue;
- msThread.Logon(((CMassStorageFileSystem*)msFsys)->iThreadStat);
- msThread.Resume();
- gSemThreadReady.Wait();
- gSemThreadReady.Close();
- msThread.Close();
-
- __PRINT(_L("CMassStorageFileSystem::CreateFileSystem Out Clean\n"));
-
- return msFsys;
- }
+ msThread.Logon(((CMassStorageFileSystem*)msFsys)->iThreadStat);
+ msThread.Resume();
+ gSemThreadReady.Wait();
+ gSemThreadReady.Close();
+ msThread.Close();
+ return msFsys;
+ }
--- a/userlibandfileserver/fileserver/smassstorage/cmassstoragemountcb.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cmassstoragemountcb.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// CMassStorageMountCB implementation.
-//
+//
//
/**
@@ -22,20 +22,27 @@
#include <f32fsys.h>
#include <f32file.h>
-#include "cmassstoragemountcb.h"
+
+#include "drivemanager.h"
#include "cusbmassstoragecontroller.h"
#include "cmassstoragefilesystem.h"
-#include "massstoragedebug.h"
+#include "cmassstoragemountcb.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cmassstoragemountcbTraces.h"
+#endif
+
CMassStorageMountCB::CMassStorageMountCB(const RArray<TInt>& aDriveMapping)
: iDriveMapping(aDriveMapping)
- {
- }
+ {
+ }
CMassStorageMountCB* CMassStorageMountCB::NewL(const RArray<TInt>& aDriveMapping)
- {
- return new (ELeave) CMassStorageMountCB(aDriveMapping);
- }
+ {
+ return new (ELeave) CMassStorageMountCB(aDriveMapping);
+ }
/**
Checks that the drive number is supported.
@@ -43,18 +50,19 @@
@leave KErrNotReady The drive number is not supported.
*/
TInt CMassStorageMountCB::CheckDriveNumberL()
- {
- __FNLOG("CMassStorageMountCB::CheckDriveNumberL");
- TInt driveNumber;
- driveNumber = Drive().DriveNumber();
- if (!IsValidLocalDriveMapping(driveNumber))
- {
- __PRINT1(_L("CMassStorageMountCB::CheckDriveNumberL: Drive number %d not supported"), driveNumber);
- User::Leave(KErrNotReady);
- }
- __PRINT1(_L("CMassStorageMountCB::CheckDriveNumberL: Drive number = %d"), driveNumber);
- return driveNumber;
- }
+ {
+ TInt driveNumber;
+ driveNumber = Drive().DriveNumber();
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_100,
+ "Drive=%d", driveNumber);
+ if (!IsValidLocalDriveMapping(driveNumber))
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_101,
+ "Drive number not supported");
+ User::Leave(KErrNotReady);
+ }
+ return driveNumber;
+ }
/**
Registers the drive with the Mass Storage drive manager.
@@ -62,57 +70,57 @@
@leave KErrNotSupported The drive is not compatible with Mass Storage.
*/
void CMassStorageMountCB::MountL(TBool /*aForceMount*/)
- {
- __FNLOG("CMassStorageMountCB::MountL");
+ {
+ CheckDriveNumberL();
+ CMassStorageFileSystem& msFsys = *reinterpret_cast<CMassStorageFileSystem*>(Drive().GetFSys());
- CheckDriveNumberL();
- CMassStorageFileSystem& msFsys = *reinterpret_cast<CMassStorageFileSystem*>(Drive().GetFSys());
+ TInt lun = DriveNumberToLun(Drive().DriveNumber());
- TInt lun = DriveNumberToLun(Drive().DriveNumber());
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_120,
+ "LUN=%d", lun);
- if(lun < 0)
- {
- // This is not a supported Mass Storage drive
- User::Leave(KErrNotSupported);
- }
+ if(lun < 0)
+ {
+ // This is not a supported Mass Storage drive
+ User::Leave(KErrNotSupported);
+ }
- TBusLocalDrive& localDrive = msFsys.iLocalDriveForMediaFlag[lun];
+ TBusLocalDrive& localDrive = msFsys.iLocalDriveForMediaFlag[lun];
- TInt err = CreateLocalDrive(localDrive);
- User::LeaveIfError(err);
+ TInt err = CreateLocalDrive(localDrive);
+ User::LeaveIfError(err);
- CProxyDrive* proxyDrive = LocalDrive();
+ CProxyDrive* proxyDrive = LocalDrive();
- TLocalDriveCapsV2Buf caps;
- err = localDrive.Caps(caps);
- //Make sure file system is FAT and removable
- if (err == KErrNone)
- {
- err = KErrNotSupported;
- if ((caps().iDriveAtt & KDriveAttRemovable) == KDriveAttRemovable)
- {
- if (caps().iType != EMediaNotPresent)
- {
- err = KErrNone;
- }
- }
- }
+ TLocalDriveCapsV2Buf caps;
+ err = localDrive.Caps(caps);
+ //Make sure file system is FAT and removable
+ if (err == KErrNone)
+ {
+ err = KErrNotSupported;
+ if ((caps().iDriveAtt & KDriveAttRemovable) == KDriveAttRemovable)
+ {
+ if (caps().iType != EMediaNotPresent)
+ {
+ err = KErrNone;
+ }
+ }
+ }
- if (err != KErrNone && err != KErrNotReady)
- {
- __PRINT1(_L("CMassStorageMountCB::MountL: Drive is not compatible with Mass Storage, err=%d"), err);
- User::Leave(err);
- }
-
- __PRINT(_L("CMassStorageMountCB::MountL: Registering drive"));
+ if (err != KErrNone && err != KErrNotReady)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_121,
+ "Drive is not compatible with Mass Storage err=%d", err);
+ User::Leave(err);
+ }
- // Set media changed to true so that Win2K doesn't used cached drive data
- (*msFsys.iMediaChanged)[lun] = ETrue;
+ // Set media changed to true so that Win2K doesn't used cached drive data
+ (*msFsys.iMediaChanged)[lun] = ETrue;
- msFsys.Controller().DriveManager().RegisterDrive(*proxyDrive, (*msFsys.iMediaChanged)[lun], lun);
+ msFsys.Controller().DriveManager().RegisterDrive(*proxyDrive, (*msFsys.iMediaChanged)[lun], lun);
- SetVolumeName(_L("MassStorage").AllocL());
- }
+ SetVolumeName(_L("MassStorage").AllocL());
+ }
/**
Returns the LUN that corresponds to the specified drive number.
@@ -120,39 +128,39 @@
@param aDriveNumber The drive number.
*/
TInt CMassStorageMountCB::DriveNumberToLun(TInt aDriveNumber)
- {
- __FNLOG("CMassStorageMountCB::DriveNumberToLun");
- TInt lun = -1;
- for (TInt i = 0; i < iDriveMapping.Count(); i++)
- {
- if (iDriveMapping[i] == aDriveNumber)
- {
- lun = i;
- break;
- }
- }
- __PRINT2(_L("CMassStorageMountCB::DriveNumberToLun: Drive %d maps to LUN %d"), aDriveNumber, lun);
- return lun;
- }
+ {
+ TInt lun = -1;
+ for (TInt i = 0; i < iDriveMapping.Count(); i++)
+ {
+ if (iDriveMapping[i] == aDriveNumber)
+ {
+ lun = i;
+ break;
+ }
+ }
+ OstTraceExt2(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_130,
+ "Drive %d maps to LUN %d", aDriveNumber, lun);
+ return lun;
+ }
/**
Deregisters the drive from the Drive Manager.
*/
void CMassStorageMountCB::Dismounted()
- {
- __FNLOG("CMassStorageMountCB::Dismounted");
- TInt driveNumber = -1;
- TRAPD(err, driveNumber = CheckDriveNumberL());
- if (err != KErrNone)
- {
- return;
- }
- __PRINT(_L("CMassStorageMountCB::Dismounted: Deregistering drive"));
+ {
+ TInt driveNumber = -1;
+ TRAPD(err, driveNumber = CheckDriveNumberL());
+ if (err != KErrNone)
+ {
+ return;
+ }
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_140,
+ "Dismounted drive %d", driveNumber);
CMassStorageFileSystem& msFsys = *reinterpret_cast<CMassStorageFileSystem*>(Drive().GetFSys());
- msFsys.Controller().DriveManager().DeregisterDrive(DriveNumberToLun(driveNumber));
-
- DismountedLocalDrive();
- }
+ msFsys.Controller().DriveManager().DeregisterDrive(DriveNumberToLun(driveNumber));
+
+ DismountedLocalDrive();
+ }
/**
Unlocks the drive with the specified password, optionally storing the password for later use.
@@ -161,158 +169,160 @@
@param aStore True if the password is to be stored.
*/
TInt CMassStorageMountCB::Unlock(TMediaPassword& aPassword, TBool aStore)
- {
- __FNLOG("CMassStorageMountCB::Unlock");
- TInt driveNumber = -1;
- TRAPD(err, driveNumber = CheckDriveNumberL());
- if (err != KErrNone)
- {
- return err;
- }
- TBusLocalDrive& localDrive=GetLocalDrive(driveNumber);
- if(localDrive.Status() == KErrLocked)
- {
- localDrive.Status() = KErrNotReady;
- }
- TInt r = localDrive.Unlock(aPassword, aStore);
- if(r == KErrNone && aStore)
- {
- WritePasswordData();
- }
- return(r);
- }
+ {
+ TInt driveNumber = -1;
+ TRAPD(err, driveNumber = CheckDriveNumberL());
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_150,
+ "Unlock drive %d", driveNumber);
+ if (err != KErrNone)
+ {
+ return err;
+ }
+ TBusLocalDrive& localDrive=GetLocalDrive(driveNumber);
+ if(localDrive.Status() == KErrLocked)
+ {
+ localDrive.Status() = KErrNotReady;
+ }
+ TInt r = localDrive.Unlock(aPassword, aStore);
+ if(r == KErrNone && aStore)
+ {
+ WritePasswordData();
+ }
+ return(r);
+ }
/**
Stores the password for the drive to the password file.
*/
void CMassStorageMountCB::WritePasswordData()
- {
- __FNLOG("CMassStorageMountCB::WritePasswordData");
- TBusLocalDrive& local=GetLocalDrive(Drive().DriveNumber());
- TInt length = local.PasswordStoreLengthInBytes();
- if(length==0)
- {
- TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
- mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
- WriteToDisk(mediaPWrdFile,_L8(""));
- return;
- }
- HBufC8* hDes=HBufC8::New(length);
- if(hDes==NULL)
- {
- return;
- }
- TPtr8 pDes=hDes->Des();
- TInt r=local.ReadPasswordData(pDes);
- if(r==KErrNone)
- {
- TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
- mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
- WriteToDisk(mediaPWrdFile,pDes);
- }
- delete hDes;
- }
+ {
+ TBusLocalDrive& local=GetLocalDrive(Drive().DriveNumber());
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEMOUNTCB_160,
+ "WritePasswordData drive %d", DriveNumber());
+ TInt length = local.PasswordStoreLengthInBytes();
+ if(length==0)
+ {
+ TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
+ mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
+ WriteToDisk(mediaPWrdFile,_L8(""));
+ return;
+ }
+ HBufC8* hDes=HBufC8::New(length);
+ if(hDes==NULL)
+ {
+ return;
+ }
+ TPtr8 pDes=hDes->Des();
+ TInt r=local.ReadPasswordData(pDes);
+ if(r==KErrNone)
+ {
+ TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
+ mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
+ WriteToDisk(mediaPWrdFile,pDes);
+ }
+ delete hDes;
+ }
TInt CMassStorageMountCB::ReMount()
- {
- return KErrNotReady;
- }
+ {
+ return KErrNotReady;
+ }
void CMassStorageMountCB::VolumeL(TVolumeInfo& /*aVolume*/) const
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::SetVolumeL(TDes& /*aName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::MkDirL(const TDesC& /*aName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::RmDirL(const TDesC& /*aName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::DeleteL(const TDesC& /*aName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::RenameL(const TDesC& /*anOldName*/,const TDesC& /*anNewName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::ReplaceL(const TDesC& /*anOldName*/,const TDesC& /*anNewName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::SetEntryL(const TDesC& /*aName*/,const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::FileOpenL(const TDesC& /*aName*/,TUint /*aMode*/,TFileOpen /*anOpen*/,CFileCB* /*aFile*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::DirOpenL(const TDesC& /*aName*/,CDirCB* /*aDir*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::RawReadL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aTrg*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/) const
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::RawWriteL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aSrc*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::GetShortNameL(const TDesC& /*aLongName*/,TDes& /*aShortName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
void CMassStorageMountCB::GetLongNameL(const TDesC& /*aShorName*/,TDes& /*aLongName*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
#if defined(_DEBUG)
TInt CMassStorageMountCB::ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2)
//
// Debug function
//
- {
- if(aCommand>=(KMaxTInt/2))
- return LocalDrive()->ControlIO(aMessage,aCommand-(KMaxTInt/2),aParam1,aParam2);
- else
- return KErrNotSupported;
- }
+ {
+ if(aCommand>=(KMaxTInt/2))
+ return LocalDrive()->ControlIO(aMessage,aCommand-(KMaxTInt/2),aParam1,aParam2);
+ else
+ return KErrNotSupported;
+ }
#else
TInt CMassStorageMountCB::ControlIO(const RMessagePtr2& /*aMessage*/,TInt /*aCommand*/,TAny* /*aParam1*/,TAny* /*aParam2*/)
- {return(KErrNotSupported);}
+ {return(KErrNotSupported);}
#endif
void CMassStorageMountCB::ReadSectionL(const TDesC& /*aName*/,TInt /*aPos*/,TAny* /*aTrg*/,TInt /*aLength*/,const RMessagePtr2& /*aMessage*/)
- {
- User::Leave(KErrNotReady);
- }
+ {
+ User::Leave(KErrNotReady);
+ }
--- a/userlibandfileserver/fileserver/smassstorage/cusbmassstoragecontroller.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cusbmassstoragecontroller.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// CUsbMassStorageController implementation.
-//
+//
//
/**
@@ -20,21 +20,31 @@
@internalTechnology
*/
+#include <e32std.h>
+#include "mtransport.h"
+#include "mprotocol.h"
+
+#include "scsiprot.h"
+#include "cusbmassstorageserver.h"
+#include "drivemanager.h"
#include "cusbmassstoragecontroller.h"
-#include "massstoragedebug.h"
-#include "scsiprot.h"
#include "cbulkonlytransport.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cusbmassstoragecontrollerTraces.h"
+#endif
+
/**
Destructor
*/
CUsbMassStorageController::~CUsbMassStorageController()
- {
- delete iServer;
- delete iProtocol;
- delete iTransport;
- delete iDriveManager;
- }
+ {
+ delete iServer;
+ delete iProtocol;
+ delete iTransport;
+ delete iDriveManager;
+ }
/**
Creates the drive manager, transport, protocol and server
@@ -42,32 +52,31 @@
@param aMaxDrives Maximum number of Mass Storage drives supported.
*/
void CUsbMassStorageController::CreateL(RArray<TInt>& aDriveMapping)
- {
- __PRINT(_L("CUsbMassStorageController::CreateL In"));
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGECONTROLLER_100);
#if !defined(__WINS__) && !defined(__X86__)
- iTransportLddFlag = EUsbcsc; // Create transport object using SC Ldd By default
+ iTransportLddFlag = EUsbcsc; // Create transport object using SC Ldd By default
#else
- iTransportLddFlag = EUsbc;
+ iTransportLddFlag = EUsbc;
#endif
- //Save this value for use in the Reset method.
- iMaxDrives = aDriveMapping.Count();
- //Create and init drive manager
- iDriveManager = CDriveManager::NewL(aDriveMapping);
+ //Save this value for use in the Reset method.
+ iMaxDrives = aDriveMapping.Count();
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGECONTROLLER_101,
+ "MaxDrives = %d", iMaxDrives);
+ //Create and init drive manager
+ iDriveManager = CDriveManager::NewL(aDriveMapping);
- //Create transport and protocol and initialize them
- __PRINT(_L("CUsbMassStorageController::CreateL: Creating transport and protocol"));
- iTransport = CBulkOnlyTransport::NewL(iMaxDrives, *this, iTransportLddFlag);
- if (!iTransport)
- User::Leave(KErrNoMemory);
+ //Create transport and protocol and initialize them
+ iTransport = CBulkOnlyTransport::NewL(iMaxDrives, *this, iTransportLddFlag);
+ if (!iTransport)
+ User::Leave(KErrNoMemory);
- iProtocol = CScsiProtocol::NewL(*iDriveManager);
+ iProtocol = CScsiProtocol::NewL(*iDriveManager);
- //Create and start server
- __PRINT(_L("CUsbMassStorageController::CreateL: Creating server"));
- iServer = CUsbMassStorageServer::NewLC(*this);
- CleanupStack::Pop(iServer);
- __PRINT(_L("CUsbMassStorageController::CreateL Out"));
- }
+ //Create and start server
+ iServer = CUsbMassStorageServer::NewLC(*this);
+ CleanupStack::Pop(iServer);
+ }
/**
Returns a reference to the drive manager
@@ -75,15 +84,15 @@
@return A reference to the drive manager
*/
CDriveManager& CUsbMassStorageController::DriveManager()
- {
- return *iDriveManager;
- }
+ {
+ return *iDriveManager;
+ }
void CUsbMassStorageController::GetTransport(MTransportBase* &aTransport)
- {
- aTransport = iTransport;
- }
+ {
+ aTransport = iTransport;
+ }
/**
Starts the transport and initializes the protocol.
@@ -91,78 +100,69 @@
@param aConfig Reference to Mass Storage configuration data
*/
TInt CUsbMassStorageController::Start(TMassStorageConfig& aConfig)
- {
- __PRINT(_L("CUsbMassStorageController::Start In"));
- //Save this value for use in the Reset method.
- iConfig = aConfig;
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGECONTROLLER_200);
+ //Save this value for use in the Reset method.
+ iConfig = aConfig;
__ASSERT_DEBUG(iTransport, User::Invariant());
- if ((iTransport->InitialiseTransportL((TInt) iTransportLddFlag)) != KErrNone)
- {
- iTransportLddFlag = EUsbc; // If SC Ldd not present use the default USB Client Ldd
- delete iTransport;
- iTransport = CBulkOnlyTransport::NewL(iMaxDrives, *this, iTransportLddFlag);
- if (!iTransport)
- User::Leave(KErrNoMemory);
- if ((iTransport->InitialiseTransportL((TInt) iTransportLddFlag)) != KErrNone)
- return KErrNotFound;
- }
-
- TInt err = KErrNotReady;
+ if ((iTransport->InitialiseTransportL((TInt) iTransportLddFlag)) != KErrNone)
+ {
+ iTransportLddFlag = EUsbc; // If SC Ldd not present use the default USB Client Ldd
+ delete iTransport;
+ iTransport = CBulkOnlyTransport::NewL(iMaxDrives, *this, iTransportLddFlag);
+ if (!iTransport)
+ User::Leave(KErrNoMemory);
+ if ((iTransport->InitialiseTransportL((TInt) iTransportLddFlag)) != KErrNone)
+ return KErrNotFound;
+ }
- if (iProtocol && iTransport)
- {
- iTransport->RegisterProtocol(*iProtocol);
- iProtocol->RegisterTransport(iTransport);
- __PRINT(_L("CUsbMassStorageController::Start: Starting"));
- ((CScsiProtocol*)iProtocol)->SetScsiParameters(aConfig);
- err = iTransport->Start();
- }
+ TInt err = KErrNotReady;
- __PRINT(_L("CUsbMassStorageController::Start Out"));
+ if (iProtocol && iTransport)
+ {
+ iTransport->RegisterProtocol(*iProtocol);
+ iProtocol->RegisterTransport(iTransport);
+ ((CScsiProtocol*)iProtocol)->SetScsiParameters(aConfig);
+ err = iTransport->Start();
+ }
- return err;
- }
+ return err;
+ }
/**
Stops the transport.
*/
TInt CUsbMassStorageController::Stop()
- {
-
- __PRINT(_L("CUsbMassStorageController::Stop In"));
- TInt err = KErrNotReady;
- if (iTransport)
- {
- __PRINT(_L("CUsbMassStorageController::Stop: Stopping"));
- err = iTransport->Stop();
- }
- TInt i=0;
- for (i=0; i<=iMaxDrives; ++i)
- {
- iDriveManager->SetCritical(i, EFalse); //unset critical
- }
- __PRINT(_L("CUsbMassStorageController::Stop Out"));
-
- return err;
- }
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGECONTROLLER_110);
+ TInt err = KErrNotReady;
+ if (iTransport)
+ {
+ err = iTransport->Stop();
+ }
+ TInt i=0;
+ for (i=0; i<=iMaxDrives; ++i)
+ {
+ iDriveManager->SetCritical(i, EFalse); //unset critical
+ }
+ return err;
+ }
/**
Delete the transport and protocol and start new ones.
*/
void CUsbMassStorageController::Reset()
- {
-
- delete iProtocol;
- iProtocol = NULL;
-
- //Create transport and protocol and initialize them
- __PRINT(_L("CUsbMassStorageController::Reset: Creating protocol"));
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGECONTROLLER_120);
+ delete iProtocol;
+ iProtocol = NULL;
- TRAPD(err,iProtocol = CScsiProtocol::NewL(*iDriveManager));
- err = err;
- __ASSERT_DEBUG(err==KErrNone, User::Invariant());
- iTransport->RegisterProtocol(*iProtocol);
- iProtocol->RegisterTransport(iTransport);
- }
+ //Create transport and protocol and initialize them
+ TRAPD(err,iProtocol = CScsiProtocol::NewL(*iDriveManager));
+ err = err;
+ __ASSERT_DEBUG(err==KErrNone, User::Invariant());
+ iTransport->RegisterProtocol(*iProtocol);
+ iProtocol->RegisterTransport(iTransport);
+ }
--- a/userlibandfileserver/fileserver/smassstorage/cusbmassstorageserver.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cusbmassstorageserver.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// Implements a Symbian OS server that exposes the RUsbMassStorage API
-//
+//
//
/**
@@ -24,30 +24,36 @@
#include "usbmsshared.h"
#include "cusbmassstorageserver.h"
#include "cusbmassstoragesession.h"
+#include "drivemanager.h"
#include "cusbmassstoragecontroller.h"
-#include "massstoragedebug.h"
+#include "smassstorage.h"
+#include "usbmsserversecuritypolicy.h"
-#include "usbmsserversecuritypolicy.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cusbmassstorageserverTraces.h"
+#endif
+
/**
Constructs a USB mass storage Server
-
+
@return a pointer to CUsbMassStorageServer object
*/
CUsbMassStorageServer* CUsbMassStorageServer::NewLC(CUsbMassStorageController& aController)
- {
- CUsbMassStorageServer* r = new (ELeave) CUsbMassStorageServer(aController);
- CleanupStack::PushL(r);
- r->StartL(KUsbMsServerName);
- return r;
- }
+ {
+ CUsbMassStorageServer* r = new (ELeave) CUsbMassStorageServer(aController);
+ CleanupStack::PushL(r);
+ r->StartL(KUsbMsServerName);
+ return r;
+ }
/**
Destructor
*/
CUsbMassStorageServer::~CUsbMassStorageServer()
- {
+ {
// Intentionally left blank
- }
+ }
/**
@@ -56,73 +62,67 @@
@param aController a USB mass storage controller reference
*/
CUsbMassStorageServer::CUsbMassStorageServer(CUsbMassStorageController& aController)
- : CPolicyServer(EPriorityHigh,KUsbMsServerPolicy)
+ : CPolicyServer(EPriorityHigh,KUsbMsServerPolicy)
, iController(aController)
- {
- __PRINT(_L("CUsbMassStorageServer::CUsbMassStorageServer\n"));
- }
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGESERVER_100);
+ }
/**
Create a new session on this server
-
- @param &aVersion Version of client
- @return A pointer to a session object to be used for the client
+
+ @param &aVersion Version of client
+ @return A pointer to a session object to be used for the client
*/
CSession2* CUsbMassStorageServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
- {
- TVersion v(KUsbMsSrvMajorVersionNumber,KUsbMsSrvMinorVersionNumber,KUsbMsSrvBuildVersionNumber);
-
- __PRINT(_L("CUsbMassStorageServer::NewSessionL\n"));
- if (!User::QueryVersionSupported(v, aVersion))
- User::Leave(KErrNotSupported);
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGESERVER_110);
+ TVersion v(KUsbMsSrvMajorVersionNumber,KUsbMsSrvMinorVersionNumber,KUsbMsSrvBuildVersionNumber);
+ if (!User::QueryVersionSupported(v, aVersion))
+ User::Leave(KErrNotSupported);
- CUsbMassStorageServer* ncThis = const_cast<CUsbMassStorageServer*>(this);
-
- CUsbMassStorageSession* sess = CUsbMassStorageSession::NewL(*ncThis);
-
- return sess;
- }
+ CUsbMassStorageServer* ncThis = const_cast<CUsbMassStorageServer*>(this);
+ CUsbMassStorageSession* sess = CUsbMassStorageSession::NewL(*ncThis);
+ return sess;
+ }
/**
Inform the client there has been an error.
-
- @param aError The error that has occurred
+
+ @param aError The error that has occurred
*/
void CUsbMassStorageServer::Error(TInt aError)
- {
- __PRINT1(_L("CUsbMassStorageServer::Error [aError=%d]\n"), aError);
-
- Message().Complete(aError);
- ReStart();
- }
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESERVER_120,
+ "aError=%d", aError);
+ Message().Complete(aError);
+ ReStart();
+ }
/**
Increment the open session count (iSessionCount) by one.
-
- @post the number of open sessions is incremented by one
+
+ @post the number of open sessions is incremented by one
*/
void CUsbMassStorageServer::IncrementSessionCount()
- {
- __PRINT1(_L("CUsbMassStorageServer::IncrementSessionCount %d\n"), iSessionCount);
- __ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
-
- ++iSessionCount;
-
- __PRINT(_L("CUsbMassStorageServer::IncrementSessionCount\n"));
- }
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESERVER_130,
+ "SessionCount=%d", iSessionCount);
+ __ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
+ ++iSessionCount;
+ }
/**
Decrement the open session count (iSessionCount) by one.
-
- @post the number of open sessions is decremented by one
+
+ @post the number of open sessions is decremented by one
*/
void CUsbMassStorageServer::DecrementSessionCount()
- {
- __PRINT1(_L("CUsbMassStorageServer::DecrementSessionCount %d\n"), iSessionCount);
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESERVER_140,
+ "SessionCount=%d", iSessionCount);
+ __ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
+ --iSessionCount;
+ }
- __ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
-
- --iSessionCount;
- }
-
--- a/userlibandfileserver/fileserver/smassstorage/cusbmassstoragesession.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/cusbmassstoragesession.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -12,7 +12,7 @@
//
// Description:
// Implements a Session of a Symbian OS server for the RUsbMassStorage API
-//
+//
//
/**
@@ -20,152 +20,163 @@
@internalTechnology
*/
-#include "cusbmassstoragesession.h"
+#include <e32std.h>
+#include <e32base.h>
+#include "usbmsshared.h"
+
+#include "drivemanager.h"
#include "cusbmassstoragecontroller.h"
#include "cusbmassstorageserver.h"
-#include "usbmsshared.h"
+#include "cusbmassstoragesession.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cusbmassstoragesessionTraces.h"
+#endif
+
/**
Construct a Symbian OS session object.
-
- @param aServer Service the session will be a member of
- @param aMessage The message from the client.
- @return A new CUsbMassStorageSession object
+
+ @param aServer Service the session will be a member of
+ @param aMessage The message from the client.
+ @return A new CUsbMassStorageSession object
*/
CUsbMassStorageSession* CUsbMassStorageSession::NewL(CUsbMassStorageServer& aServer)
- {
- CUsbMassStorageSession* r = new (ELeave) CUsbMassStorageSession(aServer);
- CleanupStack::PushL(r);
- r->ConstructL();
- CleanupStack::Pop();
- return r;
- }
+ {
+ CUsbMassStorageSession* r = new (ELeave) CUsbMassStorageSession(aServer);
+ CleanupStack::PushL(r);
+ r->ConstructL();
+ CleanupStack::Pop();
+ return r;
+ }
/**
Constructor.
-
- @param aServer Service the session will be a member of
+
+ @param aServer Service the session will be a member of
*/
CUsbMassStorageSession::CUsbMassStorageSession(CUsbMassStorageServer& aServer)
- : iUsbMsServer(aServer)
- {
- __PRINT(_L("CUsbMassStorageSession::CUsbMassStorageSession\n"));
- }
+ : iUsbMsServer(aServer)
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_100);
+ }
/**
2nd Phase Construction.
*/
void CUsbMassStorageSession::ConstructL()
- {
- iUsbMsServer.IncrementSessionCount();
+ {
+ iUsbMsServer.IncrementSessionCount();
if (iUsbMsServer.SessionCount() > 1)
{
- __PRINT1(_L("\tiSessionCount: %d\n"), iUsbMsServer.SessionCount());
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESESSION_101,
+ "iSessionCount: %d", iUsbMsServer.SessionCount());
// Only one session is allowed
User::Leave(KErrInUse);
- }
- }
+ }
+ }
/**
Destructor.
*/
CUsbMassStorageSession::~CUsbMassStorageSession()
- {
- iUsbMsServer.DecrementSessionCount();
- }
+ {
+ iUsbMsServer.DecrementSessionCount();
+ }
/**
Called when a message is received from the client.
-
- @param aMessage Message received from the client
+
+ @param aMessage Message received from the client
*/
void CUsbMassStorageSession::ServiceL(const RMessage2& aMessage)
- {
- DispatchMessageL(aMessage);
- }
+ {
+ DispatchMessageL(aMessage);
+ }
/**
Handles the request (in the form of a the message) received from the client
-
+
@internalTechnology
- @param aMessage The received message
+ @param aMessage The received message
*/
void CUsbMassStorageSession::DispatchMessageL(const RMessage2& aMessage)
- {
- TInt ret = KErrNone;
-
- switch (aMessage.Function())
- {
- case EUsbMsStart:
- ret = Start(aMessage);
- break;
- case EUsbMsStop:
- ret = Stop();
- break;
- case EUsbMsShutdown:
- ret = Shutdown();
- break;
+ {
+ TInt ret = KErrNone;
- default:
- aMessage.Panic(KUsbMsCliPncCat, EUsbMsPanicIllegalIPC);
- break;
- }
+ switch (aMessage.Function())
+ {
+ case EUsbMsStart:
+ ret = Start(aMessage);
+ break;
+ case EUsbMsStop:
+ ret = Stop();
+ break;
+ case EUsbMsShutdown:
+ ret = Shutdown();
+ break;
- aMessage.Complete(ret);
- }
+ default:
+ aMessage.Panic(KUsbMsCliPncCat, EUsbMsPanicIllegalIPC);
+ break;
+ }
+
+ aMessage.Complete(ret);
+ }
/**
Client request to start the device.
-
- @return Any error that occurred or KErrNone
+
+ @return Any error that occurred or KErrNone
*/
TInt CUsbMassStorageSession::Start(const RMessage2& aMessage)
- {
- __PRINT(_L("CUsbMassStorageSession::Start\n"));
+ {
+ OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_103);
+ TMassStorageConfig msConfig;
+ TRAPD(err, GetMsConfigL(aMessage, msConfig));
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_FS, CUSBMASSSTORAGESESSION_111,
+ "Failed to get mass storage configuration data err=%d", err);
+ return err;
+ }
- TMassStorageConfig msConfig;
- TRAPD(err, GetMsConfigL(aMessage, msConfig));
- if (err != KErrNone)
- {
- __PRINT(_L("Failed to get mass storage configuration data\n"));
- return err;
- }
-
- return iUsbMsServer.Controller().Start(msConfig);
- }
+ return iUsbMsServer.Controller().Start(msConfig);
+ }
/**
Client request to stop the device.
-
- @return Any error that occurred or KErrNone
+
+ @return Any error that occurred or KErrNone
*/
TInt CUsbMassStorageSession::Stop()
{
- __PRINT(_L("CUsbMassStorageSession::Stop\n"));
+ OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_104);
TInt err = iUsbMsServer.Controller().Stop();
- return err;
- }
+ return err;
+ }
/**
Client request to shut down the server
-
+
@return KErrNone
*/
TInt CUsbMassStorageSession::Shutdown()
{
- __PRINT(_L("CUsbMassStorageSession::Shutdown\n"));
+ OstTraceFunctionEntry0(CUSBMASSSTORAGESESSION_105);
CActiveScheduler::Stop();
- return KErrNone;
- }
+ return KErrNone;
+ }
/**
Get mass storage configuration data from the received message
*/
void CUsbMassStorageSession::GetMsConfigL(const RMessage2& aMessage, TMassStorageConfig& aMsStorage)
- {
- aMessage.ReadL(0,aMsStorage.iVendorId);
- aMessage.ReadL(1,aMsStorage.iProductId);
- aMessage.ReadL(2,aMsStorage.iProductRev);
- }
+ {
+ aMessage.ReadL(0,aMsStorage.iVendorId);
+ aMessage.ReadL(1,aMsStorage.iProductId);
+ aMessage.ReadL(2,aMsStorage.iProductRev);
+ }
--- a/userlibandfileserver/fileserver/smassstorage/drivemanager.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/drivemanager.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// Class implementation of CDriveManager and CMassStorageDrive.
-//
+//
//
/**
@@ -20,187 +20,195 @@
@internalTechnology
*/
+#include <e32std.h>
+#include <e32base.h> // C Class Definitions, Cleanup Stack
+#include <e32def.h> // T Type Definitions
#include <f32fsys.h>
-#include "massstoragedebug.h"
-#include "usbmsshared.h"
+#include <e32property.h>
+#include "usbmsshared.h" // KUsbMsMaxDrives
+
+
#include "drivemanager.h"
+#include "smassstorage.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "drivemanagerTraces.h"
+#endif
+
+
///////////////////////////////////////////////////////////////////////////////
/**
-A private structure that, when Connected, holds references to
+A private structure that, when Connected, holds references to
the CProxyDrive and the corresponding TBusLocalDrive's Media Changed flag.
*/
struct CMassStorageDrive::CLocalDriveRef : public CBase
- {
- CLocalDriveRef(CProxyDrive& aProxyDrive, TBool& aMediaChanged)
- : iProxyDrive(aProxyDrive), iMediaChanged(aMediaChanged), iDriveState(EIdle)
- {
- }
- CProxyDrive& iProxyDrive;
- TBool& iMediaChanged;
- /**
- The Drive Media state machine
- */
- TDriveState iDriveState;
- };
+ {
+ CLocalDriveRef(CProxyDrive& aProxyDrive, TBool& aMediaChanged)
+ : iProxyDrive(aProxyDrive), iMediaChanged(aMediaChanged), iDriveState(EIdle)
+ {
+ }
+ CProxyDrive& iProxyDrive;
+ TBool& iMediaChanged;
+ /**
+ The Drive Media state machine
+ */
+ TDriveState iDriveState;
+ };
/**
@param aCritSec A Critical Section object shared by all drives.
-@param aDrives Reference to the list of CMassStorageDrive objects.
-@param aDriveMap Reference to array mapping lun to drive number for supported
- mass storage drives.
+@param aDrives Reference to the list of CMassStorageDrive objects.
+@param aDriveMap Reference to array mapping lun to drive number for supported
+ mass storage drives.
@post Object is fully constructed
*/
-CMassStorageDrive::CMassStorageDrive(RCriticalSection& aCritSec,
- RDriveStateChangedPublisher& aDriveStateChangedPublisher)
- :
- iCritSec(aCritSec),
- iMountState(EDisconnected),
- iDriveStateChangedPublisher(aDriveStateChangedPublisher)
- {
- __FNLOG("CMassStorageDrive::CMassStorageDrive");
-
- }
+CMassStorageDrive::CMassStorageDrive(RCriticalSection& aCritSec,
+ RDriveStateChangedPublisher& aDriveStateChangedPublisher)
+ :
+ iCritSec(aCritSec),
+ iMountState(EDisconnected),
+ iDriveStateChangedPublisher(aDriveStateChangedPublisher)
+ {
+ }
CMassStorageDrive::~CMassStorageDrive()
- {
- delete iLocalDrive;
- }
+ {
+ delete iLocalDrive;
+ }
/**
Read from the target drive unit.
@return KErrNone on success, otherwise system wide error code
*/
TInt CMassStorageDrive::Read(const TInt64& aPos, TInt aLength, TDes8& aBuf, TBool aWholeMedia)
- {
- __FNLOG("CMassStorageDrive::Read");
+ {
+ TInt err = KErrUnknown; // never return this
+ iCritSec.Wait();
- TInt err = KErrUnknown; // never return this
- iCritSec.Wait();
+ if(iMountState != EConnected)
+ {
+ err = KErrDisconnected;
+ }
+ else
+ {
+ if(aWholeMedia)
+ {
+ err = SafeProxyDrive().Read(aPos, aLength, &aBuf, KLocalMessageHandle, 0, RLocalDrive::ELocDrvWholeMedia);
+ }
+ else
+ {
+ err = SafeProxyDrive().Read(aPos, aLength, aBuf);
+ }
- if(iMountState != EConnected)
- {
- err = KErrDisconnected;
- }
- else
- {
- if(aWholeMedia)
- {
- err = SafeProxyDrive().Read(aPos, aLength, &aBuf, KLocalMessageHandle, 0, RLocalDrive::ELocDrvWholeMedia);
- }
- else
- {
- err = SafeProxyDrive().Read(aPos, aLength, aBuf);
- }
+ if(err == KErrNone)
+ {
+#ifndef USB_TRANSFER_PUBLISHER
+ iBytesRead += aBuf.Length();
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_100,
+ "iBytesRead=%d", iBytesRead);
+#endif
+ }
- if(err == KErrNone)
- {
-#ifndef USB_TRANSFER_PUBLISHER
- iBytesRead += aBuf.Length();
- __PRINT1(_L("iBytesRead=%d\n"),iBytesRead);
-#endif
- }
+ else if(err == KErrLocked)
+ {
+ SetDriveState(ELocked);
+ }
+ }
- else if(err == KErrLocked)
- {
- SetDriveState(ELocked);
- }
- }
-
- iCritSec.Signal();
- return err;
- }
+ iCritSec.Signal();
+ return err;
+ }
/**
Write to the target drive unit.
@return KErrNone on success, otherwise system wide error code
*/
TInt CMassStorageDrive::Write(const TInt64& aPos, TDesC8& aBuf, TBool aWholeMedia)
- {
- __FNLOG("CMassStorageDrive::Write");
-
- TInt err = KErrNone;
- iCritSec.Wait();
+ {
+ TInt err = KErrNone;
+ iCritSec.Wait();
- if (iMountState != EConnected)
- {
- err = KErrDisconnected;
- }
- else
- {
- __ASSERT_DEBUG(iLocalDrive, User::Invariant());
- TDriveState oldState = iLocalDrive->iDriveState;
- if(oldState != EActive)
- {
- // SCSI hasn't called SetCritical
- SetDriveState(EActive);
- }
+ if (iMountState != EConnected)
+ {
+ err = KErrDisconnected;
+ }
+ else
+ {
+ __ASSERT_DEBUG(iLocalDrive, User::Panic(KUsbMsSvrPncCat, EMsCMassStorageDriveWrite));
+ TDriveState oldState = iLocalDrive->iDriveState;
+ if(oldState != EActive)
+ {
+ // SCSI hasn't called SetCritical
+ SetDriveState(EActive);
+ }
- if (aWholeMedia)
- {
- err = SafeProxyDrive().Write(aPos, aBuf.Length(), &aBuf, KLocalMessageHandle, 0, RLocalDrive::ELocDrvWholeMedia);
- }
- else
- {
- err = SafeProxyDrive().Write(aPos,aBuf);
- }
+ if (aWholeMedia)
+ {
+ err = SafeProxyDrive().Write(aPos, aBuf.Length(), &aBuf, KLocalMessageHandle, 0, RLocalDrive::ELocDrvWholeMedia);
+ }
+ else
+ {
+ err = SafeProxyDrive().Write(aPos,aBuf);
+ }
- if (err == KErrNone)
- {
+ if (err == KErrNone)
+ {
#ifndef USB_TRANSFER_PUBLISHER
- iBytesWritten += aBuf.Length();
+ iBytesWritten += aBuf.Length();
#endif
- }
+ }
- if (err == KErrLocked)
- {
- SetDriveState(ELocked);
- }
- else if (oldState != EActive)
- {
- SetDriveState(oldState);
- }
- }
+ if (err == KErrLocked)
+ {
+ SetDriveState(ELocked);
+ }
+ else if (oldState != EActive)
+ {
+ SetDriveState(oldState);
+ }
+ }
- iCritSec.Signal();
- return err;
- }
+ iCritSec.Signal();
+ return err;
+ }
/**
Get the capabilities of the target drive unit.
@return KErrNone on success, otherwise system wide error code
*/
TInt CMassStorageDrive::Caps(TLocalDriveCapsV4& aInfo)
- {
- __FNLOG("CMassStorageDrive::Caps");
+ {
+ TInt err = KErrNone;
+ iCritSec.Wait();
+
+ if(iMountState != EConnected)
+ {
+ err = KErrDisconnected;
+ }
+ else
+ {
+ // Initialise in case Caps() fails
+ aInfo.iType = ::EMediaUnknown;
+ err = DoCaps(aInfo);
- TInt err = KErrNone;
- iCritSec.Wait();
-
- if(iMountState != EConnected)
- {
- err = KErrDisconnected;
- }
- else
- {
- // Initialise in case Caps() fails
- aInfo.iType = ::EMediaUnknown;
- err = DoCaps(aInfo);
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_110,
+ "err=%d", err);
- __PRINTERR(_L("CheckDriveState: DoCaps err=%d\n"), err);
+ if(err == KErrNotReady || (err==KErrNone && aInfo.iType == ::EMediaNotPresent))
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_111,
+ "detected MediaNotPresent");
+ SetDriveState(CMassStorageDrive::EMediaNotPresent);
+ }
+ }
- if(err == KErrNotReady || (err==KErrNone && aInfo.iType == ::EMediaNotPresent))
- {
- __PRINT(_L("CMassStorageDrive::Caps detected MediaNotPresent\n"));
- SetDriveState(CMassStorageDrive::EMediaNotPresent);
- }
- }
-
- iCritSec.Signal();
- return err;
- }
+ iCritSec.Signal();
+ return err;
+ }
/**
Provides an interface to CProxyDrive::Caps that hides the
@@ -209,45 +217,41 @@
@param aInfo
*/
TInt CMassStorageDrive::DoCaps(TLocalDriveCapsV4& aInfo)
- {
- __FNLOG("CMassStorageDrive::DoCaps");
+ {
+ TLocalDriveCapsV4Buf buf;
+ buf.FillZ();
+ CProxyDrive& pd = SafeProxyDrive();
- TLocalDriveCapsV4Buf buf;
- buf.FillZ();
- CProxyDrive& pd = SafeProxyDrive();
-
- __PRINT(_L("CMassStorageDrive::DoCaps calling Caps\n"));
- TInt err = pd.Caps(buf);
+ TInt err = pd.Caps(buf);
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_121,
+ "Caps returned %d", err);
- __PRINT1(_L("CMassStorageDrive::DoCaps: Caps returned %d\n"), err);
+ if(err==KErrNone)
+ {
+ // Invoke function call operator to cast to TLocalDriveCapsV4&
+ aInfo = buf();
+ }
- if(err==KErrNone)
- {
- // Invoke function call operator to cast to TLocalDriveCapsV4&
- aInfo = buf();
- }
-
- return err;
- }
+ return err;
+ }
/**
Publish media error, user should reinsert the memory card.
Similar to FAT32's TDriver::HandleCriticalError.
Note: User notification is not implemented, instead we abort and dismount.
*/
-TInt CMassStorageDrive::HandleCriticalError()
- {
- __FNLOG("CMassStorageDrive::HandleCriticalError");
- iDriveMediaErrorPublisher.PublishError(ETrue);
- return KErrAbort;
- }
+TInt CMassStorageDrive::HandleCriticalError()
+ {
+ iDriveMediaErrorPublisher.PublishError(ETrue);
+ return KErrAbort;
+ }
TInt CMassStorageDrive::ClearCriticalError()
- {
- iDriveMediaErrorPublisher.PublishError(EFalse);
- return KErrNone;
- }
+ {
+ iDriveMediaErrorPublisher.PublishError(EFalse);
+ return KErrNone;
+ }
/**
@@ -256,30 +260,30 @@
@param aReset If true, the Media Changed flag is reset to EFalse.
*/
TBool CMassStorageDrive::IsMediaChanged(TBool aReset)
- {
- __FNLOG("CMassStorageDrive::IsMediaChanged");
-
- iCritSec.Wait();
+ {
+ iCritSec.Wait();
- TBool mediaChanged = EFalse;
- if(iLocalDrive)
- {
- mediaChanged = iLocalDrive->iMediaChanged;
- if(aReset)
- {
- iLocalDrive->iMediaChanged = EFalse;
- }
- }
- else
- {
- __PRINT(_L("CMassStorageDrive::IsMediaChanged: no drive\n"));
- }
+ TBool mediaChanged = EFalse;
+ if(iLocalDrive)
+ {
+ mediaChanged = iLocalDrive->iMediaChanged;
+ if(aReset)
+ {
+ iLocalDrive->iMediaChanged = EFalse;
+ }
+ }
+ else
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_130,
+ "No drive");
+ }
- iCritSec.Signal();
+ iCritSec.Signal();
- __PRINT1(_L("CMassStorageDrive::IsMediaChanged: returning %d\n"), mediaChanged);
- return mediaChanged;
- }
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_131,
+ "IsMediaChanged returning %d", mediaChanged);
+ return mediaChanged;
+ }
/**
Set the Drive State to Active or Idle.
@@ -287,58 +291,56 @@
@param aCritical ETrue for Active, EFalse for Idle
*/
TInt CMassStorageDrive::SetCritical(TBool aCritical)
- {
- __FNLOG("CMassStorageDrive::SetCritical");
+ {
+ TInt err = KErrDisMounted;
- TInt err = KErrDisMounted;
-
- iCritSec.Wait();
+ iCritSec.Wait();
- if(iLocalDrive)
- {
- if(iLocalDrive->iDriveState == CMassStorageDrive::EMediaNotPresent)
- {
- err = KErrNotReady;
- }
- else
- {
- SetDriveState(
- aCritical
- ? CMassStorageDrive::EActive
- : CMassStorageDrive::EIdle );
-
- err = KErrNone;
- }
- }
+ if(iLocalDrive)
+ {
+ if(iLocalDrive->iDriveState == CMassStorageDrive::EMediaNotPresent)
+ {
+ err = KErrNotReady;
+ }
+ else
+ {
+ SetDriveState(
+ aCritical
+ ? CMassStorageDrive::EActive
+ : CMassStorageDrive::EIdle );
- iCritSec.Signal();
+ err = KErrNone;
+ }
+ }
- return err;
- }
+ iCritSec.Signal();
+
+ return err;
+ }
/**
Set the mount state
*/
TInt CMassStorageDrive::SetMountConnected(CProxyDrive& aProxyDrive, TBool& aMediaChanged)
- {
- __FNLOG("CMassStorageDrive::SetMountConnected");
- CLocalDriveRef* localDrive = NULL;
+ {
+ CLocalDriveRef* localDrive = NULL;
- __PRINT(_L("SetMountConnected entering critical section\n"));
- iCritSec.Wait(); // note: signalled in SetMountState
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_140,
+ "SetMountConnected entering critical section");
+ iCritSec.Wait(); // note: signalled in SetMountState
- if (iLocalDrive == NULL)
- {
- localDrive = new CLocalDriveRef(aProxyDrive, aMediaChanged);
- if (localDrive==NULL)
- {
- iCritSec.Signal();
- return KErrNoMemory;
- }
- }
+ if (iLocalDrive == NULL)
+ {
+ localDrive = new CLocalDriveRef(aProxyDrive, aMediaChanged);
+ if (localDrive==NULL)
+ {
+ iCritSec.Signal();
+ return KErrNoMemory;
+ }
+ }
- return SetMountState(EConnected, localDrive);
- }
+ return SetMountState(EConnected, localDrive);
+ }
/**
@return KErrNone
@@ -346,256 +348,257 @@
@param aLocalDrive Only provide this if aNewState is EConnected.
*/
TInt CMassStorageDrive::SetMountState(TMountState aNewState, CLocalDriveRef* aLocalDrive/*=NULL*/)
- {
- __FNLOG("CMassStorageDrive::SetMountState");
-
- if(iMountState == aNewState)
- {
- __PRINT(_L("SetMountState: No change\n"));
- }
- else
- {
- // If called from SetMountConnected, already in critical section,
- // otherwise, must enter it here.
- if(EConnected!=aNewState)
- {
- __PRINT(_L("SetMountState entering critical section\n"));
- iCritSec.Wait();
- }
+ {
+ if(iMountState == aNewState)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_150,
+ "SetMountState: No change");
+ }
+ else
+ {
+ // If called from SetMountConnected, already in critical section,
+ // otherwise, must enter it here.
+ if(EConnected!=aNewState)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_151,
+ "SetMountState entering critical section");
+ iCritSec.Wait();
+ }
+
+ switch(aNewState)
+ {
+ case EConnected:
+ if(aLocalDrive)
+ {
+ __ASSERT_DEBUG(iLocalDrive, User::Panic(KUsbMsSvrPncCat, EMsCMassStorageDriveSetMountState_iLocalDrive));
+ iLocalDrive = aLocalDrive;
+ }
+ __ASSERT_DEBUG(iLocalDrive, User::Panic(KUsbMsSvrPncCat, EMsCMassStorageDriveSetMountState_aLocalDrive));
+ break;
- switch(aNewState)
- {
- case EConnected:
- if(aLocalDrive)
- {
- __ASSERT_DEBUG(!iLocalDrive, User::Invariant());
- iLocalDrive = aLocalDrive;
- }
- __ASSERT_DEBUG(iLocalDrive, User::Invariant());
- break;
-
- case EDisconnected:
- delete iLocalDrive;
- iLocalDrive = NULL;
+ case EDisconnected:
+ delete iLocalDrive;
+ iLocalDrive = NULL;
#ifndef USB_TRANSFER_PUBLISHER
- iBytesWritten = iBytesRead = 0;
+ iBytesWritten = iBytesRead = 0;
#endif
- break;
+ break;
+
+ case EDisconnecting:
+ case EConnecting:
+ // Do not change iLocalDrive for these state changes
+ break;
+ }
- case EDisconnecting:
- case EConnecting:
- // Do not change iLocalDrive for these state changes
- break;
- }
-
- iMountState = aNewState;
- __PRINT1(_L("SetMountState: state=%d\n"), iMountState);
+ iMountState = aNewState;
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_152,
+ "SetMountState: state=%d", iMountState);
+
+ iDriveStateChangedPublisher.DriveStateChanged();
- iDriveStateChangedPublisher.DriveStateChanged();
-
- iCritSec.Signal();
- __PRINT(_L("SetMountState has left the critical section\n"));
- }
+ iCritSec.Signal();
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_153,
+ "SetMountState has left the critical section");
+ }
- return KErrNone;
- }
+ return KErrNone;
+ }
/**
@return Current drive media state
*/
CMassStorageDrive::TDriveState CMassStorageDrive::DriveState() const
- {
- return iLocalDrive ? iLocalDrive->iDriveState : EErrDisMounted;
- }
+ {
+ return iLocalDrive ? iLocalDrive->iDriveState : EErrDisMounted;
+ }
/**
Check for media not present, and return the drive state.
@return Current drive media state
*/
CMassStorageDrive::TDriveState CMassStorageDrive::CheckDriveState()
- {
- __FNLOG("CMassStorageDrive::CheckDriveState");
+ {
+ CMassStorageDrive::TDriveState state = EErrDisMounted;
- CMassStorageDrive::TDriveState state = EErrDisMounted;
+ iCritSec.Wait();
- iCritSec.Wait();
-
- if (iLocalDrive)
- {
- TInt err = KErrGeneral;
- TLocalDriveCapsV4 caps;
+ if (iLocalDrive)
+ {
+ TInt err = KErrGeneral;
+ TLocalDriveCapsV4 caps;
- FOREVER
- {
- // Initialise in case Caps() fails
- caps.iType = ::EMediaNotPresent;
+ FOREVER
+ {
+ // Initialise in case Caps() fails
+ caps.iType = ::EMediaNotPresent;
- err = DoCaps(caps);
- __PRINTERR(_L("CheckDriveState: DoCaps err=%d\n"), err);
- if (err == KErrNotReady || (err == KErrNone && caps.iType == ::EMediaNotPresent))
- {
- __PRINT(_L("CheckDriveState: detected MediaNotPresent\n"));
+ err = DoCaps(caps);
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_160,
+ "DoCaps err=%d", err);
+ if (err == KErrNotReady || (err == KErrNone && caps.iType == ::EMediaNotPresent))
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_161,
+ "Detected MediaNotPresent");
- SetDriveState(CMassStorageDrive::EMediaNotPresent);
+ SetDriveState(CMassStorageDrive::EMediaNotPresent);
- if (HandleCriticalError() == KErrAbort)
- break;
- }
- else
- {
- ClearCriticalError();
- break;
- }
- }
+ if (HandleCriticalError() == KErrAbort)
+ break;
+ }
+ else
+ {
+ ClearCriticalError();
+ break;
+ }
+ }
- if (err == KErrNone && caps.iType != ::EMediaNotPresent)
- {
- if (iLocalDrive->iDriveState == CMassStorageDrive::EMediaNotPresent)
- {
- __PRINT(_L("CheckDriveState: detected media inserted\n"));
- SetDriveState(CMassStorageDrive::EIdle);
- }
- else if (iLocalDrive->iDriveState == CMassStorageDrive::ELocked &&
- !(caps.iMediaAtt & KMediaAttLocked))
- {
- __PRINT(_L("CheckDriveState: detected media unlocked\n"));
- SetDriveState(CMassStorageDrive::EIdle);
- }
- else if (caps.iMediaAtt & KMediaAttLocked)
- {
- __PRINT(_L("CheckDriveState: detected media locked\n"));
- SetDriveState(CMassStorageDrive::ELocked);
- }
-
- iWholeMediaAccess = !(caps.iDriveAtt & KDriveAttLogicallyRemovable);
- }
+ if (err == KErrNone && caps.iType != ::EMediaNotPresent)
+ {
+ if (iLocalDrive->iDriveState == CMassStorageDrive::EMediaNotPresent)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_162,
+ "Detected media inserted");
+ SetDriveState(CMassStorageDrive::EIdle);
+ }
+ else if (iLocalDrive->iDriveState == CMassStorageDrive::ELocked &&
+ !(caps.iMediaAtt & KMediaAttLocked))
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_163,
+ "Detected media unlocked");
+ SetDriveState(CMassStorageDrive::EIdle);
+ }
+ else if (caps.iMediaAtt & KMediaAttLocked)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_164,
+ "Detected media locked");
+ SetDriveState(CMassStorageDrive::ELocked);
+ }
- // Get the current state
- state = iLocalDrive->iDriveState;
- }
+ iWholeMediaAccess = !(caps.iDriveAtt & KDriveAttLogicallyRemovable);
+ }
- iCritSec.Signal();
+ // Get the current state
+ state = iLocalDrive->iDriveState;
+ }
- return state;
- }
+ iCritSec.Signal();
+
+ return state;
+ }
static TBool IsActive(CMassStorageDrive::TDriveState aDriveState)
- {
- return aDriveState==CMassStorageDrive::EActive;
- }
+ {
+ return aDriveState==CMassStorageDrive::EActive;
+ }
/**
@param aNewState
*/
void CMassStorageDrive::SetDriveState(TDriveState aNewState)
- {
- __FNLOG("CMassStorageDrive::SetDriveState");
-
- __ASSERT_DEBUG(aNewState == EIdle ||
+ {
+ __ASSERT_DEBUG(aNewState == EIdle ||
(iMountState == EConnected && NULL != iLocalDrive) ||
(iMountState == EDisconnecting && NULL != iLocalDrive),
- User::Invariant());
+ User::Panic(KUsbMsSvrPncCat, EMsCMassStorageDriveSetDriveState_State));
- if(!iLocalDrive)
- {
- __PRINT(_L("SetDriveState: Drive not mounted.\n"));
- }
- else
- {
- __PRINT2(_L("SetDriveState: %d->%d\n"), iLocalDrive->iDriveState, aNewState);
+ if(!iLocalDrive)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_170,
+ "Drive not mounted.");
+ }
+ else
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_171,
+ "Drive state change %d->%d", iLocalDrive->iDriveState, aNewState);
+
+ if(iLocalDrive->iDriveState != aNewState)
+ {
+ CMountCB* mount = SafeProxyDrive().Mount();
+ __ASSERT_DEBUG(mount != NULL, User::Panic(KUsbMsSvrPncCat, EMsCMassStorageDriveSetDriveState_Mount));
- if(iLocalDrive->iDriveState != aNewState)
- {
- CMountCB* mount = SafeProxyDrive().Mount();
-#if !defined(USBMSDRIVE_TEST)
- __ASSERT_DEBUG(mount != NULL, User::Invariant());
-#endif
- if(mount)
- {
- if(!IsActive(iLocalDrive->iDriveState) && IsActive(aNewState))
- {
- mount->IncLock();
- }
- else if(IsActive(iLocalDrive->iDriveState) && !IsActive(aNewState))
- {
- mount->DecLock();
- }
- __PRINT1(_L("SetDriveState: LockStatus=%d\n"), mount->LockStatus());
- }
+ if(mount)
+ {
+ if(!IsActive(iLocalDrive->iDriveState) && IsActive(aNewState))
+ {
+ mount->IncLock();
+ }
+ else if(IsActive(iLocalDrive->iDriveState) && !IsActive(aNewState))
+ {
+ mount->DecLock();
+ }
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_172,
+ "LockStatus=%d", mount->LockStatus());
+ }
- iLocalDrive->iDriveState = aNewState;
+ iLocalDrive->iDriveState = aNewState;
- iDriveStateChangedPublisher.DriveStateChanged();
- }
- }
- }
+ iDriveStateChangedPublisher.DriveStateChanged();
+ }
+ }
+ }
/**
Accessor for iProxyDrive; asserts if NULL
*/
CProxyDrive& CMassStorageDrive::SafeProxyDrive() const
- {
- __ASSERT_ALWAYS(NULL!=iLocalDrive, User::Invariant());
- return iLocalDrive->iProxyDrive;
- }
+ {
+ __ASSERT_ALWAYS(NULL!=iLocalDrive, User::Invariant());
+ return iLocalDrive->iProxyDrive;
+ }
/////////////////////////////////////////////////////////////////
/**
Construct a CDriveManager object.
-@param aDriveMap Reference to array mapping lun to drive number for supported
- mass storage drives.
+@param aDriveMap Reference to array mapping lun to drive number for supported
+ mass storage drives.
*/
CDriveManager* CDriveManager::NewL(TRefDriveMap aDriveMap)
- {
- __FNLOG("CDriveManager::NewL");
- __PRINT1(_L("CDriveManager::NewL - %d drives\n"), aDriveMap.Count());
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_180,
+ "%d drives available", aDriveMap.Count());
- CDriveManager* self = new (ELeave) CDriveManager(aDriveMap);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ CDriveManager* self = new (ELeave) CDriveManager(aDriveMap);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
CDriveManager::CDriveManager(const RArray<TInt>& aDriveMap)
- : iDriveMap(aDriveMap)
- {}
+ : iDriveMap(aDriveMap)
+ {}
/**
Construct a CDriveManager object.
*/
void CDriveManager::ConstructL()
- {
- __FNLOG("CDriveManager::ConstructL");
+ {
+ User::LeaveIfError(iDriveCritSec.CreateLocal());
- User::LeaveIfError(iDriveCritSec.CreateLocal());
-
- iDriveStateChangedPublisher = new (ELeave) RDriveStateChangedPublisher(iDrives, iDriveMap);
+ iDriveStateChangedPublisher = new (ELeave) RDriveStateChangedPublisher(iDrives, iDriveMap);
- for(TInt i = 0; i < iDriveMap.Count(); i++)
- {
- iDrives[i] = new (ELeave) CMassStorageDrive(iDriveCritSec, *iDriveStateChangedPublisher);
- }
+ for(TInt i = 0; i < iDriveMap.Count(); i++)
+ {
+ iDrives[i] = new (ELeave) CMassStorageDrive(iDriveCritSec, *iDriveStateChangedPublisher);
+ }
- // Publish initial drive state
- if (iDriveMap.Count() > 0)
- {
- iDriveStateChangedPublisher->DriveStateChanged();
- }
- }
+ // Publish initial drive state
+ if (iDriveMap.Count() > 0)
+ {
+ iDriveStateChangedPublisher->DriveStateChanged();
+ }
+ }
/**
Destructor
*/
CDriveManager::~CDriveManager()
- {
- __FNLOG("CDriveManager::~CDriveManager");
-
- iDrives.DeleteAll();
- delete iDriveStateChangedPublisher;
- iDriveCritSec.Close();
- }
+ {
+ iDrives.DeleteAll();
+ delete iDriveStateChangedPublisher;
+ iDriveCritSec.Close();
+ }
/**
Set the mount state to Connected and specify the Proxy Drive.
@@ -607,19 +610,18 @@
@post The Mount State will be Connected.
*/
TInt CDriveManager::RegisterDrive(CProxyDrive& aProxyDrive, TBool& aMediaChanged, TUint aLun)
- {
- __FNLOG("CDriveManager::RegisterDrive");
- __PRINT1(_L("Lun=%d \n"),aLun);
- TInt err = KErrUnknown; // never return this
- CMassStorageDrive* drive = CDriveManager::Drive(aLun, err);
- if(drive)
- {
- drive->SetMountConnected(aProxyDrive, aMediaChanged);
- }
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_190, "Lun=%d", aLun);
+ TInt err = KErrUnknown; // never return this
+ CMassStorageDrive* drive = CDriveManager::Drive(aLun, err);
+ if(drive)
+ {
+ drive->SetMountConnected(aProxyDrive, aMediaChanged);
+ }
- __PRINT1(_L("CDriveManager::RegisterDrive err=%d\n"), err);
- return err;
- }
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_191, "err=%d", err);
+ return err;
+ }
/**
Set the mount state to Disconnected.
@@ -628,18 +630,16 @@
@post The Mount State will be Disconnected.
*/
TInt CDriveManager::DeregisterDrive(TUint aLun)
- {
- __FNLOG("CDriveManager::DeregisterDrive");
+ {
+ TInt err = KErrUnknown; // never return this
+ if(CMassStorageDrive* drive = Drive(aLun, err))
+ {
+ err = drive->SetMountDisconnected();
+ }
- TInt err = KErrUnknown; // never return this
- if(CMassStorageDrive* drive = Drive(aLun, err))
- {
- err = drive->SetMountDisconnected();
- }
-
- __PRINT1(_L("CDriveManager::DeregisterDrive err=%d\n"), err);
- return err;
- }
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_200, "err=%d", err);
+ return err;
+ }
/**
Return a pointer to the drive specified aLun, or NULL if
@@ -650,22 +650,22 @@
@param aError KErrNone on success, KErrArgument if NULL is returned.
*/
CMassStorageDrive* CDriveManager::Drive(TUint aLun, TInt& aError) const
- {
- aError = KErrNone;
- CMassStorageDrive* drive = NULL;
+ {
+ aError = KErrNone;
+ CMassStorageDrive* drive = NULL;
- // Check if aLun exceeds the specified number of drives
- // (This will panic if it exceeds KMaxLun).
- if(aLun>=KUsbMsMaxDrives || !iDrives[aLun])
- {
- aError = KErrArgument;
- }
- else
- {
- drive = iDrives[aLun];
- }
- return drive;
- }
+ // Check if aLun exceeds the specified number of drives
+ // (This will panic if it exceeds KMaxLun).
+ if(aLun>=KUsbMsMaxDrives || !iDrives[aLun])
+ {
+ aError = KErrArgument;
+ }
+ else
+ {
+ drive = iDrives[aLun];
+ }
+ return drive;
+ }
/**
Checks the Media Changed flag, and optionally resets it.
@@ -674,22 +674,21 @@
@param aReset If true, the Media Changed flag is reset to EFalse.
*/
TBool CDriveManager::IsMediaChanged(TUint aLun, TBool aReset)
- {
- __FNLOG("CDriveManager::IsMediaChanged");
-
- TInt err; // not used, but is a required parameter
- CMassStorageDrive* drive = Drive(aLun, err);
+ {
+ TInt err; // not used, but is a required parameter
+ CMassStorageDrive* drive = Drive(aLun, err);
- if(!drive)
- {
- __PRINT1(_L("CDriveManager::IsMediaChanged: LUN=%d not found, returning false\n"), aLun);
- return ETrue;
- }
- else
- {
- return drive->IsMediaChanged(aReset);
- }
- }
+ if(!drive)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_210,
+ "LUN=%d not found, returning false", aLun);
+ return ETrue;
+ }
+ else
+ {
+ return drive->IsMediaChanged(aReset);
+ }
+ }
/**
Set the Drive State to Active or Idle.
@@ -699,31 +698,29 @@
@param aCritical ETrue for Active, EFalse for Idle
*/
TInt CDriveManager::SetCritical(TUint aLun, TBool aCritical)
- {
- __FNLOG("CDriveManager::SetCritical");
+ {
+ TInt err = KErrUnknown; // never return this
+
+ TInt i=aLun;
+ TInt cnt=aLun+1;
- TInt err = KErrUnknown; // never return this
+ if (aLun == KAllLuns)
+ {
+ i=0;
+ cnt= iDriveMap.Count();
+ }
- TInt i=aLun;
- TInt cnt=aLun+1;
-
- if (aLun == KAllLuns)
- {
- i=0;
- cnt= iDriveMap.Count();
- }
+ for(; i<cnt; i++)
+ {
- for(; i<cnt; i++)
- {
-
- CMassStorageDrive* drive = Drive(i, err);
- if(drive)
- {
- err = drive->SetCritical(aCritical);
- }
- }
- return err;
- }
+ CMassStorageDrive* drive = Drive(i, err);
+ if(drive)
+ {
+ err = drive->SetCritical(aCritical);
+ }
+ }
+ return err;
+ }
/**
Inititiate transition to Connected.
@@ -732,32 +729,31 @@
@post The Mount State will be Connected or Connecting.
*/
TInt CDriveManager::Connect(TUint aLun)
- {
- __FNLOG("CDriveManager::Connect");
+ {
+ TInt err = KErrUnknown; // never return this
+ CMassStorageDrive* drive = Drive(aLun, err);
- TInt err = KErrUnknown; // never return this
- CMassStorageDrive* drive = Drive(aLun, err);
-
- __PRINT3(_L("CDriveManager::Connect lun=%d, err=%d, mountState=%d\n"), aLun, err, drive->MountState());
+ OstTraceExt3(TRACE_SMASSSTORAGE_DRIVESTATE, DRIVERMANAGER_230,
+ "lun=%d err=%d mountState=%d", aLun, err, drive->MountState());
- if(drive)
- {
- switch(drive->MountState())
- {
- case CMassStorageDrive::EDisconnected:
- err = drive->SetMountConnecting();
- break;
- case CMassStorageDrive::EDisconnecting:
- err = drive->SetMountConnected();
- break;
- case CMassStorageDrive::EConnected:
- case CMassStorageDrive::EConnecting:
- // do nothing
- break;
- }
- }
- return err;
- }
+ if(drive)
+ {
+ switch(drive->MountState())
+ {
+ case CMassStorageDrive::EDisconnected:
+ err = drive->SetMountConnecting();
+ break;
+ case CMassStorageDrive::EDisconnecting:
+ err = drive->SetMountConnected();
+ break;
+ case CMassStorageDrive::EConnected:
+ case CMassStorageDrive::EConnecting:
+ // do nothing
+ break;
+ }
+ }
+ return err;
+ }
/**
Inititiate transition to Disconnected.
@@ -766,29 +762,27 @@
@post The Mount State will be Disconnected or Disconnecting.
*/
TInt CDriveManager::Disconnect(TUint aLun)
- {
- __FNLOG("CDriveManager::Disconnect");
-
- TInt err = KErrUnknown; // never return this
- CMassStorageDrive* drive = Drive(aLun, err);
+ {
+ TInt err = KErrUnknown; // never return this
+ CMassStorageDrive* drive = Drive(aLun, err);
- if(drive)
- {
- switch(drive->MountState())
- {
- case CMassStorageDrive::EConnected:
- err = drive->SetMountDisconnecting();
- break;
- case CMassStorageDrive::EConnecting:
- err = drive->SetMountDisconnected();
- break;
- case CMassStorageDrive::EDisconnected:
- case CMassStorageDrive::EDisconnecting:
- // do nothing
- break;
- }
- }
- return err;
- }
+ if(drive)
+ {
+ switch(drive->MountState())
+ {
+ case CMassStorageDrive::EConnected:
+ err = drive->SetMountDisconnecting();
+ break;
+ case CMassStorageDrive::EConnecting:
+ err = drive->SetMountDisconnected();
+ break;
+ case CMassStorageDrive::EDisconnected:
+ case CMassStorageDrive::EDisconnecting:
+ // do nothing
+ break;
+ }
+ }
+ return err;
+ }
--- a/userlibandfileserver/fileserver/smassstorage/drivepublisher.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/drivepublisher.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -11,16 +11,16 @@
// Contributors:
//
// Description:
-// Class implementation of the drive publishing classes -
+// Class implementation of the drive publishing classes -
// RDriveMediaErrorPublisher,
-// RDriveStateChangedPublisher,
+// RDriveStateChangedPublisher,
// CDriveTransferPublisher,
// CDriveWriteTransferPublisher,
// CDriveReadTransferPublisher,
// CUsbTransferPublisher,
// CUsbReadTransferPublisher,
// CUsbReadTransferPublisher.
-//
+//
//
/**
@@ -28,42 +28,48 @@
@internalTechnology
*/
-#include "massstoragedebug.h"
+
#include "drivepublisher.h"
#include "drivemanager.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "drivepublisherTraces.h"
+#endif
-//
+
+
+//
// Use Lookup table to translate from the internal pair of state variables
// to the externally published drive state code.
//
-LOCAL_D const TUint8 table[][5] =
+static const TUint8 table[][5] =
{
//TMountState=EDisconnected
- {EUsbMsDriveState_Disconnected,
- EUsbMsDriveState_Disconnected,
- EUsbMsDriveState_Disconnected,
- EUsbMsDriveState_Disconnected,
- EUsbMsDriveState_Disconnected},
+ {EUsbMsDriveState_Disconnected,
+ EUsbMsDriveState_Disconnected,
+ EUsbMsDriveState_Disconnected,
+ EUsbMsDriveState_Disconnected,
+ EUsbMsDriveState_Disconnected},
//TMountState=EConnecting
- {EUsbMsDriveState_Connecting,
- EUsbMsDriveState_Connecting,
- EUsbMsDriveState_Connecting,
- EUsbMsDriveState_Connecting,
- EUsbMsDriveState_Connecting},
+ {EUsbMsDriveState_Connecting,
+ EUsbMsDriveState_Connecting,
+ EUsbMsDriveState_Connecting,
+ EUsbMsDriveState_Connecting,
+ EUsbMsDriveState_Connecting},
//TMountState=EConnected
- //EIdle,EActive,ELocked,EMediaNotPresent,EErrDisMounted
- {EUsbMsDriveState_Connected,
- EUsbMsDriveState_Active,
- EUsbMsDriveState_Locked,
- EUsbMsDriveState_MediaNotPresent,
- EUsbMsDriveState_Removed},
+ //EIdle,EActive,ELocked,EMediaNotPresent,EErrDisMounted
+ {EUsbMsDriveState_Connected,
+ EUsbMsDriveState_Active,
+ EUsbMsDriveState_Locked,
+ EUsbMsDriveState_MediaNotPresent,
+ EUsbMsDriveState_Removed},
//TMountState=EDisconnecting
- {EUsbMsDriveState_Disconnecting,
- EUsbMsDriveState_Disconnecting,
- EUsbMsDriveState_Disconnecting,
- EUsbMsDriveState_Disconnecting,
- EUsbMsDriveState_Disconnecting}
+ {EUsbMsDriveState_Disconnecting,
+ EUsbMsDriveState_Disconnecting,
+ EUsbMsDriveState_Disconnecting,
+ EUsbMsDriveState_Disconnecting,
+ EUsbMsDriveState_Disconnecting}
};
@@ -72,29 +78,25 @@
Constructor
*/
RDriveMediaErrorPublisher::RDriveMediaErrorPublisher()
- {
- __FNLOG("RDriveMediaErrorPublisher::RDriveMediaErrorPublisher()");
-
- _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
- _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
+ {
+ _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
+ _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
- TInt result = RProperty::Define(EUsbMsDriveState_MediaError, RProperty::EInt,
- KMassStorageReadPolicy, KMassStorageWritePolicy);
-
- __ASSERT_DEBUG(result == KErrAlreadyExists || result == KErrNone, User::Invariant());
-
- result = iMediaErrorProperty.Attach(KUsbMsDriveState_Category, EUsbMsDriveState_MediaError);
- __ASSERT_DEBUG(result == KErrNone, User::Invariant());
- }
+ TInt result = RProperty::Define(EUsbMsDriveState_MediaError, RProperty::EInt,
+ KMassStorageReadPolicy, KMassStorageWritePolicy);
+
+ __ASSERT_DEBUG(result == KErrAlreadyExists || result == KErrNone, User::Invariant());
+
+ result = iMediaErrorProperty.Attach(KUsbMsDriveState_Category, EUsbMsDriveState_MediaError);
+ __ASSERT_DEBUG(result == KErrNone, User::Invariant());
+ }
RDriveMediaErrorPublisher::~RDriveMediaErrorPublisher()
- {
- __FNLOG("RDriveStatePublisher::~RDriveStatePublisher()");
-
- iMediaErrorProperty.Close();
- RProperty::Delete(KUsbMsDriveState_Category, EUsbMsDriveState_MediaError);
- }
+ {
+ iMediaErrorProperty.Close();
+ RProperty::Delete(KUsbMsDriveState_Category, EUsbMsDriveState_MediaError);
+ }
/**
Publishing method
@@ -104,17 +106,16 @@
@param aError ETrue if drive media has an error else EFalse for no error
*/
void RDriveMediaErrorPublisher::PublishError(TBool aError)
- {
- __PRINT1(_L("<< RDriveMediaErrorPublisher::PublishError %x"), aError);
-
- TInt oldValue;
- iMediaErrorProperty.Get(oldValue);
+ {
+ OstTraceFunctionEntry0(DRIVEPUBLISHER_100);
+ TInt oldValue;
+ iMediaErrorProperty.Get(oldValue);
- if (oldValue != aError)
- {
- User::LeaveIfError(iMediaErrorProperty.Set(aError));
- }
- }
+ if (oldValue != aError)
+ {
+ User::LeaveIfError(iMediaErrorProperty.Set(aError));
+ }
+ }
//----------------------------------------------------------------------------
/**
@@ -124,70 +125,64 @@
@param aDriveMap
*/
RDriveStateChangedPublisher::RDriveStateChangedPublisher(TRefMsDriveList aDrives,
- TRefDriveMap aDriveMap)
- :
- iDrives(aDrives),
- iDriveMap(aDriveMap)
- {
- __FNLOG("RDriveStateChangedPublisher::RDriveStateChangedPublisher()");
+ TRefDriveMap aDriveMap)
+ :
+ iDrives(aDrives),
+ iDriveMap(aDriveMap)
+ {
+ _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
+ _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
- _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
- _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
-
- TInt result = RProperty::Define(KUsbMsDriveState_Category,
- EUsbMsDriveState_DriveStatus, RProperty::EByteArray,
- KMassStorageReadPolicy, KMassStorageWritePolicy,
- KUsbMsMaxDrives*2);
- __ASSERT_DEBUG(result == KErrAlreadyExists || result == KErrNone, User::Invariant());
- result = result; // remove urel warning
- }
+ TInt result = RProperty::Define(KUsbMsDriveState_Category,
+ EUsbMsDriveState_DriveStatus, RProperty::EByteArray,
+ KMassStorageReadPolicy, KMassStorageWritePolicy,
+ KUsbMsMaxDrives*2);
+ __ASSERT_DEBUG(result == KErrAlreadyExists || result == KErrNone, User::Invariant());
+ result = result; // remove urel warning
+ }
RDriveStateChangedPublisher::~RDriveStateChangedPublisher()
- {
- __FNLOG("RDriveStateChangedPublisher::~RDriveStateChangedPublisher()");
-
- RProperty::Delete(KUsbMsDriveState_Category, EUsbMsDriveState_DriveStatus);
- }
+ {
+ RProperty::Delete(KUsbMsDriveState_Category, EUsbMsDriveState_DriveStatus);
+ }
/**
Publishing method
-Sends a property event on behalf of CMassStorageDrive, with the mountstate and drivestate
+Sends a property event on behalf of CMassStorageDrive, with the mountstate and drivestate
values encoded into one 32-bit word.
*/
void RDriveStateChangedPublisher::DriveStateChanged()
- {
- __FNLOG("RDriveStateChangedPublisher::DriveStateChanged");
-
-
- TUsbMsDrivesStatus allDrivesStatus;
- for(TUint8 i=0; i<KUsbMsMaxDrives && iDrives[i]; i++)
- {
- allDrivesStatus.Append(iDriveMap[i]);
+ {
+ TUsbMsDrivesStatus allDrivesStatus;
+ for(TUint8 i=0; i<KUsbMsMaxDrives && iDrives[i]; i++)
+ {
+ allDrivesStatus.Append(iDriveMap[i]);
- CMassStorageDrive::TMountState ms = iDrives[i]->MountState();
- CMassStorageDrive::TDriveState ds = iDrives[i]->DriveState();
- TInt driveStatus = EUsbMsDriveState_Error;
- if((TUint8)ds < sizeof(table[0]) && (TUint8)ms < sizeof(table)/sizeof(table[0]))
- {
- driveStatus = table[ms][ds];
- __PRINT3(_L("ms=%d ds=%d %d"), ms, ds, driveStatus);
- }
- allDrivesStatus.Append(driveStatus);
- }
+ CMassStorageDrive::TMountState ms = iDrives[i]->MountState();
+ CMassStorageDrive::TDriveState ds = iDrives[i]->DriveState();
+ TInt driveStatus = EUsbMsDriveState_Error;
+ if((TUint8)ds < sizeof(table[0]) && (TUint8)ms < sizeof(table)/sizeof(table[0]))
+ {
+ driveStatus = table[ms][ds];
+ OstTraceExt3(TRACE_SMASSSTORAGE_DRIVE, DRIVEPUBLISHER_110,
+ "ms=%d ds=%d %d", ms, ds, driveStatus);
+ }
+ allDrivesStatus.Append(driveStatus);
+ }
- __PRINT1(_L("Publishing EUsbMsDriveState_DriveStatus for %d drives\n"),
- allDrivesStatus.Length()/2);
+ OstTrace1(TRACE_SMASSSTORAGE_DRIVE, DRIVEPUBLISHER_111,
+ "Publishing EUsbMsDriveState_DriveStatus for %d drives", allDrivesStatus.Length()/2);
- if(KErrNone != RProperty::Set(KUsbMsDriveState_Category,
- EUsbMsDriveState_DriveStatus,
- allDrivesStatus))
- {
- __ASSERT_DEBUG(EFalse,User::Invariant());
- }
- }
+ if(KErrNone != RProperty::Set(KUsbMsDriveState_Category,
+ EUsbMsDriveState_DriveStatus,
+ allDrivesStatus))
+ {
+ __ASSERT_DEBUG(EFalse,User::Invariant());
+ }
+ }
//----------------------------------------------------------------------------
@@ -195,60 +190,56 @@
/**
Private default constructor to ensure that NewL is used
-@param aSubKey
+@param aSubKey
@param aDrives
*/
CDriveTransferPublisher::CDriveTransferPublisher(
- TUsbMsDriveState_Subkey aSubKey,
- TRefMsDriveList aDrives)
- :
- iSubKey(aSubKey),
- iDrives(aDrives)
- {
- }
+ TUsbMsDriveState_Subkey aSubKey,
+ TRefMsDriveList aDrives)
+ :
+ iSubKey(aSubKey),
+ iDrives(aDrives)
+ {
+ }
void CDriveTransferPublisher::ConstructL()
- {
- __FNLOG("CDriveTransferPublisher::ConstructL");
+ {
+ _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
+ _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
- _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
- _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
-
- TInt r = RProperty::Define(iSubKey, RProperty::EByteArray,
- KMassStorageReadPolicy, KMassStorageWritePolicy,
- KUsbMsMaxDrives*sizeof(TInt));
+ TInt r = RProperty::Define(iSubKey, RProperty::EByteArray,
+ KMassStorageReadPolicy, KMassStorageWritePolicy,
+ KUsbMsMaxDrives*sizeof(TInt));
- if (r != KErrAlreadyExists)
- {
- User::LeaveIfError(r);
- }
+ if (r != KErrAlreadyExists)
+ {
+ User::LeaveIfError(r);
+ }
- User::LeaveIfError(iProperty.Attach(KUsbMsDriveState_Category, iSubKey));
+ User::LeaveIfError(iProperty.Attach(KUsbMsDriveState_Category, iSubKey));
- // Create the EDataTransferred timer
- iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
- iTimerRunning = EFalse;
- }
+ // Create the EDataTransferred timer
+ iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+ iTimerRunning = EFalse;
+ }
/**
Destructor
*/
CDriveTransferPublisher::~CDriveTransferPublisher()
- {
- __FNLOG("CDriveTransferPublisher::~CDriveTransferPublisher");
+ {
+ if(iTimer)
+ {
+ iTimer->Cancel();
+ }
+ delete iTimer;
- if(iTimer)
- {
- iTimer->Cancel();
- }
- delete iTimer;
+ iProperty.Close();
- iProperty.Close();
-
- RProperty::Delete(KUsbMsDriveState_Category, iSubKey);
- }
+ RProperty::Delete(KUsbMsDriveState_Category, iSubKey);
+ }
/**
@@ -259,11 +250,10 @@
@return not used in CPeriodic callback (see TCallback)
*/
TInt CDriveTransferPublisher::PublishDataTransferredEvent(TAny* obj)
- {
- __FNLOG("CDrivePublisher::PublishDataTransferredEvent");
- static_cast<CDriveTransferPublisher*>(obj)->DoPublishDataTransferredEvent();
- return 1;
- }
+ {
+ static_cast<CDriveTransferPublisher*>(obj)->DoPublishDataTransferredEvent();
+ return 1;
+ }
/**
@@ -271,65 +261,63 @@
the last update.
*/
void CDriveTransferPublisher::DoPublishDataTransferredEvent()
- {
- if (PublishDataTransferred())
- {
- // some data has been transfered so reset the counter
- iTimerCancelCnt = ETimerCancelDelay;
- }
+ {
+ if (PublishDataTransferred())
+ {
+ // some data has been transfered so reset the counter
+ iTimerCancelCnt = ETimerCancelDelay;
+ }
- // Update the cancel count if no data was transferred the last
- // (few) times this has been called
- if (--iTimerCancelCnt == 0)
- {
- StopTimer();
- iTimerCancelCnt = ETimerCancelDelay;
- }
- }
+ // Update the cancel count if no data was transferred the last
+ // (few) times this has been called
+ if (--iTimerCancelCnt == 0)
+ {
+ StopTimer();
+ iTimerCancelCnt = ETimerCancelDelay;
+ }
+ }
/**
-Update the data transferred properties if the counts have changed since
+Update the data transferred properties if the counts have changed since
the last update.
*/
TBool CDriveTransferPublisher::PublishDataTransferred()
- {
- __FNLOG("CDriveWriteTransferPublisher::PublishDataTransferred");
-
- TUsbMsBytesTransferred bytesTransferred;
- TBool dataTransferred = EFalse;
+ {
+ TUsbMsBytesTransferred bytesTransferred;
+ TBool dataTransferred = EFalse;
- for (TInt i=0; i < iDrives.Count() && iDrives[i]; i++)
- {
- bytesTransferred[i] = GetBytesTransferred(i);
- }
+ for (TInt i=0; i < iDrives.Count() && iDrives[i]; i++)
+ {
+ bytesTransferred[i] = GetBytesTransferred(i);
+ }
- // Update the properties only if they have changed
- // (or if there's an error reading the old value.)
- // Possible optimisation: keep a copy of the value
- // as a member variable so we don't need the Get.
- TUsbMsBytesTransferred oldValue;
+ // Update the properties only if they have changed
+ // (or if there's an error reading the old value.)
+ // Possible optimisation: keep a copy of the value
+ // as a member variable so we don't need the Get.
+ TUsbMsBytesTransferred oldValue;
- if ((iProperty.Get(oldValue) != KErrNone) || (oldValue != bytesTransferred))
- {
+ if ((iProperty.Get(oldValue) != KErrNone) || (oldValue != bytesTransferred))
+ {
#ifdef __PRINT3
- for (TInt j=0; j < iDrives.Count() && iDrives[j]; j++)
- {
- if(oldValue[j] != bytesTransferred[j])
- {
- __PRINT3(_L("CDrivePublisher: KBytes[%d] %d->%d\n"), j, oldValue[j], bytesTransferred[j]);
- }
- }
+ for (TInt j=0; j < iDrives.Count() && iDrives[j]; j++)
+ {
+ if(oldValue[j] != bytesTransferred[j])
+ {
+ __PRINT3(_L("CDrivePublisher: KBytes[%d] %d->%d\n"), j, oldValue[j], bytesTransferred[j]);
+ }
+ }
#endif
- if (KErrNone != iProperty.Set(bytesTransferred))
- {
- __ASSERT_DEBUG(EFalse, User::Invariant());
- }
- dataTransferred = ETrue;
- }
+ if (KErrNone != iProperty.Set(bytesTransferred))
+ {
+ __ASSERT_DEBUG(EFalse, User::Invariant());
+ }
+ dataTransferred = ETrue;
+ }
- return dataTransferred;
- }
+ return dataTransferred;
+ }
/**
@@ -337,35 +325,31 @@
If the timer is not yet running then start it.
*/
void CDriveTransferPublisher::StartTimer()
- {
- __FNLOG("CDrivePublisher::StartTimer");
-
- if (!iTimerRunning)
- {
- // EDataTransferred event every second
- const TTimeIntervalMicroSeconds32 interval = 1 * 1000 * 1000;
- TCallBack callback(PublishDataTransferredEvent, this);
- __PRINT(_L("Starting timer"));
- iTimer->Start(interval, interval, callback);
- iTimerRunning = ETrue;
- }
- }
+ {
+ if (!iTimerRunning)
+ {
+ // EDataTransferred event every second
+ const TTimeIntervalMicroSeconds32 interval = 1 * 1000 * 1000;
+ TCallBack callback(PublishDataTransferredEvent, this);
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVE, DRIVEPUBLISHER_140, "Starting timer");
+ iTimer->Start(interval, interval, callback);
+ iTimerRunning = ETrue;
+ }
+ }
/**
Ensure that the Timer is stopped
*/
void CDriveTransferPublisher::StopTimer()
- {
- __FNLOG("CDrivePublisher::StopTimer");
-
- if (iTimerRunning)
- {
- __PRINT(_L("Stopping timer"));
- iTimer->Cancel();
- iTimerRunning = EFalse;
- }
- }
+ {
+ if (iTimerRunning)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVE, DRIVEPUBLISHER_141, "Stopping timer");
+ iTimer->Cancel();
+ iTimerRunning = EFalse;
+ }
+ }
//----------------------------------------------------------------------------
@@ -375,15 +359,13 @@
@param aDrives
*/
CDriveWriteTransferPublisher* CDriveWriteTransferPublisher::NewL(TRefMsDriveList aDrives)
- {
- __FNLOG("CDriveWriteTransferPublisher::NewL");
-
- CDriveWriteTransferPublisher* self = new (ELeave) CDriveWriteTransferPublisher(aDrives);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ {
+ CDriveWriteTransferPublisher* self = new (ELeave) CDriveWriteTransferPublisher(aDrives);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
/**
@@ -392,10 +374,10 @@
@param aDrives
*/
CDriveWriteTransferPublisher::CDriveWriteTransferPublisher(TRefMsDriveList aDrives)
- :
- CDriveTransferPublisher(EUsbMsDriveState_KBytesWritten, aDrives)
- {
- }
+ :
+ CDriveTransferPublisher(EUsbMsDriveState_KBytesWritten, aDrives)
+ {
+ }
/**
@@ -404,9 +386,9 @@
@param aLun
*/
TUint CDriveWriteTransferPublisher::GetBytesTransferred(TUint aLun) const
- {
- return iDrives[aLun]->KBytesWritten();
- }
+ {
+ return iDrives[aLun]->KBytesWritten();
+ }
//----------------------------------------------------------------------------
@@ -416,15 +398,13 @@
@param aDrives
*/
CDriveReadTransferPublisher* CDriveReadTransferPublisher::NewL(TRefMsDriveList aDrives)
- {
- __FNLOG("CDriveWriteTransferPublisher::NewL");
-
- CDriveReadTransferPublisher* self = new (ELeave) CDriveReadTransferPublisher(aDrives);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ {
+ CDriveReadTransferPublisher* self = new (ELeave) CDriveReadTransferPublisher(aDrives);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
/**
@@ -433,10 +413,10 @@
@param aDrives
*/
CDriveReadTransferPublisher::CDriveReadTransferPublisher(TRefMsDriveList aDrives)
- :
- CDriveTransferPublisher(EUsbMsDriveState_KBytesRead, aDrives)
- {
- }
+ :
+ CDriveTransferPublisher(EUsbMsDriveState_KBytesRead, aDrives)
+ {
+ }
/**
@@ -445,72 +425,68 @@
@param aLun
*/
TUint CDriveReadTransferPublisher::GetBytesTransferred(TUint aLun) const
- {
- return iDrives[aLun]->KBytesRead();
- }
+ {
+ return iDrives[aLun]->KBytesRead();
+ }
//----------------------------------------------------------------------------
#else
/**
Private default constructor to ensure that NewL is used
-
+
@param aSubKey
@param aArray
*/
CUsbTransferPublisher::CUsbTransferPublisher(
- TUsbMsDriveState_Subkey aSubKey,
- TRefBytesTransferedList aArray)
- :
- iSubKey(aSubKey),
- iArray(aArray)
- {
- }
+ TUsbMsDriveState_Subkey aSubKey,
+ TRefBytesTransferedList aArray)
+ :
+ iSubKey(aSubKey),
+ iArray(aArray)
+ {
+ }
void CUsbTransferPublisher::ConstructL()
- {
- __FNLOG("CUsbTransferPublisher::ConstructL");
+ {
+ _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
+ _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
- _LIT_SECURITY_POLICY_PASS(KMassStorageReadPolicy);
- _LIT_SECURITY_POLICY_S0(KMassStorageWritePolicy, KUsbMsDriveState_Category.iUid);
-
- TInt r = RProperty::Define(iSubKey, RProperty::EByteArray,
- KMassStorageReadPolicy, KMassStorageWritePolicy,
- KUsbMsMaxDrives*sizeof(TInt));
+ TInt r = RProperty::Define(iSubKey, RProperty::EByteArray,
+ KMassStorageReadPolicy, KMassStorageWritePolicy,
+ KUsbMsMaxDrives*sizeof(TInt));
- if (r != KErrAlreadyExists)
- {
- User::LeaveIfError(r);
- }
+ if (r != KErrAlreadyExists)
+ {
+ User::LeaveIfError(r);
+ }
- // Attach to the properties here. Only do this once, continuously attaching
- // will currently cause a memory leak
- User::LeaveIfError(iProperty.Attach(KUsbMsDriveState_Category, iSubKey));
+ // Attach to the properties here. Only do this once, continuously attaching
+ // will currently cause a memory leak
+ User::LeaveIfError(iProperty.Attach(KUsbMsDriveState_Category, iSubKey));
- // Create the EDataTransferred timer
- iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
- iTimerRunning = EFalse;
- }
+ // Create the EDataTransferred timer
+ iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+ iTimerRunning = EFalse;
+ }
/**
Destructor
*/
CUsbTransferPublisher::~CUsbTransferPublisher()
- {
- __FNLOG("CUsbTransferPublisher::~CDriveTransferPublisher");
+ {
+ if(iTimer)
+ {
+ iTimer->Cancel();
+ }
+ delete iTimer;
- if(iTimer)
- {
- iTimer->Cancel();
- }
- delete iTimer;
+ iProperty.Close();
- iProperty.Close();
-
- RProperty::Delete(KUsbMsDriveState_Category, iSubKey);
- }
+ RProperty::Delete(KUsbMsDriveState_Category, iSubKey);
+ }
/**
@@ -521,11 +497,10 @@
@return not used in CPeriodic callback (see TCallback)
*/
TInt CUsbTransferPublisher::PublishDataTransferredEvent(TAny* obj)
- {
- __FNLOG("CUsbTransferPublisher::PublishDataTransferredEvent");
- static_cast<CUsbTransferPublisher*>(obj)->DoPublishDataTransferredEvent();
- return 1;
- }
+ {
+ static_cast<CUsbTransferPublisher*>(obj)->DoPublishDataTransferredEvent();
+ return 1;
+ }
/**
@@ -533,66 +508,64 @@
the last update.
*/
void CUsbTransferPublisher::DoPublishDataTransferredEvent()
- {
- if (PublishDataTransferred())
- {
- // some data has been transfered so reset the counter
- iTimerCancelCnt = ETimerCancelDelay;
- }
+ {
+ if (PublishDataTransferred())
+ {
+ // some data has been transfered so reset the counter
+ iTimerCancelCnt = ETimerCancelDelay;
+ }
- // Update the cancel count if no data was transferred the last
- // (few) times this has been called
- if (--iTimerCancelCnt == 0)
- {
- StopTimer();
- iTimerCancelCnt = ETimerCancelDelay;
- }
- }
+ // Update the cancel count if no data was transferred the last
+ // (few) times this has been called
+ if (--iTimerCancelCnt == 0)
+ {
+ StopTimer();
+ iTimerCancelCnt = ETimerCancelDelay;
+ }
+ }
/**
-Update the data transferred properties if the counts have changed since
+Update the data transferred properties if the counts have changed since
the last update.
*/
TBool CUsbTransferPublisher::PublishDataTransferred()
- {
- __FNLOG("CUsbWriteTransferPublisher::PublishDataTransferred");
-
- TUsbMsBytesTransferred bytesTransferred;
- TBool dataTransferred = EFalse;
+ {
+ TUsbMsBytesTransferred bytesTransferred;
+ TBool dataTransferred = EFalse;
- for (TInt i = 0; i < iArray.Count(); i++)
- {
- bytesTransferred[i] = GetBytesTransferred(i);
- }
+ for (TInt i = 0; i < iArray.Count(); i++)
+ {
+ bytesTransferred[i] = GetBytesTransferred(i);
+ }
- // Update the properties only if they have changed
- // (or if there's an error reading the old value.)
- // Possible optimisation: keep a copy of the value
- // as a member variable so we don't need the Get.
- TUsbMsBytesTransferred oldValue;
+ // Update the properties only if they have changed
+ // (or if there's an error reading the old value.)
+ // Possible optimisation: keep a copy of the value
+ // as a member variable so we don't need the Get.
+ TUsbMsBytesTransferred oldValue;
- if ((iProperty.Get(oldValue) != KErrNone) || (oldValue != bytesTransferred))
- {
+ if ((iProperty.Get(oldValue) != KErrNone) || (oldValue != bytesTransferred))
+ {
#ifdef __PRINT3
- // trace of the bytes transferred
- for (TInt j=0; j < iArray.Count(); j++)
- {
- if(oldValue[j] != bytesTransferred[j])
- {
- __PRINT3(_L("CDrivePublisher: KBytes[%d] %d->%d\n"), j, oldValue[j], bytesTransferred[j]);
- }
- }
+ // trace of the bytes transferred
+ for (TInt j=0; j < iArray.Count(); j++)
+ {
+ if(oldValue[j] != bytesTransferred[j])
+ {
+ __PRINT3(_L("CDrivePublisher: KBytes[%d] %d->%d\n"), j, oldValue[j], bytesTransferred[j]);
+ }
+ }
#endif
- if (KErrNone != iProperty.Set(bytesTransferred))
- {
- __ASSERT_DEBUG(EFalse, User::Invariant());
- }
- dataTransferred = ETrue;
- }
+ if (KErrNone != iProperty.Set(bytesTransferred))
+ {
+ __ASSERT_DEBUG(EFalse, User::Invariant());
+ }
+ dataTransferred = ETrue;
+ }
- return dataTransferred;
- }
+ return dataTransferred;
+ }
/**
@@ -600,35 +573,31 @@
If the timer is not yet running then start it.
*/
void CUsbTransferPublisher::StartTimer()
- {
- __FNLOG("CUsbTransferPublisher::StartTimer");
-
- if (!iTimerRunning)
- {
- // EDataTransferred event every second
- const TTimeIntervalMicroSeconds32 interval = 1 * 1000 * 1000;
- TCallBack callback(PublishDataTransferredEvent, this);
- __PRINT(_L("Starting timer"));
- iTimer->Start(interval, interval, callback);
- iTimerRunning = ETrue;
- }
- }
+ {
+ if (!iTimerRunning)
+ {
+ // EDataTransferred event every second
+ const TTimeIntervalMicroSeconds32 interval = 1 * 1000 * 1000;
+ TCallBack callback(PublishDataTransferredEvent, this);
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVE, DRIVEPUBLISHER_120, "Starting timer");
+ iTimer->Start(interval, interval, callback);
+ iTimerRunning = ETrue;
+ }
+ }
/**
Ensure that the Timer is stopped
*/
void CUsbTransferPublisher::StopTimer()
- {
- __FNLOG("CUsbTransferPublisher::StopTimer");
-
- if (iTimerRunning)
- {
- __PRINT(_L("Stopping timer"));
- iTimer->Cancel();
- iTimerRunning = EFalse;
- }
- }
+ {
+ if (iTimerRunning)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_DRIVE, DRIVEPUBLISHER_130, "Stopping timer");
+ iTimer->Cancel();
+ iTimerRunning = EFalse;
+ }
+ }
//----------------------------------------------------------------------------
@@ -638,23 +607,21 @@
@param aArray
*/
CUsbWriteTransferPublisher* CUsbWriteTransferPublisher::NewL(TRefBytesTransferedList aArray)
- {
- __FNLOG("CUsbWriteTransferPublisher::NewL");
-
- CUsbWriteTransferPublisher* self = new (ELeave) CUsbWriteTransferPublisher(aArray);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ {
+ CUsbWriteTransferPublisher* self = new (ELeave) CUsbWriteTransferPublisher(aArray);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
CUsbWriteTransferPublisher::CUsbWriteTransferPublisher(
- TRefBytesTransferedList aArray)
- :
- CUsbTransferPublisher(EUsbMsDriveState_KBytesWritten, aArray)
- {
- }
+ TRefBytesTransferedList aArray)
+ :
+ CUsbTransferPublisher(EUsbMsDriveState_KBytesWritten, aArray)
+ {
+ }
//----------------------------------------------------------------------------
@@ -664,21 +631,19 @@
@param aArray
*/
CUsbReadTransferPublisher* CUsbReadTransferPublisher::NewL(TRefBytesTransferedList aArray)
- {
- __FNLOG("CUsbWriteTransferPublisher::NewL");
-
- CUsbReadTransferPublisher* self = new (ELeave) CUsbReadTransferPublisher(aArray);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ {
+ CUsbReadTransferPublisher* self = new (ELeave) CUsbReadTransferPublisher(aArray);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
CUsbReadTransferPublisher::CUsbReadTransferPublisher(
- TRefBytesTransferedList aArray)
- :
- CUsbTransferPublisher(EUsbMsDriveState_KBytesRead, aArray)
- {
- }
+ TRefBytesTransferedList aArray)
+ :
+ CUsbTransferPublisher(EUsbMsDriveState_KBytesRead, aArray)
+ {
+ }
#endif // USB_TRANSFER_PUBLISHER
--- a/userlibandfileserver/fileserver/smassstorage/inc/cactivedevicestatenotifierbase.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/cactivedevicestatenotifierbase.h Mon Oct 11 17:54:41 2010 +0100
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
@@ -11,59 +11,55 @@
*
* Contributors:
*
-* Description:
+* Description:
* Class declaration for Device State.Notifier Base Class
*
*/
-/**
+/**
@file
@internalTechnology
*/
#ifndef CACTIVEDEVICESTATENOTIFIERBASE_H
#define CACTIVEDEVICESTATENOTIFIERBASE_H
-#include <e32base.h>
-#include "cbulkonlytransport.h"
-#include "protocol.h"
-#include "cusbmassstoragecontroller.h"
class CActiveDeviceStateNotifierBase : public CActive
- {
+ {
public:
- // Construction
- static CActiveDeviceStateNotifierBase* NewL(CBulkOnlyTransport& aBot,
+ // Construction
+ static CActiveDeviceStateNotifierBase* NewL(CBulkOnlyTransport& aBot,
MLddDeviceStateNotification& aLddDeviceStateNotification);
- // Destruction
- ~CActiveDeviceStateNotifierBase();
+ // Destruction
+ ~CActiveDeviceStateNotifierBase();
- void Activate();
+ void Activate();
protected:
- // Construction
- CActiveDeviceStateNotifierBase(CBulkOnlyTransport& aBot,
+ // Construction
+ CActiveDeviceStateNotifierBase(CBulkOnlyTransport& aBot,
MLddDeviceStateNotification& aLddDeviceStateNotification);
- void ConstructL();
+ void ConstructL();
- // Cancel request.
- // Defined as pure virtual by CActive;
- // implementation provided by this class.
- virtual void DoCancel();
+ // Cancel request.
+ // Defined as pure virtual by CActive;
+ // implementation provided by this class.
+ virtual void DoCancel();
- // Service completed request.
- // Defined as pure virtual by CActive;
- // implementation provided by this class,
- virtual void RunL();
+ // Service completed request.
+ // Defined as pure virtual by CActive;
+ // implementation provided by this class,
+ virtual void RunL();
protected:
- CBulkOnlyTransport& iBot;
+ CBulkOnlyTransport& iBot;
MLddDeviceStateNotification& iLddDeviceStateNotification;
- TUint iDeviceState;
- TUint iOldDeviceState;
- };
+ TUint iDeviceState;
+ TUint iOldDeviceState;
+ };
#endif
--- a/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransport.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransport.h Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// Class declaration for CBulkOnlyTransport.
-//
+//
//
/**
@@ -24,22 +24,20 @@
#define __CBULKONLYTRANSPORT_H__
#include <e32std.h>
-#if !defined(__WINS__) && !defined(__X86__)
+#if !defined(__WINS__) && !defined(__X86__)
#include <d32usbcsc.h>
#endif
#include <d32usbc.h>
-#include "protocol.h"
-#include "cusbmassstoragecontroller.h"
-#include "mldddevicestatenotification.h"
+
static const TUint KCbwLength = 31;
static const TUint KCommandBufferLength = 36;
-// for control endpoint
+// for control endpoint
static const TUint KRequestHdrSize = 8;
/** size of buffer for command padding */
-static const TUint KBOTMaxBufSize = 512;
+static const TUint KBOTMaxBufSize = 512;
/** size of csw */
LOCAL_D const TInt KCswLength = 13;
@@ -49,168 +47,168 @@
Represent Endpoint0 request
*/
class TUsbRequestHdr
- {
+ {
public:
- enum TEp0Request
- {
- EReqGetMaxLun = 0xFE,
- EReqReset = 0xFF
- };
+ enum TEp0Request
+ {
+ EReqGetMaxLun = 0xFE,
+ EReqReset = 0xFF
+ };
public:
- TInt Decode(const TDesC8& aBuffer);
- TBool IsDataResponseRequired() const;
+ TInt Decode(const TDesC8& aBuffer);
+ TBool IsDataResponseRequired() const;
public:
- TUint8 iRequestType;
- TEp0Request iRequest;
- TUint16 iValue;
- TUint16 iIndex;
- TUint16 iLength;
- };
+ TUint8 iRequestType;
+ TEp0Request iRequest;
+ TUint16 iValue;
+ TUint16 iIndex;
+ TUint16 iLength;
+ };
/** handles the data transport and communications with the SCSI protocol */
class CBulkOnlyTransport : public CActive, public MTransportBase
- {
+ {
public:
- enum TCswStatus
- {
- ECommandPassed = 0,
- ECommandFailed = 1,
- EPhaseError = 2
- };
+ enum TCswStatus
+ {
+ ECommandPassed = 0,
+ ECommandFailed = 1,
+ EPhaseError = 2
+ };
- enum TTransportState
- {
- ENone,
- EWaitForCBW,
- ESendingCSW,
- EWritingData,
- EReadingData,
+ enum TTransportState
+ {
+ ENone,
+ EWaitForCBW,
+ ESendingCSW,
+ EWritingData,
+ EReadingData,
EPermErr
- };
+ };
public:
- static CBulkOnlyTransport* NewL(TInt aNumDrives,CUsbMassStorageController& aController, CUsbMassStorageController::TTransportldd aTransportLddFlag);
- static CBulkOnlyTransport* NewL(TInt aNumDrives,CUsbMassStorageController& aController);
+ static CBulkOnlyTransport* NewL(TInt aNumDrives,CUsbMassStorageController& aController, CUsbMassStorageController::TTransportldd aTransportLddFlag);
+ static CBulkOnlyTransport* NewL(TInt aNumDrives,CUsbMassStorageController& aController);
protected:
~CBulkOnlyTransport();
- CBulkOnlyTransport(TInt aNumDrives,CUsbMassStorageController& aController);
+ CBulkOnlyTransport(TInt aNumDrives,CUsbMassStorageController& aController);
public:
- TInt InitialiseTransportL(TInt aTransportLddFlag);
+ TInt InitialiseTransportL(TInt aTransportLddFlag);
- TInt Start();
- TInt Stop();
- void RegisterProtocol(MProtocolBase& aProtocol);
+ TInt Start();
+ TInt Stop();
+ void RegisterProtocol(MProtocolBase& aProtocol);
- CUsbMassStorageController& Controller();
- TInt MaxLun();
- void SetupReadData(TUint aLength);
- void SetupWriteData(TPtrC8& aData);
+ CUsbMassStorageController& Controller();
+ TInt MaxLun();
+ void SetupReadData(TUint aLength);
+ void SetupWriteData(TPtrC8& aData);
- void GetCommandBufPtr(TPtr8& aDes, TUint aLength); // Ptr to iCommandBuf to send responses to commands
- void GetReadDataBufPtr(TPtr8& aDes); // Ptr to DataBuf's
- void GetWriteDataBufPtr(TPtrC8& aDes);
+ void GetCommandBufPtr(TPtr8& aDes, TUint aLength); // Ptr to iCommandBuf to send responses to commands
+ void GetReadDataBufPtr(TPtr8& aDes); // Ptr to DataBuf's
+ void GetWriteDataBufPtr(TPtrC8& aDes);
#ifdef MSDC_MULTITHREADED
- void ProcessReadData(TAny* aAddress);
+ void ProcessReadData(TAny* aAddress);
#endif
- TInt HwStart(TBool aDiscard = EFalse);
- TInt HwStop();
+ TInt HwStart(TBool aDiscard = EFalse);
+ TInt HwStop();
void StopBulkOnlyEndpoint();
- TInt HwSuspend();
- TInt HwResume();
+ TInt HwSuspend();
+ TInt HwResume();
- virtual void RunL();
- virtual void DoCancel();
+ virtual void RunL();
+ virtual void DoCancel();
- virtual TInt SetupConfigurationDescriptor(TBool aUnset = EFalse) = 0;
- virtual TInt SetupInterfaceDescriptors() = 0;
- virtual void ReleaseInterface() = 0;
- virtual void CancelControlInterface() = 0;
- virtual TInt StartControlInterface() = 0;
- virtual void ActivateDeviceStateNotifier() = 0;
- virtual void CancelDeviceStateNotifier() = 0;
- virtual void CancelReadWriteRequests() = 0;
- virtual void AllocateEndpointResources() = 0;
- virtual TInt GetDeviceStatus(TUsbcDeviceState& deviceStatus) = 0;
- virtual void FlushData() = 0;
- virtual void ReadAndDiscardData(TInt aBytes) = 0;
- virtual void ReadCBW() = 0;
- virtual void ExpireData(TAny* aAddress = NULL) = 0;
- virtual void ProcessCbwEvent() = 0;
- virtual void StallEndpointAndWaitForClear() = 0;
- virtual void ReadData(TUint aLength = 0) = 0;
- virtual void WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse) = 0;
- virtual void SetCbwPtr() = 0;
- virtual TPtr8& SetCommandBufPtr(TUint aLength) = 0; // pointer to buf for sending responses to commands
- virtual TPtr8& SetDataBufPtr() = 0; // to swap between the two buffers
- virtual void SetPaddingBufPtr(TUint aLength) = 0;
- virtual void SetCswBufPtr(TUint aLength) = 0;
- virtual void ProcessReadingDataEvent() = 0;
- virtual void DiscardData(TUint aLength) = 0;
- virtual void WriteToClient(TUint aLength) = 0;
- virtual void SetReadDataBufPtr( TUint aLength) = 0;
+ virtual TInt SetupConfigurationDescriptor(TBool aUnset = EFalse) = 0;
+ virtual TInt SetupInterfaceDescriptors() = 0;
+ virtual void ReleaseInterface() = 0;
+ virtual void CancelControlInterface() = 0;
+ virtual TInt StartControlInterface() = 0;
+ virtual void ActivateDeviceStateNotifier() = 0;
+ virtual void CancelDeviceStateNotifier() = 0;
+ virtual void CancelReadWriteRequests() = 0;
+ virtual void AllocateEndpointResources() = 0;
+ virtual TInt GetDeviceStatus(TUsbcDeviceState& deviceStatus) = 0;
+ virtual void FlushData() = 0;
+ virtual void ReadAndDiscardData(TInt aBytes) = 0;
+ virtual void ReadCBW() = 0;
+ virtual void ExpireData(TAny* aAddress = NULL) = 0;
+ virtual void ProcessCbwEvent() = 0;
+ virtual void StallEndpointAndWaitForClear() = 0;
+ virtual void ReadData(TUint aLength = 0) = 0;
+ virtual void WriteUsb(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse) = 0;
+ virtual void SetCbwPtr() = 0;
+ virtual TPtr8& SetCommandBufPtr(TUint aLength) = 0; // pointer to buf for sending responses to commands
+ virtual TPtr8& SetDataBufPtr() = 0; // to swap between the two buffers
+ virtual void SetPaddingBufPtr(TUint aLength) = 0;
+ virtual void SetCswBufPtr(TUint aLength) = 0;
+ virtual void ProcessReadingDataEvent() = 0;
+ virtual void DiscardData(TUint aLength) = 0;
+ virtual void WriteToClient(TUint aLength) = 0;
+ virtual void SetReadDataBufPtr( TUint aLength) = 0;
#ifdef MSDC_MULTITHREADED
- virtual void GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2) = 0;
+ virtual void GetBufferPointers(TPtr8& aDes1, TPtr8& aDes2) = 0;
#endif
protected:
- void DecodeCBW();
- TBool CheckCBW();
- void SetPermError();
- void SendCSW(TUint aTag, TUint aDataResidue, TCswStatus aStatus);
- void WriteData(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse);
+ void DecodeCBW();
+ TBool CheckCBW();
+ void SetPermError();
+ void SendCSW(TUint aTag, TUint aDataResidue, TCswStatus aStatus);
+ void WriteData(TRequestStatus& aStatus, TPtrC8& aDes, TUint aLength, TBool aZlpRequired = EFalse);
- void CallReadAndDiscardData(TInt aBytes);
- void Activate(TInt aReason);
+ void CallReadAndDiscardData(TInt aBytes);
+ void Activate(TInt aReason);
protected:
- /** maximun logic unit number supported (started from 0*/
- TInt iMaxLun;
+ /** maximun logic unit number supported (started from 0*/
+ TInt iMaxLun;
- CUsbMassStorageController& iController;
+ CUsbMassStorageController& iController;
- MProtocolBase* iProtocol;
+ MProtocolBase* iProtocol;
- TTransportState iCurrentState;
+ TTransportState iCurrentState;
- /** Shows how much data was not send/received */
- TUint32 iDataResidue;
- TUint32 iCbwTag;
- TCswStatus iCmdStatus;
+ /** Shows how much data was not send/received */
+ TUint32 iDataResidue;
+ TUint32 iCbwTag;
+ TCswStatus iCmdStatus;
- /** Indicate if SCSI prot has data to sent */
- TBool iWriteSetUp;
+ /** Indicate if SCSI prot has data to sent */
+ TBool iWriteSetUp;
- /** Indicate if SCSI prot expected additional data */
- TBool iReadSetUp;
+ /** Indicate if SCSI prot expected additional data */
+ TBool iReadSetUp;
- /** Indicate whether SCSI prot started or not */
- TBool iStarted;
+ /** Indicate whether SCSI prot started or not */
+ TBool iStarted;
- TBool iStallAllowed;
+ TBool iStallAllowed;
- TBool iInterfaceConfigured;
+ TBool iInterfaceConfigured;
- TPtr8 iCommandBufPtr; // Ptr to buffer to write responses to commands
- TPtr8 iDataBufPtr;
- TPtr8 iCswBufPtr;
- TPtr8 iPaddingBufPtr;
+ TPtr8 iCommandBufPtr; // Ptr to buffer to write responses to commands
+ TPtr8 iDataBufPtr;
+ TPtr8 iCswBufPtr;
+ TPtr8 iPaddingBufPtr;
- /** Size of data, Used to tell transport how much protocol/media has to send */
- TUint iBufSize;
+ /** Size of data, Used to tell transport how much protocol/media has to send */
+ TUint32 iBufSize;
- TPtrC8 iWriteBufPtr;
+ TPtrC8 iWriteBufPtr;
- TPtr8 iReadBufPtr;
+ TPtr8 iReadBufPtr;
- /** Internal TPtr to check validity of and decode CBW */
- TPtrC8 iCbwBufPtr;
- };
+ /** Internal TPtr to check validity of and decode CBW */
+ TPtrC8 iCbwBufPtr;
+ };
#endif // __CBULKONLYTRANSPORT_H__
--- a/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransportusbcldd.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/cbulkonlytransportusbcldd.h Mon Oct 11 17:54:41 2010 +0100
@@ -28,9 +28,6 @@
#include "cbulkonlytransport.h"
#include "cactivedevicestatenotifierbase.h"
-// Maximum size for SCSI Read10 Write10 and Verify10 commands
-// Windows requests size of 64K whereas MAC requests size of 128K
-static const TUint32 KMaxBufSize = 128 * 1024;
//Forward Declaration
class CBulkOnlyTransportUsbcLdd;
@@ -138,11 +135,8 @@
TBuf8<KCommandBufferLength> iCommandBuf; // For Responses to commands
- TBuf8<KMaxBufSize> iDataBuf1; // For data transfers (Reading and Writing)
+ TBulkMm iBulkMm;
- TBuf8<KMaxBufSize> iDataBuf2;
-
- TBool iSwap;
/** internal buffer for CSW */
TBuf8<KCswLength> iCswBuf;
--- a/userlibandfileserver/fileserver/smassstorage/inc/cusbmassstoragecontroller.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/cusbmassstoragecontroller.h Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// Class declaration for CUsbMassStorageController.
-//
+//
//
/**
@@ -23,11 +23,10 @@
#ifndef __CUSBMASSSTORAGECONTROLLER_H__
#define __CUSBMASSSTORAGECONTROLLER_H__
-#include <e32base.h>
-#include <usbmsshared.h>
-#include "drivemanager.h"
-#include "cusbmassstorageserver.h"
-#include "protocol.h"
+
+class MTransportBase;
+class MProtocolBase;
+class CUsbMassStorageServer;
/**
Mass Storage Controller class.
@@ -35,25 +34,25 @@
Its main purpose is to instantiate and initialize these objects.
*/
class CUsbMassStorageController : public CBase
- {
- public:
- ~CUsbMassStorageController();
- void CreateL(RArray<TInt>& aDriveMapping);
- CDriveManager& DriveManager();
- TInt Start(TMassStorageConfig& aConfig);
- TInt Stop();
- void Reset();
- void GetTransport(MTransportBase* &aTransport);
- enum TTransportldd {EUsbc = 1, EUsbcsc};
-
- private:
- CDriveManager* iDriveManager;
- MTransportBase* iTransport;
- MProtocolBase* iProtocol;
- CUsbMassStorageServer* iServer;
- TMassStorageConfig iConfig;
- TInt iMaxDrives;
- TTransportldd iTransportLddFlag;
- };
+ {
+public:
+ ~CUsbMassStorageController();
+ void CreateL(RArray<TInt>& aDriveMapping);
+ CDriveManager& DriveManager();
+ TInt Start(TMassStorageConfig& aConfig);
+ TInt Stop();
+ void Reset();
+ void GetTransport(MTransportBase* &aTransport);
+ enum TTransportldd {EUsbc = 1, EUsbcsc};
+
+private:
+ CDriveManager* iDriveManager;
+ MTransportBase* iTransport;
+ MProtocolBase* iProtocol;
+ CUsbMassStorageServer* iServer;
+ TMassStorageConfig iConfig;
+ TInt iMaxDrives;
+ TTransportldd iTransportLddFlag;
+ };
#endif //__CUSBMASSSTORAGECONTROLLER_H__
--- a/userlibandfileserver/fileserver/smassstorage/inc/cusbmassstorageserver.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/cusbmassstorageserver.h Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// Implements a Symbian OS server that exposes the RUsbMassStorage API
-//
+//
//
/**
@@ -23,21 +23,6 @@
#ifndef __CUSBMASSSTORAGESERVER_H__
#define __CUSBMASSSTORAGESERVER_H__
-#include "massstoragedebug.h"
-
-
-_LIT(KUsbMsSvrPncCat, "CUsbMsServer");
-
-enum TUsbPanicServer
- {
- EMsCBulkOnlyTransportNull = 300,
- EMsCDeviceStateNotifierNull,
- EMsClientInvalidSessCount,
- EMsControlInterfaceBadState,
- EMsControlInterfaceStillActive,
- EMsBulkOnlyStillActive,
- EMsWrongEndpoint
- };
//
// Forward declarations
@@ -49,28 +34,28 @@
Implements a Symbian OS server that exposes the RUsbMassStorage API
*/
class CUsbMassStorageServer : public CPolicyServer
- {
+ {
public:
- static CUsbMassStorageServer* NewLC(CUsbMassStorageController& aController);
- virtual ~CUsbMassStorageServer();
+ static CUsbMassStorageServer* NewLC(CUsbMassStorageController& aController);
+ virtual ~CUsbMassStorageServer();
- virtual CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const;
- void Error(TInt aError);
+ virtual CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const;
+ void Error(TInt aError);
- inline CUsbMassStorageController& Controller() const;
+ inline CUsbMassStorageController& Controller() const;
- void IncrementSessionCount();
- void DecrementSessionCount();
- inline TInt SessionCount() const;
+ void IncrementSessionCount();
+ void DecrementSessionCount();
+ inline TInt SessionCount() const;
protected:
- CUsbMassStorageServer(CUsbMassStorageController& aController);
- void ConstructL();
-
+ CUsbMassStorageServer(CUsbMassStorageController& aController);
+ void ConstructL();
+
private:
- CUsbMassStorageController& iController;
- TInt iSessionCount;
- };
+ CUsbMassStorageController& iController;
+ TInt iSessionCount;
+ };
#include "cusbmassstorageserver.inl"
--- a/userlibandfileserver/fileserver/smassstorage/inc/cusbmassstoragesession.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/cusbmassstoragesession.h Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -12,7 +12,7 @@
//
// Description:
// Implements a Session of a Symbian OS server for the RUsbMassStorage API
-//
+//
//
/**
@@ -23,10 +23,6 @@
#ifndef __CUSBMASSSTORAGESESSION_H__
#define __CUSBMASSSTORAGESESSION_H__
-#include <e32std.h>
-#include <e32base.h>
-#include "massstoragedebug.h"
-#include "usbmsshared.h"
_LIT(KUsbMsCliPncCat, "UsbMs-Client");
@@ -44,29 +40,29 @@
Implements a Session of a Symbian OS server for the RUsbMassStorage API
*/
class CUsbMassStorageSession : public CSession2
- {
+ {
public:
- static CUsbMassStorageSession* NewL(CUsbMassStorageServer& aServer);
- virtual ~CUsbMassStorageSession();
+ static CUsbMassStorageSession* NewL(CUsbMassStorageServer& aServer);
+ virtual ~CUsbMassStorageSession();
- // CSession
- virtual void ServiceL(const RMessage2& aMessage);
+ // CSession
+ virtual void ServiceL(const RMessage2& aMessage);
protected:
- CUsbMassStorageSession(CUsbMassStorageServer& aServer);
- void ConstructL();
+ CUsbMassStorageSession(CUsbMassStorageServer& aServer);
+ void ConstructL();
- void DispatchMessageL(const RMessage2& aMessage);
- TInt Start(const RMessage2& aMessage);
- TInt Stop();
- TInt Shutdown();
+ void DispatchMessageL(const RMessage2& aMessage);
+ TInt Start(const RMessage2& aMessage);
+ TInt Stop();
+ TInt Shutdown();
private:
- void GetMsConfigL(const RMessage2& aMessage, TMassStorageConfig& aMsStorage);
-
+ void GetMsConfigL(const RMessage2& aMessage, TMassStorageConfig& aMsStorage);
+
private:
- CUsbMassStorageServer& iUsbMsServer;
- };
+ CUsbMassStorageServer& iUsbMsServer;
+ };
#endif //__CUSBMASSSTORAGESESSION_H__
--- a/userlibandfileserver/fileserver/smassstorage/inc/massstoragedebug.h Wed Oct 06 17:13:14 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/**
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-* Class declaration for MassStorageDebug
-*
-*
-*/
-
-
-
-/**
- @file
-*/
-
-#ifndef __MASSSTORAGEDEBUG_H__
-#define __MASSSTORAGEDEBUG_H__
-
-#include <e32std.h>
-#include <e32svr.h>
-
-//#define _USBMS_DEBUG_PRINT_
-
-// Display some info during IN double-buffering
-//#define PRINT_MSDC_MULTITHREADED_READ_INFO
-
-
-#if defined(_USBMS_DEBUG_PRINT_) && (defined(_DEBUG) || defined(_DEBUG_RELEASE))
-#define __PRINT(t) {RDebug::Print(t);}
-#define __PRINT1(t,a) {RDebug::Print(t,a);}
-#define __PRINT2(t,a,b) {RDebug::Print(t,a,b);}
-#define __PRINT3(t,a,b,c) {RDebug::Print(t,a,b,c);}
-#define __PRINT4(t,a,b,c,d) {RDebug::Print(t,a,b,c,d);}
-#define __PRINT5(t,a,b,c,d,e) {RDebug::Print(t,a,b,c,d,e);}
-#define __PRINT8BIT1(t,a) {TFileName temp;temp.Copy(a);RDebug::Print(t,&temp);}
-#define __PRINT1TEMP(t,a) {TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}
-#define __PRINTERR(txt, err) {if(KErrNone != err) __PRINT1(txt, err);}
-
-_LIT(KMsgIn, ">>%S\n");
-_LIT(KMsgOut,"<<%S\n");
-
-class TMSLogFn
-{
- protected:
- TBuf<100> iName;
-
- public:
- TMSLogFn(const TDesC& aName){iName = aName; RDebug::Print(KMsgIn, &iName);};
- ~TMSLogFn(){RDebug::Print(KMsgOut, &iName);};
-};
-
-#define __FNLOG(name) TMSLogFn __fn_log__(_L(name))
-
-#else
-#define __PRINT(t)
-#define __PRINT1(t,a)
-#define __PRINT2(t,a,b)
-#define __PRINT3(t,a,b,c)
-#define __PRINT4(t,a,b,c,d)
-#define __PRINT5(t,a,b,c,d,e)
-#define __PRINT8BIT1(t,a)
-#define __PRINT1TEMP(t,a)
-#define __PRINTERR(txt,err)
-#define __FNLOG(name)
-#endif
-
-#endif // __MASSSTORAGEDEBUG_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/userlibandfileserver/fileserver/smassstorage/inc/mprotocol.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,48 @@
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MPROTOCOL_H
+#define MPROTOCOL_H
+
+#include <e32base.h> // C Class Definitions, Cleanup Stack
+#include <e32def.h> // T Type Definitions
+#include <e32std.h> // ELeave definition
+#include "usbmsshared.h"
+
+
+class MTransportBase;
+
+class MProtocolBase
+ {
+ public:
+ virtual void RegisterTransport(MTransportBase* aTransport) = 0;
+ virtual TBool DecodePacket(TPtrC8& aData, TUint aLun) = 0;
+ virtual TInt ReadComplete(TInt aError) = 0;
+ virtual TInt Cancel() = 0;
+ virtual void ReportHighSpeedDevice() {};
+ virtual ~MProtocolBase() {};
+#ifdef MSDC_MULTITHREADED
+ virtual void InitializeBufferPointers(TPtr8& aDes1, TPtr8& aDes2) = 0;
+#endif
+ };
+
+
+#endif // __PROTOCOL_H__
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/userlibandfileserver/fileserver/smassstorage/inc/mtransport.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,48 @@
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef MTRANSPORT_H
+#define MTRANSPORT_H
+
+
+class MProtocolBase;
+
+class MTransportBase
+ {
+ public:
+ virtual void SetupWriteData(TPtrC8& aData) = 0;
+ virtual TInt Start() = 0;
+ virtual TInt Stop() = 0;
+ virtual void RegisterProtocol(MProtocolBase& aProtocol) = 0;
+ virtual TInt BytesAvailable() = 0;
+ virtual ~MTransportBase() {};
+ virtual TInt InitialiseTransportL(TInt aTransportLddFlag) = 0;
+ virtual void SetupReadData(TUint aLength) = 0;
+ virtual void GetCommandBufPtr(TPtr8& aDes, TUint aLength) = 0;
+ virtual void GetReadDataBufPtr(TPtr8& aDes) = 0;
+ virtual void GetWriteDataBufPtr(TPtrC8& aDes) = 0;
+#ifdef MSDC_MULTITHREADED
+ virtual void ProcessReadData(TAny* aAddress) = 0;
+#endif
+ };
+
+
+#endif // MTRANSPORT_H
+
--- a/userlibandfileserver/fileserver/smassstorage/inc/protocol.h Wed Oct 06 17:13:14 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-//
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-//
-// Contributors:
-//
-// Description:
-//
-
-/**
- @file
- @internalTechnology
-*/
-
-#ifndef __PROTOCOL_H__
-#define __PROTOCOL_H__
-
-#include <e32base.h> // C Class Definitions, Cleanup Stack
-#include <e32def.h> // T Type Definitions
-#include <e32std.h> // ELeave definition
-#include "usbmsshared.h"
-
-
-class MProtocolBase;
-
-class MTransportBase
- {
- public:
- virtual void SetupWriteData(TPtrC8& aData) = 0;
- virtual TInt Start() = 0;
- virtual TInt Stop() = 0;
- virtual void RegisterProtocol(MProtocolBase& aProtocol) = 0;
- virtual TInt BytesAvailable() = 0;
- virtual ~MTransportBase() {};
- virtual TInt InitialiseTransportL(TInt aTransportLddFlag) = 0;
- virtual void SetupReadData(TUint aLength) = 0;
- virtual void GetCommandBufPtr(TPtr8& aDes, TUint aLength) = 0;
- virtual void GetReadDataBufPtr(TPtr8& aDes) = 0;
- virtual void GetWriteDataBufPtr(TPtrC8& aDes) = 0;
-#ifdef MSDC_MULTITHREADED
- virtual void ProcessReadData(TAny* aAddress) = 0;
-#endif
- };
-
-
-class MProtocolBase
- {
- public:
- virtual void RegisterTransport(MTransportBase* aTransport) = 0;
- virtual TBool DecodePacket(TPtrC8& aData, TUint aLun) = 0;
- virtual TInt ReadComplete(TInt aError) = 0;
- virtual TInt Cancel() = 0;
- virtual void ReportHighSpeedDevice() {};
- virtual ~MProtocolBase() {};
-#ifdef MSDC_MULTITHREADED
- virtual void InitializeBufferPointers(TPtr8& aDes1, TPtr8& aDes2) = 0;
-#endif
- };
-
-
-#endif // __PROTOCOL_H__
-
--- a/userlibandfileserver/fileserver/smassstorage/inc/rwdrivethread.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/rwdrivethread.h Mon Oct 11 17:54:41 2010 +0100
@@ -186,7 +186,6 @@
public:
TBool ReadDriveData(CMassStorageDrive* aDrive, const TInt64& aOffset, TUint32 aLength, TBool aIgnoreCache);
- void DiscardRead();
private:
static TInt ThreadFunction(TAny* aSelf);
--- a/userlibandfileserver/fileserver/smassstorage/inc/scsiprot.h Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/inc/scsiprot.h Mon Oct 11 17:54:41 2010 +0100
@@ -12,7 +12,7 @@
//
// Description:
// SCSI Protocol layer for USB Mass Storage
-//
+//
//
/**
@@ -26,12 +26,12 @@
// Header files
#include "drivemanager.h"
-#include "protocol.h"
+
// Define MSDC_MULTITHREADED to use Mass Storage multi-threaded (Double-buffering) disk read/writes.
// smassstorage_db.mmp defines this macro.
-#if defined MSDC_MULTITHREADED
+#if defined MSDC_MULTITHREADED
class CWriteDriveThread;
class CReadDriveThread;
#endif
@@ -58,81 +58,81 @@
Sense Info
*/
class TSenseInfo
- {
+ {
public:
- // Spec: SCSI Primary Commands 3 (SPC-3)
- // Section 4.5.6 Sense key and sense code defintions
- // Table 27 - Sense key descriptions
- enum TSenseCode
- {
- ENoSense = 0,
- ERecoveredError = 1,
- ENotReady = 2,
- EMediumError = 3,
- EHardwareError = 4,
- EIllegalRequest = 5,
- EUnitAttention = 6,
- EDataProtection = 7,
- EBlankCheck = 8,
- EVendorSpecific = 9,
- ECopyAborted = 10,
- EAbortedCommand = 11,
- EDataOverflow = 13,
- EMisCompare = 14
- };
+ // Spec: SCSI Primary Commands 3 (SPC-3)
+ // Section 4.5.6 Sense key and sense code defintions
+ // Table 27 - Sense key descriptions
+ enum TSenseCode
+ {
+ ENoSense = 0,
+ ERecoveredError = 1,
+ ENotReady = 2,
+ EMediumError = 3,
+ EHardwareError = 4,
+ EIllegalRequest = 5,
+ EUnitAttention = 6,
+ EDataProtection = 7,
+ EBlankCheck = 8,
+ EVendorSpecific = 9,
+ ECopyAborted = 10,
+ EAbortedCommand = 11,
+ EDataOverflow = 13,
+ EMisCompare = 14
+ };
- // Table 28 - ASC and ASQ assignments
- enum TAdditionalCode
- {
- EAscNull = 0x00,
- EAscLogicalUnitNotReady = 0x04,
- EAscLogicalUnitDoesNotRespondToSelection = 0x05,
- EInvalidCmdCode = 0x20,
- ELbaOutOfRange = 0x21,
- EInvalidFieldInCdb = 0x24,
- ELuNotSupported = 0x25,
- EWriteProtected = 0x27,
- ENotReadyToReadyChange = 0x28,
- EMediaNotPresent = 0x3A,
- EInsufficientRes = 0x55
- };
+ // Table 28 - ASC and ASQ assignments
+ enum TAdditionalCode
+ {
+ EAscNull = 0x00,
+ EAscLogicalUnitNotReady = 0x04,
+ EAscLogicalUnitDoesNotRespondToSelection = 0x05,
+ EInvalidCmdCode = 0x20,
+ ELbaOutOfRange = 0x21,
+ EInvalidFieldInCdb = 0x24,
+ ELuNotSupported = 0x25,
+ EWriteProtected = 0x27,
+ ENotReadyToReadyChange = 0x28,
+ EMediaNotPresent = 0x3A,
+ EInsufficientRes = 0x55
+ };
- enum TAdditionalSenseCodeQualifier
- {
- EAscqNull = 0x00,
- EAscqLogicalUnitIsInProcessOfBecomingReady = 0x01
- };
+ enum TAdditionalSenseCodeQualifier
+ {
+ EAscqNull = 0x00,
+ EAscqLogicalUnitIsInProcessOfBecomingReady = 0x01
+ };
public:
- TSenseInfo();
+ TSenseInfo();
- void SetSense(TSenseCode aSenseCode);
+ void SetSense(TSenseCode aSenseCode);
- void SetSense(TSenseCode aSenseCode,
- TAdditionalCode aAdditional);
+ void SetSense(TSenseCode aSenseCode,
+ TAdditionalCode aAdditional);
- void SetSense(TSenseCode aSenseCode,
- TAdditionalCode aAdditional,
- TAdditionalSenseCodeQualifier aQualifier);
+ void SetSense(TSenseCode aSenseCode,
+ TAdditionalCode aAdditional,
+ TAdditionalSenseCodeQualifier aQualifier);
- TBool SenseOk();
+ TBool SenseOk();
public:
- TUint8 iSenseCode;
- TUint8 iAdditional;
- TUint8 iQualifier;
- };
+ TUint8 iSenseCode;
+ TUint8 iAdditional;
+ TUint8 iQualifier;
+ };
/**
-Returns EFalse if a sense code has been set.
+Returns EFalse if a sense code has been set.
Note that ENoSense indicates that there is no specific sense key infotmation
-to be reported and the command was successful.
+to be reported and the command was successful.
*/
inline TBool TSenseInfo::SenseOk()
- {
- return (iSenseCode == ENoSense);
- }
+ {
+ return (iSenseCode == ENoSense);
+ }
const TUint KModeSense6CommandLength = 4;
@@ -150,126 +150,126 @@
@internalTechnology
*/
class CScsiProtocol : public CBase, public MProtocolBase
- {
+ {
public:
- enum TCommand
- {
- ETestUnitReady = 0x00,
- ERequestSense = 0x03,
- EInquiry = 0x12,
- EModeSense6 = 0x1A,
- EStartStopUnit = 0x1B,
- EPreventMediaRemoval = 0x1E,
- EReadFormatCapacities = 0x23,
- EReadCapacity = 0x25,
- ERead10 = 0x28,
- EWrite10 = 0x2A,
- EVerify10 = 0x2f,
- EModeSense10 = 0x5A,
- EUndefinedCommand = 0xFF
- };
+ enum TCommand
+ {
+ ETestUnitReady = 0x00,
+ ERequestSense = 0x03,
+ EInquiry = 0x12,
+ EModeSense6 = 0x1A,
+ EStartStopUnit = 0x1B,
+ EPreventMediaRemoval = 0x1E,
+ EReadFormatCapacities = 0x23,
+ EReadCapacity = 0x25,
+ ERead10 = 0x28,
+ EWrite10 = 0x2A,
+ EVerify10 = 0x2f,
+ EModeSense10 = 0x5A,
+ EUndefinedCommand = 0xFF
+ };
public:
- static CScsiProtocol* NewL(CDriveManager& aDriveManager);
- void RegisterTransport(MTransportBase* aTransport);
- void ReportHighSpeedDevice();
- TBool DecodePacket(TPtrC8& aData, TUint aLun);
- TInt ReadComplete(TInt aError);
- TInt SetScsiParameters(TMassStorageConfig aConfig);
- TInt Cancel();
- ~CScsiProtocol();
+ static CScsiProtocol* NewL(CDriveManager& aDriveManager);
+ void RegisterTransport(MTransportBase* aTransport);
+ void ReportHighSpeedDevice();
+ TBool DecodePacket(TPtrC8& aData, TUint aLun);
+ TInt ReadComplete(TInt aError);
+ TInt SetScsiParameters(TMassStorageConfig aConfig);
+ TInt Cancel();
+ ~CScsiProtocol();
#ifdef MSDC_MULTITHREADED
- void InitializeBufferPointers(TPtr8& aDes1, TPtr8& aDes2);
- static void ProcessWriteComplete (TUint8* aAddress, TAny* aPtr); //todo const
+ void InitializeBufferPointers(TPtr8& aDes1, TPtr8& aDes2);
+ static void ProcessWriteComplete (TUint8* aAddress, TAny* aPtr); //todo const
#endif
private:
- CScsiProtocol(CDriveManager& aDriveManager);
- void ConstructL();
- CMassStorageDrive* GetCheckDrive(TUint aLun);
- TBool HandleUnitReady(TUint aLun);
- TBool HandleRequestSense(TPtrC8& aData);
- TBool HandleInquiry(TPtrC8& aData, TUint aLun);
- TBool HandleStartStopUnit(TPtrC8& aData, TUint aLun);
- TBool HandlePreventMediaRemoval(TPtrC8& aData, TUint aLun);
- TBool HandleReadCapacity(TPtrC8& aData, TUint aLun);
- TBool HandleRead10(TPtrC8& aData, TUint aLun);
- TBool HandleWrite10(TPtrC8& aData, TUint aLun);
- TBool HandleVerify10(TPtrC8& aData, TUint aLun);
- TBool HandleModeSense6(TPtrC8& aData, TUint aLun);
+ CScsiProtocol(CDriveManager& aDriveManager);
+ void ConstructL();
+ CMassStorageDrive* GetCheckDrive(TUint aLun);
+ TBool HandleUnitReady(TUint aLun);
+ TBool HandleRequestSense(TPtrC8& aData);
+ TBool HandleInquiry(TPtrC8& aData, TUint aLun);
+ TBool HandleStartStopUnit(TPtrC8& aData, TUint aLun);
+ TBool HandlePreventMediaRemoval(TPtrC8& aData, TUint aLun);
+ TBool HandleReadCapacity(TPtrC8& aData, TUint aLun);
+ TBool HandleRead10(TPtrC8& aData, TUint aLun);
+ TBool HandleWrite10(TPtrC8& aData, TUint aLun);
+ TBool HandleVerify10(TPtrC8& aData, TUint aLun);
+ TBool HandleModeSense6(TPtrC8& aData, TUint aLun);
TBool HandleModeSense10(TPtrC8& aData, TUint aLun);
- TBool HandleReadFormatCapacities(TUint aLun);
+ TBool HandleReadFormatCapacities(TUint aLun);
private:
- /** Configuration data for INQUIRY command*/
- TMassStorageConfig iConfig;
+ /** Configuration data for INQUIRY command*/
+ TMassStorageConfig iConfig;
+
+ /** reference to the Drive Manager */
+ CDriveManager& iDriveManager;
- /** reference to the Drive Manager */
- CDriveManager& iDriveManager;
-
- /** pointer to the transport level */
- MTransportBase* iTransport;
+ /** pointer to the transport level */
+ MTransportBase* iTransport;
- /** Sense Info */
- TSenseInfo iSenseInfo;
+ /** Sense Info */
+ TSenseInfo iSenseInfo;
#ifdef MSDC_MULTITHREADED
- /** Sense Info */
- TSenseInfo iDeferredSenseInfo;
+ /** Sense Info */
+ TSenseInfo iDeferredSenseInfo;
#endif
- /** Start offset (in bytes) for Write/Verify */
- TInt64 iOffset;
+ /** Start offset (in bytes) for Write/Verify */
+ TInt64 iOffset;
- /** Last command for SetupRead (Write or Verify) */
- TUint8 iLastCommand;
+ /** Last command for SetupRead (Write or Verify) */
+ TUint8 iLastCommand;
- /** LUN for SetupRead */
- TUint iLastLun;
+ /** LUN for SetupRead */
+ TUint iLastLun;
#ifdef SIMDISK
- CArrayFixFlat<TUint8>* iSimDisk;
+ CArrayFixFlat<TUint8>* iSimDisk;
#endif
- /** The number of bytes remaining to be read from the host for write operations */
- TUint32 iBytesRemain;
+ /** The number of bytes remaining to be read from the host for write operations */
+ TUint32 iBytesRemain;
- /** Write to the media when this amount of data is available */
- TUint32 iMediaWriteSize;
+ /** Write to the media when this amount of data is available */
+ TUint32 iMediaWriteSize;
#ifdef MSDC_MULTITHREADED
- /** Ptr to Write Thread instance */
- CWriteDriveThread* iWriteDriveThread;
+ /** Ptr to Write Thread instance */
+ CWriteDriveThread* iWriteDriveThread;
- /** Ptr to Read Thread instance */
- CReadDriveThread* iReadDriveThread;
+ /** Ptr to Read Thread instance */
+ CReadDriveThread* iReadDriveThread;
#endif // MSDC_MULTITHREADED
#ifdef USB_TRANSFER_PUBLISHER
- /**
- Publish and subscribe properties for tracking data transfer volume
- */
- CUsbWriteTransferPublisher* iWriteTransferPublisher;
- CUsbReadTransferPublisher* iReadTransferPublisher;
+ /**
+ Publish and subscribe properties for tracking data transfer volume
+ */
+ CUsbWriteTransferPublisher* iWriteTransferPublisher;
+ CUsbReadTransferPublisher* iReadTransferPublisher;
- /**
- Cumulative bytes read
- */
- TFixedArray<TInt64, KUsbMsMaxDrives> iBytesRead;
- /**
- Cumulative bytes written
- */
- TFixedArray<TInt64, KUsbMsMaxDrives> iBytesWritten;
+ /**
+ Cumulative bytes read
+ */
+ TFixedArray<TInt64, KUsbMsMaxDrives> iBytesRead;
+ /**
+ Cumulative bytes written
+ */
+ TFixedArray<TInt64, KUsbMsMaxDrives> iBytesWritten;
#else
- /**
- Publish and subscribe properties for tracking data transfer volume
- */
- CDriveWriteTransferPublisher* iWriteTransferPublisher;
- CDriveReadTransferPublisher* iReadTransferPublisher;
+ /**
+ Publish and subscribe properties for tracking data transfer volume
+ */
+ CDriveWriteTransferPublisher* iWriteTransferPublisher;
+ CDriveReadTransferPublisher* iReadTransferPublisher;
#endif
- };
+ };
#endif // __SCSIPROT_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/userlibandfileserver/fileserver/smassstorage/inc/smassstorage.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,48 @@
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// CDriveManager and CMassStorageDrive classes for USB Mass Storage.
+//
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef SMASSSTORAGE_H
+#define SMASSSTORAGE_H
+
+_LIT(KUsbMsSvrPncCat, "CUsbMsServer");
+
+enum TUsbPanicServer
+ {
+ EMsCBulkOnlyTransportNull = 3300,
+ EMsCDeviceStateNotifierNull,
+ EMsClientInvalidSessCount,
+ EMsControlInterfaceBadState,
+ EMsControlInterfaceStillActive,
+ EMsBulkOnlyStillActive,
+ EMsWrongEndpoint,
+ EMsInvalidLun,
+ EMsThreadWriteToDrive = 3400,
+ EMsThreadIsRecentlyWritten,
+ EMsThreadReadDriveThread,
+ EMsCMassStorageDriveWrite = 3500,
+ EMsCMassStorageDriveSetMountState_iLocalDrive,
+ EMsCMassStorageDriveSetMountState_aLocalDrive,
+ EMsCMassStorageDriveSetDriveState_State,
+ EMsCMassStorageDriveSetDriveState_Mount
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/userlibandfileserver/fileserver/smassstorage/inc/tbulkmm.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Class declaration for CBulkOnlyTransportUsbcLdd.
+*
+*/
+
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef TBULKMM_H
+#define TBULKMM_H
+
+// Maximum size for SCSI Read10 Write10 and Verify10 commands
+// Windows requests size of 64K whereas MAC requests size of 128K
+static const TUint32 KMaxBufSize = 128 * 1024;
+
+#ifdef MSDC_MULTITHREADED
+class TBulkMm
+{
+public:
+ TBulkMm();
+ void GetNextTransferBuffer(TUint aLength, TPtr8& aPtr);
+ void GetNextTransferBuffer(TPtr8& aPtr);
+
+ TUint MaxTransferSize() const {return KMaxBufSize;}
+
+ TUint8* Buf1();
+ TUint8* Buf2();
+
+private:
+ TBuf8<KMaxBufSize> iDataBuf1; // For data transfers (Reading and Writing)
+ TBuf8<KMaxBufSize> iDataBuf2;
+
+ TBool iSwap;
+};
+
+#else
+
+class TBulkMm
+{
+public:
+ TBulkMm() {};
+
+ void GetNextTransferBuffer(TUint aLength, TPtr8& aPtr);
+ void GetNextTransferBuffer(TPtr8& aPtr);
+
+ TUint MaxTransferSize() const {return KMaxBufSize;}
+
+private:
+ TBuf8<KMaxBufSize> iDataBuf;
+};
+
+#endif
+
+#ifdef MSDC_MULTITHREADED
+inline TUint8* TBulkMm::Buf1()
+{
+ return const_cast<TUint8*>(iDataBuf1.Ptr());
+}
+
+
+inline TUint8* TBulkMm::Buf2()
+{
+ return const_cast<TUint8*>(iDataBuf2.Ptr());
+}
+
+
+inline void TBulkMm::GetNextTransferBuffer(TPtr8& aPtr)
+ {
+ GetNextTransferBuffer(KMaxBufSize, aPtr);
+ }
+
+#else
+inline void TBulkMm::GetNextTransferBuffer(TUint aLength, TPtr8& aPtr)
+ {
+ iDataBuf.SetLength(aLength);
+ aPtr.Set(iDataBuf.LeftTPtr(iDataBuf.Length()));
+ }
+
+
+inline void TBulkMm::GetNextTransferBuffer(TPtr8& aPtr)
+ {
+ GetNextTransferBuffer(KMaxBufSize, aPtr);
+ }
+#endif
+
+#endif
+
--- a/userlibandfileserver/fileserver/smassstorage/rwdrivethread.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/rwdrivethread.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
@@ -13,50 +13,48 @@
// Description:
//
-#include "scsiprot.h"
+
+#include <e32std.h>
+#include "smassstorage.h"
+#include "mprotocol.h"
+#include "scsiprot.h" // KMaxBufSize
+#include "drivemanager.h"
#include "usbmsshared.h"
#include "rwdrivethread.h"
-#include "massstoragedebug.h"
-// ---
-#ifdef PRINT_MSDC_MULTITHREADED_READ_INFO
-#define __MT_READ_PRINT(t) {RDebug::Print(t);}
-#define __MT_READ_PRINT1(t,a) {RDebug::Print(t,a);}
-#define __MT_READ_PRINT2(t,a,b) {RDebug::Print(t,a,b);}
-#else
-#define __MT_READ_PRINT(t)
-#define __MT_READ_PRINT1(t,a)
-#define __MT_READ_PRINT2(t,a,b)
-#endif // PRINT_MSDC_MULTITHREADED_READ_INFO
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "rwdrivethreadTraces.h"
+#endif
-#ifdef MSDC_MULTITHREADED
+#ifdef MSDC_MULTITHREADED
TBlockDesc::TBlockDesc()
- :iBuf((TUint8 *)NULL,0,0)
- {
- }
+ :iBuf((TUint8 *)NULL,0,0)
+ {
+ }
void TBlockDesc::SetPtr(TPtr8& aDes)
- {
- iBuf.Set(aDes);
- }
+ {
+ iBuf.Set(aDes);
+ }
TBlockDescBuffer::TBlockDescBuffer()
- {
- iDescReadPtr = &iDesc1;
- iDescWritePtr = &iDesc2;
- }
+ {
+ iDescReadPtr = &iDesc1;
+ iDescWritePtr = &iDesc2;
+ }
void TBlockDescBuffer::SetUpReadBuf(TPtr8& aDes1, TPtr8& aDes2)
- {
- iDesc1.SetPtr(aDes1);
- iDesc2.SetPtr(aDes2);
- iDescReadPtr = &iDesc1;
- iDescWritePtr = &iDesc2;
- }
+ {
+ iDesc1.SetPtr(aDes1);
+ iDesc2.SetPtr(aDes2);
+ iDescReadPtr = &iDesc1;
+ iDescWritePtr = &iDesc2;
+ }
//-----------------------------------------------
@@ -69,16 +67,15 @@
@param aOwner Pointer to the object owning the thread. Used as the parameter to aThreadFunction.
*/
CThreadContext* CThreadContext::NewL(const TDesC& aName,
- TThreadFunction aThreadFunction,
- TAny* aOwner)
- {
- __FNLOG("CThreadContext::NewL");
- CThreadContext* self = new (ELeave) CThreadContext();
- CleanupStack::PushL(self);
- self->ConstructL(aName, aThreadFunction, aOwner);
- CleanupStack::Pop();
- return self;
- }
+ TThreadFunction aThreadFunction,
+ TAny* aOwner)
+ {
+ CThreadContext* self = new (ELeave) CThreadContext();
+ CleanupStack::PushL(self);
+ self->ConstructL(aName, aThreadFunction, aOwner);
+ CleanupStack::Pop();
+ return self;
+ }
/**
Construct a CThreadContext object
@@ -88,74 +85,75 @@
@param aOwner Pointer to the object owning the thread. Used as the parameter to aThreadFunction.
*/
void CThreadContext::ConstructL(const TDesC& aName,
- TThreadFunction aThreadFunction,
- TAny* aOwner)
- {
- __FNLOG("CThreadContext::ConstructL");
- __PRINT(_L("Creating Critical Section"));
- User::LeaveIfError(iCritSect.CreateLocal());
- __PRINT(_L("Creating RThread"));
+ TThreadFunction aThreadFunction,
+ TAny* aOwner)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_10, "Creating Critical Section");
+ User::LeaveIfError(iCritSect.CreateLocal());
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_11, "Creating RThread");
- TUint serial(0); // Used to retry creation of a thread in case
- // one with the same name already exists
+ TUint serial(0); // Used to retry creation of a thread in case
+ // one with the same name already exists
- RBuf threadName;
- threadName.CreateMaxL(aName.Length() + 8);
- CleanupClosePushL(threadName);
- threadName = aName;
+ RBuf threadName;
+ threadName.CreateMaxL(aName.Length() + 8);
+ CleanupClosePushL(threadName);
+ threadName = aName;
- TInt err;
- for (;;)
- {
- err = iThread.Create(threadName, aThreadFunction, 0x1000, NULL, aOwner);
- __PRINT2(_L("CThreadContext::ConstructL Created thread %S err=%d"), &threadName, err);
+ TInt err;
+ for (;;)
+ {
+ err = iThread.Create(threadName, aThreadFunction, 0x1000, NULL, aOwner);
+ OstTraceData(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_13,
+ "CThreadContext::ConstructL Created thread %s err=%d", threadName.Ptr(), threadName.Length());
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_14,
+ "err=%d", err);
+
// for a restart wait and retry until old thread is gone
- if (err == KErrAlreadyExists)
- {
- User::After(10 * 1000); // 10 mS
- threadName = aName;
- threadName.AppendNumFixedWidth(serial, EDecimal, 8);
- ++serial;
- }
- else
- {
- break;
- }
- }
+ if (err == KErrAlreadyExists)
+ {
+ User::After(10 * 1000); // 10 mS
+ threadName = aName;
+ threadName.AppendNumFixedWidth(serial, EDecimal, 8);
+ ++serial;
+ }
+ else
+ {
+ break;
+ }
+ }
User::LeaveIfError(err);
CleanupStack::Pop(); // threadName
threadName.Close();
- // set priority
- iThread.SetPriority(EPriorityMore);
- }
+ // set priority
+ iThread.SetPriority(EPriorityMore);
+ }
/**
Construct a CThreadContext object
*/
CThreadContext::CThreadContext()
- :
- iError(KErrNone)
- {
- __FNLOG("CThreadContext::CThreadContext");
- }
+ :
+ iError(KErrNone)
+ {
+ }
/**
Destructor
*/
CThreadContext::~CThreadContext()
- {
- __FNLOG("CThreadContext::~CThreadContext");
- __PRINT(_L("Closing Critical Section"));
- iCritSect.Close();
- __PRINT(_L("Killing ThreadContext"));
- iThread.Kill(0);
- __PRINT(_L("Closing ThreadContext"));
- iThread.Close();
- }
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_20, "Closing Critical Section");
+ iCritSect.Close();
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_21, "Killing ThreadContext");
+ iThread.Kill(0);
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_22, "Closing ThreadContext");
+ iThread.Close();
+ }
//-----------------------------------------------
@@ -163,47 +161,43 @@
Construct a CWriteDriveThread object
*/
CWriteDriveThread* CWriteDriveThread::NewL()
- {
- __FNLOG("CWriteDriveThread::NewL");
- CWriteDriveThread* self = new (ELeave) CWriteDriveThread();
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ {
+ CWriteDriveThread* self = new (ELeave) CWriteDriveThread();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
/**
Construct a CWriteDriveThread object
*/
void CWriteDriveThread::ConstructL()
- {
- __FNLOG("CWriteDriveThread::ConstructL");
- TBuf<16> name = _L("MassStorageWrite");
- iThreadContext = CThreadContext::NewL(name, ThreadFunction, this);
- // There are two free pointers to start with so initialise the semaphore with 1
- User::LeaveIfError(iProducerSem.CreateLocal(1));
- User::LeaveIfError(iConsumerSem.CreateLocal(0));
-
- iThreadContext->Resume();
- }
+ {
+ TBuf<16> name = _L("MassStorageWrite");
+ iThreadContext = CThreadContext::NewL(name, ThreadFunction, this);
+ // There are two free pointers to start with so initialise the semaphore with 1
+ User::LeaveIfError(iProducerSem.CreateLocal(1));
+ User::LeaveIfError(iConsumerSem.CreateLocal(0));
+
+ iThreadContext->Resume();
+ }
/**
Construct a CWriteDriveThread object
*/
-CWriteDriveThread::CWriteDriveThread()
- : iIsCommandWrite10(EFalse)
- {
- __FNLOG("CWriteDriveThread::CWriteDriveThread");
- }
+CWriteDriveThread::CWriteDriveThread()
+ : iIsCommandWrite10(EFalse)
+ {
+ }
/**
Destructor
*/
CWriteDriveThread::~CWriteDriveThread()
- {
- __FNLOG("CWriteDriveThread::~CWriteDriveThread");
- delete iThreadContext;
- }
+ {
+ delete iThreadContext;
+ }
/**
This function is called when the thread is initially scheduled.
@@ -211,150 +205,117 @@
@param aSelf Pointer to self to facilitate call to member method.
*/
TInt CWriteDriveThread::ThreadFunction(TAny* aSelf)
- {
- __FNLOG("CWriteDriveThread::ThreadFunction");
- CWriteDriveThread* self = static_cast<CWriteDriveThread*>(aSelf);
- return self->WriteToDrive();
- }
+ {
+ CWriteDriveThread* self = static_cast<CWriteDriveThread*>(aSelf);
+ return self->WriteToDrive();
+ }
/**
Writes the data pointed to by iDescWritePtr to the drive.
*/
TInt CWriteDriveThread::WriteToDrive()
- {
- __FNLOG("\tCWriteDriveThread::WriteToDrive");
-
- // One-off convenience variable assignment
- TBlockDesc* &desc = iThreadContext->iBuffer.iDescWritePtr;
-
- for(;;)
- {
- iConsumerSem.Wait();
- __PRINT(_L("\tWaiting on Write CS..."));
- iThreadContext->iCritSect.Wait();
- // +++ WRITE CS STARTS HERE +++
- __PRINT1(_L("\tNow using as write buffer: iBuf%d"), iThreadContext->iBuffer.GetBufferNumber(&desc->iBuf));
-#ifdef MEASURE_AND_DISPLAY_WRITE_TIME
- RDebug::Print(_L("\tSCSI: writing %d bytes\n"), desc->iBuf.Length());
- TTime t0, t1;
- t0.HomeTime();
-#else
- __PRINT1(_L("\tSCSI: writing %d bytes\n"), desc->iBuf.Length());
-#endif
- // Write buffer to disk
-
-#ifdef INJECT_ERROR
- if (desc->iBuf[0] == '2')
- {
- desc->iBuf[0] = 'x';
- RDebug::Printf("Injecting error");
- }
+ {
+ // One-off convenience variable assignment
+ TBlockDesc* &desc = iThreadContext->iBuffer.iDescWritePtr;
-
- RDebug::Printf("%08lx %x [%x] [%x]", desc->iByteOffset, desc->iBuf.Length(),
- desc->iBuf[0],
- desc->iBuf[desc->iBuf.Length()-1]);
-#endif
-
- iThreadContext->iError = iThreadContext->iDrive->Write(desc->iByteOffset, desc->iBuf,iThreadContext->iDrive->IsWholeMediaAccess());
-#ifdef INJECT_ERROR
- if (desc->iBuf[0] == 'x')
- {
- iThreadContext->iError = KErrUnknown;
- }
-#endif
+ for(;;)
+ {
+ iConsumerSem.Wait();
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_30, "Waiting on Write CS...");
+ iThreadContext->iCritSect.Wait();
+ // +++ WRITE CS STARTS HERE +++
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_31,
+ "Now using as write buffer: iBuf%d", iThreadContext->iBuffer.GetBufferNumber(&desc->iBuf));
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_32,
+ "SCSI: writing %d bytes", desc->iBuf.Length());
+ // Write buffer to disk
+ iThreadContext->iError = iThreadContext->iDrive->Write(desc->iByteOffset, desc->iBuf,iThreadContext->iDrive->IsWholeMediaAccess());
-#ifdef MEASURE_AND_DISPLAY_WRITE_TIME
- t1.HomeTime();
- const TTimeIntervalMicroSeconds time = t1.MicroSecondsFrom(t0);
- const TUint time_ms = I64LOW(time.Int64() / 1000);
- RDebug::Print(_L("SCSI: write took %d ms\n"), time_ms);
-#endif
- iCallback((TUint8*) (desc->iBuf.Ptr()), iCallbackParameter);
- iWriteCounter--;
- ASSERT(iWriteCounter >= 0);
+ iCallback((TUint8*) (desc->iBuf.Ptr()), iCallbackParameter);
+ iWriteCounter--;
+ __ASSERT_DEBUG(iWriteCounter >= 0, User::Panic(KUsbMsSvrPncCat, EMsThreadWriteToDrive));
- __PRINT(_L("\tSignalling Write CS"));
- iThreadContext->iCritSect.Signal();
- // +++ WRITE CS ENDS HERE +++
- iProducerSem.Signal();
- }
- }
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_33, "Signalling Write CS");
+ iThreadContext->iCritSect.Signal();
+ // +++ WRITE CS ENDS HERE +++
+ iProducerSem.Signal();
+ }
+ }
/**
-Initiates writing data pointed to by iReadBuf to the drive and resumes the thread. Writing
+Initiates writing data pointed to by iReadBuf to the drive and resumes the thread. Writing
is completed by the ThreadFunction when the thread is resumed.
@param aDrive Drive to write to.
@param aOffset Write offset.
*/
TInt CWriteDriveThread::WriteDriveData(CMassStorageDrive* aDrive, const TInt64& aOffset, TPtrC8& aDes, ProcessWriteCompleteFunc aFunc, TAny* aPtr)
- {
- // Check error code from previous write
- const TInt r = iThreadContext->iError;
- if (r != KErrNone)
- {
- __PRINT1(_L("Error after previous write = 0x%x \n"), r);
- return KErrAbort;
+ {
+ // Check error code from previous write
+ const TInt r = iThreadContext->iError;
+ if (r != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_40, "Error after previous write = %d", r);
+ return KErrAbort;
}
- // Swap the two buffer pointers
- iProducerSem.Wait();
- __PRINT(_L("Waiting on Write CS..."));
- // +++ WRITE CS STARTS HERE +++
- iThreadContext->iCritSect.Wait();
+ // Swap the two buffer pointers
+ iProducerSem.Wait();
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_41, "Waiting on Write CS...");
+ // +++ WRITE CS STARTS HERE +++
+ iThreadContext->iCritSect.Wait();
+
+ // New DB First read into the iDescReadPtr pointer,
+ // then swap,so that write pointer points to correct location, as the ptr pointed to by iDescWritePtr is what is written from in WriteToDrive
+ iThreadContext->iBuffer.iDescReadPtr->iBuf.Set((TUint8*)aDes.Ptr(), aDes.Length(), KMaxBufSize);
- // New DB First read into the iDescReadPtr pointer,
- // then swap,so that write pointer points to correct location, as the ptr pointed to by iDescWritePtr is what is written from in WriteToDrive
- iThreadContext->iBuffer.iDescReadPtr->iBuf.Set((TUint8*)aDes.Ptr(), aDes.Length(), KMaxBufSize );
-
- iCallback = aFunc;
- iCallbackParameter = aPtr;
+ iCallback = aFunc;
+ iCallbackParameter = aPtr;
- iWriteCounter++;
- iThreadContext->iBuffer.SwapDesc();
- // Prepare variables for next write
- iThreadContext->iDrive = aDrive;
- iThreadContext->iBuffer.iDescWritePtr->iByteOffset = aOffset;
- // +++ WRITE CS ENDS HERE +++
- __PRINT(_L("Signalling Write CS..."));
- iThreadContext->iCritSect.Signal();
+ iWriteCounter++;
+ iThreadContext->iBuffer.SwapDesc();
+ // Prepare variables for next write
+ iThreadContext->iDrive = aDrive;
+ iThreadContext->iBuffer.iDescWritePtr->iByteOffset = aOffset;
+ // +++ WRITE CS ENDS HERE +++
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_42, "Signalling Write CS...");
+ iThreadContext->iCritSect.Signal();
- iConsumerSem.Signal();
- return KErrNone;
+ iConsumerSem.Signal();
+ return KErrNone;
}
void CWriteDriveThread::WaitForWriteEmpty()
{
- while(iWriteCounter > 0)
- {
- User::After(100);
- }
+ while(iWriteCounter > 0)
+ {
+ User::After(100);
+ }
}
// Check if the target address range was recently written to, this is to force a
-// cache miss when reading from the same sectors that were just written.
+// cache miss when reading from the same sectors that were just written.
// Optimisation note: this is only needed if the read precache was started
// before the write was completed.
TBool CWriteDriveThread::IsRecentlyWritten(TInt64 aOffset, TInt aLength)
{
- ASSERT(iWriteCounter == 0);
- if (iIsCommandWrite10) //If the previous command is Write10, then discard pre-read as the same buffers are used and will be over written by Write10
- return ETrue;
- if(aOffset <= iThreadContext->iBuffer.iDescReadPtr->iByteOffset &&
- aOffset + aLength >= iThreadContext->iBuffer.iDescReadPtr->iByteOffset)
- return ETrue;
- if(aOffset >= iThreadContext->iBuffer.iDescReadPtr->iByteOffset &&
- aOffset <= iThreadContext->iBuffer.iDescReadPtr->iByteOffset + iThreadContext->iBuffer.iDescReadPtr->iLength)
- return ETrue;
- if(aOffset <= iThreadContext->iBuffer.iDescWritePtr->iByteOffset &&
- aOffset + aLength >= iThreadContext->iBuffer.iDescReadPtr->iByteOffset)
- return ETrue;
- if(aOffset >= iThreadContext->iBuffer.iDescWritePtr->iByteOffset &&
- aOffset <= iThreadContext->iBuffer.iDescReadPtr->iByteOffset + iThreadContext->iBuffer.iDescReadPtr->iLength)
- return ETrue;
- return EFalse;
+ __ASSERT_DEBUG(iWriteCounter == 0, User::Panic(KUsbMsSvrPncCat, EMsThreadIsRecentlyWritten));
+ if (iIsCommandWrite10) //If the previous command is Write10, then discard pre-read as the same buffers are used and will be over written by Write10
+ return ETrue;
+ if(aOffset <= iThreadContext->iBuffer.iDescReadPtr->iByteOffset &&
+ aOffset + aLength >= iThreadContext->iBuffer.iDescReadPtr->iByteOffset)
+ return ETrue;
+ if(aOffset >= iThreadContext->iBuffer.iDescReadPtr->iByteOffset &&
+ aOffset <= iThreadContext->iBuffer.iDescReadPtr->iByteOffset + iThreadContext->iBuffer.iDescReadPtr->iLength)
+ return ETrue;
+ if(aOffset <= iThreadContext->iBuffer.iDescWritePtr->iByteOffset &&
+ aOffset + aLength >= iThreadContext->iBuffer.iDescReadPtr->iByteOffset)
+ return ETrue;
+ if(aOffset >= iThreadContext->iBuffer.iDescWritePtr->iByteOffset &&
+ aOffset <= iThreadContext->iBuffer.iDescReadPtr->iByteOffset + iThreadContext->iBuffer.iDescReadPtr->iLength)
+ return ETrue;
+ return EFalse;
}
//-----------------------------------------------
@@ -363,14 +324,13 @@
Construct a CReadDriveThread object
*/
CReadDriveThread* CReadDriveThread::NewL()
- {
- __FNLOG("CReadDriveThread::NewL");
- CReadDriveThread* self = new (ELeave) CReadDriveThread();
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ {
+ CReadDriveThread* self = new (ELeave) CReadDriveThread();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
/**
Construct a CReadDriveThread object
@@ -379,30 +339,27 @@
@pram aThreadFunction Function to be called when thread is initially scheduled.
*/
void CReadDriveThread::ConstructL()
- {
- __FNLOG("CReadDriveThread::ConstructL");
- TBuf<15> name = _L("MassStorageRead");
- iThreadContext = CThreadContext::NewL(name, ThreadFunction, this);
- }
+ {
+ TBuf<15> name = _L("MassStorageRead");
+ iThreadContext = CThreadContext::NewL(name, ThreadFunction, this);
+ }
/**
Construct a CReadDriveThread object
*/
CReadDriveThread::CReadDriveThread()
- :
- iThreadRunning(EFalse)
- {
- __FNLOG("CReadDriveThread::CReadDriveThread");
- }
+ :
+ iThreadRunning(EFalse)
+ {
+ }
/**
Destructor
*/
CReadDriveThread::~CReadDriveThread()
- {
- __FNLOG("CReadDriveThread::~CReadDriveThread");
- delete iThreadContext;
- }
+ {
+ delete iThreadContext;
+ }
/**
This function is called when the thread is initially scheduled.
@@ -410,174 +367,146 @@
@param aSelf Pointer to self to facilitate call to member method.
*/
TInt CReadDriveThread::ThreadFunction(TAny* aSelf)
- {
- __FNLOG("CReadDriveThread::ThreadFunction");
- CReadDriveThread* self = static_cast<CReadDriveThread*>(aSelf);
- return self->ReadFromDrive();
- }
+ {
+ CReadDriveThread* self = static_cast<CReadDriveThread*>(aSelf);
+ return self->ReadFromDrive();
+ }
/**
Reads data from the drive with iOffset and iReadLength into memory pointer iReadBuffer
and suspends the thread.
*/
TInt CReadDriveThread::ReadFromDrive()
- {
- __FNLOG("\tCReadDriveThread::ReadFromDrive");
-
- // One-off convenience variable assignment
- TBlockDesc* &desc = iThreadContext->iBuffer.iDescWritePtr;
+ {
+ // One-off convenience variable assignment
+ TBlockDesc* &desc = iThreadContext->iBuffer.iDescWritePtr;
- for (;;)
- {
- __PRINT(_L("\tWaiting on Read CS..."));
- iThreadContext->iCritSect.Wait();
- // +++ READ CS STARTS HERE +++
- iThreadRunning = ETrue;
- iCompleted = EFalse;
+ for (;;)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_50, "Waiting on Read CS...");
+ iThreadContext->iCritSect.Wait();
+ // +++ READ CS STARTS HERE +++
+ iThreadRunning = ETrue;
+ iCompleted = EFalse;
+
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_51,
+ "\tNow using as read buffer: iBuf%d", iThreadContext->iBuffer.GetBufferNumber(&desc->iBuf));
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_52,
+ "\tSCSI: reading %d bytes", desc->iBuf.Length());
- __PRINT1(_L("\tNow using as read buffer: iBuf%d"), iThreadContext->iBuffer.GetBufferNumber(&desc->iBuf));
-
-#ifdef MEASURE_AND_DISPLAY_READ_TIME
- RDebug::Print(_L("\tSCSI: reading %d bytes\n"), desc->iBuf.Length());
- TTime t0, t1;
- t0.HomeTime();
-#else
- __PRINT1(_L("\tSCSI: reading %d bytes\n"), desc->iBuf.Length());
-#endif
- // Fill read buffer from disk
- iThreadContext->iError = iThreadContext->iDrive->Read(desc->iByteOffset,
- desc->iLength,
- desc->iBuf,
- iThreadContext->iDrive->IsWholeMediaAccess());
+ // Fill read buffer from disk
+ iThreadContext->iError = iThreadContext->iDrive->Read(desc->iByteOffset,
+ desc->iLength,
+ desc->iBuf,
+ iThreadContext->iDrive->IsWholeMediaAccess());
-#ifdef MEASURE_AND_DISPLAY_READ_TIME
- t1.HomeTime();
- const TTimeIntervalMicroSeconds time = t1.MicroSecondsFrom(t0);
- const TUint time_ms = I64LOW(time.Int64() / 1000);
- RDebug::Print(_L("SCSI: read took %d ms\n"), time_ms);
-#endif
-
- iCompleted = ETrue;
- iThreadRunning = EFalse;
- __PRINT(_L("\tSignalling Read CS"));
- // +++ READ CS ENDS HERE +++
- iThreadContext->iCritSect.Signal();
- // Suspend self
- __PRINT(_L("\tSuspending Read Thread"));
- RThread().Suspend();
- }
- }
+ iCompleted = ETrue;
+ iThreadRunning = EFalse;
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_53, "Signalling Read CS");
+ // +++ READ CS ENDS HERE +++
+ iThreadContext->iCritSect.Signal();
+ // Suspend self
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_54, "Suspending Read Thread");
+ RThread().Suspend();
+ }
+ }
/**
-Client read request of a data block from the specified drive.
+Client read request of a data block from the specified drive.
If there is no pre-read data that matches the requested Offset and Length then the drive
is read and the next pre-read is setup. If there is matching pre-read data available then
the next pre-read is setup. Finishes by resuming the thread and the ThreadFunciton runs.
@param aDrive Drive to read from.
@param aOffset Read offset
-@param aLength Length
+@param aLength Length
*/
TBool CReadDriveThread::ReadDriveData(CMassStorageDrive* aDrive,
- const TInt64& aOffset,
- TUint32 aLength,
- TBool aIgnoreCache)
- {
- __MT_READ_PRINT2(_L("\nRead10: offs %ld len %d"), aOffset, aLength);
+ const TInt64& aOffset,
+ TUint32 aLength,
+ TBool aIgnoreCache)
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_MEDIADB, CTHREADCONTEXT_60, "Read10: offs %ld len %d", aOffset, aLength);
- __PRINT(_L("Waiting on Read CS..."));
- iThreadContext->iCritSect.Wait();
- // +++ READ CS STARTS HERE +++
- __ASSERT_DEBUG(!iThreadRunning, User::Panic(_L("MSDC-THREAD"), 666));
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_61, "Waiting on Read CS...");
+ iThreadContext->iCritSect.Wait();
+ // +++ READ CS STARTS HERE +++
+ __ASSERT_DEBUG(!iThreadRunning, User::Panic(KUsbMsSvrPncCat, EMsThreadReadDriveThread));
- TBlockDesc* &desc = iThreadContext->iBuffer.iDescReadPtr;
- TBlockDesc* &bgDesc = iThreadContext->iBuffer.iDescWritePtr;
+ TBlockDesc* &desc = iThreadContext->iBuffer.iDescReadPtr;
+ TBlockDesc* &bgDesc = iThreadContext->iBuffer.iDescWritePtr;
- if ((!aIgnoreCache) &&
- (iCompleted) &&
- (iThreadContext->iError == KErrNone) &&
- (iThreadContext->iDrive == aDrive) &&
- (bgDesc->iByteOffset == aOffset) &&
- (bgDesc->iLength == aLength))
- {
- // Good: We pre-read the correct data :-)
- __MT_READ_PRINT(_L("Match: Using pre-read data :-) :-) :-) :-)"));
- }
- else
- {
- __MT_READ_PRINT(_L("Not using pre-read data"));
- if (iThreadContext->iError != KErrNone)
- {
- __MT_READ_PRINT1(_L("Pre-read failed: %d"), iThreadContext->iError);
- }
- if (iThreadContext->iDrive != aDrive)
- {
- __MT_READ_PRINT2(_L("Pre-read drive mismatch: pre 0x%08x / act 0x%08x"),
- iThreadContext->iDrive, aDrive);
- }
- if (desc->iByteOffset != aOffset)
- {
- __MT_READ_PRINT2(_L("Pre-read offset mismatch: pre %ld / act %ld"),
- desc->iByteOffset, aOffset);
- }
- if (desc->iLength != aLength)
- {
- __MT_READ_PRINT2(_L("Pre-read length mismatch: pre %d / act %d"),
- desc->iLength, aLength);
- // Potential optimization: If the pre-read was OK but for more data
- // than the host is now asking for, we could still satisfy that
- // request from the pre-read data by shortening the buffer.
- }
- // No valid pre-read data was available - so we have to read it now
- bgDesc->iByteOffset = aOffset;
- bgDesc->iLength = aLength;
- TInt err = aDrive->Read(aOffset,
- aLength,
- bgDesc->iBuf,
- aDrive->IsWholeMediaAccess());
- if (err != KErrNone)
- {
- __PRINT1(_L("Read failed, err=%d\n"), err);
- // +++ READ CS ENDS HERE +++
- __PRINT(_L("Signalling Read CS..."));
- iThreadContext->iCritSect.Signal();
- return EFalse;
- }
- }
+ if ((!aIgnoreCache) &&
+ (iCompleted) &&
+ (iThreadContext->iError == KErrNone) &&
+ (iThreadContext->iDrive == aDrive) &&
+ (bgDesc->iByteOffset == aOffset) &&
+ (bgDesc->iLength == aLength))
+ {
+ // Good: We pre-read the correct data :-)
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIADB, CTHREADCONTEXT_70, "Match: Using pre-read data :-) :-) :-) :-)");
+ }
+ else
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIADB, CTHREADCONTEXT_71, "Not using pre-read data");
+ if (iThreadContext->iError != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIADB, CTHREADCONTEXT_72, "Pre-read failed: %d", iThreadContext->iError);
+ }
+ if (iThreadContext->iDrive != aDrive)
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_MEDIADB, CTHREADCONTEXT_73,
+ "Pre-read drive mismatch: pre 0x%08x / act 0x%08x",
+ (TUint32)iThreadContext->iDrive, (TUint32)aDrive);
+ }
+ if (desc->iByteOffset != aOffset)
+ {
+ OstTraceExt4(TRACE_SMASSSTORAGE_MEDIADB, CTHREADCONTEXT_74,
+ "Pre-read offset mismatch: pre 0x%x 0x%x / act 0x%x 0x%x",
+ I64HIGH(desc->iByteOffset), I64LOW(desc->iByteOffset), I64HIGH(aOffset), I64LOW(aOffset));
+ }
+ if (desc->iLength != aLength)
+ {
+ OstTraceExt2(TRACE_SMASSSTORAGE_MEDIADB, CTHREADCONTEXT_75,
+ "Pre-read length mismatch: pre 0x%x / act 0x%x",
+ (TUint32)desc->iLength, aLength);
+ // Potential optimization: If the pre-read was OK but for more data
+ // than the host is now asking for, we could still satisfy that
+ // request from the pre-read data by shortening the buffer.
+ }
+ // No valid pre-read data was available - so we have to read it now
+ bgDesc->iByteOffset = aOffset;
+ bgDesc->iLength = aLength;
+ TInt err = aDrive->Read(aOffset,
+ aLength,
+ bgDesc->iBuf,
+ aDrive->IsWholeMediaAccess());
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_76, "Read failed, err=%d", err);
+ // +++ READ CS ENDS HERE +++
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_77, "Signalling Read CS...");
+ iThreadContext->iCritSect.Signal();
+ return EFalse;
+ }
+ }
- // Prepare thread variables for next pre-read attempt by the ReadThread
- const TInt64 offs_new = aOffset + aLength;
- iThreadContext->iDrive = aDrive; // same drive
- desc->iByteOffset = offs_new; // next block
- desc->iLength = aLength; // same length
- iCompleted = EFalse;
- iThreadContext->iBuffer.SwapDesc();
-
- // +++ READ CS ENDS HERE +++
- __PRINT(_L("Signalling Read CS..."));
- iThreadContext->iCritSect.Signal();
- // Start background read
- __PRINT(_L("Resuming Read Thread"));
- iThreadContext->Resume();
- return ETrue;
- }
+ // Prepare thread variables for next pre-read attempt by the ReadThread
+ const TInt64 offs_new = aOffset + aLength;
+ iThreadContext->iDrive = aDrive; // same drive
+ desc->iByteOffset = offs_new; // next block
+ desc->iLength = aLength; // same length
+ iCompleted = EFalse;
+ iThreadContext->iBuffer.SwapDesc();
-/**
-Discard the read buffer. This is used to force a cache miss when reading from
-the same sectors that were just written.
-*/
-void CReadDriveThread::DiscardRead()
-{
- __PRINT(_L("Waiting on Read CS in DiscardRead..."));
- iThreadContext->iCritSect.Wait();
- // +++ READ CS STARTS HERE +++
- __PRINT(_L("Discarding pre-read buffer"));
- iCompleted = EFalse;
- iThreadContext->iBuffer.iDescReadPtr->iLength = 0;
+ // +++ READ CS ENDS HERE +++
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_78, "Signalling Read CS...");
+ iThreadContext->iCritSect.Signal();
+ // Start background read
+ OstTrace0(TRACE_SMASSSTORAGE_MEDIA, CTHREADCONTEXT_79, "Resuming Read Thread");
+ iThreadContext->Resume();
+ return ETrue;
+ }
- // +++ READ CS ENDS HERE +++
- __PRINT(_L("Signalling Read CS in DiscardRead..."));
- iThreadContext->iCritSect.Signal();
-}
#endif // MSDC_MULTITHREADED
--- a/userlibandfileserver/fileserver/smassstorage/scsiprot.cpp Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/scsiprot.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -13,34 +13,41 @@
// Description:
//
+#include <e32std.h>
+#include "mtransport.h"
+#include "mprotocol.h"
#include "scsiprot.h"
-#ifdef MSDC_MULTITHREADED
+#ifdef MSDC_MULTITHREADED
#include "rwdrivethread.h"
#endif // MSDC_MULTITHREADED
-#include "massstoragedebug.h"
+
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "scsiprotTraces.h"
+#endif
// Helper macros
#define LBA(x) static_cast<TUint32>((x[3] << 24) | (x[4] << 16) | (x[5] << 8) | x[6])
#define LEN(x) static_cast<TUint16>((x[8] << 8) | x[9])
-LOCAL_D const TUint KDefaultBlockSize = 0x200; //default block size for FAT
+static const TUint32 KDefaultBlockSize = 0x200; //default block size for FAT
-LOCAL_D const TUint KUndefinedLun = 0xFFFF;
+static const TUint KUndefinedLun = 0xFFFF;
-LOCAL_D const TUint8 KAllPages = 0x3F;
+static const TUint8 KAllPages = 0x3F;
-LOCAL_D const TUint8 KChangeableValues = 0x1;
-LOCAL_D const TUint8 KDefaultValues = 0x2;
+static const TUint8 KChangeableValues = 0x1;
+static const TUint8 KDefaultValues = 0x2;
/**
Default constructor for TSenseInfo
*/
TSenseInfo::TSenseInfo()
- : iSenseCode(ENoSense),
- iAdditional(EAscNull),
- iQualifier(EAscqNull)
- {}
+ : iSenseCode(ENoSense),
+ iAdditional(EAscNull),
+ iQualifier(EAscqNull)
+ {}
/**
@@ -49,43 +56,46 @@
@param aSenseCode sense key
*/
void TSenseInfo::SetSense(TSenseCode aSenseCode)
- {
- iSenseCode = static_cast<TUint8>(aSenseCode);
- iAdditional = EAscNull;
- iQualifier = EAscqNull;
- }
+ {
+ iSenseCode = static_cast<TUint8>(aSenseCode);
+ iAdditional = EAscNull;
+ iQualifier = EAscqNull;
+ OstTraceExt3(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_SETSENSE1, " SENSE CODE %d ASC %d ASC %d", iSenseCode, iAdditional, iQualifier);
+ }
/**
Set sense with additional info.
@param aSenseCode sense key
-@param aAdditional additional sense code (ASC)
+@param aAdditional additional sense code (ASC)
*/
void TSenseInfo::SetSense(TSenseCode aSenseCode, TAdditionalCode aAdditional)
- {
- iSenseCode = static_cast<TUint8>(aSenseCode);
- iAdditional = static_cast<TUint8>(aAdditional);
- iQualifier = EAscqNull;
- }
+ {
+ iSenseCode = static_cast<TUint8>(aSenseCode);
+ iAdditional = static_cast<TUint8>(aAdditional);
+ iQualifier = EAscqNull;
+ OstTraceExt3(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_SETSENSE2, " SENSE CODE %d ASC %d ASC %d", iSenseCode, iAdditional, iQualifier);
+ }
/**
Set sense with additional info and qualifier.
-@param aSenseCode sense key
-@param aAdditional additional sense code (ASC)
+@param aSenseCode sense key
+@param aAdditional additional sense code (ASC)
@param aQualifier additional sense code qualifier (ASCQ)
*/
void TSenseInfo::SetSense(TSenseCode aSenseCode,
- TAdditionalCode aAdditional,
- TAdditionalSenseCodeQualifier aQualifier)
- {
- iSenseCode = static_cast<TUint8>(aSenseCode);
- iAdditional = static_cast<TUint8>(aAdditional);
- iQualifier = static_cast<TUint8>(aQualifier);
- }
+ TAdditionalCode aAdditional,
+ TAdditionalSenseCodeQualifier aQualifier)
+ {
+ iSenseCode = static_cast<TUint8>(aSenseCode);
+ iAdditional = static_cast<TUint8>(aAdditional);
+ iQualifier = static_cast<TUint8>(aQualifier);
+ OstTraceExt3(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_SETSENSE3, " SENSE CODE %d ASC %d ASC %d", iSenseCode, iAdditional, iQualifier);
+ }
//-----------------------------------------------
@@ -96,13 +106,13 @@
@param aDriveManager reference to the drive manager object
*/
CScsiProtocol* CScsiProtocol::NewL(CDriveManager& aDriveManager)
- {
- CScsiProtocol* self = new (ELeave) CScsiProtocol(aDriveManager);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop();
- return self;
- }
+ {
+ CScsiProtocol* self = new (ELeave) CScsiProtocol(aDriveManager);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
/**
c'tor
@@ -110,54 +120,48 @@
@param aDriveManager reference to the drive manager object
*/
CScsiProtocol::CScsiProtocol(CDriveManager& aDriveManager):
- iDriveManager(aDriveManager),
- iLastCommand(EUndefinedCommand),
- iLastLun(KUndefinedLun),
- iMediaWriteSize(KDefaultMediaWriteSize)
- {
- __FNLOG("CScsiProtocol::CScsiProtocol");
-
+ iDriveManager(aDriveManager),
+ iLastCommand(EUndefinedCommand),
+ iLastLun(KUndefinedLun),
+ iMediaWriteSize(KDefaultMediaWriteSize)
+ {
#ifdef USB_TRANSFER_PUBLISHER
- iWriteTransferPublisher = CUsbWriteTransferPublisher::NewL(iBytesWritten);
- iReadTransferPublisher = CUsbReadTransferPublisher::NewL(iBytesRead);
+ iWriteTransferPublisher = CUsbWriteTransferPublisher::NewL(iBytesWritten);
+ iReadTransferPublisher = CUsbReadTransferPublisher::NewL(iBytesRead);
- for (TUint i = 0; i < KUsbMsMaxDrives; i++)
- {
- iBytesRead[i] = 0;
- iBytesWritten[i] = 0;
- }
+ for (TUint i = 0; i < KUsbMsMaxDrives; i++)
+ {
+ iBytesRead[i] = 0;
+ iBytesWritten[i] = 0;
+ }
#else
- iWriteTransferPublisher = CDriveWriteTransferPublisher::NewL(aDriveManager.iDrives);
- iReadTransferPublisher = CDriveReadTransferPublisher::NewL(aDriveManager.iDrives);
+ iWriteTransferPublisher = CDriveWriteTransferPublisher::NewL(aDriveManager.iDrives);
+ iReadTransferPublisher = CDriveReadTransferPublisher::NewL(aDriveManager.iDrives);
#endif
- }
+ }
CScsiProtocol::~CScsiProtocol()
- {
- __FNLOG("CScsiProtocol::~CScsiProtocol");
+ {
#ifdef MSDC_MULTITHREADED
- __PRINT(_L("Deleting WriteDrive Thread"));
- delete iWriteDriveThread;
- __PRINT(_L("Deleting ReadDrive Thread"));
- delete iReadDriveThread;
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_DES, "Deleting Drive Threads");
+ delete iWriteDriveThread;
+ delete iReadDriveThread;
#endif // MSDC_MULTITHREADED
- delete iWriteTransferPublisher;
- delete iReadTransferPublisher;
- }
+ delete iWriteTransferPublisher;
+ delete iReadTransferPublisher;
+ }
void CScsiProtocol::ConstructL()
- {
- __FNLOG("CScsiProtocol::ConstructL");
+ {
#ifdef MSDC_MULTITHREADED
- __PRINT(_L("Creating WriteDrive Thread"));
- iWriteDriveThread = CWriteDriveThread::NewL();
- __PRINT(_L("Creating ReadDrive Thread"));
- iReadDriveThread = CReadDriveThread::NewL();
+ OstTrace0(TRACE_SMASSSTORAGE, _CSCSIPROTOCOL, "Creating Drive Threads");
+ iWriteDriveThread = CWriteDriveThread::NewL();
+ iReadDriveThread = CReadDriveThread::NewL();
#endif // MSDC_MULTITHREADED
- }
+ }
/**
@@ -166,10 +170,9 @@
@param aTransport pointer to the transport object
*/
void CScsiProtocol::RegisterTransport(MTransportBase* aTransport)
- {
- __FNLOG("CScsiProtocol::RegisterTransport");
- iTransport = aTransport;
- }
+ {
+ iTransport = aTransport;
+ }
/**
@@ -182,31 +185,30 @@
*/
void CScsiProtocol::ReportHighSpeedDevice()
- {
- __FNLOG("CScsiProtocol::ReportHighSpeedDevice");
- iMediaWriteSize = KHsMediaWriteSize;
- __PRINT1(_L("HS Device reported: SCSI will use %d bytes disk write size"), iMediaWriteSize);
- }
+ {
+ iMediaWriteSize = KHsMediaWriteSize;
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_REPORTHIGHSPEEDDEVICE,
+ "HS Device reported: SCSI will use 0x%x bytes disk write size", iMediaWriteSize);
+ }
TInt CScsiProtocol::SetScsiParameters(TMassStorageConfig aConfig)
- {
- __FNLOG("CScsiProtocol::SetScsiParameters");
- iConfig = aConfig;
- return KErrNone;
- }
+ {
+ iConfig = aConfig;
+ return KErrNone;
+ }
#ifdef MSDC_MULTITHREADED
void CScsiProtocol::ProcessWriteComplete (TUint8* aAddress, TAny* aPtr)
- {
- ((CScsiProtocol*)aPtr)->iTransport->ProcessReadData(aAddress);
- }
+ {
+ ((CScsiProtocol*)aPtr)->iTransport->ProcessReadData(aAddress);
+ }
void CScsiProtocol::InitializeBufferPointers(TPtr8& aDes1, TPtr8& aDes2) // Todo Change name later - InitializeReadBufferSomething
- {
- iReadDriveThread->iThreadContext->iBuffer.SetUpReadBuf(aDes1, aDes2);
- }
+ {
+ iReadDriveThread->iThreadContext->iBuffer.SetUpReadBuf(aDes1, aDes2);
+ }
#endif
/**
@@ -218,399 +220,393 @@
@return ETrue if command was decoded and executed successfully
*/
TBool CScsiProtocol::DecodePacket(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::DecodePacket");
-
- TUint8 command = aData[1];
+ {
+ TUint command = aData[1];
- if (command != ERequestSense)
- {
- iSenseInfo.SetSense(TSenseInfo::ENoSense);
- }
+ if (command != ERequestSense)
+ {
+ iSenseInfo.SetSense(TSenseInfo::ENoSense);
+ }
- __PRINT2(_L("command = 0x%x lun=%d"), command, aLun);
- switch (command)
- {
- case ETestUnitReady:
- HandleUnitReady(aLun);
- break;
+ OstTraceExt2(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_DECODEPACKET, "Command=0x%x LUN=%d", command, aLun);
+ switch (command)
+ {
+ case ETestUnitReady:
+ HandleUnitReady(aLun);
+ break;
- case ERequestSense:
- HandleRequestSense(aData);
- break;
+ case ERequestSense:
+ HandleRequestSense(aData);
+ break;
- case EInquiry:
- HandleInquiry(aData, aLun);
- break;
+ case EInquiry:
+ HandleInquiry(aData, aLun);
+ break;
- case EModeSense6:
- HandleModeSense6(aData, aLun);
- break;
+ case EModeSense6:
+ HandleModeSense6(aData, aLun);
+ break;
case EModeSense10:
HandleModeSense10(aData, aLun);
break;
- case EStartStopUnit:
- HandleStartStopUnit(aData, aLun);
- break;
+ case EStartStopUnit:
+ HandleStartStopUnit(aData, aLun);
+ break;
- case EPreventMediaRemoval:
- HandlePreventMediaRemoval(aData, aLun);
- break;
+ case EPreventMediaRemoval:
+ HandlePreventMediaRemoval(aData, aLun);
+ break;
- case EReadCapacity:
- HandleReadCapacity(aData, aLun);
- break;
+ case EReadCapacity:
+ HandleReadCapacity(aData, aLun);
+ break;
- case ERead10:
- HandleRead10(aData, aLun);
- break;
+ case ERead10:
+ HandleRead10(aData, aLun);
+ break;
- case EWrite10:
- HandleWrite10(aData,aLun);
- break;
+ case EWrite10:
+ HandleWrite10(aData,aLun);
+ break;
- case EVerify10:
- HandleVerify10(aData, aLun);
- break;
+ case EVerify10:
+ HandleVerify10(aData, aLun);
+ break;
- case EReadFormatCapacities:
- HandleReadFormatCapacities(aLun);
- break;
+ case EReadFormatCapacities:
+ HandleReadFormatCapacities(aLun);
+ break;
- default:
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidCmdCode);
- }
- __PRINT1(_L("DecodePacket result = %d"), iSenseInfo.SenseOk());
- return(iSenseInfo.SenseOk());
- }
+ default:
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidCmdCode);
+ }
+ return(iSenseInfo.SenseOk());
+ }
/**
Checks if drive ready
-@param aLun Logic unit number
+@param aLun Logic unit number
@return pointer to drive correspondent to LUN if drive mounted and ready, NULL otherwise
*/
CMassStorageDrive* CScsiProtocol::GetCheckDrive(TUint aLun)
- {
- __FNLOG("CScsiProtocol::GetCheckDrive");
- TInt err=KErrNone;
+ {
+ TInt err=KErrNone;
#ifdef MSDC_MULTITHREADED
- // check for deferred errors
- if (iWriteDriveThread->DeferredError())
- {
- iWriteDriveThread->ClearDeferredError();
- iDeferredSenseInfo.SetSense(TSenseInfo::EMediumError);
- return NULL;
- }
+ // check for deferred errors
+ if (iWriteDriveThread->DeferredError())
+ {
+ iWriteDriveThread->ClearDeferredError();
+ iDeferredSenseInfo.SetSense(TSenseInfo::EMediumError);
+ return NULL;
+ }
#endif
- CMassStorageDrive* drive= iDriveManager.Drive(aLun, err);
+ CMassStorageDrive* drive= iDriveManager.Drive(aLun, err);
- if (err !=KErrNone || drive == NULL)
- {
- __PRINT(_L("No drive available\n"));
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
- return NULL;
- }
+ if (err !=KErrNone || drive == NULL)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_GETCHECKDRIVE1, "No drive available");
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
+ return NULL;
+ }
- CMassStorageDrive::TMountState mountState = drive->MountState();
+ CMassStorageDrive::TMountState mountState = drive->MountState();
- if (mountState == CMassStorageDrive::EDisconnected || mountState == CMassStorageDrive::EConnecting)
- {
- __PRINT(_L("Drive disconnected\n"));
- iSenseInfo.SetSense(TSenseInfo::ENotReady,
- TSenseInfo::EMediaNotPresent);
- return NULL;
- }
+ if (mountState == CMassStorageDrive::EDisconnected || mountState == CMassStorageDrive::EConnecting)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_GETCHECKDRIVE2, "Drive disconnected");
+ iSenseInfo.SetSense(TSenseInfo::ENotReady,
+ TSenseInfo::EMediaNotPresent);
+ return NULL;
+ }
- CMassStorageDrive::TDriveState state = drive->CheckDriveState();
- if (state == CMassStorageDrive::EMediaNotPresent || state == CMassStorageDrive::ELocked)
- {
- __PRINT1(_L("Media not present or locked. (state =0x%X)\n"),state);
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return NULL;
- }
+ CMassStorageDrive::TDriveState state = drive->CheckDriveState();
+ if (state == CMassStorageDrive::EMediaNotPresent || state == CMassStorageDrive::ELocked)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_GETCHECKDRIVE3, "Media not present or locked. state =0x%X", state);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return NULL;
+ }
- if (drive->IsMediaChanged(ETrue)) //reset "media changed" status
- {
- __PRINT(_L("Media was changed\n"));
- // SAM-2 Section 5.9.5 Unit Attention Condition
- iSenseInfo.SetSense(TSenseInfo::EUnitAttention, TSenseInfo::ENotReadyToReadyChange);
- iDriveManager.Connect(aLun); //publish event to USB app
- return NULL;
- }
+ if (drive->IsMediaChanged(ETrue)) //reset "media changed" status
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_GETCHECKDRIVE4, "Media was changed");
+ // SAM-2 Section 5.9.5 Unit Attention Condition
+ iSenseInfo.SetSense(TSenseInfo::EUnitAttention, TSenseInfo::ENotReadyToReadyChange);
+ iDriveManager.Connect(aLun); //publish event to USB app
+ return NULL;
+ }
- if (mountState == CMassStorageDrive::EDisconnecting)
- {
- __PRINT(_L("Drive disconnecting\n"));
- iSenseInfo.SetSense(TSenseInfo::ENotReady,
- TSenseInfo::EMediaNotPresent);
- return NULL;
- }
+ if (mountState == CMassStorageDrive::EDisconnecting)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_GETCHECKDRIVE5, "Drive disconnecting");
+ iSenseInfo.SetSense(TSenseInfo::ENotReady,
+ TSenseInfo::EMediaNotPresent);
+ return NULL;
+ }
- return drive;
- }
+ return drive;
+ }
/**
Command Parser for the UNIT READY command (0x00)
-@param aLun Logic unit number
-@return ETrue if successful,
+@param aLun Logic unit number
+@return ETrue if successful,
*/
TBool CScsiProtocol::HandleUnitReady(TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleUnitReady");
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_TESTUNITREADY, ">>> TEST UNIT READY");
#ifdef MSDC_MULTITHREADED
- iWriteDriveThread->WaitForWriteEmpty();
+ iWriteDriveThread->WaitForWriteEmpty();
#endif
- return GetCheckDrive(aLun) ? (TBool)ETrue : (TBool)EFalse;
- }
+ return GetCheckDrive(aLun) ? (TBool)ETrue : (TBool)EFalse;
+ }
/**
Command Parser for the REQUEST SENSE command (0x03)
-@return ETrue if successful,
+@return ETrue if successful,
*/
TBool CScsiProtocol::HandleRequestSense(TPtrC8& aData)
- {
- __FNLOG("CScsiProtocol::HandleRequestSense");
- TUint length = aData[5];
- __PRINT1(_L("length = %d\n"), length);
-
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetCommandBufPtr(writeBuf, KRequestSenseCommandLength);
- writeBuf.FillZ(KRequestSenseCommandLength);
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_REQUESTSENSE, ">>> REQUEST SENSE");
+ TUint length = aData[5];
+ OstTrace1(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_REQUESTSENSE1, " length = %d", length);
- TSenseInfo* senseInfo;
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetCommandBufPtr(writeBuf, KRequestSenseCommandLength);
+ writeBuf.FillZ(KRequestSenseCommandLength);
+
+ TSenseInfo* senseInfo;
#ifdef MSDC_MULTITHREADED
- if (!iDeferredSenseInfo.SenseOk())
- {
- writeBuf[00] = 0x71; //(deferred errors)
- senseInfo = &iDeferredSenseInfo;
- }
- else
- {
- writeBuf[00] = 0x70; //(current errors)
- senseInfo = &iSenseInfo;
- }
+ if (!iDeferredSenseInfo.SenseOk())
+ {
+ writeBuf[00] = 0x71; //(deferred errors)
+ senseInfo = &iDeferredSenseInfo;
+ }
+ else
+ {
+ writeBuf[00] = 0x70; //(current errors)
+ senseInfo = &iSenseInfo;
+ }
#else
- senseInfo = &iSenseInfo;
- writeBuf[00] = 0x70; //(current errors)
+ senseInfo = &iSenseInfo;
+ writeBuf[00] = 0x70; //(current errors)
#endif
- writeBuf[02] = static_cast<TUint8>(senseInfo->iSenseCode & 0x0F);
+ writeBuf[02] = static_cast<TUint8>(senseInfo->iSenseCode & 0x0F);
- writeBuf[12] = senseInfo->iAdditional;
- writeBuf[13] = senseInfo->iQualifier;
- if (length<18 && length >=8)
- {
- writeBuf.SetLength(length); //length of response code data
- writeBuf[07] = TUint8(length - 8); //additional sence length
- }
- else if (length >= KRequestSenseCommandLength)
- {
- writeBuf[07] = KRequestSenseCommandLength - 8; // we have max 18 byte to send
- }
+ writeBuf[12] = senseInfo->iAdditional;
+ writeBuf[13] = senseInfo->iQualifier;
+ if (length<18 && length >=8)
+ {
+ writeBuf.SetLength(length); //length of response code data
+ writeBuf[07] = TUint8(length - 8); //additional sence length
+ }
+ else if (length >= KRequestSenseCommandLength)
+ {
+ writeBuf[07] = KRequestSenseCommandLength - 8; // we have max 18 byte to send
+ }
- __PRINT4(_L("Response=0x%x Sense=0x%x, Additional=0x%x, Qualifier=0x%x\n"),
- writeBuf[0], writeBuf[02], writeBuf[12], writeBuf[13]);
-
- TPtrC8 writeBuf1 = writeBuf.Left(length);
+ OstTraceExt4(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_REQUESTSENSE2,
+ " Response=0x%x Sense=0x%x, Additional=0x%x, Qualifier=0x%x",
+ (TUint)writeBuf[0], (TUint)writeBuf[02], (TUint)writeBuf[12], (TUint)writeBuf[13]);
- iTransport->SetupWriteData(writeBuf1);
+ TPtrC8 writeBuf1 = writeBuf.Left(length);
- // clear the sense info
- iSenseInfo.SetSense(TSenseInfo::ENoSense);
+ iTransport->SetupWriteData(writeBuf1);
+
+ // clear the sense info
+ iSenseInfo.SetSense(TSenseInfo::ENoSense);
#ifdef MSDC_MULTITHREADED
- iDeferredSenseInfo.SetSense(TSenseInfo::ENoSense);
+ iDeferredSenseInfo.SetSense(TSenseInfo::ENoSense);
#endif
- return ETrue;
- }
+ return ETrue;
+ }
/**
Command Parser for the INQUIRY command (0x12)
-@param aLun Logic unit number
-@return ETrue if successful,
+@param aLun Logic unit number
+@return ETrue if successful,
*/
TBool CScsiProtocol::HandleInquiry(TPtrC8& aData, TUint aLun )
- {
- __FNLOG("CScsiProtocol::HandleInquiry");
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_INQUIRY, ">>> INQUIRY");
+ TBool cmdDt = aData[2] & 0x2;
+ TBool evpd = aData[2] & 0x1;
+ TUint8 page = aData[3];
+ if (cmdDt || evpd || page || aLun >= KUsbMsMaxDrives)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- TBool cmdDt = aData[2] & 0x2;
- TBool evpd = aData[2] & 0x1;
- TUint8 page = aData[3];
- if (cmdDt || evpd || page || aLun >= KUsbMsMaxDrives)
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
-
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetCommandBufPtr(writeBuf, KInquiryCommandLength);
- writeBuf.FillZ(KInquiryCommandLength);
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetCommandBufPtr(writeBuf, KInquiryCommandLength);
+ writeBuf.FillZ(KInquiryCommandLength);
- writeBuf[1] = 0x80; // MSB: RMB : Removable
- writeBuf[3] = 0x02; // AERC, TrmTsk, NormACA, Response Data Format
- writeBuf[4] = 0x1F; // Additional Length
+ writeBuf[1] = 0x80; // MSB: RMB : Removable
+ writeBuf[3] = 0x02; // AERC, TrmTsk, NormACA, Response Data Format
+ writeBuf[4] = 0x1F; // Additional Length
- TPtr8 vendorId(&writeBuf[8], 8, 8); // Vendor ID (Vendor Specific/Logged by T10)
- vendorId.Fill(' ', 8);
- vendorId.Copy(iConfig.iVendorId);
+ TPtr8 vendorId(&writeBuf[8], 8, 8); // Vendor ID (Vendor Specific/Logged by T10)
+ vendorId.Fill(' ', 8);
+ vendorId.Copy(iConfig.iVendorId);
- TPtr8 productId(&writeBuf[16], 16, 16); // Product ID (Vendor Specific)
- productId.Fill(' ', 16);
- productId.Copy(iConfig.iProductId);
+ TPtr8 productId(&writeBuf[16], 16, 16); // Product ID (Vendor Specific)
+ productId.Fill(' ', 16);
+ productId.Copy(iConfig.iProductId);
- TPtr8 productRev(&writeBuf[32], 4, 4); // Product Revision Level (Vendor Specific)
- productRev.Fill(' ', 4);
- productRev.Copy(iConfig.iProductRev);
+ TPtr8 productRev(&writeBuf[32], 4, 4); // Product Revision Level (Vendor Specific)
+ productRev.Fill(' ', 4);
+ productRev.Copy(iConfig.iProductRev);
+
+ OstTraceData(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_INQUIRY1, "Vendor ID %s", vendorId.Ptr(), vendorId.Length());
+ OstTraceData(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_INQUIRY2, "Product ID %s", productId.Ptr(), productId.Length());
+ OstTraceData(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_INQUIRY3, "Product Rev %s", productRev.Ptr(), productRev.Length());
TUint length = aData[5];
- TPtrC8 writeBuf1 = writeBuf.Left(length);
- iTransport->SetupWriteData(writeBuf1);
+ TPtrC8 writeBuf1 = writeBuf.Left(length);
+ iTransport->SetupWriteData(writeBuf1);
- iSenseInfo.SetSense(TSenseInfo::ENoSense);
- return ETrue;
- }
+ iSenseInfo.SetSense(TSenseInfo::ENoSense);
+ return ETrue;
+ }
/**
Command Parser for the START STOP UNIT command (0x1B)
-
+
@param aData command data (started form position 1)
- @param aLun Logic unit number
+ @param aLun Logic unit number
@return ETrue if successful, TFalse otherwise
*/
TBool CScsiProtocol::HandleStartStopUnit(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleStartStopUnit");
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_STARTSTOPUNIT, ">>> START STOP UNIT");
+ const TUint8 KStartMask = 0x01;
+ const TUint8 KImmedMask = 0x01;
+ const TUint8 KLoejMask = 0x02;
- const TUint8 KStartMask = 0x01;
- const TUint8 KImmedMask = 0x01;
- const TUint8 KLoejMask = 0x02;
-
- TBool immed = aData[2] & KImmedMask ? (TBool)ETrue : (TBool)EFalse;
- TBool start = aData[5] & KStartMask ? (TBool)ETrue : (TBool)EFalse;
- TBool loej = aData[5] & KLoejMask ? (TBool)ETrue : (TBool)EFalse;
+ TBool immed = aData[2] & KImmedMask ? (TBool)ETrue : (TBool)EFalse;
+ TBool start = aData[5] & KStartMask ? (TBool)ETrue : (TBool)EFalse;
+ TBool loej = aData[5] & KLoejMask ? (TBool)ETrue : (TBool)EFalse;
- __PRINT2(_L("Data %X %X\n"), aData[2], aData[5]);
- __PRINT1(_L("IMMED = %d\n"), immed);
- __PRINT1(_L("START = %d\n"), start);
-
- __PRINT1(_L("LOEJ = %d\n"), loej);
+ OstTrace1(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_STARTSTOPUNIT1, " IMMED = %d", immed);
+ OstTrace1(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_STARTSTOPUNIT2, " START = %d", start);
+ OstTrace1(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_STARTSTOPUNIT3, " LOEJ = %d", loej);
- TInt err(KErrNone);
- if (loej)
- {
- if(start) //Start unit
- {
- err = iDriveManager.Connect(aLun);
- __PRINT(_L("Load media\n"));
+ TInt err(KErrNone);
+ if (loej)
+ {
+ if(start) //Start unit
+ {
+ err = iDriveManager.Connect(aLun);
#ifdef USB_TRANSFER_PUBLISHER
- iBytesRead[aLun] = 0;
- iBytesWritten[aLun] = 0;
+ iBytesRead[aLun] = 0;
+ iBytesWritten[aLun] = 0;
#endif
- // publish the initial values
- iWriteTransferPublisher->DoPublishDataTransferredEvent();
- iReadTransferPublisher->DoPublishDataTransferredEvent();
- }
- else //Stop unit
- {
- iDriveManager.SetCritical(aLun, EFalse);
- err = iDriveManager.Disconnect(aLun);
- __PRINT(_L("Unload media\n"));
- }
- }
+ // publish the initial values
+ iWriteTransferPublisher->DoPublishDataTransferredEvent();
+ iReadTransferPublisher->DoPublishDataTransferredEvent();
+ }
+ else //Stop unit
+ {
+ iDriveManager.SetCritical(aLun, EFalse);
+ err = iDriveManager.Disconnect(aLun);
+ }
+ }
- if (err !=KErrNone) //actually we have error here only if the LUN is incorrect
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
- return EFalse;
- }
- if (immed)
- {
- return ETrue;
- }
+ if (err !=KErrNone) //actually we have error here only if the LUN is incorrect
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
+ return EFalse;
+ }
+ if (immed)
+ {
+ return ETrue;
+ }
- CMassStorageDrive* drive= iDriveManager.Drive(aLun, err);
+ CMassStorageDrive* drive= iDriveManager.Drive(aLun, err);
- if (err !=KErrNone || drive == NULL)
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
- return EFalse;
- }
+ if (err !=KErrNone || drive == NULL)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELuNotSupported);
+ return EFalse;
+ }
- TInt timeLeft (20); // 1 sec timeout
- CMassStorageDrive::TMountState mountState;
+ TInt timeLeft (20); // 1 sec timeout
+ CMassStorageDrive::TMountState mountState;
- do
- {
- User::After(1000 * 50); // 50 mSec
- --timeLeft;
- mountState = drive->MountState();
+ do
+ {
+ User::After(1000 * 50); // 50 mSec
+ --timeLeft;
+ mountState = drive->MountState();
- if ((!start && mountState != CMassStorageDrive::EConnected)
- ||
- (start &&
- (mountState == CMassStorageDrive::EDisconnecting ||
- mountState == CMassStorageDrive::EConnected))
- )
- {
- return ETrue;
- }
- } while (timeLeft>0);
+ if ((!start && mountState != CMassStorageDrive::EConnected)
+ ||
+ (start &&
+ (mountState == CMassStorageDrive::EDisconnecting ||
+ mountState == CMassStorageDrive::EConnected))
+ )
+ {
+ return ETrue;
+ }
+ } while (timeLeft>0);
- //timeout happend
- iSenseInfo.SetSense(TSenseInfo::ENotReady,
- TSenseInfo::EAscLogicalUnitDoesNotRespondToSelection);
- return EFalse;
- }
+ //timeout happend
+ iSenseInfo.SetSense(TSenseInfo::ENotReady,
+ TSenseInfo::EAscLogicalUnitDoesNotRespondToSelection);
+ return EFalse;
+ }
/**
Command Parser for the PREVENT/ALLOW MEDIA REMOVAL command (0x1E)
@param aData command data (started form position 1)
-@param aLun Logic unit number
+@param aLun Logic unit number
@return ETrue if successful.
*/
TBool CScsiProtocol::HandlePreventMediaRemoval(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandlePreventMediaRemoval");
- CMassStorageDrive* drive=GetCheckDrive(aLun);
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_PREVENTMEDIAREMOVAL, ">>> PREVENT MEDIA REMOVAL");
+ CMassStorageDrive* drive=GetCheckDrive(aLun);
- if (drive == NULL)
- {
- return EFalse;
- }
+ if (drive == NULL)
+ {
+ return EFalse;
+ }
- TInt prevent = aData[5] & 0x01;
- __PRINT1(_L("prevent = %d\n"), prevent);
- iDriveManager.SetCritical(aLun, prevent);
-
- return ETrue;
- }
+ TInt prevent = aData[5] & 0x01;
+ OstTrace1(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_PREVENTMEDIAREMOVAL1, " prevent = %d", prevent);
+ iDriveManager.SetCritical(aLun, prevent);
+ return ETrue;
+ }
/** Cancel active state, Invoked by transnport when it stops */
TInt CScsiProtocol::Cancel()
- {
- iDriveManager.SetCritical(CDriveManager::KAllLuns, EFalse);
- return KErrNone;
- }
+ {
+ iDriveManager.SetCritical(CDriveManager::KAllLuns, EFalse);
+ return KErrNone;
+ }
TBool CScsiProtocol::HandleReadFormatCapacities(TUint aLun)
@@ -619,136 +615,137 @@
*
* @return ETrue if successful, else a standard Symbian OS error code.
*/
- {
- __FNLOG("CScsiProtocol::HandleReadFormatCapacities");
-
- CMassStorageDrive* drive=GetCheckDrive(aLun);
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_READFORMATCAPACITIES, ">>> READ FORMAT CAPACITIES");
+ CMassStorageDrive* drive=GetCheckDrive(aLun);
- if (drive == NULL)
- {
- return EFalse;
- }
+ if (drive == NULL)
+ {
+ return EFalse;
+ }
- TLocalDriveCapsV4 driveInfo;
+ TLocalDriveCapsV4 driveInfo;
- TInt err = drive->Caps(driveInfo);
+ TInt err = drive->Caps(driveInfo);
- if(err != KErrNone)
- {
- __PRINT1(_L("Can't obtain drive Caps. Err=%d \n"),err);
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse;
- }
+ if(err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEREADFORMATCAPACITIES, "Can't obtain drive Caps. Err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse;
+ }
- TInt64 driveBlocks = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes();
- driveBlocks /= MAKE_TINT64(0, KDefaultBlockSize);
+ TInt64 driveBlocks = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes();
+ driveBlocks /= MAKE_TINT64(0, KDefaultBlockSize);
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetCommandBufPtr(writeBuf, KReadFormatCapacitiesCommandLength);
- writeBuf.FillZ(KReadFormatCapacitiesCommandLength);
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetCommandBufPtr(writeBuf, KReadFormatCapacitiesCommandLength);
+ writeBuf.FillZ(KReadFormatCapacitiesCommandLength);
- writeBuf[3] = 0x08; // Capacity List Length
+ writeBuf[3] = 0x08; // Capacity List Length
- TUint32 numBlocks = I64LOW(driveBlocks);
+ TUint32 numBlocks = I64LOW(driveBlocks);
- writeBuf[4] = static_cast<TUint8>((numBlocks & 0xFF000000) >> 24); // Number of blocks
- writeBuf[5] = static_cast<TUint8>((numBlocks & 0x00FF0000) >> 16); //
- writeBuf[6] = static_cast<TUint8>((numBlocks & 0x0000FF00) >> 8); //
- writeBuf[7] = static_cast<TUint8>((numBlocks & 0x000000FF)); //
+ writeBuf[4] = static_cast<TUint8>((numBlocks & 0xFF000000) >> 24); // Number of blocks
+ writeBuf[5] = static_cast<TUint8>((numBlocks & 0x00FF0000) >> 16); //
+ writeBuf[6] = static_cast<TUint8>((numBlocks & 0x0000FF00) >> 8); //
+ writeBuf[7] = static_cast<TUint8>((numBlocks & 0x000000FF)); //
- writeBuf[8] = 0x02; // Formatted size
+ writeBuf[8] = 0x02; // Formatted size
- writeBuf[9] = 0x00; // 512 Byte Blocks
- writeBuf[10] = 0x02; //
- writeBuf[11] = 0x00; //
+ writeBuf[9] = 0x00; // 512 Byte Blocks
+ writeBuf[10] = 0x02; //
+ writeBuf[11] = 0x00; //
- TPtrC8 writeBuf1 = writeBuf;
+ TPtrC8 writeBuf1 = writeBuf;
- iTransport->SetupWriteData(writeBuf1);
+ iTransport->SetupWriteData(writeBuf1);
- return ETrue;
- }
+ return ETrue;
+ }
/**
Command Parser for the READ CAPACITY(10) command (0x25)
@param aData command data (started form position 1)
-@param aLun Logic unit number
+@param aLun Logic unit number
@return ETrue if successful.
*/
TBool CScsiProtocol::HandleReadCapacity(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleReadCapacity");
- CMassStorageDrive* drive=GetCheckDrive(aLun);
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_READCAPACITY, ">>> READ CAPACITY");
+ CMassStorageDrive* drive=GetCheckDrive(aLun);
- if (drive == NULL)
- {
- return EFalse;
- }
+ if (drive == NULL)
+ {
+ return EFalse;
+ }
- TInt pmi = aData[9] & 0x01;
- TInt lba = aData[3] | aData[4] | aData[5] | aData[6];
+ TInt pmi = aData[9] & 0x01;
+ TInt lba = aData[3] | aData[4] | aData[5] | aData[6];
- if (pmi || lba) //do not support partial medium indicator
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ if (pmi || lba) //do not support partial medium indicator
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- TLocalDriveCapsV4 driveInfo;
+ TLocalDriveCapsV4 driveInfo;
- TInt err = drive->Caps(driveInfo);
+ TInt err = drive->Caps(driveInfo);
- if(err != KErrNone)
- {
- __PRINT1(_L("Can't obtain drive Caps. Err=%d \n"),err);
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse;
- }
+ if(err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEREADCAPACITY1, "ERROR: Can't obtain drive Caps Err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse;
+ }
- TInt64 driveBlocks = 0;
- if (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable)
- {
- // Partition Access only
- driveBlocks = driveInfo.iSize / MAKE_TINT64(0, KDefaultBlockSize);
- }
- else
- {
- // whole Media Access
- driveBlocks = driveInfo.MediaSizeInBytes() / MAKE_TINT64(0, KDefaultBlockSize) - 1;
- }
-
+ TInt64 driveBlocks = 0;
+ if (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable)
+ {
+ // Partition Access only
+ driveBlocks = driveInfo.iSize / MAKE_TINT64(0, KDefaultBlockSize);
+ }
+ else
+ {
+ // whole Media Access
+ driveBlocks = driveInfo.MediaSizeInBytes() / MAKE_TINT64(0, KDefaultBlockSize) - 1;
+ }
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetCommandBufPtr(writeBuf, KReadCapacityCommandLength);
- writeBuf.FillZ(KReadCapacityCommandLength);
- if (I64HIGH(driveBlocks) == 0)
- {
- TUint32 numBlocks = I64LOW(driveBlocks);
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetCommandBufPtr(writeBuf, KReadCapacityCommandLength);
+ writeBuf.FillZ(KReadCapacityCommandLength);
+
+ if (I64HIGH(driveBlocks) == 0)
+ {
+ TUint32 numBlocks = I64LOW(driveBlocks);
- __PRINT2(_L("Block size=%d, NumBlocks=%d\n"), KDefaultBlockSize, numBlocks);
- writeBuf[0] = static_cast<TUint8>((numBlocks & 0xFF000000) >> 24); // Number of blocks
- writeBuf[1] = static_cast<TUint8>((numBlocks & 0x00FF0000) >> 16);
- writeBuf[2] = static_cast<TUint8>((numBlocks & 0x0000FF00) >> 8);
- writeBuf[3] = static_cast<TUint8>((numBlocks & 0x000000FF));
- }
- else
- {
- writeBuf[0] = writeBuf[1] = writeBuf[2] = writeBuf[3] = 0xFF; // indicate that size more then )0xFFFFFFFF
- }
+ OstTraceExt2(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_HANDLEREADCAPACITY2,
+ " Block size=0x%x, NumBlocks=0x%x",
+ KDefaultBlockSize, numBlocks);
+ writeBuf[0] = static_cast<TUint8>((numBlocks & 0xFF000000) >> 24); // Number of blocks
+ writeBuf[1] = static_cast<TUint8>((numBlocks & 0x00FF0000) >> 16);
+ writeBuf[2] = static_cast<TUint8>((numBlocks & 0x0000FF00) >> 8);
+ writeBuf[3] = static_cast<TUint8>((numBlocks & 0x000000FF));
+ }
+ else
+ {
+ writeBuf[0] = writeBuf[1] = writeBuf[2] = writeBuf[3] = 0xFF; // indicate that size more then )0xFFFFFFFF
+ }
- writeBuf[4] = static_cast<TUint8>((KDefaultBlockSize & 0xFF000000) >> 24); // Block Size
- writeBuf[5] = static_cast<TUint8>((KDefaultBlockSize & 0x00FF0000) >> 16);
- writeBuf[6] = static_cast<TUint8>((KDefaultBlockSize & 0x0000FF00) >> 8);
- writeBuf[7] = static_cast<TUint8>((KDefaultBlockSize & 0x000000FF));
+ writeBuf[4] = static_cast<TUint8>((KDefaultBlockSize & 0xFF000000) >> 24); // Block Size
+ writeBuf[5] = static_cast<TUint8>((KDefaultBlockSize & 0x00FF0000) >> 16);
+ writeBuf[6] = static_cast<TUint8>((KDefaultBlockSize & 0x0000FF00) >> 8);
+ writeBuf[7] = static_cast<TUint8>((KDefaultBlockSize & 0x000000FF));
- TPtrC8 writeBuf1 = writeBuf;
- iTransport->SetupWriteData(writeBuf1);
+ TPtrC8 writeBuf1 = writeBuf;
+ iTransport->SetupWriteData(writeBuf1);
- return KErrNone;
- }
+ return KErrNone;
+ }
/**
@@ -759,109 +756,109 @@
@return ETrue if successful.
*/
TBool CScsiProtocol::HandleRead10(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleRead10");
- CMassStorageDrive* drive = GetCheckDrive(aLun);
- if (drive == NULL)
- {
- return EFalse;
- }
- TInt rdProtect = aData[2] >> 5;
- if (rdProtect)
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_READ10, ">>> READ(10)");
+ CMassStorageDrive* drive = GetCheckDrive(aLun);
+ if (drive == NULL)
+ {
+ return EFalse;
+ }
+ TInt rdProtect = aData[2] >> 5;
+ if (rdProtect)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- const TUint32 lba = LBA(aData);
- const TUint16 len = LEN(aData);
+ const TUint32 lba = LBA(aData);
+ const TUint32 len = LEN(aData);
- __PRINT2(_L("READ(10) : LBA = 0x%x, Length = %d (blocks)\n"), lba, len);
+ OstTraceExt2(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_HANDLEREAD10_1,
+ " LBA = 0x%x Transfer Len = 0x%x", lba, len);
- if (!len)
- {
- return ETrue; // do nothing - this is not an error
- }
+ if (!len)
+ {
+ return ETrue; // do nothing - this is not an error
+ }
- TLocalDriveCapsV4 driveInfo;
- TInt err = drive->Caps(driveInfo);
- if (err != KErrNone)
- {
- __PRINT1(_L("Can't obtain drive Caps. Err=%d \n"), err);
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse;
- }
+ TLocalDriveCapsV4 driveInfo;
+ TInt err = drive->Caps(driveInfo);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEREAD10_2, "Can't obtain drive Caps. Err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse;
+ }
- const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
- const TInt bLength = len * KDefaultBlockSize;
- const TInt64 theEnd = bOffset + MAKE_TINT64(0, bLength);
- const TInt64 mediaSize = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes() ;
-
- if (theEnd > mediaSize) //check if media big enough for this request
- {
- __PRINT(_L("err - Request ends out of media\n"));
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
- return EFalse;
- }
+ const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
+ const TInt bLength = len * KDefaultBlockSize;
+ const TInt64 theEnd = bOffset + MAKE_TINT64(0, bLength);
+ const TInt64 mediaSize = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes() ;
+
+ if (theEnd > mediaSize) //check if media big enough for this request
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEREAD10_3, "ERROR: Requested size is out of media range");
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
+ return EFalse;
+ }
#ifdef MSDC_MULTITHREADED
- iWriteDriveThread->WaitForWriteEmpty();
+ iWriteDriveThread->WaitForWriteEmpty();
- // check if our buffer can hold requested data
- if (iReadDriveThread->iThreadContext->MaxBufferLength() < bLength)
- {
- __PRINT(_L("err - Buffer too small\n"));
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ // check if our buffer can hold requested data
+ if (iReadDriveThread->iThreadContext->MaxBufferLength() < bLength)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEREAD10_4, "ERROR: Buffer too small");
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
// Optimisation note : If the host is reading from sectors it just wrote to,
// then we have to force a cache-miss so that the real data is read from the
- // drive. It would be possible to service the read from the write buffers,
- // but as the host is probably trying to verify the write data, we don't do
- // that for now.
- if (!iReadDriveThread->ReadDriveData(drive, bOffset, bLength, iWriteDriveThread->IsRecentlyWritten(bOffset,bLength)))
- {
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse;
- }
+ // drive. It would be possible to service the read from the write buffers,
+ // but as the host is probably trying to verify the write data, we don't do
+ // that for now.
+ if (!iReadDriveThread->ReadDriveData(drive, bOffset, bLength, iWriteDriveThread->IsRecentlyWritten(bOffset,bLength)))
+ {
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse;
+ }
- iWriteDriveThread->SetCommandWrite10(EFalse);
- TBlockDesc* &desc = iReadDriveThread->iThreadContext->iBuffer.iDescReadPtr;
- TPtrC8 writeBuf1 = desc->iBuf;
+ iWriteDriveThread->SetCommandWrite10(EFalse);
+ TBlockDesc* &desc = iReadDriveThread->iThreadContext->iBuffer.iDescReadPtr;
+ TPtrC8 writeBuf1 = desc->iBuf;
#else
-
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetReadDataBufPtr(writeBuf);
- // check if our buffer can hold requested data
- if (writeBuf.MaxLength() < bLength)
- {
- __PRINT(_L("err - Buffer too small\n"));
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetReadDataBufPtr(writeBuf);
+ // check if our buffer can hold requested data
+ if (writeBuf.MaxLength() < bLength)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- err = drive->Read(bOffset, bLength, writeBuf, drive->IsWholeMediaAccess());
+ err = drive->Read(bOffset, bLength, writeBuf, drive->IsWholeMediaAccess());
- if (err != KErrNone)
- {
- __PRINT1(_L("Read failed, err=%d\n"), err);
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse;
- }
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEREAD10_5, "ERROR: Read failed err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse;
+ }
- TPtrC8 writeBuf1 = writeBuf;
+ TPtrC8 writeBuf1 = writeBuf;
#endif // MSDC_MULTITHREADED
#ifdef USB_TRANSFER_PUBLISHER
- iBytesRead[aLun] += writeBuf1.Length();
+ iBytesRead[aLun] += writeBuf1.Length();
#endif
- iReadTransferPublisher->StartTimer();
+ iReadTransferPublisher->StartTimer();
- // Set up data write to the host
- iTransport->SetupWriteData(writeBuf1);
+ // Set up data write to the host
+ iTransport->SetupWriteData(writeBuf1);
- return ETrue;
- }
+ return ETrue;
+ }
/**
@@ -872,73 +869,73 @@
@return ETrue if successful.
*/
TBool CScsiProtocol::HandleWrite10(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleWrite10");
- CMassStorageDrive* drive = GetCheckDrive(aLun);
- if (drive == NULL)
- {
- return EFalse;
- }
- TInt wrProtect = aData[2] >> 5;
- if (wrProtect)
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_WRITE10, ">>> WRITE(10)");
+ CMassStorageDrive* drive = GetCheckDrive(aLun);
+ if (drive == NULL)
+ {
+ return EFalse;
+ }
+ TInt wrProtect = aData[2] >> 5;
+ if (wrProtect)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- const TUint32 lba = LBA(aData);
- const TUint16 len = LEN(aData);
- __PRINT2(_L("WRITE(10) : LBA = 0x%x, Length = %d (blocks)\n"), lba, len);
- if (!len)
- {
- return ETrue; // do nothing - this is not an error
- }
+ const TUint32 lba = LBA(aData);
+ const TUint32 len = LEN(aData);
+ OstTraceExt2(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_HANDLEWRITE10_1, "LBA = 0x%x, Transfer Len = 0x%x", lba, len);
+ if (!len)
+ {
+ return ETrue; // do nothing - this is not an error
+ }
- TLocalDriveCapsV4 driveInfo;
- TInt err = drive->Caps(driveInfo);
- if (err != KErrNone)
- {
- __PRINT1(_L("Can't obtain drive Caps. Err=%d \n"), err);
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse;
- }
- if (driveInfo.iMediaAtt & KMediaAttWriteProtected ||
- driveInfo.iMediaAtt & KMediaAttLocked)
- {
- iSenseInfo.SetSense(TSenseInfo::EDataProtection, TSenseInfo::EWriteProtected);
- return EFalse;
- }
+ TLocalDriveCapsV4 driveInfo;
+ TInt err = drive->Caps(driveInfo);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_WRITE10_2, "ERROR: Can't obtain drive Caps Err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse;
+ }
+ if (driveInfo.iMediaAtt & KMediaAttWriteProtected ||
+ driveInfo.iMediaAtt & KMediaAttLocked)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EDataProtection, TSenseInfo::EWriteProtected);
+ return EFalse;
+ }
- const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
- iBytesRemain = len * KDefaultBlockSize;
- const TInt64 theEnd = bOffset + MAKE_TINT64(0, iBytesRemain);
- const TInt64 mediaSize = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes() ;
+ const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
+ iBytesRemain = len * KDefaultBlockSize;
+ const TInt64 theEnd = bOffset + MAKE_TINT64(0, iBytesRemain);
+ const TInt64 mediaSize = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes() ;
- if (theEnd > mediaSize) //check if media big enough for this request
- {
- __PRINT(_L("err - Request ends out of media\n"));
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
- return EFalse;
- }
+ if (theEnd > mediaSize) //check if media big enough for this request
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEWRITE10_3, "Requested size is out of media range");
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
+ return EFalse;
+ }
#ifdef MSDC_MULTITHREADED
- iWriteDriveThread->SetCommandWrite10(ETrue);
+ iWriteDriveThread->SetCommandWrite10(ETrue);
#endif
- // Set up the first request for data from the host - either
- // KMaxBufSize or the entire transfer length, whichever is smallest.
- TUint thisLength = (iBytesRemain > KMaxBufSize) ? KMaxBufSize : iBytesRemain;
- thisLength = (thisLength > iMediaWriteSize) ? iMediaWriteSize : thisLength;
+ // Set up the first request for data from the host - either
+ // KMaxBufSize or the entire transfer length, whichever is smallest.
+ TUint thisLength = (iBytesRemain > KMaxBufSize) ? KMaxBufSize : iBytesRemain;
+ thisLength = (thisLength > iMediaWriteSize) ? iMediaWriteSize : thisLength;
- iOffset = bOffset;
- iLastCommand = EWrite10;
- iLastLun = aLun;
+ iOffset = bOffset;
+ iLastCommand = EWrite10;
+ iLastLun = aLun;
- iWriteTransferPublisher->StartTimer();
- iTransport->SetupReadData(thisLength);
+ iWriteTransferPublisher->StartTimer();
+ iTransport->SetupReadData(thisLength);
- return ETrue;
- }
+ return ETrue;
+ }
/**
@@ -949,94 +946,94 @@
@return ETrue if successful.
*/
TBool CScsiProtocol::HandleVerify10(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleVerify10");
- CMassStorageDrive* drive = GetCheckDrive(aLun);
- if (drive == NULL)
- {
- return EFalse;
- }
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_VERIFY10, ">>> VERIFY(10)");
+ CMassStorageDrive* drive = GetCheckDrive(aLun);
+ if (drive == NULL)
+ {
+ return EFalse;
+ }
- TInt vrProtect = aData[2] >> 5;
- if (vrProtect)
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ TInt vrProtect = aData[2] >> 5;
+ if (vrProtect)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- const TUint32 lba = LBA(aData);
- const TUint16 len = LEN(aData);
- __PRINT2(_L("VERIFY(10) : LBA = %d, Length = %d (blocks)\n"), lba, len);
+ const TUint32 lba = LBA(aData);
+ const TUint32 len = LEN(aData);
+ OstTraceExt2(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_VERIFY10_1, "VERIFY(10) : LBA = 0x%x Transfer Len = 0x%x", lba, len);
- TInt bytChk = aData[2] & 0x02;
- if (!len)
- {
- return ETrue; // do nothing - this is not an error
- }
+ TInt bytChk = aData[2] & 0x02;
+ if (!len)
+ {
+ return ETrue; // do nothing - this is not an error
+ }
- TLocalDriveCapsV4 driveInfo;
- TInt err = drive->Caps(driveInfo);
- if (err != KErrNone)
- {
- __PRINT1(_L("Can't obtain drive Caps. Err=%d \n"), err);
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse;
- }
+ TLocalDriveCapsV4 driveInfo;
+ TInt err = drive->Caps(driveInfo);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_VERIFY10_2, "ERROR: Can't obtain drive Caps Err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse;
+ }
- const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
- const TInt bLength = len * KDefaultBlockSize;
- const TInt64 theEnd = bOffset + MAKE_TINT64(0, bLength);
- const TInt64 mediaSize = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes() ;
+ const TInt64 bOffset = MAKE_TINT64(0, lba) * KDefaultBlockSize;
+ const TInt bLength = len * KDefaultBlockSize;
+ const TInt64 theEnd = bOffset + MAKE_TINT64(0, bLength);
+ const TInt64 mediaSize = (driveInfo.iDriveAtt & KDriveAttLogicallyRemovable) ? driveInfo.iSize : driveInfo.MediaSizeInBytes() ;
- // check if media big enough for this request
- if (theEnd > mediaSize)
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
- return EFalse;
- }
+ // check if media big enough for this request
+ if (theEnd > mediaSize)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::ELbaOutOfRange);
+ return EFalse;
+ }
- // check if our buffer can hold requested data
+ // check if our buffer can hold requested data
#ifdef MSDC_MULTITHREADED
- if (iWriteDriveThread->iThreadContext->MaxBufferLength() < bLength)
+ if (iWriteDriveThread->iThreadContext->MaxBufferLength() < bLength)
#else
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetReadDataBufPtr(writeBuf);
- if (writeBuf.MaxLength() < bLength)
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetReadDataBufPtr(writeBuf);
+ if (writeBuf.MaxLength() < bLength)
#endif
- {
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest, TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- if (!bytChk)
- {
- // BYTCHK==0 : Perform a medium verification with no data comparison and not transfer any data from the application client data-out buffer.
- // The device should attempt to read from the specified locations
+ if (!bytChk)
+ {
+ // BYTCHK==0 : Perform a medium verification with no data comparison and not transfer any data from the application client data-out buffer.
+ // The device should attempt to read from the specified locations
#ifdef MSDC_MULTITHREADED
- TPtr8 writeBuf = iWriteDriveThread->iThreadContext->GetReadBuffer(bLength);
+ TPtr8 writeBuf = iWriteDriveThread->iThreadContext->GetReadBuffer(bLength);
#else
- writeBuf.SetLength(bLength);
+ writeBuf.SetLength(bLength);
#endif
- err = drive->Read(bOffset, bLength, writeBuf, drive->IsWholeMediaAccess());
- if (err != KErrNone)
- {
- iSenseInfo.SetSense(TSenseInfo::EMisCompare);
- return EFalse;
- }
- return ETrue;
- }
+ err = drive->Read(bOffset, bLength, writeBuf, drive->IsWholeMediaAccess());
+ if (err != KErrNone)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EMisCompare);
+ return EFalse;
+ }
+ return ETrue;
+ }
- // BYTCHK==1 : perform a byte-by-byte comparison of user data read from the medium & user data transferred from the application client data-out buffer.
- // The host sends data in the data-transport phase, and the device should verify that the received data matches what is stored in the device.
+ // BYTCHK==1 : perform a byte-by-byte comparison of user data read from the medium & user data transferred from the application client data-out buffer.
+ // The host sends data in the data-transport phase, and the device should verify that the received data matches what is stored in the device.
- iOffset = bOffset;
- iLastCommand = EVerify10;
- iLastLun = aLun;
+ iOffset = bOffset;
+ iLastCommand = EVerify10;
+ iLastLun = aLun;
- iTransport->SetupReadData(bLength);
+ iTransport->SetupReadData(bLength);
- return ETrue;
- }
+ return ETrue;
+ }
/**
@@ -1051,176 +1048,138 @@
KErrNone if command processing is complete and was successful.
*/
TInt CScsiProtocol::ReadComplete(TInt aError)
- {
- __FNLOG("CScsiProtocol::ReadComplete");
- __PRINT1(_L("Error = 0x%X \n"), aError);
- const TInt64 bOffset = iOffset;
- TUint8 lastCommand = iLastCommand;
- TUint lastLun = iLastLun;
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CSCSIPROTOCOL_READCOMPLETE0, "ReadComplete = 0x%X", aError);
+ const TInt64 bOffset = iOffset;
+ TUint8 lastCommand = iLastCommand;
+ TUint lastLun = iLastLun;
- iOffset = 0;
- iLastCommand = EUndefinedCommand;
- iLastLun = KUndefinedLun;
+ iOffset = 0;
+ iLastCommand = EUndefinedCommand;
+ iLastLun = KUndefinedLun;
- __PRINT1(_L("Last command was: %s\n"),
- (lastCommand == EUndefinedCommand) ? _S("Undefined") :
- ((lastCommand == EWrite10) ? _S("EWrite10") :
- ((lastCommand == EVerify10) ? _S("EVerify10") :
- _S("Unknown"))));
+// OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CSCSIPROTOCOL_READCOMPLETE1, "lastCommand = d", lastCommand);
- if (aError != KErrNone ||
- lastCommand == EUndefinedCommand ||
- lastLun == KUndefinedLun)
- {
- iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
- return KErrAbort;
- }
+ if (aError != KErrNone ||
+ lastCommand == EUndefinedCommand ||
+ lastLun == KUndefinedLun)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
+ return KErrAbort;
+ }
- CMassStorageDrive* drive = GetCheckDrive(lastLun);
- if (drive == NULL)
- {
- return KErrAbort;
- }
+ CMassStorageDrive* drive = GetCheckDrive(lastLun);
+ if (drive == NULL)
+ {
+ return KErrAbort;
+ }
- if (lastCommand == EWrite10)
- {
- TPtrC8 writeBuf(NULL, 0);
- iTransport->GetWriteDataBufPtr(writeBuf);
-
+ if (lastCommand == EWrite10)
+ {
+ TPtrC8 writeBuf(NULL, 0);
+ iTransport->GetWriteDataBufPtr(writeBuf);
+
#ifdef USB_TRANSFER_PUBLISHER
- iBytesWritten[lastLun] += writeBuf.Length();
+ iBytesWritten[lastLun] += writeBuf.Length();
#endif
#ifdef MSDC_MULTITHREADED
- TInt err = iWriteDriveThread->WriteDriveData(drive, bOffset, writeBuf, ProcessWriteComplete, this);
+ TInt err = iWriteDriveThread->WriteDriveData(drive, bOffset, writeBuf, ProcessWriteComplete, this);
+
+ if (err != KErrNone)
+ {
+ iDeferredSenseInfo.SetSense(TSenseInfo::EMediumError);
+ }
- if (err != KErrNone)
- {
- iDeferredSenseInfo.SetSense(TSenseInfo::EMediumError);
- }
+ TUint thisLength = iWriteDriveThread->WriteBufferLength();
+#else
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CSCSIPROTOCOL_READCOMPLETE2, "SCSI: writing 0x%x bytes", writeBuf.Length());
+ TInt err = drive->Write(bOffset, writeBuf, drive->IsWholeMediaAccess());
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE_MEDIA, CSCSIPROTOCOL_READCOMPLETE3, "Error after write = 0x%x", err);
+ iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
+ return KErrAbort;
+ }
- TUint thisLength = iWriteDriveThread->WriteBufferLength();
-#else
-#ifdef MEASURE_AND_DISPLAY_WRITE_TIME
- RDebug::Print(_L("SCSI: writing %d bytes\n"), writeBuf.Length());
- TTime t0, t1;
- t0.HomeTime();
-#else
- __PRINT1(_L("SCSI: writing %d bytes\n"), writeBuf.Length());
-#endif
+ TUint thisLength = writeBuf.Length();
+#endif // MSDC_MULTITHREADED
+ iOffset = bOffset + MAKE_TINT64(0, thisLength);
+ iBytesRemain -= thisLength;
+ if ((TInt)iBytesRemain > 0)
+ {
+ // More data is expected - set up another request to read from the host
+ iLastCommand = EWrite10;
+ iLastLun = lastLun;
+
+ TUint minLength = (iBytesRemain < iMediaWriteSize) ? iBytesRemain : iMediaWriteSize;
+ TUint bytesAvail = iTransport->BytesAvailable() & ~(KDefaultBlockSize-1);
+
+ TBool wait = EFalse;
+ thisLength = bytesAvail ? bytesAvail : minLength;
+ if (thisLength < minLength)
+ {
+ // Not enough data is available at the transport to satisfy the request,
+ // so return KErrNotReady to indicate that the transport should wait.
+ thisLength = minLength;
+ wait = ETrue;
+ }
-#ifdef INJECT_ERROR
- if (writeBuf[0] == '2')
- {
- writeBuf[0] = 'x';
- RDebug::Printf("Injecting error");
- }
+ thisLength = (thisLength > KMaxBufSize) ? KMaxBufSize : thisLength;
+
+ iTransport->SetupReadData(thisLength);
- RDebug::Printf("%08lx %x [%x] [%x]", bOffset,writeBuf.Length(),
- writeBuf[0],
- writeBuf[writeBuf.Length()-1]);
+ return wait ? KErrNotReady : KErrCompletion;
+ }
+ }
+ else if (lastCommand == EVerify10)
+ {
+ HBufC8* hostData = NULL;
+ TPtrC8 writeBuf(NULL, 0);
+ iTransport->GetWriteDataBufPtr(writeBuf);
+#ifdef MSDC_MULTITHREADED
+ TRAPD(err, hostData = HBufC8::NewL(writeBuf.Length()));
+#else
+ TRAPD(err, hostData = HBufC8::NewL(writeBuf.Length()));
#endif
-
- TInt err = drive->Write(bOffset, writeBuf, drive->IsWholeMediaAccess());
+ if (err != KErrNone || hostData == NULL)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EAbortedCommand, TSenseInfo::EInsufficientRes);
+ return KErrAbort;
+ }
-#ifdef INJECT_ERROR
- if (writeBuf[0] == 'x')
- {
- err = KErrUnknown;
- }
+#ifdef MSDC_MULTITHREADED
+ // copy the data
+ *hostData = writeBuf;
+ TPtr8 readBuf = iWriteDriveThread->iThreadContext->GetReadBuffer();
+ err = drive->Read(bOffset, writeBuf.Length(), readBuf, drive->IsWholeMediaAccess());
+ if (err == KErrNone)
+ {
+ err = (hostData->Compare(readBuf) == 0) ? KErrNone : KErrCorrupt;
+ }
+#else
+ *hostData = writeBuf;
+ TPtr8 readBuf((TUint8*) writeBuf.Ptr(), writeBuf.Length());
+ err = drive->Read(bOffset, writeBuf.Length(), readBuf, drive->IsWholeMediaAccess());
+ if (err == KErrNone)
+ {
+ err = (hostData->Compare(readBuf) == 0) ? KErrNone : KErrCorrupt;
+ }
#endif
-#ifdef MEASURE_AND_DISPLAY_WRITE_TIME
- t1.HomeTime();
- const TTimeIntervalMicroSeconds time = t1.MicroSecondsFrom(t0);
- const TUint time_ms = I64LOW(time.Int64() / 1000);
- RDebug::Print(_L("SCSI: write took %d ms\n"), time_ms);
-#endif
- if (err != KErrNone)
- {
- __PRINT1(_L("Error after write = 0x%X \n"), err);
- iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
- return KErrAbort;
- }
-
- TUint thisLength = writeBuf.Length();
-#endif // MSDC_MULTITHREADED
- iOffset = bOffset + MAKE_TINT64(0, thisLength);
- iBytesRemain -= thisLength;
- if ((TInt)iBytesRemain > 0)
- {
- // More data is expected - set up another request to read from the host
- iLastCommand = EWrite10;
- iLastLun = lastLun;
-
- TUint minLength = (iBytesRemain < iMediaWriteSize) ? iBytesRemain : iMediaWriteSize;
- TUint bytesAvail = iTransport->BytesAvailable() & ~(KDefaultBlockSize-1);
-
- TBool wait = EFalse;
- thisLength = bytesAvail ? bytesAvail : minLength;
- if (thisLength < minLength)
- {
- // Not enough data is available at the transport to satisfy the request,
- // so return KErrNotReady to indicate that the transport should wait.
- thisLength = minLength;
- wait = ETrue;
- }
-
- thisLength = (thisLength > KMaxBufSize) ? KMaxBufSize : thisLength;
-
- iTransport->SetupReadData(thisLength);
+ if (err != KErrNone)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EMisCompare);
+ }
- return wait ? KErrNotReady : KErrCompletion;
- }
- }
- else if (lastCommand == EVerify10)
- {
- HBufC8* hostData = NULL;
- TPtrC8 writeBuf(NULL, 0);
- iTransport->GetWriteDataBufPtr(writeBuf);
-#ifdef MSDC_MULTITHREADED
- TRAPD(err, hostData = HBufC8::NewL(writeBuf.Length()));
-#else
- TRAPD(err, hostData = HBufC8::NewL(writeBuf.Length()));
-#endif
- if (err != KErrNone || hostData == NULL)
- {
- iSenseInfo.SetSense(TSenseInfo::EAbortedCommand, TSenseInfo::EInsufficientRes);
- return KErrAbort;
- }
-
-#ifdef MSDC_MULTITHREADED
- // copy the data
- *hostData = writeBuf;
- TPtr8 readBuf = iWriteDriveThread->iThreadContext->GetReadBuffer();
- err = drive->Read(bOffset, writeBuf.Length(), readBuf, drive->IsWholeMediaAccess());
- if (err == KErrNone)
- {
- err = (hostData->Compare(readBuf) == 0) ? KErrNone : KErrCorrupt;
- }
-#else
- *hostData = writeBuf;
- TPtr8 readBuf((TUint8*) writeBuf.Ptr(), writeBuf.Length());
- err = drive->Read(bOffset, writeBuf.Length(), readBuf, drive->IsWholeMediaAccess());
- if (err == KErrNone)
- {
- err = (hostData->Compare(readBuf) == 0) ? KErrNone : KErrCorrupt;
- }
-#endif
-
- if (err != KErrNone)
- {
- iSenseInfo.SetSense(TSenseInfo::EMisCompare);
- }
-
- delete hostData;
- }
- else // unknown command
- {
- iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
- }
- return iSenseInfo.SenseOk() ? KErrNone : KErrAbort;
- }
+ delete hostData;
+ }
+ else // unknown command
+ {
+ iSenseInfo.SetSense(TSenseInfo::EAbortedCommand);
+ }
+ return iSenseInfo.SenseOk() ? KErrNone : KErrAbort;
+ }
/**
@@ -1229,57 +1188,55 @@
@return ETrue if successful.
*/
TBool CScsiProtocol::HandleModeSense6(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleModeSense6");
-
- TInt pageCode = aData[3] & 0x3F;
- TUint8 pageControl= static_cast<TUint8>(aData[3] >>6);
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_MODESENSE6, ">>> MODESENSE(06)");
+ TInt pageCode = aData[3] & 0x3F;
+ TUint8 pageControl= static_cast<TUint8>(aData[3] >>6);
- if (pageCode != KAllPages || pageControl == KChangeableValues)
- {
- __PRINT(_L("TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb"));
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ if (pageCode != KAllPages || pageControl == KChangeableValues)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- // reserve 4 bytes for Length, Media type, Device-specific parameter and Block descriptor length
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetCommandBufPtr(writeBuf, KModeSense6CommandLength);
- writeBuf.FillZ(KModeSense6CommandLength);
+ // reserve 4 bytes for Length, Media type, Device-specific parameter and Block descriptor length
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetCommandBufPtr(writeBuf, KModeSense6CommandLength);
+ writeBuf.FillZ(KModeSense6CommandLength);
- if (pageControl != KDefaultValues)
- {
- //check if drive write protected
- CMassStorageDrive* drive=GetCheckDrive(aLun);
- if (drive == NULL)
- {
- __PRINT(_L("drive == null"));
- return EFalse;
- }
+ if (pageControl != KDefaultValues)
+ {
+ //check if drive write protected
+ CMassStorageDrive* drive=GetCheckDrive(aLun);
+ if (drive == NULL)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEMODESENSE6_1, "drive == null");
+ return EFalse;
+ }
- TLocalDriveCapsV4 driveInfo;
- TInt err = drive->Caps(driveInfo);
- if (err != KErrNone)
- {
- __PRINT(_L("TSenseInfo::ENotReady"));
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse ;
- }
+ TLocalDriveCapsV4 driveInfo;
+ TInt err = drive->Caps(driveInfo);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_MODESENSE6_2, "ERROR: Can't obtain drive Caps Err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse ;
+ }
- if (driveInfo.iMediaAtt & KMediaAttWriteProtected)
- {
- writeBuf[2] = 1<<7; // set SWP bit at the Device Specific parameters
- }
- }
+ if (driveInfo.iMediaAtt & KMediaAttWriteProtected)
+ {
+ writeBuf[2] = 1<<7; // set SWP bit at the Device Specific parameters
+ }
+ }
- writeBuf[0]=3; //Sending only Mode parameter header
+ writeBuf[0]=3; //Sending only Mode parameter header
- TPtrC8 writeBuf1 = writeBuf;
+ TPtrC8 writeBuf1 = writeBuf;
- iTransport->SetupWriteData(writeBuf1);
+ iTransport->SetupWriteData(writeBuf1);
- return (iSenseInfo.SenseOk());
- }
+ return (iSenseInfo.SenseOk());
+ }
/**
@@ -1288,57 +1245,55 @@
@return ETrue if successful.
*/
TBool CScsiProtocol::HandleModeSense10(TPtrC8& aData, TUint aLun)
- {
- __FNLOG("CScsiProtocol::HandleModeSense10");
-
- TInt pageCode = aData[3] & 0x3F;
- TUint8 pageControl= static_cast<TUint8>(aData[3] >>6);
+ {
+ OstTrace0(TRACE_SMASSSTORAGE_SCSI, CSCSIPROTOCOL_MODESENSE10, ">>> MODESENSE(10)");
+ TInt pageCode = aData[3] & 0x3F;
+ TUint8 pageControl= static_cast<TUint8>(aData[3] >>6);
- if (pageCode != KAllPages || pageControl == KChangeableValues)
- {
- __PRINT(_L("TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb"));
- iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb);
- return EFalse;
- }
+ if (pageCode != KAllPages || pageControl == KChangeableValues)
+ {
+ iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb);
+ return EFalse;
+ }
- // reserve 8 bytes for Length, Media type, Device-specific parameter and Block descriptor length
- TPtr8 writeBuf(NULL, 0);
- iTransport->GetCommandBufPtr(writeBuf, KModeSense10CommandLength);
- writeBuf.FillZ(KModeSense10CommandLength);
+ // reserve 8 bytes for Length, Media type, Device-specific parameter and Block descriptor length
+ TPtr8 writeBuf(NULL, 0);
+ iTransport->GetCommandBufPtr(writeBuf, KModeSense10CommandLength);
+ writeBuf.FillZ(KModeSense10CommandLength);
- if (pageControl != KDefaultValues)
- {
- //check if drive write protected
- CMassStorageDrive* drive=GetCheckDrive(aLun);
- if (drive == NULL)
- {
- __PRINT(_L("drive == null"));
- return EFalse;
- }
+ if (pageControl != KDefaultValues)
+ {
+ //check if drive write protected
+ CMassStorageDrive* drive=GetCheckDrive(aLun);
+ if (drive == NULL)
+ {
+ OstTrace0(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_HANDLEMODESENSE10_1, "drive == null");
+ return EFalse;
+ }
- TLocalDriveCapsV4 driveInfo;
- TInt err = drive->Caps(driveInfo);
- if (err != KErrNone)
- {
- __PRINT(_L("TSenseInfo::ENotReady"));
- iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
- return EFalse ;
- }
+ TLocalDriveCapsV4 driveInfo;
+ TInt err = drive->Caps(driveInfo);
+ if (err != KErrNone)
+ {
+ OstTrace1(TRACE_SMASSSTORAGE, CSCSIPROTOCOL_MODESENSE10_1, "ERROR: Can't obtain drive Caps Err=%d", err);
+ iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent);
+ return EFalse ;
+ }
- if (driveInfo.iMediaAtt & KMediaAttWriteProtected)
- {
- writeBuf[3] = 1<<7; // set SWP bit at the Device Specific parameters
- }
- }
+ if (driveInfo.iMediaAtt & KMediaAttWriteProtected)
+ {
+ writeBuf[3] = 1<<7; // set SWP bit at the Device Specific parameters
+ }
+ }
- writeBuf[1]=6; //Sending only Mode parameter header
+ writeBuf[1]=6; //Sending only Mode parameter header
- TPtrC8 writeBuf1 = writeBuf;
+ TPtrC8 writeBuf1 = writeBuf;
- iTransport->SetupWriteData(writeBuf1);
+ iTransport->SetupWriteData(writeBuf1);
- return (iSenseInfo.SenseOk());
- }
+ return (iSenseInfo.SenseOk());
+ }
--- a/userlibandfileserver/fileserver/smassstorage/smassstorage.mmh Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/smassstorage/smassstorage.mmh Mon Oct 11 17:54:41 2010 +0100
@@ -20,9 +20,11 @@
@file
*/
-TARGETTYPE fsy
+TARGETTYPE fsy
USERINCLUDE ../inc
+USERINCLUDE traces
+
#ifdef SYMBIAN_OLD_EXPORT_LOCATION
SYSTEMINCLUDE ../inc
SYMBIAN_BASE_SYSTEMINCLUDE(kernel)
@@ -32,12 +34,17 @@
SOURCEPATH ../smassstorage
SOURCE scsiprot.cpp
SOURCE cbulkonlytransport.cpp
+
+// Double Buffering media interface
SOURCE cbulkonlytransportusbcldd.cpp
+SOURCE tbulkmm.cpp
+SOURCE rwdrivethread.cpp
+// Shared Chunk media interface
#if !defined(WINS) && !defined(GENERIC_X86)
SOURCE cbulkonlytransportusbcscldd.cpp
#endif
+
SOURCE cactivedevicestatenotifierbase.cpp
-SOURCE rwdrivethread.cpp
SOURCE cmassstoragefilesystem.cpp
SOURCE cmassstoragemountcb.cpp
SOURCE cusbmassstoragecontroller.cpp
@@ -47,20 +54,22 @@
SOURCE drivepublisher.cpp
LIBRARY efile.lib efsrv.lib euser.lib
+
+// Shared Chunk library
#if !defined(WINS) && !defined(GENERIC_X86)
LIBRARY usbcsc_bil.lib
#endif
SOURCEPATH .
-DOCUMENT ../group/release.txt
+DOCUMENT ../group/release.txt
START WINS
-BASEADDRESS 0x61000000
+BASEADDRESS 0x61000000
END
-UID 0 0x100000d6 //TODO reserve new UID
+UID 0 0x100000d6 //TODO reserve new UID
unpaged
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/userlibandfileserver/fileserver/smassstorage/tbulkmm.cpp Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <e32base.h>
+#include "tbulkmm.h"
+
+#ifdef MSDC_MULTITHREADED
+TBulkMm::TBulkMm()
+: iSwap(ETrue)
+ {
+ }
+
+
+void TBulkMm::GetNextTransferBuffer(TUint aLength, TPtr8& aPtr)
+ {
+ if (iSwap)
+ {
+ iDataBuf1.SetLength(aLength);
+ aPtr.Set(iDataBuf1.LeftTPtr(iDataBuf1.Length()));
+ iSwap = EFalse;
+ }
+ else
+ {
+ iDataBuf2.SetLength(aLength);
+ aPtr.Set(iDataBuf2.LeftTPtr(iDataBuf2.Length()));
+ iSwap = ETrue;
+ }
+ }
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/userlibandfileserver/fileserver/smassstorage/traces/OstTraceDefinitions.h Mon Oct 11 17:54:41 2010 +0100
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+
+#ifndef __OSTTRACEDEFINITIONS_H__
+#define __OSTTRACEDEFINITIONS_H__
+// OST_TRACE_COMPILER_IN_USE flag has been added by Trace Compiler
+// REMOVE BEFORE CHECK-IN TO VERSION CONTROL
+//#define OST_TRACE_COMPILER_IN_USE
+#include <opensystemtrace.h>
+#endif