zircon/kernel/arch/x86/page_tables/page_tables.cc
/**
 * @brief Allocating a new page table
 */
@brief Allocating a new page table
@brief Allocating a new page table
pt_entry_t* X86PageTableBase::AllocatePageTable() {
  paddr_t pa;
  vm_page* p;
  zx_status_t status;
  if (likely(!test_page_alloc_func_)) {
    status = pmm_alloc_page(0, &p, &pa);
  } else {
    status = test_page_alloc_func_(0, &p, &pa);
  }
  if (status != ZX_OK) {
    return nullptr;
  }
  p->set_state(VM_PAGE_STATE_MMU);
  pt_entry_t* page_ptr = static_cast<pt_entry_t*>(paddr_to_physmap(pa));
  DEBUG_ASSERT(page_ptr);
  arch_zero_page(page_ptr);
  return page_ptr;
}
pt_entry_t * X86PageTableBase :: AllocatePageTable ( ) { paddr_t pa ; vm_page * p ; zx_status_t status ; if ( likely ( ! test_page_alloc_func_ ) ) { status = pmm_alloc_page ( 0 , & p , & pa ) ; } else { status = test_page_alloc_func_ ( 0 , & p , & pa ) ; } if ( status != ZX_OK ) { return nullptr ; } p -> set_state ( VM_PAGE_STATE_MMU ) ; pt_entry_t * page_ptr = static_cast < pt_entry_t * > ( paddr_to_physmap ( pa ) ) ; DEBUG_ASSERT ( page_ptr ) ; arch_zero_page ( page_ptr ) ; return page_ptr ; }
@brief Allocating a new page table
@brief Allocating a new page table
// The default allocation routine is pmm_alloc_page so test and explicitly call it // to avoid any unnecessary virtual function calls.