diff options
author | Frans Kaashoek <[email protected]> | 2011-08-16 15:47:22 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2011-08-16 15:47:22 -0400 |
commit | c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52 (patch) | |
tree | f3c00fcd2a86748a615edb8f01ed56c45dd9f474 /kalloc.c | |
parent | 427958cb71e485cec4e7c68b280b506e555dd8e0 (diff) | |
download | xv6-labs-c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52.tar.gz xv6-labs-c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52.tar.bz2 xv6-labs-c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52.zip |
Clean up memlayout.h
Get rid of last instances of linear address and "la"
Get ready for detecting physical memory dynamically
Diffstat (limited to 'kalloc.c')
-rw-r--r-- | kalloc.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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. |