0
|
1 // BSP support routine
|
|
2 #include "types.h"
|
|
3 #include "defs.h"
|
|
4 #include "param.h"
|
|
5 #include "arm.h"
|
|
6 #include "proc.h"
|
|
7 #include "memlayout.h"
|
|
8 #include "mmu.h"
|
|
9
|
360
|
10 #include "kernel.h"
|
|
11
|
0
|
12 extern void* end;
|
|
13
|
|
14 struct cpu cpus[NCPU];
|
|
15 struct cpu *cpu;
|
|
16
|
360
|
17
|
0
|
18 #define MB (1024*1024)
|
|
19
|
|
20 void kmain (void)
|
|
21 {
|
|
22 uint vectbl;
|
|
23
|
|
24 cpu = &cpus[0];
|
|
25
|
|
26 uart_init (P2V(UART0));
|
|
27
|
|
28 // interrrupt vector table is in the middle of first 1MB. We use the left
|
|
29 // over for page tables
|
|
30 vectbl = P2V_WO (VEC_TBL & PDE_MASK);
|
|
31
|
|
32 init_vmm ();
|
|
33 kpt_freerange (align_up(&end, PT_SZ), vectbl);
|
|
34 kpt_freerange (vectbl + PT_SZ, P2V_WO(INIT_KERNMAP));
|
|
35 paging_init (INIT_KERNMAP, PHYSTOP);
|
|
36
|
|
37 kmem_init ();
|
|
38 kmem_init2(P2V(INIT_KERNMAP), P2V(PHYSTOP));
|
360
|
39
|
367
|
40 kernel_context = calloc(sizeof(struct KernelContext), 1);
|
|
41 initContext(&kernel_context->context);
|
360
|
42
|
0
|
43 trap_init (); // vector table and stacks for models
|
|
44 pic_init (P2V(VIC_BASE)); // interrupt controller
|
|
45 uart_enable_rx (); // interrupt for uart
|
|
46 consoleinit (); // console
|
|
47 pinit (); // process (locks)
|
|
48
|
|
49 binit (); // buffer cache
|
|
50 fileinit (); // file table
|
|
51 iinit (); // inode cache
|
|
52 ideinit (); // ide (memory block device)
|
|
53 timer_init (HZ); // the timer (ticker)
|
|
54
|
|
55
|
|
56 sti ();
|
|
57
|
|
58 userinit(); // first user process
|
|
59 scheduler(); // start running processes
|
|
60 }
|