Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode/dev Make the trampoline only jump once!
details: https://anonhg.NetBSD.org/src/rev/5475b5b53daf
branches: trunk
changeset: 769435:5475b5b53daf
user: reinoud <reinoud%NetBSD.org@localhost>
date: Fri Sep 09 20:14:33 2011 +0000
description:
Make the trampoline only jump once!
All next calls are directed directly to the func specified.
diffstat:
sys/arch/usermode/dev/cpu.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (47 lines):
diff -r 12e8e3f1ae28 -r 5475b5b53daf sys/arch/usermode/dev/cpu.c
--- a/sys/arch/usermode/dev/cpu.c Fri Sep 09 20:06:04 2011 +0000
+++ b/sys/arch/usermode/dev/cpu.c Fri Sep 09 20:14:33 2011 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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;
Home |
Main Index |
Thread Index |
Old Index