Module Name:    src
Committed By:   cherry
Date:           Thu Aug 11 18:11:17 UTC 2011

Modified Files:
        src/sys/arch/amd64/amd64: machdep.c
        src/sys/arch/i386/i386: machdep.c
        src/sys/arch/x86/include: cpu.h
        src/sys/arch/x86/x86: cpu.c x86_machdep.c
        src/sys/arch/xen/x86: cpu.c

Log Message:
Hide the MD details of specific IPIs behind semantically pleasing functions. 
This cleans up a couple of #ifdef XEN/#endif pairs


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.707 -r1.708 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/xen/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.163 src/sys/arch/amd64/amd64/machdep.c:1.164
--- src/sys/arch/amd64/amd64/machdep.c:1.163	Wed Aug 10 11:39:45 2011
+++ src/sys/arch/amd64/amd64/machdep.c	Thu Aug 11 18:11:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.163 2011/08/10 11:39:45 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.164 2011/08/11 18:11:17 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.163 2011/08/10 11:39:45 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.164 2011/08/11 18:11:17 cherry Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -719,11 +719,7 @@
 #endif /* XEN */
 	}
 
-#ifdef XEN
-	xen_broadcast_ipi(XEN_IPI_HALT);
-#else /* XEN */
-	x86_broadcast_ipi(X86_IPI_HALT);
-#endif
+	cpu_broadcast_halt();
 
 	if (howto & RB_HALT) {
 #if NACPICA > 0

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.707 src/sys/arch/i386/i386/machdep.c:1.708
--- src/sys/arch/i386/i386/machdep.c:1.707	Wed Aug 10 06:38:02 2011
+++ src/sys/arch/i386/i386/machdep.c	Thu Aug 11 18:11:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.707 2011/08/10 06:38:02 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.708 2011/08/11 18:11:17 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.707 2011/08/10 06:38:02 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.708 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -955,11 +955,7 @@
 	}
 
 #ifdef MULTIPROCESSOR
-#ifdef XEN
-	xen_broadcast_ipi(XEN_IPI_HALT);
-#else /* XEN */
-	x86_broadcast_ipi(X86_IPI_HALT);
-#endif /* XEN */
+	cpu_broadcast_halt();
 #endif /* MULTIPROCESSOR */
 
 	if (howto & RB_HALT) {

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.36 src/sys/arch/x86/include/cpu.h:1.37
--- src/sys/arch/x86/include/cpu.h:1.36	Wed Aug 10 06:40:35 2011
+++ src/sys/arch/x86/include/cpu.h	Thu Aug 11 18:11:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.36 2011/08/10 06:40:35 cherry Exp $	*/
+/*	$NetBSD: cpu.h,v 1.37 2011/08/11 18:11:17 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -314,6 +314,8 @@
 void cpu_init_idle_lwps(void);
 void cpu_init_msrs(struct cpu_info *, bool);
 void cpu_load_pmap(struct pmap *);
+void cpu_broadcast_halt(void);
+void cpu_kick(struct cpu_info *);
 
 extern uint32_t cpus_attached;
 

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.90 src/sys/arch/x86/x86/cpu.c:1.91
--- src/sys/arch/x86/x86/cpu.c:1.90	Fri Jul 29 21:21:43 2011
+++ src/sys/arch/x86/x86/cpu.c	Thu Aug 11 18:11:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.90 2011/07/29 21:21:43 dyoung Exp $	*/
+/*	$NetBSD: cpu.c,v 1.91 2011/08/11 18:11:17 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.90 2011/07/29 21:21:43 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.91 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -1210,3 +1210,23 @@
 	lcr3(pmap_pdirpa(pmap, 0));
 #endif /* PAE */
 }
+
+/*
+ * Notify all other cpus to halt.
+ */
+
+void
+cpu_broadcast_halt(struct cpu_info *ci)
+{
+	x86_broadcast_ipi(X86_IPI_HALT);
+}
+
+/*
+ * Send a dummy ipi to a cpu to force it to run splraise()/spllower()
+ */
+
+void
+cpu_kick(struct cpu_info *ci)
+{
+	x86_send_ipi(ci, 0);
+}

Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.54 src/sys/arch/x86/x86/x86_machdep.c:1.55
--- src/sys/arch/x86/x86/x86_machdep.c:1.54	Wed Aug 10 11:39:45 2011
+++ src/sys/arch/x86/x86/x86_machdep.c	Thu Aug 11 18:11:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.54 2011/08/10 11:39:45 cherry Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.55 2011/08/11 18:11:17 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.54 2011/08/10 11:39:45 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.55 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -205,11 +205,7 @@
 		if (ci == cur)
 			return;
 		if (x86_cpu_idle_ipi != false) {
-#ifdef XEN
-			xen_send_ipi(ci, XEN_IPI_KICK);
-#else /* XEN */
-			x86_send_ipi(ci, 0);
-#endif /* XEN */
+			cpu_kick(ci);
 		}
 		return;
 	}
@@ -231,11 +227,7 @@
 		return;
 	}
 	if ((flags & RESCHED_IMMED) != 0) {
-#ifdef XEN
-		xen_send_ipi(ci, XEN_IPI_KICK);
-#else /* XEN */
-		x86_send_ipi(ci, 0);
-#endif /* XEN */
+		cpu_kick(ci);
 	}
 }
 
@@ -246,11 +238,7 @@
 	KASSERT(kpreempt_disabled());
 	aston(l, X86_AST_GENERIC);
 	if (l->l_cpu != curcpu())
-#ifdef XEN
-		xen_send_ipi(l->l_cpu, XEN_IPI_KICK);
-#else /* XEN */
-		x86_send_ipi(l->l_cpu, 0);
-#endif /* XEN */
+		cpu_kick(l->l_cpu);
 }
 
 void

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.60 src/sys/arch/xen/x86/cpu.c:1.61
--- src/sys/arch/xen/x86/cpu.c:1.60	Sat Jul 16 14:46:18 2011
+++ src/sys/arch/xen/x86/cpu.c	Thu Aug 11 18:11:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.60 2011/07/16 14:46:18 rmind Exp $	*/
+/*	$NetBSD: cpu.c,v 1.61 2011/08/11 18:11:17 cherry Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.60 2011/07/16 14:46:18 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.61 2011/08/11 18:11:17 cherry Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1177,3 +1177,26 @@
 	}
 #endif /* __x86_64__ */
 }
+
+/*
+ * Notify all other cpus to halt.
+ */
+
+void
+cpu_broadcast_halt(void)
+{
+	xen_broadcast_ipi(XEN_IPI_HALT);
+}
+
+/*
+ * Send a dummy ipi to a cpu.
+ */
+
+void
+cpu_kick(struct cpu_info *ci)
+{
+	if (xen_send_ipi(ci, XEN_IPI_KICK) != 0) {
+		panic("xen_send_ipi(%s, XEN_IPI_KICK) failed\n",
+		    cpu_name(ci));
+	}
+}

Reply via email to