link reconfigbats and sdk stuff

This commit is contained in:
Prakxo
2023-01-01 22:06:28 +01:00
parent 1753100e34
commit 594e904145
17 changed files with 528 additions and 30 deletions
+14 -7
View File
@@ -2,11 +2,18 @@ libultra/gfxprint/gfxprint_locate.c:
.text: [0x8005B1EC, 0x8005B210]
libultra/gfxprint/gfxprint_locate8x8.c:
.text: [0x8005B210, 0x8005B238]
# libforest/ReconfigBATs.c:
# .text: [0x8007C070, 0x8005ae84]
# OS/OSEnableInterrupts.c: I'm too tired, but I did these and cba to fix atm stuff
# .text: [0x8007ac38, 0x8007ac4c]
# OS/OSRestoreInterrupts.c:
# .text: [0x8007ac4c, 0x8007ac70]
libforest/ReconfigBATs.c:
.text: [0x8005adac, 0x8005aed4]
# OS/OSDisableInterrupts.c:
# .text: [0x8007ac24, 0x8007ac38]
# .text: [0x8007ac24, 0x8007ac38]
OS/OSEnableInterrupts.c:
.text: [0x8007ac38, 0x8007ac4c]
OS/OSRestoreInterrupts.c:
.text: [0x8007ac4c, 0x8007ac70]
BASE/ppcarch.c:
.text: [0x8007867c, 0x800786e8]
OS/OSArena.c:
.text: [0x8007988c, 0x800798ac]
.sdata: [0x80218178, 0x80218180]
.sbss: [0x802188f8, 0x80218900]
+1 -1
View File
@@ -1,4 +1,4 @@
# ac_aprilfool_control/aPC_actor_dt.c:
# ac_aprilfool_control/aPC_actor_dt.c: common_data is pure bs,
# .text: [0x805153f0, 0x8051542C]
zurumode/zerucheck_init.c:
.text: [0x8040eb38, 0x8040EB50]
+18
View File
@@ -0,0 +1,18 @@
#ifndef OS_ARENA_H
#define OS_ARENA_H
#include "types.h"
#ifdef __cplusplus
extern "C"{
#endif
void* OSGetArenaHi(void);
void* OSGetArenaLo(void);
void OSSetArenaHi(void*);
void OSSetArenaLo(void*);
#ifdef __cplusplus
}
#endif
#endif
+30
View File
@@ -0,0 +1,30 @@
#ifndef OS_CACHE_H
#define OS_CACHE_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
asm void DCEnable(void);
asm void DCInvalidateRange(void* buf, u32 len);
asm void DCFlushRange(void* buf, u32 len);
asm void DCStoreRange(void* buf, u32 len);
asm void DCFlushRangeNoSync(void* buf, u32 len);
asm void DCStoreRangeNoSync(void* buf, u32 len);
asm void DCZeroRange(void* buf, u32 len);
asm void DCTouchRange(void* buf, u32 len);
asm void ICInvalidateRange(void* buf, u32 len);
asm void ICFlashInvalidate(void);
asm void ICEnable(void);
asm void LCDisable(void);
void L2GlobalInvalidate(void);
void DMAErrorHandler(u8, OSContext*, u32, u32, ...);
void __OSCacheInit(void);
#ifdef __cplusplus
}
#endif
#endif
+7
View File
@@ -0,0 +1,7 @@
#ifndef OS_MEMORY_H
#define OS_MEMORY_H
static asm void Config24MB();
static asm void Config48MB();
u32 OSGetConsoleSimulatedMemSize(void);
#endif
+7 -1
View File
@@ -3,10 +3,16 @@
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
void OSReport(const char*, ...);
asm BOOL OSDisableInterrupts(void);
asm BOOL OSEnableInterrupts(void);
asm BOOL OSRestoreInterrupts(BOOL level);
#ifdef __cplusplus
}
#endif
#endif
+36
View File
@@ -0,0 +1,36 @@
#ifndef PPCARCH_H
#define PPCARCH_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
u32 PPCMfmsr(void);
void PPCMtmsr(u32);
u32 PPCMfhid0(void);
void PPCMthid0(u32);
u32 PPCMfl2cr(void);
void PPCMtl2cr(u32);
void PPCMtdec(u32);
void PPCSync(void);
void PPCHalt(void);
u32 PPCMfhid2(void);
void PPCMthid2(u32);
void PPCMtwpar(u32);
// void PPCDisableSpeculation(void);
void PPCSetFpNonIEEEMode(void);
#ifdef __cplusplus
}
#endif
#endif
+6 -2
View File
@@ -1,7 +1,11 @@
#ifndef BATCONFIG_H
#define BATCONFIG_H
static asm void Config24MB();
static asm void Config48MB();
#include "types.h"
#include "dolphin/OSMemory.h"
#include "dolphin/os.h"
asm void Config24MB();
asm void Config48MB();
void ReconfigBATs();
#endif
+54
View File
@@ -0,0 +1,54 @@
#ifndef FAULT_H
#define FAULT_H
#include "types.h"
#include "dolphin/os.h"
#include "libultra/libultra.h"
#ifdef __cplusplus
extern "C"{
#endif
#define FAULT_MIN_PRIORITY 0
#define FAULT_STAGE_POST 0
#define FAULT_STAGE_PRE 1
#define FAULT_FLAG_POSTEXCEPTION (1 << FAULT_STAGE_POST)
#define FAULT_FLAG_PREEXCEPTION (1 << FAULT_STAGE_PRE)
#define FAULT_FLAG_DRAW_SEPARATOR (1 << 2)
#define FAULT_FLAG_DRAW_CALLBACK_INFO (1 << 3)
typedef struct {
fault_client* next;
FaultCallBack callback;
const char* msg;
u32 param;
u8 priority;
u8 flags;
} fault_client;
typedef struct {
u8 _0, _1, _2, _3;
u8 num_clients;
fault_client* first_client;
} fault;
typedef void (*FaultCallback)(const char* msg, u32 param);
void fault_AddClientEx(fault_client* client, FaultCallback callback, const char* msg, u32 param, u8 priority, u8 flags);
void fault_AddClient(fault_client* client, FaultCallback callback, const char* msg, u32 param);
void fault_Printf(const char* msg, ...);
void fault_DrawUpdate();
void fault_WaitTime(u32 waitTime);
int fault_ReadPad(u32* param_1, u32 param_2);
void fault_CallBackFunc(int stage);
void fault_Init();
static void my_PreExceptionCallback();
static void my_PostExceptionCallback();
#ifdef __cplusplus
}
#endif
#endif
+2 -1
View File
@@ -2,8 +2,9 @@
#define GFXPRINT_H
#include "types.h"
typedef void* (*PrintCallback)(void*, const char*, size_t);
typedef struct gfxprint_obj {
s32 unk0;
PrintCallback callback;
struct unknown_struct * unk4; // This is from GBI.h, from what I've seen
s16 NewX;
s16 NewY;
+96
View File
@@ -0,0 +1,96 @@
#include "dolphin/ppcarch.h"
asm u32 PPCMfmsr(void){
nofralloc
mfmsr r3
blr
}
asm void PPCMtmsr(register u32 value){
nofralloc
mtmsr value
blr
}
asm u32 PPCMfhid0(void){
nofralloc
mfspr r3, 0x3f0
blr
}
asm void PPCMthid0(register u32 value) {
nofralloc
mtspr 0x3f0, value
blr
}
asm u32 PPCMfl2cr(void) {
nofralloc
mfspr r3, 0x3f9
blr
}
asm void PPCMtl2cr(register u32 value) {
nofralloc
mtspr 0x3f9, value
blr
}
asm void PPCMtdec(register u32 value) {
nofralloc
mtspr 0x16, value
blr
}
asm void PPCSync(void){
nofralloc
sc
blr
}
asm void PPCHalt(void){
nofralloc
sync
loop:
nop
li r3, 0
nop
b loop
}
asm u32 PPCMfhid2(void){
nofralloc
mfspr r3, 0x398
blr
}
asm void PPCMthid2(u32 register value){
nofralloc
mtspr 0x398, value
blr
}
asm void PPCMtwpar(u32 register value){
nofralloc
mtspr 0x399, value
blr
}
/* PPCDisableSpeculation:
/* 800786E8 7C0802A6 mflr r0
/* 800786EC 90010004 stw r0, 4(r1)
/* 800786F0 9421FFF8 stwu r1, -8(r1)
/* 800786F4 4BFFFF99 bl func_8007868c
/* 800786F8 60630200 ori r3, r3, 0x200
/* 800786FC 4BFFFF99 bl func_80078694
/* 80078700 8001000C lwz r0, 0xc(r1)
/* 80078704 38210008 addi r1, r1, 0x8
/* 80078708 7C0803A6 mtlr r0
/* 8007870C 4E800020 blr
}
asm void PPCSetFpNonIEEEMode(void){
nofralloc
mtfsb1 0x1D
blr
} */
+20
View File
@@ -0,0 +1,20 @@
#include "dolphin/OSArena.h"
static void* __OSArenaLo = (void*) - 1;
static void* __OSArenaHi = NULL;
void* OSGetArenaHi(void) {
return (__OSArenaHi);
}
void* OSGetArenaLo (void) {
return (__OSArenaLo);
}
void OSSetArenaHi(void* hi){
__OSArenaHi = hi;
}
void OSSetArenaLo(void* lo){
__OSArenaLo = lo;
}
+215
View File
@@ -0,0 +1,215 @@
#include "dolphin/OSCache.h"
//Needs OSError stuff
asm void DCEnable(void){
nofralloc
sync 0
mfspr r3, 0x3f0
ori r3, r3, 0x4000
mtspr 0x3f0, r3
blr
}
asm void DCInvalidateRange(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- pi_r
addi len, len 0x20
pi_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
inv_ran:
dcbi 0, buf
addi buf, buf 0x20
bdnz inv_ran
blr
}
asm void DCFlushRange(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- pf_r
addi len, len 0x20
pf_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
fls_ran:
dcbf 0, buf
addi buf, buf 0x20
bdnz fls_ran
sc
blr
}
asm void DCStoreRange(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- ps_r
addi len, len 0x20
ps_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
st_ran:
dcbst 0, buf
addi buf, buf 0x20
bdnz st_ran
sc
blr
}
asm void DCFlushRangeNoSync(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- pf_r
addi len, len 0x20
pfns_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
fls_ranns:
dcbf 0, buf
addi buf, buf 0x20
bdnz fls_ranns
blr
}
asm void DCStoreRangeNoSync(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- psns_r
addi len, len 0x20
psns_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
st_ranns:
dcbst 0, buf
addi buf, buf 0x20
bdnz st_ranns
sc
blr
}
asm void DCZeroRange(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- pzr_r
addi len, len 0x20
pzr_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
z_ran:
dcbz 0, buf
addi buf, buf 0x20
bdnz z_ran
blr
}
asm void DCTouchRange(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- ptor_r
addi len, len 0x20
ptor_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
t_ran:
dcbt 0, buf
addi buf, buf 0x20
bdnz t_ran
blr
}
asm void ICInvalidateRange(register void* buf, register u32 len){
nofralloc
cmplw len, 0
blelr-
clrlwi. r5, buf, 0x1b
beq- pir_r
addi len, len 0x20
pir_r:
addi len, len 0x1f
srwi len, len, 5
mtctr len
i_ran:
icbi 0, buf
addi buf, buf 0x20
bdnz i_ran
sync 0
isync
blr
}
asm void ICFlashInvalidate(void){
nofralloc
mfspr r3, 0x3f0
ori r3, r3, 0x800
mtspr 0x3f0, r3
blr
}
asm void ICEnable(void){
nofralloc
isync
mfspr r3, 0x3f0
ori r3, r3, 0x8000
mtspr 0x3f0, r3
blr
}
asm void ICDisable(void){
nofralloc
lis r3, 0xE000
li r4, 0x200
mtctr r4
dis:
dcbi 0, r3
addi r3, r3 0x20
bdnz dis
mfspr r4, 0x398
rlwinm r4, r4, 0, 4, 2
mtspr 0x398, r4
blr
}
-2
View File
@@ -1,9 +1,7 @@
#include "dolphin/os.h"
asm BOOL OSDisableInterrupts(void){
nofralloc
mfmsr r3
rlwinm r4, r3, 0, 17, 15
mtmsr r4
+11 -15
View File
@@ -1,8 +1,6 @@
#include "libforest/batconfig.h"
#include "dolphin/os.h"
// Different to the OS ones.
// Not fully Decompiled, need ReconfigBATs func, however there's os stuff that needs to be known.
static asm void Config24MB(){
asm void Config24MB(){
nofralloc
/* 8005ADAC 7C6000A6 */ mfmsr r3
/* 8005ADB0 54630734 */ rlwinm r3, r3, 0, 0x1c, 0x1a
@@ -32,7 +30,7 @@ nofralloc
/* 8005AE10 4C00012C */ isync
/* 8005AE14 4E800020 */ blr
}
static asm void Config48MB(){
asm void Config48MB(){
nofralloc
/* 8005AE18 7C6000A6 */ mfmsr r3
/* 8005AE1C 54630734 */ rlwinm r3, r3, 0, 0x1c, 0x1a
@@ -63,14 +61,12 @@ nofralloc
/* 8005AE80 4E800020 */ blr
}
void ReconfigBATs(){
BOOL restore = OSDisableInterrupts();
if (OSGetSimulatedMemorySize() <= 0x1800000) {
Config24MB();
else{
Config48MB();
}
}
OSRestoreInterrupts(restore);
BOOL rest = OSDisableInterrupts();
if (OSGetConsoleSimulatedMemSize() <= 0x1800000){
Config24MB();
}
else {
Config48MB();
}
OSRestoreInterrupts(rest);
}
+10
View File
@@ -0,0 +1,10 @@
#include "fault.h"
static fault fault_class;
static fault* this;
void fault_AddClientEx(fault_client* client, FaultCallback callback, const char* msg, u32 param, u8 priority, u8 flags){
}