dev9null|fwnull|usbnull: Switch to new null config code

This commit is contained in:
Jonathan Li 2018-05-23 19:59:17 +01:00
parent 9d4f8a322c
commit fb7c2c1837
21 changed files with 105 additions and 401 deletions

View File

@ -12,12 +12,10 @@ set(FWnullFinalFlags "")
# FWnull sources # FWnull sources
set(FWnullSources set(FWnullSources
Config.cpp
FW.cpp) FW.cpp)
# FWnull headers # FWnull headers
set(FWnullHeaders set(FWnullHeaders
Config.h
FW.h) FW.h)
# FWnull Linux sources # FWnull Linux sources

View File

@ -1,69 +0,0 @@
/* FWnull
* Copyright (C) 2004-2009 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <string>
using namespace std;
#include "FW.h"
#include "Config.h"
extern string s_strIniPath;
extern PluginLog FWLog;
PluginConf Ini;
void setLoggingState()
{
if (conf.Log) {
FWLog.WriteToConsole = true;
FWLog.WriteToFile = true;
} else {
FWLog.WriteToConsole = false;
FWLog.WriteToFile = false;
}
}
EXPORT_C_(void)
FWconfigure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, READ_FILE)) {
FWLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
conf.Log = Ini.ReadInt("logging", 0);
setLoggingState();
Ini.Close();
}
void SaveConfig()
{
string IniPath = s_strIniPath + "/FWnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE)) {
FWLog.WriteLn("Failed to open %s\n", IniPath.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -1,21 +0,0 @@
/* FWnull
* Copyright (C) 2004-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
void SaveConf();
void LoadConf();
void SysMessage(const char *fmt, ...);
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget, widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)

View File

@ -22,6 +22,7 @@ using namespace std;
#include "FW.h" #include "FW.h"
#include "svnrev.h" #include "svnrev.h"
#include "null/config.inl"
const u8 version = PS2E_FW_VERSION; const u8 version = PS2E_FW_VERSION;
const u8 revision = 0; const u8 revision = 0;
@ -34,16 +35,22 @@ string s_strLogPath = "logs";
u8 phyregs[16]; u8 phyregs[16];
s8 *fwregs; s8 *fwregs;
Config conf;
PluginLog FWLog;
void (*FWirq)(); void (*FWirq)();
EXPORT_C_(void)
FWconfigure()
{
const std::string ini_path = s_strIniPath + "/FWnull.ini";
LoadConfig(ini_path);
ConfigureLogging();
SaveConfig(ini_path);
}
void LogInit() void LogInit()
{ {
const std::string LogFile(s_strLogPath + "/FWnull.log"); const std::string LogFile(s_strLogPath + "/FWnull.log");
setLoggingState(); g_plugin_log.Open(LogFile);
FWLog.Open(LogFile);
} }
EXPORT_C_(void) EXPORT_C_(void)
@ -53,7 +60,7 @@ FWsetLogDir(const char *dir)
s_strLogPath = (dir == NULL) ? "logs" : dir; s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path // Reload the log file after updated the path
FWLog.Close(); g_plugin_log.Close();
LogInit(); LogInit();
} }
@ -79,16 +86,16 @@ PS2EgetLibVersion2(u32 type)
EXPORT_C_(s32) EXPORT_C_(s32)
FWinit() FWinit()
{ {
LoadConfig(); LoadConfig(s_strIniPath + "/FWnull.ini");
LogInit(); LogInit();
FWLog.WriteLn("FWnull plugin version %d,%d", revision, build); g_plugin_log.WriteLn("FWnull plugin version %d,%d", revision, build);
FWLog.WriteLn("Initializing FWnull"); 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) {
FWLog.Message("Error allocating Memory"); g_plugin_log.Message("Error allocating Memory");
return -1; return -1;
} }
return 0; return 0;
@ -101,13 +108,13 @@ FWshutdown()
free(fwregs); free(fwregs);
fwregs = NULL; fwregs = NULL;
FWLog.Close(); g_plugin_log.Close();
} }
EXPORT_C_(s32) EXPORT_C_(s32)
FWopen(void *pDsp) FWopen(void *pDsp)
{ {
FWLog.WriteLn("Opening FWnull."); g_plugin_log.WriteLn("Opening FWnull.");
return 0; return 0;
} }
@ -116,7 +123,7 @@ EXPORT_C_(void)
FWclose() FWclose()
{ {
// Close the plugin. // Close the plugin.
FWLog.WriteLn("Closing FWnull."); g_plugin_log.WriteLn("Closing FWnull.");
} }
void PHYWrite() void PHYWrite()
@ -175,7 +182,7 @@ FWread32(u32 addr)
break; break;
} }
FWLog.WriteLn("FW read mem 0x%x: 0x%x", addr, ret); g_plugin_log.WriteLn("FW read mem 0x%x: 0x%x", addr, ret);
return ret; return ret;
} }
@ -264,7 +271,7 @@ FWwrite32(u32 addr, u32 value)
fwRu32(addr) = value; fwRu32(addr) = value;
break; break;
} }
FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value); g_plugin_log.WriteLn("FW write mem 0x%x: 0x%x", addr, value);
} }
EXPORT_C_(void) EXPORT_C_(void)

View File

@ -30,17 +30,6 @@ extern s8 *fwregs;
//PHY Access Address for ease of use :P //PHY Access Address for ease of use :P
#define PHYACC fwRu32(0x8414) #define PHYACC fwRu32(0x8414)
typedef struct
{
s32 Log;
} Config;
extern Config conf;
extern void (*FWirq)(); extern void (*FWirq)();
extern void SaveConfig();
extern void LoadConfig();
extern void setLoggingState();
#endif #endif

View File

@ -13,7 +13,7 @@
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|x64"> <ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
@ -52,16 +52,17 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\Config.cpp" />
<ClCompile Include="..\FW.cpp" /> <ClCompile Include="..\FW.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\FW.h" /> <ClInclude Include="..\FW.h" />
<ClInclude Include="..\Config.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="FireWireNull.def" /> <None Include="FireWireNull.def" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\common\include\null\null.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" /> <ImportGroup Label="ExtensionTargets" />
</Project> </Project>

View File

@ -15,9 +15,6 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\Config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\FW.cpp"> <ClCompile Include="..\FW.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -26,13 +23,15 @@
<ClInclude Include="..\FW.h"> <ClInclude Include="..\FW.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Config.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="FireWireNull.def"> <None Include="FireWireNull.def">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\common\include\null\null.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -12,12 +12,10 @@ set(USBnullFinalFlags "")
# USBnull sources # USBnull sources
set(USBnullSources set(USBnullSources
Config.cpp
USB.cpp) USB.cpp)
# USBnull headers # USBnull headers
set(USBnullHeaders set(USBnullHeaders
Config.h
USB.h) USB.h)
# USBnull Linux sources # USBnull Linux sources

View File

@ -1,69 +0,0 @@
/* USBnull
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <string>
using namespace std;
#include "USB.h"
#include "Config.h"
extern string s_strIniPath;
extern PluginLog USBLog;
PluginConf Ini;
void setLoggingState()
{
if (conf.Log) {
USBLog.WriteToConsole = true;
USBLog.WriteToFile = true;
} else {
USBLog.WriteToConsole = false;
USBLog.WriteToFile = false;
}
}
EXPORT_C_(void)
USBconfigure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, READ_FILE)) {
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
conf.Log = Ini.ReadInt("logging", 0);
setLoggingState();
Ini.Close();
}
void SaveConfig()
{
string IniPath = s_strIniPath + "/USBnull.ini";
if (!Ini.Open(IniPath, WRITE_FILE)) {
USBLog.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -1,17 +0,0 @@
/* USBnull
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
extern void SaveConfig();
extern void LoadConfig();

View File

@ -18,6 +18,8 @@
using namespace std; using namespace std;
#include "svnrev.h" #include "svnrev.h"
#include "USB.h" #include "USB.h"
#include "null/config.inl"
string s_strIniPath = "inis"; string s_strIniPath = "inis";
string s_strLogPath = "logs"; string s_strLogPath = "logs";
@ -28,16 +30,22 @@ const unsigned char build = 7; // increase that with each version
static char libraryName[256]; static char libraryName[256];
USBcallback USBirq; USBcallback USBirq;
Config conf;
PluginLog USBLog;
s8 *usbregs, *ram; s8 *usbregs, *ram;
EXPORT_C_(void)
USBconfigure()
{
const std::string ini_path = s_strIniPath + "/USBnull.ini";
LoadConfig(ini_path);
ConfigureLogging();
SaveConfig(ini_path);
}
void LogInit() void LogInit()
{ {
const std::string LogFile(s_strLogPath + "/USBnull.log"); const std::string LogFile(s_strLogPath + "/USBnull.log");
setLoggingState(); g_plugin_log.Open(LogFile);
USBLog.Open(LogFile);
} }
EXPORT_C_(void) EXPORT_C_(void)
@ -47,7 +55,7 @@ USBsetLogDir(const char *dir)
s_strLogPath = (dir == NULL) ? "logs" : dir; s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path // Reload the log file after updated the path
USBLog.Close(); g_plugin_log.Close();
LogInit(); LogInit();
} }
@ -73,16 +81,16 @@ PS2EgetLibVersion2(u32 type)
EXPORT_C_(s32) EXPORT_C_(s32)
USBinit() USBinit()
{ {
LoadConfig(); LoadConfig(s_strIniPath + "/USBnull.ini");
LogInit(); LogInit();
USBLog.WriteLn("USBnull plugin version %d,%d", revision, build); g_plugin_log.WriteLn("USBnull plugin version %d,%d", revision, build);
USBLog.WriteLn("Initializing USBnull"); g_plugin_log.WriteLn("Initializing USBnull");
// Initialize memory structures here. // Initialize memory structures here.
usbregs = (s8 *)calloc(0x10000, 1); usbregs = (s8 *)calloc(0x10000, 1);
if (usbregs == NULL) { if (usbregs == NULL) {
USBLog.Message("Error allocating memory"); g_plugin_log.Message("Error allocating memory");
return -1; return -1;
} }
@ -94,7 +102,7 @@ USBshutdown()
{ {
// Yes, we close things in the Shutdown routine, and // Yes, we close things in the Shutdown routine, and
// don't do anything in the close routine. // don't do anything in the close routine.
USBLog.Close(); g_plugin_log.Close();
free(usbregs); free(usbregs);
usbregs = NULL; usbregs = NULL;
@ -103,7 +111,7 @@ USBshutdown()
EXPORT_C_(s32) EXPORT_C_(s32)
USBopen(void *pDsp) USBopen(void *pDsp)
{ {
USBLog.WriteLn("Opening USBnull."); g_plugin_log.WriteLn("Opening USBnull.");
// Take care of anything else we need on opening, other then initialization. // Take care of anything else we need on opening, other then initialization.
return 0; return 0;
@ -112,7 +120,7 @@ USBopen(void *pDsp)
EXPORT_C_(void) EXPORT_C_(void)
USBclose() USBclose()
{ {
USBLog.WriteLn("Closing USBnull."); g_plugin_log.WriteLn("Closing USBnull.");
} }
// Note: actually uncommenting the read/write functions I provided here // Note: actually uncommenting the read/write functions I provided here
@ -125,12 +133,12 @@ USBread8(u32 addr)
switch (addr) { switch (addr) {
// Handle any appropriate addresses here. // Handle any appropriate addresses here.
case 0x1f801600: case 0x1f801600:
USBLog.WriteLn("(USBnull) 8 bit read at address %lx", addr); g_plugin_log.WriteLn("(USBnull) 8 bit read at address %lx", addr);
break; break;
default: default:
//value = usbRu8(addr); //value = usbRu8(addr);
USBLog.WriteLn("*(USBnull) 8 bit read at address %lx", addr); g_plugin_log.WriteLn("*(USBnull) 8 bit read at address %lx", addr);
break; break;
} }
return value; return value;
@ -144,12 +152,12 @@ USBread16(u32 addr)
switch (addr) { switch (addr) {
// Handle any appropriate addresses here. // Handle any appropriate addresses here.
case 0x1f801600: case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); g_plugin_log.WriteLn("(USBnull) 16 bit read at address %lx", addr);
break; break;
default: default:
//value = usbRu16(addr); //value = usbRu16(addr);
USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); g_plugin_log.WriteLn("(USBnull) 16 bit read at address %lx", addr);
} }
return value; return value;
} }
@ -162,12 +170,12 @@ USBread32(u32 addr)
switch (addr) { switch (addr) {
// Handle any appropriate addresses here. // Handle any appropriate addresses here.
case 0x1f801600: case 0x1f801600:
USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); g_plugin_log.WriteLn("(USBnull) 32 bit read at address %lx", addr);
break; break;
default: default:
//value = usbRu32(addr); //value = usbRu32(addr);
USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); g_plugin_log.WriteLn("(USBnull) 32 bit read at address %lx", addr);
} }
return value; return value;
} }
@ -178,12 +186,12 @@ USBwrite8(u32 addr, u8 value)
switch (addr) { switch (addr) {
// Handle any appropriate addresses here. // Handle any appropriate addresses here.
case 0x1f801600: case 0x1f801600:
USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); g_plugin_log.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value);
break; break;
default: default:
//usbRu8(addr) = value; //usbRu8(addr) = value;
USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); g_plugin_log.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value);
} }
} }
@ -193,12 +201,12 @@ USBwrite16(u32 addr, u16 value)
switch (addr) { switch (addr) {
// Handle any appropriate addresses here. // Handle any appropriate addresses here.
case 0x1f801600: case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); g_plugin_log.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
break; break;
default: default:
//usbRu16(addr) = value; //usbRu16(addr) = value;
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); g_plugin_log.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
} }
} }
@ -208,12 +216,12 @@ USBwrite32(u32 addr, u32 value)
switch (addr) { switch (addr) {
// Handle any appropriate addresses here. // Handle any appropriate addresses here.
case 0x1f801600: case 0x1f801600:
USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); g_plugin_log.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value);
break; break;
default: default:
//usbRu32(addr) = value; //usbRu32(addr) = value;
USBLog.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value); g_plugin_log.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value);
} }
} }
@ -245,7 +253,7 @@ EXPORT_C_(void)
USBsetRAM(void *mem) USBsetRAM(void *mem)
{ {
ram = (s8 *)mem; ram = (s8 *)mem;
USBLog.WriteLn("*Setting ram."); g_plugin_log.WriteLn("*Setting ram.");
} }
EXPORT_C_(void) EXPORT_C_(void)
@ -287,6 +295,3 @@ USBtest()
// 0 if the plugin works, non-0 if it doesn't. // 0 if the plugin works, non-0 if it doesn't.
return 0; return 0;
} }
/* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */
ENTRY_POINT;

View File

@ -22,13 +22,7 @@
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "PS2Eext.h" #include "PS2Eext.h"
typedef struct
{
int Log;
} Config;
extern USBcallback USBirq; extern USBcallback USBirq;
extern Config conf;
// Previous USB plugins have needed this in ohci. // Previous USB plugins have needed this in ohci.
static const s64 PSXCLK = 36864000; /* 36.864 Mhz */ static const s64 PSXCLK = 36864000; /* 36.864 Mhz */
@ -42,8 +36,4 @@ extern s8 *usbregs, *ram;
#define usbRu16(mem) (*(u16 *)&usbregs[(mem)&0xffff]) #define usbRu16(mem) (*(u16 *)&usbregs[(mem)&0xffff])
#define usbRu32(mem) (*(u32 *)&usbregs[(mem)&0xffff]) #define usbRu32(mem) (*(u32 *)&usbregs[(mem)&0xffff])
extern void SaveConfig();
extern void LoadConfig();
extern void setLoggingState();
#endif #endif

View File

@ -52,16 +52,17 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\Config.cpp" />
<ClCompile Include="..\USB.cpp" /> <ClCompile Include="..\USB.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\Config.h" />
<ClInclude Include="..\USB.h" /> <ClInclude Include="..\USB.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="USBnull.def" /> <None Include="USBnull.def" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\common\include\null\null.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" /> <ImportGroup Label="ExtensionTargets" />
</Project> </Project>

View File

@ -15,17 +15,11 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\Config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\USB.cpp"> <ClCompile Include="..\USB.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\Config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\USB.h"> <ClInclude Include="..\USB.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -35,4 +29,9 @@
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\common\include\null\null.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>

View File

@ -12,12 +12,10 @@ set(dev9nullFinalFlags "")
# dev9null sources # dev9null sources
set(dev9nullSources set(dev9nullSources
Config.cpp
DEV9.cpp) DEV9.cpp)
# dev9null headers # dev9null headers
set(dev9nullHeaders set(dev9nullHeaders
Config.h
DEV9.h) DEV9.h)
# dev9null Linux sources # dev9null Linux sources

View File

@ -1,71 +0,0 @@
/* DEV9null
* Copyright (C) 2002-2010 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <string>
using namespace std;
#include "Config.h"
#include "DEV9.h"
extern string s_strIniPath;
extern PluginLog Dev9Log;
PluginConf Ini;
void setLoggingState()
{
if (conf.Log) {
Dev9Log.WriteToConsole = true;
Dev9Log.WriteToFile = true;
} else {
Dev9Log.WriteToConsole = false;
Dev9Log.WriteToFile = false;
}
}
EXPORT_C_(void)
DEV9configure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
void LoadConfig()
{
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, READ_FILE)) {
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig();
return;
}
conf.Log = Ini.ReadInt("logging", 0);
Ini.Close();
}
void SaveConfig()
{
string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, WRITE_FILE)) {
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
return;
}
Ini.WriteInt("logging", conf.Log);
Ini.Close();
}

View File

@ -1,24 +0,0 @@
/* dev9null
* Copyright (C) 2002-2010 PCSX2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
void SaveConfig();
void LoadConfig();
void SysMessage(char *fmt, ...);
//#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
//#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)

View File

@ -32,6 +32,7 @@ using namespace std;
#include "DEV9.h" #include "DEV9.h"
#include "svnrev.h" #include "svnrev.h"
#include "null/config.inl"
const unsigned char version = PS2E_DEV9_VERSION; const unsigned char version = PS2E_DEV9_VERSION;
const unsigned char revision = 0; const unsigned char revision = 0;
@ -47,14 +48,19 @@ __aligned16 s8 dev9regs[0x10000];
string s_strIniPath = "inis"; string s_strIniPath = "inis";
string s_strLogPath = "logs"; string s_strLogPath = "logs";
PluginLog Dev9Log; EXPORT_C_(void)
Config conf; DEV9configure()
{
const std::string ini_path = s_strIniPath + "/Dev9null.ini";
LoadConfig(ini_path);
ConfigureLogging();
SaveConfig(ini_path);
}
void LogInit() void LogInit()
{ {
const std::string LogFile(s_strLogPath + "/dev9null.log"); const std::string LogFile(s_strLogPath + "/dev9null.log");
setLoggingState(); g_plugin_log.Open(LogFile);
Dev9Log.Open(LogFile);
} }
EXPORT_C_(void) EXPORT_C_(void)
@ -64,7 +70,7 @@ DEV9setLogDir(const char *dir)
s_strLogPath = (dir == NULL) ? "logs" : dir; s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path // Reload the log file after updated the path
Dev9Log.Close(); g_plugin_log.Close();
LogInit(); LogInit();
} }
@ -90,11 +96,10 @@ PS2EgetLibVersion2(u32 type)
EXPORT_C_(s32) EXPORT_C_(s32)
DEV9init() DEV9init()
{ {
LoadConfig(); LoadConfig(s_strIniPath + "/Dev9null.ini");
setLoggingState();
LogInit(); LogInit();
Dev9Log.WriteLn("dev9null plugin version %d,%d", revision, build); g_plugin_log.WriteLn("dev9null plugin version %d,%d", revision, build);
Dev9Log.WriteLn("Initializing dev9null"); g_plugin_log.WriteLn("Initializing dev9null");
// Initialize anything that needs to be initialized. // Initialize anything that needs to be initialized.
memset(dev9regs, 0, sizeof(dev9regs)); memset(dev9regs, 0, sizeof(dev9regs));
return 0; return 0;
@ -103,14 +108,14 @@ DEV9init()
EXPORT_C_(void) EXPORT_C_(void)
DEV9shutdown() DEV9shutdown()
{ {
Dev9Log.WriteLn("Shutting down Dev9null."); g_plugin_log.WriteLn("Shutting down Dev9null.");
Dev9Log.Close(); g_plugin_log.Close();
} }
EXPORT_C_(s32) EXPORT_C_(s32)
DEV9open(void *pDsp) DEV9open(void *pDsp)
{ {
Dev9Log.WriteLn("Opening Dev9null."); g_plugin_log.WriteLn("Opening Dev9null.");
// Get anything ready we need to. Opening and creating hard // Get anything ready we need to. Opening and creating hard
// drive files, for example. // drive files, for example.
return 0; return 0;
@ -119,7 +124,7 @@ DEV9open(void *pDsp)
EXPORT_C_(void) EXPORT_C_(void)
DEV9close() DEV9close()
{ {
Dev9Log.WriteLn("Closing Dev9null."); g_plugin_log.WriteLn("Closing Dev9null.");
// Close files opened. // Close files opened.
} }
@ -134,7 +139,7 @@ DEV9read8(u32 addr)
break; // We need to have at least one case to avoid warnings. break; // We need to have at least one case to avoid warnings.
default: default:
//value = dev9Ru8(addr); //value = dev9Ru8(addr);
Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr); g_plugin_log.WriteLn("*Unknown 8 bit read at address %lx", addr);
break; break;
} }
return value; return value;
@ -167,7 +172,7 @@ DEV9read16(u32 addr)
break; break;
default: default:
//value = dev9Ru16(addr); //value = dev9Ru16(addr);
Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr); g_plugin_log.WriteLn("*Unknown 16 bit read at address %lx", addr);
break; break;
} }
@ -184,7 +189,7 @@ DEV9read32(u32 addr)
break; break;
default: default:
//value = dev9Ru32(addr); //value = dev9Ru32(addr);
Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr); g_plugin_log.WriteLn("*Unknown 32 bit read at address %lx", addr);
break; break;
} }
@ -198,7 +203,7 @@ DEV9write8(u32 addr, u8 value)
case 0x10000038: /*dev9Ru8(addr) = value;*/ case 0x10000038: /*dev9Ru8(addr) = value;*/
break; break;
default: default:
Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value); g_plugin_log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value);
//dev9Ru8(addr) = value; //dev9Ru8(addr) = value;
break; break;
} }
@ -213,7 +218,7 @@ DEV9write16(u32 addr, u16 value)
case 0x10000038: /*dev9Ru16(addr) = value;*/ case 0x10000038: /*dev9Ru16(addr) = value;*/
break; break;
default: default:
Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value); g_plugin_log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value);
//dev9Ru16(addr) = value; //dev9Ru16(addr) = value;
break; break;
} }
@ -226,7 +231,7 @@ DEV9write32(u32 addr, u32 value)
case 0x10000038: /*dev9Ru32(addr) = value;*/ case 0x10000038: /*dev9Ru32(addr) = value;*/
break; break;
default: default:
Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value); g_plugin_log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value);
//dev9Ru32(addr) = value; //dev9Ru32(addr) = value;
break; break;
} }
@ -238,7 +243,7 @@ DEV9dmaRead(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed)
{ {
// You'll want to put your own DMA8 reading code here. // You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware. // Time to interact with your fake (or real) hardware.
Dev9Log.WriteLn("Reading DMA8 Mem."); g_plugin_log.WriteLn("Reading DMA8 Mem.");
*bytesProcessed = bytesLeft; *bytesProcessed = bytesLeft;
return 0; return 0;
} }
@ -247,7 +252,7 @@ EXPORT_C_(s32)
DEV9dmaWrite(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed) DEV9dmaWrite(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed)
{ {
// See above. // See above.
Dev9Log.WriteLn("Writing DMA8 Mem."); g_plugin_log.WriteLn("Writing DMA8 Mem.");
*bytesProcessed = bytesLeft; *bytesProcessed = bytesLeft;
return 0; return 0;
} }
@ -263,14 +268,14 @@ DEV9readDMA8Mem(u32 *pMem, int size)
{ {
// You'll want to put your own DMA8 reading code here. // You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware. // Time to interact with your fake (or real) hardware.
Dev9Log.WriteLn("Reading DMA8 Mem."); g_plugin_log.WriteLn("Reading DMA8 Mem.");
} }
EXPORT_C_(void) EXPORT_C_(void)
DEV9writeDMA8Mem(u32 *pMem, int size) DEV9writeDMA8Mem(u32 *pMem, int size)
{ {
// See above. // See above.
Dev9Log.WriteLn("Writing DMA8 Mem."); g_plugin_log.WriteLn("Writing DMA8 Mem.");
} }
//#endif //#endif
@ -328,6 +333,3 @@ DEV9freeze(int mode, freezeData *data)
} }
return 0; return 0;
} }
/* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */
ENTRY_POINT;

View File

@ -25,21 +25,11 @@
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "PS2Eext.h" #include "PS2Eext.h"
typedef struct
{
s32 Log;
} Config;
extern Config conf;
extern const unsigned char version; extern const unsigned char version;
extern const unsigned char revision; extern const unsigned char revision;
extern const unsigned char build; extern const unsigned char build;
extern const unsigned int minor; extern const unsigned int minor;
void SaveConfig();
void LoadConfig();
extern void (*DEV9irq)(int); extern void (*DEV9irq)(int);
extern __aligned16 s8 dev9regs[0x10000]; extern __aligned16 s8 dev9regs[0x10000];
@ -50,6 +40,4 @@ extern __aligned16 s8 dev9regs[0x10000];
#define dev9Ru16(mem) (*(u16 *)&dev9regs[(mem)&0xffff]) #define dev9Ru16(mem) (*(u16 *)&dev9regs[(mem)&0xffff])
#define dev9Ru32(mem) (*(u32 *)&dev9regs[(mem)&0xffff]) #define dev9Ru32(mem) (*(u32 *)&dev9regs[(mem)&0xffff])
extern void setLoggingState();
#endif #endif

View File

@ -53,14 +53,15 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\DEV9.cpp" /> <ClCompile Include="..\DEV9.cpp" />
<ClCompile Include="..\Config.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="dev9null.def" /> <None Include="dev9null.def" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\DEV9.h" /> <ClInclude Include="..\DEV9.h" />
<ClInclude Include="..\Config.h" /> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\common\include\null\null.rc" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" /> <ImportGroup Label="ExtensionTargets" />

View File

@ -10,9 +10,6 @@
<ClCompile Include="..\DEV9.cpp"> <ClCompile Include="..\DEV9.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\Config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="dev9null.def"> <None Include="dev9null.def">
@ -21,6 +18,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\DEV9.h" /> <ClInclude Include="..\DEV9.h" />
<ClInclude Include="..\Config.h" /> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\common\include\null\null.rc" />
</ItemGroup> </ItemGroup>
</Project> </Project>