MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / ReceiveBytes

Method ReceiveBytes

cpp/controllers/scsi_controller.cpp:614–671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614void ScsiController::ReceiveBytes()
615{
616 if (HasValidLength()) {
617 SetBytesToTransfer(GetLength());
618 UpdateOffsetAndLength();
619 return;
620 }
621
622 bool result = true;
623
624 // Processing after receiving data (by phase)
625 LogTrace("Phase: " + string(BUS::GetPhaseStrRaw(GetPhase())));
626 switch (GetPhase()) {
627 case phase_t::dataout:
628 result = XferOut(false);
629 break;
630
631 case phase_t::msgout:
632 SetMessage(GetBuffer()[0]);
633 if (!XferMsg(GetMessage())) {
634 // Immediately free the bus if message output fails
635 BusFree();
636 return;
637 }
638
639 // Clear message data in preparation for message-in
640 SetMessage(0x00);
641 break;
642
643 default:
644 break;
645 }
646
647 // If result FALSE, move to status phase
648 if (!result) {
649 Error(sense_key::aborted_command);
650 return;
651 }
652
653 // Move to next phase
654 switch (GetPhase()) {
655 case phase_t::command:
656 ProcessCommand();
657 break;
658
659 case phase_t::msgout:
660 ProcessMessage();
661 break;
662
663 case phase_t::dataout:
664 Status();
665 break;
666
667 default:
668 assert(false);
669 break;
670 }
671}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected