diff options
author | jkoshy <jkoshy@FreeBSD.org> | 2004-03-06 02:09:17 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 2004-03-06 02:09:17 +0000 |
commit | c01775c228f622280d81573279caf9785f332745 (patch) | |
tree | ff6b05009bf13604b2d54e6fd501e81869dade44 /share/man/man9/contigmalloc.9 | |
parent | b2042c11e8977dfea96070cc15c5e47b57bd1756 (diff) | |
download | FreeBSD-src-c01775c228f622280d81573279caf9785f332745.zip FreeBSD-src-c01775c228f622280d81573279caf9785f332745.tar.gz |
A manual page for contigmalloc(9).
Reviewed by: ru
Diffstat (limited to 'share/man/man9/contigmalloc.9')
-rw-r--r-- | share/man/man9/contigmalloc.9 | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/share/man/man9/contigmalloc.9 b/share/man/man9/contigmalloc.9 new file mode 100644 index 0000000..2b2d6f7 --- /dev/null +++ b/share/man/man9/contigmalloc.9 @@ -0,0 +1,130 @@ +.\" +.\" Copyright (c) 2004 Joseph Koshy +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOSEPH KOSHY AND CONTRIBUTORS ``AS IS'' +.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE +.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd March 4, 2004 +.Dt CONTIGMALLOC 9 +.Os +.Sh NAME +.Nm contigmalloc , contigfree +.Nd manage contiguous kernel physical memory +.Sh SYNOPSIS +.In sys/types.h +.In sys/malloc.h +.Ft "void *" +.Fo contigmalloc +.Fa "unsigned long size" +.Fa "struct malloc_type *type" +.Fa "int flags" +.Fa "vm_paddr_t low" +.Fa "vm_paddr_t high" +.Fa "unsigned long alignment" +.Fa "unsigned long boundary" +.Fc +.Ft void +.Fo contigfree +.Fa "void *addr" +.Fa "unsigned long size" +.Fa "struct malloc_type *type" +.Fc +.Sh DESCRIPTION +The +.Fn contigmalloc +function allocates +.Fa size +bytes of contiguous physical memory that is aligned to +.Fa alignment +bytes, and which does not cross a boundary of +.Fa boundary +bytes. +If successful, the allocation will reside between physical addresses +.Fa low +and +.Fa high . +The returned pointer points to a wired kernel virtual +address range of +.Fa size +bytes allocated from the kernel virtual address (KVA) map. +.Pp +The +.Fa flags +parameter modifies +.Fn contigmalloc Ns 's +behaviour as follows: +.Bl -tag -width indent +.It Dv M_ZERO +Causes the allocated physical memory to be zero filled. +.El +Other flags (if present) are ignored. +.Pp +The +.Fn contigfree +function deallocates memory allocated by a previous call to +.Fn contigmalloc . +.Sh IMPLEMENTATION NOTES +The +.Fn contigmalloc +function does not sleep waiting for memory resources to be freed up, +but instead scans available physical memory a small number of times +for a suitably sized free address range before giving up. +Memory allocation is done on a first-fit basis. +.Sh RETURN VALUES +The +.Fn contigmalloc +function returns a kernel virtual address if allocation succeeds, +or +.Dv NULL +otherwise. +.Sh EXAMPLES +.Bd -literal +void *p; +p = contigmalloc(8192, M_DEVBUF, M_ZERO, 0, (1L << 22), + 32 * 1024, 1024 * 1024); +.Ed +.Pp +Ask for 8192 bytes of zero-filled memory residing between physical +address 0 and 4194303 inclusive, aligned to a 32K boundary and not +crossing a 1M address boundary. +.Sh SEE ALSO +.Xr malloc 9 +.Sh DIAGNOSTICS +The +.Fn contigmalloc +function will panic if +.Fa size +is zero, or if +.Fa alignment +or +.Fa boundary +is not a power of two. +.Sh BUGS +The +.Fa type +argument to +.Fn contigmalloc +and +.Fn contigfree +is ignored. |