#include "types.h" #include "param.h" #include "mmu.h" #include "proc.h" #include "defs.h" #include "x86.h" #include "traps.h" #include "syscall.h" #include "elf.h" #include "param.h" #include "spinlock.h" extern char edata[], end[]; void proc0init(); // Bootstrap processor starts running C code here. // This is called main0 not main so that it can have // a void return type. Gcc can't handle functions named // main that don't return int. Really. void main0(void) { int i; static int bcpu; // cannot be on stack // clear BSS memset(edata, 0, end - edata); // Prevent release() from enabling interrupts. for(i=0; isz = PAGE; p->mem = kalloc(p->sz); p->cwd = igetroot(); memset(&p->tf, 0, sizeof p->tf); p->tf->es = p->tf->ds = p->tf->ss = (SEG_UDATA << 3) | DPL_USER; p->tf->cs = (SEG_UCODE << 3) | DPL_USER; p->tf->eflags = FL_IF; p->tf->esp = p->sz; // Push dummy return address to placate gcc. p->tf->esp -= 4; *(uint*)(p->mem + p->tf->esp) = 0xefefefef; p->tf->eip = 0; memmove(p->mem, _binary_initcode_start, (int)_binary_initcode_size); safestrcpy(p->name, "initcode", sizeof p->name); p->state = RUNNABLE; }