Module Name: src
Committed By: reinoud
Date: Fri Sep 9 20:14:33 UTC 2011
Modified Files:
src/sys/arch/usermode/dev: cpu.c
Log Message:
Make the trampoline only jump once!
All next calls are directed directly to the func specified.
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/usermode/dev/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/usermode/dev/cpu.c
diff -u src/sys/arch/usermode/dev/cpu.c:1.43 src/sys/arch/usermode/dev/cpu.c:1.44
--- src/sys/arch/usermode/dev/cpu.c:1.43 Fri Sep 9 20:06:04 2011
+++ src/sys/arch/usermode/dev/cpu.c Fri Sep 9 20:14:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.43 2011/09/09 20:06:04 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.44 2011/09/09 20:14:33 reinoud Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <[email protected]>
@@ -30,7 +30,7 @@
#include "opt_hz.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.43 2011/09/09 20:06:04 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.44 2011/09/09 20:14:33 reinoud Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -278,12 +278,18 @@
}
static void
-cpu_lwp_trampoline(void (*func)(void *), void *arg)
+cpu_lwp_trampoline(ucontext_t *ucp, void (*func)(void *), void *arg)
{
#ifdef CPU_DEBUG
printf("cpu_lwp_trampoline called with func %p, arg %p\n", (void *) func, arg);
#endif
+ /* init lwp */
lwp_startup(curcpu()->ci_stash, curlwp);
+
+ /* adjust context so the next switch bypasses the trampoline */
+ thunk_makecontext(ucp, (void (*)(void)) func, 1, arg, NULL, NULL);
+
+ /* issue for the 1st time */
func(arg);
}
@@ -321,7 +327,7 @@
pcb2->pcb_ucp.uc_link = &pcb2->pcb_userland_ucp;
pcb2->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU;
thunk_makecontext(&pcb2->pcb_ucp, (void (*)(void)) cpu_lwp_trampoline,
- 2, func, arg, NULL);
+ 3, &pcb2->pcb_ucp, func, arg);
/* set up the ucontext for the syscall */
pcb2->pcb_syscall_ucp.uc_flags = _UC_CPU;