Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64 Add a generic ipi to call arbitrary C funct...
details: https://anonhg.NetBSD.org/src/rev/6bce55e0a6a9
branches: trunk
changeset: 755243:6bce55e0a6a9
user: martin <martin%NetBSD.org@localhost>
date: Sat May 29 21:59:33 2010 +0000
description:
Add a generic ipi to call arbitrary C functions on another (or all other)
cpu(s). Will be used in the near future by some code Mindaugas is working on.
diffstat:
sys/arch/sparc64/include/cpu.h | 11 ++++++++++-
sys/arch/sparc64/sparc64/ipifuncs.c | 34 +++++++++++++++++++++++++++++++---
sys/arch/sparc64/sparc64/mp_subr.S | 22 ++++++++++++++++++++--
3 files changed, 61 insertions(+), 6 deletions(-)
diffs (131 lines):
diff -r 9a08cd04bb38 -r 6bce55e0a6a9 sys/arch/sparc64/include/cpu.h
--- a/sys/arch/sparc64/include/cpu.h Sat May 29 20:41:58 2010 +0000
+++ b/sys/arch/sparc64/include/cpu.h Sat May 29 21:59:33 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.91 2010/05/24 09:49:17 martin Exp $ */
+/* $NetBSD: cpu.h,v 1.92 2010/05/29 21:59:33 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -247,12 +247,21 @@
* multicast - send to everyone in the sparc64_cpuset_t
* broadcast - send to to all cpus but ourselves
* send - send to just this cpu
+ * The called function do not follow the C ABI, so need to be coded in
+ * assembler.
*/
typedef void (* ipifunc_t)(void *, void *);
void sparc64_multicast_ipi(sparc64_cpuset_t, ipifunc_t, uint64_t, uint64_t);
void sparc64_broadcast_ipi(ipifunc_t, uint64_t, uint64_t);
void sparc64_send_ipi(int, ipifunc_t, uint64_t, uint64_t);
+
+/*
+ * Call an arbitrary C function on another cpu (or all others but ourself)
+ */
+typedef void (*ipi_c_call_func_t)(void*);
+void sparc64_generic_xcall(struct cpu_info*, ipi_c_call_func_t, void*);
+
#endif
/*
diff -r 9a08cd04bb38 -r 6bce55e0a6a9 sys/arch/sparc64/sparc64/ipifuncs.c
--- a/sys/arch/sparc64/sparc64/ipifuncs.c Sat May 29 20:41:58 2010 +0000
+++ b/sys/arch/sparc64/sparc64/ipifuncs.c Sat May 29 21:59:33 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipifuncs.c,v 1.37 2010/05/24 09:49:17 martin Exp $ */
+/* $NetBSD: ipifuncs.c,v 1.38 2010/05/29 21:59:34 martin Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.37 2010/05/24 09:49:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.38 2010/05/29 21:59:34 martin Exp $");
#include "opt_ddb.h"
@@ -65,7 +65,7 @@
/*
- * These are the "function" entry points in locore.s to handle IPI's.
+ * These are the "function" entry points in locore.s/mp_subr.s to handle IPI's.
*/
void sparc64_ipi_halt(void *, void *);
void sparc64_ipi_pause(void *, void *);
@@ -74,6 +74,7 @@
void sparc64_ipi_dcache_flush_page_us(void *, void *);
void sparc64_ipi_dcache_flush_page_usiii(void *, void *);
void sparc64_ipi_blast_dcache(void *, void *);
+void sparc64_ipi_ccall(void *, void *);
/*
* Process cpu stop-self event.
@@ -461,3 +462,30 @@
printf("\n");
}
+
+void
+sparc64_generic_xcall(struct cpu_info *target, ipi_c_call_func_t func,
+ void *arg)
+{
+ /* if target == NULL broadcast to everything but curcpu */
+ if (target)
+ sparc64_send_ipi(target->ci_cpuid, sparc64_ipi_ccall,
+ (uint64_t)(uintptr_t)func, (uint64_t)(uintptr_t)arg);
+ else {
+
+ sparc64_multicast_ipi(cpus_active, sparc64_ipi_ccall,
+ (uint64_t)(uintptr_t)func, (uint64_t)(uintptr_t)arg);
+ }
+}
+
+#if 0
+/* XXX: remove once a public prototype is available */
+void xc_ipi_handler(void);
+void xc_send_ipi(struct cpu_info *);
+
+void
+xc_send_ipi(struct cpu_info *target)
+{
+ sparc64_generic_xcall(target, (ipi_c_call_func_t)xc_ipi_handler, NULL);
+}
+#endif
diff -r 9a08cd04bb38 -r 6bce55e0a6a9 sys/arch/sparc64/sparc64/mp_subr.S
--- a/sys/arch/sparc64/sparc64/mp_subr.S Sat May 29 20:41:58 2010 +0000
+++ b/sys/arch/sparc64/sparc64/mp_subr.S Sat May 29 21:59:33 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mp_subr.S,v 1.1 2010/05/23 18:49:14 martin Exp $ */
+/* $NetBSD: mp_subr.S,v 1.2 2010/05/29 21:59:34 martin Exp $ */
/*
* Copyright (c) 2006-2010 Matthew R. Green
@@ -407,5 +407,23 @@
membar #Sync
ba,a ret_from_intr_vector
nop
+
+/*
+ * Setup a C compatible environment and call a MI function.
+ *
+ * On entry:
+ * %g2 = function to call
+ * %g3 = single argument to called function
+ */
+ENTRY(sparc64_ipi_ccall)
+ save %sp, -CC64FSZ-16, %sp ! create a stack frame
+ stx %g2, [%fp + BIAS -16 + 0] ! save function pointer
+ stx %g3, [%fp + BIAS -16 + 8] ! and argument
+ wrpr %g0, PSTATE_KERN, %pstate ! switch globals
+ ldx [%fp + BIAS -16 + 0], %l0 ! reload function
+ call %l0 ! call function
+ ldx [%fp + BIAS -16 + 8], %o0 ! reload argument
+ restore ! pop stack frame
+ ba,a ret_from_intr_vector ! and return from IPI
+ nop
#endif
-
- Prev by Date:
[src/trunk]: src/share/misc +awk, cifs, lfs, mcga, mda, nntp, rss, wap, yp
- Next by Date:
[src/trunk]: src/sys/arch/powerpc/conf sysmon_power is needed to be able to u...
- Previous by Thread:
[src/trunk]: src/share/misc +awk, cifs, lfs, mcga, mda, nntp, rss, wap, yp
- Next by Thread:
[src/trunk]: src/sys/arch/powerpc/conf sysmon_power is needed to be able to u...
- Indexes:
Home |
Main Index |
Thread Index |
Old Index