summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorDerek Hensley <hensley.derek58@gmail.com>2023-07-29 11:09:57 -0700
committerGitHub <noreply@github.com>2023-07-29 14:09:57 -0400
commitbaaa9d6b4e99cb9573c8434c1758cb4b1a3132b7 (patch)
treee64019d3bde9cfcf7693428306b24a6edd1aa399 /src/boot
parentbe09c72d0ca03972fb3c43a858002a41a8e1c474 (diff)
Bootmain OK (#21)
* func_80025CC0_jp * Clean up * Some cleanup * Format
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/boot_main.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/boot/boot_main.c b/src/boot/boot_main.c
index c7f5ee3..6951860 100644
--- a/src/boot/boot_main.c
+++ b/src/boot/boot_main.c
@@ -1,5 +1,53 @@
+#include "libc/stdint.h"
#include "ultra64.h"
-#pragma GLOBAL_ASM("asm/jp/nonmatchings/boot/boot_main/func_80025C60_jp.s")
+#include "idle.h"
+#include "m_thread.h"
+#include "segment_symbols.h"
+#include "stack.h"
+#include "stackcheck.h"
-#pragma GLOBAL_ASM("asm/jp/nonmatchings/boot/boot_main/bootproc.s")
+extern OSPiHandle* gCartHandle; // TODO: Determine where this goes
+
+STACK(sIdleStack, 0x400);
+StackEntry sIdleStackInfo;
+StackEntry sBootStackInfo;
+OSThread sIdleThread;
+STACK(sBootStack, 0x400);
+
+// Unknown original name
+void bootclear(void) {
+ s32 size = (uintptr_t)bootclear - BOOT_ADDRESS_ULTRA;
+
+ if (size > 0) {
+ bzero((void*)BOOT_ADDRESS_ULTRA, size);
+ }
+
+ size = osMemSize - OS_K0_TO_PHYSICAL(SEGMENT_VRAM_START(dmadata));
+ if (size > 0) {
+ bzero(SEGMENT_VRAM_START(dmadata), size);
+ }
+}
+
+void bootproc(void) {
+ StackCheck_Init(&sBootStackInfo, sBootStack, STACK_TOP(sBootStack), 0, -1, "boot");
+
+ osMemSize = 0x400000; // 4MB
+ osInitialize();
+
+ if (osAppNMIBuffer[15] & 4) {
+ osAppNMIBuffer[15] &= ~4;
+ osAppNMIBuffer[15] |= 2;
+ } else {
+ osAppNMIBuffer[15] &= ~2;
+ }
+
+ osUnmapTLBAll();
+ bootclear();
+
+ gCartHandle = osCartRomInit();
+
+ StackCheck_Init(&sIdleStackInfo, sIdleStack, STACK_TOP(sIdleStack), 0, 0x100, "idle");
+ osCreateThread(&sIdleThread, M_THREAD_ID_IDLE, Idle_ThreadEntry, NULL, STACK_TOP(sIdleStack), M_PRIORITY_IDLE);
+ osStartThread(&sIdleThread);
+}