Skip to content

Commit

Permalink
Cast to timevalue before shifting to avoid shifting bits into the bit…
Browse files Browse the repository at this point in the history
… bucket. Fixes TUD-OS#30. Thanks @parthy.
  • Loading branch information
blitz committed Aug 12, 2013
1 parent 0860a79 commit 77a784a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions model/lapic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Lapic : public DiscoveryHelper<Lapic>, public StaticReceiver<Lapic>

// add periods to the time we started to detect the next overflow
unsigned done = delta % _ICT;
_timer_start += (delta - done) << _timer_dcr_shift;
_timer_start += timevalue((delta - done)) << _timer_dcr_shift;

return _ICT - done;
}
Expand All @@ -180,7 +180,7 @@ class Lapic : public DiscoveryHelper<Lapic>, public StaticReceiver<Lapic>
void update_timer(timevalue now) {
unsigned value = get_ccr(now);
if (!value || _TIMER & (1 << LVT_MASK_BIT)) return;
MessageTimer msg(_timer, now + (value << _timer_dcr_shift));
MessageTimer msg(_timer, now + (timevalue(value) << _timer_dcr_shift));
_mb.bus_timer.send(msg);
}

Expand Down Expand Up @@ -822,7 +822,7 @@ REGSET(Lapic,
* Move timer_start in the past, which what would be
* already done on this period with the current speed.
*/
_timer_start = now - (done << _timer_dcr_shift);
_timer_start = now - (timevalue(done) << _timer_dcr_shift);
update_timer(now);
}
))
Expand Down

0 comments on commit 77a784a

Please sign in to comment.