| 1227 | } |
| 1228 | |
| 1229 | static vm_page_t |
| 1230 | pmap_allocpte(pmap_t pmap, vm_offset_t va, u_int flags) |
| 1231 | { |
| 1232 | unsigned ptepindex; |
| 1233 | pd_entry_t *pde; |
| 1234 | vm_page_t m; |
| 1235 | |
| 1236 | /* |
| 1237 | * Calculate pagetable page index |
| 1238 | */ |
| 1239 | ptepindex = pmap_pde_pindex(va); |
| 1240 | retry: |
| 1241 | /* |
| 1242 | * Get the page directory entry |
| 1243 | */ |
| 1244 | pde = pmap_pde(pmap, va); |
| 1245 | |
| 1246 | /* |
| 1247 | * If the page table page is mapped, we just increment the hold |
| 1248 | * count, and activate it. |
| 1249 | */ |
| 1250 | if (pde != NULL && *pde != NULL) { |
| 1251 | m = PHYS_TO_VM_PAGE(MIPS_DIRECT_TO_PHYS(*pde)); |
| 1252 | m->ref_count++; |
| 1253 | } else { |
| 1254 | /* |
| 1255 | * Here if the pte page isn't mapped, or if it has been |
| 1256 | * deallocated. |
| 1257 | */ |
| 1258 | m = _pmap_allocpte(pmap, ptepindex, flags); |
| 1259 | if (m == NULL && (flags & PMAP_ENTER_NOSLEEP) == 0) |
| 1260 | goto retry; |
| 1261 | } |
| 1262 | return (m); |
| 1263 | } |
| 1264 | |
| 1265 | /*************************************************** |
| 1266 | * Pmap allocation/deallocation routines. |
no test coverage detected