mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-15 14:27:29 +00:00
Switches to proper SCSI terminology and better attempts a command phase.
This commit is contained in:
@@ -25,26 +25,30 @@ void DirectAccessDevice::scsi_bus_did_change(Bus *, BusState new_state) {
|
|||||||
time."
|
time."
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch(state_) {
|
switch(phase_) {
|
||||||
case State::Inactive:
|
case Phase::AwaitingSelection:
|
||||||
if(
|
if(
|
||||||
(new_state & scsi_id_mask_) &&
|
(new_state & scsi_id_mask_) &&
|
||||||
((new_state & (Line::SelectTarget | Line::Busy | Line::Input)) == Line::SelectTarget)
|
((new_state & (Line::SelectTarget | Line::Busy | Line::Input)) == Line::SelectTarget)
|
||||||
) {
|
) {
|
||||||
state_ = State::Selected;
|
phase_ = Phase::Command;
|
||||||
bus_state_ |= Line::Busy | Line::Request;
|
bus_state_ |= Line::Busy | Line::Request | Line::Control; // Initiate the command phase: request a command byte.
|
||||||
bus_.set_device_output(scsi_bus_device_id_, bus_state_);
|
bus_.set_device_output(scsi_bus_device_id_, bus_state_);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State::Selected:
|
case Phase::Command:
|
||||||
switch(new_state & (Line::Request | Line::Acknowledge)) {
|
switch(new_state & (Line::Request | Line::Acknowledge)) {
|
||||||
|
// If request and acknowledge are both enabled, grab a byte and cancel the request.
|
||||||
case Line::Request | Line::Acknowledge:
|
case Line::Request | Line::Acknowledge:
|
||||||
bus_state_ &= ~Line::Request;
|
bus_state_ &= ~Line::Request;
|
||||||
printf("Got %02x maybe?\n", bus_state_ & 0xff);
|
printf("Got %02x maybe?\n", bus_state_ & 0xff);
|
||||||
|
|
||||||
|
// TODO: is the command phase over?
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Line::Acknowledge:
|
// The reset of request has caused the initiator to reset acknowledge, so it is now
|
||||||
|
// safe to request the next byte.
|
||||||
case 0:
|
case 0:
|
||||||
bus_state_ |= Line::Request;
|
bus_state_ |= Line::Request;
|
||||||
break;
|
break;
|
||||||
|
@@ -32,10 +32,10 @@ class DirectAccessDevice: public Bus::Observer {
|
|||||||
const BusState scsi_id_mask_;
|
const BusState scsi_id_mask_;
|
||||||
const size_t scsi_bus_device_id_;
|
const size_t scsi_bus_device_id_;
|
||||||
|
|
||||||
enum class State {
|
enum class Phase {
|
||||||
Inactive,
|
AwaitingSelection,
|
||||||
Selected
|
Command
|
||||||
} state_ = State::Inactive;
|
} phase_ = Phase::AwaitingSelection;
|
||||||
BusState bus_state_ = DefaultBusState;
|
BusState bus_state_ = DefaultBusState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user