Decompile bootPhase1

This commit is contained in:
Ryan Dwyer 2022-08-22 19:30:51 +10:00
parent 9da91a226d
commit 83d0268f19
8 changed files with 124 additions and 362 deletions

View File

@ -132,8 +132,7 @@ typedef struct OSThread_s {
/* Thread operations */ /* Thread operations */
extern void osCreateThread(OSThread *, OSId, void (*)(void *), extern void osCreateThread(OSThread *, OSId, void (*)(void *), void *, void *, OSPri);
void *, void *, OSPri);
extern void osDestroyThread(OSThread *); extern void osDestroyThread(OSThread *);
extern void osYieldThread(void); extern void osYieldThread(void);
extern void osStartThread(OSThread *); extern void osStartThread(OSThread *);

View File

@ -152,13 +152,6 @@ SECTIONS
osMemSize = 0x80000318; osMemSize = 0x80000318;
osAppNMIBuffer = 0x8000031c; osAppNMIBuffer = 0x8000031c;
var800902e4 = 0x800902e4; /* for ntsc-beta */
var800902e8 = 0x800902e8; /* for ntsc-beta */
var803f50b8 = 0x803f50b8;
varbc000c02 = 0xbc000c02; /* for ntsc-beta */
getitle0f0155f0_hack = getitle0f0155f0; getitle0f0155f0_hack = getitle0f0155f0;
viGetHeight_hack = viGetHeight; viGetHeight_hack = viGetHeight;

View File

@ -8105,7 +8105,7 @@ void titleTickNintendoLogo(void)
} }
if (joyGetButtonsPressedThisFrame(0, 0xffff)) { if (joyGetButtonsPressedThisFrame(0, 0xffff)) {
if (osResetType == 1 /*warm*/) { if (osResetType == RESETTYPE_WARM) {
g_TitleButtonPressed = true; g_TitleButtonPressed = true;
titleSetNextMode(TITLEMODE_PDLOGO); titleSetNextMode(TITLEMODE_PDLOGO);
} else if (!g_TitleButtonPressed) { } else if (!g_TitleButtonPressed) {
@ -8278,7 +8278,7 @@ void titleTickRareLogo(void)
g_TitleTimer += g_Vars.lvupdate240_60; g_TitleTimer += g_Vars.lvupdate240_60;
if (joyGetButtonsPressedThisFrame(0, 0xffff)) { if (joyGetButtonsPressedThisFrame(0, 0xffff)) {
if (osResetType == 1 /*warm*/) { if (osResetType == RESETTYPE_WARM) {
g_TitleButtonPressed = true; g_TitleButtonPressed = true;
titleSetNextMode(TITLEMODE_PDLOGO); titleSetNextMode(TITLEMODE_PDLOGO);
} else if (!g_TitleButtonPressed) { } else if (!g_TitleButtonPressed) {

View File

@ -3496,6 +3496,9 @@
#define RENDERPASS_XLU 1 #define RENDERPASS_XLU 1
#define RENDERPASS_OPA_POSTBG 2 #define RENDERPASS_OPA_POSTBG 2
#define RESETTYPE_COLD 0
#define RESETTYPE_WARM 1
#define ROOMFLAG_DISABLEDBYSCRIPT 0x0001 #define ROOMFLAG_DISABLEDBYSCRIPT 0x0001
#define ROOMFLAG_HASDYNTEX 0x0002 // Has dynamic textures such as water #define ROOMFLAG_HASDYNTEX 0x0002 // Has dynamic textures such as water
#define ROOMFLAG_ONSCREEN 0x0004 #define ROOMFLAG_ONSCREEN 0x0004
@ -3797,6 +3800,13 @@
#define STACKSIZE_FAULT 0x2000 #define STACKSIZE_FAULT 0x2000
#define STACKSIZE_RESET 0x100 #define STACKSIZE_RESET 0x100
#define STACK_START (0x80400000 \
- STACKSIZE_MAIN \
- STACKSIZE_IDLE \
- STACKSIZE_RMON \
- STACKSIZE_SCHED \
- STACKSIZE_AUDIO)
#define STAGE_MP_RANDOM 0x01 #define STAGE_MP_RANDOM 0x01
#define STAGE_MAIANSOS 0x09 #define STAGE_MAIANSOS 0x09
#define STAGE_TEST_SILO 0x14 #define STAGE_TEST_SILO 0x14

View File

@ -28,7 +28,12 @@ OSMesgQueue *g_SchedCmdQ;
u32 var8008dbcc; u32 var8008dbcc;
OSSched g_Sched; OSSched g_Sched;
OSScClient var8008dca8; OSScClient var8008dca8;
#if VERSION >= VERSION_NTSC_1_0
u32 g_OsMemSize; u32 g_OsMemSize;
#else
u16 *var800902e4;
u16 var800902e8;
#endif
u32 var8005ce00 = 0; u32 var8005ce00 = 0;
u32 var8005ce04 = 0; u32 var8005ce04 = 0;
@ -47,10 +52,6 @@ extern u8 *_dataSegmentStart;
extern u8 *_inflateSegmentStart; extern u8 *_inflateSegmentStart;
extern u8 *_inflateSegmentRomStart; extern u8 *_inflateSegmentRomStart;
extern u8 *_inflateSegmentRomEnd; extern u8 *_inflateSegmentRomEnd;
extern u32 var803f50b8;
extern u16 varbc000c02;
extern u16 *var800902e4;
extern s16 var800902e8;
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
s32 bootGetMemSize(void) s32 bootGetMemSize(void)
@ -59,255 +60,8 @@ s32 bootGetMemSize(void)
} }
#endif #endif
#if VERSION >= VERSION_NTSC_1_0
GLOBAL_ASM(
glabel bootPhase1
/* 16cc: 3c0e8000 */ lui $t6,%hi(osResetType)
/* 16d0: 8dce030c */ lw $t6,%lo(osResetType)($t6)
/* 16d4: 27bdffd8 */ addiu $sp,$sp,-40
/* 16d8: 24010001 */ addiu $at,$zero,0x1
/* 16dc: afbf0024 */ sw $ra,0x24($sp)
/* 16e0: 15c10007 */ bne $t6,$at,.L00001700
/* 16e4: afb00020 */ sw $s0,0x20($sp)
/* 16e8: 3c0f803f */ lui $t7,0x803f
/* 16ec: 8df850b8 */ lw $t8,0x50b8($t7)
/* 16f0: 3c028009 */ lui $v0,%hi(g_OsMemSize)
/* 16f4: 2442dcb4 */ addiu $v0,$v0,%lo(g_OsMemSize)
/* 16f8: 10000008 */ b .L0000171c
/* 16fc: ac580000 */ sw $t8,0x0($v0)
.L00001700:
/* 1700: 3c198000 */ lui $t9,%hi(osMemSize)
/* 1704: 8f390318 */ lw $t9,%lo(osMemSize)($t9)
/* 1708: 3c028009 */ lui $v0,%hi(g_OsMemSize)
/* 170c: 2442dcb4 */ addiu $v0,$v0,%lo(g_OsMemSize)
/* 1710: 3c0a803f */ lui $t2,0x803f
/* 1714: ac590000 */ sw $t9,0x0($v0)
/* 1718: ad5950b8 */ sw $t9,0x50b8($t2)
.L0000171c:
/* 171c: 3c040004 */ lui $a0,%hi(_datazipSegmentRomStart)
/* 1720: 3c0b0005 */ lui $t3,%hi(_datazipSegmentRomEnd)
/* 1724: 3c0c0005 */ lui $t4,%hi(_inflateSegmentRomEnd)
/* 1728: 3c0d0005 */ lui $t5,%hi(_inflateSegmentRomStart)
/* 172c: 25ade850 */ addiu $t5,$t5,%lo(_inflateSegmentRomStart)
/* 1730: 258cfc40 */ addiu $t4,$t4,%lo(_inflateSegmentRomEnd)
/* 1734: 256be850 */ addiu $t3,$t3,%lo(_datazipSegmentRomEnd)
/* 1738: 24849850 */ addiu $a0,$a0,%lo(_datazipSegmentRomStart)
/* 173c: 01644023 */ subu $t0,$t3,$a0
/* 1740: 018d7023 */ subu $t6,$t4,$t5
/* 1744: 010e1821 */ addu $v1,$t0,$t6
/* 1748: 2462ffff */ addiu $v0,$v1,-1
/* 174c: 0440000b */ bltz $v0,.L0000177c
/* 1750: 3c057000 */ lui $a1,%hi(_libSegmentStart)
/* 1754: 3c017000 */ lui $at,0x7000
/* 1758: 3c0f7020 */ lui $t7,0x7020
/* 175c: 01e88023 */ subu $s0,$t7,$t0
/* 1760: 00811825 */ or $v1,$a0,$at
.L00001764:
/* 1764: 0062c021 */ addu $t8,$v1,$v0
/* 1768: 93190000 */ lbu $t9,0x0($t8)
/* 176c: 02024821 */ addu $t1,$s0,$v0
/* 1770: 2442ffff */ addiu $v0,$v0,-1
/* 1774: 0441fffb */ bgez $v0,.L00001764
/* 1778: a1390000 */ sb $t9,0x0($t1)
.L0000177c:
/* 177c: 24a51050 */ addiu $a1,$a1,%lo(_libSegmentStart)
/* 1780: 3c07702c */ lui $a3,0x702c
/* 1784: 3c0a7020 */ lui $t2,0x7020
/* 1788: 01488023 */ subu $s0,$t2,$t0
/* 178c: 34e793e0 */ ori $a3,$a3,0x93e0
/* 1790: 24a52000 */ addiu $a1,$a1,0x2000
/* 1794: 00002025 */ or $a0,$zero,$zero
/* 1798: 3c037028 */ lui $v1,0x7028
.L0000179c:
/* 179c: 00a45821 */ addu $t3,$a1,$a0
/* 17a0: 8d6c0000 */ lw $t4,0x0($t3)
/* 17a4: 24630004 */ addiu $v1,$v1,0x4
/* 17a8: 0067082b */ sltu $at,$v1,$a3
/* 17ac: 24840004 */ addiu $a0,$a0,0x4
/* 17b0: 1420fffa */ bnez $at,.L0000179c
/* 17b4: ac6cfffc */ sw $t4,-0x4($v1)
/* 17b8: 3c047028 */ lui $a0,0x7028
/* 17bc: 0c0005ab */ jal segInflate
/* 17c0: 3c068030 */ lui $a2,0x8030
/* 17c4: 3c058006 */ lui $a1,%hi(_dataSegmentStart)
/* 17c8: 24a59fe0 */ addiu $a1,$a1,%lo(_dataSegmentStart)
/* 17cc: 02002025 */ or $a0,$s0,$zero
/* 17d0: 0c0005ab */ jal segInflate
/* 17d4: 3c068030 */ lui $a2,0x8030
/* 17d8: 3c0da000 */ lui $t5,0xa000
/* 17dc: 8dae02e8 */ lw $t6,0x2e8($t5)
/* 17e0: 3c01c86e */ lui $at,0xc86e
/* 17e4: 34212000 */ ori $at,$at,0x2000
/* 17e8: 11c10003 */ beq $t6,$at,.L000017f8
/* 17ec: 24040001 */ addiu $a0,$zero,0x1
.L000017f0:
/* 17f0: 1000ffff */ b .L000017f0
/* 17f4: 00000000 */ nop
.L000017f8:
/* 17f8: 0c00058d */ jal tlbUnmapRange
/* 17fc: 2405001f */ addiu $a1,$zero,0x1f
/* 1800: 3c048006 */ lui $a0,%hi(g_StackLeftAddrs)
/* 1804: 3c038006 */ lui $v1,%hi(g_StackRightAddrs)
/* 1808: 3c028006 */ lui $v0,%hi(g_StackRightAddrs+0x1c)
/* 180c: 2442ce48 */ addiu $v0,$v0,%lo(g_StackRightAddrs+0x1c)
/* 1810: 2463ce2c */ addiu $v1,$v1,%lo(g_StackRightAddrs)
/* 1814: 2484ce10 */ addiu $a0,$a0,%lo(g_StackLeftAddrs)
.L00001818:
/* 1818: 24630004 */ addiu $v1,$v1,0x4
/* 181c: 24840004 */ addiu $a0,$a0,0x4
/* 1820: ac80fffc */ sw $zero,-0x4($a0)
/* 1824: 1462fffc */ bne $v1,$v0,.L00001818
/* 1828: ac60fffc */ sw $zero,-0x4($v1)
/* 182c: 0c0016d8 */ jal osInitialize
/* 1830: 00000000 */ nop
/* 1834: 0c012048 */ jal osWritebackDCacheAll
/* 1838: 00000000 */ nop
/* 183c: 3c048000 */ lui $a0,0x8000
/* 1840: 0c012054 */ jal osInvalICache
/* 1844: 24054000 */ addiu $a1,$zero,0x4000
/* 1848: 0c012074 */ jal __osGetFpcCsr
/* 184c: 00000000 */ nop
/* 1850: 0c012078 */ jal __osSetFpcCsr
/* 1854: 34440e80 */ ori $a0,$v0,0xe80
/* 1858: 24040003 */ addiu $a0,$zero,0x3
/* 185c: 0c00062b */ jal bootAllocateStack
/* 1860: 34059800 */ dli $a1,0x9800
/* 1864: 3c108009 */ lui $s0,%hi(g_MainThread)
/* 1868: 2610d6d0 */ addiu $s0,$s0,%lo(g_MainThread)
/* 186c: 3c067000 */ lui $a2,%hi(bootPhase2)
/* 1870: 2409000a */ addiu $t1,$zero,0xa
/* 1874: afa90014 */ sw $t1,0x14($sp)
/* 1878: 24c61aa4 */ addiu $a2,$a2,%lo(bootPhase2)
/* 187c: 02002025 */ or $a0,$s0,$zero
/* 1880: 24050003 */ addiu $a1,$zero,0x3
/* 1884: 00003825 */ or $a3,$zero,$zero
/* 1888: 0c000fb8 */ jal osCreateThread
/* 188c: afa20010 */ sw $v0,0x10($sp)
/* 1890: 0c01207c */ jal osStartThread
/* 1894: 02002025 */ or $a0,$s0,$zero
/* 1898: 8fbf0024 */ lw $ra,0x24($sp)
/* 189c: 8fb00020 */ lw $s0,0x20($sp)
/* 18a0: 27bd0028 */ addiu $sp,$sp,0x28
/* 18a4: 03e00008 */ jr $ra
/* 18a8: 00000000 */ nop
);
#else
GLOBAL_ASM(
glabel bootPhase1
/* 1720: 3c040003 */ lui $a0,0x3
/* 1724: 3c0e0004 */ lui $t6,0x4
/* 1728: 3c0f0004 */ lui $t7,0x4
/* 172c: 3c180004 */ lui $t8,0x4
/* 1730: 27182850 */ addiu $t8,$t8,0x2850
/* 1734: 25ef3c40 */ addiu $t7,$t7,0x3c40
/* 1738: 25ce2850 */ addiu $t6,$t6,0x2850
/* 173c: 24840850 */ addiu $a0,$a0,0x850
/* 1740: 01c44023 */ subu $t0,$t6,$a0
/* 1744: 01f8c823 */ subu $t9,$t7,$t8
/* 1748: 01191821 */ addu $v1,$t0,$t9
/* 174c: 27bdffd8 */ addiu $sp,$sp,-40
/* 1750: 2462ffff */ addiu $v0,$v1,-1
/* 1754: afbf0024 */ sw $ra,0x24($sp)
/* 1758: 0440000b */ bltz $v0,.L00001788
/* 175c: afb00020 */ sw $s0,0x20($sp)
/* 1760: 3c017000 */ lui $at,0x7000
/* 1764: 3c097020 */ lui $t1,0x7020
/* 1768: 01288023 */ subu $s0,$t1,$t0
/* 176c: 00811825 */ or $v1,$a0,$at
.L00001770:
/* 1770: 00625021 */ addu $t2,$v1,$v0
/* 1774: 914b0000 */ lbu $t3,0x0($t2)
/* 1778: 02026021 */ addu $t4,$s0,$v0
/* 177c: 2442ffff */ addiu $v0,$v0,-1
/* 1780: 0441fffb */ bgez $v0,.L00001770
/* 1784: a18b0000 */ sb $t3,0x0($t4)
.L00001788:
/* 1788: 3c057000 */ lui $a1,0x7000
/* 178c: 24a51050 */ addiu $a1,$a1,0x1050
/* 1790: 3c0d7020 */ lui $t5,0x7020
/* 1794: 3c07702c */ lui $a3,0x702c
/* 1798: 34e793e0 */ ori $a3,$a3,0x93e0
/* 179c: 01a88023 */ subu $s0,$t5,$t0
/* 17a0: 24a52000 */ addiu $a1,$a1,0x2000
/* 17a4: 00002025 */ move $a0,$zero
/* 17a8: 3c037028 */ lui $v1,0x7028
.L000017ac:
/* 17ac: 00a47021 */ addu $t6,$a1,$a0
/* 17b0: 8dcf0000 */ lw $t7,0x0($t6)
/* 17b4: 24630004 */ addiu $v1,$v1,0x4
/* 17b8: 0067082b */ sltu $at,$v1,$a3
/* 17bc: 24840004 */ addiu $a0,$a0,0x4
/* 17c0: 1420fffa */ bnez $at,.L000017ac
/* 17c4: ac6ffffc */ sw $t7,-0x4($v1)
/* 17c8: 3c047028 */ lui $a0,0x7028
/* 17cc: 0c0005c3 */ jal segInflate
/* 17d0: 3c068030 */ lui $a2,0x8030
/* 17d4: 3c058006 */ lui $a1,0x8006
/* 17d8: 24a5b760 */ addiu $a1,$a1,-18592
/* 17dc: 02002025 */ move $a0,$s0
/* 17e0: 0c0005c3 */ jal segInflate
/* 17e4: 3c068030 */ lui $a2,0x8030
/* 17e8: 24040001 */ li $a0,0x1
/* 17ec: 0c00059c */ jal tlbUnmapRange
/* 17f0: 2405001f */ li $a1,0x1f
/* 17f4: 3c048006 */ lui $a0,0x8006
/* 17f8: 3c038006 */ lui $v1,0x8006
/* 17fc: 3c028006 */ lui $v0,0x8006
/* 1800: 2442e5c8 */ addiu $v0,$v0,-6712
/* 1804: 2463e5ac */ addiu $v1,$v1,-6740
/* 1808: 2484e590 */ addiu $a0,$a0,-6768
.L0000180c:
/* 180c: 24630004 */ addiu $v1,$v1,0x4
/* 1810: 24840004 */ addiu $a0,$a0,0x4
/* 1814: ac80fffc */ sw $zero,-0x4($a0)
/* 1818: 1462fffc */ bne $v1,$v0,.L0000180c
/* 181c: ac60fffc */ sw $zero,-0x4($v1)
/* 1820: 0c001728 */ jal osInitialize
/* 1824: 00000000 */ nop
/* 1828: 0c01253c */ jal osWritebackDCacheAll
/* 182c: 00000000 */ nop
/* 1830: 3c048000 */ lui $a0,0x8000
/* 1834: 0c012548 */ jal osInvalICache
/* 1838: 24054000 */ li $a1,0x4000
/* 183c: 0c012568 */ jal __osGetFpcCsr
/* 1840: 00000000 */ nop
/* 1844: 0c01256c */ jal __osSetFpcCsr
/* 1848: 34440e80 */ ori $a0,$v0,0xe80
/* 184c: 3c03bc00 */ lui $v1,0xbc00
/* 1850: 34630c02 */ ori $v1,$v1,0xc02
/* 1854: 3c018009 */ lui $at,0x8009
/* 1858: ac2302e4 */ sw $v1,0x2e4($at)
/* 185c: 3c018009 */ lui $at,0x8009
/* 1860: 240a4040 */ li $t2,0x4040
/* 1864: a42a02e8 */ sh $t2,0x2e8($at)
/* 1868: 240b4040 */ li $t3,0x4040
/* 186c: a46b0000 */ sh $t3,0x0($v1)
/* 1870: 24040003 */ li $a0,0x3
/* 1874: 0c000631 */ jal bootAllocateStack
/* 1878: 34059800 */ li $a1,0x9800
/* 187c: 3c108009 */ lui $s0,0x8009
/* 1880: 2610fd00 */ addiu $s0,$s0,-768
/* 1884: 3c067000 */ lui $a2,0x7000
/* 1888: 240c000a */ li $t4,0xa
/* 188c: afac0014 */ sw $t4,0x14($sp)
/* 1890: 24c61b04 */ addiu $a2,$a2,0x1b04
/* 1894: 02002025 */ move $a0,$s0
/* 1898: 24050003 */ li $a1,0x3
/* 189c: 00003825 */ move $a3,$zero
/* 18a0: 0c00107c */ jal osCreateThread
/* 18a4: afa20010 */ sw $v0,0x10($sp)
/* 18a8: 0c012570 */ jal osStartThread
/* 18ac: 02002025 */ move $a0,$s0
/* 18b0: 8fbf0024 */ lw $ra,0x24($sp)
/* 18b4: 8fb00020 */ lw $s0,0x20($sp)
/* 18b8: 27bd0028 */ addiu $sp,$sp,0x28
/* 18bc: 03e00008 */ jr $ra
/* 18c0: 00000000 */ nop
);
#endif
u32 __osGetFpcCsr(void); u32 __osGetFpcCsr(void);
void __osSetFpcCsr(u32 arg0); u32 __osSetFpcCsr(u32 arg0);
/** /**
* Prepares the inflate, .data and lib segments, then creates and starts the * Prepares the inflate, .data and lib segments, then creates and starts the
@ -318,93 +72,104 @@ void __osSetFpcCsr(u32 arg0);
* in RAM thanks to this but need to be relocated, and .data and lib need to be * in RAM thanks to this but need to be relocated, and .data and lib need to be
* unzipped too. * unzipped too.
*/ */
// Mismatch: Reordered instructions. void bootPhase1(void)
// Remove U from 75000U for another interesting codegen. {
//void bootPhase1(void) s32 datacomplen;
//{ s32 inflatelen;
// s32 datacomplen; u8 *dataziprom;
// s32 inflatelen; u8 *datazipram;
// u32 dataziprom; u32 *libram;
// u32 datazipram; u32 *libzipram;
// u32 libram; u32 dataram;
// u32 libzipram; u32 copylen;
// u32 dataram; s32 i;
// u32 copylen; s32 numlibwords;
// s32 i; u32 flags;
//
//#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
// if (osResetType == 1) { if (osResetType == RESETTYPE_WARM) {
// g_OsMemSize = *(u32 *)0x803f50b8; g_OsMemSize = *(u32 *)(STACK_START - 8);
// } else { } else {
// *(u32 *)0x803f50b8 = g_OsMemSize = osMemSize; *(u32 *)(STACK_START - 8) = g_OsMemSize = osMemSize;
// } }
//#endif #endif
//
// // Copy compressed .data and inflate segments // Copy compressed .data and inflate segments
// // .data is copied from ROM to 0x701eb000 - 0x70200000 // .data is copied from ROM to 0x701eb000 - 0x70200000
// // inflate is copied from ROM to 0x70200000 - 0x702013f0 // inflate is copied from ROM to 0x70200000 - 0x702013f0
// datacomplen = (s32)&_datazipSegmentRomEnd - (s32)&_datazipSegmentRomStart; datacomplen = (s32) &_datazipSegmentRomEnd - (s32) &_datazipSegmentRomStart;
// inflatelen = (s32)&_inflateSegmentRomEnd - (s32)&_inflateSegmentRomStart; #if VERSION >= VERSION_NTSC_1_0
// copylen = datacomplen + inflatelen; if (1);
// libram = (u32)&_libSegmentStart + 0x2000; #endif
// libzipram = 0x70280000; inflatelen = (s32) &_inflateSegmentRomEnd - (s32) &_inflateSegmentRomStart;
// dataziprom = (u32)&_datazipSegmentRomStart | 0x70000000; copylen = datacomplen + inflatelen;
// datazipram = 0x70200000 - datacomplen; libram = (u32 *) ((u32) &_libSegmentStart + 0x2000);
// dataram = (u32)&_dataSegmentStart; libzipram = (u32 *) 0x70280000;
// dataziprom = (u8 *) ((s32) &_datazipSegmentRomStart | 0x70000000);
// for (i = copylen - 1; i >= 0; i--) { datazipram = (u8 *) (0x70200000 - datacomplen);
// ((u8 *)datazipram)[i] = ((u8 *)dataziprom)[i]; dataram = (u32) &_dataSegmentStart;
// }
// for (i = copylen - 1; i >= 0; i--) {
// // Copy the compressed part of lib to 0x70280000. datazipram[i] = dataziprom[i];
// // lib is compressed from 2KB onwards. }
// // It's assumed that lib's compressed length is less than 75000 words.
// // This is fine, as it's about half that. // Copy the compressed part of lib to 0x70280000.
// for (i = 0; i < 75000U; i++) { // lib is compressed from 2KB onwards.
// ((u32 *)libzipram)[i] = ((u32 *)libram)[i]; // It's assumed that lib's compressed length is less than 75000 words.
// } // This is fine, as it's about half that.
// numlibwords = 75000;
// // Inflate compressed part of lib
// segInflate((void *) libzipram, (void *) libram, (void *) 0x80300000); for (i = 0; i < numlibwords; i++) {
// libzipram[i] = libram[i];
// // Inflate .data }
// segInflate((void *) datazipram, (void *) dataram, (void *) 0x80300000);
// // Inflate compressed part of lib
//#if PIRACYCHECKS segInflate((void *) libzipram, (void *) libram, (void *) 0x80300000);
// if (IO_READ(0xa00002e8) != 0xc86e2000) {
// while (1); // Inflate .data
// } segInflate((void *) datazipram, (void *) dataram, (void *) 0x80300000);
//#endif
// #if PIRACYCHECKS
// tlbUnmapRange(1, NTLBENTRIES); if (IO_READ(0xa00002e8) != 0xc86e2000) {
// while (1);
// // Clear the stack allocation pointers }
// for (i = 0; i < ARRAYCOUNT(g_StackLeftAddrs); i++) { #endif
// g_StackLeftAddrs[i] = NULL;
// g_StackRightAddrs[i] = NULL; tlbUnmapRange(1, NTLBENTRIES);
// }
// // Clear the stack allocation pointers
// osInitialize(); for (i = 0; i < ARRAYCOUNT(g_StackLeftAddrs); i++) {
// g_StackLeftAddrs[i] = NULL;
// // Write all data memory cache into physical memory g_StackRightAddrs[i] = NULL;
// osWritebackDCacheAll(); }
//
// // Invalidate all instruction cache osInitialize();
// osInvalICache((void *) 0x80000000, ICACHE_SIZE);
// // Write all data memory cache into physical memory
// // Enable inexact operation, overflow, division by zero and invalid operation osWritebackDCacheAll();
// __osSetFpcCsr(__osGetFpcCsr() | (FPCSR_EI | FPCSR_EO | FPCSR_EZ | FPCSR_EV));
// // Invalidate all instruction cache
//#if VERSION < VERSION_NTSC_1_0 osInvalICache((void *) 0x80000000, ICACHE_SIZE);
// var800902e4 = &varbc000c02;
// var800902e8 = 0x4040; // Configure the floating point unit
// varbc000c02 = 0x4040; flags = __osGetFpcCsr();
//#endif flags |= FPCSR_EI; // enable inexact operation
// flags |= FPCSR_EO; // enable overflow
// // Create and start the main thread flags |= FPCSR_EZ; // enable division by zero
// osCreateThread(&g_MainThread, THREAD_MAIN, bootPhase2, NULL, bootAllocateStack(THREAD_MAIN, STACKSIZE_MAIN), THREADPRI_MAIN); flags |= FPCSR_EV; // enable invalid operation
// osStartThread(&g_MainThread);
//} __osSetFpcCsr(flags);
#if VERSION < VERSION_NTSC_1_0
var800902e4 = (void *) 0xbc000c02;
var800902e8 = 0x4040;
*(s16 *) 0xbc000c02 = 0x4040;
#endif
// Create and start the main thread
osCreateThread(&g_MainThread, THREAD_MAIN, bootPhase2, NULL, bootAllocateStack(THREAD_MAIN, STACKSIZE_MAIN), THREADPRI_MAIN);
osStartThread(&g_MainThread);
}
/** /**
* Allocate stack space for the given thread ID. * Allocate stack space for the given thread ID.

View File

@ -3,6 +3,7 @@
#include <os_internal.h> #include <os_internal.h>
#include <R4300.h> #include <R4300.h>
#include <rcp.h> #include <rcp.h>
#include "constants.h"
typedef struct { typedef struct {
unsigned int inst1; unsigned int inst1;
@ -57,7 +58,7 @@ void osInitialize(void)
osClockRate = osClockRate * 3 / 4; osClockRate = osClockRate * 3 / 4;
#endif #endif
if (osResetType == 0 /*cold reset*/) { if (osResetType == RESETTYPE_COLD) {
bzero(&osAppNMIBuffer, 0x40); bzero(&osAppNMIBuffer, 0x40);
} }

View File

@ -2,6 +2,7 @@
#include <os_internal.h> #include <os_internal.h>
#include <R4300.h> #include <R4300.h>
#include <rcp.h> #include <rcp.h>
#include "constants.h"
#include "versions.h" #include "versions.h"
/** /**
@ -52,7 +53,7 @@ void osInitialize2()
osClockRate = osClockRate * 3 / 4; osClockRate = osClockRate * 3 / 4;
if (osResetType == 0 /*cold reset */) { if (osResetType == RESETTYPE_COLD) {
bzero(osAppNMIBuffer, OS_APP_NMI_BUFSIZE); bzero(osAppNMIBuffer, OS_APP_NMI_BUFSIZE);
} }

View File

@ -106,13 +106,6 @@ extern u32 *g_VmZipTable;
#define MAX_LOADED_PAGES 268 #define MAX_LOADED_PAGES 268
#define VM_MEMORY_END (0x80400000 \
- STACKSIZE_MAIN \
- STACKSIZE_IDLE \
- STACKSIZE_RMON \
- STACKSIZE_SCHED \
- STACKSIZE_AUDIO - 8)
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
GLOBAL_ASM( GLOBAL_ASM(
glabel vmInit glabel vmInit
@ -818,8 +811,8 @@ glabel vmInit
// sp1474 = t8 + 1; // sp1474 = t8 + 1;
// //
// g_VmRamEnd = 0x7f000000 + PAGE_SIZE * g_VmNumPages; // g_VmRamEnd = 0x7f000000 + PAGE_SIZE * g_VmNumPages;
// g_VmStateTableEnd = VM_MEMORY_END; // g_VmStateTableEnd = STACK_START;
// g_VmStateTable = (u32 *)(VM_MEMORY_END - g_VmNumPages * 8); // g_VmStateTable = (u32 *)(STACK_START - g_VmNumPages * 8);
// g_VmZipTable = (u32 *)(((u32)g_VmStateTable - (sp1474 + 5) * 4) & ~0xf); // g_VmZipTable = (u32 *)(((u32)g_VmStateTable - (sp1474 + 5) * 4) & ~0xf);
// //
// // Load gamezips pointer list // // Load gamezips pointer list
@ -864,7 +857,7 @@ glabel vmInit
// g_Is4Mb = false; // g_Is4Mb = false;
// //
// t8 = (u32)((&_gameSegmentEnd - &_gameSegmentStart) + 0xfff) / PAGE_SIZE; // t8 = (u32)((&_gameSegmentEnd - &_gameSegmentStart) + 0xfff) / PAGE_SIZE;
// s7 = (u8 *)VM_MEMORY_END; // s7 = (u8 *)STACK_START;
// gameseg = (u8 *)(((u32)s7 - ALIGN64(&_gameSegmentEnd - &_gameSegmentStart)) & 0xfffe0000); // gameseg = (u8 *)(((u32)s7 - ALIGN64(&_gameSegmentEnd - &_gameSegmentStart)) & 0xfffe0000);
// sp1474 = t8 + 1; // sp1474 = t8 + 1;
// //