From 6d91c78f0c240e3c7d81e19e85507e0aec580d6f Mon Sep 17 00:00:00 2001 From: Zhaoming Luo Date: Mon, 24 Mar 2025 12:25:51 +0800 Subject: Integrate HPET so the functions used for getting time can have a higher accuracy Integrate HPET so host_get_time, host_get_time64, and host_get_uptime64 are more precise. The highest precision can be 10ns when this patch is applied. * i386/i386/apic.c: Implement the two high-precision clock interface functions added in this patch for i386. * i386/i386at/model_dep.c: Initialize HPET if APIC is defined * kern/mach_clock.c: Integrate the high-precision clocks to have the 10ns precise time values. * kern/mach_clock.h: Add two new interface functions for accessing the high-precision clocks. Message-ID: <20250324042551.4752-2-zhmingluo@163.com> --- kern/mach_clock.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'kern/mach_clock.h') diff --git a/kern/mach_clock.h b/kern/mach_clock.h index d4f04f5e..e83b638c 100644 --- a/kern/mach_clock.h +++ b/kern/mach_clock.h @@ -110,4 +110,8 @@ extern boolean_t untimeout(timer_func_t *fcn, const void *param); extern int timeopen(dev_t dev, int flag, io_req_t ior); extern void timeclose(dev_t dev, int flag); +/* For high-precision clocks. */ +extern uint32_t hpclock_read_counter(void); +extern uint32_t hpclock_get_counter_period_nsec(void); + #endif /* _KERN_MACH_CLOCK_H_ */ -- cgit v1.2.3