diff options
author | sigsegv7 <ian@vegaa.systems> | 2023-09-15 23:34:48 -0400 |
---|---|---|
committer | sigsegv7 <ian@vegaa.systems> | 2023-09-15 23:34:48 -0400 |
commit | d4365c9a7f653f5d81c56424fe04edb4656fd1e2 (patch) | |
tree | 56ee937fcdb9147070affa1b78914e834d52afe8 | |
parent | 48a5647796ffa766c825d47b16d75ae31cebce2c (diff) |
kernel: dev: Create hpet_sleep() helper
Sleep functions may wrap this helper to simplify
their implementation.
Signed-off-by: sigsegv7 <ian@vegaa.systems>
-rw-r--r-- | sys/dev/timer/hpet.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/timer/hpet.c b/sys/dev/timer/hpet.c index d276456..ab30f63 100644 --- a/sys/dev/timer/hpet.c +++ b/sys/dev/timer/hpet.c @@ -95,8 +95,8 @@ hpet_write(uint32_t reg, uint64_t val) mmio_write64(addr, val); } -int -hpet_msleep(size_t ms) +static int +hpet_sleep(uint64_t n, uint64_t units) { uint64_t caps; uint32_t period; @@ -112,7 +112,7 @@ hpet_msleep(size_t ms) period = CAP_CLK_PERIOD(caps); counter_val = hpet_read(HPET_REG_MAIN_COUNTER); - ticks = counter_val + (ms * (1000000000000 / period)); + ticks = counter_val + (n * (units / period)); while (hpet_read(HPET_REG_MAIN_COUNTER) < ticks) { spinwait_hint(); @@ -122,6 +122,12 @@ hpet_msleep(size_t ms) } int +hpet_msleep(size_t ms) +{ + return hpet_sleep(ms, 1000000000000); +} + +int hpet_init(void) { struct acpi_gas *gas; |