Skip to content

Commit d92de6e

Browse files
committed
cpu: Add support for FPU exceptions
The floating point exeption handling was market TODO. Implement it, handling is very similar to SYSCALL so follow that pattern. This was tested with the new or1k-fpe test in or1k-tests and works as expected. Signed-off-by: Stafford Horne <[email protected]>
1 parent f1064f5 commit d92de6e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

cpu-config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ static void
244244
cpu_hardfloat (union param_val val, void *dat)
245245
{
246246
config.cpu.hardfloat = val.int_val;
247+
cpu_state.sprs[SPR_CPUCFGR] |= SPR_CPUCFGR_OF32S;
247248
}
248249
/*---------------------------------------------------------------------------*/
249250
/*!Register the functions to handle a section cpu

cpu/or1k/except.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ except_handle (oraddr_t except, oraddr_t ea)
9999
cpu_state.pc - (cpu_state.delay_insn ? 4 : 0);
100100
break;
101101
/* EPCR is loaded with address of next not-yet-executed instruction */
102+
case EXCEPT_FPE:
102103
case EXCEPT_SYSCALL:
103104
cpu_state.sprs[SPR_EPCR_BASE] =
104105
(cpu_state.pc + 4) - (cpu_state.delay_insn ? 4 : 0);

cpu/or32/execute.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,12 +1113,10 @@ float_set_flags ()
11131113
!!(float_exception_flags & float_flag_underflow),
11141114
!!(float_exception_flags & float_flag_inexact));
11151115
*/
1116-
// TODO: Call FP exception is FPEE set and any of the flags were set
1117-
/*
1118-
if ((cpu_state.sprs[SPR_FPCSR] & SPR_FPCSR_FPEE) &
1119-
(|(cpu_state.sprs[SPR_FPCSR] & SPR_FPCSR_ALLF)))
1120-
except_handle (EXCEPT_FPE, cpu_state.iqueue.insn_addr);
1121-
*/
1116+
// Call FP exception if FPEE set and any of the flags were set
1117+
if ((cpu_state.sprs[SPR_FPCSR] & SPR_FPCSR_FPEE) &&
1118+
(cpu_state.sprs[SPR_FPCSR] & SPR_FPCSR_ALLF))
1119+
except_handle (EXCEPT_FPE, cpu_state.sprs[SPR_EEAR_BASE]);
11221120
// Now clear softfloat's flags:
11231121
float_exception_flags = 0;
11241122

0 commit comments

Comments
 (0)