aboutsummaryrefslogtreecommitdiff
path: root/pk/riscv-pk.c
blob: 8168b336f691764349de38ff094857ea1abb2014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "pcr.h"

void __attribute__((section(".boottext"))) __start()
{
  extern char stack_top;
  asm("move $sp,%0" : : "r"(&stack_top-64));

  register long sr0 = SR_S | SR_PS | SR_ET;
  #ifdef PK_ENABLE_KERNEL_64BIT
    sr0 |= SR_KX;
    #ifdef PK_ENABLE_USER_64BIT
      sr0 |= SR_UX;
    #endif
  #endif
  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();
}