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"
56 .Fo contigmalloc_domainset
57 .Fa "unsigned long size"
58 .Fa "struct malloc_type *type"
59 .Fa "struct domainset *ds"
63 .Fa "unsigned long alignment"
64 .Fa "vm_paddr_t boundary"
71 bytes of contiguous physical memory that is aligned to
73 bytes, and which does not cross a boundary of
76 If successful, the allocation will reside between physical addresses
80 The returned pointer points to a wired kernel virtual
83 bytes allocated from the kernel virtual address (KVA) map.
86 .Fn contigmalloc_domainset
87 variant allows the caller to additionally specify a
89 domain selection policy.
92 for some example policies.
97 .Fn contigmalloc Ns 's
99 .Bl -tag -width indent
101 Causes the allocated physical memory to be zero filled.
107 if the request cannot be immediately fulfilled due to resource shortage.
110 Other flags (if present) are ignored.
114 function deallocates memory allocated by a previous call to
117 .Fn contigmalloc_domainset .
118 .Sh IMPLEMENTATION NOTES
121 function does not sleep waiting for memory resources to be freed up,
122 but instead actively reclaims pages before giving up.
125 is specified, it may select a page for reclamation that must first be
126 written to backing storage, causing it to sleep.
130 function does not accept
132 as an address input, unlike
137 function returns a kernel virtual address if allocation succeeds,
144 p = contigmalloc(8192, M_DEVBUF, M_ZERO, 0, (1L << 22),
145 32 * 1024, 1024 * 1024);
148 Ask for 8192 bytes of zero-filled memory residing between physical
149 address 0 and 4194303 inclusive, aligned to a 32K boundary and not
150 crossing a 1M address boundary.
154 function will panic if
160 is not a power of two.