2007-04-26 03:41:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2007, Hugo Santos. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Hugo Santos, hugosantos@gmail.com
|
|
|
|
*/
|
|
|
|
#ifndef _SLAB_BASE_SLAB_H_
|
|
|
|
#define _SLAB_BASE_SLAB_H_
|
|
|
|
|
2007-04-26 07:31:19 +00:00
|
|
|
#include <KernelExport.h>
|
2007-04-26 03:41:24 +00:00
|
|
|
#include <OS.h>
|
2007-04-26 07:31:19 +00:00
|
|
|
|
2007-04-26 03:41:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-04-26 06:32:25 +00:00
|
|
|
enum {
|
2007-04-29 02:23:37 +00:00
|
|
|
/* create_object_cache_etc flags */
|
2007-04-28 18:53:58 +00:00
|
|
|
CACHE_NO_DEPOT = 1 << 0,
|
2007-04-29 20:55:44 +00:00
|
|
|
CACHE_UNLOCKED_PAGES = 1 << 1,
|
2007-04-26 06:32:25 +00:00
|
|
|
|
2007-04-29 02:23:37 +00:00
|
|
|
/* object_cache_alloc flags */
|
|
|
|
CACHE_DONT_SLEEP = 1 << 8,
|
|
|
|
|
|
|
|
/* internal */
|
|
|
|
CACHE_DURING_BOOT = 1 << 31
|
2007-04-28 18:53:58 +00:00
|
|
|
};
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2007-04-28 18:53:58 +00:00
|
|
|
typedef struct object_cache object_cache;
|
2007-04-26 07:31:19 +00:00
|
|
|
|
2007-04-28 18:53:58 +00:00
|
|
|
typedef status_t (*object_cache_constructor)(void *cookie, void *object);
|
|
|
|
typedef void (*object_cache_destructor)(void *cookie, void *object);
|
2007-04-28 21:35:23 +00:00
|
|
|
typedef void (*object_cache_reclaimer)(void *cookie, int32 level);
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2007-04-28 18:53:58 +00:00
|
|
|
object_cache *create_object_cache(const char *name, size_t object_size,
|
|
|
|
size_t alignment, void *cookie, object_cache_constructor constructor,
|
|
|
|
object_cache_destructor);
|
|
|
|
object_cache *create_object_cache_etc(const char *name, size_t object_size,
|
|
|
|
size_t alignment, size_t max_byte_usage, uint32 flags, void *cookie,
|
|
|
|
object_cache_constructor constructor, object_cache_destructor destructor,
|
|
|
|
object_cache_reclaimer reclaimer);
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2007-04-28 18:53:58 +00:00
|
|
|
void delete_object_cache(object_cache *cache);
|
2007-04-26 11:38:24 +00:00
|
|
|
|
2007-04-28 18:53:58 +00:00
|
|
|
void *object_cache_alloc(object_cache *cache, uint32 flags);
|
|
|
|
void object_cache_free(object_cache *cache, void *object);
|
2007-04-26 03:41:24 +00:00
|
|
|
|
2007-04-29 21:45:23 +00:00
|
|
|
status_t object_cache_reserve(object_cache *cache, size_t object_count,
|
|
|
|
uint32 flags);
|
|
|
|
|
2007-04-26 03:41:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2007-04-28 18:53:58 +00:00
|
|
|
#endif
|
2007-04-26 03:41:24 +00:00
|
|
|
|
|
|
|
#endif
|