move contiguous allocation and free routines from tte_hash.c into pmap.c
This commit is contained in:
parent
367e547fee
commit
793555da5e
@ -109,6 +109,8 @@ void pmap_invalidate_page(pmap_t pmap, vm_offset_t va, int cleartsb);
|
||||
void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, int cleartsb);
|
||||
void pmap_invalidate_all(pmap_t pmap);
|
||||
void pmap_scrub_pages(vm_paddr_t pa, int64_t size);
|
||||
void pmap_free_contig_pages(void *ptr, int npages);
|
||||
void *pmap_alloc_zeroed_contig_pages(int npages, uint64_t alignment);
|
||||
|
||||
#define vtophys(va) pmap_kextract((vm_offset_t)(va))
|
||||
|
||||
|
@ -1189,6 +1189,46 @@ pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
|
||||
return (m);
|
||||
}
|
||||
|
||||
void *
|
||||
pmap_alloc_zeroed_contig_pages(int npages, uint64_t alignment)
|
||||
{
|
||||
vm_page_t m, tm;
|
||||
int i;
|
||||
void *ptr;
|
||||
|
||||
m = NULL;
|
||||
while (m == NULL) {
|
||||
m = vm_page_alloc_contig(npages, phys_avail[0],
|
||||
phys_avail[1], alignment, (1UL<<34));
|
||||
if (m == NULL) {
|
||||
printf("vm_page_alloc_contig failed - waiting to retry\n");
|
||||
VM_WAIT;
|
||||
}
|
||||
}
|
||||
for (i = 0, tm = m; i < npages; i++, tm++) {
|
||||
tm->wire_count++;
|
||||
if ((tm->flags & PG_ZERO) == 0)
|
||||
pmap_zero_page(tm);
|
||||
}
|
||||
ptr = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m));
|
||||
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
void
|
||||
pmap_free_contig_pages(void *ptr, int npages)
|
||||
{
|
||||
int i;
|
||||
vm_page_t m;
|
||||
|
||||
m = PHYS_TO_VM_PAGE(TLB_DIRECT_TO_PHYS((vm_offset_t)ptr));
|
||||
for (i = 0; i < npages; i++, m++) {
|
||||
m->wire_count--;
|
||||
atomic_subtract_int(&cnt.v_wire_count, 1);
|
||||
vm_page_free(m);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pmap_growkernel(vm_offset_t addr)
|
||||
{
|
||||
|
@ -222,46 +222,6 @@ alloc_zeroed_page(void)
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
alloc_zeroed_contig_pages(int npages)
|
||||
{
|
||||
vm_page_t m, tm;
|
||||
int i;
|
||||
void *ptr;
|
||||
|
||||
m = NULL;
|
||||
while (m == NULL) {
|
||||
m = vm_page_alloc_contig(npages, phys_avail[0],
|
||||
phys_avail[1], PAGE_SIZE, (1UL<<34));
|
||||
if (m == NULL) {
|
||||
printf("vm_page_alloc_contig failed - waiting to retry\n");
|
||||
VM_WAIT;
|
||||
}
|
||||
}
|
||||
for (i = 0, tm = m; i < npages; i++, tm++) {
|
||||
tm->wire_count++;
|
||||
if ((tm->flags & PG_ZERO) == 0)
|
||||
pmap_zero_page(tm);
|
||||
}
|
||||
ptr = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m));
|
||||
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
static inline void
|
||||
free_contig_pages(void *ptr, int npages)
|
||||
{
|
||||
int i;
|
||||
vm_page_t m;
|
||||
|
||||
m = PHYS_TO_VM_PAGE(TLB_DIRECT_TO_PHYS((vm_offset_t)ptr));
|
||||
for (i = 0; i < npages; i++, m++) {
|
||||
m->wire_count--;
|
||||
atomic_subtract_int(&cnt.v_wire_count, 1);
|
||||
vm_page_free(m);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
free_fragment_pages(void *ptr)
|
||||
{
|
||||
@ -286,7 +246,7 @@ _tte_hash_create(uint64_t context, uint64_t *scratchval, uint16_t shift)
|
||||
th->th_entries = 0;
|
||||
th->th_context = (uint16_t)context;
|
||||
|
||||
th->th_hashtable = alloc_zeroed_contig_pages((1 << shift));
|
||||
th->th_hashtable = pmap_alloc_zeroed_contig_pages((1 << shift), PAGE_SIZE);
|
||||
|
||||
th->th_fhtail = th->th_fhhead = alloc_zeroed_page();
|
||||
KASSERT(th->th_fhtail != NULL, ("th->th_fhtail == NULL"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user