aboutsummaryrefslogtreecommitdiff
path: root/sys/sun4v
diff options
context:
space:
mode:
authorKip Macy <kmacy@FreeBSD.org>2006-11-22 03:35:37 +0000
committerKip Macy <kmacy@FreeBSD.org>2006-11-22 03:35:37 +0000
commit793555da5edde55bebf3e6d30c655c4c69d36011 (patch)
treef7519bf8ea9388180725375214e6fee1a2adf743 /sys/sun4v
parent367e547feec1b6806a65bb53dbc7e1d20ac35ce6 (diff)
downloadsrc-793555da5edde55bebf3e6d30c655c4c69d36011.tar.gz
src-793555da5edde55bebf3e6d30c655c4c69d36011.zip
move contiguous allocation and free routines from tte_hash.c into pmap.c
Notes
Notes: svn path=/head/; revision=164494
Diffstat (limited to 'sys/sun4v')
-rw-r--r--sys/sun4v/include/pmap.h2
-rw-r--r--sys/sun4v/sun4v/pmap.c40
-rw-r--r--sys/sun4v/sun4v/tte_hash.c42
3 files changed, 43 insertions, 41 deletions
diff --git a/sys/sun4v/include/pmap.h b/sys/sun4v/include/pmap.h
index b08629ad1d85..f69166d5a809 100644
--- a/sys/sun4v/include/pmap.h
+++ b/sys/sun4v/include/pmap.h
@@ -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))
diff --git a/sys/sun4v/sun4v/pmap.c b/sys/sun4v/sun4v/pmap.c
index 58ba48f44f25..8865d31b079c 100644
--- a/sys/sun4v/sun4v/pmap.c
+++ b/sys/sun4v/sun4v/pmap.c
@@ -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)
{
diff --git a/sys/sun4v/sun4v/tte_hash.c b/sys/sun4v/sun4v/tte_hash.c
index 2f7a73a2af41..b2e86218222d 100644
--- a/sys/sun4v/sun4v/tte_hash.c
+++ b/sys/sun4v/sun4v/tte_hash.c
@@ -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"));