diff --git a/devices/common/scsi/sc53c94.cpp b/devices/common/scsi/sc53c94.cpp index 613a954..ab25b60 100644 --- a/devices/common/scsi/sc53c94.cpp +++ b/devices/common/scsi/sc53c94.cpp @@ -280,9 +280,14 @@ void Sc53C94::exec_command() // assert RST line this->bus_obj->assert_ctrl_line(this->my_bus_id, SCSI_CTRL_RST); // release RST line after 25 us + if (my_timer_id) { + TimerManager::get_instance()->cancel_timer(this->my_timer_id); + my_timer_id = 0; + } my_timer_id = TimerManager::get_instance()->add_oneshot_timer( USECS_TO_NSECS(25), [this]() { + my_timer_id = 0; this->bus_obj->release_ctrl_line(this->my_bus_id, SCSI_CTRL_RST); }); if (!(config1 & 0x40)) { @@ -406,10 +411,16 @@ uint8_t Sc53C94::fifo_pop() void Sc53C94::seq_defer_state(uint64_t delay_ns) { + if (seq_timer_id) { + TimerManager::get_instance()->cancel_timer(this->seq_timer_id); + seq_timer_id = 0; + } + seq_timer_id = TimerManager::get_instance()->add_oneshot_timer( delay_ns, [this]() { // re-enter the sequencer with the state specified in next_state + this->seq_timer_id = 0; this->cur_state = this->next_state; this->sequencer(); }); @@ -576,6 +587,7 @@ void Sc53C94::notify(ScsiMsg msg_type, int param) if (this->target_id == param) { // cancel selection timeout timer TimerManager::get_instance()->cancel_timer(this->seq_timer_id); + seq_timer_id = 0; this->cur_state = SeqState::SEL_END; this->sequencer(); } else {