Source-Changes-HG archive

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

[src/trunk]: src/sys/arch implement ucas_* for m68k.



details:   https://anonhg.NetBSD.org/src/rev/9262a8871f56
branches:  trunk
changeset: 756123:9262a8871f56
user:      chs <chs%NetBSD.org@localhost>
date:      Wed Jul 07 01:16:23 2010 +0000

description:
implement ucas_* for m68k.

diffstat:

 sys/arch/amiga/amiga/trap.c       |   8 +++++-
 sys/arch/atari/atari/trap.c       |   7 ++++-
 sys/arch/cesfic/cesfic/trap.c     |   7 ++++-
 sys/arch/hp300/hp300/trap.c       |   7 ++++-
 sys/arch/luna68k/luna68k/trap.c   |   7 ++++-
 sys/arch/m68k/include/m68k.h      |   5 +++-
 sys/arch/m68k/m68k/copy.s         |  40 ++++++++++++++++++++++++++++++++++++++-
 sys/arch/m68k/m68k/m68k_machdep.c |  24 +++++++++++++++++++++-
 sys/arch/mac68k/mac68k/trap.c     |   7 ++++-
 sys/arch/mvme68k/mvme68k/trap.c   |   7 ++++-
 sys/arch/news68k/news68k/trap.c   |   7 ++++-
 sys/arch/next68k/next68k/trap.c   |   7 ++++-
 sys/arch/sun2/sun2/trap.c         |   7 ++++-
 sys/arch/sun3/sun3/trap.c         |   7 ++++-
 sys/arch/x68k/x68k/trap.c         |   7 ++++-
 15 files changed, 126 insertions(+), 28 deletions(-)

diffs (truncated from 454 to 300 lines):

diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/amiga/amiga/trap.c
--- a/sys/arch/amiga/amiga/trap.c       Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/amiga/amiga/trap.c       Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.129 2010/06/06 04:50:05 mrg Exp $   */
+/*     $NetBSD: trap.c,v 1.130 2010/07/07 01:16:23 chs Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -84,7 +84,7 @@
 #include "opt_m68k_arch.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.129 2010/06/06 04:50:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.130 2010/07/07 01:16:23 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -428,6 +428,10 @@
                printf("vmfault %s %lx returned %d\n",
                    map == kernel_map ? "kernel" : "user", va, rv);
 #endif
+       if (map == kernel_map && rv == 0 && ucas_ras_check(&fp->F_t)) {
+               return;
+       }
+
 #ifdef M68060
        if ((machineid & AMIGA_68060) == 0 && mmutype == MMU_68040) {
 #else
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/atari/atari/trap.c
--- a/sys/arch/atari/atari/trap.c       Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/atari/atari/trap.c       Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.107 2010/06/06 04:50:06 mrg Exp $   */
+/*     $NetBSD: trap.c,v 1.108 2010/07/07 01:16:23 chs Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.107 2010/06/06 04:50:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.108 2010/07/07 01:16:23 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -672,6 +672,9 @@
                                uvm_grow(p, va);
 
                        if (type == T_MMUFLT) {
+                               if (ucas_ras_check(&fp->F_t)) {
+                                       return;
+                               }
 #ifdef M68040
                                if (cputype == CPU_68040)
                                        (void) writeback(fp, 1);
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/cesfic/cesfic/trap.c
--- a/sys/arch/cesfic/cesfic/trap.c     Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/cesfic/cesfic/trap.c     Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.51 2010/06/06 04:50:06 mrg Exp $    */
+/*     $NetBSD: trap.c,v 1.52 2010/07/07 01:16:24 chs Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.51 2010/06/06 04:50:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.52 2010/07/07 01:16:24 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -628,6 +628,9 @@
                                uvm_grow(p, va);
 
                        if (type == T_MMUFLT) {
+                               if (ucas_ras_check(&fp->F_t)) {
+                                       return;
+                               }
 #ifdef M68040
                                if (cputype == CPU_68040)
                                        (void) writeback(fp, 1);
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/hp300/hp300/trap.c
--- a/sys/arch/hp300/hp300/trap.c       Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/hp300/hp300/trap.c       Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.143 2010/06/06 04:50:06 mrg Exp $   */
+/*     $NetBSD: trap.c,v 1.144 2010/07/07 01:16:24 chs Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.143 2010/06/06 04:50:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.144 2010/07/07 01:16:24 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -622,6 +622,9 @@
                                uvm_grow(p, va);
 
                        if (type == T_MMUFLT) {
+                               if (ucas_ras_check(&fp->F_t)) {
+                                       return;
+                               }
 #ifdef M68040
                                if (cputype == CPU_68040)
                                        (void) writeback(fp, 1);
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/luna68k/luna68k/trap.c
--- a/sys/arch/luna68k/luna68k/trap.c   Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/luna68k/luna68k/trap.c   Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.63 2010/06/06 04:50:06 mrg Exp $ */
+/* $NetBSD: trap.c,v 1.64 2010/07/07 01:16:24 chs Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -78,7 +78,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.63 2010/06/06 04:50:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.64 2010/07/07 01:16:24 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -578,6 +578,9 @@
                                uvm_grow(p, va);
 
                        if (type == T_MMUFLT) {
+                               if (ucas_ras_check(&fp->F_t)) {
+                                       return;
+                               }
 #ifdef M68040
                                if (cputype == CPU_68040)
                                        (void) writeback(fp, 1);
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/m68k/include/m68k.h
--- a/sys/arch/m68k/include/m68k.h      Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/m68k/include/m68k.h      Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: m68k.h,v 1.16 2009/12/19 18:06:51 tsutsui Exp $        */
+/*     $NetBSD: m68k.h,v 1.17 2010/07/07 01:16:24 chs Exp $    */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -171,5 +171,8 @@
 void   physaccess(void *, void *, int, int);
 void   physunaccess(void *, int);
 
+/* m68k_machdep.c */
+bool   ucas_ras_check(struct trapframe *);
+
 #endif /* _KERNEL */
 #endif /* _M68K_M68K_H_ */
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/m68k/m68k/copy.s
--- a/sys/arch/m68k/m68k/copy.s Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/m68k/m68k/copy.s Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copy.s,v 1.42 2010/03/20 23:31:28 chs Exp $    */
+/*     $NetBSD: copy.s,v 1.43 2010/07/07 01:16:25 chs Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -67,6 +67,11 @@
  * copyin/copyout, fuword/suword, etc.
  */
 
+#include "opt_multiprocessor.h"
+#ifdef MULTIPROCESSOR
+#error need to write MP support for ucas_* functions
+#endif
+
 #include <sys/errno.h>
 #include <machine/asm.h>
 
@@ -502,3 +507,36 @@
 Lsdone:
        clrl    %a1@(PCB_ONFAULT)       | clear fault handler
        rts
+
+/*
+ * int ucas_32(volatile int32_t *uptr, int32_t old, int32_t new, int32_t *ret);
+ * Atomically compare-and-swap an int32_t in user space.
+ */
+       .globl          _C_LABEL(ucas_32_ras_start)
+       .globl          _C_LABEL(ucas_32_ras_end)
+ENTRY(ucas_32)
+       CHECK_SFC
+       CHECK_DFC
+       movl    _C_LABEL(curpcb),%a1
+       movl    #Lucasfault,%a1@(PCB_ONFAULT)   | set fault handler
+       movl    %sp@(4),%a0             | a0 = uptr
+_C_LABEL(ucas_32_ras_start):
+       movl    %sp@(8),%d0             | d0 = old
+       movsl   %a0@,%d1                | d1 = *uptr
+       cmpl    %d0,%d1                 | does *uptr == old?
+       bne     Lucasdiff               | if not, don't change it
+       movl    %sp@(12),%d0            | d0 = new
+       movsl   %d0,%a0@                | *uptr = new
+       nop                             | pipeline sync
+_C_LABEL(ucas_32_ras_end):
+Lucasdiff:
+       movl    %sp@(16),%a0            | a0 = ret
+       movl    %d1,%a0@                | *ret = d1 (old *uptr)
+       clrl    %d0                     | return 0
+
+Lucasfault:
+       clrl    %a1@(PCB_ONFAULT)       | clear fault handler
+       rts
+
+STRONG_ALIAS(ucas_int,ucas_32)
+STRONG_ALIAS(ucas_ptr,ucas_32)
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/m68k/m68k/m68k_machdep.c
--- a/sys/arch/m68k/m68k/m68k_machdep.c Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/m68k/m68k/m68k_machdep.c Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: m68k_machdep.c,v 1.7 2008/04/28 20:23:27 martin Exp $  */
+/*     $NetBSD: m68k_machdep.c,v 1.8 2010/07/07 01:16:25 chs Exp $     */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,10 +27,30 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: m68k_machdep.c,v 1.7 2008/04/28 20:23:27 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m68k_machdep.c,v 1.8 2010/07/07 01:16:25 chs Exp $");
 
 #include <sys/param.h>
+#include <m68k/m68k.h>
+#include <m68k/frame.h>
 
 /* the following is used externally (sysctl_hw) */
 char   machine_arch[] = MACHINE_ARCH;  /* from <machine/param.h> */
 
+extern char ucas_32_ras_start[];
+extern char ucas_32_ras_end[];
+extern short exframesize[];
+
+bool
+ucas_ras_check(struct trapframe *v)
+{
+       struct frame *f = (void *)v;
+
+       if (f->f_pc <= (vaddr_t)ucas_32_ras_start ||
+           f->f_pc >= (vaddr_t)ucas_32_ras_end) {
+               return false;
+       }
+       f->f_pc = (vaddr_t)ucas_32_ras_start;
+       f->f_stackadj = exframesize[f->f_format];
+       f->f_format = f->f_vector = 0;
+       return true;
+}
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/mac68k/mac68k/trap.c
--- a/sys/arch/mac68k/mac68k/trap.c     Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/mac68k/mac68k/trap.c     Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.141 2010/06/06 04:50:07 mrg Exp $   */
+/*     $NetBSD: trap.c,v 1.142 2010/07/07 01:16:25 chs Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.141 2010/06/06 04:50:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.142 2010/07/07 01:16:25 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -618,6 +618,9 @@
                                uvm_grow(p, va);
 
                        if (type == T_MMUFLT) {
+                               if (ucas_ras_check(&fp->F_t)) {
+                                       return;
+                               }
 #if defined(M68040)
                                if (mmutype == MMU_68040)
                                        (void)writeback(fp, 1);
diff -r 7bd99695abcb -r 9262a8871f56 sys/arch/mvme68k/mvme68k/trap.c
--- a/sys/arch/mvme68k/mvme68k/trap.c   Wed Jul 07 01:15:34 2010 +0000
+++ b/sys/arch/mvme68k/mvme68k/trap.c   Wed Jul 07 01:16:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.101 2010/06/06 04:50:07 mrg Exp $   */
+/*     $NetBSD: trap.c,v 1.102 2010/07/07 01:16:25 chs Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.101 2010/06/06 04:50:07 mrg Exp $");



Home | Main Index | Thread Index | Old Index