diff options
author | sigsegv7 <ian@vegaa.systems> | 2023-09-15 23:09:33 -0400 |
---|---|---|
committer | sigsegv7 <ian@vegaa.systems> | 2023-09-15 23:09:33 -0400 |
commit | 48a5647796ffa766c825d47b16d75ae31cebce2c (patch) | |
tree | c8e9245bff2700c100b7b7b568a7a37be0789d79 /sys/dev/timer/hpet.c | |
parent | 2003325ba7b913425fe805ace0039bc9d0401633 (diff) |
kernel: dev: Handle faulty HPET in msleep routine
Signed-off-by: sigsegv7 <ian@vegaa.systems>
Diffstat (limited to 'sys/dev/timer/hpet.c')
-rw-r--r-- | sys/dev/timer/hpet.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/timer/hpet.c b/sys/dev/timer/hpet.c index 1089096..d276456 100644 --- a/sys/dev/timer/hpet.c +++ b/sys/dev/timer/hpet.c @@ -95,7 +95,7 @@ hpet_write(uint32_t reg, uint64_t val) mmio_write64(addr, val); } -void +int hpet_msleep(size_t ms) { uint64_t caps; @@ -103,6 +103,11 @@ hpet_msleep(size_t ms) uint64_t counter_val; volatile size_t ticks; + /* Don't even try if faulty, would probably cause deadlock */ + if (is_faulty) { + return 1; + } + caps = hpet_read(HPET_REG_CAPS); period = CAP_CLK_PERIOD(caps); counter_val = hpet_read(HPET_REG_MAIN_COUNTER); @@ -112,6 +117,8 @@ hpet_msleep(size_t ms) while (hpet_read(HPET_REG_MAIN_COUNTER) < ticks) { spinwait_hint(); } + + return 0; } int |