2009-05-02 04:39:05 +00:00
|
|
|
/* DEV9null
|
2009-09-08 16:39:37 +00:00
|
|
|
* Copyright (C) 2002-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/>.
|
|
|
|
*/
|
2009-05-02 04:39:05 +00:00
|
|
|
|
2009-05-15 07:02:51 +00:00
|
|
|
#include <stdlib.h>
|
2009-05-02 04:39:05 +00:00
|
|
|
#include <string.h>
|
2009-05-15 07:02:51 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
|
2009-05-02 04:39:05 +00:00
|
|
|
#include "DEV9.h"
|
|
|
|
|
|
|
|
const unsigned char version = PS2E_DEV9_VERSION;
|
|
|
|
const unsigned char revision = 0;
|
|
|
|
const unsigned char build = 4; // increase that with each version
|
|
|
|
|
|
|
|
const char *libraryName = "DEV9null Driver";
|
|
|
|
|
2009-05-15 07:02:51 +00:00
|
|
|
void (*DEV9irq)(int);
|
2009-05-02 04:39:05 +00:00
|
|
|
FILE *dev9Log;
|
2009-05-15 07:02:51 +00:00
|
|
|
Config conf;
|
2009-12-20 13:45:26 +00:00
|
|
|
string s_strIniPath="inis/";
|
2009-05-02 04:39:05 +00:00
|
|
|
|
|
|
|
EXPORT_C_(u32) PS2EgetLibType()
|
|
|
|
{
|
|
|
|
return PS2E_LT_DEV9;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(char*) PS2EgetLibName()
|
|
|
|
{
|
|
|
|
return (char *)libraryName;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
|
|
|
|
{
|
|
|
|
return (version<<16) | (revision<<8) | build;
|
|
|
|
}
|
|
|
|
|
2009-05-15 07:02:51 +00:00
|
|
|
void __Log(char *fmt, ...)
|
2009-05-02 04:39:05 +00:00
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
|
2009-05-15 07:02:51 +00:00
|
|
|
if (!conf.Log || dev9Log == NULL) return;
|
|
|
|
|
2009-05-02 04:39:05 +00:00
|
|
|
va_start(list, fmt);
|
|
|
|
vfprintf(dev9Log, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(s32) DEV9init()
|
|
|
|
{
|
2009-05-16 00:43:46 +00:00
|
|
|
#ifdef __LINUX__ // for until we get a win32 version sorted out / implemented...
|
2009-05-15 07:02:51 +00:00
|
|
|
LoadConfig();
|
2009-05-16 00:43:46 +00:00
|
|
|
#endif
|
2009-05-15 07:02:51 +00:00
|
|
|
|
|
|
|
#ifdef DEV9_LOG
|
|
|
|
dev9Log = fopen("logs/dev9Log.txt", "w");
|
|
|
|
if (dev9Log) setvbuf(dev9Log, NULL, _IONBF, 0);
|
|
|
|
DEV9_LOG("dev9null plugin version %d,%d\n", revision, build);
|
|
|
|
DEV9_LOG("DEV9init\n");
|
|
|
|
#endif
|
|
|
|
|
2009-05-02 04:39:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9shutdown()
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
#ifdef DEV9_LOG
|
|
|
|
if (dev9Log) fclose(dev9Log);
|
|
|
|
#endif
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(s32) DEV9open(void *pDsp)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9close()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(u8) DEV9read8(u32 addr)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("*Unknown 8bit read at address %lx ", addr);
|
2009-05-02 04:39:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(u16 ) DEV9read16(u32 addr)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("*Unknown 16bit read at address %lx ", addr);
|
2009-05-02 04:39:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(u32 ) DEV9read32(u32 addr)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("*Unknown 32bit read at address %lx ", addr);
|
2009-05-02 04:39:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9write8(u32 addr, u8 value)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("*Unknown 8bit write at address %lx value %x\n", addr, value);
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9write16(u32 addr, u16 value)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("*Unknown 16bit write at address %lx value %x\n", addr, value);
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9write32(u32 addr, u32 value)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("*Unknown 32bit write at address %lx value %x\n", addr, value);
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("Reading DMA8 Mem.");
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9writeDMA8Mem(u32* pMem, int size)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9_LOG("Writing DMA8 Mem.");
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9irqCallback(DEV9callback callback)
|
|
|
|
{
|
2009-05-15 07:02:51 +00:00
|
|
|
DEV9irq = callback;
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(DEV9handler) DEV9irqHandler(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-12-20 13:45:26 +00:00
|
|
|
EXPORT_C_(void) DEV9setSettingsDir(const char* dir)
|
|
|
|
{
|
|
|
|
s_strIniPath = (dir==NULL) ? "inis/" : dir;
|
|
|
|
}
|
|
|
|
|
2009-05-02 04:39:05 +00:00
|
|
|
// extended funcs
|
|
|
|
|
|
|
|
EXPORT_C_(s32) DEV9test()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-15 07:02:51 +00:00
|
|
|
#ifdef _WIN32
|
2009-05-02 04:39:05 +00:00
|
|
|
EXPORT_C_(void) DEV9configure()
|
|
|
|
{
|
2009-11-16 13:54:32 +00:00
|
|
|
SysMessage("Nothing to Configure?!");
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_C_(void) DEV9about()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HINSTANCE hInst;
|
|
|
|
|
2009-05-02 05:27:35 +00:00
|
|
|
void SysMessage(const char *fmt, ...)
|
2009-05-02 04:39:05 +00:00
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
char tmp[512];
|
|
|
|
va_start(list,fmt);
|
|
|
|
vsprintf(tmp,fmt,list);
|
|
|
|
va_end(list);
|
2009-11-16 13:54:32 +00:00
|
|
|
MessageBox( GetActiveWindow(), tmp, "DEV9null Msg", MB_SETFOREGROUND | MB_OK );
|
2009-05-02 04:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
|
|
|
DWORD dwReason,
|
|
|
|
LPVOID lpReserved) {
|
|
|
|
hInst = (HINSTANCE)hModule;
|
|
|
|
return TRUE; // very quick :)
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|