From cc524f13d4f6fc8801ab6c419447a9097fc9616a Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 20 Oct 2024 18:04:07 -0700 Subject: [PATCH] Rename OS related functions, partial matches for OSFont --- config/GM8E01_00/symbols.txt | 20 ++--- config/GM8E01_01/symbols.txt | 16 ++-- configure.py | 2 +- include/dolphin/dvd.h | 2 +- include/dolphin/hw_regs.h | 167 +++++------------------------------ include/dolphin/os/OSFont.h | 51 ++++++++--- src/Dolphin/os/OSReboot.c | 58 +++++++++++- 7 files changed, 136 insertions(+), 180 deletions(-) diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 4d4120de..1fb554fb 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -15764,11 +15764,11 @@ ConfigureVideo = .text:0x80380434; // type:function size:0xFC scope:global OSFatal = .text:0x80380530; // type:function size:0xFC scope:global Halt = .text:0x8038062C; // type:function size:0x608 scope:global GetFontCode = .text:0x80380C34; // type:function size:0x19C scope:global -fn_80380DD0 = .text:0x80380DD0; // type:function size:0x174 +Decode = .text:0x80380DD0; // type:function size:0x174 OSGetFontEncode = .text:0x80380F44; // type:function size:0x58 scope:global -fn_80380F9C = .text:0x80380F9C; // type:function size:0x8C -fn_80381028 = .text:0x80381028; // type:function size:0x334 -fn_8038135C = .text:0x8038135C; // type:function size:0x304 +ReadROM = .text:0x80380F9C; // type:function size:0x8C +OSLoadFont = .text:0x80381028; // type:function size:0x334 +OSGetFontTexel = .text:0x8038135C; // type:function size:0x304 OSDisableInterrupts = .text:0x80381660; // type:function size:0x14 scope:global __RAS_OSDisableInterrupts_begin = .text:0x80381660; // type:label scope:global __RAS_OSDisableInterrupts_end = .text:0x8038166C; // type:label scope:global @@ -19018,7 +19018,7 @@ DSPInitCode = .data:0x803F0FA8; // type:object size:0x80 scope:local @86 = .data:0x803F16D4; // type:object size:0x35 scope:local data:string @87 = .data:0x803F170C; // type:object size:0x40 scope:local HankakuToCode = .data:0x803F1750; // type:object size:0x180 scope:global -Zenkaku2Code = .data:0x803F18D0; // type:object size:0x990 scope:global +Zenkaku2Code = .data:0x803F18D0; // type:object size:0x98A scope:global InterruptPrioTable = .data:0x803F2260; // type:object size:0x2C scope:local data:4byte @62 = .data:0x803F2290; // type:object size:0x25 scope:local data:string @167 = .data:0x803F22B8; // type:object size:0x27 scope:local data:string @@ -21443,7 +21443,7 @@ __OSArenaLo = .sdata:0x805A8B30; // type:object size:0x4 scope:global data:4byte __OSFpscrEnableBits = .sdata:0x805A8B38; // type:object size:0x4 scope:global data:4byte @76 = .sdata:0x805A8B3C; // type:object size:0x2 scope:local data:string lbl_805A8B40 = .sdata:0x805A8B40; // type:object size:0x8 -fontEncode$57 = .sdata:0x805A8B48; // type:object size:0x8 scope:local data:2byte +fontEncode$57 = .sdata:0x805A8B48; // type:object size:0x2 scope:local data:2byte SwitchThreadCallback = .sdata:0x805A8B50; // type:object size:0x4 scope:local data:4byte __PADVersion = .sdata:0x805A8B58; // type:object size:0x4 scope:global data:4byte ResettingChan = .sdata:0x805A8B5C; // type:object size:0x4 scope:local data:4byte @@ -22205,10 +22205,10 @@ __OSInIPL = .sbss:0x805A98A0; // type:object size:0x4 scope:global data:4byte __OSStartTime = .sbss:0x805A98A8; // type:object size:0x8 scope:global align:8 data:4byte AlarmQueue = .sbss:0x805A98B0; // type:object size:0x8 scope:local data:4byte __OSArenaHi = .sbss:0x805A98B8; // type:object size:0x4 scope:global data:4byte -lbl_805A98C0 = .sbss:0x805A98C0; // type:object size:0x4 data:4byte -lbl_805A98C4 = .sbss:0x805A98C4; // type:object size:0x4 data:4byte -lbl_805A98C8 = .sbss:0x805A98C8; // type:object size:0x4 data:4byte -lbl_805A98CC = .sbss:0x805A98CC; // type:object size:0x4 data:4byte +FontData = .sbss:0x805A98C0; // type:object size:0x4 data:4byte +SheetImage = .sbss:0x805A98C4; // type:object size:0x4 data:4byte +WidthTable = .sbss:0x805A98C8; // type:object size:0x4 data:4byte +CharsInSheet = .sbss:0x805A98CC; // type:object size:0x4 data:4byte InterruptHandlerTable = .sbss:0x805A98D0; // type:object size:0x4 scope:local data:4byte __OSLastInterruptSrr0 = .sbss:0x805A98D4; // type:object size:0x4 scope:global data:4byte __OSLastInterrupt = .sbss:0x805A98D8; // type:object size:0x2 scope:global data:2byte diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index e0b1cae9..c047ee84 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -15779,9 +15779,9 @@ ConfigureVideo = .text:0x80380610; // type:function size:0xFC scope:global OSFatal = .text:0x8038070C; // type:function size:0xFC scope:global Halt = .text:0x80380808; // type:function size:0x608 scope:global GetFontCode = .text:0x80380E10; // type:function size:0x19C scope:global -fn_80380DD0 = .text:0x80380FAC; // type:function size:0x174 scope:global +Decode = .text:0x80380FAC; // type:function size:0x174 scope:global OSGetFontEncode = .text:0x80381120; // type:function size:0x58 scope:global -fn_80380F9C = .text:0x80381178; // type:function size:0x8C scope:global +ReadROM = .text:0x80381178; // type:function size:0x8C scope:global fn_80381028 = .text:0x80381204; // type:function size:0x334 scope:global fn_8038135C = .text:0x80381538; // type:function size:0x304 scope:global OSDisableInterrupts = .text:0x8038183C; // type:function size:0x14 scope:global @@ -19056,7 +19056,7 @@ DSPInitCode = .data:0x803F1188; // type:object size:0x80 scope:local @86 = .data:0x803F18B4; // type:object size:0x35 scope:local data:string @87 = .data:0x803F18EC; // type:object size:0x40 scope:local HankakuToCode = .data:0x803F1930; // type:object size:0x180 scope:global -Zenkaku2Code = .data:0x803F1AB0; // type:object size:0x990 scope:global +Zenkaku2Code = .data:0x803F1AB0; // type:object size:0x98a scope:global InterruptPrioTable = .data:0x803F2440; // type:object size:0x2C scope:local data:4byte @62 = .data:0x803F2470; // type:object size:0x25 scope:local data:string @167 = .data:0x803F2498; // type:object size:0x27 scope:local data:string @@ -21478,7 +21478,7 @@ __OSVersion = .sdata:0x805A8D08; // type:object size:0x4 scope:local data:4byte __OSArenaLo = .sdata:0x805A8D10; // type:object size:0x4 scope:global data:4byte __OSFpscrEnableBits = .sdata:0x805A8D18; // type:object size:0x4 scope:global data:4byte @76 = .sdata:0x805A8D1C; // type:object size:0x2 scope:local data:string -lbl_805A8B40 = .sdata:0x805A8D20; // type:object size:0x8 scope:global +fontEncode$57 = .sdata:0x805A8D20; // type:object size:0x8 scope:global lbl_805A8B48 = .sdata:0x805A8D28; // type:object size:0x8 scope:global data:2byte SwitchThreadCallback = .sdata:0x805A8D30; // type:object size:0x4 scope:local data:4byte __PADVersion = .sdata:0x805A8D38; // type:object size:0x4 scope:global data:4byte @@ -22241,10 +22241,10 @@ __OSInIPL = .sbss:0x805A9A80; // type:object size:0x4 scope:global data:4byte __OSStartTime = .sbss:0x805A9A88; // type:object size:0x8 scope:global data:4byte AlarmQueue = .sbss:0x805A9A90; // type:object size:0x8 scope:local data:4byte __OSArenaHi = .sbss:0x805A9A98; // type:object size:0x4 scope:global data:4byte -lbl_805A98C0 = .sbss:0x805A9AA0; // type:object size:0x4 scope:local data:4byte -lbl_805A98C4 = .sbss:0x805A9AA4; // type:object size:0x4 scope:local data:4byte -lbl_805A98C8 = .sbss:0x805A9AA8; // type:object size:0x4 scope:local data:4byte -lbl_805A98CC = .sbss:0x805A9AAC; // type:object size:0x4 scope:local data:4byte +FontData = .sbss:0x805A9AA0; // type:object size:0x4 scope:local data:4byte +SheetImage = .sbss:0x805A9AA4; // type:object size:0x4 scope:local data:4byte +WidthDable = .sbss:0x805A9AA8; // type:object size:0x4 scope:local data:4byte +CharsInSheet = .sbss:0x805A9AAC; // type:object size:0x4 scope:local data:4byte InterruptHandlerTable = .sbss:0x805A9AB0; // type:object size:0x4 scope:local data:4byte __OSLastInterruptSrr0 = .sbss:0x805A9AB4; // type:object size:0x4 scope:global data:4byte __OSLastInterrupt = .sbss:0x805A9AB8; // type:object size:0x2 scope:global data:2byte diff --git a/configure.py b/configure.py index 7e188532..9318e79f 100755 --- a/configure.py +++ b/configure.py @@ -151,7 +151,7 @@ if not config.non_matching: # Tool versions config.binutils_tag = "2.42-1" config.compilers_tag = "20240706" -config.dtk_tag = "v1.1.2" +config.dtk_tag = "v1.1.4" config.objdiff_tag = "v2.3.2" config.sjiswrap_tag = "v1.1.1" config.wibo_tag = "0.6.11" diff --git a/include/dolphin/dvd.h b/include/dolphin/dvd.h index ad4a8a7d..0474c4a6 100644 --- a/include/dolphin/dvd.h +++ b/include/dolphin/dvd.h @@ -99,7 +99,7 @@ BOOL DVDCancelAllAsync(DVDCBCallback callback); s32 DVDCancelAll(void); BOOL DVDPrepareStreamAsync(DVDFileInfo* fInfo, u32 length, u32 offset, DVDCallback callback); s32 DVDPrepareStream(DVDFileInfo* fInfo, u32 length, u32 offset); - +BOOL DVDSetAutoInvalidation(BOOL autoInval); BOOL DVDCancelStreamAsync(DVDCommandBlock* block, DVDCBCallback callback); s32 DVDCancelStream(DVDCommandBlock* block); diff --git a/include/dolphin/hw_regs.h b/include/dolphin/hw_regs.h index 52dcd5a7..ce6a9b97 100644 --- a/include/dolphin/hw_regs.h +++ b/include/dolphin/hw_regs.h @@ -1,15 +1,27 @@ -#ifndef _DOLPHIN_HW_REGS -#define _DOLPHIN_HW_REGS - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef _DOLPHIN_HW_REGS_H_ +#define _DOLPHIN_HW_REGS_H_ #ifdef __MWERKS__ +volatile u16 __VIRegs[59] : 0xCC002000; +volatile u32 __PIRegs[12] : 0xCC003000; +volatile u16 __MEMRegs[64] : 0xCC004000; +volatile u16 __DSPRegs[] : 0xCC005000; +volatile u32 __DIRegs[] : 0xCC006000; +volatile u32 __SIRegs[0x100] : 0xCC006400; +volatile u32 __EXIRegs[0x40] : 0xCC006800; +volatile u32 __AIRegs[8] : 0xCC006C00; +#else +#define __VIRegs ((volatile u16 *)0xCC002000) +#define __PIRegs ((volatile u32 *)0xCC003000) +#define __MEMRegs ((volatile u16 *)0xCC004000) +#define __DSPRegs ((volatile u16 *)0xCC005000) +#define __DIRegs ((volatile u32 *)0xCC006000) +#define __SIRegs ((volatile u32 *)0xCC006400) +#define __EXIRegs ((volatile u32 *)0xCC006800) +#define __AIRegs ((volatile u32 *)0xCC006C00) +#endif -vu16 __VIRegs[59] : 0xCC002000; +// Offsets for __VIRegs // offsets for __VIRegs[i] #define VI_VERT_TIMING (0) @@ -75,55 +87,6 @@ vu16 __VIRegs[59] : 0xCC002000; #define VI_WIDTH (56) -vu32 __PIRegs[12] : 0xCC003000; - -// offsets for __PIRegs[i] - -#define PI_INTRPT_SRC (0) // interrupt cause -#define PI_INTRPT_MASK (1) // interrupt mask -#define PI_FIFO_START (3) // FIFO base start -#define PI_FIFO_END (4) // FIFO base end -#define PI_FIFO_PTR (5) // FIFO current write pointer - -#define PI_RESETCODE (9) // reset code, used by OSReset - -// PI Interrupt causes. -#define PI_INTRPT_ERR (0x1) // GP runtime error -#define PI_INTRPT_RSW (0x2) // reset switch -#define PI_INTRPT_DVD (0x4) // DVD/DI interrupt -#define PI_INTRPT_SI (0x8) // serial/controller interrupt -#define PI_INTRPT_EXI (0x10) // external mem interrupt -#define PI_INTRPT_AI (0x20) // audio streaming interrupt -#define PI_INTRPT_DSP (0x40) // digital signal proc interrupt -#define PI_INTRPT_MEM (0x80) // memory interface interrupt -#define PI_INTRPT_VI (0x100) // video interface interrupt -#define PI_INTRPT_PE_TOKEN (0x200) // pixel engine token -#define PI_INTRPT_PE_FINISH (0x400) // pixel engine finish -#define PI_INTRPT_CP (0x800) // command FIFO -#define PI_INTRPT_DEBUG (0x1000) // external debugger -#define PI_INTRPT_HSP (0x2000) // high speed port -#define PI_INTRPT_RSWST (0x10000) // reset switch state (1 when pressed) - - -vu16 __MEMRegs[64] : 0xCC004000; - -// offsets for __MEMRegs[i] -#define MEM_PROT_1 (0) // protected region 1 -#define MEM_PROT_2 (2) // protected region 1 -#define MEM_PROT_3 (4) // protected region 1 -#define MEM_PROT_4 (6) // protected region 1 -#define MEM_PROT_TYPE (8) // protection type - -#define MEM_INTRPT_MASK (14) // interrupt mask -#define MEM_INTRPT_SRC (15) // interrupt cause -#define MEM_INTRPT_FLAG (16) // set when interrupt happens -#define MEM_INTRPT_ADDR_LO (17) // address that caused interrupt -#define MEM_INTRPT_ADDR_HI (18) // address that caused interrupt - -#define MEM_UNK_FLAG (20) // unknown memory flag, set in __OSInitMemoryProtection - -vu16 __DSPRegs[32] : 0xCC005000; - // offsets for __DSPRegs[i] #define DSP_MAILBOX_IN_HI (0) #define DSP_MAILBOX_IN_LO (1) @@ -146,92 +109,6 @@ vu16 __DSPRegs[32] : 0xCC005000; #define DSP_DMA_CONTROL_LEN (27) #define DSP_DMA_BYTES_LEFT (29) +#define DSP_DMA_START_FLAG (0x8000) // set to start DSP -vu32 __DIRegs[16] : 0xCC006000; - -// offsets for __DIRegs[i] -#define DI_STATUS (0) -#define DI_COVER_STATUS (1) // cover status - 0=normal, 1=interrupt/open -#define DI_CMD_BUF_0 (2) // command buffer 0 -#define DI_CMD_BUF_1 (3) // command buffer 1 -#define DI_CMD_BUF_2 (4) // command buffer 2 -#define DI_DMA_MEM_ADDR (5) // DMA address -#define DI_DMA_LENGTH (6) // transfer length address -#define DI_CONTROL (7) -#define DI_MM_BUF (8) // Main memory buffer -#define DI_CONFIG (9) - -vu32 __SIRegs[64] : 0xCC006400; - -// offsets for __SIRegs[i] -// Channel 0/Joy-channel 1 -#define SI_CHAN_0_BUF (0) // output buffer -#define SI_CHAN_0_BTN_1 (1) // button 1 -#define SI_CHAN_0_BTN_2 (2) // button 2 -// Channel 1/Joy-channel 2 -#define SI_CHAN_1_BUF (3) // output buffer -#define SI_CHAN_1_BTN_1 (4) // button 1 -#define SI_CHAN_1_BTN_2 (5) // button 2 -// Channel 2/Joy-channel 3 -#define SI_CHAN_2_BUF (6) // output buffer -#define SI_CHAN_2_BTN_1 (7) // button 1 -#define SI_CHAN_2_BTN_2 (8) // button 2 -// Channel 3/Joy-channel 4 -#define SI_CHAN_3_BUF (9) // output buffer -#define SI_CHAN_3_BTN_1 (10) // button 1 -#define SI_CHAN_3_BTN_2 (11) // button 2 - -#define SI_POLL (12) -#define SI_CC_STAT (13) // communication control status -#define SI_STAT (14) -#define SI_EXI_LOCK (15) // exi clock lock - -#define SI_IO_BUFFER (32) // start of buffer (32 to 63) - -vu32 __EXIRegs[16] : 0xCC006800; - -// offsets for __EXIRegs[i] -// Channel 0 -#define EXI_CHAN_0_STAT (0) // parameters/status -#define EXI_CHAN_0_DMA_ADDR (1) // DMA start address -#define EXI_CHAN_0_LEN (2) // DMA transfer length -#define EXI_CHAN_0_CONTROL (3) // control register -#define EXI_CHAN_0_IMM (4) // immediate data -// Channel 1 -#define EXI_CHAN_1_STAT (5) // parameters/status -#define EXI_CHAN_1_DMA_ADDR (6) // DMA start address -#define EXI_CHAN_1_LEN (7) // DMA transfer length -#define EXI_CHAN_1_CONTROL (8) // control register -#define EXI_CHAN_1_IMM (9) // immediate data -// Channel 2 -#define EXI_CHAN_2_STAT (10) // parameters/status -#define EXI_CHAN_2_DMA_ADDR (11) // DMA start address -#define EXI_CHAN_2_LEN (12) // DMA transfer length -#define EXI_CHAN_2_CONTROL (13) // control register -#define EXI_CHAN_2_IMM (14) // immediate data - - -vu32 __AIRegs[8] : 0xCC006C00; - -// offsets for __AIRegs[i] -#define AI_CONTROL (0) // control -#define AI_VOLUME (1) // volume -#define AI_SAMPLE_COUNTER (2) // number of stereo samples output -#define AI_INTRPT_TIMING (3) // interrupt timing - -#else -#define __VIRegs ((vu16*)0xCC002000) -#define __PIRegs ((vu32*)0xCC003000) -#define __MEMRegs ((vu16*)0xCC004000) -#define __DSPRegs ((vu16*)0xCC005000) -#define __DIRegs ((vu32*)0xCC006000) -#define __SIRegs ((vu32*)0xCC006400) -#define __EXIRegs ((vu32*)0xCC006800) -#define __AIRegs ((vu32*)0xCC006C00) #endif - -#ifdef __cplusplus -} -#endif - -#endif // _DOLPHIN_HW_REGS diff --git a/include/dolphin/os/OSFont.h b/include/dolphin/os/OSFont.h index 99238bad..fecf3dc4 100644 --- a/include/dolphin/os/OSFont.h +++ b/include/dolphin/os/OSFont.h @@ -1,7 +1,7 @@ -#ifndef _DOLPHIN_OSFONT -#define _DOLPHIN_OSFONT +#ifndef _DOLPHIN_OSFONT_H_ +#define _DOLPHIN_OSFONT_H_ -#include +#include #ifdef __cplusplus extern "C" { @@ -9,20 +9,47 @@ extern "C" { #define OS_FONT_ENCODE_ANSI 0u #define OS_FONT_ENCODE_SJIS 1u -#define OS_FONT_ENCODE_UTF8 3u // UTF-8 [RFC 3629] -#define OS_FONT_ENCODE_UTF16 4u // UTF-16BE [RFC 2781] -#define OS_FONT_ENCODE_UTF32 5u // UTF-32 -#define OS_FONT_ENCODE_MAX 5u -#define OS_FONT_ENCODE_VOID 0xffffu +#define OS_FONT_SIZE_ANSI (288 + 131072) // 9 sheets +#define OS_FONT_SIZE_SJIS (3840 + 1179648) // 1 sheet +#define OS_FONT_ROM_SIZE_ANSI 0x03000 +#define OS_FONT_ROM_SIZE_SJIS 0x4D000 -#define OS_FONT_PROPORTIONAL FALSE -#define OS_FONT_FIXED TRUE +typedef struct OSFontHeader +{ + /*0x00*/ u16 fontType; + u16 firstChar; + u16 lastChar; + u16 invalChar; + /*0x08*/ u16 ascent; + u16 descent; + u16 width; + u16 leading; + /*0x10*/ u16 cellWidth; + u16 cellHeight; + /*0x14*/ u32 sheetSize; + /*0x18*/ u16 sheetFormat; + u16 sheetColumn; + u16 sheetRow; + u16 sheetWidth; + /*0x20*/ u16 sheetHeight; + u16 widthTable; + u32 sheetImage; + u32 sheetFullSize; + u8 c0; + u8 c1; + u8 c2; + u8 c3; +} OSFontHeader; u16 OSGetFontEncode(void); -u16 OSSetFontEncode(u16 encode); +BOOL OSInitFont(OSFontHeader *fontData); +u32 OSLoadFont(OSFontHeader *fontData, void *temp); +char *OSGetFontTexture(char *string, void **image, s32 *x, s32 *y, s32 *width); +char *OSGetFontWidth(char *string, s32 *width); +char *OSGetFontTexel(char *string, void *image, s32 pos, s32 stride, s32 *width); #ifdef __cplusplus } #endif -#endif // _DOLPHIN_OSFONT +#endif diff --git a/src/Dolphin/os/OSReboot.c b/src/Dolphin/os/OSReboot.c index 167fbb2d..77fb8f04 100644 --- a/src/Dolphin/os/OSReboot.c +++ b/src/Dolphin/os/OSReboot.c @@ -1,6 +1,8 @@ +#include "dolphin/dvd.h" #include "dolphin/os.h" #include "dolphin/os/OSBootInfo.h" -#include "dolphin/dvd.h" +#include "dolphin/os/OSContext.h" +#include "dolphin/os/OSInterrupt.h" typedef struct ApploaderHeader { // total size: 0x20 @@ -11,6 +13,17 @@ typedef struct ApploaderHeader { u32 reserved2; // offset 0x1C, size 0x4 } ApploaderHeader; +struct { + // total size: 0x1C + int valid; // offset 0x0, size 0x4 + unsigned long restartCode; // offset 0x4, size 0x4 + unsigned long bootDol; // offset 0x8, size 0x4 + void* regionStart; // offset 0xC, size 0x4 + void* regionEnd; // offset 0x10, size 0x4 + int argsUseDefault; // offset 0x14, size 0x4 + void* argsAddr; // offset 0x18, size 0x4 +} __OSRebootParams; // size: 0x1C, address: 0x0 + static ApploaderHeader Header; extern void* __OSSavedRegionStart; @@ -19,12 +32,22 @@ extern void* __OSSavedRegionEnd; static void* SaveStart = NULL; static void* SaveEnd = NULL; +volatile u8 DAT_800030e2 : 0x800030e2; + extern u32 BOOT_REGION_START AT_ADDRESS(0x812FDFF0); //(*(u32 *)0x812fdff0) extern u32 BOOT_REGION_END AT_ADDRESS(0x812FDFEC); //(*(u32 *)0x812fdfec) +extern u32 UNK_HOT_RESET1 AT_ADDRESS(0x817ffff8); +extern u32 UNK_HOT_RESET2 AT_ADDRESS(0x817ffffc); + extern u32 __OSIsGcam; static BOOL Prepared = FALSE; +extern void __DVDPrepareResetAsync(DVDCBCallback callback); +extern BOOL DVDCheckDisk(void); +extern BOOL DVDReadAbsAsyncForBS(DVDCommandBlock* block, void* addr, s32 length, s32 offset, + DVDCBCallback callback); + asm void Run() { // clang-format off nofralloc @@ -37,10 +60,39 @@ asm void Run() { static void Callback() { Prepared = TRUE; } -void ReadApploader(OSTime time1, OSTime time2) { -} +void ReadApploader(OSTime time1, OSTime time2) {} void __OSReboot(u32 resetCode, u32 bootDol) { + // Local variables + OSContext exceptionContext; // r1+0x18 + char* argvToPass; // r1+0x10 + DVDCommandBlock headerCommand; + ApploaderHeader* header = &Header; + + OSDisableInterrupts(); + + UNK_HOT_RESET1 = 0; + UNK_HOT_RESET2 = 0; + DAT_800030e2 = 1; + __OSSavedRegionStart = SaveStart; + __OSSavedRegionEnd = SaveEnd; + OSClearContext(&exceptionContext); + OSSetCurrentContext(&exceptionContext); + DVDInit(); + DVDSetAutoInvalidation(TRUE); + __DVDPrepareResetAsync(Callback); + if (DVDCheckDisk() == FALSE) { + __OSDoHotReset(UNK_HOT_RESET2); + } + + __OSMaskInterrupts(OS_INTERRUPTMASK_PI); + __OSUnmaskInterrupts(0x400); + OSEnableInterrupts(); + + do { + + } while (Prepared == 0); + DVDReadAbsAsyncForBS(&headerCommand, header, sizeof(ApploaderHeader), 0x2440, NULL); } void OSSetSaveRegion(void* start, void* end) {