1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 03:02:53 +01:00

Merge pull request #806 from Arkaran99/master

Small refactor
This commit is contained in:
B1ackDaemon 2014-09-14 20:31:08 +03:00
commit bd1f413481
54 changed files with 382 additions and 496 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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 <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0006, cellAdec_init);
cellAtrac = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0013, cellAtrac_init);
cellAudio = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0011, cellAudio_init);
cellCamera = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0023, cellCamera_init);
cellDmux = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0007, cellDmux_init);
cellFiber = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0043, cellFiber_init);
cellFont = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0019, cellFont_init, cellFont_load, cellFont_unload);
cellFontFT = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x001a, cellFontFT_init, cellFontFT_load, cellFontFT_unload);
cellGame = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x003e, cellGame_init);
cellGcmSys = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0010, cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload);
cellGem = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x005a, cellGem_init);
cellJpgDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000f, cellJpgDec_init);
cellGifDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0xf010, cellGifDec_init);
cellL10n = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x001e, cellL10n_init);
cellNetCtl = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0014, cellNetCtl_init);
cellOvis = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000b, cellOvis_init);
cellPamf = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0012, cellPamf_init);
cellPngDec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0018, cellPngDec_init);
cellResc = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x001f, cellResc_init, cellResc_load, cellResc_unload);
cellRtc = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0009, cellRtc_init);
cellSail = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSail", cellSail_init);
cellSpurs = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000a, cellSpurs_init);
cellSpursJq = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0050, cellSpursJq_init);
cellSync = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSync", cellSync_init);
cellSync2 = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0055, cellSync2_init);
cellSysutil = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0015, cellSysutil_init, cellSysutil_load, nullptr);
cellSysutilAp = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0039, cellSysutilAp_init);
cellSysmodule = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSysmodule", cellSysmodule_init);
cellUserInfo = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0032, cellUserInfo_init);
cellVdec = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0005, cellVdec_init);
cellVpost = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0008, cellVpost_init);
libmixer = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("libmixer", libmixer_init);
sceNp = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0016, sceNp_init);
sceNpClans = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x003a, sceNpClans_init, nullptr, sceNpClans_unload);
sceNpCommerce2 = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0044, sceNpCommerce2_init, nullptr, sceNpCommerce2_unload);
sceNpSns = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0059, sceNpSns_init, nullptr, sceNpSns_unload);
sceNpTrophy = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0xf035, sceNpTrophy_init, nullptr, sceNpTrophy_unload);
sceNpTus = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0045, sceNpTus_init, nullptr, sceNpTus_unload);
sysPrxForUser = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("sysPrxForUser", sysPrxForUser_init, sysPrxForUser_load, nullptr);
sys_fs = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000e, sys_fs_init, sys_fs_load, nullptr);
sys_io = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0017, sys_io_init);
sys_net = static_cast <Module*>(&(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; i<m_max_module_id; ++i)
for (u32 i = 0; i<m_max_module_id && i<0xff; ++i)
{
if (m_modules[0][i] && m_modules[0][i]->GetName() == name)
{
@ -437,7 +323,7 @@ Module* ModuleManager::GetModuleByName(const std::string& name)
Module* ModuleManager::GetModuleById(u16 id)
{
for (u32 i = 0; i<m_max_module_id; ++i)
for (u32 i = 0; i<m_max_module_id && i<0xff; ++i)
{
if (m_modules[0][i] && m_modules[0][i]->GetID() == 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;

View File

@ -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<ModuleFunc *> m_modules_funcs_list;
std::vector<Module> m_mod_init;
std::vector<Module> 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);

View File

@ -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.size(); ++i)
{

View File

@ -59,9 +59,7 @@ class Module : public LogBase
public:
std::vector<ModuleFunc*> 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);

View File

@ -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<CellAdecCbMsg> func, u32 arg)
@ -808,8 +806,10 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr<be_t<u32>> 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);

View File

@ -203,8 +203,10 @@ int cellAtracGetInternalErrorInfo(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t
return CELL_OK;
}
void cellAtrac_init()
void cellAtrac_init(Module *pxThis)
{
cellAtrac = pxThis;
cellAtrac->AddFunc(0x66afc68e, cellAtracSetDataAndGetMemSize);
cellAtrac->AddFunc(0xfa293e88, cellAtracCreateDecoder);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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::ptr<const CellJpgD
}
void cellJpgDec_init()
void cellJpgDec_init(Module *pxThis)
{
cellJpgDec = pxThis;
cellJpgDec->AddFunc(0xa7978f59, cellJpgDecCreate);
cellJpgDec->AddFunc(0x8b300f66, cellJpgDecExtCreate);
cellJpgDec->AddFunc(0x976ca5c2, cellJpgDecOpen);

View File

@ -14,8 +14,6 @@
#include <iconv.h>
#endif
//void cellL10n_init();
//Module cellL10n(0x001e, cellL10n_init);
Module *cellL10n = nullptr;
int UTF16stoUTF8s(vm::lptrl<const char16_t> utf16, vm::ptr<be_t<u32>> utf16_len, vm::ptr<char> utf8, vm::ptr<be_t<u32>> utf8_len)
@ -337,8 +335,10 @@ int L10nConvertStr(int src_code, vm::ptr<const void> src, vm::ptr<be_t<u32>> 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);

View File

@ -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<CellNetCtlNatInfo> natInfo)
return CELL_OK;
}
void cellNetCtl_init()
void cellNetCtl_init(Module *pxThis)
{
cellNetCtl = pxThis;
cellNetCtl->AddFunc(0xbd5a59fc, cellNetCtlInit);
cellNetCtl->AddFunc(0x105ee2cb, cellNetCtlTerm);

View File

@ -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);

View File

@ -539,8 +539,10 @@ int cellPamfEpIteratorMove(vm::ptr<CellPamfEpIterator> pIt, s32 steps, vm::ptr<C
return CELL_OK;
}
void cellPamf_init()
void cellPamf_init(Module *pxThis)
{
cellPamf = pxThis;
cellPamf->AddFunc(0xca8181c1, cellPamfGetHeaderSize);
cellPamf->AddFunc(0x90fc9a59, cellPamfGetHeaderSize2);
cellPamf->AddFunc(0x44f5c9e3, cellPamfGetStreamOffsetAndSize);

View File

@ -8,8 +8,6 @@
#include "cellPngDec.h"
#include <map>
//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);

View File

@ -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);

View File

@ -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<CellRtcTick> pTick0, vm::ptr<CellRtcTick> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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<be_t<u32>> 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);

View File

@ -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);

View File

@ -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);

View File

@ -21,9 +21,6 @@
typedef void (*CellHddGameStatCallback)(vm::ptr<CellHddGameCBResult> cbResult, vm::ptr<CellHddGameStatGet> get, vm::ptr<CellHddGameStatSet> set);
//void cellSysutil_init();
//Module cellSysutil(0x0015, cellSysutil_init);
Module *cellSysutil = nullptr;
int cellSysutilGetSystemParamInt(int id, vm::ptr<be_t<u32>> value)
@ -844,8 +841,10 @@ extern int cellGameDataCheckCreate2(u32 version, vm::ptr<const char> dirName, u3
extern int cellGameDataCheckCreate(u32 version, vm::ptr<const char> dirName, u32 errDialog,
vm::ptr<void(*)(vm::ptr<CellGameDataCBResult> cbResult, vm::ptr<CellGameDataStatGet> get, vm::ptr<CellGameDataStatSet> set)> funcStat, u32 container);
void cellSysutil_init()
void cellSysutil_init(Module *pxThis)
{
cellSysutil = pxThis;
cellSysutil->AddFunc(0x40e895d3, cellSysutilGetSystemParamInt);
cellSysutil->AddFunc(0x938013a0, cellSysutilGetSystemParamString);

View File

@ -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);

View File

@ -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<CellUserInfoUserStat> stat)
@ -76,8 +74,10 @@ int cellUserInfoGetList(vm::ptr<be_t<u32>> listNum, vm::ptr<CellUserInfoUserList
return CELL_OK;
}
void cellUserInfo_init()
void cellUserInfo_init(Module *pxThis)
{
cellUserInfo = pxThis;
cellUserInfo->AddFunc(0x2b761140, cellUserInfoGetStat);
cellUserInfo->AddFunc(0x3097cc1c, cellUserInfoSelectUser_ListType);
cellUserInfo->AddFunc(0x55123a25, cellUserInfoSelectUser_SetList);

View File

@ -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<CellVdecCbMsg> 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);

View File

@ -10,8 +10,6 @@ extern "C"
#include "cellVpost.h"
//void cellVpost_init();
//Module cellVpost(0x0008, cellVpost_init);
Module *cellVpost = nullptr;
int cellVpostQueryAttr(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<CellVpostAttr> attr)
@ -153,8 +151,10 @@ int cellVpostExec(u32 handle, vm::ptr<const u8> inPicBuff, vm::ptr<const CellVpo
return CELL_OK;
}
void cellVpost_init()
void cellVpost_init(Module *pxThis)
{
cellVpost = pxThis;
cellVpost->AddFunc(0x95e788c3, cellVpostQueryAttr);
cellVpost->AddFunc(0xcd33f3e2, cellVpostOpen);
cellVpost->AddFunc(0x40524325, cellVpostOpenEx);

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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
}

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -291,8 +291,10 @@ int cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> 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);

View File

@ -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();

View File

@ -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<be_t<s32>> g_lastError = vm::ptr<be_t<s32>>::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);

View File

@ -104,6 +104,8 @@ void DisAsmFrame::Resume()
#include <Utilities/MTProgressDialog.h>
#include "Loader/ELF.h"
#include "Loader/ELF32.h"
#include "Loader/ELF64.h"
std::vector<Elf64_Shdr>* shdr_arr_64 = NULL;
std::vector<Elf32_Shdr>* shdr_arr_32 = NULL;
ELF64Loader* l_elf64 = NULL;

View File

@ -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();
}

View File

@ -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);

View File

@ -372,13 +372,16 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
auto& proc_param = vm::get_ref<sys_process_param>(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());

View File

@ -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;