2021-10-14 14:55:04 +00:00
|
|
|
#include <base.h>
|
2021-10-14 15:50:30 +00:00
|
|
|
#include <os.h>
|
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm u32 PPCMfmsr(void) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mfmsr r3;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtmsr(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtmsr val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm u32 PPCMfhid0(void) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mfspr r3, 1008;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMthid0(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtspr 1008, val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm u32 PPCMfl2cr(void) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mfspr r3, 1017;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtl2cr(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtspr 1017, val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtdec(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtdec val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCSync(void) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
sc;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCHalt(void) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
sync;
|
|
|
|
LAB_8001a134:
|
|
|
|
nop;
|
|
|
|
li r3, 0x0;
|
|
|
|
nop;
|
|
|
|
b LAB_8001a134;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtmmcr0(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtspr 952, val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtmmcr1(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtspr 956, val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtpmc1(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtspr 953, val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtpmc2(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtspr 954, val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
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
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
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
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
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
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 14:55:04 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 14:55:04 +00:00
|
|
|
asm u32 PPCMfhid2(void) {
|
2021-10-14 15:50:30 +00:00
|
|
|
// clang-format off
|
2021-10-14 14:55:04 +00:00
|
|
|
nofralloc;
|
|
|
|
mfspr r3, 920;
|
|
|
|
blr;
|
2021-10-14 15:50:30 +00:00
|
|
|
// clang-format on
|
2021-10-14 14:55:04 +00:00
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 14:55:04 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 14:55:04 +00:00
|
|
|
asm void PPCMthid2(register u32 val) {
|
2021-10-14 15:50:30 +00:00
|
|
|
// clang-format off
|
2021-10-14 14:55:04 +00:00
|
|
|
nofralloc;
|
|
|
|
mtspr 920, val;
|
|
|
|
blr;
|
2021-10-14 15:50:30 +00:00
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCMtwpar(register u32 val) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtspr 921, val;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
|
|
|
|
void PPCDisableSpeculation(void) { PPCMthid0(PPCMfhid0() | 0x200); }
|
|
|
|
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm void PPCSetFpNonIEEEMode(void) {
|
|
|
|
// clang-format off
|
|
|
|
nofralloc;
|
|
|
|
mtfsb1 29;
|
|
|
|
blr;
|
|
|
|
// clang-format on
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
void PPCMthid4(register u32 val) {
|
|
|
|
if (val & 0x80000000) {
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm {
|
|
|
|
mtspr 1011, val;
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
} else {
|
|
|
|
OSReport("H4A should not be cleared because of Broadway errata.\n");
|
|
|
|
val |= 0x80000000;
|
2021-10-19 12:33:18 +00:00
|
|
|
#ifdef __CWCC__
|
2021-10-14 15:50:30 +00:00
|
|
|
asm {
|
|
|
|
mtspr 1011, val;
|
|
|
|
}
|
2021-10-19 12:33:18 +00:00
|
|
|
#endif
|
2021-10-14 15:50:30 +00:00
|
|
|
}
|
2021-10-14 14:55:04 +00:00
|
|
|
}
|