From 9834fc7f70a1019dde2f1721ceb42f5ac80a8cca Mon Sep 17 00:00:00 2001 From: Arkaran99 Date: Sun, 7 Sep 2014 15:13:38 +0200 Subject: [PATCH 1/3] Update gitignore to ignore x64 folders. --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a404287376..8daea8f806 100644 --- a/.gitignore +++ b/.gitignore @@ -64,8 +64,7 @@ rpcs3/git-version.h # Ignore other system generated files bin/dev_hdd0/*.txt -x64/Debug/emucore.lib -x64/Release/emucore.lib +x64/* rpcs3/x64/* .DS_Store From 7dafb164e8829b060cbc5d7879ea6b7454aafa9b Mon Sep 17 00:00:00 2001 From: Arkaran99 Date: Thu, 11 Sep 2014 00:59:50 +0200 Subject: [PATCH 2/3] Remove unused include and very small refactoring. Unused include in unself.h, ELF.h. New line after an if to enable debugging. Rewrite strange boolean expression in ELF.cpp. --- rpcs3/Crypto/unself.h | 3 ++- rpcs3/Emu/FS/vfsStream.cpp | 12 +++++++++--- rpcs3/Gui/DisAsmFrame.cpp | 2 ++ rpcs3/Loader/ELF.cpp | 40 +++++++++++++++++++++++--------------- rpcs3/Loader/ELF.h | 14 ++++++++----- rpcs3/Loader/ELF64.cpp | 9 ++++++--- rpcs3/Loader/Loader.cpp | 13 ++++++++----- 7 files changed, 60 insertions(+), 33 deletions(-) diff --git a/rpcs3/Crypto/unself.h b/rpcs3/Crypto/unself.h index 947904e13a..53b34bee30 100644 --- a/rpcs3/Crypto/unself.h +++ b/rpcs3/Crypto/unself.h @@ -1,7 +1,8 @@ #pragma once #include "Loader/SELF.h" -#include "Loader/ELF.h" +#include "Loader/ELF64.h" +#include "Loader/ELF32.h" #include "key_vault.h" struct AppInfo diff --git a/rpcs3/Emu/FS/vfsStream.cpp b/rpcs3/Emu/FS/vfsStream.cpp index 5972cb39e5..eb15ad0837 100644 --- a/rpcs3/Emu/FS/vfsStream.cpp +++ b/rpcs3/Emu/FS/vfsStream.cpp @@ -50,9 +50,15 @@ u64 vfsStream::Seek(s64 offset, vfsSeekMode mode) { switch(mode) { - case vfsSeekSet: m_pos = offset; break; - case vfsSeekCur: m_pos += offset; break; - case vfsSeekEnd: m_pos = GetSize() + offset; break; + case vfsSeekSet: + m_pos = offset; + break; + case vfsSeekCur: + m_pos += offset; + break; + case vfsSeekEnd: + m_pos = GetSize() + offset; + break; } return m_pos; diff --git a/rpcs3/Gui/DisAsmFrame.cpp b/rpcs3/Gui/DisAsmFrame.cpp index f78ccfe928..da2f93d89f 100644 --- a/rpcs3/Gui/DisAsmFrame.cpp +++ b/rpcs3/Gui/DisAsmFrame.cpp @@ -104,6 +104,8 @@ void DisAsmFrame::Resume() #include #include "Loader/ELF.h" +#include "Loader/ELF32.h" +#include "Loader/ELF64.h" std::vector* shdr_arr_64 = NULL; std::vector* shdr_arr_32 = NULL; ELF64Loader* l_elf64 = NULL; diff --git a/rpcs3/Loader/ELF.cpp b/rpcs3/Loader/ELF.cpp index cc9003857f..b3708bf910 100644 --- a/rpcs3/Loader/ELF.cpp +++ b/rpcs3/Loader/ELF.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "Emu/FS/vfsStream.h" #include "ELF.h" +#include "ELF64.h" +#include "ELF32.h" void Elf_Ehdr::Show() { @@ -13,43 +15,49 @@ void Elf_Ehdr::Load(vfsStream& f) } ELFLoader::ELFLoader(vfsStream& f) - : elf_f(f) + : m_elf_file(f) , LoaderBase() - , loader(nullptr) + , m_loader(nullptr) { } bool ELFLoader::LoadInfo() { - if(!elf_f.IsOpened()) return false; + if(!m_elf_file.IsOpened()) + return false; - elf_f.Seek(0); - ehdr.Load(elf_f); - if(!ehdr.CheckMagic()) return false; + m_elf_file.Seek(0); + ehdr.Load(m_elf_file); + if(!ehdr.CheckMagic()) + return false; switch(ehdr.GetClass()) { - case CLASS_ELF32: loader = new ELF32Loader(elf_f); break; - case CLASS_ELF64: loader = new ELF64Loader(elf_f); break; + case CLASS_ELF32: + m_loader = new ELF32Loader(m_elf_file); + break; + case CLASS_ELF64: + m_loader = new ELF64Loader(m_elf_file); + break; } - if(!loader || !loader->LoadInfo()) return false; + if(!(m_loader && m_loader->LoadInfo())) + return false; - entry = loader->GetEntry(); - machine = loader->GetMachine(); + entry = m_loader->GetEntry(); + machine = m_loader->GetMachine(); return true; } bool ELFLoader::LoadData(u64 offset) { - if(!loader || !loader->LoadData(offset)) return false; - return true; + return m_loader && m_loader->LoadData(offset); } bool ELFLoader::Close() { - delete loader; - loader = nullptr; - return elf_f.Close(); + delete m_loader; + m_loader = nullptr; + return m_elf_file.Close(); } diff --git a/rpcs3/Loader/ELF.h b/rpcs3/Loader/ELF.h index 3ff9e34224..3e203e0ba8 100644 --- a/rpcs3/Loader/ELF.h +++ b/rpcs3/Loader/ELF.h @@ -1,6 +1,7 @@ #pragma once -#include "ELF64.h" -#include "ELF32.h" +#include "Loader.h" + +class vfsStream; enum ElfClass { @@ -34,14 +35,17 @@ struct Elf_Ehdr class ELFLoader : public LoaderBase { - vfsStream& elf_f; - LoaderBase* loader; + vfsStream& m_elf_file; + LoaderBase* m_loader; public: Elf_Ehdr ehdr; ELFLoader(vfsStream& f); - virtual ~ELFLoader() {Close();} + virtual ~ELFLoader() + { + Close(); + } virtual bool LoadInfo(); virtual bool LoadData(u64 offset = 0); diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index cbe12ab20d..1b79319adb 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -372,13 +372,16 @@ bool ELF64Loader::LoadPhdrData(u64 offset) auto& proc_param = vm::get_ref(offset + phdr.p_vaddr); - if (proc_param.size < sizeof(sys_process_param)) { + if (proc_param.size < sizeof(sys_process_param)) + { LOG_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", proc_param.size, sizeof(sys_process_param)); } - if (proc_param.magic != 0x13bcc5f6) { + if (proc_param.magic != 0x13bcc5f6) + { LOG_ERROR(LOADER, "Bad magic! [0x%x]", proc_param.magic); } - else { + else + { #ifdef LOADER_DEBUG sys_process_param_info& info = Emu.GetInfo().GetProcParam(); LOG_NOTICE(LOADER, "*** sdk version: 0x%x", info.sdk_version.ToLE()); diff --git a/rpcs3/Loader/Loader.cpp b/rpcs3/Loader/Loader.cpp index 4fb4b1cec4..d06511889e 100644 --- a/rpcs3/Loader/Loader.cpp +++ b/rpcs3/Loader/Loader.cpp @@ -121,14 +121,17 @@ void Loader::Open(vfsFileBase& stream) LoaderBase* Loader::SearchLoader() { - if(!m_stream) return nullptr; + if(!m_stream) + return nullptr; - LoaderBase* l; - - if((l=new ELFLoader(*m_stream))->LoadInfo()) return l; + LoaderBase* l = new ELFLoader(*m_stream); + if(l->LoadInfo()) + return l; delete l; - if((l=new SELFLoader(*m_stream))->LoadInfo()) return l; + l = new SELFLoader(*m_stream); + if(l->LoadInfo()) + return l; delete l; return nullptr; From 3caff5a107a74bc023a6c1f50264ddc7aa350c9c Mon Sep 17 00:00:00 2001 From: Arkaran99 Date: Sat, 13 Sep 2014 22:00:17 +0200 Subject: [PATCH 3/3] Change ModuleManager::init function. First step to help refactor Module management. Add every module in the static ModuleInfo list. Module without id are assigned to 0xffff. The init function is called after constructor and take a pointer to Module as an input. This pointer is used to set the Module's global pointer in its file. --- rpcs3/Emu/SysCalls/ModuleManager.cpp | 488 +++++++----------- rpcs3/Emu/SysCalls/ModuleManager.h | 10 +- rpcs3/Emu/SysCalls/Modules.cpp | 28 +- rpcs3/Emu/SysCalls/Modules.h | 4 +- rpcs3/Emu/SysCalls/Modules/cellAdec.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellAudio.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellCamera.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellDmux.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellFiber.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellFont.cpp | 8 +- rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp | 8 +- rpcs3/Emu/SysCalls/Modules/cellGame.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 8 +- rpcs3/Emu/SysCalls/Modules/cellGem.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellL10n.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellOvis.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellPamf.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellResc.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellRtc.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellSail.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellSync2.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp | 7 +- rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellVdec.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/cellVpost.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/libmixer.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp | 7 +- rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp | 7 +- rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp | 7 +- rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp | 7 +- rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp | 7 +- rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/sys_fs.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/sys_io.cpp | 6 +- rpcs3/Emu/SysCalls/Modules/sys_net.cpp | 6 +- 46 files changed, 321 insertions(+), 461 deletions(-) diff --git a/rpcs3/Emu/SysCalls/ModuleManager.cpp b/rpcs3/Emu/SysCalls/ModuleManager.cpp index 99122c1844..f3396ecb7e 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.cpp +++ b/rpcs3/Emu/SysCalls/ModuleManager.cpp @@ -1,313 +1,199 @@ #include "stdafx.h" #include "ModuleManager.h" -extern void cellAdec_init(); -extern Module* cellAdec; -extern void cellAtrac_init(); -extern Module *cellAtrac; -extern void cellAudio_init(); -extern Module *cellAudio; -extern void cellCamera_init(); -extern Module *cellCamera; -extern void cellDmux_init(); -extern Module *cellDmux; -extern void cellFiber_init(); -extern Module *cellFiber; -extern void cellFont_init(); +extern void cellAdec_init(Module* pxThis); +extern void cellAtrac_init(Module* pxThis); +extern void cellAudio_init(Module* pxThis); +extern void cellCamera_init(Module* pxThis); +extern void cellDmux_init(Module *pxThis); +extern void cellFiber_init(Module *pxThis); +extern void cellFont_init(Module *pxThis); extern void cellFont_load(); extern void cellFont_unload(); -extern Module *cellFont; -extern void cellFontFT_init(); +extern void cellFontFT_init(Module *pxThis); extern void cellFontFT_load(); extern void cellFontFT_unload(); -extern Module *cellFontFT; -extern void cellGame_init(); -extern Module *cellGame; -extern void cellGcmSys_init(); +extern void cellGame_init(Module *pxThis); +extern void cellGcmSys_init(Module *pxThis); extern void cellGcmSys_load(); extern void cellGcmSys_unload(); -extern Module *cellGcmSys; -extern void cellGem_init(); -extern Module *cellGem; -extern void cellGifDec_init(); -extern Module *cellGifDec; -extern void cellJpgDec_init(); -extern Module *cellJpgDec; -extern void cellL10n_init(); -extern Module *cellL10n; -extern void cellNetCtl_init(); -extern Module *cellNetCtl; -extern void cellOvis_init(); -extern Module *cellOvis; -extern void cellPamf_init(); -extern Module *cellPamf; -extern void cellPngDec_init(); -extern Module *cellPngDec; -extern void cellResc_init(); +extern void cellGem_init(Module *pxThis); +extern void cellJpgDec_init(Module *pxThis); +extern void cellGifDec_init(Module *pxThis); +extern void cellL10n_init(Module *pxThis); +extern void cellNetCtl_init(Module *pxThis); +extern void cellOvis_init(Module *pxThis); +extern void cellPamf_init(Module *pxThis); +extern void cellPngDec_init(Module *pxThis); +extern void cellResc_init(Module *pxThis); extern void cellResc_load(); extern void cellResc_unload(); -extern Module *cellResc; -extern void cellRtc_init(); -extern Module *cellRtc; -extern void cellSail_init(); -extern Module *cellSail; -extern void cellSpurs_init(); -extern Module *cellSpurs; -extern void cellSync_init(); -extern Module *cellSpursJq; -extern void cellSpursJq_init(); -extern Module *cellSync; -extern void cellSync2_init(); -extern Module *cellSync2; -extern void cellSysmodule_init(); -extern Module *cellSysmodule; -extern void cellSysutil_init(); +extern void cellRtc_init(Module *pxThis); +extern void cellSail_init(Module *pxThis); +extern void cellSpurs_init(Module *pxThis); +extern void cellSpursJq_init(Module *pxThis); +extern void cellSync_init(Module *pxThis); +extern void cellSync2_init(Module *pxThis); +extern void cellSysutil_init(Module *pxThis); extern void cellSysutil_load(); -extern Module *cellSysutil; -extern void cellSysutilAp_init(); -extern Module *cellSysutilAp; -extern void cellUserInfo_init(); -extern Module *cellUserInfo; -extern void cellVdec_init(); -extern Module *cellVdec; -extern void cellVpost_init(); -extern Module *cellVpost; -extern void libmixer_init(); -extern Module *libmixer; -extern void sceNp_init(); -extern Module *sceNp; +extern void cellSysutilAp_init(Module *pxThis); +extern void cellSysmodule_init(Module *pxThis); +extern void cellUserInfo_init(Module *pxThis); +extern void cellVdec_init(Module *pxThis); +extern void cellVpost_init(Module *pxThis); +extern void libmixer_init(Module *pxThis); +extern void sceNp_init(Module *pxThis); +extern void sceNpClans_init(Module *pxThis); extern void sceNpClans_unload(); -extern void sceNpClans_init(); -extern Module *sceNpClans; +extern void sceNpCommerce2_init(Module *pxThis); extern void sceNpCommerce2_unload(); -extern void sceNpCommerce2_init(); -extern Module *sceNpCommerce2; +extern void sceNpSns_init(Module *pxThis); extern void sceNpSns_unload(); -extern void sceNpSns_init(); -extern Module *sceNpSns; +extern void sceNpTrophy_init(Module *pxThis); extern void sceNpTrophy_unload(); -extern void sceNpTrophy_init(); -extern Module *sceNpTrophy; +extern void sceNpTus_init(Module *pxThis); extern void sceNpTus_unload(); -extern void sceNpTus_init(); -extern Module *sceNpTus; -extern void sysPrxForUser_init(); +extern void sysPrxForUser_init(Module *pxThis); extern void sysPrxForUser_load(); -extern Module *sysPrxForUser; -extern void sys_fs_init(); +extern void sys_fs_init(Module *pxThis); extern void sys_fs_load(); -extern Module *sys_fs; -extern void sys_io_init(); -extern Module *sys_io; -extern void sys_net_init(); -extern Module *sys_net; +extern void sys_io_init(Module *pxThis); +extern void sys_net_init(Module *pxThis); struct ModuleInfo { - u32 id; + u16 id; //0xffff is used by module with only name const char* name; + void(*init)(Module *pxThis); + void(*load)(); + void(*unload)(); } -static const g_module_list[] = +static const g_modules_list[] = { - { 0x0000, "sys_net" }, - { 0x0001, "sys_http" }, - { 0x0002, "cellHttpUtil" }, - { 0x0003, "cellSsl" }, - { 0x0004, "cellHttps" }, - { 0x0005, "libvdec" }, - { 0x0006, "cellAdec" }, - { 0x0007, "cellDmux" }, - { 0x0008, "cellVpost" }, - { 0x0009, "cellRtc" }, - { 0x000a, "cellSpurs" }, - { 0x000b, "cellOvis" }, - { 0x000c, "cellSheap" }, - { 0x000d, "sys_sync" }, - { 0x000e, "sys_fs" }, - { 0x000f, "cellJpgDec" }, - { 0x0010, "cellGcmSys" }, - { 0x0011, "cellAudio" }, - { 0x0012, "cellPamf" }, - { 0x0013, "cellAtrac" }, - { 0x0014, "cellNetCtl" }, - { 0x0015, "cellSysutil" }, - { 0x0016, "sceNp" }, - { 0x0017, "sys_io" }, - { 0x0018, "cellPngDec" }, - { 0x0019, "cellFont" }, - { 0x001a, "cellFontFT" }, - { 0x001b, "cellFreetype" }, - { 0x001c, "cellUsbd" }, - { 0x001d, "cellSail" }, - { 0x001e, "cellL10n" }, - { 0x001f, "cellResc" }, - { 0x0020, "cellDaisy" }, - { 0x0021, "cellKey2char" }, - { 0x0022, "cellMic" }, - { 0x0023, "cellCamera" }, - { 0x0024, "cellVdecMpeg2" }, - { 0x0025, "cellVdecAvc" }, - { 0x0026, "cellAdecLpcm" }, - { 0x0027, "cellAdecAc3" }, - { 0x0028, "cellAdecAtx" }, - { 0x0029, "cellAdecAt3" }, - { 0x002a, "cellDmuxPamf" }, - { 0x002e, "cellLv2dbg" }, - { 0x0030, "cellUsbpspcm" }, - { 0x0031, "cellAvconfExt" }, - { 0x0032, "cellUserInfo" }, - { 0x0033, "cellSysutilSavedata" }, - { 0x0034, "cellSubdisplay" }, - { 0x0035, "cellSysutilRec" }, - { 0x0036, "cellVideoExport" }, - { 0x0037, "cellGameExec" }, - { 0x0038, "sceNp2" }, - { 0x0039, "cellSysutilAp" }, - { 0x003a, "cellSysutilNpClans" }, - { 0x003b, "cellSysutilOskExt" }, - { 0x003c, "cellVdecDivx" }, - { 0x003d, "cellJpgEnc" }, - { 0x003e, "cellGame" }, - { 0x003f, "cellBgdl" }, - { 0x0040, "cellFreetypeTT" }, - { 0x0041, "cellSysutilVideoUpload" }, - { 0x0042, "cellSysutilSysconfExt" }, - { 0x0043, "cellFiber" }, - { 0x0044, "cellNpCommerce2" }, - { 0x0045, "cellNpTus" }, - { 0x0046, "cellVoice" }, - { 0x0047, "cellAdecCelp8" }, - { 0x0048, "cellCelp8Enc" }, - { 0x0049, "cellLicenseArea" }, - { 0x004a, "cellMusic2" }, - { 0x004e, "cellScreenshot" }, - { 0x004f, "cellMusicDecode" }, - { 0x0050, "cellSpursJq" }, - { 0x0052, "cellPngEnc" }, - { 0x0053, "cellMusicDecode2" }, - { 0x0055, "cellSync2" }, - { 0x0056, "cellNpUtil" }, - { 0x0057, "cellRudp" }, - { 0x0059, "cellNpSns" }, - { 0x005a, "cellGem" }, - { 0xf00a, "cellCelpEnc" }, - { 0xf010, "cellGifDec" }, - { 0xf019, "cellAdecCelp" }, - { 0xf01b, "cellAdecM2bc" }, - { 0xf01d, "cellAdecM4aac" }, - { 0xf01e, "cellAdecMp3" }, - { 0xf023, "cellImejp" }, - { 0xf028, "cellMusic" }, - { 0xf029, "cellPhotoExport" }, - { 0xf02a, "cellPrint" }, - { 0xf02b, "cellPhotoImport" }, - { 0xf02c, "cellMusicExport" }, - { 0xf02e, "cellPhotoDecode" }, - { 0xf02f, "cellSearch" }, - { 0xf030, "cellAvchat2" }, - { 0xf034, "cellSailRec" }, - { 0xf035, "sceNpTrophy" }, - { 0xf053, "cellAdecAt3multi" }, - { 0xf054, "cellLibatrac3multi" } + { 0x0000, "sys_net", sys_net_init, nullptr, nullptr }, + { 0x0001, "sys_http", nullptr, nullptr, nullptr }, + { 0x0002, "cellHttpUtil", nullptr, nullptr, nullptr }, + { 0x0003, "cellSsl", nullptr, nullptr, nullptr }, + { 0x0004, "cellHttps", nullptr, nullptr, nullptr }, + { 0x0005, "libvdec", cellVdec_init, nullptr, nullptr }, + { 0x0006, "cellAdec", cellAdec_init, nullptr, nullptr }, + { 0x0007, "cellDmux", cellDmux_init, nullptr, nullptr }, + { 0x0008, "cellVpost", cellVpost_init, nullptr, nullptr }, + { 0x0009, "cellRtc", cellRtc_init, nullptr, nullptr }, + { 0x000a, "cellSpurs", cellSpurs_init, nullptr, nullptr }, + { 0x000b, "cellOvis", cellOvis_init, nullptr, nullptr }, + { 0x000c, "cellSheap", nullptr, nullptr, nullptr }, + { 0x000d, "sys_sync", nullptr, nullptr, nullptr }, + { 0x000e, "sys_fs", sys_fs_init, sys_fs_load, nullptr }, + { 0x000f, "cellJpgDec", cellJpgDec_init, nullptr, nullptr }, + { 0x0010, "cellGcmSys", cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload }, + { 0x0011, "cellAudio", cellAudio_init, nullptr, nullptr }, + { 0x0012, "cellPamf", cellPamf_init, nullptr, nullptr }, + { 0x0013, "cellAtrac", cellAtrac_init, nullptr, nullptr }, + { 0x0014, "cellNetCtl", cellNetCtl_init, nullptr, nullptr }, + { 0x0015, "cellSysutil", cellSysutil_init, cellSysutil_load, nullptr }, + { 0x0016, "sceNp", sceNp_init, nullptr, nullptr }, + { 0x0017, "sys_io", sys_io_init, nullptr, nullptr }, + { 0x0018, "cellPngDec", cellPngDec_init, nullptr, nullptr }, + { 0x0019, "cellFont", cellFont_init, cellFont_load, cellFont_unload }, + { 0x001a, "cellFontFT", cellFontFT_init, cellFontFT_load, cellFontFT_unload }, + { 0x001b, "cellFreetype", nullptr, nullptr, nullptr }, + { 0x001c, "cellUsbd", nullptr, nullptr, nullptr }, + { 0x001d, "cellSail", cellSail_init, nullptr, nullptr }, + { 0x001e, "cellL10n", cellL10n_init, nullptr, nullptr }, + { 0x001f, "cellResc", cellResc_init, cellResc_load, cellResc_unload }, + { 0x0020, "cellDaisy", nullptr, nullptr, nullptr }, + { 0x0021, "cellKey2char", nullptr, nullptr, nullptr }, + { 0x0022, "cellMic", nullptr, nullptr, nullptr }, + { 0x0023, "cellCamera", cellCamera_init, nullptr, nullptr }, + { 0x0024, "cellVdecMpeg2", nullptr, nullptr, nullptr }, + { 0x0025, "cellVdecAvc", nullptr, nullptr, nullptr }, + { 0x0026, "cellAdecLpcm", nullptr, nullptr, nullptr }, + { 0x0027, "cellAdecAc3", nullptr, nullptr, nullptr }, + { 0x0028, "cellAdecAtx", nullptr, nullptr, nullptr }, + { 0x0029, "cellAdecAt3", nullptr, nullptr, nullptr }, + { 0x002a, "cellDmuxPamf", nullptr, nullptr, nullptr }, + { 0x002e, "cellLv2dbg", nullptr, nullptr, nullptr }, + { 0x0030, "cellUsbpspcm", nullptr, nullptr, nullptr }, + { 0x0031, "cellAvconfExt", nullptr, nullptr, nullptr }, + { 0x0032, "cellUserInfo", cellUserInfo_init, nullptr, nullptr }, + { 0x0033, "cellSysutilSavedata", nullptr, nullptr, nullptr }, + { 0x0034, "cellSubdisplay", nullptr, nullptr, nullptr }, + { 0x0035, "cellSysutilRec", nullptr, nullptr, nullptr }, + { 0x0036, "cellVideoExport", nullptr, nullptr, nullptr }, + { 0x0037, "cellGameExec", nullptr, nullptr, nullptr }, + { 0x0038, "sceNp2", nullptr, nullptr, nullptr }, + { 0x0039, "cellSysutilAp", cellSysutilAp_init, nullptr, nullptr }, + { 0x003a, "cellSysutilNpClans", sceNpClans_init, nullptr, sceNpClans_unload }, + { 0x003b, "cellSysutilOskExt", nullptr, nullptr, nullptr }, + { 0x003c, "cellVdecDivx", nullptr, nullptr, nullptr }, + { 0x003d, "cellJpgEnc", nullptr, nullptr, nullptr }, + { 0x003e, "cellGame", cellGame_init, nullptr, nullptr }, + { 0x003f, "cellBgdl", nullptr, nullptr, nullptr }, + { 0x0040, "cellFreetypeTT", nullptr, nullptr, nullptr }, + { 0x0041, "cellSysutilVideoUpload", nullptr, nullptr, nullptr }, + { 0x0042, "cellSysutilSysconfExt", nullptr, nullptr, nullptr }, + { 0x0043, "cellFiber", cellFiber_init, nullptr, nullptr }, + { 0x0044, "cellNpCommerce2", sceNpCommerce2_init, nullptr, sceNpCommerce2_unload }, + { 0x0045, "cellNpTus", sceNpTus_init, nullptr, sceNpTus_unload }, + { 0x0046, "cellVoice", nullptr, nullptr, nullptr }, + { 0x0047, "cellAdecCelp8", nullptr, nullptr, nullptr }, + { 0x0048, "cellCelp8Enc", nullptr, nullptr, nullptr }, + { 0x0049, "cellLicenseArea", nullptr, nullptr, nullptr }, + { 0x004a, "cellMusic2", nullptr, nullptr, nullptr }, + { 0x004e, "cellScreenshot", nullptr, nullptr, nullptr }, + { 0x004f, "cellMusicDecode", nullptr, nullptr, nullptr }, + { 0x0050, "cellSpursJq", cellSpursJq_init, nullptr, nullptr }, + { 0x0052, "cellPngEnc", nullptr, nullptr, nullptr }, + { 0x0053, "cellMusicDecode2", nullptr, nullptr, nullptr }, + { 0x0055, "cellSync2", cellSync2_init, nullptr, nullptr }, + { 0x0056, "cellNpUtil", nullptr, nullptr, nullptr }, + { 0x0057, "cellRudp", nullptr, nullptr, nullptr }, + { 0x0059, "cellNpSns", sceNpSns_init, nullptr, sceNpSns_unload }, + { 0x005a, "cellGem", cellGem_init, nullptr, nullptr }, + { 0xf00a, "cellCelpEnc", nullptr, nullptr, nullptr }, + { 0xf010, "cellGifDec", cellGifDec_init, nullptr, nullptr }, + { 0xf019, "cellAdecCelp", nullptr, nullptr, nullptr }, + { 0xf01b, "cellAdecM2bc", nullptr, nullptr, nullptr }, + { 0xf01d, "cellAdecM4aac", nullptr, nullptr, nullptr }, + { 0xf01e, "cellAdecMp3", nullptr, nullptr, nullptr }, + { 0xf023, "cellImejp", nullptr, nullptr, nullptr }, + { 0xf028, "cellMusic", nullptr, nullptr, nullptr }, + { 0xf029, "cellPhotoExport", nullptr, nullptr, nullptr }, + { 0xf02a, "cellPrint", nullptr, nullptr, nullptr }, + { 0xf02b, "cellPhotoImport", nullptr, nullptr, nullptr }, + { 0xf02c, "cellMusicExport", nullptr, nullptr, nullptr }, + { 0xf02e, "cellPhotoDecode", nullptr, nullptr, nullptr }, + { 0xf02f, "cellSearch", nullptr, nullptr, nullptr }, + { 0xf030, "cellAvchat2", nullptr, nullptr, nullptr }, + { 0xf034, "cellSailRec", nullptr, nullptr, nullptr }, + { 0xf035, "sceNpTrophy", sceNpTrophy_init, nullptr, sceNpTrophy_unload }, + { 0xf053, "cellAdecAt3multi", nullptr, nullptr, nullptr }, + { 0xf054, "cellLibatrac3multi", nullptr, nullptr, nullptr }, + { 0xffff, "cellSync", cellSync_init, nullptr, nullptr }, + { 0xffff, "cellSysmodule", cellSysmodule_init, nullptr, nullptr }, + { 0xffff, "libmixer", libmixer_init, nullptr, nullptr }, + { 0xffff, "sysPrxForUser", sysPrxForUser_init, sysPrxForUser_load, nullptr } }; void ModuleManager::init() { - //this is a really bad hack and the whole idea of Modules and how they're implemented should probably be changed - //the contruction of the modules accessses the global variable for that module. - //For example cellAdec needs to be set before cellAdec_init is called but it would be called in the constructor of - //cellAdec, so we need to point cellAdec to where we will construct it in the future + //TODO Refactor every Module part to remove the global pointer defined in each module's file + //and the need to call init functions after its constructor + + //To define a new module, add it in g_modules_list + //m.init the function which defines module's own functions and assignes module's pointer to its global pointer if (!initialized) { - m_mod_init.reserve(m_mod_init.size() + 160);//currently 131 - for (auto& m : g_module_list) + u32 global_module_nb = sizeof(g_modules_list) / sizeof(g_modules_list[0]); + m_mod_init.reserve(global_module_nb); + for (auto& m : g_modules_list) { - m_mod_init.emplace_back(m.id, m.name); + m_mod_init.emplace_back(m.id, m.name, m.load, m.unload); + if (m.init) + m.init(&m_mod_init.back()); } - cellAdec = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0006, cellAdec_init); - cellAtrac = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0013, cellAtrac_init); - cellAudio = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0011, cellAudio_init); - cellCamera = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0023, cellCamera_init); - cellDmux = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0007, cellDmux_init); - cellFiber = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0043, cellFiber_init); - cellFont = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0019, cellFont_init, cellFont_load, cellFont_unload); - cellFontFT = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x001a, cellFontFT_init, cellFontFT_load, cellFontFT_unload); - cellGame = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x003e, cellGame_init); - cellGcmSys = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0010, cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload); - cellGem = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x005a, cellGem_init); - cellJpgDec = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x000f, cellJpgDec_init); - cellGifDec = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0xf010, cellGifDec_init); - cellL10n = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x001e, cellL10n_init); - cellNetCtl = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0014, cellNetCtl_init); - cellOvis = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x000b, cellOvis_init); - cellPamf = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0012, cellPamf_init); - cellPngDec = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0018, cellPngDec_init); - cellResc = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x001f, cellResc_init, cellResc_load, cellResc_unload); - cellRtc = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0009, cellRtc_init); - cellSail = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back("cellSail", cellSail_init); - cellSpurs = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x000a, cellSpurs_init); - cellSpursJq = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0050, cellSpursJq_init); - cellSync = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back("cellSync", cellSync_init); - cellSync2 = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0055, cellSync2_init); - cellSysutil = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0015, cellSysutil_init, cellSysutil_load, nullptr); - cellSysutilAp = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0039, cellSysutilAp_init); - cellSysmodule = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back("cellSysmodule", cellSysmodule_init); - cellUserInfo = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0032, cellUserInfo_init); - cellVdec = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0005, cellVdec_init); - cellVpost = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0008, cellVpost_init); - libmixer = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back("libmixer", libmixer_init); - sceNp = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0016, sceNp_init); - sceNpClans = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x003a, sceNpClans_init, nullptr, sceNpClans_unload); - sceNpCommerce2 = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0044, sceNpCommerce2_init, nullptr, sceNpCommerce2_unload); - sceNpSns = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0059, sceNpSns_init, nullptr, sceNpSns_unload); - sceNpTrophy = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0xf035, sceNpTrophy_init, nullptr, sceNpTrophy_unload); - sceNpTus = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0045, sceNpTus_init, nullptr, sceNpTus_unload); - sysPrxForUser = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back("sysPrxForUser", sysPrxForUser_init, sysPrxForUser_load, nullptr); - sys_fs = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x000e, sys_fs_init, sys_fs_load, nullptr); - sys_io = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back(0x0017, sys_io_init); - sys_net = static_cast (&(m_mod_init.back())) + 1; - m_mod_init.emplace_back((u16)0x0000, sys_net_init); + initialized = true; } } @@ -402,7 +288,7 @@ void ModuleManager::UnloadModules() //this could be done by calling the destructor and then a placement-new //to avoid repeating the initial values here but the defaults aren't //complicated enough to complicate this by using the placement-new - m_mod_init.clear(); + m_mod_init.clear(); //destroy Module(s), their respective global pointer become invalid m_max_module_id = 0; m_module_2_count = 0; initialized = false; @@ -414,7 +300,7 @@ void ModuleManager::UnloadModules() Module* ModuleManager::GetModuleByName(const std::string& name) { - for (u32 i = 0; iGetName() == name) { @@ -437,7 +323,7 @@ Module* ModuleManager::GetModuleByName(const std::string& name) Module* ModuleManager::GetModuleById(u16 id) { - for (u32 i = 0; iGetID() == id) { @@ -453,46 +339,42 @@ Module* ModuleManager::GetModuleById(u16 id) return nullptr; } -void ModuleManager::SetModule(int id, Module* module, bool with_data) +void ModuleManager::SetModule(u16 id, Module* module) { - if (id != 0xffff) + if (id != 0xffff) //id != -1 { - if (u16((u8)id + 1) > m_max_module_id) + u8 index2 = (u8)id; + if (u16(index2 + 1) > m_max_module_id) { - m_max_module_id = u16((u8)id + 1); + m_max_module_id = u16(index2 + 1); } - int index; + u8 index; switch (id >> 8) { - case 0x00: index = 0; break; - case 0xf0: index = 1; break; + case 0x00: index = 0; break;//id = 0x0000 to 0x00fe go to m_modules[0] + case 0xf0: index = 1; break;//id = 0xf000 to 0xf0fe go to m_modules[1] default: assert(0); return; } - if (m_modules[index][(u8)id]) + //fill m_modules[index] by truncating id to 8 bits + if (m_modules[index][index2]) //if module id collision { - if (with_data) - { - module->SetName(m_modules[index][(u8)id]->GetName()); - // delete m_modules[index][(u8)id]; - m_modules[index][(u8)id] = module; - } - else - { - m_modules[index][(u8)id]->SetName(module->GetName()); - // delete module; - } + //Not sure if this is a good idea to hide collision + module->SetName(m_modules[index][index2]->GetName()); + m_modules[index][index2] = module; + //don't need to delete since m_mod_init has the ownership } else { - m_modules[index][(u8)id] = module; + m_modules[index][index2] = module; } } - else + else //id = 0xffff go to m_modules[2] { - m_modules[2][m_module_2_count++] = module; - + //fill m_modules[2] from 0 to 0xff + m_modules[2][m_module_2_count] = module; + ++m_module_2_count; if (m_module_2_count > m_max_module_id) { m_max_module_id = m_module_2_count; diff --git a/rpcs3/Emu/SysCalls/ModuleManager.h b/rpcs3/Emu/SysCalls/ModuleManager.h index a4588a30a0..a7acec1c22 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.h +++ b/rpcs3/Emu/SysCalls/ModuleManager.h @@ -3,12 +3,12 @@ class ModuleManager { - Module* m_modules[3][0xff]; - uint m_max_module_id; - uint m_module_2_count; + Module* m_modules[3][0xff];//keep pointer to modules split in 3 categories according to their id + uint m_max_module_id; //max index in m_modules[2][], m_modules[1][] and m_modules[0][] + uint m_module_2_count; //max index in m_modules[2][] std::mutex m_funcs_lock; std::vector m_modules_funcs_list; - std::vector m_mod_init; + std::vector m_mod_init; //owner of Module bool initialized; public: ModuleManager(); @@ -16,7 +16,7 @@ public: void init(); void AddFunc(ModuleFunc *func); - void SetModule(int id, Module* module, bool with_data); + void SetModule(u16 id, Module* module);//insert into m_modules bool IsLoadedFunc(u32 id) const; bool CallFunc(u32 num); bool UnloadFunc(u32 id); diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 2853698a40..a994cf5488 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -22,35 +22,14 @@ u32 getFunctionId(const char* name) return (u32&)output[0]; } -Module::Module(u16 id, const char* name) +Module::Module(u16 id, const char* name, void(*load)(), void(*unload)()) : m_is_loaded(false) , m_name(name) , m_id(id) - , m_load_func(nullptr) - , m_unload_func(nullptr) -{ - Emu.GetModuleManager().SetModule(m_id, this, false); -} - -Module::Module(const char* name, void (*init)(), void (*load)(), void (*unload)()) - : m_is_loaded(false) - , m_name(name) - , m_id(-1) - , m_load_func(load) - , m_unload_func(unload) -{ - Emu.GetModuleManager().SetModule(m_id, this, init != nullptr); - if(init) init(); -} - -Module::Module(u16 id, void (*init)(), void (*load)(), void (*unload)()) - : m_is_loaded(false) - , m_id(id) , m_load_func(load) , m_unload_func(unload) { - Emu.GetModuleManager().SetModule(m_id, this, init != nullptr); - if(init) init(); + Emu.GetModuleManager().SetModule(m_id, this); } Module::Module(Module &&other) @@ -120,7 +99,8 @@ void Module::UnLoad() bool Module::Load(u32 id) { - if(Emu.GetModuleManager().IsLoadedFunc(id)) return false; + if(Emu.GetModuleManager().IsLoadedFunc(id)) + return false; for(u32 i=0; i m_funcs_list; - Module(u16 id, const char* name); - Module(const char* name, void (*init)(), void (*load)() = nullptr, void (*unload)() = nullptr); - Module(u16 id, void (*init)(), void (*load)() = nullptr, void (*unload)() = nullptr); + Module(u16 id, const char* name, void(*load)() = nullptr, void(*unload)() = nullptr); Module(Module &other) = delete; Module(Module &&other); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index 17af4d56b7..51dc0e6b62 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -17,8 +17,6 @@ extern "C" #include "cellPamf.h" #include "cellAdec.h" -//void cellAdec_init(); -//Module cellAdec(0x0006, cellAdec_init); Module *cellAdec = nullptr; AudioDecoder::AudioDecoder(AudioCodecType type, u32 addr, u32 size, vm::ptr func, u32 arg) @@ -808,8 +806,10 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr> pcmItem_ptr) return CELL_OK; } -void cellAdec_init() +void cellAdec_init(Module * pxThis) { + cellAdec = pxThis; + REG_FUNC(cellAdec, cellAdecQueryAttr); REG_FUNC(cellAdec, cellAdecOpen); REG_FUNC(cellAdec, cellAdecOpenEx); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp index 14227915a2..6e9a72d357 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp @@ -203,8 +203,10 @@ int cellAtracGetInternalErrorInfo(vm::ptr pHandle, vm::ptrAddFunc(0x66afc68e, cellAtracSetDataAndGetMemSize); cellAtrac->AddFunc(0xfa293e88, cellAtracCreateDecoder); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index acc99b5594..262ae847aa 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -11,8 +11,6 @@ #include "Emu/Audio/AudioDumper.h" #include "Emu/Audio/cellAudio.h" -//void cellAudio_init(); -//Module cellAudio(0x0011, cellAudio_init); Module *cellAudio = nullptr; static std::mutex audioMutex; @@ -886,8 +884,10 @@ int cellAudioUnsetPersonalDevice(int iPersonalStream) return CELL_OK; } -void cellAudio_init() +void cellAudio_init(Module *pxThis) { + cellAudio = pxThis; + cellAudio->AddFunc(0x0b168f92, cellAudioInit); cellAudio->AddFunc(0x4129fe2d, cellAudioPortClose); cellAudio->AddFunc(0x5b1e2c73, cellAudioPortStop); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp index 7037d64476..102caccaf0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp @@ -5,8 +5,6 @@ #include "cellCamera.h" -void cellCamera_init(); -//Module cellCamera(0x0023, cellCamera_init); Module *cellCamera = nullptr; struct cellCameraInternal @@ -224,8 +222,10 @@ int cellCameraRemoveNotifyEventQueue2() return CELL_OK; } -void cellCamera_init() +void cellCamera_init(Module* pxThis) { + cellCamera = pxThis; + cellCamera->AddFunc(0xbf47c5dd, cellCameraInit); cellCamera->AddFunc(0x5ad46570, cellCameraEnd); cellCamera->AddFunc(0x85e1b8da, cellCameraOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index ee89639795..3e715a2dfb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -8,8 +8,6 @@ #include "cellPamf.h" #include "cellDmux.h" -//void cellDmux_init(); -//Module cellDmux(0x0007, cellDmux_init); Module *cellDmux = nullptr; PesHeader::PesHeader(DemuxerStream& stream) @@ -1121,8 +1119,10 @@ int cellDmuxFlushEs(u32 esHandle) return CELL_OK; } -void cellDmux_init() +void cellDmux_init(Module *pxThis) { + cellDmux = pxThis; + cellDmux->AddFunc(0xa2d4189b, cellDmuxQueryAttr); cellDmux->AddFunc(0x3f76e3cd, cellDmuxQueryAttr2); cellDmux->AddFunc(0x68492de9, cellDmuxOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp index c52891d005..6f0394f352 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp @@ -5,8 +5,6 @@ #include "cellFiber.h" -//void cellFiber_init(); -//Module cellFiber(0x0043, cellFiber_init); Module* cellFiber = nullptr; int _cellFiberPpuInitialize() @@ -293,8 +291,10 @@ int cellFiberPpuUtilWorkerControlInitializeWithAttribute() return CELL_OK; } -void cellFiber_init() +void cellFiber_init(Module *pxThis) { + cellFiber = pxThis; + cellFiber->AddFunc(0x55870804, _cellFiberPpuInitialize); cellFiber->AddFunc(0x9e25c72d, _cellFiberPpuSchedulerAttributeInitialize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index cd7e953270..010f69c9e7 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -6,10 +6,6 @@ #include "Emu/FS/vfsFile.h" #include "cellFont.h" -//void cellFont_init(); -//void cellFont_load(); -//void cellFont_unload(); -//Module cellFont(0x0019, cellFont_init, cellFont_load, cellFont_unload); Module *cellFont = nullptr; CCellFontInternal* s_fontInternalInstance = nullptr; @@ -583,8 +579,10 @@ int cellFontGetCharGlyphMetricsVertical() return CELL_FONT_OK; } -void cellFont_init() +void cellFont_init(Module *pxThis) { + cellFont = pxThis; + cellFont->AddFunc(0x25c107e6, cellFontInit); cellFont->AddFunc(0x6bf6f832, cellFontSetFontsetOpenMode); cellFont->AddFunc(0x6cfada83, cellFontSetFontOpenMode); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp index 64ecde7ca6..f58b460f71 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp @@ -5,10 +5,6 @@ #include "cellFont.h" #include "cellFontFT.h" -//void cellFontFT_init(); -//void cellFontFT_load(); -//void cellFontFT_unload(); -//Module cellFontFT(0x001a, cellFontFT_init, cellFontFT_load, cellFontFT_unload); Module *cellFontFT = nullptr; CCellFontFTInternal* s_fontFtInternalInstance = nullptr; @@ -38,8 +34,10 @@ int cellFontFTGetInitializedRevisionFlags() return CELL_OK; } -void cellFontFT_init() +void cellFontFT_init(Module *pxThis) { + cellFontFT = pxThis; + cellFontFT->AddFunc(0x7a0a83c4, cellFontInitLibraryFreeTypeWithRevision); cellFontFT->AddFunc(0xec89a187, cellFontFTGetRevisionFlags); cellFontFT->AddFunc(0xfa0c2de0, cellFontFTGetInitializedRevisionFlags); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index b55bbcec80..b851bba8b8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -10,8 +10,6 @@ #include "Loader/PSF.h" #include "cellGame.h" -//void cellGame_init(); -//Module cellGame(0x003e, cellGame_init); Module *cellGame = nullptr; std::string contentInfo = ""; @@ -471,8 +469,10 @@ int cellGameThemeInstallFromBuffer() return CELL_OK; } -void cellGame_init() +void cellGame_init(Module *pxThis) { + cellGame = pxThis; + // (TODO: Disc Exchange functions missing) cellGame->AddFunc(0xf52639ea, cellGameBootCheck); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index edcc13f0e6..b6cd5faf21 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -9,10 +9,6 @@ //#include "Emu/SysCalls/lv2/sys_process.h" #include "cellGcmSys.h" -//void cellGcmSys_init(); -//void cellGcmSys_load(); -//void cellGcmSys_unload(); -//Module cellGcmSys(0x0010, cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload); Module *cellGcmSys = nullptr; const u32 tiled_pitches[] = { @@ -1182,8 +1178,10 @@ int cellGcmCallback(u32 context_addr, u32 count) //---------------------------------------------------------------------------- -void cellGcmSys_init() +void cellGcmSys_init(Module *pxThis) { + cellGcmSys = pxThis; + // Data Retrieval cellGcmSys->AddFunc(0xc8f3bd09, cellGcmGetCurrentField); cellGcmSys->AddFunc(0xf80196c1, cellGcmGetLabelAddress); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp index d677abb1d9..2fc7b1eb83 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp @@ -4,8 +4,6 @@ #include "cellGem.h" -void cellGem_init(); -//Module cellGem(0x005a, cellGem_init); Module *cellGem = nullptr; struct cellGemInternal @@ -253,8 +251,10 @@ int cellGemWriteExternalPort() return CELL_OK; } -void cellGem_init() +void cellGem_init(Module *pxThis) { + cellGem = pxThis; + //cellGem->AddFunc(, cellGemAttributeInit); cellGem->AddFunc(0xafa99ead, cellGemCalibrate); cellGem->AddFunc(0x9b9714a4, cellGemClearStatusFlags); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index 75675106a8..c39f8ec181 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -7,8 +7,6 @@ #include "Emu/SysCalls/lv2/lv2Fs.h" #include "cellGifDec.h" -//void cellGifDec_init(); -//Module cellGifDec(0xf010, cellGifDec_init); Module *cellGifDec = nullptr; int cellGifDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam) @@ -277,8 +275,10 @@ int cellGifDecDestroy(u32 mainHandle) return CELL_OK; } -void cellGifDec_init() +void cellGifDec_init(Module *pxThis) { + cellGifDec = pxThis; + cellGifDec->AddFunc(0xb60d42a5, cellGifDecCreate); cellGifDec->AddFunc(0x4711cb7f, cellGifDecExtCreate); cellGifDec->AddFunc(0x75745079, cellGifDecOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index b34c42dc3e..7039b25c65 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -6,8 +6,6 @@ #include "Emu/SysCalls/lv2/lv2Fs.h" #include "cellJpgDec.h" -//void cellJpgDec_init(); -//Module cellJpgDec(0x000f, cellJpgDec_init); Module *cellJpgDec = nullptr; int cellJpgDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam) @@ -322,8 +320,10 @@ int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptrAddFunc(0xa7978f59, cellJpgDecCreate); cellJpgDec->AddFunc(0x8b300f66, cellJpgDecExtCreate); cellJpgDec->AddFunc(0x976ca5c2, cellJpgDecOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp index b47d5d8383..ef71786077 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp @@ -14,8 +14,6 @@ #include #endif -//void cellL10n_init(); -//Module cellL10n(0x001e, cellL10n_init); Module *cellL10n = nullptr; int UTF16stoUTF8s(vm::lptrl utf16, vm::ptr> utf16_len, vm::ptr utf8, vm::ptr> utf8_len) @@ -337,8 +335,10 @@ int L10nConvertStr(int src_code, vm::ptr src, vm::ptr> src #endif } -void cellL10n_init() +void cellL10n_init(Module *pxThis) { + cellL10n = pxThis; + // NOTE: I think this module should be LLE'd instead of implementing all its functions // cellL10n->AddFunc(0x005200e6, UCS2toEUCJP); diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp index f5888e46a3..995b633b96 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp @@ -6,8 +6,6 @@ #include "cellSysutil.h" #include "cellNetCtl.h" -//void cellNetCtl_init(); -//Module cellNetCtl(0x0014, cellNetCtl_init); Module *cellNetCtl; struct cellNetCtlInternal @@ -113,8 +111,10 @@ int cellNetCtlGetNatInfo(vm::ptr natInfo) return CELL_OK; } -void cellNetCtl_init() +void cellNetCtl_init(Module *pxThis) { + cellNetCtl = pxThis; + cellNetCtl->AddFunc(0xbd5a59fc, cellNetCtlInit); cellNetCtl->AddFunc(0x105ee2cb, cellNetCtlTerm); diff --git a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp index 46f6ea8a78..3b2e2e0403 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp @@ -1,8 +1,6 @@ #include "stdafx.h" #include "Emu/SysCalls/Modules.h" -void cellOvis_init(); -//Module cellOvis(0x000b, cellOvis_init); Module *cellOvis = nullptr; // Return Codes @@ -37,8 +35,10 @@ int cellOvisInvalidateOverlappedSegments() return CELL_OK; } -void cellOvis_init() +void cellOvis_init(Module *pxThis) { + cellOvis = pxThis; + cellOvis->AddFunc(0x82f294b2, cellOvisGetOverlayTableSize); cellOvis->AddFunc(0xa876c911, cellOvisInitializeOverlayTable); cellOvis->AddFunc(0xce6cb776, cellOvisFixSpuSegments); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp index 584157e797..e06df6d5dd 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp @@ -539,8 +539,10 @@ int cellPamfEpIteratorMove(vm::ptr pIt, s32 steps, vm::ptrAddFunc(0xca8181c1, cellPamfGetHeaderSize); cellPamf->AddFunc(0x90fc9a59, cellPamfGetHeaderSize2); cellPamf->AddFunc(0x44f5c9e3, cellPamfGetStreamOffsetAndSize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index c036052c2a..ea76f998d2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -8,8 +8,6 @@ #include "cellPngDec.h" #include -//void cellPngDec_init(); -//Module cellPngDec(0x0018, cellPngDec_init); Module *cellPngDec = nullptr; #ifdef PRX_DEBUG @@ -769,8 +767,10 @@ s32 cellPngDecGetTextChunk( #endif } -void cellPngDec_init() +void cellPngDec_init(Module *pxThis) { + cellPngDec = pxThis; + REG_FUNC(cellPngDec, cellPngDecGetUnknownChunks); REG_FUNC(cellPngDec, cellPngDecClose); REG_FUNC(cellPngDec, cellPngDecGetpCAL); diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 735ab38984..9c07072b33 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -1249,8 +1249,10 @@ int cellRescCreateInterlaceTable(u32 ea_addr, float srcH, CellRescTableElement d } -void cellResc_init() +void cellResc_init(Module *pxThis) { + cellResc = pxThis; + cellResc->AddFunc(0x25c107e6, cellRescSetConvertAndFlip); cellResc->AddFunc(0x0d3c22ce, cellRescSetWaitFlip); cellResc->AddFunc(0x2ea94661, cellRescSetFlipHandler); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp index da1d05e189..99f281514c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp @@ -5,8 +5,6 @@ #include "Utilities/rTime.h" #include "cellRtc.h" -//void cellRtc_init(); -//Module cellRtc(0x0009, cellRtc_init); Module *cellRtc = nullptr; s64 convertToUNIXTime(u16 seconds, u16 minutes, u16 hours, u16 days, int years) @@ -447,8 +445,10 @@ int cellRtcCompareTick(vm::ptr pTick0, vm::ptr pTick1) else return CELL_OK; } -void cellRtc_init() +void cellRtc_init(Module *pxThis) { + cellRtc = pxThis; + cellRtc->AddFunc(0x9dafc0d9, cellRtcGetCurrentTick); cellRtc->AddFunc(0x32c941cf, cellRtcGetCurrentClock); cellRtc->AddFunc(0x2cce9cf5, cellRtcGetCurrentClockLocalTime); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp index 6859c20edf..409535dd88 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp @@ -762,8 +762,10 @@ int cellSailPlayerUnregisterSource() return CELL_OK; } -void cellSail_init() +void cellSail_init(Module *pxThis) { + cellSail = pxThis; + cellSail->AddFunc(0x346ebba3, cellSailMemAllocatorInitialize); cellSail->AddFunc(0x4cc54f8e, cellSailFutureInitialize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index 5ec1ea034d..e7d6958b95 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -5,8 +5,6 @@ #include "Emu/Cell/SPURSManager.h" #include "cellSpurs.h" -//void cellSpurs_init(); -//Module cellSpurs(0x000a, cellSpurs_init); Module *cellSpurs = nullptr; #ifdef PRX_DEBUG @@ -1559,8 +1557,10 @@ s64 cellSpursSemaphoreGetTasksetAddress() #endif } -void cellSpurs_init() +void cellSpurs_init(Module *pxThis) { + cellSpurs = pxThis; + // Core REG_FUNC(cellSpurs, cellSpursInitialize); REG_FUNC(cellSpurs, cellSpursInitializeWithAttribute); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp index 572113678d..8c8e50f384 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp @@ -696,8 +696,10 @@ s64 cellSpursJobQueueUnsetExceptionEventHandler() #endif } -void cellSpursJq_init() +void cellSpursJq_init(Module *pxThis) { + cellSpursJq = pxThis; + REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeInitialize); REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetMaxGrab); REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetSubmitWithEntryLock); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 15e293c746..c96ee1f61f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -8,8 +8,6 @@ #include "Emu/Event.h" #include "cellSync.h" -//void cellSync_init(); -//Module cellSync("cellSync", cellSync_init); Module *cellSync = nullptr; #ifdef PRX_DEBUG @@ -2166,8 +2164,10 @@ s32 _cellSyncLFQueueDetachLv2EventQueue(vm::ptr> spus, u32 num, vm::pt return syncLFQueueDetachLv2EventQueue(spus, num, queue); } -void cellSync_init() +void cellSync_init(Module *pxThis) { + cellSync = pxThis; + cellSync->AddFunc(0xa9072dee, cellSyncMutexInitialize); cellSync->AddFunc(0x1bb675c2, cellSyncMutexLock); cellSync->AddFunc(0xd06918c4, cellSyncMutexTryLock); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp index 7236e46fea..de4ca912e0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp @@ -5,8 +5,6 @@ #include "cellSync2.h" -//void cellSync2_init(); -//Module cellSync2(0x0055, cellSync2_init); Module* cellSync2 = nullptr; #ifdef PRX_DEBUG @@ -417,8 +415,10 @@ s64 cellSync2QueueGetDepth() #endif } -void cellSync2_init() +void cellSync2_init(Module *pxThis) { + cellSync2 = pxThis; + cellSync2->AddFunc(0x55836e73, _cellSync2MutexAttributeInitialize); cellSync2->AddFunc(0xd51bfae7, cellSync2MutexEstimateBufferSize); cellSync2->AddFunc(0xeb81a467, cellSync2MutexInitialize); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp index 89b1b9333d..69445ccb17 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp @@ -4,8 +4,6 @@ #include "Emu/SysCalls/ModuleManager.h" #include "Emu/SysCalls/Modules.h" -//void cellSysmodule_init(); -//Module cellSysmodule("cellSysmodule", cellSysmodule_init); Module *cellSysmodule = nullptr; enum @@ -212,8 +210,10 @@ int cellSysmoduleIsLoaded(u16 id) return m->IsLoaded() ? CELL_SYSMODULE_LOADED : CELL_SYSMODULE_ERROR_UNLOADED; } -void cellSysmodule_init() +void cellSysmodule_init(Module *pxThis) { + cellSysmodule = pxThis; + cellSysmodule->AddFunc(0x63ff6ff9, cellSysmoduleInitialize); cellSysmodule->AddFunc(0x96c07adf, cellSysmoduleFinalize); cellSysmodule->AddFunc(0xa193143c, cellSysmoduleSetMemcontainer); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index b33f6f2f73..e096a7e657 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -21,9 +21,6 @@ typedef void (*CellHddGameStatCallback)(vm::ptr cbResult, vm::ptr get, vm::ptr set); - -//void cellSysutil_init(); -//Module cellSysutil(0x0015, cellSysutil_init); Module *cellSysutil = nullptr; int cellSysutilGetSystemParamInt(int id, vm::ptr> value) @@ -844,8 +841,10 @@ extern int cellGameDataCheckCreate2(u32 version, vm::ptr dirName, u3 extern int cellGameDataCheckCreate(u32 version, vm::ptr dirName, u32 errDialog, vm::ptr cbResult, vm::ptr get, vm::ptr set)> funcStat, u32 container); -void cellSysutil_init() +void cellSysutil_init(Module *pxThis) { + cellSysutil = pxThis; + cellSysutil->AddFunc(0x40e895d3, cellSysutilGetSystemParamInt); cellSysutil->AddFunc(0x938013a0, cellSysutilGetSystemParamString); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp index 0eb532cfed..07a29a9be1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp @@ -2,8 +2,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -//void cellSysutilAp_init(); -//Module cellSysutilAp(0x0039, cellSysutilAp_init); Module *cellSysutilAp = nullptr; // Return Codes @@ -37,8 +35,10 @@ int cellSysutilApOff() return CELL_OK; } -void cellSysutilAp_init() +void cellSysutilAp_init(Module *pxThis) { + cellSysutilAp = pxThis; + cellSysutilAp->AddFunc(0x9e67e0dd, cellSysutilApGetRequiredMemSize); cellSysutilAp->AddFunc(0x3343824c, cellSysutilApOn); cellSysutilAp->AddFunc(0x90c2bb19, cellSysutilApOff); diff --git a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp index 162a32bc61..8c4d653abc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp @@ -7,8 +7,6 @@ #include "Emu/FS/vfsFileBase.h" #include "cellUserInfo.h" -//void cellUserInfo_init(); -//Module cellUserInfo(0x0032, cellUserInfo_init); Module *cellUserInfo = nullptr; int cellUserInfoGetStat(u32 id, vm::ptr stat) @@ -76,8 +74,10 @@ int cellUserInfoGetList(vm::ptr> listNum, vm::ptrAddFunc(0x2b761140, cellUserInfoGetStat); cellUserInfo->AddFunc(0x3097cc1c, cellUserInfoSelectUser_ListType); cellUserInfo->AddFunc(0x55123a25, cellUserInfoSelectUser_SetList); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index 1da760f52b..55dc0e5c1e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -17,8 +17,6 @@ extern "C" #include "cellPamf.h" #include "cellVdec.h" -//void cellVdec_init(); -//Module cellVdec(0x0005, cellVdec_init); Module *cellVdec = nullptr; VideoDecoder::VideoDecoder(CellVdecCodecType type, u32 profile, u32 addr, u32 size, vm::ptr func, u32 arg) @@ -788,8 +786,10 @@ int cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc) return CELL_OK; } -void cellVdec_init() +void cellVdec_init(Module *pxThis) { + cellVdec = pxThis; + cellVdec->AddFunc(0xff6f6ebe, cellVdecQueryAttr); cellVdec->AddFunc(0xc982a84a, cellVdecQueryAttrEx); cellVdec->AddFunc(0xb6bbcd5d, cellVdecOpen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp index 5944b4f055..749dc18f42 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp @@ -10,8 +10,6 @@ extern "C" #include "cellVpost.h" -//void cellVpost_init(); -//Module cellVpost(0x0008, cellVpost_init); Module *cellVpost = nullptr; int cellVpostQueryAttr(vm::ptr cfgParam, vm::ptr attr) @@ -153,8 +151,10 @@ int cellVpostExec(u32 handle, vm::ptr inPicBuff, vm::ptrAddFunc(0x95e788c3, cellVpostQueryAttr); cellVpost->AddFunc(0xcd33f3e2, cellVpostOpen); cellVpost->AddFunc(0x40524325, cellVpostOpenEx); diff --git a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp index 2042eb1e78..8db8c9bf91 100644 --- a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp @@ -8,8 +8,6 @@ #include "Emu/Audio/cellAudio.h" #include "libmixer.h" -//void libmixer_init(); -//Module libmixer("libmixer", libmixer_init); Module *libmixer = nullptr; CellSurMixerConfig surMixer; @@ -642,8 +640,10 @@ void cellSurMixerUtilNoteToRatio(u8 refNote, u8 note) (float&)CPU.FPR[0] = 0.0f; } -void libmixer_init() +void libmixer_init(Module *pxThis) { + libmixer = pxThis; + REG_SUB(libmixer, "surmxAAN", cellAANAddData, 0xffffffff7c691b78, 0xffffffff7c0802a6, diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index e573c7743a..1e9154bf63 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -9,8 +9,6 @@ #include "Crypto/unedat.h" #include "sceNp.h" -//void sceNp_init(); -//Module sceNp(0x0016, sceNp_init); Module *sceNp = nullptr; struct sceNpInternal @@ -1508,8 +1506,10 @@ int sceNpSignalingDestroyCtx() return CELL_OK; } -void sceNp_init() +void sceNp_init(Module *pxThis) { + sceNp = pxThis; + sceNp->AddFunc(0xbd28fdbf, sceNpInit); sceNp->AddFunc(0x41251f74, sceNp2Init); sceNp->AddFunc(0x4885aa18, sceNpTerm); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp index d0528c0334..0494fb9d37 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp @@ -6,9 +6,6 @@ #include "sceNp.h" #include "sceNpClans.h" -//void sceNpClans_unload(); -//void sceNpClans_init(); -//Module sceNpClans(0x003a, sceNpClans_init, nullptr, sceNpClans_unload); Module *sceNpClans = nullptr; int sceNpClansInit() @@ -250,8 +247,10 @@ void sceNpClans_unload() // TODO: Unload Clans module } -void sceNpClans_init() +void sceNpClans_init(Module *pxThis) { + sceNpClans = pxThis; + sceNpClans->AddFunc(0x9b820047, sceNpClansInit); sceNpClans->AddFunc(0x42332cb7, sceNpClansTerm); sceNpClans->AddFunc(0x9a72232d, sceNpClansCreateRequest); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp index c6e29023b0..d2ea06cc48 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp @@ -4,9 +4,6 @@ #include "sceNpCommerce2.h" -//void sceNpCommerce2_unload(); -//void sceNpCommerce2_init(); -//Module sceNpCommerce2(0x0044, sceNpCommerce2_init, nullptr, sceNpCommerce2_unload); Module *sceNpCommerce2 = nullptr; int sceNpCommerce2ExecuteStoreBrowse() @@ -296,8 +293,10 @@ void sceNpCommerce2_unload() // TODO: Unload SNS module } -void sceNpCommerce2_init() +void sceNpCommerce2_init(Module *pxThis) { + sceNpCommerce2 = pxThis; + sceNpCommerce2->AddFunc(0xeef51be0, sceNpCommerce2ExecuteStoreBrowse); sceNpCommerce2->AddFunc(0x1fa1b312, sceNpCommerce2GetStoreBrowseUserdata); sceNpCommerce2->AddFunc(0x3539d233, sceNpCommerce2Init); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp index a5930c192d..535b6b3f01 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpSns.cpp @@ -2,9 +2,6 @@ #include "Emu/SysCalls/Modules.h" #include "sceNpSns.h" -//void sceNpSns_unload(); -//void sceNpSns_init(); -//Module sceNpSns(0x0059, sceNpSns_init, nullptr, sceNpSns_unload); Module *sceNpSns = nullptr; void sceNpSns_unload() @@ -12,7 +9,9 @@ void sceNpSns_unload() // TODO: Unload SNS module } -void sceNpSns_init() +void sceNpSns_init(Module *pxThis) { + sceNpSns = pxThis; + // TODO: Register SNS module functions here } \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index 8f56d50067..9577708714 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -15,9 +15,6 @@ #include "sceNp.h" #include "sceNpTrophy.h" -//void sceNpTrophy_unload(); -//void sceNpTrophy_init(); -//Module sceNpTrophy(0xf035, sceNpTrophy_init, nullptr, sceNpTrophy_unload); Module *sceNpTrophy = nullptr; // Internal Structs @@ -426,8 +423,10 @@ void sceNpTrophy_unload() s_npTrophyInstance.m_bInitialized = false; } -void sceNpTrophy_init() +void sceNpTrophy_init(Module *pxThis) { + sceNpTrophy = pxThis; + sceNpTrophy->AddFunc(0x079f0e87, sceNpTrophyGetGameProgress); sceNpTrophy->AddFunc(0x1197b52c, sceNpTrophyRegisterContext); sceNpTrophy->AddFunc(0x1c25470d, sceNpTrophyCreateHandle); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp index a71088b5e6..50a5af0d2c 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp @@ -5,9 +5,6 @@ #include "sceNp.h" #include "sceNpTus.h" -//void sceNpTus_unload(); -//void sceNpTus_init(); -//Module sceNpTus(0x0045, sceNpTus_init, nullptr, sceNpTus_unload); Module *sceNpTus = nullptr; int sceNpTusInit() @@ -339,8 +336,10 @@ void sceNpTus_unload() // TODO: Unload Tus module } -void sceNpTus_init() +void sceNpTus_init(Module *pxThis) { + sceNpTus = pxThis; + sceNpTus->AddFunc(0x8f87a06b, sceNpTusInit); sceNpTus->AddFunc(0x225aed26, sceNpTusTerm); sceNpTus->AddFunc(0x7caf58ee, sceNpTusCreateTitleCtx); diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index b0051f4854..8730463aff 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -19,8 +19,6 @@ #include "Emu/Cell/RawSPUThread.h" #include "sysPrxForUser.h" -//void sysPrxForUser_init(); -//Module sysPrxForUser("sysPrxForUser", sysPrxForUser_init); Module *sysPrxForUser = nullptr; extern u32 LoadSpuImage(vfsStream& stream, u32& spu_ep); @@ -352,8 +350,10 @@ s32 _unnamed_E75C40F2(u32 dest) return CELL_ENOENT; } -void sysPrxForUser_init() +void sysPrxForUser_init(Module *pxThis) { + sysPrxForUser = pxThis; + // Setup random number generator srand(time(NULL)); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index d98a276f25..0c3c18224b 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -291,8 +291,10 @@ int cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr buf, u64 buffer_size, return CELL_OK; } -void sys_fs_init() +void sys_fs_init(Module *pxThis) { + sys_fs = pxThis; + sys_fs->AddFunc(0x718bf5f8, cellFsOpen); sys_fs->AddFunc(0xb1840b53, cellFsSdataOpen); sys_fs->AddFunc(0x6d3bb15b, cellFsSdataOpenByFd); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp index 238777321e..e6b87792ca 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp @@ -1,16 +1,16 @@ #include "stdafx.h" #include "Emu/SysCalls/Modules.h" -//void sys_io_init(); -//Module sys_io(0x0017, sys_io_init); Module *sys_io = nullptr; extern void cellPad_init(); extern void cellKb_init(); extern void cellMouse_init(); -void sys_io_init() +void sys_io_init(Module *pxThis) { + sys_io = pxThis; + cellPad_init(); cellKb_init(); cellMouse_init(); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp index 133592d26b..a98f61d002 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp @@ -17,8 +17,6 @@ extern "C" #include "sys_net.h" -//void sys_net_init(); -//Module sys_net((u16)0x0000, sys_net_init); Module *sys_net = nullptr; vm::ptr> g_lastError = vm::ptr>::make(0); @@ -501,8 +499,10 @@ int sys_net_free_thread_context() return CELL_OK; } -void sys_net_init() +void sys_net_init(Module *pxThis) { + sys_net = pxThis; + // The names of the following functions are modified to avoid overloading problems sys_net->AddFunc(0xc94f6939, sys_net_accept); sys_net->AddFunc(0xb0a59804, sys_net_bind);