DEV9: initial merge complete

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2020-10-03 17:31:30 +02:00 committed by refractionpcsx2
parent b3ae282522
commit a2e2ed1ecf
15 changed files with 56 additions and 105 deletions

View File

@ -29,7 +29,6 @@ include(BuildParameters)
# SearchForStuff be done before SelectPcsx2Plugins # SearchForStuff be done before SelectPcsx2Plugins
include(SearchForStuff) include(SearchForStuff)
include(SelectPcsx2Plugins) include(SelectPcsx2Plugins)
include(macros/GlibCompileResourcesSupport)
# Must be done after SearchForStuff # Must be done after SearchForStuff
get_git_version_info() get_git_version_info()

View File

@ -1,3 +1,6 @@
include(macros/GlibCompileResourcesSupport)
if (openSUSE) if (openSUSE)
# openSUSE don't install wx in a standard library system # openSUSE don't install wx in a standard library system
# path. Let's bypass the dynamic linker and hardcode the path. # path. Let's bypass the dynamic linker and hardcode the path.
@ -310,7 +313,7 @@ set(pcsx2DEV9Sources
DEV9/Linux/Config.cpp DEV9/Linux/Config.cpp
DEV9/Linux/Linux.cpp DEV9/Linux/Linux.cpp
DEV9/Linux/net.cpp DEV9/Linux/net.cpp
${pcsx2DEV9UISources} #${pcsx2DEV9UISources}
) )
# DEV9 headers # DEV9 headers
@ -320,7 +323,7 @@ set(pcsx2DEV9Headers
DEV9/net.h DEV9/net.h
DEV9/pcap_io.h DEV9/pcap_io.h
DEV9/smap.h DEV9/smap.h
${pcsx2DEV9UIHeaders} #${pcsx2DEV9UIHeaders}
) )

View File

@ -82,17 +82,6 @@ u8 eeprom[] = {
u32 *iopPC; u32 *iopPC;
const unsigned char version = PS2E_DEV9_VERSION;
const unsigned char revision = 0;
const unsigned char build = 4; // increase that with each version
static const char *libraryName = "GiGaHeRz's DEV9 Driver"
#ifdef _DEBUG
"(debug)"
#endif
;
#ifdef _WIN32 #ifdef _WIN32
HANDLE hEeprom; HANDLE hEeprom;
HANDLE mapping; HANDLE mapping;
@ -101,22 +90,6 @@ int hEeprom;
int mapping; int mapping;
#endif #endif
EXPORT_C_(u32)
PS2EgetLibType() {
return PS2E_LT_DEV9;
}
EXPORT_C_(const char*)
PS2EgetLibName() {
return libraryName;
}
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type) {
return (version<<16) | (revision<<8) | build;
}
std::string s_strIniPath = "inis"; std::string s_strIniPath = "inis";
std::string s_strLogPath = "logs"; std::string s_strLogPath = "logs";
// Warning: The below log function is SLOW. Better fix it before attempting to use it. // Warning: The below log function is SLOW. Better fix it before attempting to use it.
@ -157,8 +130,7 @@ void LogInit()
DEV9Log.Open(LogFile); DEV9Log.Open(LogFile);
} }
EXPORT_C_(s32) s32 DEV9init()
DEV9init()
{ {
#ifdef DEV9_LOG_ENABLE #ifdef DEV9_LOG_ENABLE
@ -242,16 +214,14 @@ DEV9init()
return 0; return 0;
} }
EXPORT_C_(void) void DEV9shutdown() {
DEV9shutdown() {
DEV9_LOG("DEV9shutdown\n"); DEV9_LOG("DEV9shutdown\n");
#ifdef DEV9_LOG_ENABLE #ifdef DEV9_LOG_ENABLE
DEV9Log.Close(); DEV9Log.Close();
#endif #endif
} }
EXPORT_C_(s32) s32 DEV9open(void *pDsp)
DEV9open(void *pDsp)
{ {
DEV9_LOG("DEV9open\n"); DEV9_LOG("DEV9open\n");
LoadConf(); LoadConf();
@ -266,8 +236,7 @@ DEV9open(void *pDsp)
return _DEV9open(); return _DEV9open();
} }
EXPORT_C_(void) void DEV9close()
DEV9close()
{ {
DEV9_LOG("DEV9close\n"); DEV9_LOG("DEV9close\n");
#ifdef ENABLE_ATA #ifdef ENABLE_ATA
@ -276,8 +245,7 @@ DEV9close()
_DEV9close(); _DEV9close();
} }
EXPORT_C_(int) int DEV9irqHandler(void)
_DEV9irqHandler(void)
{ {
//dev9Ru16(SPD_R_INTR_STAT)|= dev9.irqcause; //dev9Ru16(SPD_R_INTR_STAT)|= dev9.irqcause;
DEV9_LOG("_DEV9irqHandler %x, %x\n", dev9.irqcause, dev9Ru16(SPD_R_INTR_MASK)); DEV9_LOG("_DEV9irqHandler %x, %x\n", dev9.irqcause, dev9Ru16(SPD_R_INTR_MASK));
@ -286,11 +254,6 @@ _DEV9irqHandler(void)
return 0; return 0;
} }
EXPORT_C_(DEV9handler)
DEV9irqHandler(void) {
return (DEV9handler)_DEV9irqHandler;
}
void _DEV9irq(int cause, int cycles) void _DEV9irq(int cause, int cycles)
{ {
DEV9_LOG("_DEV9irq %x, %x\n", cause, dev9Ru16(SPD_R_INTR_MASK)); DEV9_LOG("_DEV9irq %x, %x\n", cause, dev9Ru16(SPD_R_INTR_MASK));
@ -298,14 +261,13 @@ void _DEV9irq(int cause, int cycles)
dev9.irqcause|= cause; dev9.irqcause|= cause;
if(cycles<1) if(cycles<1)
DEV9irq(1); dev9Irq(1);
else else
DEV9irq(cycles); dev9Irq(cycles);
} }
EXPORT_C_(u8) u8 DEV9read8(u32 addr) {
DEV9read8(u32 addr) {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return 0; return 0;
@ -372,8 +334,7 @@ EXPORT_C_(u8)
return hard; return hard;
} }
EXPORT_C_(u16) u16 DEV9read16(u32 addr)
DEV9read16(u32 addr)
{ {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return 0; return 0;
@ -438,8 +399,7 @@ DEV9read16(u32 addr)
return hard; return hard;
} }
EXPORT_C_(u32) u32 DEV9read32(u32 addr)
DEV9read32(u32 addr)
{ {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return 0; return 0;
@ -474,8 +434,7 @@ DEV9read32(u32 addr)
// return hard; // return hard;
} }
EXPORT_C_(void) void DEV9write8(u32 addr, u8 value)
DEV9write8(u32 addr, u8 value)
{ {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return; return;
@ -585,8 +544,7 @@ DEV9write8(u32 addr, u8 value)
DEV9_LOG("*Known 8bit write at address %lx value %x\n", addr, value); DEV9_LOG("*Known 8bit write at address %lx value %x\n", addr, value);
} }
EXPORT_C_(void) void DEV9write16(u32 addr, u16 value)
DEV9write16(u32 addr, u16 value)
{ {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return; return;
@ -610,7 +568,7 @@ DEV9write16(u32 addr, u16 value)
if ((dev9Ru16(SPD_R_INTR_MASK)!=value) && ((dev9Ru16(SPD_R_INTR_MASK)|value) & dev9.irqcause)) if ((dev9Ru16(SPD_R_INTR_MASK)!=value) && ((dev9Ru16(SPD_R_INTR_MASK)|value) & dev9.irqcause))
{ {
DEV9_LOG("SPD_R_INTR_MASK16=0x%X , checking for masked/unmasked interrupts\n",value); DEV9_LOG("SPD_R_INTR_MASK16=0x%X , checking for masked/unmasked interrupts\n",value);
DEV9irq(1); dev9Irq(1);
} }
break; break;
@ -629,8 +587,7 @@ DEV9write16(u32 addr, u16 value)
DEV9_LOG("*Known 16bit write at address %lx value %x\n", addr, value); DEV9_LOG("*Known 16bit write at address %lx value %x\n", addr, value);
} }
EXPORT_C_(void) void DEV9write32(u32 addr, u32 value)
DEV9write32(u32 addr, u32 value)
{ {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return; return;
@ -667,8 +624,7 @@ DEV9write32(u32 addr, u32 value)
DEV9_LOG("*Known 32bit write at address %lx value %lx\n", addr, value); DEV9_LOG("*Known 32bit write at address %lx value %lx\n", addr, value);
} }
EXPORT_C_(void) void DEV9readDMA8Mem(u32 *pMem, int size)
DEV9readDMA8Mem(u32 *pMem, int size)
{ {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return; return;
@ -682,8 +638,7 @@ DEV9readDMA8Mem(u32 *pMem, int size)
#endif #endif
} }
EXPORT_C_(void) void DEV9writeDMA8Mem(u32* pMem, int size)
DEV9writeDMA8Mem(u32* pMem, int size)
{ {
if (!config.ethEnable & !config.hddEnable) if (!config.ethEnable & !config.hddEnable)
return; return;
@ -698,35 +653,21 @@ DEV9writeDMA8Mem(u32* pMem, int size)
} }
//plugin interface void DEV9async(u32 cycles)
EXPORT_C_(void)
DEV9irqCallback(void (*callback)(int cycles)) {
DEV9irq = callback;
}
EXPORT_C_(void)
DEV9async(u32 cycles)
{ {
smap_async(cycles); smap_async(cycles);
} }
// extended funcs // extended funcs
EXPORT_C_(s32) void DEV9setSettingsDir(const char* dir)
DEV9test() {
return 0;
}
EXPORT_C_(void)
DEV9setSettingsDir(const char* dir)
{ {
// Grab the ini directory. // Grab the ini directory.
// TODO: Use // TODO: Use
s_strIniPath = (dir == NULL) ? "inis" : dir; s_strIniPath = (dir == NULL) ? "inis" : dir;
} }
EXPORT_C_(void) void DEV9setLogDir(const char* dir)
DEV9setLogDir(const char* dir)
{ {
// Get the path to the log directory. // Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir; s_strLogPath = (dir == NULL) ? "logs" : dir;

View File

@ -122,7 +122,6 @@ EXTERN int ThreadRun;
s32 _DEV9open(); s32 _DEV9open();
void _DEV9close(); void _DEV9close();
EXTERN DEV9callback DEV9irq;
//void DEV9thread(); //void DEV9thread();
EXTERN PluginLog DEV9Log; EXTERN PluginLog DEV9Log;
@ -636,13 +635,22 @@ static flash_info_t devices[] = {
#define FLASH_REGSIZE 0x20 #define FLASH_REGSIZE 0x20
EXPORT_C_(void) extern void dev9Irq(int cycles);
FLASHinit();
EXPORT_C_(u32) void FLASHinit();
FLASHread32(u32 addr, int size); u32 FLASHread32(u32 addr, int size);
EXPORT_C_(void) void FLASHwrite32(u32 addr, u32 value, int size);
FLASHwrite32(u32 addr, u32 value, int size);
void _DEV9irq(int cause, int cycles); void _DEV9irq(int cause, int cycles);
int DEV9irqHandler(void);
void DEV9async(u32 cycles);
void DEV9writeDMA8Mem(u32* pMem, int size);
void DEV9readDMA8Mem(u32 *pMem, int size);
u8 DEV9read8(u32 addr);
u16 DEV9read16(u32 addr);
u32 DEV9read32(u32 addr);
void DEV9write8(u32 addr, u8 value);
void DEV9write16(u32 addr, u16 value);
void DEV9write32(u32 addr, u32 value);
int emu_printf(const char *fmt, ...); int emu_printf(const char *fmt, ...);

View File

@ -22,11 +22,11 @@
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include "Config.h" #include "../Config.h"
#include "../DEV9.h" #include "../DEV9.h"
#include "pcap.h" #include "pcap.h"
#include "pcap_io.h" #include "../pcap_io.h"
#include "net.h" #include "../net.h"
static GtkBuilder * builder; static GtkBuilder * builder;

View File

@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "net.h" #include "../net.h"
#include "../DEV9.h" #include "../DEV9.h"
#include <pthread.h> #include <pthread.h>

View File

@ -57,8 +57,7 @@ static const char* getCmdName(u32 cmd){
} }
} }
EXPORT_C_(void) void FLASHinit(){
FLASHinit(){
FILE *fd; FILE *fd;
id= FLASH_ID_64MBIT; id= FLASH_ID_64MBIT;
@ -82,8 +81,7 @@ FLASHinit(){
memset(file, 0xFF, CARD_SIZE_ECC); memset(file, 0xFF, CARD_SIZE_ECC);
} }
EXPORT_C_(u32) u32 FLASHread32(u32 addr, int size) {
FLASHread32(u32 addr, int size) {
u32 value, refill= 0; u32 value, refill= 0;
switch(addr) { switch(addr) {
@ -148,8 +146,7 @@ EXPORT_C_(u32)
} }
} }
EXPORT_C_(void) void FLASHwrite32(u32 addr, u32 value, int size) {
FLASHwrite32(u32 addr, u32 value, int size) {
switch(addr & 0x1FFFFFFF) { switch(addr & 0x1FFFFFFF) {
case FLASH_R_DATA: case FLASH_R_DATA:

View File

@ -21,6 +21,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "IopCommon.h" #include "IopCommon.h"
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "DEV9/DEV9.h"
#include <math.h> #include <math.h>
@ -514,10 +515,7 @@ void psxRcntUpdate()
else else
c -= difference; c -= difference;
psxNextCounter = c; psxNextCounter = c;
if (DEV9async)
{
DEV9async(1); DEV9async(1);
}
if(USBasync) if(USBasync)
{ {
const s32 difference = psxRegs.cycle - psxCounters[7].sCycleT; const s32 difference = psxRegs.cycle - psxCounters[7].sCycleT;

View File

@ -18,6 +18,7 @@
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "Sif.h" #include "Sif.h"
#include "DEV9/DEV9.h"
using namespace R3000A; using namespace R3000A;

View File

@ -42,5 +42,4 @@ extern void spu2DMA7Irq();
extern void iopIntcIrq( uint irqType ); extern void iopIntcIrq( uint irqType );
extern void iopTestIntc(); extern void iopTestIntc();
extern DEV9handler dev9Handler;
extern USBhandler usbHandler; extern USBhandler usbHandler;

View File

@ -15,12 +15,13 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "IopCommon.h" #include "IopCommon.h"
#include "DEV9/DEV9.h"
using namespace R3000A; using namespace R3000A;
void dev9Interrupt() void dev9Interrupt()
{ {
if ((dev9Handler != NULL) && (dev9Handler() != 1)) return; if (DEV9irqHandler() != 1) return;
iopIntcIrq(13); iopIntcIrq(13);
} }

View File

@ -18,6 +18,7 @@
#include "IopCommon.h" #include "IopCommon.h"
#include "ps2/pgif.h" // for PSX kernel TTY in iopMemWrite32 #include "ps2/pgif.h" // for PSX kernel TTY in iopMemWrite32
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "DEV9/DEV9.h"
uptr *psxMemWLUT = NULL; uptr *psxMemWLUT = NULL;
const uptr *psxMemRLUT = NULL; const uptr *psxMemRLUT = NULL;

View File

@ -41,6 +41,7 @@ BIOS
#include "GS.h" #include "GS.h"
#include "VUmicro.h" #include "VUmicro.h"
#include "MTVU.h" #include "MTVU.h"
#include "DEV9/DEV9.h"
#include "ps2/HwInternal.h" #include "ps2/HwInternal.h"
#include "ps2/BiosTools.h" #include "ps2/BiosTools.h"

View File

@ -21,6 +21,7 @@
#include "CDVD/CdRom.h" #include "CDVD/CdRom.h"
#include "FW.h" #include "FW.h"
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "DEV9/DEV9.h"
#include "ps2/pgif.h" #include "ps2/pgif.h"
#include "Mdec.h" #include "Mdec.h"

View File

@ -20,6 +20,7 @@
#include "FW.h" #include "FW.h"
#include "CDVD/CdRom.h" #include "CDVD/CdRom.h"
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "DEV9/DEV9.h"
#include "ps2/pgif.h" #include "ps2/pgif.h"
#include "Mdec.h" #include "Mdec.h"