zircon/kernel/arch/x86/page_tables/page_tables.cc
/**
 * @brief  Walk the page table structures returning the entry and level that maps the address.
 *
 * @param table The top-level paging structure's virtual address
 * @param vaddr The virtual address to retrieve the mapping for
 * @param ret_level The level of the table that defines the found mapping
 * @param mapping The mapping that was found
 *
 * @return ZX_OK if mapping is found
 * @return ZX_ERR_NOT_FOUND if mapping is not found
 */
@brief  Walk the page table structures returning the entry and level that maps the address.
@param table The top-level paging structure's virtual address
@param vaddr The virtual address to retrieve the mapping for
@param ret_level The level of the table that defines the found mapping
@param mapping The mapping that was found

@return ZX_OK if mapping is found
@return ZX_ERR_NOT_FOUND if mapping is not found
@brief Walk the page table structures returning the entry and level that maps the address . @param table The top - level paging structure ' s virtual address @param vaddr The virtual address to retrieve the mapping for @param ret_level The level of the table that defines the found mapping @param mapping The mapping that was found @return ZX_OK if mapping is found @return ZX_ERR_NOT_FOUND if mapping is not found
zx_status_t X86PageTableBase::GetMapping(volatile pt_entry_t* table, vaddr_t vaddr,
                                         PageTableLevel level, PageTableLevel* ret_level,
                                         volatile pt_entry_t** mapping) {
  DEBUG_ASSERT(table);
  DEBUG_ASSERT(ret_level);
  DEBUG_ASSERT(mapping);
  if (level == PT_L) {
    return GetMappingL0(table, vaddr, ret_level, mapping);
  }
  LTRACEF_LEVEL(2, "table %p\n", table);
  uint index = vaddr_to_index(level, vaddr);
  volatile pt_entry_t* e = table + index;
  pt_entry_t pt_val = *e;
  if (!IS_PAGE_PRESENT(pt_val))
    return ZX_ERR_NOT_FOUND;
  if (IS_LARGE_PAGE(pt_val)) {
    *mapping = e;
    *ret_level = level;
    return ZX_OK;
  }
  volatile pt_entry_t* next_table = get_next_table_from_entry(pt_val);
  return GetMapping(next_table, vaddr, lower_level(level), ret_level, mapping);
}
zx_status_t X86PageTableBase :: GetMapping ( volatile pt_entry_t * table , vaddr_t vaddr , PageTableLevel level , PageTableLevel * ret_level , volatile pt_entry_t * * mapping ) { DEBUG_ASSERT ( table ) ; DEBUG_ASSERT ( ret_level ) ; DEBUG_ASSERT ( mapping ) ; if ( level == PT_L ) { return GetMappingL0 ( table , vaddr , ret_level , mapping ) ; } LTRACEF_LEVEL ( 2 , " \n " , table ) ; uint index = vaddr_to_index ( level , vaddr ) ; volatile pt_entry_t * e = table + index ; pt_entry_t pt_val = * e ; if ( ! IS_PAGE_PRESENT ( pt_val ) ) return ZX_ERR_NOT_FOUND ; if ( IS_LARGE_PAGE ( pt_val ) ) { * mapping = e ; * ret_level = level ; return ZX_OK ; } volatile pt_entry_t * next_table = get_next_table_from_entry ( pt_val ) ; return GetMapping ( next_table , vaddr , lower_level ( level ) , ret_level , mapping ) ; }
@brief  Walk the page table structures returning the entry and level that maps the address.
@brief Walk the page table structures returning the entry and level that maps the address .
/* if this is a large page, stop here */