aboutsummaryrefslogtreecommitdiff
path: root/pk/riscv-pk.c
blob: 3e4c76f1b3dfd563dac0bd3e2613d1e76169207d (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
26
27
28
#include "pcr.h"

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

  extern char trap_entry;
  register void* te = &trap_entry;
  mtpcr(te,PCR_EVEC);

  mtpcr(0,PCR_COUNT);
  mtpcr(0,PCR_COMPARE);

  register long sr0 = SR_S | SR_PS | SR_ET | SR_IM;
  #ifdef PK_ENABLE_KERNEL_64BIT
    sr0 |= SR_SX;
    #ifdef PK_ENABLE_USER_64BIT
      sr0 |= SR_UX;
    #endif
  #endif
  mtpcr(sr0,PCR_SR);

  extern void boot();
  register void (*boot_p)() = &boot;
  asm("" : "=r"(boot_p) : "0"(boot_p));
  boot_p();
}