diff options
Diffstat (limited to 'debug/programs')
l--------- | debug/programs/encoding.h | 1 | ||||
-rwxr-xr-x | debug/programs/entry.S | 15 | ||||
-rwxr-xr-x | debug/programs/infinite_loop | bin | 0 -> 9288 bytes | |||
-rw-r--r-- | debug/programs/infinite_loop.c | 14 | ||||
-rw-r--r-- | debug/programs/mprv.S | 6 | ||||
-rw-r--r-- | debug/programs/priv.S | 2 | ||||
-rw-r--r-- | debug/programs/regs.S | 2 | ||||
-rw-r--r-- | debug/programs/trigger.S | 2 |
8 files changed, 36 insertions, 6 deletions
diff --git a/debug/programs/encoding.h b/debug/programs/encoding.h new file mode 120000 index 0000000..56fa44a --- /dev/null +++ b/debug/programs/encoding.h @@ -0,0 +1 @@ +../../env/encoding.h
\ No newline at end of file diff --git a/debug/programs/entry.S b/debug/programs/entry.S index e021860..c9e319c 100755 --- a/debug/programs/entry.S +++ b/debug/programs/entry.S @@ -30,8 +30,23 @@ handle_reset: la t0, trap_entry csrw mtvec, t0 csrwi mstatus, 0 + + // make sure these registers exist by seeing if either S or U bits + // are set before attempting to zero them out. + csrr t1, misa + addi t2, x0, 1 + slli t2, t2, 20 // U_EXTENSION + and t2, t1, t2 + bne x0, t2, 1f + addi t2, x0, 1 + slli t2, t2, 18 // S_EXTENSION + and t2, t1, t2 + bne x0, t2, 1f + j 2f +1: csrwi mideleg, 0 csrwi medeleg, 0 +2: csrwi mie, 0 # initialize global pointer diff --git a/debug/programs/infinite_loop b/debug/programs/infinite_loop Binary files differnew file mode 100755 index 0000000..0cf68cb --- /dev/null +++ b/debug/programs/infinite_loop diff --git a/debug/programs/infinite_loop.c b/debug/programs/infinite_loop.c new file mode 100644 index 0000000..460f78a --- /dev/null +++ b/debug/programs/infinite_loop.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <string.h> +#include <stdint.h> +#include <stdlib.h> + + +int main() +{ + + volatile int forever = 1; + while (forever); + + return 1; +} diff --git a/debug/programs/mprv.S b/debug/programs/mprv.S index 574f32e..a17852a 100644 --- a/debug/programs/mprv.S +++ b/debug/programs/mprv.S @@ -1,4 +1,4 @@ -#include "../../env/encoding.h" +#include "encoding.h" #define PGSHIFT 12 .global main @@ -13,9 +13,9 @@ main: # update mstatus csrr t1, CSR_MSTATUS #if XLEN == 32 - li t0, (MSTATUS_MPRV | (VM_SV32 << 24)) + li t0, (MSTATUS_MPRV | (SPTBR_MODE_SV32 << 24)) #else - li t0, (MSTATUS_MPRV | (VM_SV39 << 24)) + li t0, (MSTATUS_MPRV | (SPTBR_MODE_SV39 << 24)) #endif #li t0, ((VM_SV39 << 24)) or t1, t0, t1 diff --git a/debug/programs/priv.S b/debug/programs/priv.S index 2d20a65..75481be 100644 --- a/debug/programs/priv.S +++ b/debug/programs/priv.S @@ -1,4 +1,4 @@ -#include "../../env/encoding.h" +#include "encoding.h" .global main diff --git a/debug/programs/regs.S b/debug/programs/regs.S index 200184d..50dafa2 100644 --- a/debug/programs/regs.S +++ b/debug/programs/regs.S @@ -8,7 +8,7 @@ # define REGBYTES 4 #endif -#include "../../env/encoding.h" +#include "encoding.h" .global main main: diff --git a/debug/programs/trigger.S b/debug/programs/trigger.S index ac5a2f8..3d502dc 100644 --- a/debug/programs/trigger.S +++ b/debug/programs/trigger.S @@ -1,4 +1,4 @@ -#include "../../env/encoding.h" +#include "encoding.h" #if XLEN == 64 # define LREG ld |