kernel/inc/mm/heap.h

32 lines
839 B
C
Raw Normal View History

// This file is part of noxos and licensed under the MIT open source license
#ifndef NOX_HEAP_H
#define NOX_HEAP_H
#include "utils/stdtypes.h"
#define HEAP_SEGMENT_MAGIC 0xA1C3A1B2
typedef struct heap_segment_T heap_segment_T;
struct heap_segment_T {
uint32_t magic;
uint64_t size;
bool free;
heap_segment_T* next;
heap_segment_T* prev;
};
typedef struct {
void* start;
void* end;
heap_segment_T* last_segment;
} heap_T;
void heap_init (heap_T* heap, void* base);
void* heap_memory_allocate (heap_T* heap, uint64_t size);
void heap_memory_free (heap_T* heap, void* address);
void heap_dump_segments (heap_T* heap);
void heap_destruct (heap_T* heap);
#endif //NOX_HEAP_H