rtc: improve tsc calibration

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-21 21:03:03 -04:00
commit 8fc9f1396e

View file

@ -18,21 +18,19 @@ static u8 bcd_to_bin(u8 bcd)
return (bcd & 0x0F) + ((bcd >> 4) * 10);
}
static void wait_update()
{
u8 last = cmos_read(0x00);
while (cmos_read(0x00) == last)
;
return;
}
u64 tsc_calibrate()
{
u64 start;
u64 end;
wait_update();
u8 last = cmos_read(0x00);
while (cmos_read(0x00) == last)
;
start = rdtsc();
wait_update();
last = cmos_read(0x00);
while (cmos_read(0x00) == last)
;
end = rdtsc();
return end - start;
}