diff options
author | njl <njl@FreeBSD.org> | 2003-10-18 22:25:07 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2003-10-18 22:25:07 +0000 |
commit | 8689796a4b7db48eb94863f228f183d526c03134 (patch) | |
tree | d0d76931498b719475fa35837a3e8a739d9a033c /sys/i386 | |
parent | fb13ea0aa949c066e3a08be2fd0c4cde79a61d21 (diff) | |
download | FreeBSD-src-8689796a4b7db48eb94863f228f183d526c03134.zip FreeBSD-src-8689796a4b7db48eb94863f228f183d526c03134.tar.gz |
Add the cpu_idle_hook() function pointer so that other idlers can be
hooked at runtime. Make C1 sleep (e.g., HLT) be the default. This
prepares the way for further ACPI sleep states.
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/machdep.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index a0ff4a2..e2ceead 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1033,6 +1033,17 @@ static int cpu_idle_hlt = 1; SYSCTL_INT(_machdep, OID_AUTO, cpu_idle_hlt, CTLFLAG_RW, &cpu_idle_hlt, 0, "Idle loop HLT enable"); +static void +cpu_idle_default(void) +{ + /* + * we must absolutely guarentee that hlt is the + * absolute next instruction after sti or we + * introduce a timing window. + */ + __asm __volatile("sti; hlt"); +} + /* * Note that we have to be careful here to avoid a race between checking * sched_runnable() and actually halting. If we don't do this, we may waste @@ -1050,19 +1061,16 @@ cpu_idle(void) if (cpu_idle_hlt) { disable_intr(); - if (sched_runnable()) { + if (sched_runnable()) enable_intr(); - } else { - /* - * we must absolutely guarentee that hlt is the - * absolute next instruction after sti or we - * introduce a timing window. - */ - __asm __volatile("sti; hlt"); - } + else + (*cpu_idle_hook)(); } } +/* Other subsystems (e.g., ACPI) can hook this later. */ +void (*cpu_idle_hook)(void) = cpu_idle_default; + /* * Clear registers on exec */ |