Improve accuracy of internal timers.
commitb7ab1784acf11b1ebf63b6dd40d45c2bbf745ef7
authorKevin O'Connor <kevin@koconnor.net>
Sat, 20 Jul 2013 17:06:35 +0000 (20 13:06 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 20 Jul 2013 23:30:01 +0000 (20 19:30 -0400)
treedaa4eecaa4596ec46c410c61e929b4069c231a82
parent69013378972c07c9a1e46fa6ec274070cad1a532
Improve accuracy of internal timers.

The TICKS_PER_DAY setting is a bios standard and needs to be 1573040
for compatibility.  However, there are actually ~1573042.24 ticks in a
day.  So, only use TICKS_PER_DAY when working with the BDA
timer_counter - not when calculating any internal times.

The PIT hz is actually 143181800 / 12 (~1193181.667).  This can be
accurately encoded as PMTIMER hz / 3.  Because the PIT hz is usually
multiplied and divided by other numbers, we can use the PMTIMER hz and
defer the division by 3 to improve accuracy.

When doing division for delay time calculations, always round up the
division so the delay is never less than the requested time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/biosvar.h
src/clock.c
src/pit.h
src/timer.c