rtc: improve tsc calibration
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
bc39293c83
commit
8fc9f1396e
1 changed files with 8 additions and 10 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue