summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJordan Hargrave <jordan@cvs.openbsd.org>2009-06-02 03:04:55 +0000
committerJordan Hargrave <jordan@cvs.openbsd.org>2009-06-02 03:04:55 +0000
commiteb6d6ee82a1be8478ff86830ee0a0d74c138b4cf (patch)
tree1d56f518a7928f3d8b160dcec82ef7b017df9664 /sys
parent14f26834652fe502181af3c1bc2c0372575a5a13 (diff)
Added interface for cpu idle on amd64
ok gwk@, toby@, marco@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/locore.S20
-rw-r--r--sys/arch/amd64/amd64/machdep.c9
-rw-r--r--sys/arch/amd64/include/cpu.h5
3 files changed, 31 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S
index 694d16314ed..e185eb4e371 100644
--- a/sys/arch/amd64/amd64/locore.S
+++ b/sys/arch/amd64/amd64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.35 2009/05/28 09:05:33 art Exp $ */
+/* $OpenBSD: locore.S,v 1.36 2009/06/02 03:04:54 jordan Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
@@ -789,13 +789,30 @@ switch_exited:
ret
ENTRY(cpu_idle_enter)
+ movq _C_LABEL(cpu_idle_enter_fcn),%rax
+ cmpq $0,%rax
+ je 1f
+ jmpq *%rax
+1:
ret
ENTRY(cpu_idle_cycle)
+ movq _C_LABEL(cpu_idle_cycle_fcn),%rax
+ cmpq $0,%rax
+ je 1f
+ call *%rax
+ ret
+1:
+ sti
hlt
ret
ENTRY(cpu_idle_leave)
+ movq _C_LABEL(cpu_idle_leave_fcn),%rax
+ cmpq $0,%rax
+ je 1f
+ jmpq *%rax
+1:
ret
.globl _C_LABEL(panic)
@@ -1049,3 +1066,4 @@ ENTRY(acpi_release_global_lock)
andl $1, %eax
ret
#endif
+
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 7b16c679bce..d8492b681a0 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.91 2009/05/30 20:47:00 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.92 2009/06/02 03:04:54 jordan Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -148,6 +148,13 @@ extern int db_console;
/* the following is used externally (sysctl_hw) */
char machine[] = MACHINE;
+/*
+ * switchto vectors
+ */
+void (*cpu_idle_leave_fcn)(void) = NULL;
+void (*cpu_idle_cycle_fcn)(void) = NULL;
+void (*cpu_idle_enter_fcn)(void) = NULL;
+
/* the following is used externally for concurrent handlers */
int setperf_prio = 0;
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 599cbf4449b..efd8ea21f50 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.44 2009/05/28 09:05:33 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.45 2009/06/02 03:04:54 jordan Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -276,6 +276,9 @@ void x86_64_bufinit(void);
void x86_64_init_pcb_tss_ldt(struct cpu_info *);
void cpu_proc_fork(struct proc *, struct proc *);
int amd64_pa_used(paddr_t);
+extern void (*cpu_idle_enter_fcn)(void);
+extern void (*cpu_idle_cycle_fcn)(void);
+extern void (*cpu_idle_leave_fcn)(void);
struct region_descriptor;
void lgdt(struct region_descriptor *);