diff options
Diffstat (limited to 'include/nitro/os_alloc.h')
-rw-r--r-- | include/nitro/os_alloc.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/include/nitro/os_alloc.h b/include/nitro/os_alloc.h new file mode 100644 index 00000000..e3c37079 --- /dev/null +++ b/include/nitro/os_alloc.h @@ -0,0 +1,67 @@ +// +// Created by mart on 4/23/20. +// + +#ifndef POKEDIAMOND_OS_ALLOC_H +#define POKEDIAMOND_OS_ALLOC_H + +#include "types.h" + +typedef enum { + OS_ARENA_MAIN = 0, + OS_ARENA_MAIN_SUBPRIV = 1, + OS_ARENA_MAINEX = 2, + OS_ARENA_ITCM = 3, + OS_ARENA_DTCM = 4, + OS_ARENA_SHARED = 5, + OS_ARENA_WRAM_MAIN = 6, + OS_ARENA_WRAM_SUB = 7, + OS_ARENA_WRAM_SUBPRIV = 8, + OS_ARENA_MAX = 9 +} OSArenaId; + +typedef struct { + void* lo[OS_ARENA_MAX]; + void* hi[OS_ARENA_MAX]; + u16 initialized; + u8 padding[2]; +} OSArenaInfo; + +typedef int OSHeapHandle; + +typedef struct Cell Cell; + +struct Cell { + Cell* prev; + Cell* next; + long size; +}; + +typedef struct { + long size; + Cell *free; + Cell *allocated; +} HeapDesc; + +typedef struct { + volatile OSHeapHandle currentHeap; + int numHeaps; + void* arenaStart; + void* arenaEnd; + HeapDesc* heapArray; +} OSHeapInfo; + +void* OS_AllocFromArenaHi(OSArenaId id, u32 size, u32 align); +void* OS_AllocFromArenaLo(OSArenaId id, u32 size, u32 align); +void OS_SetArenaLo(OSArenaId id, void *newLo); +void OS_SetArenaHi(OSArenaId id, void *newHi); +void* OS_GetInitArenaLo(OSArenaId id); +void* OS_GetInitArenaHi(OSArenaId id); +void* OS_GetArenaLo(OSArenaId id); +void* OS_GetArenaHi(OSArenaId id); +void OS_InitArenaEx(); +void OS_InitArena(); +void OS_FreeToHeap(OSArenaId id, OSHeapHandle heap, void *ptr); +void* OS_AllocFromHeap(OSArenaId id, OSHeapHandle heap, u32 size); + +#endif //POKEDIAMOND_OS_ALLOC_H |