aboutsummaryrefslogtreecommitdiff
path: root/pk/pk.S
blob: e6c972f9d5408b5d6b889c2bfac5711a8673f768 (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
29
30
31
32
33
34
35
36
37
// See LICENSE for license details.

#include "pcr.h"
#include "pk.h"

.section .text,"ax",@progbits
.globl _start
_start:

  lui sp, %hi(stack_top)
  add sp, sp, %lo(stack_top)

  lui a0, %hi(trap_entry)
  add a0, a0, %lo(trap_entry)
  mtpcr a0, ASM_CR(PCR_EVEC)

#ifdef __riscv64
  li a0, SR_S | SR_PS | SR_ET | SR_EC | SR_S64
#else
  li a0, SR_S | SR_PS | SR_ET | SR_EC
#endif
  or a1, a0, SR_EF | SR_EV
  mtpcr a1, ASM_CR(PCR_SR)
  mfpcr a1, ASM_CR(PCR_SR)
  mtpcr a0, ASM_CR(PCR_SR)
  
  and a2, a1, SR_EF
  lui a0, %hi(have_fp)
  sw  a2, %lo(have_fp)(a0)
  
  and a2, a1, SR_EV
  lui a0, %hi(have_vector)
  sw  a2, %lo(have_vector)(a0)

  lui a0, %hi(boot)
  jalr.j a0, %lo(boot)
  #j boot