FW: merge into core, simplify setup and config

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2020-09-19 16:23:29 +02:00 committed by refractionpcsx2
parent 4a3e67d143
commit 385c698212
7 changed files with 22 additions and 137 deletions

View File

@ -593,14 +593,6 @@ extern _USBirqHandler USBirqHandler;
extern _USBsetRAM USBsetRAM; extern _USBsetRAM USBsetRAM;
#endif #endif
// FW
#ifndef BUILTIN_FW_PLUGIN
extern _FWopen FWopen;
extern _FWread32 FWread32;
extern _FWwrite32 FWwrite32;
extern _FWirqCallback FWirqCallback;
#endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -18,109 +18,30 @@
using namespace std; using namespace std;
#include "FW.h" #include "FW.h"
#include "svnrev.h"
#include "null/config.inl"
const u8 version = PS2E_FW_VERSION;
const u8 revision = 0;
const u8 build = 7; // increase that with each version
static char libraryName[256];
string s_strIniPath = "inis";
string s_strLogPath = "logs";
u8 phyregs[16]; u8 phyregs[16];
s8 *fwregs; s8 *fwregs;
void (*FWirq)(); void (*FWirq)();
EXPORT_C_(void) s32 FWopen()
FWconfigure()
{ {
const std::string ini_path = s_strIniPath + "/FWnull.ini";
LoadConfig(ini_path);
ConfigureLogging();
SaveConfig(ini_path);
}
void LogInit()
{
const std::string LogFile(s_strLogPath + "/FWnull.log");
g_plugin_log.Open(LogFile);
}
EXPORT_C_(void)
FWsetLogDir(const char *dir)
{
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
g_plugin_log.Close();
LogInit();
}
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_FW;
}
EXPORT_C_(const char *)
PS2EgetLibName()
{
snprintf(libraryName, 255, "FWnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
}
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
EXPORT_C_(s32)
FWinit()
{
LoadConfig(s_strIniPath + "/FWnull.ini");
LogInit();
g_plugin_log.WriteLn("FWnull plugin version %d,%d", revision, build);
g_plugin_log.WriteLn("Initializing FWnull");
memset(phyregs, 0, sizeof(phyregs)); memset(phyregs, 0, sizeof(phyregs));
// Initializing our registers. // Initializing our registers.
fwregs = (s8 *)calloc(0x10000, 1); fwregs = (s8 *)calloc(0x10000, 1);
if (fwregs == NULL) { if (fwregs == NULL) {
g_plugin_log.Message("Error allocating Memory"); DevCon.WriteLn("FW: Error allocating Memory");
return -1; return -1;
} }
return 0; return 0;
} }
EXPORT_C_(void) void FWclose()
FWshutdown()
{ {
// Freeing the registers. // Freeing the registers.
free(fwregs); free(fwregs);
fwregs = NULL; fwregs = NULL;
g_plugin_log.Close();
}
EXPORT_C_(s32)
FWopen(void *pDsp)
{
g_plugin_log.WriteLn("Opening FWnull.");
return 0;
}
EXPORT_C_(void)
FWclose()
{
// Close the plugin.
g_plugin_log.WriteLn("Closing FWnull.");
} }
void PHYWrite() void PHYWrite()
@ -147,8 +68,8 @@ void PHYRead()
FWirq(); FWirq();
} }
} }
EXPORT_C_(u32)
FWread32(u32 addr) u32 FWread32(u32 addr)
{ {
u32 ret = 0; u32 ret = 0;
@ -179,13 +100,12 @@ FWread32(u32 addr)
break; break;
} }
g_plugin_log.WriteLn("FW read mem 0x%x: 0x%x", addr, ret); DevCon.WriteLn("FW: read mem 0x%x: 0x%x", addr, ret);
return ret; return ret;
} }
EXPORT_C_(void) void FWwrite32(u32 addr, u32 value)
FWwrite32(u32 addr, u32 value)
{ {
switch (addr) { switch (addr) {
// Include other memory locations we want to catch here. // Include other memory locations we want to catch here.
@ -268,45 +188,11 @@ FWwrite32(u32 addr, u32 value)
fwRu32(addr) = value; fwRu32(addr) = value;
break; break;
} }
g_plugin_log.WriteLn("FW write mem 0x%x: 0x%x", addr, value); DevCon.WriteLn("FW: write mem 0x%x: 0x%x", addr, value);
} }
EXPORT_C_(void) void FWirqCallback(void (*callback)())
FWirqCallback(void (*callback)())
{ {
// Register FWirq, so we can trigger an interrupt with it later. // Register FWirq, so we can trigger an interrupt with it later.
FWirq = callback; FWirq = callback;
} }
EXPORT_C_(void)
FWsetSettingsDir(const char *dir)
{
// Find out from pcsx2 where we are supposed to put our ini file.
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
EXPORT_C_(s32)
FWfreeze(int mode, freezeData *data)
{
// This should store or retrieve any information, for if emulation
// gets suspended, or for savestates.
switch (mode) {
case FREEZE_LOAD:
// Load previously saved data.
break;
case FREEZE_SAVE:
// Save data.
break;
case FREEZE_SIZE:
// return the size of the data.
break;
}
return 0;
}
EXPORT_C_(s32)
FWtest()
{
// 0 if the plugin works, non-0 if it doesn't.
return 0;
}

View File

@ -18,8 +18,6 @@
#include <stdio.h> #include <stdio.h>
#define FWdefs #define FWdefs
#include "PS2Edefs.h"
#include "PS2Eext.h"
// Our main memory storage, and defines for accessing it. // Our main memory storage, and defines for accessing it.
extern s8 *fwregs; extern s8 *fwregs;
@ -31,3 +29,10 @@ extern s8 *fwregs;
extern void (*FWirq)(); extern void (*FWirq)();
s32 FWopen();
void FWclose();
void PHYWrite();
void PHYRead();
u32 FWread32(u32 addr);
void FWwrite32(u32 addr, u32 value);
void FWirqCallback(void (*callback)());

View File

@ -25,6 +25,7 @@
#include "SysThreads.h" #include "SysThreads.h"
#include "MTVU.h" #include "MTVU.h"
#include "IPC.h" #include "IPC.h"
#include "FW.h"
#include "../DebugTools/MIPSAnalyst.h" #include "../DebugTools/MIPSAnalyst.h"
#include "../DebugTools/SymbolMap.h" #include "../DebugTools/SymbolMap.h"
@ -288,14 +289,14 @@ void SysCoreThread::OnSuspendInThread()
{ {
GetCorePlugins().Close(); GetCorePlugins().Close();
DoCDVDclose(); DoCDVDclose();
DoFWclose(); FWclose();
} }
void SysCoreThread::OnResumeInThread( bool isSuspended ) void SysCoreThread::OnResumeInThread( bool isSuspended )
{ {
GetCorePlugins().Open(); GetCorePlugins().Open();
DoCDVDopen(); DoCDVDopen();
DoFWopen(); FWopen();
} }
@ -311,7 +312,7 @@ void SysCoreThread::OnCleanupInThread()
// FIXME: temporary workaround for deadlock on exit, which actually should be a crash // FIXME: temporary workaround for deadlock on exit, which actually should be a crash
vu1Thread.WaitVU(); vu1Thread.WaitVU();
DoCDVDclose(); DoCDVDclose();
DoFWclose(); FWclose();
GetCorePlugins().Close(); GetCorePlugins().Close();
GetCorePlugins().Shutdown(); GetCorePlugins().Shutdown();

View File

@ -432,7 +432,6 @@ void MainEmuFrame::CreateConfigMenu()
m_menuConfig.Append(MenuId_Config_PAD, _("&Controllers (PAD)"),m_PluginMenuPacks[PluginId_PAD]); m_menuConfig.Append(MenuId_Config_PAD, _("&Controllers (PAD)"),m_PluginMenuPacks[PluginId_PAD]);
m_menuConfig.Append(MenuId_Config_DEV9, _("&Dev9"), m_PluginMenuPacks[PluginId_DEV9]); m_menuConfig.Append(MenuId_Config_DEV9, _("&Dev9"), m_PluginMenuPacks[PluginId_DEV9]);
m_menuConfig.Append(MenuId_Config_USB, _("&USB"), m_PluginMenuPacks[PluginId_USB]); m_menuConfig.Append(MenuId_Config_USB, _("&USB"), m_PluginMenuPacks[PluginId_USB]);
m_menuConfig.Append(MenuId_Config_FireWire, _("&Firewire"), m_PluginMenuPacks[PluginId_FW]);
m_menuConfig.AppendSeparator(); m_menuConfig.AppendSeparator();
m_menuConfig.Append(MenuId_Config_Multitap0Toggle, _("Multitap &1"), wxEmptyString, wxITEM_CHECK ); m_menuConfig.Append(MenuId_Config_Multitap0Toggle, _("Multitap &1"), wxEmptyString, wxITEM_CHECK );

View File

@ -19,6 +19,7 @@
#include "Sif.h" #include "Sif.h"
#include "Sio.h" #include "Sio.h"
#include "CDVD/CdRom.h" #include "CDVD/CdRom.h"
#include "FW.h"
#include "ps2/pgif.h" #include "ps2/pgif.h"
#include "Mdec.h" #include "Mdec.h"

View File

@ -17,6 +17,7 @@
#include "IopHw_Internal.h" #include "IopHw_Internal.h"
#include "Sif.h" #include "Sif.h"
#include "Sio.h" #include "Sio.h"
#include "FW.h"
#include "CDVD/CdRom.h" #include "CDVD/CdRom.h"
#include "ps2/pgif.h" #include "ps2/pgif.h"