// Initialization happens in two phases. // 1. main() calls kinit1() while still using entrypgdir to place just // the pages mapped by entrypgdir on free list. // 2. main() calls kinit2() with the rest of the physical pages // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; freerange(vstart, vend); }
// Initialization happens in two phases. // 1. main() calls kinit1() while still using entrypgdir to place just // the pages mapped by entrypgdir on free list. // 2. main() calls kinit2() with the rest of the physical pages // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; freerange(vstart, vend); cprintf("+%x\n", kmem.freelist); }
void initmem1(void *start, void *end) { initlock(&kmem.lock); kmem.freelist = 0; // interrupts aren't set up yet, so we can't call lock/unlock kmem.uselock = 0; freerange(start, end); }
void kinit2(void *vstart, void *vend) { freerange(vstart, vend); kmem.use_lock = 1; }
void initmem2(void *start, void *end) { freerange(start, end); kmem.uselock = 1; }
//------------------------------------------------------------------------------------------------------------------- // kinit2() -- the late initialization for the memory structures. It will free all the remaining paged that are // covered by the full paging tables available to all processors. //------------------------------------------------------------------------------------------------------------------- void kinit2(void *vstart, void *vend) { freerange(vstart, vend); kmem.use_lock = 1; // now, we need to enforce locking }
//------------------------------------------------------------------------------------------------------------------- // kinit1() -- the early initialization of memory. It will free the pages that are initially mapped in the startup // page table (with 1M pages). //------------------------------------------------------------------------------------------------------------------- void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; // no need to use the lock yet freerange(vstart, vend); }
void kinit(void *vstart, void *vend) { freerange(vstart, vend); }