vmem.h

Go to the documentation of this file.
00001 /*
00002  * CDDL HEADER START
00003  *
00004  * The contents of this file are subject to the terms of the
00005  * Common Development and Distribution License, Version 1.0 only
00006  * (the "License").  You may not use this file except in compliance
00007  * with the License.
00008  *
00009  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
00010  * or http://www.opensolaris.org/os/licensing.
00011  * See the License for the specific language governing permissions
00012  * and limitations under the License.
00013  *
00014  * When distributing Covered Code, include this CDDL HEADER in each
00015  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
00016  * If applicable, add the following below this CDDL HEADER, with the
00017  * fields enclosed by brackets "[]" replaced with your own identifying
00018  * information: Portions Copyright [yyyy] [name of copyright owner]
00019  *
00020  * CDDL HEADER END
00021  */
00022 /*
00023  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
00024  * Use is subject to license terms.
00025  */
00026 
00027 #ifndef _SYS_VMEM_H
00028 #define _SYS_VMEM_H
00029 
00030 /* #pragma ident        "@(#)vmem.h     1.13    05/06/08 SMI" */
00031 
00032 #include <sys/types.h>
00033 
00034 #ifdef  __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 
00039 /*
00040  * Per-allocation flags
00041  */
00042 #define VM_SLEEP        0x00000000      /* same as KM_SLEEP */
00043 #define VM_NOSLEEP      0x00000001      /* same as KM_NOSLEEP */
00044 #define VM_PANIC        0x00000002      /* same as KM_PANIC */
00045 #define VM_PUSHPAGE     0x00000004      /* same as KM_PUSHPAGE */
00046 #define VM_KMFLAGS      0x000000ff      /* flags that must match KM_* flags */
00047 
00048 #define VM_BESTFIT      0x00000100
00049 #define VM_FIRSTFIT     0x00000200
00050 #define VM_NEXTFIT      0x00000400
00051 
00052 /*
00053  * The following flags are restricted for use only within the kernel.
00054  * VM_MEMLOAD is for use by the HAT to avoid infinite recursion.
00055  * VM_NORELOC is used by the kernel when static VA->PA mappings are required.
00056  */
00057 #define VM_MEMLOAD      0x00000800
00058 #define VM_NORELOC      0x00001000
00059 /*
00060  * VM_ABORT requests that vmem_alloc() *ignore* the VM_SLEEP/VM_NOSLEEP flags
00061  * and forgo reaping if the allocation or attempted import, fails.  This
00062  * flag is a segkmem-specific flag, and should not be used by anyone else.
00063  */
00064 #define VM_ABORT        0x00002000
00065 
00066 #define VM_FLAGS        0x0000FFFF
00067 
00068 /*
00069  * Arena creation flags
00070  */
00071 #define VMC_POPULATOR   0x00010000
00072 #define VMC_NO_QCACHE   0x00020000      /* cannot use quantum caches */
00073 #define VMC_IDENTIFIER  0x00040000      /* not backed by memory */
00074 /*
00075  * internal use only;   the import function uses the vmem_ximport_t interface
00076  *                      and may increase the request size if it so desires
00077  */
00078 #define VMC_XALLOC      0x00080000
00079 #define VMC_FLAGS       0xFFFF0000
00080 
00081 /*
00082  * Public segment types
00083  */
00084 #define VMEM_ALLOC      0x01
00085 #define VMEM_FREE       0x02
00086 
00087 /*
00088  * Implementation-private segment types
00089  */
00090 #define VMEM_SPAN       0x10
00091 #define VMEM_ROTOR      0x20
00092 #define VMEM_WALKER     0x40
00093 
00094 /*
00095  * VMEM_REENTRANT indicates to vmem_walk() that the callback routine may
00096  * call back into the arena being walked, so vmem_walk() must drop the
00097  * arena lock before each callback.  The caveat is that since the arena
00098  * isn't locked, its state can change.  Therefore it is up to the callback
00099  * routine to handle cases where the segment isn't of the expected type.
00100  * For example, we use this to walk heap_arena when generating a crash dump;
00101  * see segkmem_dump() for sample usage.
00102  */
00103 #define VMEM_REENTRANT  0x80000000
00104 
00105 typedef struct vmem vmem_t;
00106 typedef void *(vmem_alloc_t)(vmem_t *, size_t, int);
00107 typedef void (vmem_free_t)(vmem_t *, void *, size_t);
00108 
00109 /*
00110  * Alternate import style; the requested size is passed in a pointer,
00111  * which can be increased by the import function if desired.
00112  */
00113 typedef void *(vmem_ximport_t)(vmem_t *, size_t *, int);
00114 
00115 #ifdef _KERNEL
00116 extern vmem_t *vmem_init(const char *, void *, size_t, size_t,
00117     vmem_alloc_t *, vmem_free_t *);
00118 extern void vmem_update(void *);
00119 extern int vmem_is_populator();
00120 extern size_t vmem_seg_size;
00121 #endif
00122 
00123 extern vmem_t *vmem_create(const char *, void *, size_t, size_t,
00124     vmem_alloc_t *, vmem_free_t *, vmem_t *, size_t, int);
00125 extern vmem_t *vmem_xcreate(const char *, void *, size_t, size_t,
00126     vmem_ximport_t *, vmem_free_t *, vmem_t *, size_t, int);
00127 extern void vmem_destroy(vmem_t *);
00128 extern void *vmem_alloc(vmem_t *, size_t, int);
00129 extern void *vmem_xalloc(vmem_t *, size_t, size_t, size_t, size_t,
00130     void *, void *, int);
00131 extern void vmem_free(vmem_t *, void *, size_t);
00132 extern void vmem_xfree(vmem_t *, void *, size_t);
00133 extern void *vmem_add(vmem_t *, void *, size_t, int);
00134 extern int vmem_contains(vmem_t *, void *, size_t);
00135 extern void vmem_walk(vmem_t *, int, void (*)(void *, void *, size_t), void *);
00136 extern size_t vmem_size(vmem_t *, int);
00137 
00138 #ifdef  __cplusplus
00139 }
00140 #endif
00141 
00142 #endif  /* _SYS_VMEM_H */

Generated on Wed Sep 9 01:07:04 2009 for umem by  doxygen 1.5.9