sc53c94: Set timer_id to zero.

If a timer is not in progress then set its timer_id to zero. Also, don't start a newer timer if an existing one is still in progress.
This commit is contained in:
joevt 2024-03-10 17:52:47 -07:00 committed by dingusdev
parent 8a81cb4f9c
commit 82f4d05f4b
1 changed files with 12 additions and 0 deletions

View File

@ -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 {