From 3d3bc2ccb4af3c62523193326da5050ddc67af7b Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Jul 2024 16:04:42 -0700 Subject: [PATCH 1/7] Split 7D140 --- src/main/7D140.c | 10 ++++++++++ yamls/us/main.yaml | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/main/7D140.c diff --git a/src/main/7D140.c b/src/main/7D140.c new file mode 100644 index 0000000..3090cb4 --- /dev/null +++ b/src/main/7D140.c @@ -0,0 +1,10 @@ +#include "global.h" + + +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C540.s") + +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C5EC.s") + +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C61C.s") + +#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C640.s") diff --git a/yamls/us/main.yaml b/yamls/us/main.yaml index 522df6f..6994f6e 100644 --- a/yamls/us/main.yaml +++ b/yamls/us/main.yaml @@ -79,7 +79,7 @@ - [0x79D60, asm] # Probably has at least 2 file split - [0x7CA70, asm] - [0x7CC30, asm] - - [0x7D140, asm] + - [0x7D140, c, 7D140] - [0x7D270, asm] - [0x7D9A0, c, eepmgr] - [0x7E1E0, asm] @@ -348,7 +348,7 @@ - [0xB3600, rodata] - [0xB3640, rodata, 7CA70] - [0xB3690, rodata, 7CC30] - - [0xB36A0, rodata, 7D140] + - [0xB36A0, .rodata, 7D140] - [0xB36E0, .rodata, eepmgr] - [0xB39F0, .rodata, dmamgr] - [0xB3AA0, rodata, 7EC30] From e78d7825ce48d0d944397571a3ccad7d27b3440f Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Jul 2024 16:26:30 -0700 Subject: [PATCH 2/7] func_8007C540 OK --- include/global.h | 2 ++ include/ys64thread.h | 2 ++ linker_scripts/us/symbol_addrs.txt | 5 +++++ src/main/7D140.c | 15 ++++++++++++++- yamls/us/main.yaml | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/global.h b/include/global.h index 0a85fec..aac352d 100644 --- a/include/global.h +++ b/include/global.h @@ -33,6 +33,7 @@ typedef struct MallocRecord { extern MallocRecord mallocRecord; extern UNK_TYPE D_800DA83C; +extern UNK_TYPE D_801001F8; extern UNK_TYPE D_8010DF40; typedef struct Y511F0UnkStruct { @@ -48,6 +49,7 @@ extern Y511F0UnkStruct D_800DA840[]; OSMesgQueue* func_800744B0(s32 arg0); void func_8007451C(s32 arg0, OSMesgQueue* arg1); void func_80074C88(UNK_PTR, struct Input*, s32); +void func_80075020(UNK_PTR, OSMesgQueue*, UNK_PTR, s32, s32, void*); // malloc void* func_80064DD0(u32 size); diff --git a/include/ys64thread.h b/include/ys64thread.h index 3d68a32..5e13445 100644 --- a/include/ys64thread.h +++ b/include/ys64thread.h @@ -2,8 +2,10 @@ #define YS64_THREAD_H #define Y_THREAD_ID_FAULT 2 +#define Y_THREAD_ID_PAD 7 #define Y_THREAD_ID_DMA 18 +#define Y_PRIORITY_PAD 15 #define Y_PRIORITY_DMA 18 #define Y_PRIORITY_FAULT OS_PRIORITY_APPMAX diff --git a/linker_scripts/us/symbol_addrs.txt b/linker_scripts/us/symbol_addrs.txt index 7a94aba..29faaef 100644 --- a/linker_scripts/us/symbol_addrs.txt +++ b/linker_scripts/us/symbol_addrs.txt @@ -125,3 +125,8 @@ gOverlayLogSeverity = 0x800AA390; // type:s32 // rodata // bss + +sSerialEventQueue = 0x8010DAA0; +sSerialMsgBuff = 0x8010DAB8; +sPadStack = 0x8010DAC0; +sPadStackInfo = 0x8010DEC0; \ No newline at end of file diff --git a/src/main/7D140.c b/src/main/7D140.c index 3090cb4..8850a27 100644 --- a/src/main/7D140.c +++ b/src/main/7D140.c @@ -1,7 +1,20 @@ #include "global.h" +#include "stack.h" +#include "stackcheck.h" +#include "ys64thread.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C540.s") +extern OSMesgQueue sSerialEventQueue; +extern OSMesg sSerialMsgBuff[1]; +extern STACK(sPadStack, 0x400); +extern StackEntry sPadStackInfo; + +void func_8007C540(void) { + osCreateMesgQueue(&sSerialEventQueue, sSerialMsgBuff, ARRAY_COUNT(sSerialMsgBuff)); + osSetEventMesg(OS_EVENT_SI, &sSerialEventQueue, NULL); + StackCheck_Init(&sPadStackInfo, sPadStack, STACK_TOP(sPadStack), 0, 0x100, "padmgr"); + func_80075020(&D_8010DF40, &sSerialEventQueue, &D_801001F8, Y_THREAD_ID_PAD, Y_PRIORITY_PAD, STACK_TOP(sPadStack)); +} #pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C5EC.s") diff --git a/yamls/us/main.yaml b/yamls/us/main.yaml index 6994f6e..12e3f95 100644 --- a/yamls/us/main.yaml +++ b/yamls/us/main.yaml @@ -349,6 +349,7 @@ - [0xB3640, rodata, 7CA70] - [0xB3690, rodata, 7CC30] - [0xB36A0, .rodata, 7D140] + - [0xB36B0, rodata, 7D270] - [0xB36E0, .rodata, eepmgr] - [0xB39F0, .rodata, dmamgr] - [0xB3AA0, rodata, 7EC30] From 606da732768e537d4d1c131013bdcbf0c39ada1c Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Jul 2024 16:28:44 -0700 Subject: [PATCH 3/7] func_8007C5EC OK --- linker_scripts/us/symbol_addrs.txt | 3 ++- src/main/7D140.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/linker_scripts/us/symbol_addrs.txt b/linker_scripts/us/symbol_addrs.txt index 29faaef..4081ac5 100644 --- a/linker_scripts/us/symbol_addrs.txt +++ b/linker_scripts/us/symbol_addrs.txt @@ -129,4 +129,5 @@ gOverlayLogSeverity = 0x800AA390; // type:s32 sSerialEventQueue = 0x8010DAA0; sSerialMsgBuff = 0x8010DAB8; sPadStack = 0x8010DAC0; -sPadStackInfo = 0x8010DEC0; \ No newline at end of file +sPadStackInfo = 0x8010DEC0; +D_8010DEE0 = 0x8010DEE0; diff --git a/src/main/7D140.c b/src/main/7D140.c index 8850a27..73e79e7 100644 --- a/src/main/7D140.c +++ b/src/main/7D140.c @@ -1,5 +1,6 @@ #include "global.h" +#include "pad.h" #include "stack.h" #include "stackcheck.h" #include "ys64thread.h" @@ -8,6 +9,7 @@ extern OSMesgQueue sSerialEventQueue; extern OSMesg sSerialMsgBuff[1]; extern STACK(sPadStack, 0x400); extern StackEntry sPadStackInfo; +extern Input D_8010DEE0; void func_8007C540(void) { osCreateMesgQueue(&sSerialEventQueue, sSerialMsgBuff, ARRAY_COUNT(sSerialMsgBuff)); @@ -16,7 +18,9 @@ void func_8007C540(void) { func_80075020(&D_8010DF40, &sSerialEventQueue, &D_801001F8, Y_THREAD_ID_PAD, Y_PRIORITY_PAD, STACK_TOP(sPadStack)); } -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C5EC.s") +void func_8007C5EC(void) { + func_80074C88(&D_8010DF40, &D_8010DEE0, 1); +} #pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C61C.s") From c316163f8444cd2a130310ae10e32f86fc65e8c1 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Jul 2024 16:31:13 -0700 Subject: [PATCH 4/7] func_8007C61C OK --- include/eepmgr.h | 3 ++- include/global.h | 2 +- src/main/7D140.c | 4 +++- src/main/eepmgr.c | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/eepmgr.h b/include/eepmgr.h index af4528f..f5db720 100644 --- a/include/eepmgr.h +++ b/include/eepmgr.h @@ -2,6 +2,7 @@ #define EEPMGR_H #include "ultra64.h" +#include "unk.h" typedef struct EepRequest { @@ -18,7 +19,7 @@ typedef struct EepMgr { /* 0x048 */ EepRequest unk048; /* 0x050 */ char unk_04C[0x68 - 0x50]; /* 0x068 */ OSThread thread; - /* 0x218 */ s32 unk218; + /* 0x218 */ UNK_PTR unk218; /* 0x21C */ u8 type; /* 0x21E */ u16 numBlocks; /* 0x220 */ u64* cache; diff --git a/include/global.h b/include/global.h index aac352d..20f180b 100644 --- a/include/global.h +++ b/include/global.h @@ -46,7 +46,7 @@ typedef struct Y511F0UnkStruct { extern Y511F0UnkStruct D_800DA840[]; // 740F0 -OSMesgQueue* func_800744B0(s32 arg0); +OSMesgQueue* func_800744B0(UNK_PTR arg0); void func_8007451C(s32 arg0, OSMesgQueue* arg1); void func_80074C88(UNK_PTR, struct Input*, s32); void func_80075020(UNK_PTR, OSMesgQueue*, UNK_PTR, s32, s32, void*); diff --git a/src/main/7D140.c b/src/main/7D140.c index 73e79e7..3c70774 100644 --- a/src/main/7D140.c +++ b/src/main/7D140.c @@ -22,6 +22,8 @@ void func_8007C5EC(void) { func_80074C88(&D_8010DF40, &D_8010DEE0, 1); } -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C61C.s") +void func_8007C61C(void) { + func_800744B0(&D_8010DF40); +} #pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C640.s") diff --git a/src/main/eepmgr.c b/src/main/eepmgr.c index ba5eb58..0d416bd 100644 --- a/src/main/eepmgr.c +++ b/src/main/eepmgr.c @@ -71,7 +71,7 @@ void eepmgr_Probe(EepMgr* eepmgr) { } } -void eepmgr_Setup(EepMgr* eepmgr, s32 arg1, s32 type, u64* buffer) { +void eepmgr_Setup(EepMgr* eepmgr, UNK_PTR arg1, s32 type, u64* buffer) { bzero(eepmgr, sizeof(EepMgr)); eepmgr->unk218 = arg1; eepmgr->cache = buffer; @@ -255,7 +255,7 @@ void eepmgr_ThreadEntry(void* arg) { } } -void eepmgr_Create(EepMgr* eepmgr, s32 arg1, s32 type, u64* buffer, s32 id, s32 priority, void* stack) { +void eepmgr_Create(EepMgr* eepmgr, UNK_PTR arg1, s32 type, u64* buffer, s32 id, s32 priority, void* stack) { (void)"eepmgr_Create(%08x, %08x, %d, %08x, %d, %d, %08x)\n"; eepmgr_Setup(eepmgr, arg1, type, buffer); osCreateMesgQueue(&eepmgr->unk014, eepmgr->unk000, ARRAY_COUNT(eepmgr->unk000)); From b3d6f73151c9b44786ce1a6272a99fee40accac3 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Jul 2024 16:34:59 -0700 Subject: [PATCH 5/7] func_8007C640 OK --- include/global.h | 2 +- src/main/7D140.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/global.h b/include/global.h index 20f180b..34c6f5a 100644 --- a/include/global.h +++ b/include/global.h @@ -47,7 +47,7 @@ extern Y511F0UnkStruct D_800DA840[]; // 740F0 OSMesgQueue* func_800744B0(UNK_PTR arg0); -void func_8007451C(s32 arg0, OSMesgQueue* arg1); +void func_8007451C(UNK_PTR arg0, OSMesgQueue* arg1); void func_80074C88(UNK_PTR, struct Input*, s32); void func_80075020(UNK_PTR, OSMesgQueue*, UNK_PTR, s32, s32, void*); diff --git a/src/main/7D140.c b/src/main/7D140.c index 3c70774..0398c8d 100644 --- a/src/main/7D140.c +++ b/src/main/7D140.c @@ -26,4 +26,6 @@ void func_8007C61C(void) { func_800744B0(&D_8010DF40); } -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/7D140/func_8007C640.s") +void func_8007C640(OSMesgQueue* arg0) { + func_8007451C(&D_8010DF40, arg0); +} From 247a460dac349a1bbf45ff7dcafc44949e275650 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Jul 2024 16:40:50 -0700 Subject: [PATCH 6/7] bss --- include/global.h | 1 + src/main/7D140.c | 9 ++++----- yamls/us/main.yaml | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/global.h b/include/global.h index 34c6f5a..a3b6966 100644 --- a/include/global.h +++ b/include/global.h @@ -34,6 +34,7 @@ extern MallocRecord mallocRecord; extern UNK_TYPE D_800DA83C; extern UNK_TYPE D_801001F8; +extern struct Input D_8010DEE0; extern UNK_TYPE D_8010DF40; typedef struct Y511F0UnkStruct { diff --git a/src/main/7D140.c b/src/main/7D140.c index 0398c8d..3993d9c 100644 --- a/src/main/7D140.c +++ b/src/main/7D140.c @@ -5,11 +5,10 @@ #include "stackcheck.h" #include "ys64thread.h" -extern OSMesgQueue sSerialEventQueue; -extern OSMesg sSerialMsgBuff[1]; -extern STACK(sPadStack, 0x400); -extern StackEntry sPadStackInfo; -extern Input D_8010DEE0; +OSMesgQueue sSerialEventQueue; +OSMesg sSerialMsgBuff[1]; +STACK(sPadStack, 0x400); +StackEntry sPadStackInfo; void func_8007C540(void) { osCreateMesgQueue(&sSerialEventQueue, sSerialMsgBuff, ARRAY_COUNT(sSerialMsgBuff)); diff --git a/yamls/us/main.yaml b/yamls/us/main.yaml index 12e3f95..79f1ffd 100644 --- a/yamls/us/main.yaml +++ b/yamls/us/main.yaml @@ -382,6 +382,8 @@ - {type: bss, vram: 0x800B4CB0, name: 800B4CB0} - {type: .bss, vram: 0x80108630, name: fault} - {type: bss, vram: 0x801090D0, name: 801090D0} + - {type: .bss, vram: 0x8010DAA0, name: 7D140} + - {type: bss, vram: 0x8010DEE0, name: 8010DEE0} - {type: .bss, vram: 0x8010E840, name: dmamgr} - {type: .bss, vram: 0x8010ED90, name: 7EFD0} From 0d3bfb3a5cf408b32f42c4a7118adb3ebd21d7f4 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Jul 2024 17:23:35 -0700 Subject: [PATCH 7/7] Reorder global.h --- include/global.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/global.h b/include/global.h index 2c7fc71..92c04e0 100644 --- a/include/global.h +++ b/include/global.h @@ -97,18 +97,17 @@ extern MallocRecord mallocRecord; // Bss extern UNK_TYPE D_800DA83C; -extern UNK_TYPE D_801001F8; -extern struct Input D_8010DEE0; -extern UNK_TYPE D_8010DF40; extern Y511F0UnkStruct D_800DA840[]; extern MallocRecord D_800F8E58; extern u8 D_800FAAF8; extern u8 D_800FAB1C; extern u8 D_800FAB20; +extern UNK_TYPE D_801001F8; extern UNK_TYPE D_80108620; extern UNK_TYPE D_80108624; extern UNK_TYPE D_80108628; - +extern struct Input D_8010DEE0; +extern UNK_TYPE D_8010DF40; #endif