Fixed tests using sbi shutdown

master
vhaudiquet 1 year ago
parent b5cf188c0a
commit e9cc295470
  1. 2
      src/devices/sbi/sbi.c
  2. 2
      tests/Makefile
  3. 4
      tests/addi.s
  4. 10
      tests/beq.s
  5. 10
      tests/blt.s
  6. 4
      tests/exit_return.s
  7. 8
      tests/jal.s
  8. 14
      tests/jalr.s
  9. 4
      tests/mv.s
  10. 8
      tests/swlw.s

@ -75,7 +75,7 @@ void sbi_call(rv32_cpu_t* cpu, uint32_t extension_id, uint32_t func_id)
case SBI_EXTENSION_LEGACY_SHUTDOWN: case SBI_EXTENSION_LEGACY_SHUTDOWN:
{ {
printf("sbi_call: shutdown, goodbye !\n"); printf("sbi_call: shutdown, goodbye !\n");
cpu->sim_ticks_left = 1; exit(cpu->regs.a0);
break; break;
} }
default: default:

@ -2,7 +2,7 @@ AS=riscv32-elf-as
LD=riscv32-elf-ld LD=riscv32-elf-ld
BUILD_DIR=../build/tests/ 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)) NAMES = $(basename $(S_FILES))
OBJECTS=$(patsubst %, $(BUILD_DIR)/%, $(NAMES)) OBJECTS=$(patsubst %, $(BUILD_DIR)/%, $(NAMES))

@ -1,4 +1,6 @@
.include "exit_return.s"
.global _start .global _start
_start: _start:
addi a0, zero, 0xBA addi a0, zero, 0xBA
ebreak exret

@ -1,3 +1,5 @@
.include "exit_return.s"
.global _start .global _start
_start: _start:
# Set base value of a0 to 'test failed' # Set base value of a0 to 'test failed'
@ -14,18 +16,18 @@ _start:
beq t0, t1, eq1 beq t0, t1, eq1
# On failure, return # On failure, return
ebreak exret
eqNeg: eqNeg:
# All passed # All passed
addi a0, zero, 0 addi a0, zero, 0
ebreak exret
eq0: eq0:
# Inequality failed # Inequality failed
ebreak exret
eq1: eq1:
# Equality passed ; now try to test a negative offset case # Equality passed ; now try to test a negative offset case
beq t0, t1, eqNeg beq t0, t1, eqNeg
ebreak exret

@ -1,3 +1,5 @@
.include "exit_return.s"
.global _start .global _start
_start: _start:
# Set base value of a0 to 'test failed' # Set base value of a0 to 'test failed'
@ -12,20 +14,20 @@ _start:
blt t0, t1, lt1 blt t0, t1, lt1
# On failure, return # On failure, return
ebreak exret
ltNeg: ltNeg:
# All passed # All passed
addi a0, zero, 0 addi a0, zero, 0
ebreak exret
lt0: lt0:
# Inequality failed # Inequality failed
ebreak exret
lt1: lt1:
# Inequality passed ; now try with negative numbers # Inequality passed ; now try with negative numbers
addi t0, zero, -1 addi t0, zero, -1
addi t1, zero, -2 addi t1, zero, -2
blt t1, t0, ltNeg blt t1, t0, ltNeg
ebreak exret

@ -0,0 +1,4 @@
.macro exret
addi a7, zero, 0x8
ecall
.endm

@ -1,3 +1,5 @@
.include "exit_return.s"
.global _start .global _start
_start: _start:
# Set base value of a0 to 'test failed' # Set base value of a0 to 'test failed'
@ -8,17 +10,17 @@ _start:
addi t0, t0, 12 addi t0, t0, 12
# Jump and link # Jump and link
jal ra, fn0 jal ra, fn0
ebreak exret
fnNeg: fnNeg:
# All good # All good
addi a0, zero, 0 addi a0, zero, 0
ebreak exret
fn0: fn0:
# Check ra value with our t0 construct # Check ra value with our t0 construct
beq t0, ra, eq0 beq t0, ra, eq0
ebreak exret
eq0: eq0:
# Try to jump back to a negative offset # Try to jump back to a negative offset

@ -1,3 +1,5 @@
.include "exit_return.s"
.global _start .global _start
_start: _start:
# Set base value of a0 to 'test failed' # Set base value of a0 to 'test failed'
@ -19,13 +21,13 @@ _start:
# Jump far to test jalr with negative offset # Jump far to test jalr with negative offset
jal fnfar jal fnfar
ebreak exret
# just_after : address is 16 bytes after auipc # just_after : address is 16 bytes after auipc
just_after: just_after:
# ra must still be the old address # ra must still be the old address
ret ret
ebreak exret
# fn0 : function that calls fn1 and returns # fn0 : function that calls fn1 and returns
fn0: fn0:
@ -42,18 +44,18 @@ fn0:
addi sp, sp, 4 addi sp, sp, 4
ret ret
ebreak exret
# fn1 : just return # fn1 : just return
fn1: fn1:
ret ret
ebreak exret
fnneg: fnneg:
addi a0, zero, 0 addi a0, zero, 0
ebreak exret
fnfar: fnfar:
auipc ra, 0 auipc ra, 0
jalr -8(ra) jalr -8(ra)
ebreak exret

@ -1,5 +1,7 @@
.include "exit_return.s"
.global _start .global _start
_start: _start:
addi a1, zero, 0xBA addi a1, zero, 0xBA
mv a0, a1 mv a0, a1
ebreak exret

@ -1,3 +1,5 @@
.include "exit_return.s"
.global _start .global _start
_start: _start:
# Set base value of a0 to 'test failed' # Set base value of a0 to 'test failed'
@ -16,12 +18,12 @@ _start:
# Compare # Compare
beq t0, t1, good beq t0, t1, good
ebreak exret
good: good:
beq t0, t2, xtragood beq t0, t2, xtragood
ebreak exret
xtragood: xtragood:
addi a0, zero, 0 addi a0, zero, 0
ebreak exret

Loading…
Cancel
Save