-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.c
52 lines (44 loc) · 1.25 KB
/
main.c
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
#include <sys/types.h>
#include <xv6/param.h>
#include "defs.h"
#include "memlayout.h"
#include "mmu.h"
#include "proc.h"
#include "gaia.h"
static void mpmain(void);
extern pde_t *kpgdir;
extern char end[];
// Bootstrap processor starts running C code here.
// Allocate a real stack and switch to it, first
// doing some setup required for memory allocator to work.
int
main(void)
{
kinit1(end, P2V(1024*1024)); // phys page allocator
kvmalloc(); // kernel page table
mpinit(); // collect info about this machine
cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
consoleinit(); // I/O devices & their interrupts
deviceinit();
uartinit(); // serial port
pinit(); // process table
trapinit(); // trap vectors
binit(); // buffer cache
fileinit(); // file table
iinit(); // inode cache
ideinit(); // disk
if(!ismp)
timerinit(); // uniprocessor timer
kinit2(P2V(1024*1024), P2V(PHYSTOP)); // must come after startothers()
userinit(); // first user process
// Finish setting up this processor in mpmain.
mpmain();
}
// Common CPU setup code.
static void
mpmain(void)
{
cprintf("cpu%d: starting\n", cpu->id);
cpu->started = 1;
scheduler(); // start running processes
}