Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode implement splraise/spllower



details:   https://anonhg.NetBSD.org/src/rev/d7c72a3ab72f
branches:  trunk
changeset: 769255:d7c72a3ab72f
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Sep 04 21:08:18 2011 +0000

description:
implement splraise/spllower

diffstat:

 sys/arch/usermode/conf/files.usermode |   3 +-
 sys/arch/usermode/include/intr.h      |  24 ++----------
 sys/arch/usermode/include/thunk.h     |   4 +-
 sys/arch/usermode/usermode/intr.c     |  64 +++++++++++++++++++++++++++++++++++
 sys/arch/usermode/usermode/machdep.c  |   5 +-
 sys/arch/usermode/usermode/thunk.c    |  24 ++++++++++++-
 6 files changed, 97 insertions(+), 27 deletions(-)

diffs (216 lines):

diff -r 71a76897b673 -r d7c72a3ab72f sys/arch/usermode/conf/files.usermode
--- a/sys/arch/usermode/conf/files.usermode     Sun Sep 04 21:04:42 2011 +0000
+++ b/sys/arch/usermode/conf/files.usermode     Sun Sep 04 21:08:18 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.usermode,v 1.9 2011/09/03 18:42:13 jmcneill Exp $
+# $NetBSD: files.usermode,v 1.10 2011/09/04 21:08:18 jmcneill Exp $
 
 maxpartitions 8
 maxusers 8 16 64
@@ -34,6 +34,7 @@
 file   arch/usermode/dev/genfb_thunkbus.c      genfb_thunkbus
 
 file   arch/usermode/usermode/copy.c
+file   arch/usermode/usermode/intr.c
 file   arch/usermode/usermode/machdep.c
 file   arch/usermode/usermode/pmap.c
 file   arch/usermode/usermode/process_machdep.c
diff -r 71a76897b673 -r d7c72a3ab72f sys/arch/usermode/include/intr.h
--- a/sys/arch/usermode/include/intr.h  Sun Sep 04 21:04:42 2011 +0000
+++ b/sys/arch/usermode/include/intr.h  Sun Sep 04 21:08:18 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.2 2009/10/21 16:06:59 snj Exp $ */
+/* $NetBSD: intr.h,v 1.3 2011/09/04 21:08:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,29 +31,13 @@
 
 #include <machine/intrdefs.h>
 
-__inline static int
-splraise(int x)
-{
-       extern int usermode_x;
-       int oldx = usermode_x;
-
-       usermode_x = x;
-
-       return oldx;
-}
-
-__inline static void
-spllower(int x)
-{
-       extern int usermode_x;
-
-       usermode_x = x;
-}
+int    splraise(int);
+void   spllower(int);
 
 #define        spl0()          spllower(IPL_NONE)
 #define splx(x)                spllower(x)
 
-typedef uint8_t        ipl_t;
+typedef uint8_t ipl_t;
 typedef struct {
        ipl_t _ipl;
 } ipl_cookie_t;
diff -r 71a76897b673 -r d7c72a3ab72f sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Sun Sep 04 21:04:42 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Sun Sep 04 21:08:18 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.27 2011/09/04 20:46:58 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.28 2011/09/04 21:08:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -106,6 +106,8 @@
 int    thunk_sigaction(int, const struct sigaction *, struct sigaction *);
 int    thunk_sigaltstack(const stack_t *, stack_t *);
 void   thunk_signal(int, void (*)(int));
+int    thunk_sigblock(int);
+int    thunk_sigunblock(int);
 int    thunk_atexit(void (*function)(void));
 
 int    thunk_aio_read(struct aiocb *);
diff -r 71a76897b673 -r d7c72a3ab72f sys/arch/usermode/usermode/intr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/usermode/usermode/intr.c Sun Sep 04 21:08:18 2011 +0000
@@ -0,0 +1,64 @@
+/* $NetBSD: intr.c,v 1.1 2011/09/04 21:08:18 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.1 2011/09/04 21:08:18 jmcneill Exp $");
+
+#include <sys/types.h>
+
+#include <machine/intr.h>
+#include <machine/thunk.h>
+
+static int usermode_x = IPL_NONE;
+static bool usermode_sigalrm_blocked = false;
+
+int
+splraise(int x)
+{
+       int oldx = usermode_x;
+
+       if (x > IPL_VM && usermode_sigalrm_blocked == false) {
+               thunk_sigblock(SIGALRM);
+               usermode_sigalrm_blocked = true;
+       }
+
+       usermode_x = x;
+
+       return oldx;
+}
+
+void
+spllower(int x)
+{
+       if (x <= IPL_VM && usermode_sigalrm_blocked == true) {
+               thunk_sigunblock(SIGALRM);
+               usermode_sigalrm_blocked = false;
+       }
+
+       usermode_x = x;
+}
diff -r 71a76897b673 -r d7c72a3ab72f sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c      Sun Sep 04 21:04:42 2011 +0000
+++ b/sys/arch/usermode/usermode/machdep.c      Sun Sep 04 21:08:18 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.22 2011/09/03 15:00:28 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.23 2011/09/04 21:08:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #include "opt_urkelvisor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.22 2011/09/03 15:00:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.23 2011/09/04 21:08:18 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -56,7 +56,6 @@
 char machine[] = "usermode";
 char machine_arch[] = "usermode";
 
-int            usermode_x = IPL_NONE;
 /* XXX */
 int            physmem = MEMSIZE * 1024 / PAGE_SIZE;
 
diff -r 71a76897b673 -r d7c72a3ab72f sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Sun Sep 04 21:04:42 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Sun Sep 04 21:08:18 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.31 2011/09/04 20:49:59 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.32 2011/09/04 21:08:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.31 2011/09/04 20:49:59 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.32 2011/09/04 21:08:18 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -387,6 +387,26 @@
 }
 
 int
+thunk_sigblock(int sig)
+{
+       sigset_t set;
+
+       sigemptyset(&set);
+       sigaddset(&set, sig);
+       return sigprocmask(SIG_BLOCK, &set, NULL);
+}
+
+int
+thunk_sigunblock(int sig)
+{
+       sigset_t set;
+
+       sigemptyset(&set);
+       sigaddset(&set, sig);
+       return sigprocmask(SIG_UNBLOCK, &set, NULL);
+}
+
+int
 thunk_atexit(void (*function)(void))
 {
        return atexit(function);



Home | Main Index | Thread Index | Old Index