Skip to content

Commit

Permalink
small fixes to __start and __ppc_eabi_init
Browse files Browse the repository at this point in the history
  • Loading branch information
shibbo committed Nov 24, 2024
1 parent 0d21b9a commit f2320d1
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 45 deletions.
4 changes: 2 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2595,8 +2595,8 @@ def JSysLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
Object(NonMatching, "RVL_SDK/os/OSPlayTime.c"),
Object(NonMatching, "RVL_SDK/os/OSLaunch.c"),
Object(NonMatching, "RVL_SDK/os/init/__start.c"),
Object(NonMatching, "RVL_SDK/os/init/__ppc_eabi_init.cpp"),
Object(NonMatching, "RVL_SDK/os/__ppc_eabi_init.c")
Object(Matching, "RVL_SDK/os/init/__ppc_eabi_init.cpp"),
Object(Matching, "RVL_SDK/os/__ppc_eabi_init.c")
]
),

Expand Down
46 changes: 46 additions & 0 deletions src/RVL_SDK/os/__ppc_eabi_init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifdef __cplusplus
extern "C" {
#endif

typedef void (*funcPtr) (void);
__declspec(section ".ctors") extern funcPtr _ctors[];
__declspec(section ".dtors") extern funcPtr _dtors[];
extern void exit(int);
static void __init_cpp(void);

extern void __OSCacheInit(void);
extern void __OSFPRInit(void);
extern void __OSPSInit(void);

/* written in assembly to generate the frame allocations */
asm void __init_user(void) {
fralloc
bl __init_cpp
frfree
blr
}

static void __init_cpp(void) {
funcPtr* ctor;

for (ctor = _ctors; *ctor; ctor++) {
(*ctor)();
}
}

static void __fini_cpp(void) {
funcPtr* dtor;

for (dtor = _dtors; *dtor; dtor++) {
(*dtor)();
}
}

void exit(int status) {
__fini_cpp();
PPCHalt();
}

#ifdef __cplusplus
}
#endif
29 changes: 0 additions & 29 deletions src/RVL_SDK/os/init/__ppc_eabi_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,6 @@ asm void __init_hardware(void) {
blr
}

/* written in assembly to generate the frame allocations */
asm void __init_user(void) {
fralloc
bl __init_cpp
frfree
blr
}

static void __init_cpp(void) {
funcPtr* ctor;

for (ctor = _ctors; *ctor; ctor++) {
(*ctor)();
}
}

static void __fini_cpp(void) {
funcPtr* dtor;

for (dtor = _dtors; *dtor; dtor++) {
(*dtor)();
}
}

void exit(int status) {
__fini_cpp();
PPCHalt();
}

asm void __flush_cache(void *, unsigned int) {
nofralloc

Expand Down
17 changes: 3 additions & 14 deletions src/RVL_SDK/os/init/__start.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,12 @@ static u8 Debug_BBA = 0;

static void __init_registers(void);
static void __init_data(void);

extern void OSInit(void);
extern void DBInit(void);

extern void main(void);

void InitMetroTRK(void) {
return;
}

void InitMetroTRK_BBA(void) {
return;
}

void exit(void) {
return;
}
extern void exit(void);
extern void InitMetroTRK(void);
extern void InitMetroTRK_BBA(void);

static void __check_pad3(void) {
if ((Pad3Button & 0xEEF) == 0xEEF) {
Expand Down

0 comments on commit f2320d1

Please sign in to comment.