diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-03-09 23:58:17 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-03-09 23:58:17 -0800 |
commit | b94c7a4b07f96f24ae7411780abf874416549f7b (patch) | |
tree | b94ca015e49392f52e5abf1209ee184fcf874db4 /machine/sbi_impl.c | |
parent | f5a96732cb81571a3ba6b081b8556187d564f678 (diff) | |
download | riscv-pk-b94c7a4b07f96f24ae7411780abf874416549f7b.zip riscv-pk-b94c7a4b07f96f24ae7411780abf874416549f7b.tar.gz riscv-pk-b94c7a4b07f96f24ae7411780abf874416549f7b.tar.bz2 |
Refactor pk, bbl, machine into separate libraries
Yuck.
Diffstat (limited to 'machine/sbi_impl.c')
-rw-r--r-- | machine/sbi_impl.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/machine/sbi_impl.c b/machine/sbi_impl.c new file mode 100644 index 0000000..07844e0 --- /dev/null +++ b/machine/sbi_impl.c @@ -0,0 +1,33 @@ +#include "mtrap.h" +#include "sbi.h" + +uintptr_t __sbi_query_memory(uintptr_t id, memory_block_info *p) +{ + if (id == 0) { + p->base = first_free_paddr; + p->size = mem_size - p->base; + return 0; + } + + return -1; +} + +#define LOW_IRQ_OK(n) ((n) == IRQ_S_SOFT || (n) == IRQ_S_TIMER) + +uintptr_t __sbi_mask_interrupt(uintptr_t which) +{ + if (!LOW_IRQ_OK(which)) + return -1; + + clear_csr(sie, 1UL << which); + return 0; +} + +uintptr_t __sbi_unmask_interrupt(uintptr_t which) +{ + if (!LOW_IRQ_OK(which)) + return -1; + + set_csr(sie, 1UL << which); + return 0; +} |