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 "vm_paddr_t 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.
85 if the request cannot be immediately fulfilled due to resource shortage.
88 Other flags (if present) are ignored.
92 function deallocates memory allocated by a previous call to
94 .Sh IMPLEMENTATION NOTES
97 function does not sleep waiting for memory resources to be freed up,
98 but instead actively reclaims pages before giving up.
101 is specified, it may select a page for reclamation that must first be
102 written to backing storage, causing it to sleep.
106 function returns a kernel virtual address if allocation succeeds,
113 p = contigmalloc(8192, M_DEVBUF, M_ZERO, 0, (1L << 22),
114 32 * 1024, 1024 * 1024);
117 Ask for 8192 bytes of zero-filled memory residing between physical
118 address 0 and 4194303 inclusive, aligned to a 32K boundary and not
119 crossing a 1M address boundary.
123 function will panic if
129 is not a power of two.