os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/include/cscsiprotocol.h
First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #ifndef CSCSIPROTOCOL_H
22 #define CSCSIPROTOCOL_H
24 class CMassStorageFsm;
26 class TSbcClientInterface;
28 class RMediaChangeNotifier
31 RMediaChangeNotifier();
32 ~RMediaChangeNotifier();
34 void Register(const RMessage2& aMessage);
39 void CompleteNotifierL(TInt);
42 /** Notification service */
44 /** Flag to indicate that media change notification is active */
50 SCSI Protocol procedures
52 class CScsiProtocol: public CBase, public MProtocol, public MBlockTransferProtocol
62 static CScsiProtocol* NewL(TLun aLun, MTransport& aTransport);
65 void ConstructL(TLun aLun);
66 CScsiProtocol(MTransport& aTransport);
69 void InitialiseUnitL();
71 // Stop unit command to uninitialise the lun
72 void UninitialiseUnitL();
74 // Read command to read the media
75 void ReadL(TPos aPos, TDes8& aCopybuf, TInt aLen);
77 // Write command to write to the media
78 void WriteL(TPos aPos, TDesC8& aCopybuf, TInt aLen);
80 // ReadCapacity command to find the capacity of the media
81 void GetCapacityL(TCapsInfo& aCapsInfo);
84 void CreateSbcInterfaceL(TUint32 aBlockLen, TUint32 aLastLba);
86 void DoScsiReadyCheckEventL();
88 void NotifyChange(const RMessage2& aMessage);
89 void ForceCompleteNotifyChangeL();
90 void CancelChangeNotifierL();
91 void CompleteNotifyChangeL();
96 // Supported Mass Storage commands
98 TInt MsTestUnitReadyL();
99 TInt MsStartStopUnitL(TBool aStart);
100 TInt MsPreventAllowMediaRemovalL(TBool aPrevent);
102 TInt MsReadCapacityL();
103 TInt MsModeSense10L();
104 TInt MsModeSense6L();
106 TInt MsRequestSenseL();
108 TBool MsIsSbcSet() const;
109 TBool MsIsRemovableMedia() const;
110 const TSenseInfo& MsSenseInfo() const;
112 // MBlockTransferProtocol interface
113 void BlockReadL(TPos aPos, TDes8& aBuf, TInt aLength);
114 void BlockWriteL(TPos aPos, TDesC8& aBuf, TUint aOffset, TInt aLength);
119 void DoCheckConditionL();
121 TInt GetSystemWideSenseError(const TSenseInfo& aSenseInfo);
122 TInt ProcessAsCodes(const TSenseInfo& aSenseInfo);
126 /** State machine for device initialisation protocol */
127 CMassStorageFsm* iFsm;
129 /** SCSI SPC interface methods */
130 TSpcClientInterface iSpcInterface;
131 /** SCSI SBC interface methods */
132 TSbcClientInterface* iSbcInterface;
133 // buffers for block manipulation (for use in iSbcInterface)
137 // Logical Unit properties
139 TBool iRemovableMedia;
140 /** LU write protected */
143 /** Result of the last SCSI command */
144 TSenseInfo iSenseInfo;
146 /** State of the LUN represented by this object */
149 /** Notifier for media changes */
150 RMediaChangeNotifier iMediaChangeNotifier;
155 Returns the state of the SBC interface. INQUIRY command is used to detect if
156 device supports SBC and initialise the SBC interface.
158 @return TBool ETrue is SBC interface is initialised
160 inline TBool CScsiProtocol::MsIsSbcSet() const
162 return iSbcInterface ? ETrue : EFalse;
166 Returns the device removable property. MODE SENSE command is used to detect if
167 the device is removable.
169 @return TBool ETrue if device is removable
171 inline TBool CScsiProtocol::MsIsRemovableMedia() const
173 return iRemovableMedia;
178 Helper to return current SenseInfo. SCSI REQUEST SENSE command sets the sense
179 info. The protocol will retrieve device's sense info in the event of a SCSI
182 @return const TSenseInfo&
184 inline const TSenseInfo& CScsiProtocol::MsSenseInfo() const
189 #endif // CSCSIPROTOCOL_H