blob: 21b64ffd4589f84ab571d4925a8960d2a10a72b9 [file] [log] [blame]
#include "unit_header.h"
entry:
li x2, 0
la x8, _trap_handler
csrw mtvec, x8
// dep_lo
la x8, _start
ori x8, x8, 1
csrw 0xBC0, x8
// dep_hi
la x8, pad
ori x8, x8, 1
csrw 0xBC1, x8
jal x1, illegal_code
li x8, 4 // When we come back, clear out x8 and x1
li x1, 4
j done
1:
li x8, 26
j done
nop
_trap_handler:
csrr x8, mepc // Increment beyond the faulting instruction
li x2, 1
addi x8, x8, 4
csrw mepc, x8
mret
pad: // pad to get the next section into harm's way
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
illegal_code:
// Return
li x2, 2
jr x1
data:
.word 0x01020304
.word 0x05060708
start_expected:
.word 1, 4
.word 2, 1
.word 8, 4
.word (0x28+5), 0x80000054 // MTVEC
.word (0x30+1), 0x8000003c // MEPC
.word (0x30+2), 0x00000001 // MCAUSE
.word (0x30+3), 0x80000038 // MTVAL
end_expected: