mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 17:01:24 +12:00
initial start to eliminate static func init, not compilable atm
move module initialization into a module manager, still has some issues like stopping not working and debug crashing add #idef 0 to modules that aren't in the windows project don't double initialize and don't de-initialize for now, since many modules don't expect it and it leads to many errors remove duplicate module lists for empty modules and implemented ones, make Module non-copyable but movable add secondary project, no real use for it now add some memleak config to the emucore and add asmjit path to rpcs3 small rebase error fixed to get it to compile again add filters for emucore re-add the module manager and static file WIP commit, linker errors abound some more abstraction layer stuff fix the remaining linker errors, re-enable platform specific mouse, pad and keyboard handlers rebasing fix memset undefined and re() usage of se_t before declaration Add wxGUI define by default for cmake builds fix copy constructors of Datetime header fix copy constructors of other wx interface classes remove static declarations of global variables make wxGLCanvas constructor non-ambiguous even with wx2.8. compat mode, fix wrong std::exception constructor calls remove duplicate definition for FromUTF8 and ToUTF8 temp changes
This commit is contained in:
parent
c4e3ec825e
commit
c37905e465
156 changed files with 6567 additions and 4611 deletions
|
@ -6,322 +6,11 @@
|
|||
#include "Emu/SysCalls/SC_FUNC.h"
|
||||
#include "Emu/SysCalls/Modules.h"
|
||||
#include <mutex>
|
||||
#include "Emu/System.h"
|
||||
#include "ModuleManager.h"
|
||||
|
||||
|
||||
Module* g_modules[3][0xff] = {0};
|
||||
uint g_max_module_id = 0;
|
||||
uint g_module_2_count = 0;
|
||||
std::vector<ModuleFunc *> g_modules_funcs_list;
|
||||
std::mutex g_funcs_lock;
|
||||
std::vector<SFunc *> g_static_funcs_list;
|
||||
|
||||
struct ModuleInfo
|
||||
{
|
||||
u32 id;
|
||||
const char* name;
|
||||
}
|
||||
static const g_module_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"}
|
||||
};
|
||||
|
||||
struct _InitNullModules
|
||||
{
|
||||
std::vector<Module*> m_modules;
|
||||
|
||||
_InitNullModules()
|
||||
{
|
||||
for(auto& m : g_module_list)
|
||||
{
|
||||
m_modules.push_back(new Module(m.id, m.name));
|
||||
}
|
||||
}
|
||||
|
||||
~_InitNullModules()
|
||||
{
|
||||
for (int i = 0; i < m_modules.size(); ++i)
|
||||
{
|
||||
delete m_modules[i];
|
||||
}
|
||||
}
|
||||
} InitNullModules;
|
||||
|
||||
/** HACK: Used to delete SFunc objects that get added to the global static function array (g_static_funcs_list).
|
||||
* The destructor of this static object gets called when the program shuts down.
|
||||
*/
|
||||
struct StaticFunctionListCleaner_t
|
||||
{
|
||||
StaticFunctionListCleaner_t() {}
|
||||
~StaticFunctionListCleaner_t()
|
||||
{
|
||||
for (int i = 0; i < g_static_funcs_list.size(); ++i)
|
||||
{
|
||||
delete g_static_funcs_list[i];
|
||||
}
|
||||
}
|
||||
} StaticFunctionListCleaner;
|
||||
|
||||
bool IsLoadedFunc(u32 id)
|
||||
{
|
||||
for(u32 i=0; i<g_modules_funcs_list.size(); ++i)
|
||||
{
|
||||
if(g_modules_funcs_list[i]->id == id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CallFunc(u32 num)
|
||||
{
|
||||
func_caller* func = nullptr;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_funcs_lock);
|
||||
|
||||
for(u32 i=0; i<g_modules_funcs_list.size(); ++i)
|
||||
{
|
||||
if(g_modules_funcs_list[i]->id == num)
|
||||
{
|
||||
func = g_modules_funcs_list[i]->func;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (func)
|
||||
{
|
||||
(*func)();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UnloadFunc(u32 id)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_funcs_lock);
|
||||
|
||||
for(u32 i=0; i<g_modules_funcs_list.size(); ++i)
|
||||
{
|
||||
if(g_modules_funcs_list[i]->id == id)
|
||||
{
|
||||
g_modules_funcs_list.erase(g_modules_funcs_list.begin() +i);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 GetFuncNumById(u32 id)
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
void UnloadModules()
|
||||
{
|
||||
for(u32 i=0; i<3; ++i)
|
||||
{
|
||||
for(u32 j=0; j<g_max_module_id; ++j)
|
||||
{
|
||||
if(g_modules[i][j])
|
||||
{
|
||||
g_modules[i][j]->UnLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(g_funcs_lock);
|
||||
g_modules_funcs_list.clear();
|
||||
}
|
||||
|
||||
Module* GetModuleByName(const std::string& name)
|
||||
{
|
||||
for(u32 i=0; i<g_max_module_id; ++i)
|
||||
{
|
||||
if(g_modules[0][i] && g_modules[0][i]->GetName() == name)
|
||||
{
|
||||
return g_modules[0][i];
|
||||
}
|
||||
|
||||
if(g_modules[1][i] && g_modules[1][i]->GetName() == name)
|
||||
{
|
||||
return g_modules[1][i];
|
||||
}
|
||||
|
||||
if(g_modules[2][i] && g_modules[2][i]->GetName() == name)
|
||||
{
|
||||
return g_modules[2][i];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Module* GetModuleById(u16 id)
|
||||
{
|
||||
for(u32 i=0; i<g_max_module_id; ++i)
|
||||
{
|
||||
if(g_modules[0][i] && g_modules[0][i]->GetID() == id)
|
||||
{
|
||||
return g_modules[0][i];
|
||||
}
|
||||
|
||||
if(g_modules[1][i] && g_modules[1][i]->GetID() == id)
|
||||
{
|
||||
return g_modules[1][i];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SetModule(int id, Module* module, bool with_data)
|
||||
{
|
||||
if(id != 0xffff)
|
||||
{
|
||||
if(u16((u8)id + 1) > g_max_module_id)
|
||||
{
|
||||
g_max_module_id = u16((u8)id + 1);
|
||||
}
|
||||
|
||||
int index;
|
||||
switch(id >> 8)
|
||||
{
|
||||
case 0x00: index = 0; break;
|
||||
case 0xf0: index = 1; break;
|
||||
default: assert(0); return;
|
||||
}
|
||||
|
||||
if(g_modules[index][(u8)id])
|
||||
{
|
||||
if(with_data)
|
||||
{
|
||||
module->SetName(g_modules[index][(u8)id]->GetName());
|
||||
// delete g_modules[index][(u8)id];
|
||||
g_modules[index][(u8)id] = module;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_modules[index][(u8)id]->SetName(module->GetName());
|
||||
// delete module;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_modules[index][(u8)id] = module;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_modules[2][g_module_2_count++] = module;
|
||||
|
||||
if(g_module_2_count > g_max_module_id)
|
||||
{
|
||||
g_max_module_id = g_module_2_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Module::Module(u16 id, const char* name)
|
||||
: m_is_loaded(false)
|
||||
|
@ -330,7 +19,7 @@ Module::Module(u16 id, const char* name)
|
|||
, m_load_func(nullptr)
|
||||
, m_unload_func(nullptr)
|
||||
{
|
||||
SetModule(m_id, this, false);
|
||||
Emu.GetModuleManager().SetModule(m_id, this, false);
|
||||
}
|
||||
|
||||
Module::Module(const char* name, void (*init)(), void (*load)(), void (*unload)())
|
||||
|
@ -340,7 +29,7 @@ Module::Module(const char* name, void (*init)(), void (*load)(), void (*unload)(
|
|||
, m_load_func(load)
|
||||
, m_unload_func(unload)
|
||||
{
|
||||
SetModule(m_id, this, init != nullptr);
|
||||
Emu.GetModuleManager().SetModule(m_id, this, init != nullptr);
|
||||
if(init) init();
|
||||
}
|
||||
|
||||
|
@ -350,10 +39,35 @@ Module::Module(u16 id, void (*init)(), void (*load)(), void (*unload)())
|
|||
, m_load_func(load)
|
||||
, m_unload_func(unload)
|
||||
{
|
||||
SetModule(m_id, this, init != nullptr);
|
||||
Emu.GetModuleManager().SetModule(m_id, this, init != nullptr);
|
||||
if(init) init();
|
||||
}
|
||||
|
||||
Module::Module(Module &&other)
|
||||
: m_is_loaded(false)
|
||||
, m_id(0)
|
||||
, m_load_func(nullptr)
|
||||
, m_unload_func(nullptr)
|
||||
{
|
||||
std::swap(this->m_name,other.m_name);
|
||||
std::swap(this->m_id, other.m_id);
|
||||
std::swap(this->m_is_loaded, other.m_is_loaded);
|
||||
std::swap(this->m_load_func, other.m_load_func);
|
||||
std::swap(this->m_unload_func, other.m_unload_func);
|
||||
std::swap(this->m_funcs_list, other.m_funcs_list);
|
||||
}
|
||||
|
||||
Module &Module::operator =(Module &&other)
|
||||
{
|
||||
std::swap(this->m_name, other.m_name);
|
||||
std::swap(this->m_id, other.m_id);
|
||||
std::swap(this->m_is_loaded, other.m_is_loaded);
|
||||
std::swap(this->m_load_func, other.m_load_func);
|
||||
std::swap(this->m_unload_func, other.m_unload_func);
|
||||
std::swap(this->m_funcs_list, other.m_funcs_list);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Module::~Module()
|
||||
{
|
||||
UnLoad();
|
||||
|
@ -373,11 +87,7 @@ void Module::Load()
|
|||
|
||||
for(u32 i=0; i<m_funcs_list.size(); ++i)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_funcs_lock);
|
||||
|
||||
if(IsLoadedFunc(m_funcs_list[i]->id)) continue;
|
||||
|
||||
g_modules_funcs_list.push_back(m_funcs_list[i]);
|
||||
Emu.GetModuleManager().AddFunc(m_funcs_list[i]);
|
||||
}
|
||||
|
||||
SetLoaded(true);
|
||||
|
@ -392,7 +102,7 @@ void Module::UnLoad()
|
|||
|
||||
for(u32 i=0; i<m_funcs_list.size(); ++i)
|
||||
{
|
||||
UnloadFunc(m_funcs_list[i]->id);
|
||||
Emu.GetModuleManager().UnloadFunc(m_funcs_list[i]->id);
|
||||
}
|
||||
|
||||
SetLoaded(false);
|
||||
|
@ -400,16 +110,16 @@ void Module::UnLoad()
|
|||
|
||||
bool Module::Load(u32 id)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_funcs_lock);
|
||||
//std::lock_guard<std::mutex> lock(g_funcs_lock);
|
||||
|
||||
if(IsLoadedFunc(id)) return false;
|
||||
if(Emu.GetModuleManager().IsLoadedFunc(id)) return false;
|
||||
|
||||
for(u32 i=0; i<m_funcs_list.size(); ++i)
|
||||
{
|
||||
if(m_funcs_list[i]->id == id)
|
||||
{
|
||||
g_modules_funcs_list.push_back(m_funcs_list[i]);
|
||||
|
||||
//g_modules_funcs_list.push_back(m_funcs_list[i]);
|
||||
Emu.GetModuleManager().AddFunc(m_funcs_list[i]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +129,7 @@ bool Module::Load(u32 id)
|
|||
|
||||
bool Module::UnLoad(u32 id)
|
||||
{
|
||||
return UnloadFunc(id);
|
||||
return Emu.GetModuleManager().UnloadFunc(id);
|
||||
}
|
||||
|
||||
void Module::SetLoaded(bool loaded)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue