From f543b7b4718a388aafd67203f10bc1f7cfa2bcf3 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 28 Dec 2024 15:45:24 -0500 Subject: [PATCH] Add ASM define to wrap mwerks asm keyword --- include/global.h | 2 + .../Runtime/Src/__init_cpp_exceptions.cpp | 3 +- src/PowerPC_EABI_Support/Runtime/Src/ptmf.c | 7 +-- .../Runtime/Src/runtime.c | 45 ++++++++++--------- src/dolphin/os/OS.c | 12 ++--- src/dolphin/os/OSAlarm.c | 4 +- src/dolphin/os/OSCache.c | 28 ++++++------ src/dolphin/os/OSContext.c | 20 ++++----- src/dolphin/os/OSInterrupt.c | 8 ++-- src/dolphin/os/OSMemory.c | 6 +-- src/dolphin/os/OSReboot.c | 2 +- src/dolphin/os/OSReset.c | 2 +- src/dolphin/os/OSSync.c | 2 +- src/dolphin/os/OSTime.c | 12 ++--- src/dolphin/os/__start.c | 8 ++-- 15 files changed, 83 insertions(+), 78 deletions(-) diff --git a/include/global.h b/include/global.h index 863466a0d..654524c23 100644 --- a/include/global.h +++ b/include/global.h @@ -33,11 +33,13 @@ #define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT))) #define SECTION_DATA __declspec(section ".data") #define SECTION_INIT __declspec(section ".init") +#define ASM asm #else #define STATIC_ASSERT(...) #define ALIGN_DECL(...) #define SECTION_DATA #define SECTION_INIT +#define ASM #endif extern int __cntlzw(uint); diff --git a/src/PowerPC_EABI_Support/Runtime/Src/__init_cpp_exceptions.cpp b/src/PowerPC_EABI_Support/Runtime/Src/__init_cpp_exceptions.cpp index 6b72cd685..8ea08c077 100644 --- a/src/PowerPC_EABI_Support/Runtime/Src/__init_cpp_exceptions.cpp +++ b/src/PowerPC_EABI_Support/Runtime/Src/__init_cpp_exceptions.cpp @@ -1,5 +1,6 @@ #include "NMWException.h" #include "__ppc_eabi_linker.h" +#include "global.h" #if __MWERKS__ #pragma exceptions off @@ -20,7 +21,7 @@ extern void __fini_cpp_exceptions(void); static int fragmentID = -2; /* clang-format off */ -static asm char* GetR2() { +static ASM char* GetR2() { nofralloc; mr r3, r2 blr diff --git a/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c b/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c index 42919e58c..772c2f939 100644 --- a/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c +++ b/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c @@ -1,8 +1,9 @@ #include "ptmf.h" +#include "global.h" const __ptmf __ptmf_null = { 0, 0, 0 }; -asm long __ptmf_test(register __ptmf* ptmf) { +ASM long __ptmf_test(register __ptmf* ptmf) { lwz r5, __ptmf.this_delta(ptmf) lwz r6, __ptmf.v_offset(ptmf) lwz r7, __ptmf.f_data(ptmf) @@ -17,7 +18,7 @@ asm long __ptmf_test(register __ptmf* ptmf) { blr }; -asm void __ptmf_cmpr(register __ptmf* lhs, register __ptmf* rhs) { +ASM void __ptmf_cmpr(register __ptmf* lhs, register __ptmf* rhs) { lwz r5, __ptmf.this_delta(lhs) lwz r6, __ptmf.this_delta(rhs) lwz r7, __ptmf.v_offset(lhs) @@ -35,7 +36,7 @@ asm void __ptmf_cmpr(register __ptmf* lhs, register __ptmf* rhs) { blr }; -asm void __ptmf_scall(...) { +ASM void __ptmf_scall(...) { nofralloc; lwz r0, __ptmf.this_delta(r12) lwz r11, __ptmf.v_offset(r12) diff --git a/src/PowerPC_EABI_Support/Runtime/Src/runtime.c b/src/PowerPC_EABI_Support/Runtime/Src/runtime.c index a32369336..e0dd805da 100644 --- a/src/PowerPC_EABI_Support/Runtime/Src/runtime.c +++ b/src/PowerPC_EABI_Support/Runtime/Src/runtime.c @@ -1,4 +1,5 @@ #include "PowerPC_EABI_Support/Runtime/Inc/runtime.h" +#include "global.h" #ifdef __cplusplus extern "C" { @@ -17,14 +18,14 @@ extern "C" { #define save_restore_reg r11 -asm void __div2u(void); -asm void __div2i(void); -asm void __mod2u(void); -asm void __mod2i(void); -asm void __shl2i(void); -asm void __shr2u(void); -asm void __shr2i(void); -asm void __cvt_dbl_usll(void); +ASM void __div2u(void); +ASM void __div2i(void); +ASM void __mod2u(void); +ASM void __mod2i(void); +ASM void __shl2i(void); +ASM void __shr2u(void); +ASM void __shr2i(void); +ASM void __cvt_dbl_usll(void); void SAVE_FPR(14)(void); void SAVE_FPR(15)(void); @@ -110,7 +111,7 @@ static const u32 __constants[] = { * @note Address: 0x800C1B4C * @note Size: 0x5C */ -asm u32 __cvt_fp2unsigned(register f64 d) +ASM u32 __cvt_fp2unsigned(register f64 d) { #ifdef __MWERKS__ // clang-format off nofralloc @@ -145,7 +146,7 @@ asm u32 __cvt_fp2unsigned(register f64 d) * @note Address: 0x800C1BA8 * @note Size: 0x4C */ -asm static void __save_fpr(void) { +ASM static void __save_fpr(void) { #ifdef __MWERKS__ // clang-format off nofralloc stfd fp14,-144(save_restore_reg) @@ -178,7 +179,7 @@ asm static void __save_fpr(void) { * @note Address: 0x800C1BF4 * @note Size: 0x4C */ -asm static void __restore_fpr(void) { +ASM static void __restore_fpr(void) { #ifdef __MWERKS__ // clang-format off nofralloc lfd fp14,-144(save_restore_reg) @@ -211,7 +212,7 @@ asm static void __restore_fpr(void) { * @note Address: 0x800C1C40 * @note Size: 0x4C */ -asm static void __save_gpr(void) { +ASM static void __save_gpr(void) { #ifdef __MWERKS__ // clang-format off nofralloc ENTRY_SAVE_GPR(14) @@ -256,7 +257,7 @@ asm static void __save_gpr(void) { * @note Address: 0x800C1C8C * @note Size: 0x4C */ -asm static void __restore_gpr(void) { +ASM static void __restore_gpr(void) { #ifdef __MWERKS__ // clang-format off nofralloc ENTRY_RESTORE_GPR(14) @@ -301,7 +302,7 @@ asm static void __restore_gpr(void) { * @note Address: 0x800C1CD8 * @note Size: 0xEC */ -asm void __div2u(void) { +ASM void __div2u(void) { #ifdef __MWERKS__ // clang-format off nofralloc cmpwi cr0,r3,0 @@ -379,7 +380,7 @@ asm void __div2u(void) { * @note Address: 0x800C1DC4 * @note Size: 0x138 */ -asm void __div2i(void) { +ASM void __div2i(void) { #ifdef __MWERKS__ // clang-format off nofralloc stwu r1,-16(r1) @@ -482,7 +483,7 @@ asm void __div2i(void) { * @note Address: 0x800C1EFC * @note Size: 0xE4 */ -asm void __mod2u(void) { +ASM void __mod2u(void) { #ifdef __MWERKS__ // clang-format off nofralloc cmpwi cr0,r3,0 @@ -558,7 +559,7 @@ asm void __mod2u(void) { * @note Address: 0x800C1FE0 * @note Size: 0x10C */ -asm void __mod2i(void) { +ASM void __mod2i(void) { #ifdef __MWERKS__ // clang-format off nofralloc @@ -648,7 +649,7 @@ asm void __mod2i(void) { * @note Address: 0x800C20EC * @note Size: 0x24 */ -asm void __shl2i(void) { +ASM void __shl2i(void) { #ifdef __MWERKS__ // clang-format off nofralloc subfic r8,r5,32 @@ -667,7 +668,7 @@ asm void __shl2i(void) { * @note Address: 0x800C2110 * @note Size: 0x24 */ -asm void __shr2u(void) { +ASM void __shr2u(void) { #ifdef __MWERKS__ // clang-format off nofralloc subfic r8,r5,32 @@ -686,7 +687,7 @@ asm void __shr2u(void) { * @note Address: 0x800C2134 * @note Size: 0x28 */ -asm void __shr2i(void) { +ASM void __shr2i(void) { #ifdef __MWERKS__ // clang-format off nofralloc subfic r8, r5, 0x20 @@ -707,7 +708,7 @@ asm void __shr2i(void) { * @note Address: 0x800C21F8 * @note Size: 0xCC */ -asm void __cvt_dbl_usll(void) +ASM void __cvt_dbl_usll(void) { #ifdef __MWERKS__ // clang-format off nofralloc @@ -774,4 +775,4 @@ asm void __cvt_dbl_usll(void) #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/src/dolphin/os/OS.c b/src/dolphin/os/OS.c index 3aaa7cdaa..e551627c4 100644 --- a/src/dolphin/os/OS.c +++ b/src/dolphin/os/OS.c @@ -44,7 +44,7 @@ f64 ZeroPS; extern f64 ZeroF; f64 ZeroF; -asm void __OSFPRInit(void) { +ASM void __OSFPRInit(void) { // clang-format off nofralloc @@ -451,7 +451,7 @@ static void OSExceptionInit(void) { DBPrintf("Exceptions initialized...\n"); } -asm void __OSDBIntegrator(void) { +ASM void __OSDBIntegrator(void) { // clang-format off nofralloc @@ -469,7 +469,7 @@ entry __OSDBINTEND // clang-format on } -asm void __OSDBJump(void){ +ASM void __OSDBJump(void){ // clang-format off nofralloc @@ -489,7 +489,7 @@ OSExceptionHandler __OSGetExceptionHandler(__OSException exception) { return OSExceptionTable[exception]; } -static asm void OSExceptionVector(void) { +static ASM void OSExceptionVector(void) { // clang-format off nofralloc @@ -573,7 +573,7 @@ entry __OSEVEnd // clang-format on } -static asm void OSDefaultExceptionHandler(register __OSException exception, +static ASM void OSDefaultExceptionHandler(register __OSException exception, register OSContext* context) { // clang-format off nofralloc @@ -605,7 +605,7 @@ static asm void OSDefaultExceptionHandler(register __OSException exception, // clang-format on } -asm void __OSPSInit(void){ +ASM void __OSPSInit(void){ // clang-format off nofralloc diff --git a/src/dolphin/os/OSAlarm.c b/src/dolphin/os/OSAlarm.c index 61e9af128..27e1a5f1c 100644 --- a/src/dolphin/os/OSAlarm.c +++ b/src/dolphin/os/OSAlarm.c @@ -23,7 +23,7 @@ void OSCreateAlarm(OSAlarm* alarm) { alarm->tag = 0; } -static inline SetTimer(OSAlarm* alarm) { +static void SetTimer(OSAlarm* alarm) { OSTime delta; delta = alarm->fire_time - __OSGetSystemTime(); @@ -177,7 +177,7 @@ static void DecrementerExceptionCallback(register __OSException exception, OSLoadContext(context); } -static asm void DecrementerExceptionHandler(register __OSException exception, +static ASM void DecrementerExceptionHandler(register __OSException exception, register OSContext* context) { // clang-format off nofralloc diff --git a/src/dolphin/os/OSCache.c b/src/dolphin/os/OSCache.c index 0d3138e6f..d39e8b143 100644 --- a/src/dolphin/os/OSCache.c +++ b/src/dolphin/os/OSCache.c @@ -3,7 +3,7 @@ #include "dolphin/db/db.h" #include "dolphin/os/OS.h" -static asm void DCEnable(void) { +static ASM void DCEnable(void) { // clang-format off nofralloc @@ -16,7 +16,7 @@ static asm void DCEnable(void) { // clang-format on } -asm void DCInvalidateRange(register void* start, register u32 nBytes) { +ASM void DCInvalidateRange(register void* start, register u32 nBytes) { // clang-format off nofralloc @@ -38,7 +38,7 @@ asm void DCInvalidateRange(register void* start, register u32 nBytes) { // clang-format on } -asm void DCFlushRange(register void* start, register u32 nBytes) { +ASM void DCFlushRange(register void* start, register u32 nBytes) { // clang-format off nofralloc @@ -61,7 +61,7 @@ asm void DCFlushRange(register void* start, register u32 nBytes) { // clang-format on } -asm void DCStoreRange(register void* start, register u32 nBytes) { +ASM void DCStoreRange(register void* start, register u32 nBytes) { // clang-format off nofralloc @@ -84,7 +84,7 @@ asm void DCStoreRange(register void* start, register u32 nBytes) { // clang-format on } -asm void DCFlushRangeNoSync(register void* start, register u32 nBytes) { +ASM void DCFlushRangeNoSync(register void* start, register u32 nBytes) { // clang-format off nofralloc @@ -106,7 +106,7 @@ asm void DCFlushRangeNoSync(register void* start, register u32 nBytes) { // clang-format on } -asm void DCStoreRangeNoSync(register void* start, register u32 nBytes) { +ASM void DCStoreRangeNoSync(register void* start, register u32 nBytes) { // clang-format off nofralloc @@ -128,7 +128,7 @@ asm void DCStoreRangeNoSync(register void* start, register u32 nBytes) { // clang-format on } -asm void DCZeroRange(register void* start, register u32 nBytes) { +ASM void DCZeroRange(register void* start, register u32 nBytes) { // clang-format off nofralloc @@ -150,7 +150,7 @@ asm void DCZeroRange(register void* start, register u32 nBytes) { // clang-format on } -asm void ICInvalidateRange(register void* start, register u32 nBytes) { +ASM void ICInvalidateRange(register void* start, register u32 nBytes) { // clang-format off nofralloc @@ -175,7 +175,7 @@ asm void ICInvalidateRange(register void* start, register u32 nBytes) { // clang-format on } -asm void ICFlashInvalidate(void) { +ASM void ICFlashInvalidate(void) { // clang-format off nofralloc @@ -187,7 +187,7 @@ asm void ICFlashInvalidate(void) { // clang-format on } -static asm void ICEnable(void) { +static ASM void ICEnable(void) { // clang-format off nofralloc @@ -200,7 +200,7 @@ static asm void ICEnable(void) { // clang-format on } -asm void __LCEnable(void) { +ASM void __LCEnable(void) { // clang-format off nofralloc @@ -274,7 +274,7 @@ void LCEnable(void) { OSRestoreInterrupts(interrupt); } -asm void LCDisable(void) { +ASM void LCDisable(void) { // clang-format off nofralloc @@ -294,7 +294,7 @@ asm void LCDisable(void) { // clang-format on } -static asm void LCStoreBlocks(register void* destAddr, register void* srcAddr, +static ASM void LCStoreBlocks(register void* destAddr, register void* srcAddr, register u32 blockNum){ // clang-format off nofralloc @@ -331,7 +331,7 @@ u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes) { return ret; } -asm void LCQueueWait(register u32 len) { +ASM void LCQueueWait(register u32 len) { // clang-format off nofralloc diff --git a/src/dolphin/os/OSContext.c b/src/dolphin/os/OSContext.c index 41621d097..e9a06de12 100644 --- a/src/dolphin/os/OSContext.c +++ b/src/dolphin/os/OSContext.c @@ -6,7 +6,7 @@ volatile OSContext* __OSCurrentContext AT_ADDRESS(OS_BASE_CACHED | 0x00D4); volatile OSContext* __OSFPUContext AT_ADDRESS(OS_BASE_CACHED | 0x00D8); -asm void __OSLoadFPUContext(s32 unused0, register OSContext* context) { +ASM void __OSLoadFPUContext(s32 unused0, register OSContext* context) { // clang-format off nofralloc @@ -92,7 +92,7 @@ asm void __OSLoadFPUContext(s32 unused0, register OSContext* context) { // clang-format on } -asm void __OSSaveFPUContext(s32 unused0, s32 unused1, register OSContext* context) { +ASM void __OSSaveFPUContext(s32 unused0, s32 unused1, register OSContext* context) { // clang-format off nofralloc @@ -178,7 +178,7 @@ asm void __OSSaveFPUContext(s32 unused0, s32 unused1, register OSContext* contex // clang-format on } -asm void OSSaveFPUContext(register OSContext* context) { +ASM void OSSaveFPUContext(register OSContext* context) { // clang-format off nofralloc @@ -187,7 +187,7 @@ asm void OSSaveFPUContext(register OSContext* context) { // clang-format on } -asm void OSSetCurrentContext(register OSContext* context) { +ASM void OSSetCurrentContext(register OSContext* context) { // clang-format off nofralloc @@ -223,7 +223,7 @@ OSContext* OSGetCurrentContext(void) { return OS_CURRENT_CONTEXT; } -asm u32 OSSaveContext(register OSContext* context) { +ASM u32 OSSaveContext(register OSContext* context) { // clang-format off nofralloc @@ -267,7 +267,7 @@ asm u32 OSSaveContext(register OSContext* context) { // clang-format on } -asm void OSLoadContext(register OSContext* context) { +ASM void OSLoadContext(register OSContext* context) { // clang-format off nofralloc @@ -334,7 +334,7 @@ asm void OSLoadContext(register OSContext* context) { // clang-format on } -asm u8* OSGetStackPointer(void) { +ASM u8* OSGetStackPointer(void) { // clang-format off nofralloc @@ -352,7 +352,7 @@ void OSClearContext(OSContext* context) { } } -asm void OSInitContext(register OSContext* context, register u32 srr0, register u32 stack) { +ASM void OSInitContext(register OSContext* context, register u32 srr0, register u32 stack) { // clang-format off nofralloc @@ -459,7 +459,7 @@ void OSDumpContext(OSContext* context) { } } -static asm void OSSwitchFPUContext(register u8 err, register OSContext* context) { +static ASM void OSSwitchFPUContext(register u8 err, register OSContext* context) { // clang-format off nofralloc @@ -509,7 +509,7 @@ void __OSContextInit(void) { DBPrintf("FPU-unavailable handler installed\n"); } -asm void OSFillFPUContext(register OSContext* context) { +ASM void OSFillFPUContext(register OSContext* context) { // clang-format off nofralloc diff --git a/src/dolphin/os/OSInterrupt.c b/src/dolphin/os/OSInterrupt.c index edc2522aa..4761ba92b 100644 --- a/src/dolphin/os/OSInterrupt.c +++ b/src/dolphin/os/OSInterrupt.c @@ -6,7 +6,7 @@ vu32 __PIRegs[12] AT_ADDRESS(0xCC003000); vu16 __MEMRegs[64] AT_ADDRESS(0xCC004000); -asm BOOL OSDisableInterrupts(void) { +ASM BOOL OSDisableInterrupts(void) { // clang-format off nofralloc @@ -25,7 +25,7 @@ asm BOOL OSDisableInterrupts(void) { // clang-format on } -asm BOOL OSEnableInterrupts(void) { +ASM BOOL OSEnableInterrupts(void) { // clang-format off nofralloc @@ -40,7 +40,7 @@ asm BOOL OSEnableInterrupts(void) { // clang-format on } -asm BOOL OSRestoreInterrupts(register BOOL status) { +ASM BOOL OSRestoreInterrupts(register BOOL status) { // clang-format off nofralloc @@ -400,7 +400,7 @@ void __OSDispatchInterrupt(__OSException exception, OSContext* context) { OSLoadContext(context); } -static asm void ExternalInterruptHandler(register __OSInterrupt type, register OSContext* context) { +static ASM void ExternalInterruptHandler(register __OSInterrupt type, register OSContext* context) { // clang-format off nofralloc diff --git a/src/dolphin/os/OSMemory.c b/src/dolphin/os/OSMemory.c index 34c28c150..f53e44308 100644 --- a/src/dolphin/os/OSMemory.c +++ b/src/dolphin/os/OSMemory.c @@ -73,7 +73,7 @@ void OSProtectRange(u32 chan, void* addr, u32 nBytes, u32 control) { OSRestoreInterrupts(enabled); } -static asm void Config24MB(void) { +static ASM void Config24MB(void) { // clang-format off nofralloc @@ -112,7 +112,7 @@ static asm void Config24MB(void) { // clang-format on } -static asm void Config48MB(void) { +static ASM void Config48MB(void) { // clang-format off nofralloc @@ -151,7 +151,7 @@ static asm void Config48MB(void) { // clang-format on } -static asm void RealMode(register u32 config) { +static ASM void RealMode(register u32 config) { // clang-format off nofralloc diff --git a/src/dolphin/os/OSReboot.c b/src/dolphin/os/OSReboot.c index 1da64fc38..2a3af285d 100644 --- a/src/dolphin/os/OSReboot.c +++ b/src/dolphin/os/OSReboot.c @@ -22,7 +22,7 @@ typedef struct _ApploaderHeader { static ApploaderHeader Header ALIGN_DECL(32); -asm static void Run(register u32 addr) { +ASM static void Run(register u32 addr) { nofralloc sync diff --git a/src/dolphin/os/OSReset.c b/src/dolphin/os/OSReset.c index 4606713b7..7ce4e7325 100644 --- a/src/dolphin/os/OSReset.c +++ b/src/dolphin/os/OSReset.c @@ -56,7 +56,7 @@ inline BOOL __OSCallResetFunctions(u32 arg0) { } #ifdef __MWERKS__ -static asm void Reset(register s32 param_0) { +static ASM void Reset(register s32 param_0) { // clang-format off nofralloc diff --git a/src/dolphin/os/OSSync.c b/src/dolphin/os/OSSync.c index fd7b70863..d8fa1f109 100644 --- a/src/dolphin/os/OSSync.c +++ b/src/dolphin/os/OSSync.c @@ -4,7 +4,7 @@ void __OSSystemCallVectorStart(); void __OSSystemCallVectorEnd(); -static asm void SystemCallVector(void) { +static ASM void SystemCallVector(void) { // clang-format off nofralloc diff --git a/src/dolphin/os/OSTime.c b/src/dolphin/os/OSTime.c index cd622f5e2..8754c8459 100644 --- a/src/dolphin/os/OSTime.c +++ b/src/dolphin/os/OSTime.c @@ -5,9 +5,9 @@ #define OS_TIME_WEEK_DAY_MAX 7 #define OS_TIME_YEAR_DAY_MAX 365 -#ifdef __MWERKS__ -asm OSTime OSGetTime(void) { +ASM OSTime OSGetTime(void) { // clang-format off +#ifdef __MWERKS__ nofralloc mftbu r3 @@ -18,20 +18,20 @@ asm OSTime OSGetTime(void) { bne OSGetTime blr +#endif // clang-format on } -#endif -#ifdef __MWERKS__ -asm OSTick OSGetTick(void) { +ASM OSTick OSGetTick(void) { // clang-format off +#ifdef __MWERKS__ nofralloc mftb r3, 0x10C blr +#endif // clang-format on } -#endif #define OS_SYSTEMTIME_BASE 0x30D8 diff --git a/src/dolphin/os/__start.c b/src/dolphin/os/__start.c index 62698b6b1..3831936a5 100644 --- a/src/dolphin/os/__start.c +++ b/src/dolphin/os/__start.c @@ -11,7 +11,7 @@ SECTION_INIT void __check_pad3(void) { } } -SECTION_INIT asm void __start(void) { +SECTION_INIT ASM void __start(void) { // clang-format off nofralloc @@ -114,7 +114,7 @@ SECTION_INIT asm void __start(void) { // clang-format on } -asm static void __init_registers(void) +ASM static void __init_registers(void) { #ifdef __MWERKS__ nofralloc @@ -165,7 +165,7 @@ void __init_data(void) } } -asm void __init_hardware() { +ASM void __init_hardware() { #ifdef __MWERKS__ // clang-format off nofralloc mfmsr r0 @@ -179,7 +179,7 @@ asm void __init_hardware() { #endif // clang-format on } -asm void __flush_cache(void* addr, u32 size) +ASM void __flush_cache(void* addr, u32 size) { #ifdef __MWERKS__ nofralloc