This source file includes following definitions.
- start
- timerinit
1 #include "types.h"
2 #include "param.h"
3 #include "memlayout.h"
4 #include "riscv.h"
5 #include "defs.h"
6
7 void main();
8 void timerinit();
9
10
11 __attribute__ ((aligned (16))) char stack0[4096 * NCPU];
12
13
14 void
15 start()
16 {
17
18 unsigned long x = r_mstatus();
19 x &= ~MSTATUS_MPP_MASK;
20 x |= MSTATUS_MPP_S;
21 w_mstatus(x);
22
23
24
25 w_mepc((uint64)main);
26
27
28 w_satp(0);
29
30
31 w_medeleg(0xffff);
32 w_mideleg(0xffff);
33 w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
34
35
36
37 w_pmpaddr0(0x3fffffffffffffull);
38 w_pmpcfg0(0xf);
39
40
41 timerinit();
42
43
44 int id = r_mhartid();
45 w_tp(id);
46
47
48 asm volatile("mret");
49 }
50
51
52 void
53 timerinit()
54 {
55
56 w_mie(r_mie() | MIE_STIE);
57
58
59 w_menvcfg(r_menvcfg() | (1L << 63));
60
61
62 w_mcounteren(r_mcounteren() | 2);
63
64
65 w_stimecmp(r_time() + 1000000);
66 }