Fix slab allocator
This commit is contained in:
parent
3b08a6ce99
commit
0db98c358e
8 changed files with 185 additions and 314 deletions
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
void _kmalloc_init(void);
|
||||
|
||||
void *kmalloc(size_t size);
|
||||
void *kzalloc(size_t size);
|
||||
void *kmalloc(size_t size) __attribute__ ((alloc_size (1)));
|
||||
void *kzalloc(size_t size) __attribute__ ((alloc_size (1)));
|
||||
kstatus kfree(void *addr);
|
||||
|
|
|
|||
|
|
@ -43,11 +43,16 @@ struct ma_cache {
|
|||
uint16_t flags; // Not useful yet
|
||||
uint32_t num; // Number of objects per slab
|
||||
uint32_t slabsize; // How many pages does a single slab take up. Useful for objects > PAGE_SIZE
|
||||
|
||||
uint16_t color; // Max color of the slab
|
||||
uint16_t color_next; // Next color to use
|
||||
uint16_t alignment; // Alignment required of the objects. Default is 8 bytes if 0 is passed
|
||||
struct ma_slab *slabs_free;
|
||||
struct ma_slab *slabs_partial;
|
||||
struct ma_slab *slabs_used;
|
||||
|
||||
void (*constructor)(void *, size_t);
|
||||
void (*destructor)(void *, size_t);
|
||||
|
||||
atomic_flag lock;
|
||||
|
||||
char name[KCACHE_NAME_LEN];
|
||||
|
|
@ -55,6 +60,6 @@ struct ma_cache {
|
|||
|
||||
void *ma_cache_alloc(struct ma_cache *kcache, uint32_t flags);
|
||||
kstatus ma_cache_dealloc(void *object);
|
||||
struct ma_cache *ma_cache_create(char *name, size_t size, uint32_t flags, void (*constructor)(void *, size_t), void (*destructor)(void *, size_t));
|
||||
struct ma_cache *ma_cache_create(char *name, size_t size, uint32_t flags, uint16_t align, void (*constructor)(void *, size_t), void (*destructor)(void *, size_t));
|
||||
void cache_info(struct ma_cache *cache);
|
||||
void create_base_caches();
|
||||
Loading…
Add table
Add a link
Reference in a new issue