1 IMPLEMENTATION[ia32,ux,amd64]:
9 #include "kmem_alloc.h"
10 #include "mem_layout.h"
13 #include "static_init.h"
14 #include "initcalls.h"
19 Vmem_alloc::page_alloc(void *address, Zero_fill zf, unsigned mode)
24 vpage = Kmem_alloc::allocator()->alloc(Config::PAGE_SHIFT);
26 if (EXPECT_FALSE(!vpage))
29 // insert page into master page table
30 Pdir::Iter e = Kmem::kdir->walk(Virt_addr(address), 100,
31 pdir_alloc(Kmem_alloc::allocator()));
32 if (EXPECT_FALSE(e.e->valid()))
34 kdb_ke("page_alloc: address already mapped");
38 if (e.shift() != Config::PAGE_SHIFT)
42 memset(vpage, 0, Config::PAGE_SIZE);
44 page = Mem_layout::pmem_to_phys((Address)vpage);
46 *e.e = page | Pt_entry::Writable | Pt_entry::Dirty
47 | Pt_entry::Valid | Pt_entry::Referenced | Pt_entry::global();
48 page_map (address, 0, zf, page);
51 e.e->add_attr(Pt_entry::User);
56 Kmem_alloc::allocator()->free(Config::PAGE_SHIFT, vpage); // 2^0 = 1 page
61 //----------------------------------------------------------------------------
62 IMPLEMENTATION[ia32,amd64]:
66 Vmem_alloc::page_map(void * /*address*/, int /*order*/, Zero_fill /*zf*/,