From 8e33c08c84b9f418dee69f79e7b579c59e77814b Mon Sep 17 00:00:00 2001 From: ths Date: Mon, 11 Dec 2006 19:22:27 +0000 Subject: MIPS FPU support for the gdb stub, by Daniel Jacobowitz. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2242 c046a42c-6fe2-441c-8c8c-71466251a162 --- gdbstub.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'gdbstub.c') diff --git a/gdbstub.c b/gdbstub.c index 9e10c0c..a5e68ae 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -532,11 +532,37 @@ static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) *(uint32_t *)ptr = tswapl(env->PC); ptr += 4; +#ifdef MIPS_USES_FPU + for (i = 0; i < 32; i++) + { + *(uint32_t *)ptr = tswapl(FPR_W (env, i)); + ptr += 4; + } + + *(uint32_t *)ptr = tswapl(env->fcr31); + ptr += 4; + + *(uint32_t *)ptr = tswapl(env->fcr0); + ptr += 4; +#endif + /* 32 FP registers, fsr, fir, fp. Not yet implemented. */ + /* what's 'fp' mean here? */ return ptr - mem_buf; } +/* convert MIPS rounding mode in FCR31 to IEEE library */ +static unsigned int ieee_rm[] = + { + float_round_nearest_even, + float_round_to_zero, + float_round_up, + float_round_down + }; +#define RESTORE_ROUNDING_MODE \ + set_float_rounding_mode(ieee_rm[env->fcr31 & 3], &env->fp_status) + static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size) { int i; @@ -566,6 +592,28 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size) env->PC = tswapl(*(uint32_t *)ptr); ptr += 4; + +#ifdef MIPS_USES_FPU + for (i = 0; i < 32; i++) + { + FPR_W (env, i) = tswapl(*(uint32_t *)ptr); + ptr += 4; + } + + env->fcr31 = tswapl(*(uint32_t *)ptr) & 0x0183FFFF; + ptr += 4; + + env->fcr0 = tswapl(*(uint32_t *)ptr); + ptr += 4; + + /* set rounding mode */ + RESTORE_ROUNDING_MODE; + +#ifndef CONFIG_SOFTFLOAT + /* no floating point exception for native float */ + SET_FP_ENABLE(env->fcr31, 0); +#endif +#endif } #elif defined (TARGET_SH4) static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) -- cgit v1.1