diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2023-05-28 20:04:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-29 13:04:07 +1000 |
| commit | fc475a97565ade34d57f80970c6b5cebcc2892a7 (patch) | |
| tree | 92d32e23a29bf3b2c7063ddc730c7c66b5b5f4d6 /src/boot_O2/boot_800862E0.c | |
| parent | 1ec875f6dccf7efd9d637cd27a1a500f35eed43e (diff) | |
Docs Cleanup (#1153)
* sysheap
* Gorons
* Update goron comment
* functions.h
* Update src/boot_O2/system_heap.c
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
* add header
* Fix header guards
* Update data
* Add malloc and free to header
---------
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Diffstat (limited to 'src/boot_O2/boot_800862E0.c')
| -rw-r--r-- | src/boot_O2/boot_800862E0.c | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/src/boot_O2/boot_800862E0.c b/src/boot_O2/boot_800862E0.c deleted file mode 100644 index 5774af9da..000000000 --- a/src/boot_O2/boot_800862E0.c +++ /dev/null @@ -1,116 +0,0 @@ -#include "global.h" -#include "system_malloc.h" - -typedef void (*BlockFunc)(void*); -typedef void (*BlockFunc1)(void*, u32); -typedef void (*BlockFunc8)(void*, u32, u32, u32, u32, u32, u32, u32, u32); - -typedef struct InitFunc { - uintptr_t nextOffset; - void (*func)(void); -} InitFunc; - -void* sInitFuncs = NULL; - -char sNew[] = { 0x00, 0x00, 0x00, 0x00 }; - -char D_80097508[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, - 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, -}; - -void* SystemArena_MallocMin1(size_t size) { - if (size == 0) { - size = 1; - } - - return __osMalloc(&gSystemArena, size); -} - -void SystemArena_FreeNullCheck(void* ptr) { - if (ptr != NULL) { - __osFree(&gSystemArena, ptr); - } -} - -void SystemArena_RunBlockFunc(void* blk, size_t nBlk, size_t blkSize, BlockFunc blockFunc) { - uintptr_t pos = blk; - - for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { - blockFunc(pos); - } -} - -void SystemArena_RunBlockFunc1(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc) { - uintptr_t pos = blk; - - for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { - blockFunc(pos, 2); - } -} - -void* SystemArena_RunBlockFunc8(void* blk, size_t nBlk, size_t blkSize, BlockFunc8 blockFunc) { - if (blk == NULL) { - blk = SystemArena_MallocMin1(nBlk * blkSize); - } - - if (blk != NULL && blockFunc != NULL) { - uintptr_t pos = blk; - - for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { - blockFunc(pos, 0, 0, 0, 0, 0, 0, 0, 0); - } - } - - return blk; -} - -void SystemArena_RunBlockFunc1Reverse(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc, s32 shouldFree) { - uintptr_t pos; - uintptr_t start; - size_t maskedBlkSize; - - if (blk == NULL) { - return; - } - - if (blockFunc != NULL) { - start = blk; - maskedBlkSize = (blkSize & ~0); - pos = (uintptr_t)start + (nBlk * blkSize); - - while (pos > start) { - pos -= maskedBlkSize; - blockFunc(pos, 2); - } - } - - if (shouldFree) { - SystemArena_FreeNullCheck(blk); - } -} - -void SystemArena_RunInits(void) { - InitFunc* initFunc = (InitFunc*)&sInitFuncs; - u32 nextOffset = initFunc->nextOffset; - InitFunc* prev = NULL; - - while (nextOffset != 0) { - initFunc = (InitFunc*)((uintptr_t)initFunc + nextOffset); - - if (initFunc->func != NULL) { - (*initFunc->func)(); - } - - nextOffset = initFunc->nextOffset; - initFunc->nextOffset = (uintptr_t)prev; - prev = initFunc; - } - - sInitFuncs = prev; -} - -void SystemArena_Init(void* start, size_t size) { - SystemArena_InitArena(start, size); - SystemArena_RunInits(); -} |
