Newer
Older
// memory for user processes, kernel stacks, page table pages,
// and pipe buffers. Allocates 4096-byte pages.
extern char end[]; // first address after kernel loaded from ELF file
p = (char*)PGROUNDUP((uint)end);
for(; p + PGSIZE - 1 < (char*)PHYSTOP; p += PGSIZE)
// Free the page of physical memory pointed at by v,
// call to kalloc(). (The exception is when
if((uint)v % PGSIZE || v < end || (uint)v >= PHYSTOP)
r->next = kmem.freelist;
kmem.freelist = r;
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
r = kmem.freelist;
if(r)
kmem.freelist = r->next;