131 void CScsiProtocol::ReadL(TPos aPos, |
135 void CScsiProtocol::ReadL(TPos aPos, |
132 TDes8& aBuf, |
136 TDes8& aBuf, |
133 TInt aLength) |
137 TInt aLength) |
134 { |
138 { |
135 __MSFNLOG |
139 __MSFNLOG |
|
140 |
|
141 if (!iSbcInterface) |
|
142 User::Leave(KErrNotSupported); |
|
143 |
136 if(!IsConnected()) |
144 if(!IsConnected()) |
137 User::Leave(KErrNotReady); |
145 User::Leave(KErrNotReady); |
138 iSbcInterface->iBlockTransfer.ReadL(*this, aPos, aLength, aBuf); |
146 iSbcInterface->iBlockTransfer.ReadL(*this, aPos, aLength, aBuf); |
139 } |
147 } |
140 |
148 |
141 |
149 |
142 void CScsiProtocol::BlockReadL(TPos aPos, TDes8& aCopybuf, TInt aLen) |
150 void CScsiProtocol::BlockReadL(TPos aPos, TDes8& aCopybuf, TInt aLen) |
143 { |
151 { |
144 __MSFNLOG |
152 __MSFNLOG |
|
153 if (!iSbcInterface) |
|
154 User::Leave(KErrNotSupported); |
|
155 |
145 __ASSERT_DEBUG(aPos % iSbcInterface->iBlockTransfer.BlockLength() == 0, |
156 __ASSERT_DEBUG(aPos % iSbcInterface->iBlockTransfer.BlockLength() == 0, |
146 User::Panic(KUsbMsHostPanicCat, EBlockDevice)); |
157 User::Panic(KUsbMsHostPanicCat, EBlockDevice)); |
147 |
158 |
148 const TInt blockLen = iSbcInterface->iBlockTransfer.BlockLength(); |
159 const TInt blockLen = iSbcInterface->iBlockTransfer.BlockLength(); |
149 TInt len = aLen; |
160 TInt len = aLen; |
194 void CScsiProtocol::WriteL(TPos aPosition, |
205 void CScsiProtocol::WriteL(TPos aPosition, |
195 TDesC8& aBuf, |
206 TDesC8& aBuf, |
196 TInt aLength) |
207 TInt aLength) |
197 { |
208 { |
198 __MSFNLOG |
209 __MSFNLOG |
|
210 if (!iSbcInterface) |
|
211 User::Leave(KErrNotSupported); |
|
212 |
199 if(!IsConnected()) |
213 if(!IsConnected()) |
200 User::Leave(KErrNotReady); |
214 User::Leave(KErrNotReady); |
201 iSbcInterface->iBlockTransfer.WriteL(*this, aPosition, aLength, aBuf); |
215 iSbcInterface->iBlockTransfer.WriteL(*this, aPosition, aLength, aBuf); |
202 } |
216 } |
203 |
217 |
204 |
218 |
205 void CScsiProtocol::BlockWriteL(TPos aPos, TDesC8& aCopybuf, TUint aOffset, TInt aLen) |
219 void CScsiProtocol::BlockWriteL(TPos aPos, TDesC8& aCopybuf, TUint aOffset, TInt aLen) |
206 { |
220 { |
207 __MSFNLOG |
221 __MSFNLOG |
|
222 if (!iSbcInterface) |
|
223 User::Leave(KErrNotSupported); |
|
224 |
208 __ASSERT_DEBUG(aPos % iSbcInterface->iBlockTransfer.BlockLength() == 0, |
225 __ASSERT_DEBUG(aPos % iSbcInterface->iBlockTransfer.BlockLength() == 0, |
209 User::Panic(KUsbMsHostPanicCat, EBlockDevice)); |
226 User::Panic(KUsbMsHostPanicCat, EBlockDevice)); |
210 const TInt blockLen = iSbcInterface->iBlockTransfer.BlockLength(); |
227 const TInt blockLen = iSbcInterface->iBlockTransfer.BlockLength(); |
211 TInt len = aLen; |
228 TInt len = aLen; |
212 TInt err = iSbcInterface->Write10L(aPos/blockLen, aCopybuf, aOffset, len); |
229 TInt err = iSbcInterface->Write10L(aPos/blockLen, aCopybuf, aOffset, len); |
349 &info.iIdentification.iProductId, |
377 &info.iIdentification.iProductId, |
350 &info.iIdentification.iProductRev); |
378 &info.iIdentification.iProductRev); |
351 |
379 |
352 if (info.iPeripheralQualifier != 0 && info.iPeripheralQualifier != 1) |
380 if (info.iPeripheralQualifier != 0 && info.iPeripheralQualifier != 1) |
353 { |
381 { |
354 __HOSTPRINT(_L("Peripheral Qualifier[Unknown device type]\n")) |
382 __HOSTPRINT(_L("Peripheral Qualifier[Unknown device type]")) |
355 return KErrUnknown; |
383 err = KErrUnknown; |
356 } |
384 } |
357 |
385 else if (info.iPeripheralDeviceType == 0) |
358 if (info.iPeripheralDeviceType != 0) |
386 { |
359 { |
387 // SCSI SBC Direct access device |
360 __HOSTPRINT(_L("Peripheral Device Type[Unsupported device type]\n")) |
388 iRemovableMedia = info.iRemovable; |
361 return KErrUnknown; |
389 |
362 } |
390 // SCSI Block device |
363 |
391 iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport()); |
364 iRemovableMedia = info.iRemovable; |
392 iSbcInterface->InitBuffers(&iHeadbuf, &iTailbuf); |
365 |
393 err = KErrNone; |
366 // SCSI Block device |
394 } |
367 iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport()); |
395 else if (info.iPeripheralDeviceType == 5) |
368 iSbcInterface->InitBuffers(&iHeadbuf, &iTailbuf); |
396 { |
369 |
397 // SCSI MMC-2 CD-ROM device |
370 return KErrNone; |
398 __HOSTPRINT(_L("Peripheral Device Type[CD-ROM]")) |
|
399 iRemovableMedia = info.iRemovable; |
|
400 |
|
401 // MMC-2 is not supported. A SCSI interface call will return |
|
402 // KErrNotSupported. If SCSI support is extended in future then |
|
403 // TSbcInterface class should be replaced with a proper interface class. |
|
404 iSbcInterface = NULL; |
|
405 err = KErrNone; |
|
406 } |
|
407 else |
|
408 { |
|
409 __HOSTPRINT(_L("Peripheral Device Type[Unsupported device type]")) |
|
410 err = KErrUnknown; |
|
411 } |
|
412 |
|
413 return err; |
371 } |
414 } |
372 |
415 |
373 |
416 |
374 /** |
417 /** |
375 Perform SCSI TEST UNIT READY command. The function leaves if the device response |
418 Perform SCSI TEST UNIT READY command. The function leaves if the device response |
418 device status error, KErrCommandStalled to indicate a device stall |
466 device status error, KErrCommandStalled to indicate a device stall |
419 */ |
467 */ |
420 TInt CScsiProtocol::MsModeSense10L() |
468 TInt CScsiProtocol::MsModeSense10L() |
421 { |
469 { |
422 __MSFNLOG |
470 __MSFNLOG |
|
471 if (!iSbcInterface) |
|
472 User::Leave(KErrNotSupported); |
|
473 |
423 TBool writeProtected; |
474 TBool writeProtected; |
424 TInt err = iSbcInterface->ModeSense10L(TSbcClientInterface::EReturnAllModePages, writeProtected); |
475 TInt err = iSbcInterface->ModeSense10L(TSbcClientInterface::EReturnAllModePages, writeProtected); |
425 |
476 |
426 if (!err) |
477 if (!err) |
427 { |
478 { |
439 device status error, KErrCommandStalled to indicate a device stall |
490 device status error, KErrCommandStalled to indicate a device stall |
440 */ |
491 */ |
441 TInt CScsiProtocol::MsModeSense6L() |
492 TInt CScsiProtocol::MsModeSense6L() |
442 { |
493 { |
443 __MSFNLOG |
494 __MSFNLOG |
|
495 if (!iSbcInterface) |
|
496 User::Leave(KErrNotSupported); |
|
497 |
444 TBool writeProtected; |
498 TBool writeProtected; |
445 TInt err = iSbcInterface->ModeSense6L(TSbcClientInterface::EReturnAllModePages, writeProtected); |
499 TInt err = iSbcInterface->ModeSense6L(TSbcClientInterface::EReturnAllModePages, writeProtected); |
446 |
500 |
447 if (!err) |
501 if (!err) |
448 { |
502 { |
490 // Check if init is needed |
547 // Check if init is needed |
491 if (iSenseInfo.iSenseCode == TSenseInfo::ENotReady && |
548 if (iSenseInfo.iSenseCode == TSenseInfo::ENotReady && |
492 iSenseInfo.iAdditional == TSenseInfo::EAscLogicalUnitNotReady && |
549 iSenseInfo.iAdditional == TSenseInfo::EAscLogicalUnitNotReady && |
493 iSenseInfo.iQualifier == TSenseInfo::EAscqInitializingCommandRequired) |
550 iSenseInfo.iQualifier == TSenseInfo::EAscqInitializingCommandRequired) |
494 { |
551 { |
495 // start unit |
552 if (iSbcInterface) |
496 err = iSbcInterface->StartStopUnitL(ETrue); |
553 { |
497 if (err) |
554 // start unit |
498 { |
555 err = iSbcInterface->StartStopUnitL(ETrue); |
499 User::LeaveIfError(MsRequestSenseL()); |
556 if (err) |
500 } |
557 { |
|
558 User::LeaveIfError(MsRequestSenseL()); |
|
559 } |
|
560 } |
501 } |
561 } |
502 |
562 |
503 err = GetSystemWideSenseError(iSenseInfo); |
563 err = GetSystemWideSenseError(iSenseInfo); |
504 |
564 |
505 TScsiState nextState = iState; |
565 TScsiState nextState = iState; |
743 void CScsiProtocol::DoScsiReadyCheckEventL() |
803 void CScsiProtocol::DoScsiReadyCheckEventL() |
744 { |
804 { |
745 __MSFNLOG |
805 __MSFNLOG |
746 TInt err = KErrNone; |
806 TInt err = KErrNone; |
747 |
807 |
748 if(iFsm->IsRemovableMedia() || iState != EConnected) |
808 if(iRemovableMedia || iState != EConnected) |
749 { |
809 { |
750 iFsm->SetStatusCheck(); |
810 iFsm->SetStatusCheck(); |
751 TRAP(err, iFsm->ConnectLogicalUnitL()); |
811 TRAP(err, iFsm->ConnectLogicalUnitL()); |
752 iFsm->ClearStatusCheck(); |
812 iFsm->ClearStatusCheck(); |
753 |
813 |