diff options
Diffstat (limited to 'pt/riscv_test.h')
-rw-r--r-- | pt/riscv_test.h | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/pt/riscv_test.h b/pt/riscv_test.h index 93c1c4d..67d5ead 100644 --- a/pt/riscv_test.h +++ b/pt/riscv_test.h @@ -5,7 +5,7 @@ #include "../p/riscv_test.h" -#define TIMER_INTERVAL 100 +#define TIMER_INTERVAL 2 #undef EXTRA_TVEC_USER #define EXTRA_TVEC_USER \ @@ -22,11 +22,16 @@ _skip: \ _jump_around_interrupt_handler: \ #define ENABLE_TIMER_INTERRUPT \ - li a0, MIP_STIP; \ + li a0, MIP_MTIP; \ csrs mie, a0; \ - csrr a0, stime; \ + csrr a0, mtime; \ addi a0, a0, TIMER_INTERVAL; \ - csrw stimecmp, a0; \ + csrw mtimecmp, a0; \ + +#if SSTATUS_XS != 0xc000 +# error +#endif +#define XS_SHIFT 14 #define INTERRUPT_HANDLER \ _interrupt_handler: \ @@ -34,17 +39,14 @@ _interrupt_handler: \ srli a0, a0, 1; \ add a0, a0, -IRQ_TIMER; \ bnez a0, _skip; \ - csrw sscratch, a1; \ - li a1, SSTATUS_XS; \ - csrr a0, sstatus; \ - and a0, a0, a1; \ + srl a0, a0, XS_SHIFT; \ + andi a0, a0, 3; \ beqz a0, _skip_vector_restore; \ VECTOR_RESTORE; \ _skip_vector_restore: \ - csrr a1, sscratch; \ - csrr a0, stime; \ + csrr a0, mtime; \ addi a0, a0, TIMER_INTERVAL; \ - csrw stimecmp, a0; \ + csrw mtimecmp, a0; \ csrr a0, mscratch; \ eret; \ @@ -53,12 +55,13 @@ _skip_vector_restore: \ #define VECTOR_RESTORE \ _vector_restore: \ la a0,regspill; \ - sd a2,0(a0); \ - sd a3,8(a0); \ - sd a4,16(a0); \ - sd a5,24(a0); \ - sd a6,32(a0); \ - sd a7,40(a0); \ + sd a1,0(a0); \ + sd a2,8(a0); \ + sd a3,16(a0); \ + sd a4,24(a0); \ + sd a5,32(a0); \ + sd a6,40(a0); \ + sd a7,48(a0); \ vgetcfg a6; \ vgetvl a7; \ la a0,evac; \ @@ -110,12 +113,13 @@ _done: \ venqcmd a4,a3; \ _done_skip: \ la a0,regspill; \ - ld a2,0(a0); \ - ld a3,8(a0); \ - ld a4,16(a0); \ - ld a5,24(a0); \ - ld a6,32(a0); \ - ld a7,40(a0); \ + ld a1,0(a0); \ + ld a2,8(a0); \ + ld a3,16(a0); \ + ld a4,24(a0); \ + ld a5,32(a0); \ + ld a6,40(a0); \ + ld a7,48(a0); \ #else |