| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include <arch/cpu.h> |
| 7 |
#include <arch/encoding.h> |
| 8 |
#include <vm.h> |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
static u32 delegate = 0 |
| 17 |
| (1 << CAUSE_MISALIGNED_FETCH) |
| 18 |
| (1 << CAUSE_MISALIGNED_STORE) |
| 19 |
| (1 << CAUSE_MISALIGNED_LOAD) |
| 20 |
| (1 << CAUSE_FETCH_ACCESS) |
| 21 |
| (1 << CAUSE_ILLEGAL_INSTRUCTION) |
| 22 |
| (1 << CAUSE_BREAKPOINT) |
| 23 |
| (1 << CAUSE_LOAD_ACCESS) |
| 24 |
| (1 << CAUSE_STORE_ACCESS) |
| 25 |
| (1 << CAUSE_USER_ECALL) |
| 26 |
| (1 << CAUSE_FETCH_PAGE_FAULT) |
| 27 |
| (1 << CAUSE_LOAD_PAGE_FAULT) |
| 28 |
| (1 << CAUSE_STORE_PAGE_FAULT) |
| 29 |
; |
| 30 |
|
| 31 |
void mstatus_init(void) |
| 32 |
{ |
| 33 |
|
| 34 |
clear_csr(mip, MIP_STIP | MIP_SSIP); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
set_csr(mie, MIP_MTIP | MIP_STIP | MIP_SSIP); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
if (supports_extension('S')) { |
| 43 |
set_csr(mideleg, MIP_STIP | MIP_SSIP); |
| 44 |
set_csr(medeleg, delegate); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
write_csr(mcounteren, 7); |
| 49 |
} |