diff --git a/main.c b/main.c index 9e33708..4176e6c 100644 --- a/main.c +++ b/main.c @@ -6,13 +6,13 @@ #include "x86.h" static void bootothers(void); +static void mpmain(void) __attribute__((noreturn)); // Bootstrap processor starts running C code here. int main(void) { - int i; - static volatile int bcpu; // cannot be on stack + int bcpu, i; extern char edata[], end[]; // clear BSS @@ -20,15 +20,10 @@ main(void) // splhi() every processor during bootstrap. for(i=0; impstack + MPSTACK; + *(void**)(code-4) = c->stack + KSTACKSIZE; *(void**)(code-8) = mpmain; lapic_startap(c->apicid, (uint)code); diff --git a/proc.h b/proc.h index ad37271..57fb4d9 100644 --- a/proc.h +++ b/proc.h @@ -49,8 +49,6 @@ struct proc { // fixed-size stack // expandable heap -#define MPSTACK 512 - // Per-CPU state struct cpu { uchar apicid; // Local APIC ID @@ -58,7 +56,7 @@ struct cpu { struct context context; // Switch here to enter scheduler struct taskstate ts; // Used by x86 to find stack for interrupt struct segdesc gdt[NSEGS]; // x86 global descriptor table - char mpstack[MPSTACK]; // Per-CPU startup stack + char *stack; volatile int booted; // Has the CPU started? int nsplhi; // Depth of splhi nesting. };