Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sh5 Deal with NMIs by jumping through the normal tr...



details:   https://anonhg.NetBSD.org/src/rev/3766dda00296
branches:  trunk
changeset: 535893:3766dda00296
user:      scw <scw%NetBSD.org@localhost>
date:      Sat Aug 31 09:11:56 2002 +0000

description:
Deal with NMIs by jumping through the normal trap() code path.
At the very least, this will dump the machine state. At best,
we get into ddb().

This provides a useful way to regain control using an NMI button
if the cpu decides to spin at a high ipl.

diffstat:

 sys/arch/sh5/include/trap.h  |   3 ++-
 sys/arch/sh5/sh5/exception.S |  30 +++++++++++++++++++++++++++++-
 sys/arch/sh5/sh5/trap.c      |   5 ++++-
 3 files changed, 35 insertions(+), 3 deletions(-)

diffs (87 lines):

diff -r 3a6e9cf48eab -r 3766dda00296 sys/arch/sh5/include/trap.h
--- a/sys/arch/sh5/include/trap.h       Sat Aug 31 08:42:00 2002 +0000
+++ b/sys/arch/sh5/include/trap.h       Sat Aug 31 09:11:56 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.h,v 1.2 2002/08/26 10:38:53 scw Exp $     */
+/*     $NetBSD: trap.h,v 1.3 2002/08/31 09:11:56 scw Exp $     */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -88,6 +88,7 @@
 
 /* Software Exception Types */
 #define        T_AST           0x0002  /* Asynchronous System Trap */
+#define        T_NMI           0x0003  /* NMI trap */
 
 /* Bit 0 set == trap came from user mode */
 #define        T_USER          0x0001
diff -r 3a6e9cf48eab -r 3766dda00296 sys/arch/sh5/sh5/exception.S
--- a/sys/arch/sh5/sh5/exception.S      Sat Aug 31 08:42:00 2002 +0000
+++ b/sys/arch/sh5/sh5/exception.S      Sat Aug 31 09:11:56 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exception.S,v 1.6 2002/08/31 08:42:00 scw Exp $        */
+/*     $NetBSD: exception.S,v 1.7 2002/08/31 09:11:56 scw Exp $        */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -845,6 +845,21 @@
 Lsh5_event_interrupt:
        _INTR_FRAME_SAVE(SZ_INTRFRAME)
 
+#ifdef DEBUG
+       /*
+        * Catch NMIs early so that we can convert the interrupt frame
+        * to a regular trapframe and drop into DDB if the NMI button
+        * is pressed.
+        *
+        * This provides a handy way to regain control if the CPU should
+        * decide to spin at a high ipl.
+        */
+       pta/l   Lsh5_event_nmi, tr0
+       ld.q    r15, SFO(SF_INTEVT, SZ_INTRFRAME), r0 /* Fetch INTEVT */
+       movi    0x1c0, r1               /* The NMI event code */
+       beq/l   r0, r1, tr0             /* Jump if NMI */
+#endif
+
        /* sh5_intr_dispatch(struct intrframe *f); */
        LEAF(_C_LABEL(sh5_intr_dispatch), r0)
        ptabs/l r0, tr0
@@ -911,6 +926,19 @@
        /* NOTREACHED */
 
 
+#ifdef DEBUG
+Lsh5_event_nmi:
+       /*
+        * Convert the interrupt frame to a trapframe
+        */
+       addi    r15, -(SZ_TRAPFRAME - SZ_INTRFRAME), r15
+       _TRAP_FRAME_SAVE(SZ_TRAPFRAME)
+       pta/l   Ltrapagain, tr0
+       movi    T_NMI, r0               /* Fabricate an "NMI" event */
+       st.q    r15, SFO(SF_EXPEVT, SZ_TRAPFRAME), r0
+       blink   tr0, r63                /* Go back around to deal with it */
+#endif /* DEBUG */
+
 
 /******************************************************************************
  *
diff -r 3a6e9cf48eab -r 3766dda00296 sys/arch/sh5/sh5/trap.c
--- a/sys/arch/sh5/sh5/trap.c   Sat Aug 31 08:42:00 2002 +0000
+++ b/sys/arch/sh5/sh5/trap.c   Sat Aug 31 09:11:56 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.4 2002/08/26 10:14:02 scw Exp $     */
+/*     $NetBSD: trap.c,v 1.5 2002/08/31 09:11:56 scw Exp $     */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -472,6 +472,9 @@
        case T_AST:
                t = "AST";
                break;
+       case T_NMI:
+               t = "NMI";
+               break;
        default:
                t = "Unknown Exception";
                break;



Home | Main Index | Thread Index | Old Index