| 2006 | } |
| 2007 | |
| 2008 | static vm_page_t |
| 2009 | pmap_alloc_l3(pmap_t pmap, vm_offset_t va, struct rwlock **lockp) |
| 2010 | { |
| 2011 | vm_pindex_t ptepindex; |
| 2012 | pd_entry_t *pde, tpde; |
| 2013 | #ifdef INVARIANTS |
| 2014 | pt_entry_t *pte; |
| 2015 | #endif |
| 2016 | vm_page_t m; |
| 2017 | int lvl; |
| 2018 | |
| 2019 | /* |
| 2020 | * Calculate pagetable page index |
| 2021 | */ |
| 2022 | ptepindex = pmap_l2_pindex(va); |
| 2023 | retry: |
| 2024 | /* |
| 2025 | * Get the page directory entry |
| 2026 | */ |
| 2027 | pde = pmap_pde(pmap, va, &lvl); |
| 2028 | |
| 2029 | /* |
| 2030 | * If the page table page is mapped, we just increment the hold count, |
| 2031 | * and activate it. If we get a level 2 pde it will point to a level 3 |
| 2032 | * table. |
| 2033 | */ |
| 2034 | switch (lvl) { |
| 2035 | case -1: |
| 2036 | break; |
| 2037 | case 0: |
| 2038 | #ifdef INVARIANTS |
| 2039 | pte = pmap_l0_to_l1(pde, va); |
| 2040 | KASSERT(pmap_load(pte) == 0, |
| 2041 | ("pmap_alloc_l3: TODO: l0 superpages")); |
| 2042 | #endif |
| 2043 | break; |
| 2044 | case 1: |
| 2045 | #ifdef INVARIANTS |
| 2046 | pte = pmap_l1_to_l2(pde, va); |
| 2047 | KASSERT(pmap_load(pte) == 0, |
| 2048 | ("pmap_alloc_l3: TODO: l1 superpages")); |
| 2049 | #endif |
| 2050 | break; |
| 2051 | case 2: |
| 2052 | tpde = pmap_load(pde); |
| 2053 | if (tpde != 0) { |
| 2054 | m = PHYS_TO_VM_PAGE(tpde & ~ATTR_MASK); |
| 2055 | m->ref_count++; |
| 2056 | return (m); |
| 2057 | } |
| 2058 | break; |
| 2059 | default: |
| 2060 | panic("pmap_alloc_l3: Invalid level %d", lvl); |
| 2061 | } |
| 2062 | |
| 2063 | /* |
| 2064 | * Here if the pte page isn't mapped, or if it has been deallocated. |
| 2065 | */ |
no test coverage detected