Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode Complete rewrite of the signal and spl fra...
details: https://anonhg.NetBSD.org/src/rev/6ed60281fd15
branches: trunk
changeset: 772933:6ed60281fd15
user: reinoud <reinoud%NetBSD.org@localhost>
date: Sat Jan 21 22:09:56 2012 +0000
description:
Complete rewrite of the signal and spl framework for NetBSD/usermode
Signals are now moved from the sigaltstack ASAP and stacked on a replacement
stack for each processes.
Preemption now works though could be enhanced a bit more
diffstat:
sys/arch/usermode/dev/clock.c | 32 +-
sys/arch/usermode/dev/cpu.c | 19 +-
sys/arch/usermode/dev/if_veth.c | 9 +-
sys/arch/usermode/dev/ld_thunkbus.c | 10 +-
sys/arch/usermode/dev/ttycons.c | 47 ++-
sys/arch/usermode/include/intr.h | 15 +-
sys/arch/usermode/usermode/intr.c | 128 +----------
sys/arch/usermode/usermode/trap.c | 400 ++++++++++++++++++++++-------------
8 files changed, 326 insertions(+), 334 deletions(-)
diffs (truncated from 1113 to 300 lines):
diff -r aabe950d3560 -r 6ed60281fd15 sys/arch/usermode/dev/clock.c
--- a/sys/arch/usermode/dev/clock.c Sat Jan 21 22:05:06 2012 +0000
+++ b/sys/arch/usermode/dev/clock.c Sat Jan 21 22:09:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.25 2012/01/14 21:42:51 reinoud Exp $ */
+/* $NetBSD: clock.c,v 1.26 2012/01/21 22:09:56 reinoud Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_hz.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.25 2012/01/14 21:42:51 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.26 2012/01/21 22:09:56 reinoud Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -50,11 +50,14 @@
static int clock_match(device_t, cfdata_t, void *);
static void clock_attach(device_t, device_t, void *);
-static void clock_signal(int sig, siginfo_t *info, void *ctx);
static unsigned int clock_getcounter(struct timecounter *);
static int clock_todr_gettime(struct todr_chip_handle *, struct timeval *);
+extern void setup_clock_intr(void);
+void clock_intr(void *priv);
+
+
struct clock_softc {
device_t sc_dev;
struct todr_chip_handle sc_todr;
@@ -72,6 +75,7 @@
};
timer_t clock_timerid;
+int clock_running = 0;
CFATTACH_DECL_NEW(clock, sizeof(struct clock_softc),
clock_match, clock_attach, NULL, NULL);
@@ -90,7 +94,6 @@
static void
clock_attach(device_t parent, device_t self, void *opaque)
{
- static struct sigaction sa;
struct clock_softc *sc = device_private(self);
aprint_naive("\n");
@@ -101,21 +104,15 @@
sc->sc_todr.todr_gettime = clock_todr_gettime;
todr_attach(&sc->sc_todr);
- memset(&sa, 0, sizeof(sa));
- thunk_sigemptyset(&sa.sa_mask);
- sa.sa_sigaction = clock_signal;
- sa.sa_flags = SA_RESTART | SA_ONSTACK;
- if (thunk_sigaction(SIGALRM, &sa, NULL) == -1)
- panic("couldn't register SIGALRM handler : %d",
- thunk_geterrno());
-
clock_timerid = thunk_timer_attach();
-
clock_timecounter.tc_quality = 1000;
tc_init(&clock_timecounter);
+
+ setup_clock_intr();
+ clock_running = 1;
}
-static void
+void
clock_intr(void *priv)
{
struct clockframe cf;
@@ -126,13 +123,6 @@
}
}
-static void
-clock_signal(int sig, siginfo_t *info, void *ctx)
-{
- curcpu()->ci_idepth++;
- spl_intr(IPL_SOFTCLOCK, clock_intr, NULL);
- curcpu()->ci_idepth--;
-}
static unsigned int
clock_getcounter(struct timecounter *tc)
diff -r aabe950d3560 -r 6ed60281fd15 sys/arch/usermode/dev/cpu.c
--- a/sys/arch/usermode/dev/cpu.c Sat Jan 21 22:05:06 2012 +0000
+++ b/sys/arch/usermode/dev/cpu.c Sat Jan 21 22:09:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.68 2012/01/18 19:17:02 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.69 2012/01/21 22:09:56 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.68 2012/01/18 19:17:02 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.69 2012/01/21 22:09:56 reinoud Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -244,12 +244,13 @@
thunk_makecontext(&sc->sc_ucp, (void (*)(void)) cpu_switchto_atomic,
2, oldlwp, newlwp, NULL);
- if (!oldpcb) {
+ KASSERT(sc);
+ if (oldpcb) {
+ thunk_swapcontext(&oldpcb->pcb_ucp, &sc->sc_ucp);
+ /* returns here */
+ } else {
thunk_setcontext(&sc->sc_ucp);
/* never returns */
- } else {
- thunk_swapcontext(&oldpcb->pcb_ucp, &sc->sc_ucp);
- /* returns here */
}
#ifdef CPU_DEBUG
@@ -374,8 +375,10 @@
/* get l2 its own stack */
pcb2->pcb_ucp.uc_stack.ss_sp = pcb2->sys_stack;
pcb2->pcb_ucp.uc_stack.ss_size = pcb2->sys_stack_top - pcb2->sys_stack;
+ pcb2->pcb_ucp.uc_link = &pcb2->pcb_userret_ucp;
+
+ thunk_sigemptyset(&pcb2->pcb_ucp.uc_sigmask);
pcb2->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK;
- pcb2->pcb_ucp.uc_link = &pcb2->pcb_userret_ucp;
thunk_makecontext(&pcb2->pcb_ucp,
(void (*)(void)) cpu_lwp_trampoline,
3, &pcb2->pcb_ucp, func, arg);
@@ -412,7 +415,9 @@
/* init lwp0 */
memset(&lwp0pcb, 0, sizeof(lwp0pcb));
thunk_getcontext(&lwp0pcb.pcb_ucp);
+ thunk_sigemptyset(&lwp0pcb.pcb_ucp.uc_sigmask);
lwp0pcb.pcb_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK;
+
uvm_lwp_setuarea(&lwp0, (vaddr_t) &lwp0pcb);
memcpy(&lwp0pcb.pcb_userret_ucp, &lwp0pcb.pcb_ucp, sizeof(ucontext_t));
diff -r aabe950d3560 -r 6ed60281fd15 sys/arch/usermode/dev/if_veth.c
--- a/sys/arch/usermode/dev/if_veth.c Sat Jan 21 22:05:06 2012 +0000
+++ b/sys/arch/usermode/dev/if_veth.c Sat Jan 21 22:09:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_veth.c,v 1.4 2012/01/15 10:51:12 jmcneill Exp $ */
+/* $NetBSD: if_veth.c,v 1.5 2012/01/21 22:09:56 reinoud Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.4 2012/01/15 10:51:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.5 2012/01/21 22:09:56 reinoud Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -189,10 +189,7 @@
{
struct veth_softc *sc = priv;
- curcpu()->ci_idepth++;
- spl_intr(IPL_NET, softint_schedule, sc->sc_rx_intr);
- curcpu()->ci_idepth--;
-
+ softint_schedule(sc->sc_rx_intr);
return 0;
}
diff -r aabe950d3560 -r 6ed60281fd15 sys/arch/usermode/dev/ld_thunkbus.c
--- a/sys/arch/usermode/dev/ld_thunkbus.c Sat Jan 21 22:05:06 2012 +0000
+++ b/sys/arch/usermode/dev/ld_thunkbus.c Sat Jan 21 22:09:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.29 2012/01/09 21:01:31 reinoud Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.30 2012/01/21 22:09:57 reinoud Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.29 2012/01/09 21:01:31 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.30 2012/01/21 22:09:57 reinoud Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -145,9 +145,7 @@
struct ld_softc *ld = arg;
struct ld_thunkbus_softc *sc = (struct ld_thunkbus_softc *)ld;
- curcpu()->ci_idepth++;
- spl_intr(IPL_BIO, softint_schedule, sc->sc_ih);
- curcpu()->ci_idepth--;
+ softint_schedule(sc->sc_ih);
return 0;
}
@@ -250,7 +248,7 @@
/* let the softint do the work */
sc->busy = true;
- spl_intr(IPL_BIO, softint_schedule, sc->sc_ih);
+ softint_schedule(sc->sc_ih);
return 0;
}
diff -r aabe950d3560 -r 6ed60281fd15 sys/arch/usermode/dev/ttycons.c
--- a/sys/arch/usermode/dev/ttycons.c Sat Jan 21 22:05:06 2012 +0000
+++ b/sys/arch/usermode/dev/ttycons.c Sat Jan 21 22:09:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ttycons.c,v 1.17 2011/12/27 20:59:45 jmcneill Exp $ */
+/* $NetBSD: ttycons.c,v 1.18 2012/01/21 22:09:57 reinoud Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttycons.c,v 1.17 2011/12/27 20:59:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttycons.c,v 1.18 2012/01/21 22:09:57 reinoud Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -103,9 +103,9 @@
static int ttycons_intr(void *);
static void ttycons_softintr(void *);
-static void ttycons_ctrlc(int);
+static sigfunc_t ttycons_ctrlc;
static void ttycons_softctrlc(void *);
-static void ttycons_ctrlz(int);
+static sigfunc_t ttycons_ctrlz;
static void ttycons_softctrlz(void *);
static int
@@ -154,8 +154,9 @@
panic("couldn't establish ttycons ctrlz handler\n");
sigio_intr_establish(ttycons_intr, sc);
- thunk_signal(SIGINT, ttycons_ctrlc);
- thunk_signal(SIGTSTP, ttycons_ctrlz);
+ signal_intr_establish(SIGINT, ttycons_ctrlc);
+ signal_intr_establish(SIGTSTP, ttycons_ctrlz);
+
if (thunk_set_stdin_sigio(true) != 0)
panic("couldn't enable stdin async mode");
}
@@ -361,9 +362,7 @@
{
struct ttycons_softc *sc = priv;
- curcpu()->ci_idepth++;
- spl_intr(IPL_SERIAL, softint_schedule, sc->sc_rd_sih);
- curcpu()->ci_idepth--;
+ softint_schedule(sc->sc_rd_sih);
return 0;
}
@@ -383,17 +382,20 @@
}
}
+
+/*
+ * handle SIGINT signal from trap.c
+ *
+ * argument 'pc' and 'va' are not used.
+ */
static void
-ttycons_ctrlc(int sig)
+ttycons_ctrlc(vaddr_t from_userland, vaddr_t pc, vaddr_t va)
{
struct ttycons_softc *sc;
- curcpu()->ci_idepth++;
sc = device_lookup_private(&ttycons_cd, minor(cn_tab->cn_dev));
- if (sc) {
- spl_intr(IPL_SERIAL, softint_schedule, sc->sc_ctrlc_sih);
- }
- curcpu()->ci_idepth--;
+ if (sc)
+ softint_schedule(sc->sc_ctrlc_sih);
}
@@ -408,18 +410,19 @@
t->t_linesw->l_rint(ch, t);
}
Home |
Main Index |
Thread Index |
Old Index