mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
base-hw: fix RISC-V duration calculation
Simplify calculation of Timer::_duration, the old implementation caused the time running backwards sometimes. This makes 'nic_router_dhcp_*' and 'event_filter' run scripts succeed. issue #4021
This commit is contained in:
parent
1826ff8a59
commit
d4b58b689c
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user