From 8d774afb2d45592d85725474a704ac99b0624d2c Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Tue, 31 Aug 2010 15:39:25 -0400 Subject: no more pminit, or ELF header at 0x10000 kinit() knows about end and PHYSTOP map all of kernel read/write (rather than r/o instructions) thanks, austin --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 878ea36..cb6e6ce 100644 --- a/main.c +++ b/main.c @@ -21,7 +21,7 @@ main(void) ioapicinit(); // another interrupt controller consoleinit(); // I/O devices & their interrupts uartinit(); // serial port - pminit(); // discover how much memory there is + kinit(); // initialize memory allocator jkstack(); // call mainc() on a properly-allocated stack } -- cgit v1.2.3 From b0751a3e9bfce88cb07c1a540ceabf21f2d53b31 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 1 Sep 2010 00:41:25 -0400 Subject: Space police --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index cb6e6ce..8ddf261 100644 --- a/main.c +++ b/main.c @@ -29,7 +29,7 @@ void jkstack(void) { char *kstack = kalloc(); - if (!kstack) + if(!kstack) panic("jkstack\n"); char *top = kstack + PGSIZE; asm volatile("movl %0,%%esp" : : "r" (top)); -- cgit v1.2.3 From faad047ab22cbe989c208bff5ecb42608ecb8d7b Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Mon, 13 Sep 2010 15:34:44 -0400 Subject: 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() --- main.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 8ddf261..beac4da 100644 --- a/main.c +++ b/main.c @@ -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() -- cgit v1.2.3 From 1a81e38b17144624415d252a521fd5a06079d681 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 11 Jan 2011 13:01:13 -0500 Subject: make new code like old code Variable declarations at top of function, separate from initialization. Use == 0 instead of ! for checking pointers. Consistent spacing around {, *, casts. Declare 0-parameter functions as (void) not (). Integer valued functions return -1 on failure, 0 on success. --- main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index beac4da..8a5f7f1 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,7 @@ static void bootothers(void); static void mpmain(void); -void jkstack(void) __attribute__((noreturn)); +void jmpkstack(void) __attribute__((noreturn)); void mainc(void); // Bootstrap processor starts running C code here. @@ -20,19 +20,20 @@ main(void) lapicinit(mpbcpu()); seginit(); // set up segments kinit(); // initialize memory allocator - jkstack(); // call mainc() on a properly-allocated stack + jmpkstack(); // call mainc() on a properly-allocated stack } void -jkstack(void) +jmpkstack(void) { - char *kstack = kalloc(); - if(!kstack) - panic("jkstack\n"); - char *top = kstack + PGSIZE; - asm volatile("movl %0,%%esp" : : "r" (top)); - asm volatile("call mainc"); - panic("jkstack"); + char *kstack, *top; + + kstack = kalloc(); + if(kstack == 0) + panic("jmpkstack kalloc"); + top = kstack + PGSIZE; + asm volatile("movl %0,%%esp; call mainc" : : "r" (top)); + panic("jmpkstack"); } // Set up hardware and software. @@ -67,7 +68,7 @@ mainc(void) static void mpmain(void) { - if(cpunum() != mpbcpu()) { + if(cpunum() != mpbcpu()){ seginit(); lapicinit(cpunum()); } @@ -87,9 +88,9 @@ bootothers(void) struct cpu *c; char *stack; - // Write bootstrap code to unused memory at 0x7000. The linker has - // placed the start of bootother.S there. - code = (uchar *) 0x7000; + // Write bootstrap code to unused memory at 0x7000. + // The linker has placed the image of bootother.S in _binary_bootother_start. + code = (uchar*)0x7000; memmove(code, _binary_bootother_start, (uint)_binary_bootother_size); for(c = cpus; c < cpus+ncpu; c++){ @@ -110,4 +111,3 @@ bootothers(void) ; } } - -- cgit v1.2.3 From cf4b1ad90bcaeeb0c8458098c87948f61d408f94 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 19 Feb 2011 21:17:55 -0500 Subject: xv6: formatting, cleanup, rev5 (take 2) --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 8a5f7f1..e6d81f3 100644 --- a/main.c +++ b/main.c @@ -89,7 +89,8 @@ bootothers(void) char *stack; // Write bootstrap code to unused memory at 0x7000. - // The linker has placed the image of bootother.S in _binary_bootother_start. + // The linker has placed the image of bootother.S in + // _binary_bootother_start. code = (uchar*)0x7000; memmove(code, _binary_bootother_start, (uint)_binary_bootother_size); @@ -111,3 +112,7 @@ bootothers(void) ; } } + +//PAGEBREAK! +// Blank page. + -- cgit v1.2.3 From 13a96baefc0ff5d8262c4bc8c797bee4b157443c Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Wed, 27 Jul 2011 20:35:46 -0400 Subject: Dirt simple logging Passes usertests and stressfs Seems to recover correctly in a number of simple cases --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index e6d81f3..a27c4ff 100644 --- a/main.c +++ b/main.c @@ -20,7 +20,7 @@ main(void) lapicinit(mpbcpu()); seginit(); // set up segments kinit(); // initialize memory allocator - jmpkstack(); // call mainc() on a properly-allocated stack + jmpkstack(); // call mainc() on a properly-allocated stack } void -- cgit v1.2.3