2007-04-26 07:41:24 +04:00
|
|
|
/*
|
2008-01-16 23:30:16 +03:00
|
|
|
* Copyright 2008, Axel Dörfler. All Rights Reserved.
|
2007-04-26 07:41:24 +04:00
|
|
|
* Copyright 2007, Hugo Santos. All Rights Reserved.
|
|
|
|
*
|
2008-01-16 23:30:16 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
2007-04-26 07:41:24 +04:00
|
|
|
*/
|
|
|
|
#ifndef _SLAB_SLAB_H_
|
|
|
|
#define _SLAB_SLAB_H_
|
|
|
|
|
2007-10-22 00:44:19 +04:00
|
|
|
|
|
|
|
#include <KernelExport.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
/* create_object_cache_etc flags */
|
|
|
|
CACHE_NO_DEPOT = 1 << 0,
|
|
|
|
CACHE_UNLOCKED_PAGES = 1 << 1,
|
2008-01-16 23:30:16 +03:00
|
|
|
CACHE_LARGE_SLAB = 1 << 2,
|
2007-10-22 00:44:19 +04:00
|
|
|
|
|
|
|
/* object_cache_alloc flags */
|
|
|
|
CACHE_DONT_SLEEP = 1 << 8,
|
|
|
|
|
|
|
|
/* internal */
|
2010-01-19 13:17:16 +03:00
|
|
|
CACHE_ALIGN_ON_SIZE = 1 << 30,
|
2007-10-22 00:44:19 +04:00
|
|
|
CACHE_DURING_BOOT = 1 << 31
|
|
|
|
};
|
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
struct ObjectCache;
|
|
|
|
typedef struct ObjectCache object_cache;
|
2007-10-22 00:44:19 +04:00
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
typedef status_t (*object_cache_constructor)(void* cookie, void* object);
|
|
|
|
typedef void (*object_cache_destructor)(void* cookie, void* object);
|
|
|
|
typedef void (*object_cache_reclaimer)(void* cookie, int32 level);
|
2007-10-22 00:44:19 +04:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
object_cache* create_object_cache(const char* name, size_t object_size,
|
|
|
|
size_t alignment, void* cookie, object_cache_constructor constructor,
|
2007-10-22 00:44:19 +04:00
|
|
|
object_cache_destructor);
|
2010-01-19 22:13:25 +03:00
|
|
|
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,
|
2007-10-22 00:44:19 +04:00
|
|
|
object_cache_constructor constructor, object_cache_destructor destructor,
|
|
|
|
object_cache_reclaimer reclaimer);
|
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
void delete_object_cache(object_cache* cache);
|
2007-10-22 00:44:19 +04:00
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
status_t object_cache_set_minimum_reserve(object_cache* cache,
|
2008-08-21 07:21:37 +04:00
|
|
|
size_t objectCount);
|
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
void* object_cache_alloc(object_cache* cache, uint32 flags);
|
|
|
|
void object_cache_free(object_cache* cache, void* object);
|
2007-10-22 00:44:19 +04:00
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
status_t object_cache_reserve(object_cache* cache, size_t object_count,
|
2007-10-22 00:44:19 +04:00
|
|
|
uint32 flags);
|
|
|
|
|
2010-01-19 22:13:25 +03:00
|
|
|
void object_cache_get_usage(object_cache* cache, size_t* _allocatedMemory);
|
2008-08-06 04:07:55 +04:00
|
|
|
|
2007-10-22 00:44:19 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2007-04-26 07:41:24 +04:00
|
|
|
#endif
|
2007-10-22 00:44:19 +04:00
|
|
|
|
|
|
|
#endif /* _SLAB_SLAB_H_ */
|