summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2011-10-27 02:52:24 +0000
committeralc <alc@FreeBSD.org>2011-10-27 02:52:24 +0000
commit0a7d6450d66712b7cb6e6e8396620f2e38a7d018 (patch)
tree597ccd87f28b111ce472332c7ff45a3e969036a6
parent9eaf5975ff4055ceac0fbe67d28e54d3d9c016c0 (diff)
downloadFreeBSD-src-0a7d6450d66712b7cb6e6e8396620f2e38a7d018.zip
FreeBSD-src-0a7d6450d66712b7cb6e6e8396620f2e38a7d018.tar.gz
contigmalloc(9) and contigfree(9) are now implemented in terms of other
more general VM system interfaces. So, their implementation can now reside in kern_malloc.c alongside the other functions that are declared in malloc.h.
-rw-r--r--sys/kern/kern_malloc.c37
-rw-r--r--sys/vm/vm_contig.c28
2 files changed, 37 insertions, 28 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 12baa3f..ecc45db 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -408,6 +408,43 @@ malloc_type_freed(struct malloc_type *mtp, unsigned long size)
}
/*
+ * contigmalloc:
+ *
+ * Allocate a block of physically contiguous memory.
+ *
+ * If M_NOWAIT is set, this routine will not block and return NULL if
+ * the allocation fails.
+ */
+void *
+contigmalloc(unsigned long size, struct malloc_type *type, int flags,
+ vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
+ unsigned long boundary)
+{
+ void *ret;
+
+ ret = (void *)kmem_alloc_contig(kernel_map, size, flags, low, high,
+ alignment, boundary, VM_MEMATTR_DEFAULT);
+ if (ret != NULL)
+ malloc_type_allocated(type, round_page(size));
+ return (ret);
+}
+
+/*
+ * contigfree:
+ *
+ * Free a block of memory allocated by contigmalloc.
+ *
+ * This routine may not block.
+ */
+void
+contigfree(void *addr, unsigned long size, struct malloc_type *type)
+{
+
+ kmem_free(kernel_map, (vm_offset_t)addr, size);
+ malloc_type_freed(type, round_page(size));
+}
+
+/*
* malloc:
*
* Allocate a block of memory.
diff --git a/sys/vm/vm_contig.c b/sys/vm/vm_contig.c
index 67ebdc3..dc87799 100644
--- a/sys/vm/vm_contig.c
+++ b/sys/vm/vm_contig.c
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
-#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@@ -334,25 +333,6 @@ contigmapping(vm_map_t map, vm_size_t size, vm_page_t m, vm_memattr_t memattr,
return (addr);
}
-void *
-contigmalloc(
- unsigned long size, /* should be size_t here and for malloc() */
- struct malloc_type *type,
- int flags,
- vm_paddr_t low,
- vm_paddr_t high,
- unsigned long alignment,
- unsigned long boundary)
-{
- void *ret;
-
- ret = (void *)kmem_alloc_contig(kernel_map, size, flags, low, high,
- alignment, boundary, VM_MEMATTR_DEFAULT);
- if (ret != NULL)
- malloc_type_allocated(type, round_page(size));
- return (ret);
-}
-
vm_offset_t
kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low,
vm_paddr_t high, unsigned long alignment, unsigned long boundary,
@@ -382,11 +362,3 @@ retry:
}
return (ret);
}
-
-void
-contigfree(void *addr, unsigned long size, struct malloc_type *type)
-{
-
- kmem_free(kernel_map, (vm_offset_t)addr, size);
- malloc_type_freed(type, round_page(size));
-}
OpenPOWER on IntegriCloud