aboutsummaryrefslogtreecommitdiff
path: root/machine/sbi_entry.S
blob: a37dd25f6a0d5e153b5b570aa4c7135432c038fe (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "encoding.h"
#include "mcall.h"

  .section .sbi,"ax",@progbits
  .option norvc
  .align RISCV_PGSHIFT
  .globl sbi_base
sbi_base:

  # TODO: figure out something better to do with this space.  It's not
  # protected from the OS, so beware.
  .skip RISCV_PGSIZE - 2048

  # hart_id
  .align 4
  li a7, MCALL_HART_ID
  ecall
  ret

  # num_harts
  .align 4
  lw a0, num_harts
  ret

  # query_memory
  .align 4
  tail __sbi_query_memory

  # console_putchar
  .align 4
  li a7, MCALL_CONSOLE_PUTCHAR
  ecall
  ret

  # console_getchar
  .align 4
  li a7, MCALL_CONSOLE_GETCHAR
  ecall
  ret

  # empty
  .align 4
  unimp

  # send ipi
  .align 4
  li a7, MCALL_SEND_IPI
  ecall
  ret

  # clear ipi
  .align 4
  li a7, MCALL_CLEAR_IPI
  ecall
  ret

  # timebase
  .align 4
  li a0, 10000000 # or, you know, we could provide the correct answer
  ret

  # shutdown
  .align 4
  li a7, MCALL_SHUTDOWN
  ecall

  # set_timer
  .align 4
  li a7, MCALL_SET_TIMER
  ecall
  ret

  # mask_interrupt
  .align 4
  tail __sbi_mask_interrupt

  # unmask_interrupt
  .align 4
  tail __sbi_unmask_interrupt

  # remote_sfence_vm
  .align 4
  li a7, MCALL_REMOTE_SFENCE_VM
  ecall
  ret

  # remote_sfence_vm_range
  .align 4
  li a7, MCALL_REMOTE_SFENCE_VM
  ecall
  ret

  # remote_fence_i
  .align 4
  li a7, MCALL_REMOTE_FENCE_I
  ecall
  ret

  # end of SBI trampolines

  .globl do_mcall
do_mcall:
  mv a7, a0
  mv a0, a1
  mv a1, a2
  ecall
  ret

  .align RISCV_PGSHIFT
  .globl _sbi_end
_sbi_end: