diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2022-11-08 14:49:21 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2022-11-08 14:49:21 +0000 |
commit | 52795ea172afc3bdb6a9c5ba1216a090cba85ed5 (patch) | |
tree | e2a65430a975e337c723c108cf8dcb200bd66e50 /sys | |
parent | ea07ebefe4efd98cef68e1179e8a693515001ce6 (diff) |
i386: add delay_fini()
Not all of the clocks with a delay(9) implementation necessarily keep
ticking across suspend/resume. We need a clean way to reverse
delay_init() during suspend when those clocks stop ticking.
Hence, delay_fini(). delay_fini() resets delay_func() to
i8254_delay() if the given function pointer is the active delay(9)
implementation.
ok mlarkin@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 18 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 62e2c88bde7..310208ac4cd 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.657 2022/10/30 17:43:39 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.658 2022/11/08 14:49:20 cheloha Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -3973,12 +3973,22 @@ cpu_rnd_messybits(void) return (ts.tv_nsec ^ (ts.tv_sec << 20)); } +int i386_delay_quality; + void delay_init(void(*fn)(int), int fn_quality) { - static int cur_quality = 0; - if (fn_quality > cur_quality) { + if (fn_quality > i386_delay_quality) { delay_func = fn; - cur_quality = fn_quality; + i386_delay_quality = fn_quality; + } +} + +void +delay_fini(void (*fn)(int)) +{ + if (delay_func == fn) { + delay_func = i8254_delay; + i386_delay_quality = 0; } } diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 68bc3542a0f..6d707fc2d77 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.179 2022/08/29 02:58:13 jsg Exp $ */ +/* $OpenBSD: cpu.h,v 1.180 2022/11/08 14:49:20 cheloha Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -302,6 +302,7 @@ void signotify(struct proc *); * We need a machine-independent name for this. */ extern void (*delay_func)(int); +void delay_fini(void(*)(int)); void delay_init(void(*)(int), int); struct timeval; |