diff --git a/include/dolphin/dsp.h b/include/dolphin/dsp.h index a0b295351..36ca71e83 100644 --- a/include/dolphin/dsp.h +++ b/include/dolphin/dsp.h @@ -3,9 +3,10 @@ #include "dolphin/os/OS.h" #include "dolphin/types.h" +#include "dolphin/os/OSUtil.h" -volatile u16 __DSPRegs[32] : 0xCC005000; -volatile u32 __AIRegs[8] : 0xCC006C00; +volatile u16 __DSPRegs[32] AT_ADDRESS(0xCC005000); +volatile u32 __AIRegs[8] AT_ADDRESS(0xCC006C00); #ifdef __cplusplus extern "C" { diff --git a/include/dolphin/dvd/dvdlow.h b/include/dolphin/dvd/dvdlow.h index a7645d901..31b863974 100644 --- a/include/dolphin/dvd/dvdlow.h +++ b/include/dolphin/dvd/dvdlow.h @@ -2,8 +2,9 @@ #define DVDLOW_H #include "dolphin/types.h" +#include "dolphin/os/OSUtil.h" typedef void (*DVDLowCallback)(u32 intType); -vu32 __DIRegs[16] : 0xCC006000; +vu32 __DIRegs[16] AT_ADDRESS(0xCC006000); #endif /* DVDLOW_H */ diff --git a/include/dolphin/exi/EXIBios.h b/include/dolphin/exi/EXIBios.h index 00099f62b..40bee83b0 100644 --- a/include/dolphin/exi/EXIBios.h +++ b/include/dolphin/exi/EXIBios.h @@ -2,6 +2,7 @@ #define EXIBIOS_H #include "dolphin/types.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -9,7 +10,7 @@ extern "C" { typedef struct OSContext OSContext; -vu32 __EXIRegs[16] : 0xCC006800; +vu32 __EXIRegs[16] AT_ADDRESS(0xCC006800); #define EXI_MEMORY_CARD_59 0x00000004 #define EXI_MEMORY_CARD_123 0x00000008 diff --git a/include/dolphin/gx/GX.h b/include/dolphin/gx/GX.h index 39c2ec5e4..32c35737f 100644 --- a/include/dolphin/gx/GX.h +++ b/include/dolphin/gx/GX.h @@ -14,6 +14,7 @@ #include "dolphin/gx/GXTev.h" #include "dolphin/gx/GXTexture.h" #include "dolphin/gx/GXTransform.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -41,7 +42,7 @@ typedef union { f64 f64; } PPCWGPipe; -volatile PPCWGPipe GXFIFO : 0xCC008000; +volatile PPCWGPipe GXFIFO AT_ADDRESS(0xCC008000); // Direct inline void GXPosition2f32(f32 x, f32 z) { diff --git a/include/dolphin/os/OS.h b/include/dolphin/os/OS.h index fe1ad7e9f..d37a4f3f3 100644 --- a/include/dolphin/os/OS.h +++ b/include/dolphin/os/OS.h @@ -24,6 +24,7 @@ #include "dolphin/os/OSSync.h" #include "dolphin/os/OSThread.h" #include "dolphin/os/OSTime.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -59,19 +60,19 @@ extern "C" { #define OS_CONSOLE_PC_EMULATOR 0x10000001 #define OS_CONSOLE_EMULATOR 0x10000000 -volatile u16 __OSDeviceCode : 0x800030E6; +volatile u16 __OSDeviceCode AT_ADDRESS(0x800030E6); -volatile u32 OS_PI_INTR_CAUSE : 0xCC003000; -volatile u32 OS_PI_INTR_MASK : 0xCC003004; +volatile u32 OS_PI_INTR_CAUSE AT_ADDRESS(0xCC003000); +volatile u32 OS_PI_INTR_MASK AT_ADDRESS(0xCC003004); -volatile u16 OS_MI_INTR_MASK : 0xCC00401C; +volatile u16 OS_MI_INTR_MASK AT_ADDRESS(0xCC00401C); -volatile u16 OS_DSP_DMA_ADDR_HI : 0xCC005030; -volatile u16 OS_DSP_DMA_ADDR_LO : 0xCC005032; -volatile u16 OS_DSP_INTR_MASK : 0xCC00500A; +volatile u16 OS_DSP_DMA_ADDR_HI AT_ADDRESS(0xCC005030); +volatile u16 OS_DSP_DMA_ADDR_LO AT_ADDRESS(0xCC005032); +volatile u16 OS_DSP_INTR_MASK AT_ADDRESS(0xCC00500A); -volatile u16 OS_ARAM_DMA_ADDR_HI : 0xCC005020; -volatile u16 OS_ARAM_DMA_ADDR_LO : 0xCC005022; +volatile u16 OS_ARAM_DMA_ADDR_HI AT_ADDRESS(0xCC005020); +volatile u16 OS_ARAM_DMA_ADDR_LO AT_ADDRESS(0xCC005022); BOOL OSIsThreadSuspended(OSThread* thread); @@ -89,8 +90,8 @@ extern u8 __OSReport_enable; extern BOOL __OSIsGcam; -extern u32 BOOT_REGION_START : 0x812FDFF0; -extern u32 BOOT_REGION_END : 0x812FDFEC; +extern u32 BOOT_REGION_START AT_ADDRESS(0x812FDFF0); +extern u32 BOOT_REGION_END AT_ADDRESS(0x812FDFEC); void OSReportInit__Fv(void); // needed for inline asm diff --git a/include/dolphin/os/OSContext.h b/include/dolphin/os/OSContext.h index 78562a353..35af16433 100644 --- a/include/dolphin/os/OSContext.h +++ b/include/dolphin/os/OSContext.h @@ -2,6 +2,7 @@ #define OSCONTEXT_H #include "dolphin/types.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -151,8 +152,8 @@ typedef struct OSContext { /* 0x1C4 */ f64 ps[32]; } OSContext; -OSContext* OS_CURRENT_CONTEXT : 0x800000D4; -OSContext* OS_CURRENT_FPU_CONTEXT : 0x800000D8; +OSContext* OS_CURRENT_CONTEXT AT_ADDRESS(0x800000D4); +OSContext* OS_CURRENT_FPU_CONTEXT AT_ADDRESS(0x800000D8); void __OSLoadFPUContext(void); void __OSSaveFPUContext(s32 unused0, s32 unused1, OSContext* context); diff --git a/include/dolphin/os/OSLink.h b/include/dolphin/os/OSLink.h index 55e63d5e2..f344c9bc1 100644 --- a/include/dolphin/os/OSLink.h +++ b/include/dolphin/os/OSLink.h @@ -1,6 +1,7 @@ #ifndef OSLINK_H #define OSLINK_H +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -18,8 +19,8 @@ typedef struct OSSectionInfo OSSectionInfo; typedef struct OSImportInfo OSImportInfo; typedef struct OSRel OSRel; -OSModuleQueue __OSModuleList : 0x800030C8; -void* __OSStringTable : 0x800030D0; +OSModuleQueue __OSModuleList AT_ADDRESS(0x800030C8); +void* __OSStringTable AT_ADDRESS(0x800030D0); struct OSModuleQueue { OSModuleInfo* head; diff --git a/include/dolphin/os/OSReset.h b/include/dolphin/os/OSReset.h index 54678e53d..81f0904ff 100644 --- a/include/dolphin/os/OSReset.h +++ b/include/dolphin/os/OSReset.h @@ -2,12 +2,13 @@ #define OSRESET_H #include "dolphin/types.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { #endif -vu32 __PIRegs[12] : 0xCC003000; +vu32 __PIRegs[12] AT_ADDRESS(0xCC003000); #define OS_RESETCODE_RESTART 0x80000000 #define OS_RESETCODE_SYSTEM 0x40000000 diff --git a/include/dolphin/os/OSThread.h b/include/dolphin/os/OSThread.h index f13bc3479..af9ac6b23 100644 --- a/include/dolphin/os/OSThread.h +++ b/include/dolphin/os/OSThread.h @@ -2,6 +2,7 @@ #define OSTHREAD_H #include "dolphin/os/OSContext.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -75,8 +76,8 @@ struct OSThread { typedef void (*OSSwitchThreadCallback)(OSThread* from, OSThread* to); -OSThreadQueue OS_THREAD_QUEUE : 0x800000DC; -OSThread* OS_CURRENT_THREAD : 0x800000E4; +OSThreadQueue OS_THREAD_QUEUE AT_ADDRESS(0x800000DC); +OSThread* OS_CURRENT_THREAD AT_ADDRESS(0x800000E4); static void DefaultSwitchThreadCallback(OSThread* from, OSThread* to); OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback func); diff --git a/include/dolphin/os/OSTime.h b/include/dolphin/os/OSTime.h index c0df3585f..36f106a5e 100644 --- a/include/dolphin/os/OSTime.h +++ b/include/dolphin/os/OSTime.h @@ -2,6 +2,7 @@ #define OSTIME_H #include "dolphin/types.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -10,7 +11,7 @@ extern "C" { typedef s64 OSTime; typedef u32 OSTick; -OSTime OS_SYSTEM_TIME : 0x800030D8; +OSTime OS_SYSTEM_TIME AT_ADDRESS(0x800030D8); typedef struct OSCalendarTime { /* 0x00 */ s32 seconds; @@ -32,7 +33,7 @@ OSTime __OSTimeToSystemTime(OSTime time); void GetDates(s32 days, OSCalendarTime* ct); void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* ct); -extern u32 __OSBusClock : 0x800000F8; +extern u32 __OSBusClock AT_ADDRESS(0x800000F8); #define OS_BUS_CLOCK (__OSBusClock) #define OS_CORE_CLOCK (*(u32*)0x800000FC) diff --git a/include/dolphin/os/OSUtil.h b/include/dolphin/os/OSUtil.h new file mode 100644 index 000000000..e565be714 --- /dev/null +++ b/include/dolphin/os/OSUtil.h @@ -0,0 +1,21 @@ +#ifndef _DOLPHIN_OS_OSUTIL_H +#define _DOLPHIN_OS_OSUTIL_H + +#include "dolphin/types.h" + +#ifdef __cplusplus +extern "C" { +#endif // ifdef __cplusplus + +// Macro to make it more clear when something is an address, and to prevent intellisense errors. +#ifdef __MWERKS__ +#define AT_ADDRESS(addr) : (addr) +#else +#define AT_ADDRESS(addr) +#endif + +#ifdef __cplusplus +}; +#endif // ifdef __cplusplus + +#endif diff --git a/include/dolphin/os/__start.h b/include/dolphin/os/__start.h index 3ce610ce1..bf4c01124 100644 --- a/include/dolphin/os/__start.h +++ b/include/dolphin/os/__start.h @@ -2,6 +2,7 @@ #define __START_H #include "global.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -21,7 +22,7 @@ extern "C" { extern void InitMetroTRK(); -u16 Pad3Button : PAD3_BUTTON_ADDR; +u16 Pad3Button AT_ADDRESS(PAD3_BUTTON_ADDR); extern int main(int argc, char* argv[]); extern void exit(int); diff --git a/include/dolphin/si/SIBios.h b/include/dolphin/si/SIBios.h index b5f10067d..2e8d19de4 100644 --- a/include/dolphin/si/SIBios.h +++ b/include/dolphin/si/SIBios.h @@ -3,6 +3,7 @@ #include "dolphin/os/OSInterrupt.h" #include "dolphin/os/OSTime.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -121,7 +122,7 @@ u32 SIGetType(s32 chan); u32 SIGetTypeAsync(s32 chan, SITypeAndStatusCallback callback); u32 SIProbe(s32 chan); -vu32 __SIRegs[64] : 0xCC006400; +vu32 __SIRegs[64] AT_ADDRESS(0xCC006400); #ifdef __cplusplus } diff --git a/include/dolphin/vi/vi.h b/include/dolphin/vi/vi.h index f233b3024..901879e5e 100644 --- a/include/dolphin/vi/vi.h +++ b/include/dolphin/vi/vi.h @@ -2,6 +2,7 @@ #define VI_H #include "dolphin/types.h" +#include "dolphin/os/OSUtil.h" #ifdef __cplusplus extern "C" { @@ -54,7 +55,7 @@ void VISetBlack(BOOL); u32 VIGetRetraceCount(); u32 VIGetDTVStatus(); -vu16 __VIRegs[59] : 0xCC002000; +vu16 __VIRegs[59] AT_ADDRESS(0xCC002000); #ifdef __cplusplus }; diff --git a/src/dolphin/os/OS.c b/src/dolphin/os/OS.c index 8e6a1a744..3aaa7cdaa 100644 --- a/src/dolphin/os/OS.c +++ b/src/dolphin/os/OS.c @@ -628,7 +628,7 @@ asm void __OSPSInit(void){ // clang-format on } -vu32 __DIRegs[16] : 0xCC006000; +vu32 __DIRegs[16] AT_ADDRESS(0xCC006000); #define DI_CONFIG_IDX 0x9 #define DI_CONFIG_CONFIG_MASK 0xFF diff --git a/src/dolphin/os/OSContext.c b/src/dolphin/os/OSContext.c index f41d4aff2..6fa8f0e82 100644 --- a/src/dolphin/os/OSContext.c +++ b/src/dolphin/os/OSContext.c @@ -1,9 +1,10 @@ #include "dolphin/os/OSContext.h" #include "dolphin/db/db.h" #include "dolphin/os/OS.h" +#include "dolphin/os/OSUtil.h" -volatile OSContext* __OSCurrentContext : (OS_BASE_CACHED | 0x00D4); -volatile OSContext* __OSFPUContext : (OS_BASE_CACHED | 0x00D8); +volatile OSContext* __OSCurrentContext AT_ADDRESS(OS_BASE_CACHED | 0x00D4); +volatile OSContext* __OSFPUContext AT_ADDRESS(OS_BASE_CACHED | 0x00D8); asm void __OSLoadFPUContext(void) { // clang-format off diff --git a/src/dolphin/os/OSError.c b/src/dolphin/os/OSError.c index 53bb300c6..4e184693f 100644 --- a/src/dolphin/os/OSError.c +++ b/src/dolphin/os/OSError.c @@ -4,9 +4,9 @@ #include "dolphin/dvd/dvdlow.h" #include "dolphin/os/OS.h" -OSThread* __OSCurrentThread : (OS_BASE_CACHED | 0x00E4); -OSThreadQueue __OSActiveThreadQueue : (OS_BASE_CACHED | 0x00DC); -volatile OSContext* __OSFPUContext : (OS_BASE_CACHED | 0x00D8); +OSThread* __OSCurrentThread AT_ADDRESS(OS_BASE_CACHED | 0x00E4); +OSThreadQueue __OSActiveThreadQueue AT_ADDRESS(OS_BASE_CACHED | 0x00DC); +volatile OSContext* __OSFPUContext AT_ADDRESS(OS_BASE_CACHED | 0x00D8); extern volatile u32 __OSLastInterruptSrr0; extern volatile s16 __OSLastInterrupt; diff --git a/src/dolphin/os/OSInterrupt.c b/src/dolphin/os/OSInterrupt.c index 711bfcce5..edc2522aa 100644 --- a/src/dolphin/os/OSInterrupt.c +++ b/src/dolphin/os/OSInterrupt.c @@ -3,8 +3,8 @@ #include "dolphin/exi/EXIBios.h" #include "dolphin/os/OS.h" -vu32 __PIRegs[12] : 0xCC003000; -vu16 __MEMRegs[64] : 0xCC004000; +vu32 __PIRegs[12] AT_ADDRESS(0xCC003000); +vu16 __MEMRegs[64] AT_ADDRESS(0xCC004000); asm BOOL OSDisableInterrupts(void) { // clang-format off diff --git a/src/dolphin/os/OSLink.c b/src/dolphin/os/OSLink.c index e0e987d86..6acb67921 100644 --- a/src/dolphin/os/OSLink.c +++ b/src/dolphin/os/OSLink.c @@ -107,7 +107,7 @@ __prev->link.next = __next; \ } while (0) -OSModuleQueue __OSModuleInfoList : (OS_BASE_CACHED | 0x30C8); +OSModuleQueue __OSModuleInfoList AT_ADDRESS(OS_BASE_CACHED | 0x30C8); #pragma dont_inline on diff --git a/src/dolphin/os/OSMemory.c b/src/dolphin/os/OSMemory.c index a91576ed4..34c28c150 100644 --- a/src/dolphin/os/OSMemory.c +++ b/src/dolphin/os/OSMemory.c @@ -4,7 +4,7 @@ #define TRUNC(n, a) (((u32)(n)) & ~((a)-1)) #define ROUND(n, a) (((u32)(n) + (a)-1) & ~((a)-1)) -vu16 __MEMRegs[64] : 0xCC004000; +vu16 __MEMRegs[64] AT_ADDRESS(0xCC004000); extern OSErrorHandlerEx __OSErrorTable[16]; diff --git a/src/dolphin/os/OSReboot.c b/src/dolphin/os/OSReboot.c index 91f763f12..92879288b 100644 --- a/src/dolphin/os/OSReboot.c +++ b/src/dolphin/os/OSReboot.c @@ -1,14 +1,14 @@ -#include "dolphin/os/Os.h" +#include "dolphin/os/OS.h" #include "dolphin/os/OSReboot.h" static void* SaveStart = NULL; static void* SaveEnd = NULL; static volatile BOOL Prepared; -extern u32 OS_RESET_CODE : 0x800030F0; -extern u8 OS_REBOOT_BOOL : 0x800030E2; // unknown function, set to true by __OSReboot -extern u32 UNK_817FFFF8 : 0x817FFFF8; -extern u32 UNK_817FFFFC : 0x817FFFFC; +extern u32 OS_RESET_CODE AT_ADDRESS(0x800030F0); +extern u8 OS_REBOOT_BOOL AT_ADDRESS(0x800030E2); // unknown function, set to true by __OSReboot +extern u32 UNK_817FFFF8 AT_ADDRESS(0x817FFFF8); +extern u32 UNK_817FFFFC AT_ADDRESS(0x817FFFFC); #define OS_BOOTROM_ADDR 0x81300000 diff --git a/src/dolphin/os/OSReset.c b/src/dolphin/os/OSReset.c index be39a12f3..4f131b1a5 100644 --- a/src/dolphin/os/OSReset.c +++ b/src/dolphin/os/OSReset.c @@ -1,8 +1,8 @@ #include "dolphin/os/OSReset.h" #include "dolphin/os/OS.h" -vu16 __VIRegs[59] : 0xCC002000; -OSThreadQueue __OSActiveThreadQueue : (OS_BASE_CACHED | 0x00DC); +vu16 __VIRegs[59] AT_ADDRESS(0xCC002000); +OSThreadQueue __OSActiveThreadQueue AT_ADDRESS(OS_BASE_CACHED | 0x00DC); static OSResetQueue ResetFunctionQueue; diff --git a/src/dolphin/os/OSResetSW.c b/src/dolphin/os/OSResetSW.c index 386bc20db..34b47726f 100644 --- a/src/dolphin/os/OSResetSW.c +++ b/src/dolphin/os/OSResetSW.c @@ -2,7 +2,7 @@ #include "dolphin/os/OS.h" #include "dolphin/os/OSReset.h" -u8 GameChoice : (OS_BASE_CACHED | 0x30E3); +u8 GameChoice AT_ADDRESS(OS_BASE_CACHED | 0x30E3); void __OSResetSWInterruptHandler(__OSInterrupt interrupt, OSContext* context); diff --git a/src/dolphin/os/OSThread.c b/src/dolphin/os/OSThread.c index a420c7496..a5c0e3238 100644 --- a/src/dolphin/os/OSThread.c +++ b/src/dolphin/os/OSThread.c @@ -7,10 +7,10 @@ #include "dolphin/os/OSThread.h" #include "dolphin/os/OS.h" -OSThread* __OSCurrentThread : OS_BASE_CACHED + 0x00E4; -OSThreadQueue __OSActiveThreadQueue : OS_BASE_CACHED + 0x00DC; -volatile OSContext __OSCurrentContext : OS_BASE_CACHED + 0x00D4; -volatile OSContext* __OSFPUContext : OS_BASE_CACHED + 0x00D8; +OSThread* __OSCurrentThread AT_ADDRESS(OS_BASE_CACHED + 0x00E4); +OSThreadQueue __OSActiveThreadQueue AT_ADDRESS(OS_BASE_CACHED + 0x00DC); +volatile OSContext __OSCurrentContext AT_ADDRESS(OS_BASE_CACHED + 0x00D4); +volatile OSContext* __OSFPUContext AT_ADDRESS(OS_BASE_CACHED + 0x00D8); #define AddTail(queue, thread, link) \ do { \