Skip to content

Commit 495b917

Browse files
authored
Or1k spec 1.4 user mode FPCSR R/W (#26)
2 parents 84d285c + c6ff955 commit 495b917

File tree

17 files changed

+846
-19
lines changed

17 files changed

+846
-19
lines changed

cpu/or32/insnset.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@ INSTRUCTION (l_mtspr) {
904904
uint16_t regno = PARAM0 | PARAM2;
905905
uorreg_t value = PARAM1;
906906

907-
if (cpu_state.sprs[SPR_SR] & SPR_SR_SM)
907+
if ((regno == SPR_FPCSR) ||
908+
(cpu_state.sprs[SPR_SR] & SPR_SR_SM))
908909
mtspr(regno, value);
909910
else {
910911
PRINTF("WARNING: trying to write SPR while SR[SUPV] is cleared.\n");
@@ -915,10 +916,11 @@ INSTRUCTION (l_mfspr) {
915916
uint16_t regno = PARAM1 | PARAM2;
916917
uorreg_t value = mfspr(regno);
917918

918-
if ((cpu_state.sprs[SPR_SR] & SPR_SR_SM) ||
919+
if ((regno == SPR_FPCSR) ||
920+
(cpu_state.sprs[SPR_SR] & SPR_SR_SM) ||
919921
// TODO: Check if this SPR should actually be allowed to be read with
920922
// SR's SM==0 and SUMRA==1
921-
(!(cpu_state.sprs[SPR_SR] & SPR_SR_SM) &&
923+
(!(cpu_state.sprs[SPR_SR] & SPR_SR_SM) &&
922924
(cpu_state.sprs[SPR_SR] & SPR_SR_SUMRA)))
923925
SET_PARAM0(value);
924926
else

testsuite/or1ksim.tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ EXTRA_DIST = cfg/or1k/acv-gpio.cfg \
5252
cfg/or1k/fp.cfg \
5353
cfg/or1knd/fp.cfg \
5454
fp.exp \
55+
fpee.exp \
5556
functest.exp \
5657
int-test.exp \
5758
cfg/or1k/inst-set-test.cfg \

testsuite/or1ksim.tests/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ EXTRA_DIST = cfg/or1k/acv-gpio.cfg \
317317
cfg/or1k/fp.cfg \
318318
cfg/or1knd/fp.cfg \
319319
fp.exp \
320+
fpee.exp \
320321
functest.exp \
321322
int-test.exp \
322323
cfg/or1k/inst-set-test.cfg \

testsuite/or1ksim.tests/fpee.exp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# fpee.exp. Floating point exception DejaGNU tests
2+
3+
# Copyright (C) 2023 OpenRISC Developers
4+
5+
# Contributor Stafford Horne <[email protected]>
6+
7+
# This file is part of OpenRISC 1000 Architectural Simulator.
8+
9+
# This program is free software; you can redistribute it and/or modify it
10+
# under the terms of the GNU General Public License as published by the Free
11+
# Software Foundation; either version 3 of the License, or (at your option)
12+
# any later version.
13+
14+
# This program is distributed in the hope that it will be useful, but WITHOUT
15+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17+
# more details.
18+
19+
# You should have received a copy of the GNU General Public License along
20+
# with this program. If not, see <http:#www.gnu.org/licenses/>. */
21+
22+
# -----------------------------------------------------------------------------
23+
# This code is commented throughout for use with Doxygen.
24+
# -----------------------------------------------------------------------------
25+
26+
27+
# Run the floating point test
28+
run_or1ksim "fpee" \
29+
[list "Switching to User Mode" \
30+
"Enabling FPU Exceptions" \
31+
"Exceptions enabled, now DIV 3.14 / 0" \
32+
"Got fpe: " \
33+
"report(0x7f800000);" \
34+
"report(0x00000801);" \
35+
"One more, now MUL 3.14 * MAX" \
36+
"Got fpe: " \
37+
"report(0x7f800000);" \
38+
"report(0x00000109);" \
39+
"exit(0)"] \
40+
"fp.cfg" "fpee/fpee"

testsuite/test-code-or1k/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ SUBDIRS = support \
5555
ext \
5656
fbtest \
5757
fp \
58+
fpee \
5859
testfloat \
5960
functest \
6061
flag \

testsuite/test-code-or1k/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ SUBDIRS = support \
386386
ext \
387387
fbtest \
388388
fp \
389+
fpee \
389390
testfloat \
390391
functest \
391392
flag \

testsuite/test-code-or1k/configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13246,7 +13246,7 @@ printf "%s\n" "#define SIZEOF_INT 4" >>confdefs.h
1324613246
printf "%s\n" "#define SIZEOF_LONG 4" >>confdefs.h
1324713247

1324813248

13249-
ac_config_files="$ac_config_files Makefile acv-gpio/Makefile acv-uart/Makefile atomic/Makefile basic/Makefile cache/Makefile cbasic/Makefile cfg/Makefile dhry/Makefile dmatest/Makefile eth/Makefile except/Makefile except-test/Makefile exit/Makefile ext/Makefile fbtest/Makefile fp/Makefile testfloat/Makefile functest/Makefile flag/Makefile int-test/Makefile int-logger/Makefile inst-set-test/Makefile kbdtest/Makefile local-global/Makefile loop/Makefile mc-async/Makefile mc-dram/Makefile mc-ssram/Makefile mc-sync/Makefile mc-common/Makefile mem-test/Makefile mmu/Makefile mul/Makefile mycompress/Makefile support/Makefile tick/Makefile uos/Makefile upcalls/Makefile pcu/Makefile"
13249+
ac_config_files="$ac_config_files Makefile acv-gpio/Makefile acv-uart/Makefile atomic/Makefile basic/Makefile cache/Makefile cbasic/Makefile cfg/Makefile dhry/Makefile dmatest/Makefile eth/Makefile except/Makefile except-test/Makefile exit/Makefile ext/Makefile fbtest/Makefile fp/Makefile fpee/Makefile testfloat/Makefile functest/Makefile flag/Makefile int-test/Makefile int-logger/Makefile inst-set-test/Makefile kbdtest/Makefile local-global/Makefile loop/Makefile mc-async/Makefile mc-dram/Makefile mc-ssram/Makefile mc-sync/Makefile mc-common/Makefile mem-test/Makefile mmu/Makefile mul/Makefile mycompress/Makefile support/Makefile tick/Makefile uos/Makefile upcalls/Makefile pcu/Makefile"
1325013250

1325113251

1325213252
cat >confcache <<\_ACEOF
@@ -14282,6 +14282,7 @@ do
1428214282
"ext/Makefile") CONFIG_FILES="$CONFIG_FILES ext/Makefile" ;;
1428314283
"fbtest/Makefile") CONFIG_FILES="$CONFIG_FILES fbtest/Makefile" ;;
1428414284
"fp/Makefile") CONFIG_FILES="$CONFIG_FILES fp/Makefile" ;;
14285+
"fpee/Makefile") CONFIG_FILES="$CONFIG_FILES fpee/Makefile" ;;
1428514286
"testfloat/Makefile") CONFIG_FILES="$CONFIG_FILES testfloat/Makefile" ;;
1428614287
"functest/Makefile") CONFIG_FILES="$CONFIG_FILES functest/Makefile" ;;
1428714288
"flag/Makefile") CONFIG_FILES="$CONFIG_FILES flag/Makefile" ;;

testsuite/test-code-or1k/configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ AC_CONFIG_FILES([Makefile \
148148
ext/Makefile \
149149
fbtest/Makefile \
150150
fp/Makefile \
151+
fpee/Makefile \
151152
testfloat/Makefile \
152153
functest/Makefile \
153154
flag/Makefile \

testsuite/test-code-or1k/except-test/except-test-s.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ stack:
6666
.extern excpt_itlbmiss
6767
.extern excpt_range
6868
.extern excpt_syscall
69-
.extern excpt_break
69+
.extern excpt_fpu
7070
.extern excpt_trap
7171

7272
/* Our special text section is used to guarantee this code goes first
@@ -334,14 +334,14 @@ syscall_vector:
334334
l.addi r3,r3,8
335335

336336
.org 0xd00
337-
break_vector:
337+
fpu_vector:
338338
l.addi r1,r1,-120
339339
l.sw 0x1c(r1),r9
340340
l.sw 0x20(r1),r10
341341
l.movhi r9,hi(store_regs)
342342
l.ori r9,r9,lo(store_regs)
343-
l.movhi r10,hi(excpt_break)
344-
l.ori r10,r10,lo(excpt_break)
343+
l.movhi r10,hi(excpt_fpu)
344+
l.ori r10,r10,lo(excpt_fpu)
345345
l.jr r9
346346
l.nop
347347
l.nop

testsuite/test-code-or1k/except-test/except-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ extern unsigned long excpt_dtlbmiss;
143143
extern unsigned long excpt_itlbmiss;
144144
extern unsigned long excpt_range;
145145
extern unsigned long excpt_syscall;
146-
extern unsigned long excpt_break;
146+
extern unsigned long excpt_fpu;
147147
extern unsigned long excpt_trap;
148148

149149

0 commit comments

Comments
 (0)