|
|
|
@@ -28,7 +28,12 @@ OSMesgQueue *g_SchedCmdQ;
|
|
|
|
|
u32 var8008dbcc;
|
|
|
|
|
OSSched g_Sched;
|
|
|
|
|
OSScClient var8008dca8;
|
|
|
|
|
#if VERSION >= VERSION_NTSC_1_0
|
|
|
|
|
u32 g_OsMemSize;
|
|
|
|
|
#else
|
|
|
|
|
u16 *var800902e4;
|
|
|
|
|
u16 var800902e8;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
u32 var8005ce00 = 0;
|
|
|
|
|
u32 var8005ce04 = 0;
|
|
|
|
@@ -47,10 +52,6 @@ extern u8 *_dataSegmentStart;
|
|
|
|
|
extern u8 *_inflateSegmentStart;
|
|
|
|
|
extern u8 *_inflateSegmentRomStart;
|
|
|
|
|
extern u8 *_inflateSegmentRomEnd;
|
|
|
|
|
extern u32 var803f50b8;
|
|
|
|
|
extern u16 varbc000c02;
|
|
|
|
|
extern u16 *var800902e4;
|
|
|
|
|
extern s16 var800902e8;
|
|
|
|
|
|
|
|
|
|
#if VERSION >= VERSION_NTSC_1_0
|
|
|
|
|
s32 bootGetMemSize(void)
|
|
|
|
@@ -59,255 +60,8 @@ s32 bootGetMemSize(void)
|
|
|
|
|
}
|
|
|
|
|
#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);
|
|
|
|
|
void __osSetFpcCsr(u32 arg0);
|
|
|
|
|
u32 __osSetFpcCsr(u32 arg0);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* unzipped too.
|
|
|
|
|
*/
|
|
|
|
|
// Mismatch: Reordered instructions.
|
|
|
|
|
// Remove U from 75000U for another interesting codegen.
|
|
|
|
|
//void bootPhase1(void)
|
|
|
|
|
//{
|
|
|
|
|
// s32 datacomplen;
|
|
|
|
|
// s32 inflatelen;
|
|
|
|
|
// u32 dataziprom;
|
|
|
|
|
// u32 datazipram;
|
|
|
|
|
// u32 libram;
|
|
|
|
|
// u32 libzipram;
|
|
|
|
|
// u32 dataram;
|
|
|
|
|
// u32 copylen;
|
|
|
|
|
// s32 i;
|
|
|
|
|
//
|
|
|
|
|
//#if VERSION >= VERSION_NTSC_1_0
|
|
|
|
|
// if (osResetType == 1) {
|
|
|
|
|
// g_OsMemSize = *(u32 *)0x803f50b8;
|
|
|
|
|
// } else {
|
|
|
|
|
// *(u32 *)0x803f50b8 = g_OsMemSize = osMemSize;
|
|
|
|
|
// }
|
|
|
|
|
//#endif
|
|
|
|
|
//
|
|
|
|
|
// // Copy compressed .data and inflate segments
|
|
|
|
|
// // .data is copied from ROM to 0x701eb000 - 0x70200000
|
|
|
|
|
// // inflate is copied from ROM to 0x70200000 - 0x702013f0
|
|
|
|
|
// datacomplen = (s32)&_datazipSegmentRomEnd - (s32)&_datazipSegmentRomStart;
|
|
|
|
|
// inflatelen = (s32)&_inflateSegmentRomEnd - (s32)&_inflateSegmentRomStart;
|
|
|
|
|
// copylen = datacomplen + inflatelen;
|
|
|
|
|
// libram = (u32)&_libSegmentStart + 0x2000;
|
|
|
|
|
// libzipram = 0x70280000;
|
|
|
|
|
// dataziprom = (u32)&_datazipSegmentRomStart | 0x70000000;
|
|
|
|
|
// datazipram = 0x70200000 - datacomplen;
|
|
|
|
|
// dataram = (u32)&_dataSegmentStart;
|
|
|
|
|
//
|
|
|
|
|
// for (i = copylen - 1; i >= 0; i--) {
|
|
|
|
|
// ((u8 *)datazipram)[i] = ((u8 *)dataziprom)[i];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // Copy the compressed part of lib to 0x70280000.
|
|
|
|
|
// // 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.
|
|
|
|
|
// for (i = 0; i < 75000U; i++) {
|
|
|
|
|
// ((u32 *)libzipram)[i] = ((u32 *)libram)[i];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // Inflate compressed part of lib
|
|
|
|
|
// segInflate((void *) libzipram, (void *) libram, (void *) 0x80300000);
|
|
|
|
|
//
|
|
|
|
|
// // Inflate .data
|
|
|
|
|
// segInflate((void *) datazipram, (void *) dataram, (void *) 0x80300000);
|
|
|
|
|
//
|
|
|
|
|
//#if PIRACYCHECKS
|
|
|
|
|
// if (IO_READ(0xa00002e8) != 0xc86e2000) {
|
|
|
|
|
// while (1);
|
|
|
|
|
// }
|
|
|
|
|
//#endif
|
|
|
|
|
//
|
|
|
|
|
// tlbUnmapRange(1, NTLBENTRIES);
|
|
|
|
|
//
|
|
|
|
|
// // Clear the stack allocation pointers
|
|
|
|
|
// for (i = 0; i < ARRAYCOUNT(g_StackLeftAddrs); i++) {
|
|
|
|
|
// g_StackLeftAddrs[i] = NULL;
|
|
|
|
|
// g_StackRightAddrs[i] = NULL;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// osInitialize();
|
|
|
|
|
//
|
|
|
|
|
// // Write all data memory cache into physical memory
|
|
|
|
|
// osWritebackDCacheAll();
|
|
|
|
|
//
|
|
|
|
|
// // Invalidate all instruction cache
|
|
|
|
|
// osInvalICache((void *) 0x80000000, ICACHE_SIZE);
|
|
|
|
|
//
|
|
|
|
|
// // Enable inexact operation, overflow, division by zero and invalid operation
|
|
|
|
|
// __osSetFpcCsr(__osGetFpcCsr() | (FPCSR_EI | FPCSR_EO | FPCSR_EZ | FPCSR_EV));
|
|
|
|
|
//
|
|
|
|
|
//#if VERSION < VERSION_NTSC_1_0
|
|
|
|
|
// var800902e4 = &varbc000c02;
|
|
|
|
|
// var800902e8 = 0x4040;
|
|
|
|
|
// varbc000c02 = 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);
|
|
|
|
|
//}
|
|
|
|
|
void bootPhase1(void)
|
|
|
|
|
{
|
|
|
|
|
s32 datacomplen;
|
|
|
|
|
s32 inflatelen;
|
|
|
|
|
u8 *dataziprom;
|
|
|
|
|
u8 *datazipram;
|
|
|
|
|
u32 *libram;
|
|
|
|
|
u32 *libzipram;
|
|
|
|
|
u32 dataram;
|
|
|
|
|
u32 copylen;
|
|
|
|
|
s32 i;
|
|
|
|
|
s32 numlibwords;
|
|
|
|
|
u32 flags;
|
|
|
|
|
|
|
|
|
|
#if VERSION >= VERSION_NTSC_1_0
|
|
|
|
|
if (osResetType == RESETTYPE_WARM) {
|
|
|
|
|
g_OsMemSize = *(u32 *)(STACK_START - 8);
|
|
|
|
|
} else {
|
|
|
|
|
*(u32 *)(STACK_START - 8) = g_OsMemSize = osMemSize;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Copy compressed .data and inflate segments
|
|
|
|
|
// .data is copied from ROM to 0x701eb000 - 0x70200000
|
|
|
|
|
// inflate is copied from ROM to 0x70200000 - 0x702013f0
|
|
|
|
|
datacomplen = (s32) &_datazipSegmentRomEnd - (s32) &_datazipSegmentRomStart;
|
|
|
|
|
#if VERSION >= VERSION_NTSC_1_0
|
|
|
|
|
if (1);
|
|
|
|
|
#endif
|
|
|
|
|
inflatelen = (s32) &_inflateSegmentRomEnd - (s32) &_inflateSegmentRomStart;
|
|
|
|
|
copylen = datacomplen + inflatelen;
|
|
|
|
|
libram = (u32 *) ((u32) &_libSegmentStart + 0x2000);
|
|
|
|
|
libzipram = (u32 *) 0x70280000;
|
|
|
|
|
dataziprom = (u8 *) ((s32) &_datazipSegmentRomStart | 0x70000000);
|
|
|
|
|
datazipram = (u8 *) (0x70200000 - datacomplen);
|
|
|
|
|
dataram = (u32) &_dataSegmentStart;
|
|
|
|
|
|
|
|
|
|
for (i = copylen - 1; i >= 0; i--) {
|
|
|
|
|
datazipram[i] = dataziprom[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Copy the compressed part of lib to 0x70280000.
|
|
|
|
|
// 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.
|
|
|
|
|
numlibwords = 75000;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < numlibwords; i++) {
|
|
|
|
|
libzipram[i] = libram[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Inflate compressed part of lib
|
|
|
|
|
segInflate((void *) libzipram, (void *) libram, (void *) 0x80300000);
|
|
|
|
|
|
|
|
|
|
// Inflate .data
|
|
|
|
|
segInflate((void *) datazipram, (void *) dataram, (void *) 0x80300000);
|
|
|
|
|
|
|
|
|
|
#if PIRACYCHECKS
|
|
|
|
|
if (IO_READ(0xa00002e8) != 0xc86e2000) {
|
|
|
|
|
while (1);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
tlbUnmapRange(1, NTLBENTRIES);
|
|
|
|
|
|
|
|
|
|
// Clear the stack allocation pointers
|
|
|
|
|
for (i = 0; i < ARRAYCOUNT(g_StackLeftAddrs); i++) {
|
|
|
|
|
g_StackLeftAddrs[i] = NULL;
|
|
|
|
|
g_StackRightAddrs[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osInitialize();
|
|
|
|
|
|
|
|
|
|
// Write all data memory cache into physical memory
|
|
|
|
|
osWritebackDCacheAll();
|
|
|
|
|
|
|
|
|
|
// Invalidate all instruction cache
|
|
|
|
|
osInvalICache((void *) 0x80000000, ICACHE_SIZE);
|
|
|
|
|
|
|
|
|
|
// Configure the floating point unit
|
|
|
|
|
flags = __osGetFpcCsr();
|
|
|
|
|
flags |= FPCSR_EI; // enable inexact operation
|
|
|
|
|
flags |= FPCSR_EO; // enable overflow
|
|
|
|
|
flags |= FPCSR_EZ; // enable division by zero
|
|
|
|
|
flags |= FPCSR_EV; // enable invalid operation
|
|
|
|
|
|
|
|
|
|
__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.
|
|
|
|
|