56 |
56 |
57 /** |
57 /** |
58 Sense Info |
58 Sense Info |
59 */ |
59 */ |
60 class TSenseInfo |
60 class TSenseInfo |
61 { |
61 { |
62 public: |
62 public: |
63 // Spec: SCSI Primary Commands 3 (SPC-3) |
63 // Spec: SCSI Primary Commands 3 (SPC-3) |
64 // Section 4.5.6 Sense key and sense code defintions |
64 // Section 4.5.6 Sense key and sense code defintions |
65 // Table 27 - Sense key descriptions |
65 // Table 27 - Sense key descriptions |
66 enum TSenseCode |
66 enum TSenseCode |
67 { |
67 { |
68 ENoSense = 0, |
68 ENoSense = 0, |
69 ERecoveredError = 1, |
69 ERecoveredError = 1, |
70 ENotReady = 2, |
70 ENotReady = 2, |
71 EMediumError = 3, |
71 EMediumError = 3, |
72 EHardwareError = 4, |
72 EHardwareError = 4, |
73 EIllegalRequest = 5, |
73 EIllegalRequest = 5, |
74 EUnitAttention = 6, |
74 EUnitAttention = 6, |
75 EDataProtection = 7, |
75 EDataProtection = 7, |
76 EBlankCheck = 8, |
76 EBlankCheck = 8, |
77 EVendorSpecific = 9, |
77 EVendorSpecific = 9, |
78 ECopyAborted = 10, |
78 ECopyAborted = 10, |
79 EAbortedCommand = 11, |
79 EAbortedCommand = 11, |
80 EDataOverflow = 13, |
80 EDataOverflow = 13, |
81 EMisCompare = 14 |
81 EMisCompare = 14 |
82 }; |
82 }; |
83 |
83 |
84 // Table 28 - ASC and ASQ assignments |
84 // Table 28 - ASC and ASQ assignments |
85 enum TAdditionalCode |
85 enum TAdditionalCode |
86 { |
86 { |
87 EAscNull = 0x00, |
87 EAscNull = 0x00, |
88 EAscLogicalUnitNotReady = 0x04, |
88 EAscLogicalUnitNotReady = 0x04, |
89 EAscLogicalUnitDoesNotRespondToSelection = 0x05, |
89 EAscLogicalUnitDoesNotRespondToSelection = 0x05, |
90 EInvalidCmdCode = 0x20, |
90 EInvalidCmdCode = 0x20, |
91 ELbaOutOfRange = 0x21, |
91 ELbaOutOfRange = 0x21, |
92 EInvalidFieldInCdb = 0x24, |
92 EInvalidFieldInCdb = 0x24, |
93 ELuNotSupported = 0x25, |
93 ELuNotSupported = 0x25, |
94 EWriteProtected = 0x27, |
94 EWriteProtected = 0x27, |
95 ENotReadyToReadyChange = 0x28, |
95 ENotReadyToReadyChange = 0x28, |
96 EMediaNotPresent = 0x3A, |
96 EMediaNotPresent = 0x3A, |
97 EInsufficientRes = 0x55 |
97 EInsufficientRes = 0x55 |
98 }; |
98 }; |
99 |
99 |
100 enum TAdditionalSenseCodeQualifier |
100 enum TAdditionalSenseCodeQualifier |
101 { |
101 { |
102 EAscqNull = 0x00, |
102 EAscqNull = 0x00, |
103 EAscqLogicalUnitIsInProcessOfBecomingReady = 0x01 |
103 EAscqLogicalUnitIsInProcessOfBecomingReady = 0x01 |
104 }; |
104 }; |
105 |
105 |
106 public: |
106 public: |
107 TSenseInfo(); |
107 TSenseInfo(); |
108 |
108 |
109 void SetSense(TSenseCode aSenseCode); |
109 void SetSense(TSenseCode aSenseCode); |
110 |
110 |
111 void SetSense(TSenseCode aSenseCode, |
111 void SetSense(TSenseCode aSenseCode, |
112 TAdditionalCode aAdditional); |
112 TAdditionalCode aAdditional); |
113 |
113 |
114 void SetSense(TSenseCode aSenseCode, |
114 void SetSense(TSenseCode aSenseCode, |
115 TAdditionalCode aAdditional, |
115 TAdditionalCode aAdditional, |
116 TAdditionalSenseCodeQualifier aQualifier); |
116 TAdditionalSenseCodeQualifier aQualifier); |
117 |
117 |
118 TBool SenseOk(); |
118 TBool SenseOk(); |
119 |
119 |
120 public: |
120 public: |
121 TUint8 iSenseCode; |
121 TUint8 iSenseCode; |
122 TUint8 iAdditional; |
122 TUint8 iAdditional; |
123 TUint8 iQualifier; |
123 TUint8 iQualifier; |
124 }; |
124 }; |
125 |
125 |
126 |
126 |
127 /** |
127 /** |
128 Returns EFalse if a sense code has been set. |
128 Returns EFalse if a sense code has been set. |
129 Note that ENoSense indicates that there is no specific sense key infotmation |
129 Note that ENoSense indicates that there is no specific sense key infotmation |
130 to be reported and the command was successful. |
130 to be reported and the command was successful. |
131 */ |
131 */ |
132 inline TBool TSenseInfo::SenseOk() |
132 inline TBool TSenseInfo::SenseOk() |
133 { |
133 { |
134 return (iSenseCode == ENoSense); |
134 return (iSenseCode == ENoSense); |
135 } |
135 } |
136 |
136 |
137 |
137 |
138 const TUint KModeSense6CommandLength = 4; |
138 const TUint KModeSense6CommandLength = 4; |
139 const TUint KModeSense10CommandLength = 8; |
139 const TUint KModeSense10CommandLength = 8; |
140 const TUint KReadCapacityCommandLength = 8; |
140 const TUint KReadCapacityCommandLength = 8; |
148 and where appropriate routing specific requests through to the appropriate drive unit. |
148 and where appropriate routing specific requests through to the appropriate drive unit. |
149 |
149 |
150 @internalTechnology |
150 @internalTechnology |
151 */ |
151 */ |
152 class CScsiProtocol : public CBase, public MProtocolBase |
152 class CScsiProtocol : public CBase, public MProtocolBase |
153 { |
153 { |
154 public: |
154 public: |
155 enum TCommand |
155 enum TCommand |
156 { |
156 { |
157 ETestUnitReady = 0x00, |
157 ETestUnitReady = 0x00, |
158 ERequestSense = 0x03, |
158 ERequestSense = 0x03, |
159 EInquiry = 0x12, |
159 EInquiry = 0x12, |
160 EModeSense6 = 0x1A, |
160 EModeSense6 = 0x1A, |
161 EStartStopUnit = 0x1B, |
161 EStartStopUnit = 0x1B, |
162 EPreventMediaRemoval = 0x1E, |
162 EPreventMediaRemoval = 0x1E, |
163 EReadFormatCapacities = 0x23, |
163 EReadFormatCapacities = 0x23, |
164 EReadCapacity = 0x25, |
164 EReadCapacity = 0x25, |
165 ERead10 = 0x28, |
165 ERead10 = 0x28, |
166 EWrite10 = 0x2A, |
166 EWrite10 = 0x2A, |
167 EVerify10 = 0x2f, |
167 EVerify10 = 0x2f, |
168 EModeSense10 = 0x5A, |
168 EModeSense10 = 0x5A, |
169 EUndefinedCommand = 0xFF |
169 EUndefinedCommand = 0xFF |
170 }; |
170 }; |
171 |
171 |
172 |
172 |
173 public: |
173 public: |
174 |
174 |
175 static CScsiProtocol* NewL(CDriveManager& aDriveManager); |
175 static CScsiProtocol* NewL(CDriveManager& aDriveManager); |
176 void RegisterTransport(MTransportBase* aTransport); |
176 void RegisterTransport(MTransportBase* aTransport); |
177 void ReportHighSpeedDevice(); |
177 void ReportHighSpeedDevice(); |
178 TBool DecodePacket(TPtrC8& aData, TUint aLun); |
178 TBool DecodePacket(TPtrC8& aData, TUint aLun); |
179 TInt ReadComplete(TInt aError); |
179 TInt ReadComplete(TInt aError); |
180 TInt SetScsiParameters(TMassStorageConfig aConfig); |
180 TInt SetScsiParameters(TMassStorageConfig aConfig); |
181 TInt Cancel(); |
181 TInt Cancel(); |
182 ~CScsiProtocol(); |
182 ~CScsiProtocol(); |
183 |
183 |
184 #ifdef MSDC_MULTITHREADED |
184 #ifdef MSDC_MULTITHREADED |
185 void InitializeBufferPointers(TPtr8& aDes1, TPtr8& aDes2); |
185 void InitializeBufferPointers(TPtr8& aDes1, TPtr8& aDes2); |
186 static void ProcessWriteComplete (TUint8* aAddress, TAny* aPtr); //todo const |
186 static void ProcessWriteComplete (TUint8* aAddress, TAny* aPtr); //todo const |
187 #endif |
187 #endif |
188 |
188 |
189 private: |
189 private: |
190 CScsiProtocol(CDriveManager& aDriveManager); |
190 CScsiProtocol(CDriveManager& aDriveManager); |
191 void ConstructL(); |
191 void ConstructL(); |
192 CMassStorageDrive* GetCheckDrive(TUint aLun); |
192 CMassStorageDrive* GetCheckDrive(TUint aLun); |
193 TBool HandleUnitReady(TUint aLun); |
193 TBool HandleUnitReady(TUint aLun); |
194 TBool HandleRequestSense(TPtrC8& aData); |
194 TBool HandleRequestSense(TPtrC8& aData); |
195 TBool HandleInquiry(TPtrC8& aData, TUint aLun); |
195 TBool HandleInquiry(TPtrC8& aData, TUint aLun); |
196 TBool HandleStartStopUnit(TPtrC8& aData, TUint aLun); |
196 TBool HandleStartStopUnit(TPtrC8& aData, TUint aLun); |
197 TBool HandlePreventMediaRemoval(TPtrC8& aData, TUint aLun); |
197 TBool HandlePreventMediaRemoval(TPtrC8& aData, TUint aLun); |
198 TBool HandleReadCapacity(TPtrC8& aData, TUint aLun); |
198 TBool HandleReadCapacity(TPtrC8& aData, TUint aLun); |
199 TBool HandleRead10(TPtrC8& aData, TUint aLun); |
199 TBool HandleRead10(TPtrC8& aData, TUint aLun); |
200 TBool HandleWrite10(TPtrC8& aData, TUint aLun); |
200 TBool HandleWrite10(TPtrC8& aData, TUint aLun); |
201 TBool HandleVerify10(TPtrC8& aData, TUint aLun); |
201 TBool HandleVerify10(TPtrC8& aData, TUint aLun); |
202 TBool HandleModeSense6(TPtrC8& aData, TUint aLun); |
202 TBool HandleModeSense6(TPtrC8& aData, TUint aLun); |
203 TBool HandleModeSense10(TPtrC8& aData, TUint aLun); |
203 TBool HandleModeSense10(TPtrC8& aData, TUint aLun); |
204 TBool HandleReadFormatCapacities(TUint aLun); |
204 TBool HandleReadFormatCapacities(TUint aLun); |
205 |
205 |
206 private: |
206 private: |
207 /** Configuration data for INQUIRY command*/ |
207 /** Configuration data for INQUIRY command*/ |
208 TMassStorageConfig iConfig; |
208 TMassStorageConfig iConfig; |
209 |
209 |
210 /** reference to the Drive Manager */ |
210 /** reference to the Drive Manager */ |
211 CDriveManager& iDriveManager; |
211 CDriveManager& iDriveManager; |
212 |
212 |
213 /** pointer to the transport level */ |
213 /** pointer to the transport level */ |
214 MTransportBase* iTransport; |
214 MTransportBase* iTransport; |
215 |
215 |
216 /** Sense Info */ |
216 /** Sense Info */ |
217 TSenseInfo iSenseInfo; |
217 TSenseInfo iSenseInfo; |
218 |
218 |
219 #ifdef MSDC_MULTITHREADED |
219 #ifdef MSDC_MULTITHREADED |
220 /** Sense Info */ |
220 /** Sense Info */ |
221 TSenseInfo iDeferredSenseInfo; |
221 TSenseInfo iDeferredSenseInfo; |
222 #endif |
222 #endif |
223 |
223 |
224 /** Start offset (in bytes) for Write/Verify */ |
224 /** Start offset (in bytes) for Write/Verify */ |
225 TInt64 iOffset; |
225 TInt64 iOffset; |
226 |
226 |
227 /** Last command for SetupRead (Write or Verify) */ |
227 /** Last command for SetupRead (Write or Verify) */ |
228 TUint8 iLastCommand; |
228 TUint8 iLastCommand; |
229 |
229 |
230 /** LUN for SetupRead */ |
230 /** LUN for SetupRead */ |
231 TUint iLastLun; |
231 TUint iLastLun; |
232 |
232 |
233 #ifdef SIMDISK |
233 #ifdef SIMDISK |
234 CArrayFixFlat<TUint8>* iSimDisk; |
234 CArrayFixFlat<TUint8>* iSimDisk; |
235 #endif |
235 #endif |
236 |
236 |
237 /** The number of bytes remaining to be read from the host for write operations */ |
237 /** The number of bytes remaining to be read from the host for write operations */ |
238 TUint32 iBytesRemain; |
238 TUint32 iBytesRemain; |
239 |
239 |
240 /** Write to the media when this amount of data is available */ |
240 /** Write to the media when this amount of data is available */ |
241 TUint32 iMediaWriteSize; |
241 TUint32 iMediaWriteSize; |
242 |
242 |
243 #ifdef MSDC_MULTITHREADED |
243 #ifdef MSDC_MULTITHREADED |
244 /** Ptr to Write Thread instance */ |
244 /** Ptr to Write Thread instance */ |
245 CWriteDriveThread* iWriteDriveThread; |
245 CWriteDriveThread* iWriteDriveThread; |
246 |
246 |
247 /** Ptr to Read Thread instance */ |
247 /** Ptr to Read Thread instance */ |
248 CReadDriveThread* iReadDriveThread; |
248 CReadDriveThread* iReadDriveThread; |
249 #endif // MSDC_MULTITHREADED |
249 #endif // MSDC_MULTITHREADED |
250 |
250 |
251 #ifdef USB_TRANSFER_PUBLISHER |
251 #ifdef USB_TRANSFER_PUBLISHER |
252 /** |
252 /** |
253 Publish and subscribe properties for tracking data transfer volume |
253 Publish and subscribe properties for tracking data transfer volume |
254 */ |
254 */ |
255 CUsbWriteTransferPublisher* iWriteTransferPublisher; |
255 CUsbWriteTransferPublisher* iWriteTransferPublisher; |
256 CUsbReadTransferPublisher* iReadTransferPublisher; |
256 CUsbReadTransferPublisher* iReadTransferPublisher; |
257 |
257 |
258 /** |
258 /** |
259 Cumulative bytes read |
259 Cumulative bytes read |
260 */ |
260 */ |
261 TFixedArray<TInt64, KUsbMsMaxDrives> iBytesRead; |
261 TFixedArray<TInt64, KUsbMsMaxDrives> iBytesRead; |
262 /** |
262 /** |
263 Cumulative bytes written |
263 Cumulative bytes written |
264 */ |
264 */ |
265 TFixedArray<TInt64, KUsbMsMaxDrives> iBytesWritten; |
265 TFixedArray<TInt64, KUsbMsMaxDrives> iBytesWritten; |
266 #else |
266 #else |
267 /** |
267 /** |
268 Publish and subscribe properties for tracking data transfer volume |
268 Publish and subscribe properties for tracking data transfer volume |
269 */ |
269 */ |
270 CDriveWriteTransferPublisher* iWriteTransferPublisher; |
270 CDriveWriteTransferPublisher* iWriteTransferPublisher; |
271 CDriveReadTransferPublisher* iReadTransferPublisher; |
271 CDriveReadTransferPublisher* iReadTransferPublisher; |
272 #endif |
272 #endif |
273 }; |
273 }; |
274 |
274 |
275 #endif // __SCSIPROT_H__ |
275 #endif // __SCSIPROT_H__ |