Turnstone Operating System
Loading...
Searching...
No Matches
memory_simple.xx.c File Reference

a simple heap implementation More...

#include <memory.h>
#include <systeminfo.h>
#include <cpu.h>
#include <cpu/task.h>
#include <logging.h>
#include <cpu/sync.h>
#include <linker.h>
#include <utils.h>

Classes

struct  heapinfo_t
 heap info struct More...
 
struct  heapmetainfo_t
 heap info struct More...
 
struct  heapmetainfo_t::fast_classes_t
 

Macros

#define HEAP_INFO_FLAG_STARTEND   (1 << 0)
 
#define HEAP_INFO_FLAG_USED   (1 << 1)
 
#define HEAP_INFO_FLAG_NOTUSED   (0 << 1)
 
#define HEAP_INFO_FLAG_HEAP   (1 << 4)
 
#define HEAP_INFO_FLAG_HEAP_INITED   (HEAP_INFO_FLAG_HEAP | HEAP_INFO_FLAG_USED)
 
#define HEAP_INFO_MAGIC   (0xaa55)
 
#define HEAP_INFO_PADDING   (0xaa55aa55)
 
#define HEAP_HEADER   HEAP_INFO_PADDING
 

Typedefs

typedef struct heapinfo_t heapinfo_t
 short hand for struct
 
typedef struct heapmetainfo_t heapmetainfo_t
 short hand for struct
 

Functions

void memory_heap_backtrace (void)
 
 MODULE ("turnstone.lib.memory")
 
void * memory_simple_malloc_ext (memory_heap_t *heap, size_t size, size_t align)
 simple heap malloc implementation More...
 
int8_t memory_simple_free (memory_heap_t *heap, void *address)
 simple heap free implementation More...
 
void memory_simple_stat (memory_heap_t *heap, memory_heap_stat_t *stat)
 
memory_heap_tmemory_create_heap_simple (size_t start, size_t end)
 creates simple heap More...
 
static void memory_simple_insert_sorted (heapmetainfo_t *heap, int8_t tofull, heapinfo_t *item)
 

Detailed Description

a simple heap implementation

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ HEAP_HEADER

#define HEAP_HEADER   HEAP_INFO_PADDING

heap header

◆ HEAP_INFO_FLAG_HEAP

#define HEAP_INFO_FLAG_HEAP   (1 << 4)

heap metadata flag

◆ HEAP_INFO_FLAG_HEAP_INITED

#define HEAP_INFO_FLAG_HEAP_INITED   (HEAP_INFO_FLAG_HEAP | HEAP_INFO_FLAG_USED)

heap initilized flag

◆ HEAP_INFO_FLAG_NOTUSED

#define HEAP_INFO_FLAG_NOTUSED   (0 << 1)

unused heap hole flag

◆ HEAP_INFO_FLAG_STARTEND

#define HEAP_INFO_FLAG_STARTEND   (1 << 0)

heap flag for heap start and end hi

◆ HEAP_INFO_FLAG_USED

#define HEAP_INFO_FLAG_USED   (1 << 1)

used heap hole flag

◆ HEAP_INFO_MAGIC

#define HEAP_INFO_MAGIC   (0xaa55)

heap magic for protection

◆ HEAP_INFO_PADDING

#define HEAP_INFO_PADDING   (0xaa55aa55)

heap padding for protection

Function Documentation

◆ memory_create_heap_simple()

memory_heap_t * memory_create_heap_simple ( size_t  start,
size_t  end 
)

creates simple heap

Parameters
[in]startstart address of heap
[in]endend address of heap
Returns
heap

◆ memory_simple_free()

int8_t memory_simple_free ( memory_heap_t heap,
void *  address 
)

simple heap free implementation

Parameters
[in]heapsimple heap (itself)
[in]addressaddress to free
Returns
0 if successed

◆ memory_simple_malloc_ext()

void * memory_simple_malloc_ext ( memory_heap_t heap,
size_t  size,
size_t  align 
)

simple heap malloc implementation

Parameters
[in]heapsimple heap (itself)
[in]sizesize of memory
[in]alignalign value
Returns
allocated memory start address