summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
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 /sys/kern/kern_malloc.c
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.
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c37
1 files changed, 37 insertions, 0 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.
OpenPOWER on IntegriCloud