LF OS
Hobby operating system for amd64 with high ambitions
Loading...
Searching...
No Matches
slab.c File Reference

(29312b1 fbconsole, panic: render panic after framebuffer was given to userspace - without clearing screen contents)

#include "slab.h"
#include "bitmap.h"
#include "string.h"
#include "panic.h"
+ Include dependency graph for slab.c:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void init_slab (ptr_t mem_start, ptr_t mem_end, size_t allocation_size)
 
ptr_t slab_alloc (SlabHeader *slab)
 
void slab_free (SlabHeader *slab, ptr_t mem)
 

Function Documentation

◆ init_slab()

void init_slab ( ptr_t  mem_start,
ptr_t  mem_end,
size_t  allocation_size 
)

Initialize a new slab allocator at the given memory location. After initialization, you can use mem_start as pointer to SlabHeader for more operations.

Parameters
mem_startMemory address where the slab allocator region begins
mem_endMemory address where the slab allocator region ends
allocation_sizeSize of single objects in this allocator

Definition at line 6 of file slab.c.

References bitmap_size(), header, and memset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slab_alloc()

ptr_t slab_alloc ( SlabHeader slab)

Allocate object from slab allocator region.

Parameters
slabmem_start given to init_slab before
Returns
Address in memory with the allocated object, NULL if full

Definition at line 22 of file slab.c.

References bitmap_get(), bitmap_set(), SlabHeader::num_entries, panic_message(), and slab_mem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slab_free()

void slab_free ( SlabHeader slab,
ptr_t  memory 
)

Free object in slab allocator region.

Parameters
slabmem_start given to init_slab before
memoryAddress to mark as free

Definition at line 37 of file slab.c.

References bitmap_clear(), and slab_index().

+ Here is the call graph for this function: