| 427 | } |
| 428 | |
| 429 | void ScsiController::Send() |
| 430 | { |
| 431 | assert(!GetBus().GetREQ()); |
| 432 | assert(GetBus().GetIO()); |
| 433 | |
| 434 | if (HasValidLength()) { |
| 435 | LogTrace("Sending data, offset: " + to_string(GetOffset()) + ", length: " + to_string(GetLength())); |
| 436 | |
| 437 | // The delay should be taken from the respective LUN, but as there are no Daynaport drivers for |
| 438 | // LUNs other than 0 this work-around works. |
| 439 | if (const int len = GetBus().SendHandShake(GetBuffer().data() + GetOffset(), GetLength(), |
| 440 | HasDeviceForLun(0) ? GetDeviceForLun(0)->GetSendDelay() : 0); |
| 441 | len != static_cast<int>(GetLength())) { |
| 442 | // If you cannot send all, move to status phase |
| 443 | Error(sense_key::aborted_command); |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | UpdateOffsetAndLength(); |
| 448 | |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | DecrementBlocks(); |
| 453 | |
| 454 | // Processing after data collection (read/data-in only) |
| 455 | if (IsDataIn() && HasBlocks()) { |
| 456 | // set next buffer (set offset, length) |
| 457 | if (!XferIn(GetBuffer())) { |
| 458 | // If result FALSE, move to status phase |
| 459 | Error(sense_key::aborted_command); |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | LogTrace("Processing after data collection"); |
| 464 | } |
| 465 | |
| 466 | // Continue sending if blocks != 0 |
| 467 | if (HasBlocks()) { |
| 468 | LogTrace("Continuing to send"); |
| 469 | assert(HasValidLength()); |
| 470 | assert(GetOffset() == 0); |
| 471 | return; |
| 472 | } |
| 473 | |
| 474 | // Move to next phase |
| 475 | LogTrace("All data transferred, moving to next phase: " + string(BUS::GetPhaseStrRaw(GetPhase()))); |
| 476 | switch (GetPhase()) { |
| 477 | case phase_t::msgin: |
| 478 | // Completed sending response to extended message of IDENTIFY message |
| 479 | if (scsi.atnmsg) { |
| 480 | scsi.atnmsg = false; |
| 481 | |
| 482 | Command(); |
| 483 | } else { |
| 484 | BusFree(); |
| 485 | } |
| 486 | break; |
nothing calls this directly
no test coverage detected