uts: make emu10k non-verbose
[unleashed.git] / include / sys / vmem.h
blob9d72797a52d68d67f8c3eb19c2ee667e46507ca6
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
26 #ifndef _SYS_VMEM_H
27 #define _SYS_VMEM_H
29 #include <sys/types.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
37 * Per-allocation flags
39 #define VM_SLEEP 0x00000000 /* same as KM_SLEEP */
40 #define VM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */
41 #define VM_PANIC 0x00000002 /* same as KM_PANIC */
42 #define VM_PUSHPAGE 0x00000004 /* same as KM_PUSHPAGE */
43 #define VM_NORMALPRI 0x00000008 /* same as KM_NORMALPRI */
44 #define VM_KMFLAGS 0x000000ff /* flags that must match KM_* flags */
46 #define VM_BESTFIT 0x00000100
47 #define VM_FIRSTFIT 0x00000200
48 #define VM_NEXTFIT 0x00000400
51 * The following flags are restricted for use only within the kernel.
52 * VM_MEMLOAD is for use by the HAT to avoid infinite recursion.
53 * VM_NORELOC is used by the kernel when static VA->PA mappings are required.
55 #define VM_MEMLOAD 0x00000800
56 #define VM_NORELOC 0x00001000
58 * VM_ABORT requests that vmem_alloc() *ignore* the VM_SLEEP/VM_NOSLEEP flags
59 * and forgo reaping if the allocation or attempted import, fails. This
60 * flag is a segkmem-specific flag, and should not be used by anyone else.
62 #define VM_ABORT 0x00002000
65 * VM_ENDALLOC requests that large addresses be preferred in allocations.
66 * Has no effect if VM_NEXTFIT is active.
68 #define VM_ENDALLOC 0x00004000
70 #define VM_FLAGS 0x0000FFFF
73 * Arena creation flags
75 #define VMC_POPULATOR 0x00010000
76 #define VMC_NO_QCACHE 0x00020000 /* cannot use quantum caches */
77 #define VMC_IDENTIFIER 0x00040000 /* not backed by memory */
78 #define VMC_DUMPSAFE 0x00200000 /* can use alternate dump memory */
80 * internal use only; the import function uses the vmem_ximport_t interface
81 * and may increase the request size if it so desires.
82 * VMC_XALIGN, for use with vmem_xcreate, specifies that
83 * the address returned by the import function will be
84 * aligned according to the alignment argument.
86 #define VMC_XALLOC 0x00080000
87 #define VMC_XALIGN 0x00100000
88 #define VMC_FLAGS 0xFFFF0000
91 * Public segment types
93 #define VMEM_ALLOC 0x01
94 #define VMEM_FREE 0x02
97 * Implementation-private segment types
99 #define VMEM_SPAN 0x10
100 #define VMEM_ROTOR 0x20
101 #define VMEM_WALKER 0x40
104 * VMEM_REENTRANT indicates to vmem_walk() that the callback routine may
105 * call back into the arena being walked, so vmem_walk() must drop the
106 * arena lock before each callback. The caveat is that since the arena
107 * isn't locked, its state can change. Therefore it is up to the callback
108 * routine to handle cases where the segment isn't of the expected type.
109 * For example, we use this to walk heap_arena when generating a crash dump;
110 * see segkmem_dump() for sample usage.
112 #define VMEM_REENTRANT 0x80000000
114 typedef struct vmem vmem_t;
115 typedef void *(vmem_alloc_t)(vmem_t *, size_t, int);
116 typedef void (vmem_free_t)(vmem_t *, void *, size_t);
119 * Alternate import style; the requested size is passed in a pointer,
120 * which can be increased by the import function if desired.
122 typedef void *(vmem_ximport_t)(vmem_t *, size_t *, size_t, int);
124 #ifdef _KERNEL
125 extern vmem_t *vmem_init(const char *, void *, size_t, size_t,
126 vmem_alloc_t *, vmem_free_t *);
127 extern void vmem_update(void *);
128 extern int vmem_is_populator();
129 extern size_t vmem_seg_size;
130 #endif
132 extern vmem_t *vmem_create(const char *, void *, size_t, size_t,
133 vmem_alloc_t *, vmem_free_t *, vmem_t *, size_t, int);
134 extern vmem_t *vmem_xcreate(const char *, void *, size_t, size_t,
135 vmem_ximport_t *, vmem_free_t *, vmem_t *, size_t, int);
136 extern void vmem_destroy(vmem_t *);
137 extern void *vmem_alloc(vmem_t *, size_t, int);
138 extern void *vmem_xalloc(vmem_t *, size_t, size_t, size_t, size_t,
139 void *, void *, int);
140 extern void vmem_free(vmem_t *, void *, size_t);
141 extern void vmem_xfree(vmem_t *, void *, size_t);
142 extern void *vmem_add(vmem_t *, void *, size_t, int);
143 extern int vmem_contains(vmem_t *, void *, size_t);
144 extern void vmem_walk(vmem_t *, int, void (*)(void *, void *, size_t), void *);
145 extern size_t vmem_size(vmem_t *, int);
146 extern void vmem_qcache_reap(vmem_t *vmp);
148 #ifdef __cplusplus
150 #endif
152 #endif /* _SYS_VMEM_H */