Boot_800862E0 OK (#769)

* boot_800862E0 OK

* Ran format.sh

* attempt at fixing bss reordering

* boot_800862E0 OK (for real this time)

* Run formatter

* Changes u32 pointers to uintptr_t and sizes to size_t

* Run formatter

* Fix bss reordering

* Delete baserom.mm.us.rev1.z64:Zone.Identifier

* Cleanup and some notes

* Try my best to document

* remove comments

* Remove D_80097508 from variables.h

Co-authored-by: kyleburnette <kyle@kyleburnette.com>
Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com>
This commit is contained in:
Derek Hensley 2022-03-29 12:42:44 -07:00 committed by GitHub
parent afec1c56a6
commit ec9909c65c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 126 additions and 32 deletions

View File

@ -153,14 +153,10 @@ void MtxConv_L2F(MtxF* m1, MatrixInternal* m2);
void __assert(const char* file, u32 lineNum);
// void func_800862B4(void);
void* SystemArena_MallocMin1(u32 size);
void SystemArena_FreeNull(void* pvParm1);
void func_8008633C(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4);
void func_800863AC(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4);
// void func_8008641C(void);
// void func_800864EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_80086588(void);
void SystemArena_Init(u32 base, u32 size);
s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status);
void SystemArena_FreeNullCheck(void* ptr);
void SystemArena_RunInits(void);
void SystemArena_Init(void* start, size_t size);
s32 func_80086620(OSMesgQueue* param_1, PadMgr* param_2, OSContStatus* param_3);
// void func_80086760(void);
// void func_80086794(void);
// void func_800867B4(void);

View File

@ -43,7 +43,6 @@ extern StackEntry* sStackInfoListEnd;
// extern UNK_TYPE1 sGfxPrintUnkTLUT;
// extern UNK_TYPE1 sGfxPrintUnkData;
// extern UNK_TYPE1 sGfxPrintFontData;
// extern UNK_TYPE4 D_80097500;
// extern UNK_TYPE4 D_80097524;
// extern u32 sRandInt;
extern OSViMode osViModeNtscHpf1;

1
spec
View File

@ -38,7 +38,6 @@ beginseg
include "build/src/boot_O2/mtxuty-cvt.o"
include "build/src/boot_O2/assert.o"
include "build/src/boot_O2/boot_800862E0.o"
include "build/data/boot/boot_800862E0.data.o"
include "build/src/boot_O2/padsetup.o"
include "build/src/boot_O2/boot_80086760.o"
include "build/asm/boot/fp.text.o"

View File

@ -1,18 +1,116 @@
#include "global.h"
#include "os_malloc.h"
#include "system_malloc.h"
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s")
typedef void (*BlockFunc)(void*);
typedef void (*BlockFunc1)(void*, u32);
typedef void (*BlockFunc8)(void*, u32, u32, u32, u32, u32, u32, u32, u32);
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s")
typedef struct InitFunc {
uintptr_t nextOffset;
void (*func)(void);
} InitFunc;
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008633C.s")
void* sInitFuncs = NULL;
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800863AC.s")
char sNew[] = { 0x00, 0x00, 0x00, 0x00 };
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008641C.s")
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,
};
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800864EC.s")
void* SystemArena_MallocMin1(size_t size) {
if (size == 0) {
size = 1;
}
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_80086588.s")
return __osMalloc(&gSystemArena, size);
}
#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s")
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();
}

View File

@ -158,12 +158,12 @@
0x80086280:("__assert",),
0x800862B4:("func_800862B4",),
0x800862E0:("SystemArena_MallocMin1",),
0x80086310:("SystemArena_FreeNull",),
0x8008633C:("func_8008633C",),
0x800863AC:("func_800863AC",),
0x8008641C:("func_8008641C",),
0x800864EC:("func_800864EC",),
0x80086588:("func_80086588",),
0x80086310:("SystemArena_FreeNullCheck",),
0x8008633C:("SystemArena_RunBlockFunc",),
0x800863AC:("SystemArena_RunBlockFunc1",),
0x8008641C:("SystemArena_RunBlockFunc8",),
0x800864EC:("SystemArena_RunBlockFunc1Reverse",),
0x80086588:("SystemArena_RunInits",),
0x800865F8:("SystemArena_Init",),
0x80086620:("PadSetup_Init",),
0x80086760:("func_80086760",),

View File

@ -35,7 +35,9 @@
0x80096CD0:("sGfxPrintUnkTLUT","u16","[16]",0x20),
0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8),
0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800),
0x80097500:("D_80097500","UNK_TYPE4","",0x4),
0x80097500:("sInitFuncs","void*","",0x4),
0x80097504:("sNew","char","[4]",0x4),
0x80097508:("D_80097508","[24]","",0x18),
0x80097520:("qNaN0x3FFFFF","f32","",0x4),
0x80097524:("qNaN0x10000","f32","",0x4),
0x80097528:("sNaN0x3FFFFF","f32","",0x4),

View File

@ -155,12 +155,12 @@ asm/non_matchings/boot/mtxuty-cvt/MtxConv_L2F.s,MtxConv_L2F,0x80086258,0xA
asm/non_matchings/boot/assert/__assert.s,__assert,0x80086280,0xD
asm/non_matchings/boot/assert/func_800862B4.s,func_800862B4,0x800862B4,0xB
asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s,SystemArena_MallocMin1,0x800862E0,0xC
asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s,SystemArena_FreeNull,0x80086310,0xB
asm/non_matchings/boot/boot_800862E0/func_8008633C.s,func_8008633C,0x8008633C,0x1C
asm/non_matchings/boot/boot_800862E0/func_800863AC.s,func_800863AC,0x800863AC,0x1C
asm/non_matchings/boot/boot_800862E0/func_8008641C.s,func_8008641C,0x8008641C,0x34
asm/non_matchings/boot/boot_800862E0/func_800864EC.s,func_800864EC,0x800864EC,0x27
asm/non_matchings/boot/boot_800862E0/func_80086588.s,func_80086588,0x80086588,0x1C
asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNullCheck.s,SystemArena_FreeNullCheck,0x80086310,0xB
asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc.s,SystemArena_RunBlockFunc,0x8008633C,0x1C
asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1.s,SystemArena_RunBlockFunc1,0x800863AC,0x1C
asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc8.s,SystemArena_RunBlockFunc8,0x8008641C,0x34
asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1Reverse.s,SystemArena_RunBlockFunc1Reverse,0x800864EC,0x27
asm/non_matchings/boot/boot_800862E0/SystemArena_RunInits.s,SystemArena_RunInits,0x80086588,0x1C
asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s,SystemArena_Init,0x800865F8,0xA
asm/non_matchings/boot/padsetup/PadSetup_Init.s,PadSetup_Init,0x80086620,0x50
asm/non_matchings/boot/boot_80086760/func_80086760.s,func_80086760,0x80086760,0xD

1 asm/non_matchings/boot/boot_main/bootproc.s bootproc 0x80080060 0x3C
155 asm/non_matchings/boot/assert/__assert.s __assert 0x80086280 0xD
156 asm/non_matchings/boot/assert/func_800862B4.s func_800862B4 0x800862B4 0xB
157 asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s SystemArena_MallocMin1 0x800862E0 0xC
158 asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNullCheck.s SystemArena_FreeNull SystemArena_FreeNullCheck 0x80086310 0xB
159 asm/non_matchings/boot/boot_800862E0/func_8008633C.s asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc.s func_8008633C SystemArena_RunBlockFunc 0x8008633C 0x1C
160 asm/non_matchings/boot/boot_800862E0/func_800863AC.s asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1.s func_800863AC SystemArena_RunBlockFunc1 0x800863AC 0x1C
161 asm/non_matchings/boot/boot_800862E0/func_8008641C.s asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc8.s func_8008641C SystemArena_RunBlockFunc8 0x8008641C 0x34
162 asm/non_matchings/boot/boot_800862E0/func_800864EC.s asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1Reverse.s func_800864EC SystemArena_RunBlockFunc1Reverse 0x800864EC 0x27
163 asm/non_matchings/boot/boot_800862E0/func_80086588.s asm/non_matchings/boot/boot_800862E0/SystemArena_RunInits.s func_80086588 SystemArena_RunInits 0x80086588 0x1C
164 asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s SystemArena_Init 0x800865F8 0xA
165 asm/non_matchings/boot/padsetup/PadSetup_Init.s PadSetup_Init 0x80086620 0x50
166 asm/non_matchings/boot/boot_80086760/func_80086760.s func_80086760 0x80086760 0xD