diff --git a/Makefile.wiiu b/Makefile.wiiu index 701d3c3214..753ade52b9 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -16,7 +16,7 @@ OBJ += wiiu/tex_shader.o ifneq ($(RPX_BUILD), 1) OBJ += wiiu/system/dynamic.o -OBJ += wiiu/system/dyn_stubs.o +OBJ += wiiu/system/stubs_elf.o endif DEFINES := diff --git a/wiiu/system/dynamic.c b/wiiu/system/dynamic.c index e10c13933b..8b929071d4 100644 --- a/wiiu/system/dynamic.c +++ b/wiiu/system/dynamic.c @@ -1,18 +1,19 @@ #include #include -#define EXPORT(name) void* addr_##name -#define EXPORT_BEGIN(lib) -#define EXPORT_END() -#include "exports/all.h" +#define IMPORT(name) void* addr_##name +#define IMPORT_BEGIN(lib) +#define IMPORT_END() +#include "imports.h" -#undef EXPORT -#undef EXPORT_BEGIN -//#undef EXPORT_END +#undef IMPORT +#undef IMPORT_BEGIN +#undef IMPORT_END -#define EXPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0) -#define EXPORT_BEGIN(lib) OSDynLoad_Acquire(#lib, &handle) -//#define EXPORT_END() OSDynLoad_Release(handle) +#define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0) +#define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle) +//#define IMPORT_END() OSDynLoad_Release(handle) +#define IMPORT_END() void InitFunctionPointers(void) { @@ -20,6 +21,6 @@ void InitFunctionPointers(void) addr_OSDynLoad_Acquire = *(void**)0x00801500; addr_OSDynLoad_FindExport = *(void**)0x00801504; -#include "exports/all.h" +#include "imports.h" } diff --git a/wiiu/system/exports/all.h b/wiiu/system/exports/all.h deleted file mode 100644 index c2accb1058..0000000000 --- a/wiiu/system/exports/all.h +++ /dev/null @@ -1,8 +0,0 @@ - -#include "libcoreinit.h" -#include "libnsysnet.h" -#include "libgx2.h" -#include "libproc_ui.h" -#include "libsndcore2.h" -#include "libsysapp.h" -#include "libvpad.h" diff --git a/wiiu/system/exports/libcoreinit.h b/wiiu/system/exports/libcoreinit.h deleted file mode 100644 index b291de7f76..0000000000 --- a/wiiu/system/exports/libcoreinit.h +++ /dev/null @@ -1,7 +0,0 @@ - -EXPORT_BEGIN(coreinit.rpl); - -/* OSFatal should preferably be put first in the list */ -#include "../rpl/libcoreinit/exports.h" - -EXPORT_END(); diff --git a/wiiu/system/exports/libgx2.h b/wiiu/system/exports/libgx2.h deleted file mode 100644 index 7d8ebf90bf..0000000000 --- a/wiiu/system/exports/libgx2.h +++ /dev/null @@ -1,6 +0,0 @@ - -EXPORT_BEGIN(gx2.rpl); - -#include "../rpl/libgx2/exports.h" -EXPORT(GX2GetSwapStatus); -EXPORT_END(); diff --git a/wiiu/system/exports/libnsysnet.h b/wiiu/system/exports/libnsysnet.h deleted file mode 100644 index e950006893..0000000000 --- a/wiiu/system/exports/libnsysnet.h +++ /dev/null @@ -1,6 +0,0 @@ - -EXPORT_BEGIN(nsysnet.rpl); - -#include "../rpl/libnsysnet/exports.h" - -EXPORT_END(); diff --git a/wiiu/system/exports/libproc_ui.h b/wiiu/system/exports/libproc_ui.h deleted file mode 100644 index 870b28b86f..0000000000 --- a/wiiu/system/exports/libproc_ui.h +++ /dev/null @@ -1,6 +0,0 @@ - -EXPORT_BEGIN(proc_ui.rpl); - -#include "../rpl/libproc_ui/exports.h" - -EXPORT_END(); diff --git a/wiiu/system/exports/libsndcore2.h b/wiiu/system/exports/libsndcore2.h deleted file mode 100644 index 649cabf62e..0000000000 --- a/wiiu/system/exports/libsndcore2.h +++ /dev/null @@ -1,18 +0,0 @@ - -EXPORT_BEGIN(sndcore2.rpl); - -#include "../rpl/libsndcore2/exports.h" - -EXPORT(AXRegisterFrameCallback); - -EXPORT(AXAcquireMultiVoice); -EXPORT(AXSetMultiVoiceDeviceMix); -EXPORT(AXSetMultiVoiceOffsets); -EXPORT(AXSetMultiVoiceState); -EXPORT(AXSetMultiVoiceVe); -EXPORT(AXSetMultiVoiceSrcType); -EXPORT(AXSetMultiVoiceSrcRatio); -EXPORT(AXIsMultiVoiceRunning); -EXPORT(AXFreeMultiVoice); - -EXPORT_END(); diff --git a/wiiu/system/exports/libsysapp.h b/wiiu/system/exports/libsysapp.h deleted file mode 100644 index 8a5759dcfc..0000000000 --- a/wiiu/system/exports/libsysapp.h +++ /dev/null @@ -1,6 +0,0 @@ - -EXPORT_BEGIN(sysapp.rpl); - -#include "../rpl/libsysapp/exports.h" - -EXPORT_END(); diff --git a/wiiu/system/exports/libvpad.h b/wiiu/system/exports/libvpad.h deleted file mode 100644 index 9df6a5e438..0000000000 --- a/wiiu/system/exports/libvpad.h +++ /dev/null @@ -1,6 +0,0 @@ - -EXPORT_BEGIN(vpad.rpl); - -#include "../rpl/libvpad/exports.h" - -EXPORT_END(); diff --git a/wiiu/system/imports.h b/wiiu/system/imports.h new file mode 100644 index 0000000000..e660fe2f86 --- /dev/null +++ b/wiiu/system/imports.h @@ -0,0 +1,166 @@ +/* coreinit */ +IMPORT_BEGIN(coreinit); + +IMPORT(OSFatal); +IMPORT(OSDynLoad_Acquire); +IMPORT(OSDynLoad_FindExport); +IMPORT(OSDynLoad_Release); +IMPORT(OSSetExceptionCallback); +IMPORT(OSSavesDone_ReadyToRelease); +IMPORT(OSInitMutex); +IMPORT(OSLockMutex); +IMPORT(OSUnlockMutex); +IMPORT(OSInitSpinLock); +IMPORT(OSUninterruptibleSpinLock_Acquire); +IMPORT(OSUninterruptibleSpinLock_Release); +IMPORT(OSSleepTicks); +IMPORT(OSYieldThread); +IMPORT(OSGetSystemTime); +IMPORT(OSGetSystemTick); + +IMPORT(exit); +IMPORT(_Exit); +IMPORT(__os_snprintf); + +IMPORT(DCFlushRange); +IMPORT(DCStoreRange); +IMPORT(DCStoreRangeNoSync); + +IMPORT(MEMGetBaseHeapHandle); +IMPORT(MEMCreateExpHeapEx); +IMPORT(MEMDestroyExpHeap); +IMPORT(MEMAllocFromExpHeapEx); +IMPORT(MEMFreeToExpHeap); +IMPORT(MEMGetSizeForMBlockExpHeap); +IMPORT(MEMAllocFromFrmHeapEx); +IMPORT(MEMFreeToFrmHeap); +IMPORT(MEMGetAllocatableSizeForFrmHeapEx); + +IMPORT(FSInit); +IMPORT(FSShutdown); +IMPORT(FSAddClient); +IMPORT(FSDelClient); +IMPORT(FSInitCmdBlock); +IMPORT(FSChangeDir); +IMPORT(FSGetFreeSpaceSize); +IMPORT(FSGetStat); +IMPORT(FSRemove); +IMPORT(FSOpenFile); +IMPORT(FSCloseFile); +IMPORT(FSOpenDir); +IMPORT(FSMakeDir); +IMPORT(FSReadDir); +IMPORT(FSRewindDir); +IMPORT(FSCloseDir); +IMPORT(FSGetStatFile); +IMPORT(FSReadFile); +IMPORT(FSWriteFile); +IMPORT(FSSetPosFile); +IMPORT(FSFlushFile); +IMPORT(FSTruncateFile); +IMPORT(FSRename); +IMPORT(FSGetMountSource); +IMPORT(FSMount); +IMPORT(FSUnmount); + +IMPORT_END(); + +/* nsysnet */ +IMPORT_BEGIN(nsysnet); + +IMPORT(socket_lib_init); +IMPORT(socket); +IMPORT(socketclose); +IMPORT(connect); +IMPORT(send); +IMPORT(inet_aton); + +IMPORT_END(); + +/* gx2 */ +IMPORT_BEGIN(gx2); + +IMPORT(GX2Invalidate); +IMPORT(GX2Init); +IMPORT(GX2GetSystemTVScanMode); +IMPORT(GX2CalcTVSize); +IMPORT(GX2SetTVBuffer); +IMPORT(GX2CalcDRCSize); +IMPORT(GX2SetDRCBuffer); +IMPORT(GX2CalcSurfaceSizeAndAlignment); +IMPORT(GX2InitColorBufferRegs); +IMPORT(GX2SetupContextStateEx); +IMPORT(GX2SetContextState); +IMPORT(GX2SetColorBuffer); +IMPORT(GX2SetViewport); +IMPORT(GX2SetScissor); +IMPORT(GX2SetDepthOnlyControl); +IMPORT(GX2SetColorControl); +IMPORT(GX2SetBlendControl); +IMPORT(GX2SetCullOnlyControl); +IMPORT(GX2CalcFetchShaderSizeEx); +IMPORT(GX2InitFetchShaderEx); +IMPORT(GX2SetFetchShader); +IMPORT(GX2SetVertexShader); +IMPORT(GX2SetPixelShader); +IMPORT(GX2SetAttribBuffer); +IMPORT(GX2InitTextureRegs); +IMPORT(GX2InitSampler); +IMPORT(GX2SetPixelTexture); +IMPORT(GX2SetPixelSampler); +IMPORT(GX2ClearColor); +IMPORT(GX2CopyColorBufferToScanBuffer); +IMPORT(GX2SwapScanBuffers); +IMPORT(GX2Flush); +IMPORT(GX2WaitForVsync); +IMPORT(GX2SetTVEnable); +IMPORT(GX2SetDRCEnable); +IMPORT(GX2SetSwapInterval); +IMPORT(GX2DrawDone); +IMPORT(GX2Shutdown); +IMPORT(GX2DrawEx); +IMPORT(GX2WaitForFlip); +IMPORT(GX2GetSwapStatus); + +IMPORT_END(); + +/* proc_ui */ +IMPORT_BEGIN(proc_ui); + +IMPORT(ProcUIInit); +IMPORT(ProcUIShutdown); + +IMPORT_END(); + +/* sndcore2 */ +IMPORT_BEGIN(sndcore2); + +IMPORT(AXInitWithParams); +IMPORT(AXQuit); +IMPORT(AXRegisterFrameCallback); +IMPORT(AXAcquireMultiVoice); +IMPORT(AXSetMultiVoiceDeviceMix); +IMPORT(AXSetMultiVoiceOffsets); +IMPORT(AXSetMultiVoiceState); +IMPORT(AXSetMultiVoiceVe); +IMPORT(AXSetMultiVoiceSrcType); +IMPORT(AXSetMultiVoiceSrcRatio); +IMPORT(AXIsMultiVoiceRunning); +IMPORT(AXFreeMultiVoice); + +IMPORT_END(); + +/* sysapp */ +IMPORT_BEGIN(sysapp); + +IMPORT(SYSRelaunchTitle); + +IMPORT_END(); + +/* vpad */ +IMPORT_BEGIN(vpad); + +IMPORT(VPADRead); +IMPORT(VPADInit); + +IMPORT_END(); diff --git a/wiiu/system/dyn_stubs.S b/wiiu/system/stubs_elf.S similarity index 72% rename from wiiu/system/dyn_stubs.S rename to wiiu/system/stubs_elf.S index 1b2f85d7ed..2fb57eb6b1 100644 --- a/wiiu/system/dyn_stubs.S +++ b/wiiu/system/stubs_elf.S @@ -1,4 +1,4 @@ -/*#define EXPORT(name) \ +/*#define IMPORT(name) \ .global name; \ name: \ lis %r11, addr_##name@h; \ @@ -6,7 +6,7 @@ mtctr %r11; \ bctr*/ -#define EXPORT(name) \ +#define IMPORT(name) \ .global name; \ name: \ lis %r11, addr_##name@h; \ @@ -15,11 +15,11 @@ mtctr %r11; \ bctr -#define EXPORT_BEGIN(lib) -#define EXPORT_END() +#define IMPORT_BEGIN(lib) +#define IMPORT_END() .align 2; .section ".text"; -#include "exports/all.h" +#include "imports.h"