--------------------------------------------------------------------------- Data transfer IN *Reset offset and length ---------------------------------------------------------------------------
| 721 | // |
| 722 | //--------------------------------------------------------------------------- |
| 723 | bool ScsiController::XferIn(vector<uint8_t>& buf) |
| 724 | { |
| 725 | assert(IsDataIn()); |
| 726 | |
| 727 | stringstream s; |
| 728 | s << "Command: $" << setfill('0') << setw(2) << hex << static_cast<int>(GetOpcode()); |
| 729 | LogTrace(s.str()); |
| 730 | |
| 731 | const int lun = GetEffectiveLun(); |
| 732 | if (!HasDeviceForLun(lun)) { |
| 733 | return false; |
| 734 | } |
| 735 | |
| 736 | // Limited to read commands |
| 737 | switch (GetOpcode()) { |
| 738 | case scsi_command::eCmdRead6: |
| 739 | case scsi_command::eCmdRead10: |
| 740 | case scsi_command::eCmdRead16: |
| 741 | // Read from StorageDevice |
| 742 | try { |
| 743 | SetLength(dynamic_pointer_cast<StorageDevice>(GetDeviceForLun(lun))->Read(buf, GetNext())); |
| 744 | } |
| 745 | catch(const scsi_exception&) { |
| 746 | // If there is an error, go to the status phase |
| 747 | return false; |
| 748 | } |
| 749 | |
| 750 | IncrementNext(); |
| 751 | |
| 752 | // If things are normal, work setting |
| 753 | ResetOffset(); |
| 754 | break; |
| 755 | |
| 756 | default: |
| 757 | assert(false); |
| 758 | return false; |
| 759 | } |
| 760 | |
| 761 | return true; |
| 762 | } |
| 763 | |
| 764 | //--------------------------------------------------------------------------- |
| 765 | // |