Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc Add RAS support for sparc.



details:   https://anonhg.NetBSD.org/src/rev/0464766701ab
branches:  trunk
changeset: 782401:0464766701ab
user:      chs <chs%NetBSD.org@localhost>
date:      Fri Nov 02 00:01:19 2012 +0000

description:
Add RAS support for sparc.

diffstat:

 sys/arch/sparc/include/types.h   |   6 ++----
 sys/arch/sparc/sparc/genassym.cf |  17 +++++++++++++----
 sys/arch/sparc/sparc/locore.s    |  23 +++++++++++++++++++++--
 sys/arch/sparc/sparc/machdep.c   |  12 ++++++++++--
 4 files changed, 46 insertions(+), 12 deletions(-)

diffs (158 lines):

diff -r 77c1461080d0 -r 0464766701ab sys/arch/sparc/include/types.h
--- a/sys/arch/sparc/include/types.h    Thu Nov 01 23:34:44 2012 +0000
+++ b/sys/arch/sparc/include/types.h    Fri Nov 02 00:01:19 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.61 2011/07/30 19:29:12 martin Exp $ */
+/*     $NetBSD: types.h,v 1.62 2012/11/02 00:01:19 chs Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -122,15 +122,13 @@
 #define        __GENERIC_SOFT_INTERRUPTS_ALL_LEVELS
 #define __HAVE_CPU_DATA_FIRST
 #define        __HAVE_CPU_VMSPACE_EXEC
+#define        __HAVE_RAS
 
 #ifdef SUN4U
 #define        __HAVE_DEVICE_REGISTER_POSTCONFIG
 #define        __HAVE_ATOMIC64_OPS
 #define        __HAVE_CPU_COUNTER      /* sparc v9 CPUs have %tick */
 #define        __HAVE_FAST_SOFTINTS
-#if defined(_KERNEL)
-#define        __HAVE_RAS
-#endif
 #else
 #define        __HAVE_MM_MD_READWRITE
 #endif
diff -r 77c1461080d0 -r 0464766701ab sys/arch/sparc/sparc/genassym.cf
--- a/sys/arch/sparc/sparc/genassym.cf  Thu Nov 01 23:34:44 2012 +0000
+++ b/sys/arch/sparc/sparc/genassym.cf  Fri Nov 02 00:01:19 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.67 2011/08/15 02:19:44 mrg Exp $
+#      $NetBSD: genassym.cf,v 1.68 2012/11/02 00:01:19 chs Exp $
 
 #
 # Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -106,18 +106,23 @@
 define BSD             BSD
 define USRSTACK        USRSTACK
 
-# proc fields and values
+# LWP fields and values
 define L_PCB           offsetof(struct lwp, l_addr)
 define L_PROC          offsetof(struct lwp, l_proc)
 define L_STAT          offsetof(struct lwp, l_stat)
 define L_WCHAN         offsetof(struct lwp, l_wchan)
 define L_CPU           offsetof(struct lwp, l_cpu)
 define L_PRIORITY      offsetof(struct lwp, l_priority)
-define P_VMSPACE       offsetof(struct proc, p_vmspace)
-define P_MD_SYSCALL    offsetof(struct proc, p_md.md_syscall)
+define L_TF            offsetof(struct lwp, l_md.md_tf)
+
 define LSRUN           LSRUN
 define LSONPROC        LSONPROC
 
+# proc fields
+define P_VMSPACE       offsetof(struct proc, p_vmspace)
+define P_RASLIST       offsetof(struct proc, p_raslist)
+define P_MD_SYSCALL    offsetof(struct proc, p_md.md_syscall)
+
 # VM structure fields
 define VM_PMAP         offsetof(struct vmspace, vm_map.pmap)
 define PMAP_CTX        offsetof(struct pmap, pm_ctx)
@@ -219,6 +224,10 @@
 define PCB_UW          offsetof(struct pcb, pcb_uw)
 define PCB_WIM         offsetof(struct pcb, pcb_wim)
 
+# trapframe fields
+define TF_PC           offsetof(struct trapframe, tf_pc)
+define TF_NPC          offsetof(struct trapframe, tf_npc)
+
 # interrupt enable register PTE
 define IE_REG_PTE_PG   (PG_V | PG_W | PG_S | PG_NC | PG_OBIO)
 
diff -r 77c1461080d0 -r 0464766701ab sys/arch/sparc/sparc/locore.s
--- a/sys/arch/sparc/sparc/locore.s     Thu Nov 01 23:34:44 2012 +0000
+++ b/sys/arch/sparc/sparc/locore.s     Fri Nov 02 00:01:19 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.266 2012/02/19 21:06:28 rmind Exp $       */
+/*     $NetBSD: locore.s,v 1.267 2012/11/02 00:01:19 chs Exp $ */
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -4949,8 +4949,27 @@
        st      %o0, [%o4 + PMAP_CPUSET]
 #endif
 
+       /*
+        * Check for restartable atomic sequences (RAS)
+        */
+       ld      [%g3 + L_PROC], %o0     ! now %o0 points to p
+       ld      [%o0 + P_RASLIST], %o1  ! any RAS in p?
+       cmp     %o1, 0
+       be      Lsw_noras               ! no, skip RAS check
+        mov    %g1, %i0                ! restore oldlwp (for return value)
+       ld      [%g3 + L_TF], %l3       ! pointer to trap frame
+       call    _C_LABEL(ras_lookup)
+        ld     [%l3 + TF_PC], %o1
+       cmp     %o0, -1
+       be      Lsw_noras
+        add    %o0, 4, %o1
+       st      %o0, [%l3 + TF_PC]      ! store rewound %pc
+       st      %o1, [%l3 + TF_NPC]     ! and %npc
+
+Lsw_noras:
+
        ret
-        restore %g0, %g1, %o0          ! return (lastproc)
+        restore                        ! return (oldlwp)
 
 /*
  * Call the idlespin() function if it exists, otherwise just return.
diff -r 77c1461080d0 -r 0464766701ab sys/arch/sparc/sparc/machdep.c
--- a/sys/arch/sparc/sparc/machdep.c    Thu Nov 01 23:34:44 2012 +0000
+++ b/sys/arch/sparc/sparc/machdep.c    Fri Nov 02 00:01:19 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.324 2012/09/13 11:49:16 martin Exp $ */
+/*     $NetBSD: machdep.c,v 1.325 2012/11/02 00:01:20 chs Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.324 2012/09/13 11:49:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.325 2012/11/02 00:01:20 chs Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_sunos.h"
@@ -103,6 +103,7 @@
 #include <sys/simplelock.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
+#include <sys/ras.h>
 
 #include <dev/mm.h>
 
@@ -594,6 +595,7 @@
 {
        struct trapframe *tf = (struct trapframe *)l->l_md.md_tf;
        __greg_t *r = mcp->__gregs;
+       __greg_t ras_pc;
 #ifdef FPU_CONTEXT
        __fpregset_t *f = &mcp->__fpregs;
        struct fpstate *fps = l->l_md.md_fpstate;
@@ -633,6 +635,12 @@
        r[_REG_O6] = tf->tf_out[6];
        r[_REG_O7] = tf->tf_out[7];
 
+       if ((ras_pc = (__greg_t)ras_lookup(l->l_proc,
+           (void *) r[_REG_PC])) != -1) {
+               r[_REG_PC] = ras_pc;
+               r[_REG_nPC] = ras_pc + 4;
+       }
+
        *flags |= (_UC_CPU|_UC_TLSBASE);
 
 #ifdef FPU_CONTEXT



Home | Main Index | Thread Index | Old Index