This source file includes following definitions.
- main
- mpenter
- mpmain
- startothers
1 #include "types.h"
2 #include "defs.h"
3 #include "param.h"
4 #include "memlayout.h"
5 #include "mmu.h"
6 #include "proc.h"
7 #include "x86.h"
8
9 static void startothers(void);
10 static void mpmain(void) __attribute__((noreturn));
11 extern pde_t *kpgdir;
12 extern char end[];
13
14
15
16
17 int
18 main(void)
19 {
20 kinit1(end, P2V(4*1024*1024));
21 kvmalloc();
22 mpinit();
23 lapicinit();
24 seginit();
25 picinit();
26 ioapicinit();
27 consoleinit();
28 uartinit();
29 pinit();
30 tvinit();
31 binit();
32 fileinit();
33 ideinit();
34 startothers();
35 kinit2(P2V(4*1024*1024), P2V(PHYSTOP));
36 userinit();
37 mpmain();
38 }
39
40
41 static void
42 mpenter(void)
43 {
44 switchkvm();
45 seginit();
46 lapicinit();
47 mpmain();
48 }
49
50
51 static void
52 mpmain(void)
53 {
54 cprintf("cpu%d: starting %d\n", cpuid(), cpuid());
55 idtinit();
56 xchg(&(mycpu()->started), 1);
57 scheduler();
58 }
59
60 pde_t entrypgdir[];
61
62
63 static void
64 startothers(void)
65 {
66 extern uchar _binary_entryother_start[], _binary_entryother_size[];
67 uchar *code;
68 struct cpu *c;
69 char *stack;
70
71
72
73
74 code = P2V(0x7000);
75 memmove(code, _binary_entryother_start, (uint)_binary_entryother_size);
76
77 for(c = cpus; c < cpus+ncpu; c++){
78 if(c == mycpu())
79 continue;
80
81
82
83
84 stack = kalloc();
85 *(void**)(code-4) = stack + KSTACKSIZE;
86 *(void(**)(void))(code-8) = mpenter;
87 *(int**)(code-12) = (void *) V2P(entrypgdir);
88
89 lapicstartap(c->apicid, V2P(code));
90
91
92 while(c->started == 0)
93 ;
94 }
95 }
96
97
98
99
100
101
102 __attribute__((__aligned__(PGSIZE)))
103 pde_t entrypgdir[NPDENTRIES] = {
104
105 [0] = (0) | PTE_P | PTE_W | PTE_PS,
106
107 [KERNBASE>>PDXSHIFT] = (0) | PTE_P | PTE_W | PTE_PS,
108 };
109
110
111
112
113
114
115
116