summaryrefslogtreecommitdiff
path: root/sys/arch/i386/include
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>2007-05-26 22:09:18 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>2007-05-26 22:09:18 +0000
commit1bcfbbfdb34c25a28af67ebf5994768517f7b9b9 (patch)
treeb438d54990fba309fd16566f45bae3e1fe818289 /sys/arch/i386/include
parentc3228f5d60740159839a6c80297911c64ca64343 (diff)
Move cpu_info/curcpu to be mapped by the %fs segment. Extra input and
debugging by tom@, art@, kettenis@, and others. Testing by many others. ok art@, kettenis@, tom@
Diffstat (limited to 'sys/arch/i386/include')
-rw-r--r--sys/arch/i386/include/cpu.h18
-rw-r--r--sys/arch/i386/include/i82489var.h4
2 files changed, 18 insertions, 4 deletions
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index b69f1f78dd3..e74c7ace152 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.92 2007/04/21 21:06:15 gwk Exp $ */
+/* $OpenBSD: cpu.h,v 1.93 2007/05/26 22:09:17 weingart Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -182,8 +182,20 @@ extern struct cpu_info *cpu_info_list;
#define CPU_STOP(_ci) ((_ci)->ci_func->stop(_ci))
#define CPU_START_CLEANUP(_ci) ((_ci)->ci_func->cleanup(_ci))
-#define cpu_number() (i82489_readreg(LAPIC_ID)>>LAPIC_ID_SHIFT)
-#define curcpu() (cpu_info[cpu_number()])
+static struct cpu_info *curcpu(void);
+
+__inline static struct cpu_info *
+curcpu(void)
+{
+ struct cpu_info *ci;
+
+ /* Can't include sys/param.h for offsetof() since it includes us */
+ __asm __volatile("movl %%fs:%1, %0" :
+ "=r" (ci) : "m"
+ (*(struct cpu_info * const *)&((struct cpu_info *)0)->ci_self));
+ return ci;
+}
+#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY)
diff --git a/sys/arch/i386/include/i82489var.h b/sys/arch/i386/include/i82489var.h
index 0fe445e41fe..3fac16e9011 100644
--- a/sys/arch/i386/include/i82489var.h
+++ b/sys/arch/i386/include/i82489var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i82489var.h,v 1.5 2007/05/25 15:55:27 art Exp $ */
+/* $OpenBSD: i82489var.h,v 1.6 2007/05/26 22:09:17 weingart Exp $ */
/* $NetBSD: i82489var.h,v 1.1.2.2 2000/02/21 18:46:14 sommerfeld Exp $ */
/*-
@@ -134,4 +134,6 @@ extern void lapic_set_softvectors(void);
extern void lapic_enable(void);
extern void lapic_calibrate_timer(struct cpu_info *);
+#define lapic_cpu_number() (i82489_readreg(LAPIC_ID)>>LAPIC_ID_SHIFT)
+
#endif