Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/booke/pmap.c
Show First 20 Lines • Show All 657 Lines • ▼ Show 20 Lines | pdir_unhold(mmu_t mmu, pmap_t pmap, u_int pp2d_idx) | ||||
/* decrement hold count */ | /* decrement hold count */ | ||||
pa = DMAP_TO_PHYS((vm_offset_t) pdir); | pa = DMAP_TO_PHYS((vm_offset_t) pdir); | ||||
m = PHYS_TO_VM_PAGE(pa); | m = PHYS_TO_VM_PAGE(pa); | ||||
/* | /* | ||||
* Free pdir page if there are no dir entries in this pdir. | * Free pdir page if there are no dir entries in this pdir. | ||||
*/ | */ | ||||
m->wire_count--; | m->ref_count--; | ||||
if (m->wire_count == 0) { | if (m->ref_count == 0) { | ||||
pdir_free(mmu, pmap, pp2d_idx, m); | pdir_free(mmu, pmap, pp2d_idx, m); | ||||
return (1); | return (1); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Increment hold count for pdir pages. This routine is used when new ptlb | * Increment hold count for pdir pages. This routine is used when new ptlb | ||||
* entry is being inserted into pdir. | * entry is being inserted into pdir. | ||||
*/ | */ | ||||
static void | static void | ||||
pdir_hold(mmu_t mmu, pmap_t pmap, pte_t ** pdir) | pdir_hold(mmu_t mmu, pmap_t pmap, pte_t ** pdir) | ||||
{ | { | ||||
vm_page_t m; | vm_page_t m; | ||||
KASSERT((pmap != kernel_pmap), | KASSERT((pmap != kernel_pmap), | ||||
("pdir_hold: holding kernel pdir!")); | ("pdir_hold: holding kernel pdir!")); | ||||
KASSERT((pdir != NULL), ("pdir_hold: null pdir")); | KASSERT((pdir != NULL), ("pdir_hold: null pdir")); | ||||
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pdir)); | m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pdir)); | ||||
m->wire_count++; | m->ref_count++; | ||||
} | } | ||||
/* Allocate page table. */ | /* Allocate page table. */ | ||||
static pte_t * | static pte_t * | ||||
ptbl_alloc(mmu_t mmu, pmap_t pmap, pte_t ** pdir, unsigned int pdir_idx, | ptbl_alloc(mmu_t mmu, pmap_t pmap, pte_t ** pdir, unsigned int pdir_idx, | ||||
boolean_t nosleep) | boolean_t nosleep) | ||||
{ | { | ||||
vm_page_t m; | vm_page_t m; | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | ptbl_unhold(mmu_t mmu, pmap_t pmap, vm_offset_t va) | ||||
pdir = pmap->pm_pp2d[pp2d_idx]; | pdir = pmap->pm_pp2d[pp2d_idx]; | ||||
ptbl = pdir[pdir_idx]; | ptbl = pdir[pdir_idx]; | ||||
/* decrement hold count */ | /* decrement hold count */ | ||||
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t) ptbl)); | m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t) ptbl)); | ||||
/* | /* | ||||
* Free ptbl pages if there are no pte entries in this ptbl. | * Free ptbl pages if there are no pte entries in this ptbl. | ||||
* wire_count has the same value for all ptbl pages, so check the | * ref_count has the same value for all ptbl pages, so check the | ||||
* last page. | * last page. | ||||
*/ | */ | ||||
m->wire_count--; | m->ref_count--; | ||||
if (m->wire_count == 0) { | if (m->ref_count == 0) { | ||||
ptbl_free(mmu, pmap, pdir, pdir_idx, m); | ptbl_free(mmu, pmap, pdir, pdir_idx, m); | ||||
pdir_unhold(mmu, pmap, pp2d_idx); | pdir_unhold(mmu, pmap, pp2d_idx); | ||||
return (1); | return (1); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
Show All 9 Lines | ptbl_hold(mmu_t mmu, pmap_t pmap, pte_t ** pdir, unsigned int pdir_idx) | ||||
KASSERT((pmap != kernel_pmap), | KASSERT((pmap != kernel_pmap), | ||||
("ptbl_hold: holding kernel ptbl!")); | ("ptbl_hold: holding kernel ptbl!")); | ||||
ptbl = pdir[pdir_idx]; | ptbl = pdir[pdir_idx]; | ||||
KASSERT((ptbl != NULL), ("ptbl_hold: null ptbl")); | KASSERT((ptbl != NULL), ("ptbl_hold: null ptbl")); | ||||
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t) ptbl)); | m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t) ptbl)); | ||||
m->wire_count++; | m->ref_count++; | ||||
} | } | ||||
#else | #else | ||||
/* Initialize pool of kva ptbl buffers. */ | /* Initialize pool of kva ptbl buffers. */ | ||||
static void | static void | ||||
ptbl_init(void) | ptbl_init(void) | ||||
{ | { | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | ptbl_unhold(mmu_t mmu, pmap_t pmap, unsigned int pdir_idx) | ||||
KASSERT(((vm_offset_t)ptbl >= VM_MIN_KERNEL_ADDRESS), | KASSERT(((vm_offset_t)ptbl >= VM_MIN_KERNEL_ADDRESS), | ||||
("ptbl_unhold: non kva ptbl")); | ("ptbl_unhold: non kva ptbl")); | ||||
/* decrement hold count */ | /* decrement hold count */ | ||||
for (i = 0; i < PTBL_PAGES; i++) { | for (i = 0; i < PTBL_PAGES; i++) { | ||||
pa = pte_vatopa(mmu, kernel_pmap, | pa = pte_vatopa(mmu, kernel_pmap, | ||||
(vm_offset_t)ptbl + (i * PAGE_SIZE)); | (vm_offset_t)ptbl + (i * PAGE_SIZE)); | ||||
m = PHYS_TO_VM_PAGE(pa); | m = PHYS_TO_VM_PAGE(pa); | ||||
m->wire_count--; | m->ref_count--; | ||||
} | } | ||||
/* | /* | ||||
* Free ptbl pages if there are no pte etries in this ptbl. | * Free ptbl pages if there are no pte etries in this ptbl. | ||||
* wire_count has the same value for all ptbl pages, so check the last | * ref_count has the same value for all ptbl pages, so check the last | ||||
* page. | * page. | ||||
*/ | */ | ||||
if (m->wire_count == 0) { | if (m->ref_count == 0) { | ||||
ptbl_free(mmu, pmap, pdir_idx); | ptbl_free(mmu, pmap, pdir_idx); | ||||
//debugf("ptbl_unhold: e (freed ptbl)\n"); | //debugf("ptbl_unhold: e (freed ptbl)\n"); | ||||
return (1); | return (1); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 21 Lines | ptbl_hold(mmu_t mmu, pmap_t pmap, unsigned int pdir_idx) | ||||
ptbl = pmap->pm_pdir[pdir_idx]; | ptbl = pmap->pm_pdir[pdir_idx]; | ||||
KASSERT((ptbl != NULL), ("ptbl_hold: null ptbl")); | KASSERT((ptbl != NULL), ("ptbl_hold: null ptbl")); | ||||
for (i = 0; i < PTBL_PAGES; i++) { | for (i = 0; i < PTBL_PAGES; i++) { | ||||
pa = pte_vatopa(mmu, kernel_pmap, | pa = pte_vatopa(mmu, kernel_pmap, | ||||
(vm_offset_t)ptbl + (i * PAGE_SIZE)); | (vm_offset_t)ptbl + (i * PAGE_SIZE)); | ||||
m = PHYS_TO_VM_PAGE(pa); | m = PHYS_TO_VM_PAGE(pa); | ||||
m->wire_count++; | m->ref_count++; | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
/* Allocate pv_entry structure. */ | /* Allocate pv_entry structure. */ | ||||
pv_entry_t | pv_entry_t | ||||
pv_alloc(void) | pv_alloc(void) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 3,309 Lines • Show Last 20 Lines |