--- 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__