Fixed tests using sbi shutdown
This commit is contained in:
parent
b5cf188c0a
commit
e9cc295470
@ -75,7 +75,7 @@ void sbi_call(rv32_cpu_t* cpu, uint32_t extension_id, uint32_t func_id)
|
||||
case SBI_EXTENSION_LEGACY_SHUTDOWN:
|
||||
{
|
||||
printf("sbi_call: shutdown, goodbye !\n");
|
||||
cpu->sim_ticks_left = 1;
|
||||
exit(cpu->regs.a0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -2,7 +2,7 @@ AS=riscv32-elf-as
|
||||
LD=riscv32-elf-ld
|
||||
BUILD_DIR=../build/tests/
|
||||
|
||||
S_FILES := $(shell find ./ -name '*.s')
|
||||
S_FILES := $(shell find ./ -name '*.s' -not -name 'exit_return.s')
|
||||
NAMES = $(basename $(S_FILES))
|
||||
OBJECTS=$(patsubst %, $(BUILD_DIR)/%, $(NAMES))
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
.include "exit_return.s"
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
addi a0, zero, 0xBA
|
||||
ebreak
|
||||
exret
|
||||
|
10
tests/beq.s
10
tests/beq.s
@ -1,3 +1,5 @@
|
||||
.include "exit_return.s"
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
# Set base value of a0 to 'test failed'
|
||||
@ -14,18 +16,18 @@ _start:
|
||||
beq t0, t1, eq1
|
||||
|
||||
# On failure, return
|
||||
ebreak
|
||||
exret
|
||||
|
||||
eqNeg:
|
||||
# All passed
|
||||
addi a0, zero, 0
|
||||
ebreak
|
||||
exret
|
||||
|
||||
eq0:
|
||||
# Inequality failed
|
||||
ebreak
|
||||
exret
|
||||
|
||||
eq1:
|
||||
# Equality passed ; now try to test a negative offset case
|
||||
beq t0, t1, eqNeg
|
||||
ebreak
|
||||
exret
|
||||
|
10
tests/blt.s
10
tests/blt.s
@ -1,3 +1,5 @@
|
||||
.include "exit_return.s"
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
# Set base value of a0 to 'test failed'
|
||||
@ -12,20 +14,20 @@ _start:
|
||||
blt t0, t1, lt1
|
||||
|
||||
# On failure, return
|
||||
ebreak
|
||||
exret
|
||||
|
||||
ltNeg:
|
||||
# All passed
|
||||
addi a0, zero, 0
|
||||
ebreak
|
||||
exret
|
||||
|
||||
lt0:
|
||||
# Inequality failed
|
||||
ebreak
|
||||
exret
|
||||
|
||||
lt1:
|
||||
# Inequality passed ; now try with negative numbers
|
||||
addi t0, zero, -1
|
||||
addi t1, zero, -2
|
||||
blt t1, t0, ltNeg
|
||||
ebreak
|
||||
exret
|
||||
|
4
tests/exit_return.s
Normal file
4
tests/exit_return.s
Normal file
@ -0,0 +1,4 @@
|
||||
.macro exret
|
||||
addi a7, zero, 0x8
|
||||
ecall
|
||||
.endm
|
@ -1,3 +1,5 @@
|
||||
.include "exit_return.s"
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
# Set base value of a0 to 'test failed'
|
||||
@ -8,17 +10,17 @@ _start:
|
||||
addi t0, t0, 12
|
||||
# Jump and link
|
||||
jal ra, fn0
|
||||
ebreak
|
||||
exret
|
||||
|
||||
fnNeg:
|
||||
# All good
|
||||
addi a0, zero, 0
|
||||
ebreak
|
||||
exret
|
||||
|
||||
fn0:
|
||||
# Check ra value with our t0 construct
|
||||
beq t0, ra, eq0
|
||||
ebreak
|
||||
exret
|
||||
|
||||
eq0:
|
||||
# Try to jump back to a negative offset
|
||||
|
14
tests/jalr.s
14
tests/jalr.s
@ -1,3 +1,5 @@
|
||||
.include "exit_return.s"
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
# Set base value of a0 to 'test failed'
|
||||
@ -19,13 +21,13 @@ _start:
|
||||
# Jump far to test jalr with negative offset
|
||||
jal fnfar
|
||||
|
||||
ebreak
|
||||
exret
|
||||
|
||||
# just_after : address is 16 bytes after auipc
|
||||
just_after:
|
||||
# ra must still be the old address
|
||||
ret
|
||||
ebreak
|
||||
exret
|
||||
|
||||
# fn0 : function that calls fn1 and returns
|
||||
fn0:
|
||||
@ -42,18 +44,18 @@ fn0:
|
||||
addi sp, sp, 4
|
||||
|
||||
ret
|
||||
ebreak
|
||||
exret
|
||||
|
||||
# fn1 : just return
|
||||
fn1:
|
||||
ret
|
||||
ebreak
|
||||
exret
|
||||
|
||||
fnneg:
|
||||
addi a0, zero, 0
|
||||
ebreak
|
||||
exret
|
||||
|
||||
fnfar:
|
||||
auipc ra, 0
|
||||
jalr -8(ra)
|
||||
ebreak
|
||||
exret
|
||||
|
@ -1,5 +1,7 @@
|
||||
.include "exit_return.s"
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
addi a1, zero, 0xBA
|
||||
mv a0, a1
|
||||
ebreak
|
||||
exret
|
||||
|
@ -1,3 +1,5 @@
|
||||
.include "exit_return.s"
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
# Set base value of a0 to 'test failed'
|
||||
@ -16,12 +18,12 @@ _start:
|
||||
# Compare
|
||||
beq t0, t1, good
|
||||
|
||||
ebreak
|
||||
exret
|
||||
|
||||
good:
|
||||
beq t0, t2, xtragood
|
||||
ebreak
|
||||
exret
|
||||
|
||||
xtragood:
|
||||
addi a0, zero, 0
|
||||
ebreak
|
||||
exret
|
||||
|
Loading…
Reference in New Issue
Block a user