diff options
Diffstat (limited to 'pk/riscv-pk.c')
-rw-r--r-- | pk/riscv-pk.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/pk/riscv-pk.c b/pk/riscv-pk.c index b25b339..dfcc71d 100644 --- a/pk/riscv-pk.c +++ b/pk/riscv-pk.c @@ -1,6 +1,19 @@ -// force the linker to pull in our __start from boot.S. -void* dummy() +#include "pcr.h" + +void __attribute__((section(".boottext"))) __start() { - extern void __start(); - return &__start; + extern char stack_top; + asm("move $sp,%0" : : "r"(&stack_top-64)); + + register long sr0 = SR_S | SR_PS | SR_ET | SR_UX | SR_KX; + mtpcr(sr0,PCR_SR); + + extern char trap_table; + register void* tt = &trap_table; + mtpcr(tt,PCR_TBR); + + extern void boot(); + register void (*boot_p)() = &boot; + asm("" : "=r"(boot_p) : "0"(boot_p)); + boot_p(); } |