michael@0: /*- michael@0: * Copyright (c) 2009-2010 Brad Penoff michael@0: * Copyright (c) 2009-2010 Humaira Kamal michael@0: * Copyright (c) 2011-2012 Irene Ruengeler michael@0: * Copyright (c) 2011-2012 Michael Tuexen michael@0: * michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * 1. Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * 2. Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND michael@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE michael@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE michael@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE michael@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL michael@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS michael@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) michael@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT michael@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY michael@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@0: * SUCH DAMAGE. michael@0: */ michael@0: michael@0: #ifndef _USER_UMA_H_ michael@0: #define _USER_UMA_H_ michael@0: michael@0: #define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */ michael@0: #define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */ michael@0: michael@0: /* __Userspace__ All these definitions will change for michael@0: userspace Universal Memory Allocator (UMA). These are included michael@0: for reference purposes and to avoid compile errors for the time being. michael@0: */ michael@0: typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags); michael@0: typedef void (*uma_dtor)(void *mem, int size, void *arg); michael@0: typedef int (*uma_init)(void *mem, int size, int flags); michael@0: typedef void (*uma_fini)(void *mem, int size); michael@0: typedef struct uma_zone * uma_zone_t; michael@0: typedef struct uma_keg * uma_keg_t; michael@0: michael@0: struct uma_cache { michael@0: int stub; /* TODO __Userspace__ */ michael@0: }; michael@0: michael@0: struct uma_keg { michael@0: int stub; /* TODO __Userspace__ */ michael@0: }; michael@0: michael@0: struct uma_zone { michael@0: char *uz_name; /* Text name of the zone */ michael@0: struct mtx *uz_lock; /* Lock for the zone (keg's lock) */ michael@0: uma_keg_t uz_keg; /* Our underlying Keg */ michael@0: michael@0: LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */ michael@0: LIST_HEAD(,uma_bucket) uz_full_bucket; /* full buckets */ michael@0: LIST_HEAD(,uma_bucket) uz_free_bucket; /* Buckets for frees */ michael@0: michael@0: uma_ctor uz_ctor; /* Constructor for each allocation */ michael@0: uma_dtor uz_dtor; /* Destructor */ michael@0: uma_init uz_init; /* Initializer for each item */ michael@0: uma_fini uz_fini; /* Discards memory */ michael@0: michael@0: u_int64_t uz_allocs; /* Total number of allocations */ michael@0: u_int64_t uz_frees; /* Total number of frees */ michael@0: u_int64_t uz_fails; /* Total number of alloc failures */ michael@0: uint16_t uz_fills; /* Outstanding bucket fills */ michael@0: uint16_t uz_count; /* Highest value ub_ptr can have */ michael@0: michael@0: /* michael@0: * This HAS to be the last item because we adjust the zone size michael@0: * based on NCPU and then allocate the space for the zones. michael@0: */ michael@0: struct uma_cache uz_cpu[1]; /* Per cpu caches */ michael@0: }; michael@0: michael@0: /* Prototype */ michael@0: uma_zone_t michael@0: uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, michael@0: uma_init uminit, uma_fini fini, int align, u_int32_t flags); michael@0: michael@0: michael@0: #define uma_zone_set_max(zone, number) /* stub TODO __Userspace__ */ michael@0: michael@0: uma_zone_t michael@0: uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, michael@0: uma_init uminit, uma_fini fini, int align, u_int32_t flags) michael@0: { michael@0: return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */ michael@0: michael@0: } michael@0: #endif