2 .\" Copyright (c) 2004 Joseph Koshy
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
15 .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
18 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 .\" POSSIBILITY OF SUCH DAMAGE.
32 .Nm contigmalloc , contigfree
33 .Nd manage contiguous kernel physical memory
39 .Fa "unsigned long size"
40 .Fa "struct malloc_type *type"
44 .Fa "unsigned long alignment"
45 .Fa "unsigned long boundary"
50 .Fa "unsigned long size"
51 .Fa "struct malloc_type *type"
58 bytes of contiguous physical memory that is aligned to
60 bytes, and which does not cross a boundary of
63 If successful, the allocation will reside between physical addresses
67 The returned pointer points to a wired kernel virtual
70 bytes allocated from the kernel virtual address (KVA) map.
75 .Fn contigmalloc Ns 's
77 .Bl -tag -width indent
79 Causes the allocated physical memory to be zero filled.
81 Other flags (if present) are ignored.
85 function deallocates memory allocated by a previous call to
87 .Sh IMPLEMENTATION NOTES
90 function does not sleep waiting for memory resources to be freed up,
91 but instead scans available physical memory a small number of times
92 for a suitably sized free address range before giving up.
93 Memory allocation is done on a first-fit basis, starting from the
94 top of the provided address range.
98 function returns a kernel virtual address if allocation succeeds,
105 p = contigmalloc(8192, M_DEVBUF, M_ZERO, 0, (1L << 22),
106 32 * 1024, 1024 * 1024);
109 Ask for 8192 bytes of zero-filled memory residing between physical
110 address 0 and 4194303 inclusive, aligned to a 32K boundary and not
111 crossing a 1M address boundary.
115 function will panic if
121 is not a power of two.