2009-05-02 00:56:56 +00:00
|
|
|
/* FWnull
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2004-2010 PCSX2 Dev Team
|
2009-05-02 00:56:56 +00:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "FW.h"
|
|
|
|
|
2009-05-21 21:12:01 +00:00
|
|
|
const u8 version = PS2E_FW_VERSION;
|
|
|
|
const u8 revision = 0;
|
2010-01-09 05:11:18 +00:00
|
|
|
const u8 build = 6; // increase that with each version
|
2009-05-02 00:56:56 +00:00
|
|
|
|
|
|
|
static char *libraryName = "FWnull Driver";
|
2009-05-15 06:08:35 +00:00
|
|
|
|
2010-01-09 05:11:18 +00:00
|
|
|
string s_strIniPath="inis/";
|
2010-05-29 10:46:48 +00:00
|
|
|
string s_strLogPath = "logs/";
|
|
|
|
|
2009-05-02 00:56:56 +00:00
|
|
|
s8 *fwregs;
|
|
|
|
Config conf;
|
2010-01-09 05:11:18 +00:00
|
|
|
PluginLog FWLog;
|
2009-05-15 06:08:35 +00:00
|
|
|
|
2009-05-02 00:56:56 +00:00
|
|
|
void (*FWirq)();
|
|
|
|
|
2010-05-29 10:46:48 +00:00
|
|
|
void LogInit()
|
|
|
|
{
|
|
|
|
const std::string LogFile(s_strLogPath + "/FWnull.log");
|
|
|
|
setLoggingState();
|
|
|
|
FWLog.Open(LogFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) PADSetLogFolder(const char* dir)
|
|
|
|
{
|
|
|
|
// Get the path to the log directory.
|
|
|
|
s_strLogPath = (dir==NULL) ? "logs/" : dir;
|
|
|
|
|
|
|
|
// Reload the log file after updated the path
|
|
|
|
FWLog.Close();
|
|
|
|
LogInit();
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(u32) PS2EgetLibType()
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
|
|
|
return PS2E_LT_FW;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(char*) PS2EgetLibName()
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
|
|
|
return libraryName;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
|
|
|
return (version<<16) | (revision<<8) | build;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(s32) FWinit()
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
|
|
|
LoadConfig();
|
2010-05-29 10:46:48 +00:00
|
|
|
LogInit();
|
2010-01-09 05:11:18 +00:00
|
|
|
FWLog.WriteLn("FWnull plugin version %d,%d", revision, build);
|
|
|
|
FWLog.WriteLn("Initializing FWnull");
|
2009-05-02 00:56:56 +00:00
|
|
|
|
2010-01-09 05:11:18 +00:00
|
|
|
// Initializing our registers.
|
2010-05-28 16:54:42 +00:00
|
|
|
fwregs = (s8*)calloc(0x10000,1);
|
2010-04-25 00:31:27 +00:00
|
|
|
if (fwregs == NULL)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
FWLog.Message("Error allocating Memory");
|
2009-05-02 00:56:56 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(void) FWshutdown()
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
// Freeing the registers.
|
2009-05-02 00:56:56 +00:00
|
|
|
free(fwregs);
|
2010-05-28 16:54:42 +00:00
|
|
|
fwregs = NULL;
|
|
|
|
|
2010-01-09 05:11:18 +00:00
|
|
|
FWLog.Close();
|
2009-05-02 00:56:56 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(s32) FWopen(void *pDsp)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
FWLog.WriteLn("Opening FWnull.");
|
2009-05-02 00:56:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(void) FWclose()
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
// Close the plugin.
|
|
|
|
FWLog.WriteLn("Closing FWnull.");
|
2009-05-02 00:56:56 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(u32) FWread32(u32 addr)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
|
|
|
u32 ret = 0;
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
switch (addr)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
// We should document what this location is.
|
2009-05-02 00:56:56 +00:00
|
|
|
case 0x1f808410:
|
|
|
|
ret = 0x8;
|
|
|
|
break;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-01-09 05:11:18 +00:00
|
|
|
// Include other relevant 32 bit addresses we need to catch here.
|
2009-05-02 00:56:56 +00:00
|
|
|
default:
|
2010-01-09 05:11:18 +00:00
|
|
|
// By default, read fwregs.
|
2009-05-02 00:56:56 +00:00
|
|
|
ret = fwRu32(addr);
|
|
|
|
break;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-01-09 05:11:18 +00:00
|
|
|
FWLog.WriteLn("FW read mem 0x%x: 0x%x", addr, ret);
|
2009-05-02 00:56:56 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
switch (addr)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
// Include other memory locations we want to catch here.
|
|
|
|
// For example:
|
|
|
|
//
|
|
|
|
// case 0x1f808400:
|
|
|
|
// case 0x1f808414:
|
|
|
|
// case 0x1f808420:
|
|
|
|
// case 0x1f808428:
|
|
|
|
// case 0x1f808430:
|
2010-04-25 00:31:27 +00:00
|
|
|
//
|
2010-01-09 05:11:18 +00:00
|
|
|
// Are addresses to look at.
|
|
|
|
case 0x1f808410: fwRu32(addr) = value; break;
|
2009-05-02 00:56:56 +00:00
|
|
|
default:
|
2010-01-09 05:11:18 +00:00
|
|
|
// By default, just write it to fwregs.
|
2009-05-02 00:56:56 +00:00
|
|
|
fwRu32(addr) = value;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-09 05:11:18 +00:00
|
|
|
FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value);
|
2009-05-02 00:56:56 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(void) FWirqCallback(void (*callback)())
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
// Register FWirq, so we can trigger an interrupt with it later.
|
2009-05-02 00:56:56 +00:00
|
|
|
FWirq = callback;
|
|
|
|
}
|
|
|
|
|
2009-12-20 13:45:26 +00:00
|
|
|
EXPORT_C_(void) FWsetSettingsDir(const char* dir)
|
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
// Find out from pcsx2 where we are supposed to put our ini file.
|
|
|
|
s_strIniPath = (dir == NULL) ? "inis/" : dir;
|
2009-12-20 13:45:26 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(s32) FWfreeze(int mode, freezeData *data)
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
// This should store or retrieve any information, for if emulation
|
2010-01-09 05:11:18 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2009-05-02 00:56:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
EXPORT_C_(s32) FWtest()
|
2009-05-02 00:56:56 +00:00
|
|
|
{
|
2010-01-09 05:11:18 +00:00
|
|
|
// 0 if the plugin works, non-0 if it doesn't.
|
2009-05-02 00:56:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|