diff options
author | Robert Morris <rtm@csail.mit.edu> | 2010-09-13 15:34:44 -0400 |
---|---|---|
committer | Robert Morris <rtm@csail.mit.edu> | 2010-09-13 15:34:44 -0400 |
commit | faad047ab22cbe989c208bff5ecb42608ecb8d7b (patch) | |
tree | b47cd8948dcbc5c86117982245b53f4e9c95dc30 /main.c | |
parent | 124fe7e457c0dc9b671c7ffccb56004eb61da4f0 (diff) | |
download | xv6-labs-faad047ab22cbe989c208bff5ecb42608ecb8d7b.tar.gz xv6-labs-faad047ab22cbe989c208bff5ecb42608ecb8d7b.tar.bz2 xv6-labs-faad047ab22cbe989c208bff5ecb42608ecb8d7b.zip |
change some comments, maybe more informative
delete most comments from bootother.S (since copy of bootasm.S)
ksegment() -> seginit()
move more stuff from main() to mainc()
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -11,16 +11,14 @@ void jkstack(void) __attribute__((noreturn)); void mainc(void); // 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) { mpinit(); // collect info about this machine lapicinit(mpbcpu()); - ksegment(); // set up segments - picinit(); // interrupt controller - ioapicinit(); // another interrupt controller - consoleinit(); // I/O devices & their interrupts - uartinit(); // serial port + seginit(); // set up segments kinit(); // initialize memory allocator jkstack(); // call mainc() on a properly-allocated stack } @@ -37,10 +35,16 @@ jkstack(void) panic("jkstack"); } +// Set up hardware and software. +// Runs only on the boostrap processor. void mainc(void) { cprintf("\ncpu%d: starting xv6\n\n", cpu->id); + picinit(); // interrupt controller + ioapicinit(); // another interrupt controller + consoleinit(); // I/O devices & their interrupts + uartinit(); // serial port kvmalloc(); // initialize the kernel page table pinit(); // process table tvinit(); // trap vectors @@ -64,16 +68,17 @@ static void mpmain(void) { if(cpunum() != mpbcpu()) { - ksegment(); + seginit(); lapicinit(cpunum()); } vmenable(); // turn on paging cprintf("cpu%d: starting\n", cpu->id); idtinit(); // load idt register - xchg(&cpu->booted, 1); + xchg(&cpu->booted, 1); // tell bootothers() we're up scheduler(); // start running processes } +// Start the non-boot processors. static void bootothers(void) { @@ -91,10 +96,13 @@ bootothers(void) if(c == cpus+cpunum()) // We've started already. continue; - // Fill in %esp, %eip and start code on cpu. + // Tell bootother.S what stack to use and the address of mpmain; + // it expects to find these two addresses stored just before + // its first instruction. stack = kalloc(); *(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-8) = mpmain; + lapicstartap(c->id, (uint)code); // Wait for cpu to finish mpmain() |