150c150,155
< period = count;
---
> // In the RateGen or SquareWave modes, the timer wraps around and
> // triggers on a value of 1, not 0.
> if (mode == RateGen || mode == SquareWave)
> period = count - 1;
> else
> period = count;
152,156c157,159
< if (period > 0) {
< DPRINTF(Intel8254Timer, "Timer set to curTick + %d\n",
< count * event.interval);
< event.schedule(curTick + count * event.interval);
< }
---
> if (period > 0)
> event.setTo(period);
>
242a246
> break;
244a249
> setTo(counter->period);
250a256,265
> void
> Intel8254Timer::Counter::CounterEvent::setTo(int clocks)
> {
> if (clocks == 0)
> panic("Timer can't be set to go off instantly.\n");
> DPRINTF(Intel8254Timer, "Timer set to curTick + %d\n",
> clocks * interval);
> schedule(curTick + clocks * interval);
> }
>