Decompile PPCArch.c

This commit is contained in:
Charlotte Delenk 2021-10-14 17:50:30 +02:00
parent 065e34f7eb
commit 21f99638df
Signed by: darkkirb
GPG key ID: 015E3768A70AFBC5
4 changed files with 204 additions and 1 deletions

View file

@ -1,7 +1,7 @@
.init start,.init end,extab start,extab end,extabindex start,extabindex end,.text start,.text end,.ctors start,.ctors end,.dtors start,.dtors end,.rodata start,.rodata end,.data start,.data end,.bss start,.bss end,.sdata start,.sdata end,.sbss start,.sbss end,.sdata2 start,.sdata2 end,.sbss2 start,.sbss2 end,File
80004000,80004380,,,,,,,,,,,,,,,,,,,,,,,,,sdk/msl/runtime/__mem.o
80004380,800062c0,,,,,,,,,,,,,,,,,,,,,,,,,sdk/trk/__exception.o
,,,,,,8001a200,8001a218,,,,,,,,,,,,,,,,,,,sdk/rvl/base/PPCArch.o
,,,,,,8001a0b0,8001a2c0,,,,,,,80421da0,80421dd7,,,,,,,,,,,sdk/rvl/base/PPCArch.o
,,,,,,8001b670,8001b6c4,,,,,,,,,,,,,,,,,,,sdk/rvl/os/OS.o
,,,,,,8001cab0,8001cac0,,,,,,,,,,,,,,,,,,,sdk/rvl/os/OSCache.o
800062c0,80006620,,,,,,,,,,,,,,,,,,,8055c878,8055c879,,,,,sdk/rvl/os/__start.o

1 .init start .init end extab start extab end extabindex start extabindex end .text start .text end .ctors start .ctors end .dtors start .dtors end .rodata start .rodata end .data start .data end .bss start .bss end .sdata start .sdata end .sbss start .sbss end .sdata2 start .sdata2 end .sbss2 start .sbss2 end File
2 80004000 80004380 sdk/msl/runtime/__mem.o
3 80004380 800062c0 sdk/trk/__exception.o
4 8001a200 8001a0b0 8001a218 8001a2c0 80421da0 80421dd7 sdk/rvl/base/PPCArch.o
5 8001b670 8001b6c4 sdk/rvl/os/OS.o
6 8001cab0 8001cac0 sdk/rvl/os/OSCache.o
7 800062c0 80006620 8055c878 8055c879 sdk/rvl/os/__start.o

View file

@ -9,6 +9,7 @@ Address,SymbolName
8001a2c0,__OSFPRInit
8001ad80,OSInit
8001cea0,__OSCacheInit
8001d990,OSReport
80023820,OSResetSystem
80028530,__init_user
800285a0,exit

1 Address SymbolName
9 8001a2c0 __OSFPRInit
10 8001ad80 OSInit
11 8001cea0 __OSCacheInit
12 8001d990 OSReport
13 80023820 OSResetSystem
14 80028530 __init_user
15 800285a0 exit

11
include/os.h Normal file
View file

@ -0,0 +1,11 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
void OSReport(const char *fmt, ...);
#ifdef __cplusplus
}
#endif

View file

@ -1,13 +1,204 @@
#include <base.h>
#include <os.h>
asm u32 PPCMfmsr(void) {
// clang-format off
nofralloc;
mfmsr r3;
blr;
// clang-format on
}
asm void PPCMtmsr(register u32 val) {
// clang-format off
nofralloc;
mtmsr val;
blr;
// clang-format on
}
asm u32 PPCMfhid0(void) {
// clang-format off
nofralloc;
mfspr r3, 1008;
blr;
// clang-format on
}
asm void PPCMthid0(register u32 val) {
// clang-format off
nofralloc;
mtspr 1008, val;
blr;
// clang-format on
}
asm u32 PPCMfl2cr(void) {
// clang-format off
nofralloc;
mfspr r3, 1017;
blr;
// clang-format on
}
asm void PPCMtl2cr(register u32 val) {
// clang-format off
nofralloc;
mtspr 1017, val;
blr;
// clang-format on
}
asm void PPCMtdec(register u32 val) {
// clang-format off
nofralloc;
mtdec val;
blr;
// clang-format on
}
asm void PPCSync(void) {
// clang-format off
nofralloc;
sc;
blr;
// clang-format on
}
asm void PPCHalt(void) {
// clang-format off
nofralloc;
sync;
LAB_8001a134:
nop;
li r3, 0x0;
nop;
b LAB_8001a134;
// clang-format on
}
asm void PPCMtmmcr0(register u32 val) {
// clang-format off
nofralloc;
mtspr 952, val;
blr;
// clang-format on
}
asm void PPCMtmmcr1(register u32 val) {
// clang-format off
nofralloc;
mtspr 956, val;
blr;
// clang-format on
}
asm void PPCMtpmc1(register u32 val) {
// clang-format off
nofralloc;
mtspr 953, val;
blr;
// clang-format on
}
asm void PPCMtpmc2(register u32 val) {
// clang-format off
nofralloc;
mtspr 954, val;
blr;
// clang-format on
}
asm void PPCMtpmc3(register u32 val) {
// clang-format off
nofralloc;
mtspr 957, val;
blr;
// clang-format on
}
asm void PPCMtpmc4(register u32 val) {
// clang-format off
nofralloc;
mtspr 958, val;
blr;
// clang-format on
}
asm u32 PPCMffpscr(void) {
// clang-format off
nofralloc;
stwu r1, -0x20(r1);
stfd f31, 0x18(r1);
mffs f31;
stfd f31, 0x08(r1);
lfd f31, 0x18(r1);
lwz r3, 0xc(r1);
addi r1, r1, 0x20;
blr;
// clang-format on
}
asm void PPCMtfpscr(register u32 val) {
// clang-format off
nofralloc;
stwu r1, -0x20(r1);
stfd f31, 0x18(r1);
li r4, 0x0;
stw r4, 0x08(r1);
stw val, 0x0c(r1);
lfd f31, 0x08(r1);
mtfsf 0xff, f31;
lfd f31, 0x18(r1);
addi r1, r1, 0x20;
blr;
// clang-format on
}
asm u32 PPCMfhid2(void) {
// clang-format off
nofralloc;
mfspr r3, 920;
blr;
// clang-format on
}
asm void PPCMthid2(register u32 val) {
// clang-format off
nofralloc;
mtspr 920, val;
blr;
// clang-format on
}
asm void PPCMtwpar(register u32 val) {
// clang-format off
nofralloc;
mtspr 921, val;
blr;
// clang-format on
}
void PPCDisableSpeculation(void) { PPCMthid0(PPCMfhid0() | 0x200); }
asm void PPCSetFpNonIEEEMode(void) {
// clang-format off
nofralloc;
mtfsb1 29;
blr;
// clang-format on
}
void PPCMthid4(register u32 val) {
if (val & 0x80000000) {
asm {
mtspr 1011, val;
}
} else {
OSReport("H4A should not be cleared because of Broadway errata.\n");
val |= 0x80000000;
asm {
mtspr 1011, val;
}
}
}