From c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Tue, 16 Aug 2011 15:47:22 -0400 Subject: Clean up memlayout.h Get rid of last instances of linear address and "la" Get ready for detecting physical memory dynamically --- kalloc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'kalloc.c') diff --git a/kalloc.c b/kalloc.c index 4cc4202..9ff3245 100644 --- a/kalloc.c +++ b/kalloc.c @@ -19,7 +19,8 @@ struct { } kmem; extern char end[]; // first address after kernel loaded from ELF file -char *newend; +extern uint maxpa; // Maximum physical address +static char *newend; // simple page allocator to get off the ground during entry char * @@ -36,6 +37,12 @@ enter_alloc(void) return p; } +uint +detect_memory(void) +{ + return 0xE000000; +} + // Initialize free list of physical pages. void kinit(void) @@ -44,7 +51,7 @@ kinit(void) initlock(&kmem.lock, "kmem"); p = (char*)PGROUNDUP((uint)newend); - for(; p + PGSIZE <= (char*)p2v(PHYSTOP); p += PGSIZE) + for(; p + PGSIZE <= (char*)p2v(maxpa); p += PGSIZE) kfree(p); } @@ -58,7 +65,7 @@ kfree(char *v) { struct run *r; - if((uint)v % PGSIZE || v < end || v2p(v) >= PHYSTOP) + if((uint)v % PGSIZE || v < end || v2p(v) >= maxpa) panic("kfree"); // Fill with junk to catch dangling refs. -- cgit v1.2.3