diff --git a/repos/base-hw/src/core/spec/riscv/timer.cc b/repos/base-hw/src/core/spec/riscv/timer.cc index b222712a6e..dd1297b1b7 100644 --- a/repos/base-hw/src/core/spec/riscv/timer.cc +++ b/repos/base-hw/src/core/spec/riscv/timer.cc @@ -39,8 +39,8 @@ time_t Board::Timer::stime() const void Timer::_start_one_shot(time_t const ticks) { - _device.timeout = _device.stime() + ticks; - Sbi::set_timer(_device.timeout); + _device.last_time = _device.stime(); + Sbi::set_timer(_device.last_time + ticks); } @@ -58,9 +58,7 @@ time_t Timer::_max_value() const { time_t Timer::_duration() const { - addr_t time = _device.stime(); - return time < _device.timeout ? _device.timeout - time - : _last_timeout_duration + (time - _device.timeout); + return _device.stime() - _device.last_time; } diff --git a/repos/base-hw/src/core/spec/riscv/timer.h b/repos/base-hw/src/core/spec/riscv/timer.h index 8ded8dffd9..d5032409a6 100644 --- a/repos/base-hw/src/core/spec/riscv/timer.h +++ b/repos/base-hw/src/core/spec/riscv/timer.h @@ -31,7 +31,7 @@ struct Board::Timer TICKS_PER_US = TICKS_PER_MS / 1000, }; - Kernel::time_t timeout = 0; + Kernel::time_t last_time { 0 }; Kernel::time_t stime() const;