Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips FIX:



details:   https://anonhg.NetBSD.org/src/rev/9753bb345988
branches:  trunk
changeset: 479812:9753bb345988
user:      jun <jun%NetBSD.org@localhost>
date:      Wed Dec 22 04:54:14 1999 +0000

description:
FIX:
port-mips/9016 [serious/medium]:
        MIPS FPU emulator points wrong epc on exception case

        Responsible:    port-mips-maintainer (NetBSD/mips Portmasters)
        State:          open
        Class:          sw-bug
        Originator:     Shuichiro URATA
        Release:        current 12/11/1999
        Arrival-Date:   Fri Dec 17 10:18:00 1999
commit patch
     http://www.a-r.org/~ur/softfloat1211.diff.gz
     by Shuichiro URATA (ur%a-r.org@localhost)

diffstat:

 sys/arch/mips/conf/files.mips   |    5 +-
 sys/arch/mips/include/cpuregs.h |    6 +-
 sys/arch/mips/mips/fp.S         |  566 ++++++++++++++++----------------
 sys/arch/mips/mips/fpemu.c      |  682 +++++++++++++++++++++++----------------
 sys/arch/mips/mips/locore.S     |   81 ++--
 sys/arch/mips/mips/trap.c       |    7 +-
 6 files changed, 745 insertions(+), 602 deletions(-)

diffs (truncated from 2327 to 300 lines):

diff -r ff66bf623e56 -r 9753bb345988 sys/arch/mips/conf/files.mips
--- a/sys/arch/mips/conf/files.mips     Wed Dec 22 04:03:01 1999 +0000
+++ b/sys/arch/mips/conf/files.mips     Wed Dec 22 04:54:14 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.mips,v 1.21 1999/11/18 06:47:48 jun Exp $
+#      $NetBSD: files.mips,v 1.22 1999/12/22 04:54:14 jun Exp $
 #
 
 defopt         opt_cputype.h   NOTHING_YET     # reserved for  CPU level
@@ -12,7 +12,6 @@
 file   arch/mips/mips/mips_mcclock.c   mcclock # CPU speed via mcclock
 file   arch/mips/mips/pmap.c
 file   arch/mips/mips/trap.c                   # interrupt, trap handlers
-file   arch/mips/mips/fpemu.c                  # FPU emulation
 file   arch/mips/mips/vm_machdep.c
 file   arch/mips/mips/mips_machdep.c           # shared mips machdep.c
 file   arch/mips/mips/sys_machdep.c            # shared mips sys_machdep
@@ -21,5 +20,7 @@
 file   arch/mips/mips/in_cksum.c       inet
 file   netns/ns_cksum.c                ns
 
+file   arch/mips/mips/fpemu.c          softfloat
+
 # Binary compatibility with previous NetBSD releases (COMPAT_XX)
 file   arch/mips/mips/compat_13_machdep.c      compat_13 | compat_ultrix
diff -r ff66bf623e56 -r 9753bb345988 sys/arch/mips/include/cpuregs.h
--- a/sys/arch/mips/include/cpuregs.h   Wed Dec 22 04:03:01 1999 +0000
+++ b/sys/arch/mips/include/cpuregs.h   Wed Dec 22 04:54:14 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuregs.h,v 1.24 1999/11/29 11:12:12 uch Exp $ */
+/*     $NetBSD: cpuregs.h,v 1.25 1999/12/22 04:54:15 jun Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -483,6 +483,10 @@
  */
 #define MIPS_OPCODE_SHIFT      26
 #define MIPS_OPCODE_C1         0x11
+#define MIPS_OPCODE_LWC1       0x31
+#define MIPS_OPCODE_LDC1       0x35
+#define MIPS_OPCODE_SWC1       0x39
+#define MIPS_OPCODE_SDC1       0x3d
 
 
 
diff -r ff66bf623e56 -r 9753bb345988 sys/arch/mips/mips/fp.S
--- a/sys/arch/mips/mips/fp.S   Wed Dec 22 04:03:01 1999 +0000
+++ b/sys/arch/mips/mips/fp.S   Wed Dec 22 04:54:14 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fp.S,v 1.14 1999/11/18 06:47:49 jun Exp $      */
+/*     $NetBSD: fp.S,v 1.15 1999/12/22 04:54:15 jun Exp $      */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,6 +41,7 @@
 
 #include <mips/asm.h>
 #include <mips/cpuregs.h>
+#include <mips/trap.h>
 
 #include "assym.h"
 
@@ -82,11 +83,10 @@
  *     Emulate unimplemented floating point operations.
  *     This routine should only be called by MachFPInterrupt().
  *
- *     MachEmulateFP(instr)
- *             unsigned instr;
- *     MachEmulateFP(instr, frame)     : SOFTFLOAT case
- *             unsigned instr;
- *             mips_reg_t *frame;
+ *     MachEmulateFP(instr, frame, cause)
+ *             u_int32_t instr;
+ *             struct frame *frame;
+ *             u_int32_t cause;
  *
  * Results:
  *     None.
@@ -99,19 +99,17 @@
 NESTED(MachEmulateFP, CALLFRAME_SIZ, ra)
        subu    sp, sp, CALLFRAME_SIZ
        sw      ra, CALLFRAME_RA(sp)
+       sw      a2, CALLFRAME_SIZ + 8(sp)
 /*
  * Decode the FMT field (bits 25-21) and FUNCTION field (bits 5-0).
  */
        srl     v0, a0, 21 - 2                  # get FMT field
        andi    v0, v0, 0x1F << 2               # mask FMT field
 #ifdef SOFTFLOAT
-       la      t0, _C_LABEL(fpcurproc)
-       lw      t0, 0(t0)
+       lw      t0, _C_LABEL(fpcurproc)
        lw      t0, P_ADDR(t0)                  # get pointer to pcb for proc
+       lw      a3, fmt_tbl(v0)                 # switch on FUNC & FMT
        lw      a2, U_PCB_FPREGS+FRAME_FSR(t0)
-       lw      a3, fmt_tbl(v0)                 # switch on FUNC & FMT
-       and     a2, a2, ~MIPS_FPU_EXCEPTION_UNIMPL      # clear exception
-       sw      a2, U_PCB_FPREGS+FRAME_FSR(t0)
 #else
        cfc1    a2, MIPS_FPU_CSR                # get exception register
        lw      a3, fmt_tbl(v0)                 # switch on FUNC & FMT
@@ -464,11 +462,9 @@
 
 #ifdef SOFTFLOAT
 mfromc1:
-       la      t0, _C_LABEL(fpcurproc)
-       lw      t0, 0(t0)
+       lw      t0, _C_LABEL(fpcurproc)
+       srl     t1, a0, 11-2
        lw      t0, P_ADDR(t0)                  # get pointer to pcb for proc
-
-       srl     t1, a0, 11-2
        andi    t1, t1, 0x007C
        addu    t0, t0, t1
 
@@ -480,34 +476,30 @@
 
        sw      v0, FRAME_ZERO(t0)
 
-       move    v0, zero
        b       done
 
 mtoc1:
+       sw      zero, FRAME_ZERO(a1)            # ensure zero has value 0
+
        srl     t0, a0, 16-2
        andi    t0, t0, 0x007C
        addu    v0, a1, t0
        lw      v0, FRAME_ZERO(v0)
 
-       la      t0, _C_LABEL(fpcurproc)
-       lw      t0, 0(t0)
+       lw      t0, _C_LABEL(fpcurproc)
+       srl     t1, a0, 11-2
        lw      t0, P_ADDR(t0)                  # get pointer to pcb for proc
-
-       srl     t1, a0, 11-2
        andi    t1, t1, 0x007C
        addu    t0, t0, t1
 
        sw      v0, U_PCB_FPREGS+FRAME_FP0(t0)
 
-       move    v0, zero
        b       done
 
 cfromc1:
-       la      t0, _C_LABEL(fpcurproc)
-       lw      t0, 0(t0)
+       lw      t0, _C_LABEL(fpcurproc)
+       srl     t1, a0, 11
        lw      t0, P_ADDR(t0)                  # get pointer to pcb for proc
-
-       srl     t1, a0, 11
        andi    t1, t1, 0x001F
        li      t2, 0x1F
        move    v0, zero
@@ -523,28 +515,24 @@
 
        sw      v0, FRAME_ZERO(t0)
 
-       move    v0, zero
        b       done
 
 ctoc1:
+       sw      zero, FRAME_ZERO(a1)            # ensure zero has value 0
+
        srl     t0, a0, 11
        andi    t0, t0, 0x001F
-       li      t1, 0x1F        
-       move    v0, zero
+       li      t1, 0x1F
        bne     t0, t1, done
 
        srl     t0, a0, 16-2
        andi    t0, t0, 0x007C
        addu    v0, a1, t0
+       lw      t0, _C_LABEL(fpcurproc)
        lw      v0, FRAME_ZERO(v0)
-
-       la      t0, _C_LABEL(fpcurproc)
-       lw      t0, 0(t0)
        lw      t0, P_ADDR(t0)                  # get pointer to pcb for proc
-
        sw      v0, U_PCB_FPREGS+FRAME_FSR(t0)
 
-       move    v0, zero
        b       done
 
 branchc1:
@@ -594,13 +582,11 @@
        li      v0, MIPS_FPU_COND_BIT
        and     v0, v0, a2
        beq     v0, zero, bcemul_branch
-       move    v0, zero
        b       done
 bctrue:
        li      v0, MIPS_FPU_COND_BIT
        and     v0, v0, a2
        bne     v0, zero, bcemul_branch
-       move    v0, zero
        b       done
 bcfalse_l:
        li      v0, MIPS_FPU_COND_BIT
@@ -609,7 +595,6 @@
        lw      v0, FRAME_EPC(a1)
        addiu   v0, v0, 4
        sw      v0, FRAME_EPC(a1)
-       move    v0, zero
        b       done
 bctrue_l:
        li      v0, MIPS_FPU_COND_BIT
@@ -618,25 +603,22 @@
        lw      v0, FRAME_EPC(a1)
        addiu   v0, v0, 4
        sw      v0, FRAME_EPC(a1)
-       move    v0, zero
        b       done
 
 bcemul_branch:
        /* Fetch delay slot instruction */
-       sw      a0, 0(sp)
-       sw      a1, 4(sp)
+       sw      a1, CALLFRAME_SIZ + 4(sp)
        lw      a0, FRAME_EPC(a1)
+       addiu   a0, a0, 4
        jal     _C_LABEL(fuiword)
-       lw      a0, 0(sp)
-       lw      a1, 4(sp)
 
-       /* Calculate branch destination */
-       sll     t0, a0, 16
-       sra     t0, t0, 16-2
-       lw      t1, FRAME_EPC(a1)
-       addu    t1, t1, t0
-       sw      t1, FRAME_EPC(a1)
        move    a0, v0
+       lw      a1, CALLFRAME_SIZ + 4(sp)
+       lw      a2, CALLFRAME_SIZ + 8(sp)
+
+       /* Update cause */
+       li      t0, MIPS_CR_BR_DELAY
+       or      a2, a2, t0
 
        /* Free MachEmulateFP call frame */
        lw      ra, CALLFRAME_RA(sp)
@@ -1589,8 +1571,7 @@
        and     v0, a2, MIPS_FPU_ENABLE_INEXACT
        bne     v0, zero, fpe_trap
 #ifdef SOFTFLOAT
-       la      v0, _C_LABEL(fpcurproc)
-       lw      v0, 0(v0)
+       lw      v0, _C_LABEL(fpcurproc)
        lw      v0, P_ADDR(v0)                  # get pointer to pcb for proc
        sw      a2, U_PCB_FPREGS+FRAME_FSR(v0)
 #else
@@ -1702,14 +1683,12 @@
        or      a2, a2, MIPS_FPU_COND_BIT       # set condition bit
 2:
 #ifdef SOFTFLOAT
-       la      v0, _C_LABEL(fpcurproc)
-       lw      v0, 0(v0)
+       lw      v0, _C_LABEL(fpcurproc)
        lw      v0, P_ADDR(v0)                  # get pointer to pcb for proc
        sw      a2, U_PCB_FPREGS+FRAME_FSR(v0)
 #else
        ctc1    a2, MIPS_FPU_CSR                # save condition bit
 #endif
-       move    v0, zero
        b       done
 
 unordered:
@@ -1727,14 +1706,12 @@
        bne     v0, zero, fpe_trap
 1:
 #ifdef SOFTFLOAT
-       la      v0, _C_LABEL(fpcurproc)
-       lw      v0, 0(v0)
+       lw      v0, _C_LABEL(fpcurproc)
        lw      v0, P_ADDR(v0)                  # get pointer to pcb for proc
        sw      a2, U_PCB_FPREGS+FRAME_FSR(v0)
 #else
        ctc1    a2, MIPS_FPU_CSR                # save condition bit
 #endif
-       move    v0, zero
        b       done
 
 /*
@@ -1846,14 +1823,12 @@
        and     v0, a2, MIPS_FPU_ENABLE_INEXACT
        bne     v0, zero, fpe_trap
 #ifdef SOFTFLOAT
-       la      v0, _C_LABEL(fpcurproc)
-       lw      v0, 0(v0)
+       lw      v0, _C_LABEL(fpcurproc)
        lw      v0, P_ADDR(v0)                  # get pointer to pcb for proc
        sw      a2, U_PCB_FPREGS+FRAME_FSR(v0)
 #else
        ctc1    a2, MIPS_FPU_CSR                # save exceptions
 #endif
-       move    v0, zero



Home | Main Index | Thread Index | Old Index