Switch back to #define for PHYSTOP. Using the E820 to retrieve the memory map is too complicated (must be done in 16-bit real-mode, probably enlarged bootblock beyond 512 bytes, and a #define requires less explanation).
This commit is contained in:
parent
c3dcf47966
commit
5f069dcf2f
3 changed files with 8 additions and 14 deletions
5
kalloc.c
5
kalloc.c
|
@ -19,7 +19,6 @@ struct {
|
|||
} kmem;
|
||||
|
||||
extern char end[]; // first address after kernel loaded from ELF file
|
||||
extern uint maxpa; // Maximum physical address
|
||||
static char *newend;
|
||||
|
||||
// simple page allocator to get off the ground during entry
|
||||
|
@ -51,7 +50,7 @@ kinit(void)
|
|||
|
||||
initlock(&kmem.lock, "kmem");
|
||||
p = (char*)PGROUNDUP((uint)newend);
|
||||
for(; p + PGSIZE <= (char*)p2v(maxpa); p += PGSIZE)
|
||||
for(; p + PGSIZE <= (char*)p2v(PHYSTOP); p += PGSIZE)
|
||||
kfree(p);
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,7 @@ kfree(char *v)
|
|||
{
|
||||
struct run *r;
|
||||
|
||||
if((uint)v % PGSIZE || v < end || v2p(v) >= maxpa)
|
||||
if((uint)v % PGSIZE || v < end || v2p(v) >= PHYSTOP)
|
||||
panic("kfree");
|
||||
|
||||
// Fill with junk to catch dangling refs.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue