kernel/arm/pmap.c
/*
 * Extract the physical address and flags associates with a virtual address
 */
Extract the physical address and flags associates with a virtual address
Extract the physical address and flags associates with a virtual address
int PmapExtract(struct AddressSpace *as, vm_addr va, vm_addr *pa,
                uint32_t *flags) {
  struct Pmap *pmap;
  uint32_t *pt, *phys_pt;
  int pde_idx, pte_idx;
  vm_addr current_paddr;
  struct PmapVPTE *vpte;
  struct PmapVPTE *vpte_base;
  pmap = &as->pmap;
  pde_idx = (va & L1_ADDR_BITS) >> L1_IDX_SHIFT;
  if ((pmap->l1_table[pde_idx] & L1_TYPE_MASK) == L1_TYPE_INV) {
    return -1;
  } else {
    phys_pt = (uint32_t *)(pmap->l1_table[pde_idx] & L1_C_ADDR_MASK);
    pt = (uint32_t *)PmapPaToVa((vm_addr)phys_pt);
  }
  pte_idx = (va & L2_ADDR_BITS) >> L2_IDX_SHIFT;
  vpte_base = (struct PmapVPTE *)((uint8_t *)pt + VPTE_TABLE_OFFS);
  vpte = vpte_base + pte_idx;
  current_paddr = pt[pte_idx] & L2_ADDR_MASK;
  if ((pt[pte_idx] & L2_TYPE_MASK) == L2_TYPE_INV) {
    return -1;
  }
  *pa = current_paddr;
  *flags = vpte->flags;
  return 0;
}
int PmapExtract ( struct AddressSpace * as , vm_addr va , vm_addr * pa , uint32_t * flags ) { struct Pmap * pmap ; uint32_t * pt , * phys_pt ; int pde_idx , pte_idx ; vm_addr current_paddr ; struct PmapVPTE * vpte ; struct PmapVPTE * vpte_base ; pmap = & as -> pmap ; pde_idx = ( va & L1_ADDR_BITS ) >> L1_IDX_SHIFT ; if ( ( pmap -> l1_table [ pde_idx ] & L1_TYPE_MASK ) == L1_TYPE_INV ) { return -1 ; } else { phys_pt = ( uint32_t * ) ( pmap -> l1_table [ pde_idx ] & L1_C_ADDR_MASK ) ; pt = ( uint32_t * ) PmapPaToVa ( ( vm_addr ) phys_pt ) ; } pte_idx = ( va & L2_ADDR_BITS ) >> L2_IDX_SHIFT ; vpte_base = ( struct PmapVPTE * ) ( ( uint8_t * ) pt + VPTE_TABLE_OFFS ) ; vpte = vpte_base + pte_idx ; current_paddr = pt [ pte_idx ] & L2_ADDR_MASK ; if ( ( pt [ pte_idx ] & L2_TYPE_MASK ) == L2_TYPE_INV ) { return -1 ; } * pa = current_paddr ; * flags = vpte -> flags ; return 0 ; }
Extract the physical address and flags associates with a virtual address
Extract the physical address and flags associates with a virtual address