Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/sys/arch/m68k/fpe pullup 1.20->1.21 (briggs): fix FPE
details: https://anonhg.NetBSD.org/src/rev/d223ffee05a4
branches: netbsd-1-4
changeset: 468799:d223ffee05a4
user: perry <perry%NetBSD.org@localhost>
date: Mon Jun 21 15:18:31 1999 +0000
description:
pullup 1.20->1.21 (briggs): fix FPE
diffstat:
sys/arch/m68k/fpe/fpu_emulate.c | 522 +++++++++++++++++++--------------------
1 files changed, 256 insertions(+), 266 deletions(-)
diffs (truncated from 945 to 300 lines):
diff -r 3a2c732abd98 -r d223ffee05a4 sys/arch/m68k/fpe/fpu_emulate.c
--- a/sys/arch/m68k/fpe/fpu_emulate.c Mon Jun 21 15:18:10 1999 +0000
+++ b/sys/arch/m68k/fpe/fpu_emulate.c Mon Jun 21 15:18:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_emulate.c,v 1.20 1998/07/04 22:18:27 jonathan Exp $ */
+/* $NetBSD: fpu_emulate.c,v 1.20.8.1 1999/06/21 15:18:31 perry Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross
@@ -36,14 +36,12 @@
* XXX - Just a start at it for now...
*/
-#include "opt_ddb.h"
-
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/systm.h>
#include <machine/frame.h>
-#if defined(DDB) && defined(DEBUG)
+#if defined(DDB) && defined(DEBUG_FPE)
# include <m68k/db_machdep.h>
#endif
@@ -57,29 +55,13 @@
static int test_cc __P((struct fpemu *fe, int pred));
static struct fpn *fpu_cmp __P((struct fpemu *fe));
-#if !defined(DL_DEFAULT)
-# if defined(DEBUG_WITH_FPU)
-# define DL_DEFAULT DL_ALL
-# else
-# define DL_DEFAULT 0
-# endif
-#endif
-
-int fpu_debug_level;
-#if DEBUG
-static int global_debug_level = DL_DEFAULT;
-#endif
-
-#define DUMP_INSN(insn) \
-if (fpu_debug_level & DL_DUMPINSN) { \
- printf(" fpu_emulate: insn={adv=%d,siz=%d,op=%04x,w1=%04x}\n", \
+#if DEBUG_FPE
+# define DUMP_INSN(insn) \
+ printf("fpu_emulate: insn={adv=%d,siz=%d,op=%04x,w1=%04x}\n", \
(insn)->is_advance, (insn)->is_datasize, \
- (insn)->is_opcode, (insn)->is_word1); \
-}
-
-#ifdef DEBUG_WITH_FPU
-/* mock fpframe for FPE - it's never overwritten by the real fpframe */
-struct fpframe mockfpf;
+ (insn)->is_opcode, (insn)->is_word1)
+#else
+# define DUMP_INSN(insn)
#endif
/*
@@ -94,37 +76,28 @@
{
static struct instruction insn;
static struct fpemu fe;
+#if 0
u_int savedpc = 0; /* XXX work around gcc -O lossage */
+#endif
int word, optype, sig;
-#ifdef DEBUG
+
/* initialize insn.is_datasize to tell it is *not* initialized */
insn.is_datasize = -1;
-#endif
+
fe.fe_frame = frame;
-#ifdef DEBUG_WITH_FPU
- fe.fe_fpframe = &mockfpf;
- fe.fe_fpsr = mockfpf.fpf_fpsr;
- fe.fe_fpcr = mockfpf.fpf_fpcr;
-#else
fe.fe_fpframe = fpf;
fe.fe_fpsr = fpf->fpf_fpsr;
fe.fe_fpcr = fpf->fpf_fpcr;
+
+#if DEBUG_FPE
+ printf("ENTERING fpu_emulate: FPSR=%08x, FPCR=%08x\n",
+ fe.fe_fpsr, fe.fe_fpcr);
#endif
-#ifdef DEBUG
- if ((fpu_debug_level = (fe.fe_fpcr >> 16) & 0x0000ffff) == 0) {
- /* set the default */
- fpu_debug_level = global_debug_level;
- }
-#endif
-
- if (fpu_debug_level & DL_VERBOSE) {
- printf("ENTERING fpu_emulate: FPSR=%08x, FPCR=%08x\n",
- fe.fe_fpsr, fe.fe_fpcr);
- }
/* always set this (to avoid a warning) */
- savedpc = frame->f_pc;
+ insn.is_pc = frame->f_pc;
+ insn.is_nextpc = 0;
if (frame->f_format == 4) {
/*
* A format 4 is generated by the 68{EC,LC}040. The PC is
@@ -137,33 +110,28 @@
* sizes of all instructions we run across. This may not
* be true, so we save the PC in order to restore it later.
*/
- frame->f_pc = frame->f_fmt4.f_fslw;
+ insn.is_pc = frame->f_fmt4.f_fslw;
+ insn.is_nextpc = frame->f_pc;
}
- word = fusword((void *) (frame->f_pc));
+ word = fusword((void *) (insn.is_pc));
if (word < 0) {
#ifdef DEBUG
- printf(" fpu_emulate: fault reading opcode\n");
+ printf("fpu_emulate: fault reading opcode\n");
#endif
return SIGSEGV;
}
if ((word & 0xf000) != 0xf000) {
#ifdef DEBUG
- printf(" fpu_emulate: not coproc. insn.: opcode=0x%x\n", word);
+ printf("fpu_emulate: not coproc. insn.: opcode=0x%x\n", word);
#endif
return SIGILL;
}
- if (
-#ifdef DEBUG_WITH_FPU
- (word & 0x0E00) != 0x0c00 /* accept fake ID == 6 */
-#else
- (word & 0x0E00) != 0x0200
-#endif
- ) {
+ if ((word & 0x0E00) != 0x0200) {
#ifdef DEBUG
- printf(" fpu_emulate: bad coproc. id: opcode=0x%x\n", word);
+ printf("fpu_emulate: bad coproc. id: opcode=0x%x\n", word);
#endif
return SIGILL;
}
@@ -171,10 +139,10 @@
insn.is_opcode = word;
optype = (word & 0x01C0);
- word = fusword((void *) (frame->f_pc + 2));
+ word = fusword((void *) (insn.is_pc + 2));
if (word < 0) {
#ifdef DEBUG
- printf(" fpu_emulate: fault reading word1\n");
+ printf("fpu_emulate: fault reading word1\n");
#endif
return SIGSEGV;
}
@@ -192,49 +160,58 @@
if (optype == 0x0000) {
/* type=0: generic */
if ((word & 0xc000) == 0xc000) {
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulate: fmovm FPr\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: fmovm FPr\n");
+#endif
sig = fpu_emul_fmovm(&fe, &insn);
} else if ((word & 0xc000) == 0x8000) {
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulate: fmovm FPcr\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: fmovm FPcr\n");
+#endif
sig = fpu_emul_fmovmcr(&fe, &insn);
} else if ((word & 0xe000) == 0x6000) {
/* fstore = fmove FPn,mem */
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulate: fmove to mem\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: fmove to mem\n");
+#endif
sig = fpu_emul_fstore(&fe, &insn);
} else if ((word & 0xfc00) == 0x5c00) {
/* fmovecr */
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulate: fmovecr\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: fmovecr\n");
+#endif
sig = fpu_emul_fmovecr(&fe, &insn);
} else if ((word & 0xa07f) == 0x26) {
/* fscale */
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulate: fscale\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: fscale\n");
+#endif
sig = fpu_emul_fscale(&fe, &insn);
} else {
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulte: other type0\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: other type0\n");
+#endif
/* all other type0 insns are arithmetic */
sig = fpu_emul_arith(&fe, &insn);
}
if (sig == 0) {
- if (fpu_debug_level & DL_VERBOSE)
- printf(" fpu_emulate: type 0 returned 0\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: type 0 returned 0\n");
+#endif
sig = fpu_upd_excp(&fe);
}
} else if (optype == 0x0080 || optype == 0x00C0) {
/* type=2 or 3: fbcc, short or long disp. */
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulate: fbcc %s\n",
- (optype & 0x40) ? "long" : "short");
+#if DEBUG_FPE
+ printf("fpu_emulate: fbcc %s\n",
+ (optype & 0x40) ? "long" : "short");
+#endif
sig = fpu_emul_brcc(&fe, &insn);
} else if (optype == 0x0040) {
/* type=1: fdbcc, fscc, ftrapcc */
- if (fpu_debug_level & DL_INSN)
- printf(" fpu_emulate: type1\n");
+#if DEBUG_FPE
+ printf("fpu_emulate: type1\n");
+#endif
sig = fpu_emul_type1(&fe, &insn);
} else {
/* type=4: fsave (privileged) */
@@ -242,7 +219,7 @@
/* type=6: reserved */
/* type=7: reserved */
#ifdef DEBUG
- printf(" fpu_emulate: bad opcode type: opcode=0x%x\n", insn.is_opcode);
+ printf("fpu_emulate: bad opcode type: opcode=0x%x\n", insn.is_opcode);
#endif
sig = SIGILL;
}
@@ -258,17 +235,19 @@
frame->f_pc += insn.is_advance;
#if defined(DDB) && defined(DEBUG)
else {
- printf(" fpu_emulate: sig=%d, opcode=%x, word1=%x\n",
+ printf("fpu_emulate: sig=%d, opcode=%x, word1=%x\n",
sig, insn.is_opcode, insn.is_word1);
kdb_trap(-1, (db_regs_t *)&frame);
}
#endif
if (frame->f_format == 4)
- frame->f_pc = savedpc; /* XXX Restore PC -- 68{EC,LC}040 only */
+ /* XXX Restore PC -- 68{EC,LC}040 only */
+ frame->f_pc = insn.is_nextpc;
- if (fpu_debug_level & DL_VERBOSE)
- printf("EXITING fpu_emulate: w/FPSR=%08x, FPCR=%08x\n",
- fe.fe_fpsr, fe.fe_fpcr);
+#if DEBUG_FPE
+ printf("EXITING fpu_emulate: w/FPSR=%08x, FPCR=%08x\n",
+ fe.fe_fpsr, fe.fe_fpcr);
+#endif
return (sig);
}
@@ -314,56 +293,64 @@
{
u_int fpsr;
- if (fpu_debug_level & DL_RESULT)
- printf(" fpu_upd_fpsr: previous fpsr=%08x\n", fe->fe_fpsr);
-
+#if DEBUG_FPE
+ printf("fpu_upd_fpsr: previous fpsr=%08x\n", fe->fe_fpsr);
+#endif
/* clear all condition code */
fpsr = fe->fe_fpsr & ~FPSR_CCB;
- if (fpu_debug_level & DL_RESULT)
- printf(" fpu_upd_fpsr: result is a ");
-
+#if DEBUG_FPE
+ printf("fpu_upd_fpsr: result is a ");
+#endif
if (fp->fp_sign) {
- if (fpu_debug_level & DL_RESULT)
- printf("negative ");
+#if DEBUG_FPE
+ printf("negative ");
+#endif
Home |
Main Index |
Thread Index |
Old Index