mirror of https://github.com/PCSX2/pcsx2.git
DEV9: updated license headers and clang-format
This commit is contained in:
parent
ca8bf22423
commit
2c1bbd5efb
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -13,7 +13,6 @@
|
|||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#define WINVER 0x0600
|
||||
#define _WIN32_WINNT 0x0600
|
||||
|
||||
|
@ -33,17 +32,17 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#define EXTERN
|
||||
#define EXTERN
|
||||
#include "DEV9.h"
|
||||
#undef EXTERN
|
||||
#undef EXTERN
|
||||
#include "Config.h"
|
||||
#include "smap.h"
|
||||
#include "ata.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4244)
|
||||
#pragma warning(disable : 4244)
|
||||
|
||||
HINSTANCE hInst=NULL;
|
||||
HINSTANCE hInst = NULL;
|
||||
#endif
|
||||
|
||||
//#define HDD_48BIT
|
||||
|
@ -53,7 +52,8 @@ HINSTANCE hInst=NULL;
|
|||
static __inline__ unsigned long long GetTickCount(void)
|
||||
{
|
||||
unsigned long long int x;
|
||||
__asm__ volatile ("rdtsc" : "=A" (x));
|
||||
__asm__ volatile("rdtsc"
|
||||
: "=A"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -62,25 +62,82 @@ static __inline__ unsigned long long GetTickCount(void)
|
|||
static __inline__ unsigned long long GetTickCount(void)
|
||||
{
|
||||
unsigned hi, lo;
|
||||
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||
return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
|
||||
__asm__ __volatile__("rdtsc"
|
||||
: "=a"(lo), "=d"(hi));
|
||||
return ((unsigned long long)lo) | (((unsigned long long)hi) << 32);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
u8 eeprom[] = {
|
||||
//0x6D, 0x76, 0x63, 0x61, 0x31, 0x30, 0x08, 0x01,
|
||||
0x76, 0x6D, 0x61, 0x63, 0x30, 0x31, 0x07, 0x02,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x76,
|
||||
0x6D,
|
||||
0x61,
|
||||
0x63,
|
||||
0x30,
|
||||
0x31,
|
||||
0x07,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x10,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x10,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x10,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
u32 *iopPC;
|
||||
u32* iopPC;
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE hEeprom;
|
||||
|
@ -99,24 +156,27 @@ int Log = 1;
|
|||
int Log = 0;
|
||||
#endif
|
||||
|
||||
void __Log(char *fmt, ...) {
|
||||
if (!Log) return;
|
||||
void __Log(char* fmt, ...)
|
||||
{
|
||||
if (!Log)
|
||||
return;
|
||||
va_list list;
|
||||
|
||||
static int ticks=-1;
|
||||
int nticks=GetTickCount();
|
||||
static int ticks = -1;
|
||||
int nticks = GetTickCount();
|
||||
|
||||
if(ticks==-1) ticks=nticks;
|
||||
if (ticks == -1)
|
||||
ticks = nticks;
|
||||
|
||||
if(iopPC!=NULL)
|
||||
if (iopPC != NULL)
|
||||
{
|
||||
DEV9Log.Write("[%10d + %4d, IOP PC = %08x] ", nticks, nticks - ticks, *iopPC);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEV9Log.Write( "[%10d + %4d] ", nticks, nticks - ticks);
|
||||
DEV9Log.Write("[%10d + %4d] ", nticks, nticks - ticks);
|
||||
}
|
||||
ticks=nticks;
|
||||
ticks = nticks;
|
||||
|
||||
va_start(list, fmt);
|
||||
DEV9Log.Write(fmt, list);
|
||||
|
@ -146,63 +206,62 @@ s32 DEV9init()
|
|||
|
||||
#ifdef _WIN32
|
||||
hEeprom = CreateFile(
|
||||
"eeprom.dat",
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_WRITE_THROUGH,
|
||||
NULL
|
||||
);
|
||||
"eeprom.dat",
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_WRITE_THROUGH,
|
||||
NULL);
|
||||
|
||||
if(hEeprom==INVALID_HANDLE_VALUE)
|
||||
if (hEeprom == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
dev9.eeprom=(u16*)eeprom;
|
||||
dev9.eeprom = (u16*)eeprom;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapping=CreateFileMapping(hEeprom,NULL,PAGE_READWRITE,0,0,NULL);
|
||||
if(mapping==INVALID_HANDLE_VALUE)
|
||||
mapping = CreateFileMapping(hEeprom, NULL, PAGE_READWRITE, 0, 0, NULL);
|
||||
if (mapping == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hEeprom);
|
||||
dev9.eeprom=(u16*)eeprom;
|
||||
dev9.eeprom = (u16*)eeprom;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev9.eeprom = (u16*)MapViewOfFile(mapping,FILE_MAP_WRITE,0,0,0);
|
||||
dev9.eeprom = (u16*)MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
|
||||
|
||||
if(dev9.eeprom==NULL)
|
||||
if (dev9.eeprom == NULL)
|
||||
{
|
||||
CloseHandle(mapping);
|
||||
CloseHandle(hEeprom);
|
||||
dev9.eeprom=(u16*)eeprom;
|
||||
dev9.eeprom = (u16*)eeprom;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
hEeprom = open("eeprom.dat", O_RDWR, 0);
|
||||
|
||||
if(-1 == hEeprom)
|
||||
if (-1 == hEeprom)
|
||||
{
|
||||
dev9.eeprom=(u16*)eeprom;
|
||||
dev9.eeprom = (u16*)eeprom;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev9.eeprom = (u16*)mmap(NULL, 64, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, hEeprom, 0);
|
||||
dev9.eeprom = (u16*)mmap(NULL, 64, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, hEeprom, 0);
|
||||
|
||||
if(dev9.eeprom==NULL)
|
||||
{
|
||||
close(hEeprom);
|
||||
dev9.eeprom=(u16*)eeprom;
|
||||
}
|
||||
if (dev9.eeprom == NULL)
|
||||
{
|
||||
close(hEeprom);
|
||||
dev9.eeprom = (u16*)eeprom;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int rxbi;
|
||||
|
||||
for(rxbi=0;rxbi<(SMAP_BD_SIZE/8);rxbi++)
|
||||
for (rxbi = 0; rxbi < (SMAP_BD_SIZE / 8); rxbi++)
|
||||
{
|
||||
smap_bd_t *pbd = (smap_bd_t *)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff];
|
||||
smap_bd_t* pbd = (smap_bd_t*)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff];
|
||||
pbd = &pbd[rxbi];
|
||||
|
||||
pbd->ctrl_stat = SMAP_BD_RX_EMPTY;
|
||||
|
@ -214,22 +273,23 @@ s32 DEV9init()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void DEV9shutdown() {
|
||||
void DEV9shutdown()
|
||||
{
|
||||
DEV9_LOG("DEV9shutdown\n");
|
||||
#ifdef DEV9_LOG_ENABLE
|
||||
DEV9Log.Close();
|
||||
#endif
|
||||
}
|
||||
|
||||
s32 DEV9open(void *pDsp)
|
||||
s32 DEV9open(void* pDsp)
|
||||
{
|
||||
DEV9_LOG("DEV9open\n");
|
||||
LoadConf();
|
||||
DEV9_LOG("open r+: %s\n", config.Hdd);
|
||||
config.HddSize = 8*1024;
|
||||
|
||||
config.HddSize = 8 * 1024;
|
||||
|
||||
iopPC = (u32*)pDsp;
|
||||
|
||||
|
||||
#ifdef ENABLE_ATA
|
||||
ata_init();
|
||||
#endif
|
||||
|
@ -249,7 +309,7 @@ int DEV9irqHandler(void)
|
|||
{
|
||||
//dev9Ru16(SPD_R_INTR_STAT)|= dev9.irqcause;
|
||||
DEV9_LOG("_DEV9irqHandler %x, %x\n", dev9.irqcause, dev9Ru16(SPD_R_INTR_MASK));
|
||||
if (dev9.irqcause & dev9Ru16(SPD_R_INTR_MASK))
|
||||
if (dev9.irqcause & dev9Ru16(SPD_R_INTR_MASK))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -258,21 +318,22 @@ void _DEV9irq(int cause, int cycles)
|
|||
{
|
||||
DEV9_LOG("_DEV9irq %x, %x\n", cause, dev9Ru16(SPD_R_INTR_MASK));
|
||||
|
||||
dev9.irqcause|= cause;
|
||||
dev9.irqcause |= cause;
|
||||
|
||||
if(cycles<1)
|
||||
if (cycles < 1)
|
||||
dev9Irq(1);
|
||||
else
|
||||
dev9Irq(cycles);
|
||||
}
|
||||
|
||||
|
||||
u8 DEV9read8(u32 addr) {
|
||||
u8 DEV9read8(u32 addr)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return 0;
|
||||
|
||||
u8 hard;
|
||||
if (addr>=ATA_DEV9_HDD_BASE && addr<ATA_DEV9_HDD_END)
|
||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||
{
|
||||
#ifdef ENABLE_ATA
|
||||
return ata_read<1>(addr);
|
||||
|
@ -280,13 +341,13 @@ u8 DEV9read8(u32 addr) {
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
if (addr>=SMAP_REGBASE && addr<FLASH_REGBASE)
|
||||
if (addr >= SMAP_REGBASE && addr < FLASH_REGBASE)
|
||||
{
|
||||
//smap
|
||||
return smap_read8(addr);
|
||||
}
|
||||
|
||||
switch (addr)
|
||||
|
||||
switch (addr)
|
||||
{
|
||||
case SPD_R_PIO_DATA:
|
||||
|
||||
|
@ -296,24 +357,26 @@ u8 DEV9read8(u32 addr) {
|
|||
break;
|
||||
}*/
|
||||
|
||||
if(dev9.eeprom_state==EEPROM_TDATA)
|
||||
if (dev9.eeprom_state == EEPROM_TDATA)
|
||||
{
|
||||
if(dev9.eeprom_command==2) //read
|
||||
if (dev9.eeprom_command == 2) //read
|
||||
{
|
||||
if(dev9.eeprom_bit==0xFF)
|
||||
hard=0;
|
||||
if (dev9.eeprom_bit == 0xFF)
|
||||
hard = 0;
|
||||
else
|
||||
hard=((dev9.eeprom[dev9.eeprom_address]<<dev9.eeprom_bit)&0x8000)>>11;
|
||||
hard = ((dev9.eeprom[dev9.eeprom_address] << dev9.eeprom_bit) & 0x8000) >> 11;
|
||||
dev9.eeprom_bit++;
|
||||
if(dev9.eeprom_bit==16)
|
||||
if (dev9.eeprom_bit == 16)
|
||||
{
|
||||
dev9.eeprom_address++;
|
||||
dev9.eeprom_bit=0;
|
||||
dev9.eeprom_bit = 0;
|
||||
}
|
||||
}
|
||||
else hard=0;
|
||||
else
|
||||
hard = 0;
|
||||
}
|
||||
else hard=0;
|
||||
else
|
||||
hard = 0;
|
||||
return hard;
|
||||
|
||||
case DEV9_R_REV:
|
||||
|
@ -321,15 +384,16 @@ u8 DEV9read8(u32 addr) {
|
|||
break;
|
||||
|
||||
default:
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE))) {
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE)))
|
||||
{
|
||||
return (u8)FLASHread32(addr, 1);
|
||||
}
|
||||
|
||||
hard = dev9Ru8(addr);
|
||||
hard = dev9Ru8(addr);
|
||||
DEV9_LOG("*Unknown 8bit read at address %lx value %x\n", addr, hard);
|
||||
return hard;
|
||||
}
|
||||
|
||||
|
||||
DEV9_LOG("*Known 8bit read at address %lx value %x\n", addr, hard);
|
||||
return hard;
|
||||
}
|
||||
|
@ -340,7 +404,7 @@ u16 DEV9read16(u32 addr)
|
|||
return 0;
|
||||
|
||||
u16 hard;
|
||||
if (addr>=ATA_DEV9_HDD_BASE && addr<ATA_DEV9_HDD_END)
|
||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||
{
|
||||
#ifdef ENABLE_ATA
|
||||
return ata_read<2>(addr);
|
||||
|
@ -348,13 +412,13 @@ u16 DEV9read16(u32 addr)
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
if (addr>=SMAP_REGBASE && addr<FLASH_REGBASE)
|
||||
if (addr >= SMAP_REGBASE && addr < FLASH_REGBASE)
|
||||
{
|
||||
//smap
|
||||
return smap_read16(addr);
|
||||
}
|
||||
|
||||
switch (addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SPD_R_INTR_STAT:
|
||||
return dev9.irqcause;
|
||||
|
@ -376,25 +440,27 @@ u16 DEV9read16(u32 addr)
|
|||
/*if (config.hddEnable) {
|
||||
hard|= 0x2;
|
||||
}*/
|
||||
if (config.ethEnable) {
|
||||
hard|= 0x1;
|
||||
if (config.ethEnable)
|
||||
{
|
||||
hard |= 0x1;
|
||||
}
|
||||
hard|= 0x20;//flash
|
||||
hard |= 0x20; //flash
|
||||
break;
|
||||
|
||||
case SPD_R_0e:
|
||||
hard = 0x0002;
|
||||
break;
|
||||
default:
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE))) {
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE)))
|
||||
{
|
||||
return (u16)FLASHread32(addr, 2);
|
||||
}
|
||||
|
||||
hard = dev9Ru16(addr);
|
||||
hard = dev9Ru16(addr);
|
||||
DEV9_LOG("*Unknown 16bit read at address %lx value %x\n", addr, hard);
|
||||
return hard;
|
||||
}
|
||||
|
||||
|
||||
DEV9_LOG("*Known 16bit read at address %lx value %x\n", addr, hard);
|
||||
return hard;
|
||||
}
|
||||
|
@ -405,7 +471,7 @@ u32 DEV9read32(u32 addr)
|
|||
return 0;
|
||||
|
||||
u32 hard;
|
||||
if (addr>=ATA_DEV9_HDD_BASE && addr<ATA_DEV9_HDD_END)
|
||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||
{
|
||||
#ifdef ENABLE_ATA
|
||||
return ata_read<4>(addr);
|
||||
|
@ -413,52 +479,54 @@ u32 DEV9read32(u32 addr)
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
if (addr>=SMAP_REGBASE && addr<FLASH_REGBASE)
|
||||
if (addr >= SMAP_REGBASE && addr < FLASH_REGBASE)
|
||||
{
|
||||
//smap
|
||||
return smap_read32(addr);
|
||||
}
|
||||
// switch (addr) {
|
||||
// switch (addr) {
|
||||
|
||||
// default:
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE))) {
|
||||
return (u32)FLASHread32(addr, 4);
|
||||
}
|
||||
// default:
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE)))
|
||||
{
|
||||
return (u32)FLASHread32(addr, 4);
|
||||
}
|
||||
|
||||
hard = dev9Ru32(addr);
|
||||
DEV9_LOG("*Unknown 32bit read at address %lx value %x\n", addr, hard);
|
||||
return hard;
|
||||
// }
|
||||
hard = dev9Ru32(addr);
|
||||
DEV9_LOG("*Unknown 32bit read at address %lx value %x\n", addr, hard);
|
||||
return hard;
|
||||
// }
|
||||
|
||||
// DEV9_LOG("*Known 32bit read at address %lx: %lx\n", addr, hard);
|
||||
// return hard;
|
||||
// DEV9_LOG("*Known 32bit read at address %lx: %lx\n", addr, hard);
|
||||
// return hard;
|
||||
}
|
||||
|
||||
void DEV9write8(u32 addr, u8 value)
|
||||
void DEV9write8(u32 addr, u8 value)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
||||
if (addr>=ATA_DEV9_HDD_BASE && addr<ATA_DEV9_HDD_END)
|
||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||
{
|
||||
#ifdef ENABLE_ATA
|
||||
ata_write<1>(addr,value);
|
||||
ata_write<1>(addr, value);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (addr>=SMAP_REGBASE && addr<FLASH_REGBASE)
|
||||
if (addr >= SMAP_REGBASE && addr < FLASH_REGBASE)
|
||||
{
|
||||
//smap
|
||||
smap_write8(addr,value);
|
||||
smap_write8(addr, value);
|
||||
return;
|
||||
}
|
||||
switch (addr) {
|
||||
switch (addr)
|
||||
{
|
||||
case 0x10000020:
|
||||
dev9.irqcause = 0xff;
|
||||
break;
|
||||
case SPD_R_INTR_STAT:
|
||||
emu_printf("SPD_R_INTR_STAT , WTFH ?\n");
|
||||
dev9.irqcause=value;
|
||||
dev9.irqcause = value;
|
||||
return;
|
||||
case SPD_R_INTR_MASK:
|
||||
emu_printf("SPD_R_INTR_MASK8 , WTFH ?\n");
|
||||
|
@ -467,36 +535,36 @@ void DEV9write8(u32 addr, u8 value)
|
|||
case SPD_R_PIO_DIR:
|
||||
//DEV9_LOG("SPD_R_PIO_DIR 8bit write %x\n", value);
|
||||
|
||||
if((value&0xc0)!=0xc0)
|
||||
if ((value & 0xc0) != 0xc0)
|
||||
return;
|
||||
|
||||
if((value&0x30)==0x20)
|
||||
if ((value & 0x30) == 0x20)
|
||||
{
|
||||
dev9.eeprom_state=0;
|
||||
dev9.eeprom_state = 0;
|
||||
}
|
||||
dev9.eeprom_dir=(value>>4)&3;
|
||||
|
||||
dev9.eeprom_dir = (value >> 4) & 3;
|
||||
|
||||
return;
|
||||
|
||||
case SPD_R_PIO_DATA:
|
||||
//DEV9_LOG("SPD_R_PIO_DATA 8bit write %x\n", value);
|
||||
|
||||
if((value&0xc0)!=0xc0)
|
||||
if ((value & 0xc0) != 0xc0)
|
||||
return;
|
||||
|
||||
switch(dev9.eeprom_state)
|
||||
switch (dev9.eeprom_state)
|
||||
{
|
||||
case EEPROM_READY:
|
||||
dev9.eeprom_command=0;
|
||||
dev9.eeprom_command = 0;
|
||||
dev9.eeprom_state++;
|
||||
break;
|
||||
case EEPROM_OPCD0:
|
||||
dev9.eeprom_command = (value>>4)&2;
|
||||
dev9.eeprom_command = (value >> 4) & 2;
|
||||
dev9.eeprom_state++;
|
||||
dev9.eeprom_bit=0xFF;
|
||||
dev9.eeprom_bit = 0xFF;
|
||||
break;
|
||||
case EEPROM_OPCD1:
|
||||
dev9.eeprom_command |= (value>>5)&1;
|
||||
dev9.eeprom_command |= (value >> 5) & 1;
|
||||
dev9.eeprom_state++;
|
||||
break;
|
||||
case EEPROM_ADDR0:
|
||||
|
@ -506,32 +574,33 @@ void DEV9write8(u32 addr, u8 value)
|
|||
case EEPROM_ADDR4:
|
||||
case EEPROM_ADDR5:
|
||||
dev9.eeprom_address =
|
||||
(dev9.eeprom_address&(63^(1<<(dev9.eeprom_state-EEPROM_ADDR0))))|
|
||||
((value>>(dev9.eeprom_state-EEPROM_ADDR0))&(0x20>>(dev9.eeprom_state-EEPROM_ADDR0)));
|
||||
(dev9.eeprom_address & (63 ^ (1 << (dev9.eeprom_state - EEPROM_ADDR0)))) |
|
||||
((value >> (dev9.eeprom_state - EEPROM_ADDR0)) & (0x20 >> (dev9.eeprom_state - EEPROM_ADDR0)));
|
||||
dev9.eeprom_state++;
|
||||
break;
|
||||
case EEPROM_TDATA:
|
||||
{
|
||||
if (dev9.eeprom_command == 1) //write
|
||||
{
|
||||
if(dev9.eeprom_command==1) //write
|
||||
dev9.eeprom[dev9.eeprom_address] =
|
||||
(dev9.eeprom[dev9.eeprom_address] & (63 ^ (1 << dev9.eeprom_bit))) |
|
||||
((value >> dev9.eeprom_bit) & (0x8000 >> dev9.eeprom_bit));
|
||||
dev9.eeprom_bit++;
|
||||
if (dev9.eeprom_bit == 16)
|
||||
{
|
||||
dev9.eeprom[dev9.eeprom_address] =
|
||||
(dev9.eeprom[dev9.eeprom_address]&(63^(1<<dev9.eeprom_bit)))|
|
||||
((value>>dev9.eeprom_bit)&(0x8000>>dev9.eeprom_bit));
|
||||
dev9.eeprom_bit++;
|
||||
if(dev9.eeprom_bit==16)
|
||||
{
|
||||
dev9.eeprom_address++;
|
||||
dev9.eeprom_bit=0;
|
||||
}
|
||||
dev9.eeprom_address++;
|
||||
dev9.eeprom_bit = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
default:
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE))) {
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE)))
|
||||
{
|
||||
FLASHwrite32(addr, (u32)value, 1);
|
||||
return;
|
||||
}
|
||||
|
@ -549,32 +618,33 @@ void DEV9write16(u32 addr, u16 value)
|
|||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
||||
if (addr>=ATA_DEV9_HDD_BASE && addr<ATA_DEV9_HDD_END)
|
||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||
{
|
||||
#ifdef ENABLE_ATA
|
||||
ata_write<2>(addr,value);
|
||||
ata_write<2>(addr, value);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (addr>=SMAP_REGBASE && addr<FLASH_REGBASE)
|
||||
if (addr >= SMAP_REGBASE && addr < FLASH_REGBASE)
|
||||
{
|
||||
//smap
|
||||
smap_write16(addr,value);
|
||||
smap_write16(addr, value);
|
||||
return;
|
||||
}
|
||||
switch (addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SPD_R_INTR_MASK:
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE))) {
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE)))
|
||||
{
|
||||
FLASHwrite32(addr, (u32)value, 2);
|
||||
return;
|
||||
}
|
||||
|
@ -592,26 +662,27 @@ void DEV9write32(u32 addr, u32 value)
|
|||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
||||
if (addr>=ATA_DEV9_HDD_BASE && addr<ATA_DEV9_HDD_END)
|
||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||
{
|
||||
#ifdef ENABLE_ATA
|
||||
ata_write<4>(addr,value);
|
||||
ata_write<4>(addr, value);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (addr>=SMAP_REGBASE && addr<FLASH_REGBASE)
|
||||
if (addr >= SMAP_REGBASE && addr < FLASH_REGBASE)
|
||||
{
|
||||
//smap
|
||||
smap_write32(addr,value);
|
||||
smap_write32(addr, value);
|
||||
return;
|
||||
}
|
||||
switch (addr)
|
||||
{
|
||||
switch (addr)
|
||||
{
|
||||
case SPD_R_INTR_MASK:
|
||||
emu_printf("SPD_R_INTR_MASK , WTFH ?\n");
|
||||
break;
|
||||
default:
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE))) {
|
||||
if ((addr >= FLASH_REGBASE) && (addr < (FLASH_REGBASE + FLASH_REGSIZE)))
|
||||
{
|
||||
FLASHwrite32(addr, (u32)value, 4);
|
||||
return;
|
||||
}
|
||||
|
@ -624,17 +695,17 @@ void DEV9write32(u32 addr, u32 value)
|
|||
DEV9_LOG("*Known 32bit write at address %lx value %lx\n", addr, value);
|
||||
}
|
||||
|
||||
void DEV9readDMA8Mem(u32 *pMem, int size)
|
||||
void DEV9readDMA8Mem(u32* pMem, int size)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
||||
DEV9_LOG("*DEV9readDMA8Mem: size %x\n", size);
|
||||
emu_printf("rDMA\n");
|
||||
|
||||
smap_readDMA8Mem(pMem,size);
|
||||
|
||||
smap_readDMA8Mem(pMem, size);
|
||||
#ifdef ENABLE_ATA
|
||||
ata_readDMA8Mem(pMem,size);
|
||||
ata_readDMA8Mem(pMem, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -645,10 +716,10 @@ void DEV9writeDMA8Mem(u32* pMem, int size)
|
|||
|
||||
DEV9_LOG("*DEV9writeDMA8Mem: size %x\n", size);
|
||||
emu_printf("wDMA\n");
|
||||
|
||||
smap_writeDMA8Mem(pMem,size);
|
||||
|
||||
smap_writeDMA8Mem(pMem, size);
|
||||
#ifdef ENABLE_ATA
|
||||
ata_writeDMA8Mem(pMem,size);
|
||||
ata_writeDMA8Mem(pMem, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -664,7 +735,7 @@ void DEV9setSettingsDir(const char* dir)
|
|||
{
|
||||
// Grab the ini directory.
|
||||
// TODO: Use
|
||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||
}
|
||||
|
||||
void DEV9setLogDir(const char* dir)
|
||||
|
@ -678,12 +749,12 @@ void DEV9setLogDir(const char* dir)
|
|||
LogInit();
|
||||
}
|
||||
|
||||
int emu_printf(const char *fmt, ...)
|
||||
int emu_printf(const char* fmt, ...)
|
||||
{
|
||||
va_list vl;
|
||||
int ret;
|
||||
va_start(vl,fmt);
|
||||
ret = vfprintf(stderr,fmt,vl);
|
||||
va_start(vl, fmt);
|
||||
ret = vfprintf(stderr, fmt, vl);
|
||||
va_end(vl);
|
||||
fflush(stderr);
|
||||
return ret;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -27,96 +27,106 @@
|
|||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
void SaveConf() {
|
||||
void SaveConf()
|
||||
{
|
||||
|
||||
xmlDocPtr doc = NULL; /* document pointer */
|
||||
xmlNodePtr root_node = NULL;
|
||||
char buff[256];
|
||||
xmlDocPtr doc = NULL; /* document pointer */
|
||||
xmlNodePtr root_node = NULL;
|
||||
char buff[256];
|
||||
|
||||
/*
|
||||
/*
|
||||
* Creates a new document, a node and set it as a root node
|
||||
*/
|
||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
||||
root_node = xmlNewNode(NULL, BAD_CAST "dev9");
|
||||
xmlDocSetRootElement(doc, root_node);
|
||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
||||
root_node = xmlNewNode(NULL, BAD_CAST "dev9");
|
||||
xmlDocSetRootElement(doc, root_node);
|
||||
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "Eth",
|
||||
BAD_CAST config.Eth);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "Eth",
|
||||
BAD_CAST config.Eth);
|
||||
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "Hdd",
|
||||
BAD_CAST config.Hdd);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "Hdd",
|
||||
BAD_CAST config.Hdd);
|
||||
|
||||
sprintf(buff,"%d",config.HddSize);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "HddSize",
|
||||
BAD_CAST buff);
|
||||
sprintf(buff, "%d", config.HddSize);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "HddSize",
|
||||
BAD_CAST buff);
|
||||
|
||||
sprintf(buff,"%d",config.ethEnable);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "ethEnable",
|
||||
BAD_CAST buff);
|
||||
sprintf(buff, "%d", config.ethEnable);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "ethEnable",
|
||||
BAD_CAST buff);
|
||||
|
||||
sprintf(buff,"%d",config.hddEnable);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "hddEnable",
|
||||
BAD_CAST buff);
|
||||
/*
|
||||
sprintf(buff, "%d", config.hddEnable);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "hddEnable",
|
||||
BAD_CAST buff);
|
||||
/*
|
||||
* Dumping document to stdio or file
|
||||
*/
|
||||
|
||||
|
||||
const std::string file(s_strIniPath + "DEV9.cfg");
|
||||
const std::string file(s_strIniPath + "DEV9.cfg");
|
||||
|
||||
xmlSaveFormatFileEnc(file.c_str(), doc, "UTF-8", 1);
|
||||
// free(configFile);
|
||||
xmlSaveFormatFileEnc(file.c_str(), doc, "UTF-8", 1);
|
||||
// free(configFile);
|
||||
|
||||
/*free the document */
|
||||
xmlFreeDoc(doc);
|
||||
/*free the document */
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
/*
|
||||
/*
|
||||
*Free the global variables that may
|
||||
*have been allocated by the parser.
|
||||
*/
|
||||
xmlCleanupParser();
|
||||
xmlCleanupParser();
|
||||
}
|
||||
|
||||
void LoadConf() {
|
||||
void LoadConf()
|
||||
{
|
||||
|
||||
const std::string file(s_strIniPath + "DEV9.cfg");
|
||||
if( -1 == access( file.c_str(), F_OK ) )
|
||||
return;
|
||||
const std::string file(s_strIniPath + "DEV9.cfg");
|
||||
if (-1 == access(file.c_str(), F_OK))
|
||||
return;
|
||||
|
||||
memset(&config, 0, sizeof(config));
|
||||
memset(&config, 0, sizeof(config));
|
||||
|
||||
// Read the files
|
||||
xmlDoc *doc = NULL;
|
||||
xmlNode *cur_node = NULL;
|
||||
// Read the files
|
||||
xmlDoc* doc = NULL;
|
||||
xmlNode* cur_node = NULL;
|
||||
|
||||
doc = xmlReadFile(file.c_str(), NULL, 0);
|
||||
doc = xmlReadFile(file.c_str(), NULL, 0);
|
||||
|
||||
if (doc == NULL){
|
||||
SysMessage("Unable to parse configuration file! Suggest deleting it and starting over.");
|
||||
}
|
||||
if (doc == NULL)
|
||||
{
|
||||
SysMessage("Unable to parse configuration file! Suggest deleting it and starting over.");
|
||||
}
|
||||
|
||||
for (cur_node = xmlDocGetRootElement(doc)->children; cur_node; cur_node = cur_node->next) {
|
||||
if (cur_node->type == XML_ELEMENT_NODE) {
|
||||
// printf("node type: Element, name: %s\n", cur_node->name);
|
||||
if(0 == strcmp((const char*)cur_node->name, "Eth")) {
|
||||
strcpy(config.Eth, (const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "Hdd")) {
|
||||
strcpy(config.Hdd, (const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "HddSize")) {
|
||||
config.HddSize = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "ethEnable")) {
|
||||
config.ethEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "hddEnable")) {
|
||||
config.hddEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (cur_node = xmlDocGetRootElement(doc)->children; cur_node; cur_node = cur_node->next)
|
||||
{
|
||||
if (cur_node->type == XML_ELEMENT_NODE)
|
||||
{
|
||||
// printf("node type: Element, name: %s\n", cur_node->name);
|
||||
if (0 == strcmp((const char*)cur_node->name, "Eth"))
|
||||
{
|
||||
strcpy(config.Eth, (const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if (0 == strcmp((const char*)cur_node->name, "Hdd"))
|
||||
{
|
||||
strcpy(config.Hdd, (const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if (0 == strcmp((const char*)cur_node->name, "HddSize"))
|
||||
{
|
||||
config.HddSize = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if (0 == strcmp((const char*)cur_node->name, "ethEnable"))
|
||||
{
|
||||
config.ethEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if (0 == strcmp((const char*)cur_node->name, "hddEnable"))
|
||||
{
|
||||
config.hddEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// free(configFile);
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
// free(configFile);
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -29,147 +29,154 @@
|
|||
#include "../net.h"
|
||||
#include "AppCoreThread.h"
|
||||
|
||||
static GtkBuilder * builder;
|
||||
static GtkBuilder* builder;
|
||||
|
||||
void SysMessage(char *fmt, ...) {
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
void SysMessage(char* fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
|
||||
va_start(list,fmt);
|
||||
vsprintf(tmp,fmt,list);
|
||||
va_end(list);
|
||||
va_start(list, fmt);
|
||||
vsprintf(tmp, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
GtkWidget *dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", tmp);
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_hide(dialog);
|
||||
GtkWidget* dialog = gtk_message_dialog_new(NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", tmp);
|
||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_hide(dialog);
|
||||
}
|
||||
|
||||
void OnInitDialog() {
|
||||
char *dev;
|
||||
gint idx = 0;
|
||||
static int initialized = 0;
|
||||
void OnInitDialog()
|
||||
{
|
||||
char* dev;
|
||||
gint idx = 0;
|
||||
static int initialized = 0;
|
||||
|
||||
LoadConf();
|
||||
LoadConf();
|
||||
|
||||
if( initialized )
|
||||
return;
|
||||
if (initialized)
|
||||
return;
|
||||
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_BAYTYPE"),"Expansion");
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_BAYTYPE"),"PC Card");
|
||||
for (int i=0; i<pcap_io_get_dev_num(); i++) {
|
||||
dev = pcap_io_get_dev_name(i);
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_ETHDEV"), dev);
|
||||
if (strcmp(dev, config.Eth) == 0) {
|
||||
gtk_combo_box_set_active((GtkComboBox *)gtk_builder_get_object(builder,"IDC_ETHDEV"),idx);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
gtk_entry_set_text ((GtkEntry *)gtk_builder_get_object(builder,"IDC_HDDFILE"), config.Hdd);
|
||||
gtk_toggle_button_set_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_ETHENABLED"),
|
||||
config.ethEnable);
|
||||
gtk_toggle_button_set_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_HDDENABLED"),
|
||||
config.hddEnable);
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText*)gtk_builder_get_object(builder, "IDC_BAYTYPE"), "Expansion");
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText*)gtk_builder_get_object(builder, "IDC_BAYTYPE"), "PC Card");
|
||||
for (int i = 0; i < pcap_io_get_dev_num(); i++)
|
||||
{
|
||||
dev = pcap_io_get_dev_name(i);
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText*)gtk_builder_get_object(builder, "IDC_ETHDEV"), dev);
|
||||
if (strcmp(dev, config.Eth) == 0)
|
||||
{
|
||||
gtk_combo_box_set_active((GtkComboBox*)gtk_builder_get_object(builder, "IDC_ETHDEV"), idx);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
gtk_entry_set_text((GtkEntry*)gtk_builder_get_object(builder, "IDC_HDDFILE"), config.Hdd);
|
||||
gtk_toggle_button_set_active((GtkToggleButton*)gtk_builder_get_object(builder, "IDC_ETHENABLED"),
|
||||
config.ethEnable);
|
||||
gtk_toggle_button_set_active((GtkToggleButton*)gtk_builder_get_object(builder, "IDC_HDDENABLED"),
|
||||
config.hddEnable);
|
||||
|
||||
initialized = 1;
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
void OnOk() {
|
||||
void OnOk()
|
||||
{
|
||||
|
||||
char* ptr = gtk_combo_box_text_get_active_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_ETHDEV"));
|
||||
strcpy(config.Eth, ptr);
|
||||
char* ptr = gtk_combo_box_text_get_active_text((GtkComboBoxText*)gtk_builder_get_object(builder, "IDC_ETHDEV"));
|
||||
strcpy(config.Eth, ptr);
|
||||
|
||||
strcpy(config.Hdd, gtk_entry_get_text ((GtkEntry *)gtk_builder_get_object(builder,"IDC_HDDFILE")));
|
||||
strcpy(config.Hdd, gtk_entry_get_text((GtkEntry*)gtk_builder_get_object(builder, "IDC_HDDFILE")));
|
||||
|
||||
config.ethEnable = gtk_toggle_button_get_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_ETHENABLED"));
|
||||
config.hddEnable = gtk_toggle_button_get_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_HDDENABLED"));
|
||||
|
||||
SaveConf();
|
||||
config.ethEnable = gtk_toggle_button_get_active((GtkToggleButton*)gtk_builder_get_object(builder, "IDC_ETHENABLED"));
|
||||
config.hddEnable = gtk_toggle_button_get_active((GtkToggleButton*)gtk_builder_get_object(builder, "IDC_HDDENABLED"));
|
||||
|
||||
SaveConf();
|
||||
}
|
||||
|
||||
/* Simple GTK+2 variant of gtk_builder_add_from_resource() */
|
||||
static guint builder_add_from_resource(GtkBuilder *builder
|
||||
, const gchar *resource_path
|
||||
, GError **error)
|
||||
static guint builder_add_from_resource(GtkBuilder* builder, const gchar* resource_path, GError** error)
|
||||
{
|
||||
GBytes *data;
|
||||
const gchar *buffer;
|
||||
gsize buffer_length;
|
||||
guint ret;
|
||||
GBytes* data;
|
||||
const gchar* buffer;
|
||||
gsize buffer_length;
|
||||
guint ret;
|
||||
|
||||
g_assert(error && *error == NULL);
|
||||
g_assert(error && *error == NULL);
|
||||
|
||||
data = g_resources_lookup_data(resource_path, G_RESOURCE_LOOKUP_FLAGS_NONE, error);
|
||||
if (data == NULL) {
|
||||
return 0;
|
||||
}
|
||||
data = g_resources_lookup_data(resource_path, G_RESOURCE_LOOKUP_FLAGS_NONE, error);
|
||||
if (data == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer_length = 0;
|
||||
buffer = (const gchar *)g_bytes_get_data(data, &buffer_length);
|
||||
g_assert(buffer != NULL);
|
||||
buffer_length = 0;
|
||||
buffer = (const gchar*)g_bytes_get_data(data, &buffer_length);
|
||||
g_assert(buffer != NULL);
|
||||
|
||||
ret = gtk_builder_add_from_string(builder, buffer, buffer_length, error);
|
||||
ret = gtk_builder_add_from_string(builder, buffer, buffer_length, error);
|
||||
|
||||
g_bytes_unref(data);
|
||||
g_bytes_unref(data);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DEV9configure() {
|
||||
void DEV9configure()
|
||||
{
|
||||
ScopedCoreThreadPause paused_core;
|
||||
gtk_init (NULL, NULL);
|
||||
GError *error = NULL;
|
||||
builder = gtk_builder_new();
|
||||
if (!builder_add_from_resource(builder, "/net/pcsx2/dev9/DEV9/Linux/dev9.ui", &error)) {
|
||||
g_warning("Could not build config ui: %s", error->message);
|
||||
g_error_free(error);
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
}
|
||||
GtkDialog *dlg = GTK_DIALOG (gtk_builder_get_object(builder, "IDD_CONFDLG"));
|
||||
OnInitDialog();
|
||||
gint result = gtk_dialog_run (dlg);
|
||||
switch(result) {
|
||||
case -5: //IDOK
|
||||
OnOk();
|
||||
break;
|
||||
case -6: //IDCANCEL
|
||||
break;
|
||||
}
|
||||
gtk_widget_hide (GTK_WIDGET(dlg));
|
||||
gtk_init(NULL, NULL);
|
||||
GError* error = NULL;
|
||||
builder = gtk_builder_new();
|
||||
if (!builder_add_from_resource(builder, "/net/pcsx2/dev9/DEV9/Linux/dev9.ui", &error))
|
||||
{
|
||||
g_warning("Could not build config ui: %s", error->message);
|
||||
g_error_free(error);
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
}
|
||||
GtkDialog* dlg = GTK_DIALOG(gtk_builder_get_object(builder, "IDD_CONFDLG"));
|
||||
OnInitDialog();
|
||||
gint result = gtk_dialog_run(dlg);
|
||||
switch (result)
|
||||
{
|
||||
case -5: //IDOK
|
||||
OnOk();
|
||||
break;
|
||||
case -6: //IDCANCEL
|
||||
break;
|
||||
}
|
||||
gtk_widget_hide(GTK_WIDGET(dlg));
|
||||
paused_core.AllowResume();
|
||||
}
|
||||
|
||||
NetAdapter* GetNetAdapter()
|
||||
{
|
||||
NetAdapter* na;
|
||||
na = new PCAPAdapter();
|
||||
NetAdapter* na;
|
||||
na = new PCAPAdapter();
|
||||
|
||||
if (!na->isInitialised())
|
||||
{
|
||||
delete na;
|
||||
return 0;
|
||||
}
|
||||
return na;
|
||||
if (!na->isInitialised())
|
||||
{
|
||||
delete na;
|
||||
return 0;
|
||||
}
|
||||
return na;
|
||||
}
|
||||
s32 _DEV9open()
|
||||
s32 _DEV9open()
|
||||
{
|
||||
NetAdapter* na=GetNetAdapter();
|
||||
if (!na)
|
||||
{
|
||||
emu_printf("Failed to GetNetAdapter()\n");
|
||||
config.ethEnable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitNet(na);
|
||||
}
|
||||
return 0;
|
||||
NetAdapter* na = GetNetAdapter();
|
||||
if (!na)
|
||||
{
|
||||
emu_printf("Failed to GetNetAdapter()\n");
|
||||
config.ethEnable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitNet(na);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _DEV9close() {
|
||||
TermNet();
|
||||
void _DEV9close()
|
||||
{
|
||||
TermNet();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -22,58 +22,57 @@
|
|||
NetAdapter* nif;
|
||||
pthread_t rx_thread;
|
||||
|
||||
volatile bool RxRunning=false;
|
||||
volatile bool RxRunning = false;
|
||||
|
||||
void *NetRxThread(void *arg)
|
||||
void* NetRxThread(void* arg)
|
||||
{
|
||||
NetPacket tmp;
|
||||
while(RxRunning)
|
||||
{
|
||||
while(rx_fifo_can_rx() && nif->recv(&tmp))
|
||||
{
|
||||
rx_process(&tmp);
|
||||
}
|
||||
NetPacket tmp;
|
||||
while (RxRunning)
|
||||
{
|
||||
while (rx_fifo_can_rx() && nif->recv(&tmp))
|
||||
{
|
||||
rx_process(&tmp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tx_put(NetPacket* pkt)
|
||||
{
|
||||
nif->send(pkt);
|
||||
//pkt must be copied if its not processed by here, since it can be allocated on the callers stack
|
||||
nif->send(pkt);
|
||||
//pkt must be copied if its not processed by here, since it can be allocated on the callers stack
|
||||
}
|
||||
|
||||
void InitNet(NetAdapter* ad)
|
||||
{
|
||||
nif=ad;
|
||||
RxRunning=true;
|
||||
nif = ad;
|
||||
RxRunning = true;
|
||||
|
||||
pthread_attr_t thAttr;
|
||||
int policy = 0;
|
||||
int max_prio_for_policy = 0;
|
||||
pthread_attr_t thAttr;
|
||||
int policy = 0;
|
||||
int max_prio_for_policy = 0;
|
||||
|
||||
|
||||
int ret = pthread_create(&rx_thread, NULL, NetRxThread, NULL);
|
||||
pthread_attr_init(&thAttr);
|
||||
pthread_attr_getschedpolicy(&thAttr, &policy);
|
||||
max_prio_for_policy = sched_get_priority_max(policy);
|
||||
int ret = pthread_create(&rx_thread, NULL, NetRxThread, NULL);
|
||||
pthread_attr_init(&thAttr);
|
||||
pthread_attr_getschedpolicy(&thAttr, &policy);
|
||||
max_prio_for_policy = sched_get_priority_max(policy);
|
||||
|
||||
|
||||
pthread_setschedprio(rx_thread, max_prio_for_policy);
|
||||
pthread_attr_destroy(&thAttr);
|
||||
pthread_setschedprio(rx_thread, max_prio_for_policy);
|
||||
pthread_attr_destroy(&thAttr);
|
||||
}
|
||||
|
||||
void TermNet()
|
||||
{
|
||||
if(RxRunning)
|
||||
{
|
||||
RxRunning = false;
|
||||
emu_printf("Waiting for RX-net thread to terminate..");
|
||||
pthread_join(rx_thread,NULL);
|
||||
emu_printf(".done\n");
|
||||
if (RxRunning)
|
||||
{
|
||||
RxRunning = false;
|
||||
emu_printf("Waiting for RX-net thread to terminate..");
|
||||
pthread_join(rx_thread, NULL);
|
||||
emu_printf(".done\n");
|
||||
|
||||
delete nif;
|
||||
}
|
||||
delete nif;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -27,10 +27,11 @@ bool FileExists(std::string szPath)
|
|||
{
|
||||
DWORD dwAttrib = GetFileAttributes(szPath.c_str());
|
||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
|
||||
!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
void SaveConf() {
|
||||
void SaveConf()
|
||||
{
|
||||
const std::string file(s_strIniPath + "dev9ghz.ini");
|
||||
DeleteFile(file.c_str());
|
||||
|
||||
|
@ -41,7 +42,8 @@ void SaveConf() {
|
|||
WritePrivateProfileInt("DEV9", "hddEnable", config.hddEnable, file.c_str());
|
||||
}
|
||||
|
||||
void LoadConf() {
|
||||
void LoadConf()
|
||||
{
|
||||
const std::string file(s_strIniPath + "dev9ghz.ini");
|
||||
if (FileExists(file.c_str()) == false)
|
||||
return;
|
||||
|
@ -51,4 +53,4 @@ void LoadConf() {
|
|||
config.HddSize = GetPrivateProfileInt("DEV9", "HddSize", config.HddSize, file.c_str());
|
||||
config.ethEnable = GetPrivateProfileInt("DEV9", "ethEnable", config.ethEnable, file.c_str());
|
||||
config.hddEnable = GetPrivateProfileInt("DEV9", "hddEnable", config.hddEnable, file.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
/*++ BUILD Version: 0004 // Increment this if a change has global effects
|
||||
Copyright (c) 1992-1993 Microsoft Corporation
|
||||
Module Name:
|
||||
devioctl.h
|
||||
Revision History:
|
||||
-- */
|
||||
// begin_winioctl
|
||||
#ifndef _DEVIOCTL_
|
||||
#define _DEVIOCTL_
|
||||
// begin_ntddk begin_nthal begin_ntifs
|
||||
//
|
||||
// Define the various device type values. Note that values used by Microsoft
|
||||
// Corporation are in the range 0-32767, and 32768-65535 are reserved for use
|
||||
// by customers.
|
||||
//
|
||||
#define DEVICE_TYPE ULONG
|
||||
#define FILE_DEVICE_BEEP 0x00000001
|
||||
#define FILE_DEVICE_CD_ROM 0x00000002
|
||||
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
|
||||
#define FILE_DEVICE_CONTROLLER 0x00000004
|
||||
#define FILE_DEVICE_DATALINK 0x00000005
|
||||
#define FILE_DEVICE_DFS 0x00000006
|
||||
#define FILE_DEVICE_DISK 0x00000007
|
||||
#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
|
||||
#define FILE_DEVICE_FILE_SYSTEM 0x00000009
|
||||
#define FILE_DEVICE_INPORT_PORT 0x0000000a
|
||||
#define FILE_DEVICE_KEYBOARD 0x0000000b
|
||||
#define FILE_DEVICE_MAILSLOT 0x0000000c
|
||||
#define FILE_DEVICE_MIDI_IN 0x0000000d
|
||||
#define FILE_DEVICE_MIDI_OUT 0x0000000e
|
||||
#define FILE_DEVICE_MOUSE 0x0000000f
|
||||
#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
|
||||
#define FILE_DEVICE_NAMED_PIPE 0x00000011
|
||||
#define FILE_DEVICE_NETWORK 0x00000012
|
||||
#define FILE_DEVICE_NETWORK_BROWSER 0x00000013
|
||||
#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
|
||||
#define FILE_DEVICE_NULL 0x00000015
|
||||
#define FILE_DEVICE_PARALLEL_PORT 0x00000016
|
||||
#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
|
||||
#define FILE_DEVICE_PRINTER 0x00000018
|
||||
#define FILE_DEVICE_SCANNER 0x00000019
|
||||
#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
|
||||
#define FILE_DEVICE_SERIAL_PORT 0x0000001b
|
||||
#define FILE_DEVICE_SCREEN 0x0000001c
|
||||
#define FILE_DEVICE_SOUND 0x0000001d
|
||||
#define FILE_DEVICE_STREAMS 0x0000001e
|
||||
#define FILE_DEVICE_TAPE 0x0000001f
|
||||
#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
|
||||
#define FILE_DEVICE_TRANSPORT 0x00000021
|
||||
#define FILE_DEVICE_UNKNOWN 0x00000022
|
||||
#define FILE_DEVICE_VIDEO 0x00000023
|
||||
#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
|
||||
#define FILE_DEVICE_WAVE_IN 0x00000025
|
||||
#define FILE_DEVICE_WAVE_OUT 0x00000026
|
||||
#define FILE_DEVICE_8042_PORT 0x00000027
|
||||
#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
|
||||
#define FILE_DEVICE_BATTERY 0x00000029
|
||||
#define FILE_DEVICE_BUS_EXTENDER 0x0000002a
|
||||
#define FILE_DEVICE_MODEM 0x0000002b
|
||||
#define FILE_DEVICE_VDM 0x0000002c
|
||||
#define FILE_DEVICE_MASS_STORAGE 0x0000002d
|
||||
//
|
||||
// Macro definition for defining IOCTL and FSCTL function control codes. Note
|
||||
// that function codes 0-2047 are reserved for Microsoft Corporation, and
|
||||
// 2048-4095 are reserved for customers.
|
||||
//
|
||||
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
|
||||
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
|
||||
)
|
||||
//
|
||||
// Define the method codes for how buffers are passed for I/O and FS controls
|
||||
//
|
||||
#define METHOD_BUFFERED 0
|
||||
#define METHOD_IN_DIRECT 1
|
||||
#define METHOD_OUT_DIRECT 2
|
||||
#define METHOD_NEITHER 3
|
||||
//
|
||||
// Define the access check value for any access
|
||||
//
|
||||
//
|
||||
// The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
|
||||
// ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
|
||||
// constants *MUST* always be in sync.
|
||||
//
|
||||
#define FILE_ANY_ACCESS 0
|
||||
#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
|
||||
#define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
|
||||
// end_ntddk end_nthal end_ntifs
|
||||
#endif // _DEVIOCTL_
|
||||
// end_winioctl
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -30,37 +30,43 @@ extern HINSTANCE hInst;
|
|||
//HANDLE handleDEV9Thread = NULL;
|
||||
//DWORD dwThreadId, dwThrdParam;
|
||||
|
||||
void SysMessage(char *fmt, ...) {
|
||||
void SysMessage(char* fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
|
||||
va_start(list,fmt);
|
||||
vsprintf(tmp,fmt,list);
|
||||
va_start(list, fmt);
|
||||
vsprintf(tmp, fmt, list);
|
||||
va_end(list);
|
||||
MessageBox(0, tmp, "Dev9 Msg", 0);
|
||||
}
|
||||
|
||||
void OnInitDialog(HWND hW) {
|
||||
char *dev;
|
||||
void OnInitDialog(HWND hW)
|
||||
{
|
||||
char* dev;
|
||||
//int i;
|
||||
|
||||
LoadConf();
|
||||
|
||||
ComboBox_AddString(GetDlgItem(hW, IDC_BAYTYPE), "Expansion");
|
||||
ComboBox_AddString(GetDlgItem(hW, IDC_BAYTYPE), "PC Card");
|
||||
for (int i=0; i<pcap_io_get_dev_num(); i++) {
|
||||
for (int i = 0; i < pcap_io_get_dev_num(); i++)
|
||||
{
|
||||
dev = pcap_io_get_dev_desc(i);
|
||||
int itm=ComboBox_AddString(GetDlgItem(hW, IDC_ETHDEV), dev);
|
||||
ComboBox_SetItemData(GetDlgItem(hW, IDC_ETHDEV),itm,_strdup(pcap_io_get_dev_name(i)));
|
||||
if (strcmp(pcap_io_get_dev_name(i), config.Eth) == 0) {
|
||||
int itm = ComboBox_AddString(GetDlgItem(hW, IDC_ETHDEV), dev);
|
||||
ComboBox_SetItemData(GetDlgItem(hW, IDC_ETHDEV), itm, _strdup(pcap_io_get_dev_name(i)));
|
||||
if (strcmp(pcap_io_get_dev_name(i), config.Eth) == 0)
|
||||
{
|
||||
ComboBox_SetCurSel(GetDlgItem(hW, IDC_ETHDEV), itm);
|
||||
}
|
||||
}
|
||||
vector<tap_adapter> * al=GetTapAdapters();
|
||||
for (size_t i=0; i<al->size(); i++) {
|
||||
int itm=ComboBox_AddString(GetDlgItem(hW, IDC_ETHDEV), al[0][i].name.c_str());
|
||||
ComboBox_SetItemData(GetDlgItem(hW, IDC_ETHDEV),itm,_strdup( al[0][i].guid.c_str()));
|
||||
if (strcmp(al[0][i].guid.c_str(), config.Eth) == 0) {
|
||||
vector<tap_adapter>* al = GetTapAdapters();
|
||||
for (size_t i = 0; i < al->size(); i++)
|
||||
{
|
||||
int itm = ComboBox_AddString(GetDlgItem(hW, IDC_ETHDEV), al[0][i].name.c_str());
|
||||
ComboBox_SetItemData(GetDlgItem(hW, IDC_ETHDEV), itm, _strdup(al[0][i].guid.c_str()));
|
||||
if (strcmp(al[0][i].guid.c_str(), config.Eth) == 0)
|
||||
{
|
||||
ComboBox_SetCurSel(GetDlgItem(hW, IDC_ETHDEV), itm);
|
||||
}
|
||||
}
|
||||
|
@ -71,12 +77,13 @@ void OnInitDialog(HWND hW) {
|
|||
Button_SetCheck(GetDlgItem(hW, IDC_HDDENABLED), config.hddEnable);
|
||||
}
|
||||
|
||||
void OnOk(HWND hW) {
|
||||
void OnOk(HWND hW)
|
||||
{
|
||||
int i = ComboBox_GetCurSel(GetDlgItem(hW, IDC_ETHDEV));
|
||||
if (i == -1)
|
||||
{
|
||||
//adapter not selected
|
||||
if ( Button_GetCheck(GetDlgItem(hW, IDC_ETHENABLED)))
|
||||
if (Button_GetCheck(GetDlgItem(hW, IDC_ETHENABLED)))
|
||||
{
|
||||
//Trying to use an ethernet without
|
||||
//selected adapter, we can't have that
|
||||
|
@ -107,15 +114,18 @@ void OnOk(HWND hW) {
|
|||
EndDialog(hW, TRUE);
|
||||
}
|
||||
|
||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
switch(uMsg) {
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
OnInitDialog(hW);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
|
@ -127,13 +137,16 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch(uMsg) {
|
||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
|
@ -142,29 +155,32 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void DEV9configure() {
|
||||
ScopedCoreThreadPause paused_core;
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_CONFIG),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)ConfigureDlgProc);
|
||||
//SysMessage("Nothing to Configure");
|
||||
paused_core.AllowResume();
|
||||
void DEV9configure()
|
||||
{
|
||||
ScopedCoreThreadPause paused_core;
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_CONFIG),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)ConfigureDlgProc);
|
||||
//SysMessage("Nothing to Configure");
|
||||
paused_core.AllowResume();
|
||||
}
|
||||
|
||||
EXPORT_C_(void)
|
||||
DEV9about() {
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_ABOUT),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)AboutDlgProc);
|
||||
DEV9about()
|
||||
{
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_ABOUT),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)AboutDlgProc);
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved) {
|
||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved)
|
||||
{
|
||||
hInst = (HINSTANCE)hModule;
|
||||
return TRUE; // very quick :)
|
||||
return TRUE; // very quick :)
|
||||
}
|
||||
/*
|
||||
UINT DEV9ThreadProc() {
|
||||
|
@ -183,12 +199,12 @@ NetAdapter* GetNetAdapter()
|
|||
}
|
||||
return na;
|
||||
}
|
||||
s32 _DEV9open()
|
||||
s32 _DEV9open()
|
||||
{
|
||||
//handleDEV9Thread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) DEV9ThreadProc, &dwThrdParam, CREATE_SUSPENDED, &dwThreadId);
|
||||
//SetThreadPriority(handleDEV9Thread,THREAD_PRIORITY_HIGHEST);
|
||||
//ResumeThread (handleDEV9Thread);
|
||||
NetAdapter* na=GetNetAdapter();
|
||||
NetAdapter* na = GetNetAdapter();
|
||||
if (!na)
|
||||
{
|
||||
emu_printf("Failed to GetNetAdapter()\n");
|
||||
|
@ -201,7 +217,8 @@ s32 _DEV9open()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void _DEV9close() {
|
||||
void _DEV9close()
|
||||
{
|
||||
//TerminateThread(handleDEV9Thread,0);
|
||||
//handleDEV9Thread = NULL;
|
||||
TermNet();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,20 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* 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 <windows.h>
|
||||
#include <winuser.h>
|
||||
|
||||
#define IDC_STATIC (-1)
|
|
@ -1,85 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
//a simple, mt-safe fifo template class
|
||||
template<typename T>
|
||||
class mtfifo
|
||||
{
|
||||
struct container
|
||||
{
|
||||
container(container* n,T d)
|
||||
{
|
||||
next=n;
|
||||
data=d;
|
||||
}
|
||||
container* next;T data;
|
||||
};
|
||||
container* start;
|
||||
container* end;
|
||||
|
||||
CRITICAL_SECTION cs;
|
||||
public:
|
||||
mtfifo()
|
||||
{
|
||||
InitializeCriticalSection(&cs);
|
||||
}
|
||||
~mtfifo()
|
||||
{
|
||||
//no need to destroy the CS? i cant remember realy .. ;p
|
||||
}
|
||||
void put(T data)
|
||||
{
|
||||
EnterCriticalSection(&cs);
|
||||
if (end==0)
|
||||
{
|
||||
end=start=new container(0,data);
|
||||
}
|
||||
else
|
||||
{
|
||||
end=end->next=new container(0,data);
|
||||
}
|
||||
LeaveCriticalSection(&cs);
|
||||
}
|
||||
//Note, this is partialy mt-safe, the get may fail even if that returned false
|
||||
bool empty(){ return start==0;}
|
||||
bool get(T& rvi)
|
||||
{
|
||||
container* rv;
|
||||
EnterCriticalSection(&cs);
|
||||
if (start==0)
|
||||
{
|
||||
rv=0; //error
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
rv=start;
|
||||
start=rv->next;
|
||||
if (!start)
|
||||
end=0; //last item
|
||||
}
|
||||
LeaveCriticalSection(&cs);
|
||||
|
||||
if(!rv)
|
||||
return false;
|
||||
rvi=rv->data;
|
||||
delete rv;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -22,18 +22,18 @@
|
|||
NetAdapter* nif;
|
||||
HANDLE rx_thread;
|
||||
|
||||
volatile bool RxRunning=false;
|
||||
volatile bool RxRunning = false;
|
||||
//rx thread
|
||||
DWORD WINAPI NetRxThread(LPVOID lpThreadParameter)
|
||||
{
|
||||
{
|
||||
NetPacket tmp;
|
||||
while(RxRunning)
|
||||
while (RxRunning)
|
||||
{
|
||||
while(rx_fifo_can_rx() && nif->recv(&tmp))
|
||||
while (rx_fifo_can_rx() && nif->recv(&tmp))
|
||||
{
|
||||
rx_process(&tmp);
|
||||
}
|
||||
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
|
@ -42,23 +42,23 @@ DWORD WINAPI NetRxThread(LPVOID lpThreadParameter)
|
|||
|
||||
void tx_put(NetPacket* pkt)
|
||||
{
|
||||
if (nif!=NULL)
|
||||
if (nif != NULL)
|
||||
nif->send(pkt);
|
||||
//pkt must be copied if its not processed by here, since it can be allocated on the callers stack
|
||||
}
|
||||
void InitNet(NetAdapter* ad)
|
||||
{
|
||||
nif=ad;
|
||||
RxRunning=true;
|
||||
nif = ad;
|
||||
RxRunning = true;
|
||||
|
||||
rx_thread=CreateThread(0,0,NetRxThread,0,CREATE_SUSPENDED,0);
|
||||
rx_thread = CreateThread(0, 0, NetRxThread, 0, CREATE_SUSPENDED, 0);
|
||||
|
||||
SetThreadPriority(rx_thread,THREAD_PRIORITY_HIGHEST);
|
||||
SetThreadPriority(rx_thread, THREAD_PRIORITY_HIGHEST);
|
||||
ResumeThread(rx_thread);
|
||||
}
|
||||
void TermNet()
|
||||
{
|
||||
if(RxRunning)
|
||||
if (RxRunning)
|
||||
{
|
||||
RxRunning = false;
|
||||
emu_printf("Waiting for RX-net thread to terminate..");
|
||||
|
@ -68,4 +68,4 @@ void TermNet()
|
|||
delete nif;
|
||||
nif = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,27 +4,27 @@
|
|||
//
|
||||
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
#define IDC_STATIC -1
|
||||
#endif
|
||||
|
||||
#define IDD_CONFDLG 101
|
||||
#define IDD_CONFIG 101
|
||||
#define IDD_ABOUT 103
|
||||
#define IDC_NAME 1000
|
||||
#define IDC_COMBO1 1007
|
||||
#define IDC_ETHDEV 1007
|
||||
#define IDC_BAYTYPE 1008
|
||||
#define IDC_ETHENABLED 1009
|
||||
#define IDC_HDDFILE 1010
|
||||
#define IDC_HDDENABLED 1011
|
||||
#define IDD_CONFDLG 101
|
||||
#define IDD_CONFIG 101
|
||||
#define IDD_ABOUT 103
|
||||
#define IDC_NAME 1000
|
||||
#define IDC_COMBO1 1007
|
||||
#define IDC_ETHDEV 1007
|
||||
#define IDC_BAYTYPE 1008
|
||||
#define IDC_ETHENABLED 1009
|
||||
#define IDC_HDDFILE 1010
|
||||
#define IDC_HDDENABLED 1011
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1011
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1011
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -16,12 +16,12 @@
|
|||
#ifndef __SOCKS_H__
|
||||
#define __SOCKS_H__
|
||||
|
||||
long sockOpen(char *Device);
|
||||
long sockOpen(char* Device);
|
||||
void sockClose();
|
||||
long sockSendData(void *pData, int Size);
|
||||
long sockRecvData(void *pData, int Size);
|
||||
long sockSendData(void* pData, int Size);
|
||||
long sockRecvData(void* pData, int Size);
|
||||
long sockGetDevicesNum();
|
||||
char *sockGetDevice(int index);
|
||||
char *sockGetDeviceDesc(int index);
|
||||
char* sockGetDevice(int index);
|
||||
char* sockGetDeviceDesc(int index);
|
||||
|
||||
#endif /* __SOCKS_H__*/
|
||||
|
|
|
@ -1,31 +1,18 @@
|
|||
/*
|
||||
* TAP-Win32 -- A kernel driver to provide virtual tap device functionality
|
||||
* on Windows. Originally derived from the CIPE-Win32
|
||||
* project by Damion K. Wilson, with extensive modifications by
|
||||
* James Yonan.
|
||||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
||||
*
|
||||
* All source code which derives from the CIPE-Win32 project is
|
||||
* Copyright (C) Damion K. Wilson, 2003, and is released under the
|
||||
* GPL version 2 (see below).
|
||||
* 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.
|
||||
*
|
||||
* All other source code is Copyright (C) James Yonan, 2003-2004,
|
||||
* and is released under the GPL version 2 (see below).
|
||||
* 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.
|
||||
*
|
||||
* 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 (see the file COPYING included with this
|
||||
* distribution); if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
@ -37,18 +24,18 @@
|
|||
// TAP IOCTLs
|
||||
//=============
|
||||
|
||||
#define TAP_CONTROL_CODE(request,method) \
|
||||
CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS)
|
||||
#define TAP_CONTROL_CODE(request, method) \
|
||||
CTL_CODE(FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS)
|
||||
|
||||
#define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE (3, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE (4, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE (5, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE (6, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE (7, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE (8, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE (9, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE(1, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE(2, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE(3, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE(4, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE(5, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE(6, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE(7, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE(8, METHOD_BUFFERED)
|
||||
#define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE(9, METHOD_BUFFERED)
|
||||
|
||||
//=================
|
||||
// Registry keys
|
||||
|
@ -63,7 +50,7 @@
|
|||
//======================
|
||||
|
||||
#define USERMODEDEVICEDIR "\\\\.\\Global\\"
|
||||
#define TAPSUFFIX ".tap"
|
||||
#define TAPSUFFIX ".tap"
|
||||
|
||||
#define TAP_COMPONENT_ID "tap0901"
|
||||
|
||||
|
@ -211,56 +198,60 @@ vector<tap_adapter>* GetTapAdapters()
|
|||
//Set the connection status
|
||||
static int TAPSetStatus(HANDLE handle, int status)
|
||||
{
|
||||
unsigned long len = 0;
|
||||
unsigned long len = 0;
|
||||
|
||||
return DeviceIoControl(handle, TAP_IOCTL_SET_MEDIA_STATUS,
|
||||
&status, sizeof (status),
|
||||
&status, sizeof (status), &len, NULL);
|
||||
return DeviceIoControl(handle, TAP_IOCTL_SET_MEDIA_STATUS,
|
||||
&status, sizeof(status),
|
||||
&status, sizeof(status), &len, NULL);
|
||||
}
|
||||
//Open the TAP adapter and set the connection to enabled :)
|
||||
HANDLE TAPOpen(const char *device_guid)
|
||||
HANDLE TAPOpen(const char* device_guid)
|
||||
{
|
||||
char device_path[256];
|
||||
|
||||
struct {
|
||||
unsigned long major;
|
||||
unsigned long minor;
|
||||
unsigned long debug;
|
||||
} version;
|
||||
LONG version_len;
|
||||
|
||||
_snprintf (device_path, sizeof(device_path), "%s%s%s",
|
||||
USERMODEDEVICEDIR,
|
||||
device_guid,
|
||||
TAPSUFFIX);
|
||||
struct
|
||||
{
|
||||
unsigned long major;
|
||||
unsigned long minor;
|
||||
unsigned long debug;
|
||||
} version;
|
||||
LONG version_len;
|
||||
|
||||
HANDLE handle = CreateFile (
|
||||
device_path,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
0,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED,
|
||||
0 );
|
||||
_snprintf(device_path, sizeof(device_path), "%s%s%s",
|
||||
USERMODEDEVICEDIR,
|
||||
device_guid,
|
||||
TAPSUFFIX);
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
HANDLE handle = CreateFile(
|
||||
device_path,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
0,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED,
|
||||
0);
|
||||
|
||||
BOOL bret = DeviceIoControl(handle, TAP_IOCTL_GET_VERSION,
|
||||
&version, sizeof (version),
|
||||
&version, sizeof (version), (LPDWORD)&version_len, NULL);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if (bret == FALSE) {
|
||||
CloseHandle(handle);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
BOOL bret = DeviceIoControl(handle, TAP_IOCTL_GET_VERSION,
|
||||
&version, sizeof(version),
|
||||
&version, sizeof(version), (LPDWORD)&version_len, NULL);
|
||||
|
||||
if (!TAPSetStatus(handle, TRUE)) {
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if (bret == FALSE)
|
||||
{
|
||||
CloseHandle(handle);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return handle;
|
||||
if (!TAPSetStatus(handle, TRUE))
|
||||
{
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,69 +264,67 @@ TAPAdapter::TAPAdapter()
|
|||
if (htap == INVALID_HANDLE_VALUE)
|
||||
SysMessage("Can't open Device '%s'\n", config.Eth);
|
||||
|
||||
read.Offset = 0;
|
||||
read.OffsetHigh = 0;
|
||||
read.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
read.Offset = 0;
|
||||
read.OffsetHigh = 0;
|
||||
read.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
|
||||
write.Offset = 0;
|
||||
write.OffsetHigh = 0;
|
||||
write.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
isActive = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool TAPAdapter::blocks()
|
||||
{
|
||||
return true; //we use blocking io
|
||||
return true; //we use blocking io
|
||||
}
|
||||
bool TAPAdapter::isInitialised()
|
||||
{
|
||||
return (htap != NULL);
|
||||
}
|
||||
u8 broadcast_adddrrrr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
|
||||
u8 broadcast_adddrrrr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
//gets a packet.rv :true success
|
||||
bool TAPAdapter::recv(NetPacket* pkt)
|
||||
{
|
||||
DWORD read_size;
|
||||
BOOL result = ReadFile(htap,
|
||||
pkt->buffer,
|
||||
sizeof(pkt->buffer),
|
||||
&read_size,
|
||||
&read);
|
||||
pkt->buffer,
|
||||
sizeof(pkt->buffer),
|
||||
&read_size,
|
||||
&read);
|
||||
|
||||
if (!result) {
|
||||
DWORD dwError = GetLastError();
|
||||
if (dwError == ERROR_IO_PENDING)
|
||||
if (!result)
|
||||
{
|
||||
DWORD dwError = GetLastError();
|
||||
if (dwError == ERROR_IO_PENDING)
|
||||
{
|
||||
WaitForSingleObject(read.hEvent, INFINITE);
|
||||
result = GetOverlappedResult(htap, &read,
|
||||
&read_size, FALSE);
|
||||
if (!result)
|
||||
{
|
||||
WaitForSingleObject(read.hEvent, INFINITE);
|
||||
result = GetOverlappedResult( htap, &read,
|
||||
&read_size, FALSE);
|
||||
if (!result)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result)
|
||||
{
|
||||
if((memcmp(pkt->buffer,dev9.eeprom,6)!=0)&&(memcmp(pkt->buffer,&broadcast_adddrrrr,6)!=0))
|
||||
if ((memcmp(pkt->buffer, dev9.eeprom, 6) != 0) && (memcmp(pkt->buffer, &broadcast_adddrrrr, 6) != 0))
|
||||
{
|
||||
//ignore strange packets
|
||||
return false;
|
||||
}
|
||||
|
||||
if(memcmp(pkt->buffer+6,dev9.eeprom,6)==0)
|
||||
if (memcmp(pkt->buffer + 6, dev9.eeprom, 6) == 0)
|
||||
{
|
||||
//avoid pcap looping packets
|
||||
return false;
|
||||
}
|
||||
pkt->size=read_size;
|
||||
pkt->size = read_size;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -346,31 +335,31 @@ bool TAPAdapter::send(NetPacket* pkt)
|
|||
{
|
||||
DWORD writen;
|
||||
BOOL result = WriteFile(htap,
|
||||
pkt->buffer,
|
||||
pkt->size,
|
||||
&writen,
|
||||
&write);
|
||||
pkt->buffer,
|
||||
pkt->size,
|
||||
&writen,
|
||||
&write);
|
||||
|
||||
if (!result) {
|
||||
DWORD dwError = GetLastError();
|
||||
if (dwError == ERROR_IO_PENDING)
|
||||
if (!result)
|
||||
{
|
||||
DWORD dwError = GetLastError();
|
||||
if (dwError == ERROR_IO_PENDING)
|
||||
{
|
||||
WaitForSingleObject(write.hEvent, INFINITE);
|
||||
result = GetOverlappedResult(htap, &write,
|
||||
&writen, FALSE);
|
||||
if (!result)
|
||||
{
|
||||
WaitForSingleObject(write.hEvent, INFINITE);
|
||||
result = GetOverlappedResult( htap, &write,
|
||||
&writen, FALSE);
|
||||
if (!result)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
if (writen!=pkt->size)
|
||||
if (writen != pkt->size)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -390,7 +379,7 @@ TAPAdapter::~TAPAdapter()
|
|||
}
|
||||
|
||||
//i leave these for reference, in case we need msth :p
|
||||
#if 0==666
|
||||
#if 0 == 666
|
||||
//======================
|
||||
// Compile time configuration
|
||||
//======================
|
||||
|
@ -785,7 +774,7 @@ static int tap_win32_write(tap_win32_overlapped_t *overlapped,
|
|||
if (!result) {
|
||||
switch (error = GetLastError())
|
||||
{
|
||||
case ERROR_IO_PENDING:
|
||||
case ERROR_IO_PENDING:
|
||||
#ifndef TUN_ASYNCHRONOUS_WRITES
|
||||
WaitForSingleObject(overlapped->write_event, INFINITE);
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -19,12 +19,12 @@
|
|||
void ata_init();
|
||||
void ata_term();
|
||||
|
||||
template<int sz>
|
||||
template <int sz>
|
||||
void ata_write(u32 addr, u32 value);
|
||||
template<int sz>
|
||||
template <int sz>
|
||||
u8 ata_read(u32 addr);
|
||||
|
||||
EXPORT_C_(void)
|
||||
ata_readDMA8Mem(u32 *pMem, int size);
|
||||
ata_readDMA8Mem(u32* pMem, int size);
|
||||
EXPORT_C_(void)
|
||||
ata_writeDMA8Mem(u32 *pMem, int size);
|
||||
ata_writeDMA8Mem(u32* pMem, int size);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -18,253 +18,328 @@
|
|||
//#include <winsock2.h>
|
||||
#include "DEV9.h"
|
||||
|
||||
#define PAGE_SIZE_BITS 9
|
||||
#define PAGE_SIZE (1<<PAGE_SIZE_BITS)
|
||||
#define ECC_SIZE (16)
|
||||
#define PAGE_SIZE_ECC (PAGE_SIZE+ECC_SIZE)
|
||||
#define BLOCK_SIZE (16 * PAGE_SIZE)
|
||||
#define BLOCK_SIZE_ECC (16 * PAGE_SIZE_ECC)
|
||||
#define CARD_SIZE (1024 * BLOCK_SIZE)
|
||||
#define CARD_SIZE_ECC (1024 * BLOCK_SIZE_ECC)
|
||||
#define PAGE_SIZE_BITS 9
|
||||
#define PAGE_SIZE (1 << PAGE_SIZE_BITS)
|
||||
#define ECC_SIZE (16)
|
||||
#define PAGE_SIZE_ECC (PAGE_SIZE + ECC_SIZE)
|
||||
#define BLOCK_SIZE (16 * PAGE_SIZE)
|
||||
#define BLOCK_SIZE_ECC (16 * PAGE_SIZE_ECC)
|
||||
#define CARD_SIZE (1024 * BLOCK_SIZE)
|
||||
#define CARD_SIZE_ECC (1024 * BLOCK_SIZE_ECC)
|
||||
|
||||
|
||||
static volatile u32 ctrl, cmd= (u32)-1, address, id, counter, addrbyte;
|
||||
static volatile u32 ctrl, cmd = (u32)-1, address, id, counter, addrbyte;
|
||||
static u8 data[PAGE_SIZE_ECC], file[CARD_SIZE_ECC];
|
||||
|
||||
static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char blah[4]);
|
||||
|
||||
static void calculateECC(u8 page[PAGE_SIZE_ECC]){
|
||||
memset(page+PAGE_SIZE, 0x00, ECC_SIZE);
|
||||
xfromman_call20_calculateXors(page + 0*(PAGE_SIZE>>2), page+PAGE_SIZE+0*3);//(ECC_SIZE>>2));
|
||||
xfromman_call20_calculateXors(page + 1*(PAGE_SIZE>>2), page+PAGE_SIZE+1*3);//(ECC_SIZE>>2));
|
||||
xfromman_call20_calculateXors(page + 2*(PAGE_SIZE>>2), page+PAGE_SIZE+2*3);//(ECC_SIZE>>2));
|
||||
xfromman_call20_calculateXors(page + 3*(PAGE_SIZE>>2), page+PAGE_SIZE+3*3);//(ECC_SIZE>>2));
|
||||
static void calculateECC(u8 page[PAGE_SIZE_ECC])
|
||||
{
|
||||
memset(page + PAGE_SIZE, 0x00, ECC_SIZE);
|
||||
xfromman_call20_calculateXors(page + 0 * (PAGE_SIZE >> 2), page + PAGE_SIZE + 0 * 3); //(ECC_SIZE>>2));
|
||||
xfromman_call20_calculateXors(page + 1 * (PAGE_SIZE >> 2), page + PAGE_SIZE + 1 * 3); //(ECC_SIZE>>2));
|
||||
xfromman_call20_calculateXors(page + 2 * (PAGE_SIZE >> 2), page + PAGE_SIZE + 2 * 3); //(ECC_SIZE>>2));
|
||||
xfromman_call20_calculateXors(page + 3 * (PAGE_SIZE >> 2), page + PAGE_SIZE + 3 * 3); //(ECC_SIZE>>2));
|
||||
}
|
||||
|
||||
static const char* getCmdName(u32 cmd){
|
||||
switch(cmd) {
|
||||
case SM_CMD_READ1: return "READ1";
|
||||
case SM_CMD_READ2: return "READ2";
|
||||
case SM_CMD_READ3: return "READ3";
|
||||
case SM_CMD_RESET: return "RESET";
|
||||
case SM_CMD_WRITEDATA: return "WRITEDATA";
|
||||
case SM_CMD_PROGRAMPAGE: return "PROGRAMPAGE";
|
||||
case SM_CMD_ERASEBLOCK: return "ERASEBLOCK";
|
||||
case SM_CMD_ERASECONFIRM: return "ERASECONFIRM";
|
||||
case SM_CMD_GETSTATUS: return "GETSTATUS";
|
||||
case SM_CMD_READID: return "READID";
|
||||
default: return "unknown";
|
||||
static const char* getCmdName(u32 cmd)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case SM_CMD_READ1:
|
||||
return "READ1";
|
||||
case SM_CMD_READ2:
|
||||
return "READ2";
|
||||
case SM_CMD_READ3:
|
||||
return "READ3";
|
||||
case SM_CMD_RESET:
|
||||
return "RESET";
|
||||
case SM_CMD_WRITEDATA:
|
||||
return "WRITEDATA";
|
||||
case SM_CMD_PROGRAMPAGE:
|
||||
return "PROGRAMPAGE";
|
||||
case SM_CMD_ERASEBLOCK:
|
||||
return "ERASEBLOCK";
|
||||
case SM_CMD_ERASECONFIRM:
|
||||
return "ERASECONFIRM";
|
||||
case SM_CMD_GETSTATUS:
|
||||
return "GETSTATUS";
|
||||
case SM_CMD_READID:
|
||||
return "READID";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
void FLASHinit(){
|
||||
FILE *fd;
|
||||
void FLASHinit()
|
||||
{
|
||||
FILE* fd;
|
||||
|
||||
id= FLASH_ID_64MBIT;
|
||||
counter= 0;
|
||||
addrbyte= 0;
|
||||
id = FLASH_ID_64MBIT;
|
||||
counter = 0;
|
||||
addrbyte = 0;
|
||||
|
||||
address = 0;
|
||||
memset(data, 0xFF, PAGE_SIZE);
|
||||
calculateECC(data);
|
||||
ctrl = FLASH_PP_READY;
|
||||
|
||||
fd=fopen("flash.dat", "rb");
|
||||
if (fd != NULL){
|
||||
|
||||
fd = fopen("flash.dat", "rb");
|
||||
if (fd != NULL)
|
||||
{
|
||||
size_t ret;
|
||||
|
||||
ret = fread(file, 1, CARD_SIZE_ECC, fd);
|
||||
if (ret != CARD_SIZE_ECC) { DEV9_LOG("Reading error."); }
|
||||
if (ret != CARD_SIZE_ECC)
|
||||
{
|
||||
DEV9_LOG("Reading error.");
|
||||
}
|
||||
|
||||
fclose(fd);
|
||||
}else
|
||||
}
|
||||
else
|
||||
memset(file, 0xFF, CARD_SIZE_ECC);
|
||||
}
|
||||
|
||||
u32 FLASHread32(u32 addr, int size) {
|
||||
u32 value, refill= 0;
|
||||
u32 FLASHread32(u32 addr, int size)
|
||||
{
|
||||
u32 value, refill = 0;
|
||||
|
||||
switch(addr) {
|
||||
case FLASH_R_DATA:
|
||||
memcpy(&value, &data[counter], size);
|
||||
counter += size;
|
||||
DEV9_LOG("*FLASH DATA %dbit read 0x%08lX %s\n", size*8, value, (ctrl & FLASH_PP_READ) ? "READ_ENABLE" : "READ_DISABLE");
|
||||
if (cmd == SM_CMD_READ3){
|
||||
if (counter >= PAGE_SIZE_ECC){
|
||||
counter= PAGE_SIZE;
|
||||
refill= 1;
|
||||
switch (addr)
|
||||
{
|
||||
case FLASH_R_DATA:
|
||||
memcpy(&value, &data[counter], size);
|
||||
counter += size;
|
||||
DEV9_LOG("*FLASH DATA %dbit read 0x%08lX %s\n", size * 8, value, (ctrl & FLASH_PP_READ) ? "READ_ENABLE" : "READ_DISABLE");
|
||||
if (cmd == SM_CMD_READ3)
|
||||
{
|
||||
if (counter >= PAGE_SIZE_ECC)
|
||||
{
|
||||
counter = PAGE_SIZE;
|
||||
refill = 1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if ( (ctrl & FLASH_PP_NOECC) && (counter >= PAGE_SIZE)){
|
||||
counter %= PAGE_SIZE;
|
||||
refill= 1;
|
||||
}else
|
||||
if (!(ctrl & FLASH_PP_NOECC) && (counter >= PAGE_SIZE_ECC)){
|
||||
counter %= PAGE_SIZE_ECC;
|
||||
refill= 1;
|
||||
else
|
||||
{
|
||||
if ((ctrl & FLASH_PP_NOECC) && (counter >= PAGE_SIZE))
|
||||
{
|
||||
counter %= PAGE_SIZE;
|
||||
refill = 1;
|
||||
}
|
||||
else if (!(ctrl & FLASH_PP_NOECC) && (counter >= PAGE_SIZE_ECC))
|
||||
{
|
||||
counter %= PAGE_SIZE_ECC;
|
||||
refill = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (refill){
|
||||
ctrl &= ~FLASH_PP_READY;
|
||||
address += PAGE_SIZE;
|
||||
address %= CARD_SIZE;
|
||||
memcpy(data, file+(address>>PAGE_SIZE_BITS)*PAGE_SIZE_ECC, PAGE_SIZE);
|
||||
calculateECC(data); // calculate ECC; should be in the file already
|
||||
ctrl |= FLASH_PP_READY;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
case FLASH_R_CMD:
|
||||
DEV9_LOG("*FLASH CMD %dbit read %s DENIED\n", size*8, getCmdName(cmd));
|
||||
return cmd;
|
||||
|
||||
case FLASH_R_ADDR:
|
||||
DEV9_LOG("*FLASH ADDR %dbit read DENIED\n", size*8);
|
||||
return 0;
|
||||
|
||||
case FLASH_R_CTRL:
|
||||
DEV9_LOG("*FLASH CTRL %dbit read 0x%08lX\n", size*8, ctrl);
|
||||
return ctrl;
|
||||
|
||||
case FLASH_R_ID:
|
||||
if (cmd == SM_CMD_READID){
|
||||
DEV9_LOG("*FLASH ID %dbit read 0x%08lX\n", size*8, id);
|
||||
return id;//0x98=Toshiba/0xEC=Samsung maker code should be returned first
|
||||
}else
|
||||
if (cmd == SM_CMD_GETSTATUS){
|
||||
value= 0x80 | ((ctrl & 1) << 6); // 0:0=pass, 6:ready/busy, 7:1=not protected
|
||||
DEV9_LOG("*FLASH STATUS %dbit read 0x%08lX\n", size*8, value);
|
||||
return value;
|
||||
}//else fall off
|
||||
return 0;
|
||||
|
||||
default:
|
||||
DEV9_LOG("*FLASH Unknown %dbit read at address %lx\n", size*8, addr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void FLASHwrite32(u32 addr, u32 value, int size) {
|
||||
|
||||
switch(addr & 0x1FFFFFFF) {
|
||||
case FLASH_R_DATA:
|
||||
|
||||
DEV9_LOG("*FLASH DATA %dbit write 0x%08lX %s\n", size*8, value, (ctrl & FLASH_PP_WRITE) ? "WRITE_ENABLE" : "WRITE_DISABLE");
|
||||
memcpy(&data[counter], &value, size);
|
||||
counter += size;
|
||||
counter %= PAGE_SIZE_ECC;//should not get past the last byte, but at the end
|
||||
break;
|
||||
|
||||
case FLASH_R_CMD:
|
||||
if (!(ctrl & FLASH_PP_READY)){
|
||||
if ((value != SM_CMD_GETSTATUS) && (value != SM_CMD_RESET)){
|
||||
DEV9_LOG("*FLASH CMD %dbit write %s ILLEGAL in busy mode - IGNORED\n", size*8, getCmdName(value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmd == SM_CMD_WRITEDATA){
|
||||
if ((value != SM_CMD_PROGRAMPAGE) && (value != SM_CMD_RESET)){
|
||||
DEV9_LOG("*FLASH CMD %dbit write %s ILLEGAL after WRITEDATA cmd - IGNORED\n", size*8, getCmdName(value));
|
||||
ctrl &= ~FLASH_PP_READY;//go busy, reset is needed
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEV9_LOG("*FLASH CMD %dbit write %s\n", size*8, getCmdName(value));
|
||||
switch (value){ // A8 bit is encoded in READ cmd;)
|
||||
case SM_CMD_READ1: counter= 0; if (cmd != SM_CMD_GETSTATUS) address= counter; addrbyte= 0; break;
|
||||
case SM_CMD_READ2: counter= PAGE_SIZE/2; if (cmd != SM_CMD_GETSTATUS) address= counter; addrbyte= 0; break;
|
||||
case SM_CMD_READ3: counter= PAGE_SIZE; if (cmd != SM_CMD_GETSTATUS) address= counter; addrbyte= 0; break;
|
||||
case SM_CMD_RESET: FLASHinit(); break;
|
||||
case SM_CMD_WRITEDATA: counter= 0; address= counter; addrbyte= 0; break;
|
||||
case SM_CMD_ERASEBLOCK: counter= 0; memset(data, 0xFF, PAGE_SIZE); address= counter; addrbyte= 1; break;
|
||||
case SM_CMD_PROGRAMPAGE: //fall
|
||||
case SM_CMD_ERASECONFIRM:
|
||||
ctrl &= ~FLASH_PP_READY;
|
||||
calculateECC(data);
|
||||
memcpy(file+(address/PAGE_SIZE)*PAGE_SIZE_ECC, data, PAGE_SIZE_ECC);
|
||||
/*write2file*/
|
||||
ctrl |= FLASH_PP_READY; break;
|
||||
case SM_CMD_GETSTATUS: break;
|
||||
case SM_CMD_READID: counter= 0; address= counter; addrbyte= 0; break;
|
||||
default:
|
||||
ctrl &= ~FLASH_PP_READY;
|
||||
return;//ignore any other command; go busy, reset is needed
|
||||
}
|
||||
cmd= value;
|
||||
break;
|
||||
|
||||
case FLASH_R_ADDR:
|
||||
DEV9_LOG("*FLASH ADDR %dbit write 0x%08lX\n", size*8, value);
|
||||
address |= (value & 0xFF) << (addrbyte == 0 ? 0 : (1 + 8 * addrbyte));
|
||||
addrbyte++;
|
||||
DEV9_LOG("*FLASH ADDR = 0x%08lX (addrbyte=%d)\n", address, addrbyte);
|
||||
if (!(value & 0x100)){ // address is complete
|
||||
if ((cmd == SM_CMD_READ1) || (cmd == SM_CMD_READ2) || (cmd == SM_CMD_READ3)) {
|
||||
if (refill)
|
||||
{
|
||||
ctrl &= ~FLASH_PP_READY;
|
||||
memcpy(data, file+(address>>PAGE_SIZE_BITS)*PAGE_SIZE_ECC, PAGE_SIZE);
|
||||
calculateECC(data); // calculate ECC; should be in the file already
|
||||
address += PAGE_SIZE;
|
||||
address %= CARD_SIZE;
|
||||
memcpy(data, file + (address >> PAGE_SIZE_BITS) * PAGE_SIZE_ECC, PAGE_SIZE);
|
||||
calculateECC(data); // calculate ECC; should be in the file already
|
||||
ctrl |= FLASH_PP_READY;
|
||||
}
|
||||
addrbyte= 0; // address reset
|
||||
|
||||
return value;
|
||||
|
||||
case FLASH_R_CMD:
|
||||
DEV9_LOG("*FLASH CMD %dbit read %s DENIED\n", size * 8, getCmdName(cmd));
|
||||
return cmd;
|
||||
|
||||
case FLASH_R_ADDR:
|
||||
DEV9_LOG("*FLASH ADDR %dbit read DENIED\n", size * 8);
|
||||
return 0;
|
||||
|
||||
case FLASH_R_CTRL:
|
||||
DEV9_LOG("*FLASH CTRL %dbit read 0x%08lX\n", size * 8, ctrl);
|
||||
return ctrl;
|
||||
|
||||
case FLASH_R_ID:
|
||||
if (cmd == SM_CMD_READID)
|
||||
{
|
||||
u32 bytes, pages, blocks;
|
||||
|
||||
blocks = address / BLOCK_SIZE;
|
||||
pages = address-(blocks*BLOCK_SIZE);
|
||||
bytes = pages % PAGE_SIZE;
|
||||
pages = pages / PAGE_SIZE;
|
||||
DEV9_LOG("*FLASH ADDR = 0x%08lX (%d:%d:%d) (addrbyte=%d) FINAL\n", address, blocks, pages, bytes, addrbyte);
|
||||
DEV9_LOG("*FLASH ID %dbit read 0x%08lX\n", size * 8, id);
|
||||
return id; //0x98=Toshiba/0xEC=Samsung maker code should be returned first
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FLASH_R_CTRL:
|
||||
DEV9_LOG("*FLASH CTRL %dbit write 0x%08lX\n", size*8, value);
|
||||
ctrl = (ctrl & FLASH_PP_READY) | (value & ~FLASH_PP_READY);
|
||||
break;
|
||||
else if (cmd == SM_CMD_GETSTATUS)
|
||||
{
|
||||
value = 0x80 | ((ctrl & 1) << 6); // 0:0=pass, 6:ready/busy, 7:1=not protected
|
||||
DEV9_LOG("*FLASH STATUS %dbit read 0x%08lX\n", size * 8, value);
|
||||
return value;
|
||||
} //else fall off
|
||||
return 0;
|
||||
|
||||
case FLASH_R_ID:
|
||||
DEV9_LOG("*FLASH ID %dbit write 0x%08lX DENIED :P\n", size*8, value);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEV9_LOG("*FLASH Unkwnown %dbit write at address 0x%08lX= 0x%08lX IGNORED\n", size*8, addr, value);
|
||||
break;
|
||||
default:
|
||||
DEV9_LOG("*FLASH Unknown %dbit read at address %lx\n", size * 8, addr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char xor_table[256]={
|
||||
0x00, 0x87, 0x96, 0x11, 0xA5, 0x22, 0x33, 0xB4, 0xB4, 0x33, 0x22, 0xA5, 0x11, 0x96, 0x87, 0x00,
|
||||
0xC3, 0x44, 0x55, 0xD2, 0x66, 0xE1, 0xF0, 0x77, 0x77, 0xF0, 0xE1, 0x66, 0xD2, 0x55, 0x44, 0xC3,
|
||||
0xD2, 0x55, 0x44, 0xC3, 0x77, 0xF0, 0xE1, 0x66, 0x66, 0xE1, 0xF0, 0x77, 0xC3, 0x44, 0x55, 0xD2,
|
||||
0x11, 0x96, 0x87, 0x00, 0xB4, 0x33, 0x22, 0xA5, 0xA5, 0x22, 0x33, 0xB4, 0x00, 0x87, 0x96, 0x11,
|
||||
0xE1, 0x66, 0x77, 0xF0, 0x44, 0xC3, 0xD2, 0x55, 0x55, 0xD2, 0xC3, 0x44, 0xF0, 0x77, 0x66, 0xE1,
|
||||
0x22, 0xA5, 0xB4, 0x33, 0x87, 0x00, 0x11, 0x96, 0x96, 0x11, 0x00, 0x87, 0x33, 0xB4, 0xA5, 0x22,
|
||||
0x33, 0xB4, 0xA5, 0x22, 0x96, 0x11, 0x00, 0x87, 0x87, 0x00, 0x11, 0x96, 0x22, 0xA5, 0xB4, 0x33,
|
||||
0xF0, 0x77, 0x66, 0xE1, 0x55, 0xD2, 0xC3, 0x44, 0x44, 0xC3, 0xD2, 0x55, 0xE1, 0x66, 0x77, 0xF0,
|
||||
0xF0, 0x77, 0x66, 0xE1, 0x55, 0xD2, 0xC3, 0x44, 0x44, 0xC3, 0xD2, 0x55, 0xE1, 0x66, 0x77, 0xF0,
|
||||
0x33, 0xB4, 0xA5, 0x22, 0x96, 0x11, 0x00, 0x87, 0x87, 0x00, 0x11, 0x96, 0x22, 0xA5, 0xB4, 0x33,
|
||||
0x22, 0xA5, 0xB4, 0x33, 0x87, 0x00, 0x11, 0x96, 0x96, 0x11, 0x00, 0x87, 0x33, 0xB4, 0xA5, 0x22,
|
||||
0xE1, 0x66, 0x77, 0xF0, 0x44, 0xC3, 0xD2, 0x55, 0x55, 0xD2, 0xC3, 0x44, 0xF0, 0x77, 0x66, 0xE1,
|
||||
0x11, 0x96, 0x87, 0x00, 0xB4, 0x33, 0x22, 0xA5, 0xA5, 0x22, 0x33, 0xB4, 0x00, 0x87, 0x96, 0x11,
|
||||
0xD2, 0x55, 0x44, 0xC3, 0x77, 0xF0, 0xE1, 0x66, 0x66, 0xE1, 0xF0, 0x77, 0xC3, 0x44, 0x55, 0xD2,
|
||||
0xC3, 0x44, 0x55, 0xD2, 0x66, 0xE1, 0xF0, 0x77, 0x77, 0xF0, 0xE1, 0x66, 0xD2, 0x55, 0x44, 0xC3,
|
||||
0x00, 0x87, 0x96, 0x11, 0xA5, 0x22, 0x33, 0xB4, 0xB4, 0x33, 0x22, 0xA5, 0x11, 0x96, 0x87, 0x00};
|
||||
void FLASHwrite32(u32 addr, u32 value, int size)
|
||||
{
|
||||
|
||||
static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char blah[4]){
|
||||
unsigned char a=0, b=0, c=0, i;
|
||||
switch (addr & 0x1FFFFFFF)
|
||||
{
|
||||
case FLASH_R_DATA:
|
||||
|
||||
for (i=0; i<128; i++){
|
||||
DEV9_LOG("*FLASH DATA %dbit write 0x%08lX %s\n", size * 8, value, (ctrl & FLASH_PP_WRITE) ? "WRITE_ENABLE" : "WRITE_DISABLE");
|
||||
memcpy(&data[counter], &value, size);
|
||||
counter += size;
|
||||
counter %= PAGE_SIZE_ECC; //should not get past the last byte, but at the end
|
||||
break;
|
||||
|
||||
case FLASH_R_CMD:
|
||||
if (!(ctrl & FLASH_PP_READY))
|
||||
{
|
||||
if ((value != SM_CMD_GETSTATUS) && (value != SM_CMD_RESET))
|
||||
{
|
||||
DEV9_LOG("*FLASH CMD %dbit write %s ILLEGAL in busy mode - IGNORED\n", size * 8, getCmdName(value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmd == SM_CMD_WRITEDATA)
|
||||
{
|
||||
if ((value != SM_CMD_PROGRAMPAGE) && (value != SM_CMD_RESET))
|
||||
{
|
||||
DEV9_LOG("*FLASH CMD %dbit write %s ILLEGAL after WRITEDATA cmd - IGNORED\n", size * 8, getCmdName(value));
|
||||
ctrl &= ~FLASH_PP_READY; //go busy, reset is needed
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEV9_LOG("*FLASH CMD %dbit write %s\n", size * 8, getCmdName(value));
|
||||
switch (value)
|
||||
{ // A8 bit is encoded in READ cmd;)
|
||||
case SM_CMD_READ1:
|
||||
counter = 0;
|
||||
if (cmd != SM_CMD_GETSTATUS)
|
||||
address = counter;
|
||||
addrbyte = 0;
|
||||
break;
|
||||
case SM_CMD_READ2:
|
||||
counter = PAGE_SIZE / 2;
|
||||
if (cmd != SM_CMD_GETSTATUS)
|
||||
address = counter;
|
||||
addrbyte = 0;
|
||||
break;
|
||||
case SM_CMD_READ3:
|
||||
counter = PAGE_SIZE;
|
||||
if (cmd != SM_CMD_GETSTATUS)
|
||||
address = counter;
|
||||
addrbyte = 0;
|
||||
break;
|
||||
case SM_CMD_RESET:
|
||||
FLASHinit();
|
||||
break;
|
||||
case SM_CMD_WRITEDATA:
|
||||
counter = 0;
|
||||
address = counter;
|
||||
addrbyte = 0;
|
||||
break;
|
||||
case SM_CMD_ERASEBLOCK:
|
||||
counter = 0;
|
||||
memset(data, 0xFF, PAGE_SIZE);
|
||||
address = counter;
|
||||
addrbyte = 1;
|
||||
break;
|
||||
case SM_CMD_PROGRAMPAGE: //fall
|
||||
case SM_CMD_ERASECONFIRM:
|
||||
ctrl &= ~FLASH_PP_READY;
|
||||
calculateECC(data);
|
||||
memcpy(file + (address / PAGE_SIZE) * PAGE_SIZE_ECC, data, PAGE_SIZE_ECC);
|
||||
/*write2file*/
|
||||
ctrl |= FLASH_PP_READY;
|
||||
break;
|
||||
case SM_CMD_GETSTATUS:
|
||||
break;
|
||||
case SM_CMD_READID:
|
||||
counter = 0;
|
||||
address = counter;
|
||||
addrbyte = 0;
|
||||
break;
|
||||
default:
|
||||
ctrl &= ~FLASH_PP_READY;
|
||||
return; //ignore any other command; go busy, reset is needed
|
||||
}
|
||||
cmd = value;
|
||||
break;
|
||||
|
||||
case FLASH_R_ADDR:
|
||||
DEV9_LOG("*FLASH ADDR %dbit write 0x%08lX\n", size * 8, value);
|
||||
address |= (value & 0xFF) << (addrbyte == 0 ? 0 : (1 + 8 * addrbyte));
|
||||
addrbyte++;
|
||||
DEV9_LOG("*FLASH ADDR = 0x%08lX (addrbyte=%d)\n", address, addrbyte);
|
||||
if (!(value & 0x100))
|
||||
{ // address is complete
|
||||
if ((cmd == SM_CMD_READ1) || (cmd == SM_CMD_READ2) || (cmd == SM_CMD_READ3))
|
||||
{
|
||||
ctrl &= ~FLASH_PP_READY;
|
||||
memcpy(data, file + (address >> PAGE_SIZE_BITS) * PAGE_SIZE_ECC, PAGE_SIZE);
|
||||
calculateECC(data); // calculate ECC; should be in the file already
|
||||
ctrl |= FLASH_PP_READY;
|
||||
}
|
||||
addrbyte = 0; // address reset
|
||||
{
|
||||
u32 bytes, pages, blocks;
|
||||
|
||||
blocks = address / BLOCK_SIZE;
|
||||
pages = address - (blocks * BLOCK_SIZE);
|
||||
bytes = pages % PAGE_SIZE;
|
||||
pages = pages / PAGE_SIZE;
|
||||
DEV9_LOG("*FLASH ADDR = 0x%08lX (%d:%d:%d) (addrbyte=%d) FINAL\n", address, blocks, pages, bytes, addrbyte);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FLASH_R_CTRL:
|
||||
DEV9_LOG("*FLASH CTRL %dbit write 0x%08lX\n", size * 8, value);
|
||||
ctrl = (ctrl & FLASH_PP_READY) | (value & ~FLASH_PP_READY);
|
||||
break;
|
||||
|
||||
case FLASH_R_ID:
|
||||
DEV9_LOG("*FLASH ID %dbit write 0x%08lX DENIED :P\n", size * 8, value);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEV9_LOG("*FLASH Unkwnown %dbit write at address 0x%08lX= 0x%08lX IGNORED\n", size * 8, addr, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char xor_table[256] = {
|
||||
0x00, 0x87, 0x96, 0x11, 0xA5, 0x22, 0x33, 0xB4, 0xB4, 0x33, 0x22, 0xA5, 0x11, 0x96, 0x87, 0x00,
|
||||
0xC3, 0x44, 0x55, 0xD2, 0x66, 0xE1, 0xF0, 0x77, 0x77, 0xF0, 0xE1, 0x66, 0xD2, 0x55, 0x44, 0xC3,
|
||||
0xD2, 0x55, 0x44, 0xC3, 0x77, 0xF0, 0xE1, 0x66, 0x66, 0xE1, 0xF0, 0x77, 0xC3, 0x44, 0x55, 0xD2,
|
||||
0x11, 0x96, 0x87, 0x00, 0xB4, 0x33, 0x22, 0xA5, 0xA5, 0x22, 0x33, 0xB4, 0x00, 0x87, 0x96, 0x11,
|
||||
0xE1, 0x66, 0x77, 0xF0, 0x44, 0xC3, 0xD2, 0x55, 0x55, 0xD2, 0xC3, 0x44, 0xF0, 0x77, 0x66, 0xE1,
|
||||
0x22, 0xA5, 0xB4, 0x33, 0x87, 0x00, 0x11, 0x96, 0x96, 0x11, 0x00, 0x87, 0x33, 0xB4, 0xA5, 0x22,
|
||||
0x33, 0xB4, 0xA5, 0x22, 0x96, 0x11, 0x00, 0x87, 0x87, 0x00, 0x11, 0x96, 0x22, 0xA5, 0xB4, 0x33,
|
||||
0xF0, 0x77, 0x66, 0xE1, 0x55, 0xD2, 0xC3, 0x44, 0x44, 0xC3, 0xD2, 0x55, 0xE1, 0x66, 0x77, 0xF0,
|
||||
0xF0, 0x77, 0x66, 0xE1, 0x55, 0xD2, 0xC3, 0x44, 0x44, 0xC3, 0xD2, 0x55, 0xE1, 0x66, 0x77, 0xF0,
|
||||
0x33, 0xB4, 0xA5, 0x22, 0x96, 0x11, 0x00, 0x87, 0x87, 0x00, 0x11, 0x96, 0x22, 0xA5, 0xB4, 0x33,
|
||||
0x22, 0xA5, 0xB4, 0x33, 0x87, 0x00, 0x11, 0x96, 0x96, 0x11, 0x00, 0x87, 0x33, 0xB4, 0xA5, 0x22,
|
||||
0xE1, 0x66, 0x77, 0xF0, 0x44, 0xC3, 0xD2, 0x55, 0x55, 0xD2, 0xC3, 0x44, 0xF0, 0x77, 0x66, 0xE1,
|
||||
0x11, 0x96, 0x87, 0x00, 0xB4, 0x33, 0x22, 0xA5, 0xA5, 0x22, 0x33, 0xB4, 0x00, 0x87, 0x96, 0x11,
|
||||
0xD2, 0x55, 0x44, 0xC3, 0x77, 0xF0, 0xE1, 0x66, 0x66, 0xE1, 0xF0, 0x77, 0xC3, 0x44, 0x55, 0xD2,
|
||||
0xC3, 0x44, 0x55, 0xD2, 0x66, 0xE1, 0xF0, 0x77, 0x77, 0xF0, 0xE1, 0x66, 0xD2, 0x55, 0x44, 0xC3,
|
||||
0x00, 0x87, 0x96, 0x11, 0xA5, 0x22, 0x33, 0xB4, 0xB4, 0x33, 0x22, 0xA5, 0x11, 0x96, 0x87, 0x00};
|
||||
|
||||
static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char blah[4])
|
||||
{
|
||||
unsigned char a = 0, b = 0, c = 0, i;
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
a ^= xor_table[buffer[i]];
|
||||
if (xor_table[buffer[i]] & 0x80){
|
||||
if (xor_table[buffer[i]] & 0x80)
|
||||
{
|
||||
b ^= ~i;
|
||||
c ^= i;
|
||||
c ^= i;
|
||||
}
|
||||
}
|
||||
|
||||
blah[0]=(~a) & 0x77;
|
||||
blah[1]=(~b) & 0x7F;
|
||||
blah[2]=(~c) & 0x7F;
|
||||
blah[0] = (~a) & 0x77;
|
||||
blah[1] = (~b) & 0x7F;
|
||||
blah[2] = (~c) & 0x7F;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -15,15 +15,19 @@
|
|||
|
||||
#pragma once
|
||||
#include <stdlib.h>
|
||||
#include <string.h> //uh isnt memcpy @ stdlib ?
|
||||
#include <string.h> //uh isnt memcpy @ stdlib ?
|
||||
|
||||
struct NetPacket
|
||||
{
|
||||
NetPacket() {size=0;}
|
||||
NetPacket(void* ptr,int sz) {size=sz;memcpy(buffer,ptr,sz);}
|
||||
NetPacket() { size = 0; }
|
||||
NetPacket(void* ptr, int sz)
|
||||
{
|
||||
size = sz;
|
||||
memcpy(buffer, ptr, sz);
|
||||
}
|
||||
|
||||
int size;
|
||||
char buffer[2048-sizeof(int)];//1536 is realy needed, just pad up to 2048 bytes :)
|
||||
char buffer[2048 - sizeof(int)]; //1536 is realy needed, just pad up to 2048 bytes :)
|
||||
};
|
||||
/*
|
||||
extern mtfifo<NetPacket*> rx_fifo;
|
||||
|
@ -33,13 +37,13 @@ extern mtfifo<NetPacket*> tx_fifo;
|
|||
class NetAdapter
|
||||
{
|
||||
public:
|
||||
virtual bool blocks()=0;
|
||||
virtual bool blocks() = 0;
|
||||
virtual bool isInitialised() = 0;
|
||||
virtual bool recv(NetPacket* pkt)=0; //gets a packet
|
||||
virtual bool send(NetPacket* pkt)=0; //sends the packet and deletes it when done
|
||||
virtual ~NetAdapter(){}
|
||||
virtual bool recv(NetPacket* pkt) = 0; //gets a packet
|
||||
virtual bool send(NetPacket* pkt) = 0; //sends the packet and deletes it when done
|
||||
virtual ~NetAdapter() {}
|
||||
};
|
||||
|
||||
void tx_put(NetPacket* ptr);
|
||||
void InitNet(NetAdapter* adapter);
|
||||
void TermNet();
|
||||
void TermNet();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -30,20 +30,20 @@
|
|||
#include "DEV9.h"
|
||||
#include "net.h"
|
||||
#ifndef PCAP_NETMASK_UNKNOWN
|
||||
#define PCAP_NETMASK_UNKNOWN 0xffffffff
|
||||
#define PCAP_NETMASK_UNKNOWN 0xffffffff
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define mac_address char*
|
||||
#else
|
||||
pcap_t *adhandle;
|
||||
pcap_t* adhandle;
|
||||
pcap_dumper_t* dump_pcap;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
mac_address virtual_mac = {0x00, 0x04, 0x1F, 0x82, 0x30, 0x31}; // first three recognized by Xlink as Sony PS2
|
||||
mac_address broadcast_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
mac_address host_mac = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
#endif
|
||||
int pcap_io_running=0;
|
||||
int pcap_io_running = 0;
|
||||
extern u8 eeprom[];
|
||||
|
||||
char namebuff[256];
|
||||
|
@ -51,7 +51,7 @@ char namebuff[256];
|
|||
|
||||
|
||||
// Fetches the MAC address and prints it
|
||||
int GetMACAddress(char *adapter, mac_address* addr)
|
||||
int GetMACAddress(char* adapter, mac_address* addr)
|
||||
{
|
||||
int retval = 0;
|
||||
#ifdef _WIN32
|
||||
|
@ -65,9 +65,8 @@ int GetMACAddress(char *adapter, mac_address* addr)
|
|||
GAA_FLAG_INCLUDE_PREFIX,
|
||||
NULL,
|
||||
AdapterInfo,
|
||||
&dwBufLen
|
||||
);
|
||||
if(dwStatus != ERROR_SUCCESS)
|
||||
&dwBufLen);
|
||||
if (dwStatus != ERROR_SUCCESS)
|
||||
return 0;
|
||||
|
||||
pAdapterInfo = AdapterInfo;
|
||||
|
@ -85,16 +84,16 @@ int GetMACAddress(char *adapter, mac_address* addr)
|
|||
wchar_t wadapter[128];
|
||||
std::mbstowcs(wadapter, adapter_desc, 128);
|
||||
|
||||
do {
|
||||
if ( 0 == wcscmp(pAdapterInfo->Description, wadapter ) )
|
||||
do
|
||||
{
|
||||
if (0 == wcscmp(pAdapterInfo->Description, wadapter))
|
||||
{
|
||||
memcpy(addr,pAdapterInfo->PhysicalAddress,6);
|
||||
memcpy(addr, pAdapterInfo->PhysicalAddress, 6);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pAdapterInfo = pAdapterInfo->Next;
|
||||
}
|
||||
while(pAdapterInfo);
|
||||
} while (pAdapterInfo);
|
||||
#elif defined(__linux__)
|
||||
struct ifreq ifr;
|
||||
int fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
@ -102,7 +101,7 @@ int GetMACAddress(char *adapter, mac_address* addr)
|
|||
if (0 == ioctl(fd, SIOCGIFHWADDR, &ifr))
|
||||
{
|
||||
retval = 1;
|
||||
memcpy(addr,ifr.ifr_hwaddr.sa_data,6);
|
||||
memcpy(addr, ifr.ifr_hwaddr.sa_data, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -113,22 +112,22 @@ int GetMACAddress(char *adapter, mac_address* addr)
|
|||
return retval;
|
||||
}
|
||||
|
||||
int pcap_io_init(char *adapter)
|
||||
int pcap_io_init(char* adapter)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
#ifndef _WIN32
|
||||
struct bpf_program fp;
|
||||
char filter[1024] = "ether broadcast or ether dst ";
|
||||
int dlt;
|
||||
char *dlt_name;
|
||||
emu_printf("Opening adapter '%s'...",adapter);
|
||||
char* dlt_name;
|
||||
emu_printf("Opening adapter '%s'...", adapter);
|
||||
u16 checksum;
|
||||
GetMACAddress(adapter,&host_mac);
|
||||
|
||||
GetMACAddress(adapter, &host_mac);
|
||||
|
||||
//Lets take the hosts last 2 bytes to make it unique on Xlink
|
||||
virtual_mac.bytes[4] = host_mac.bytes[4];
|
||||
virtual_mac.bytes[5] = host_mac.bytes[5];
|
||||
|
||||
for(int ii=0; ii<6; ii++)
|
||||
for (int ii = 0; ii < 6; ii++)
|
||||
eeprom[ii] = virtual_mac.bytes[ii];
|
||||
|
||||
//The checksum seems to be all the values of the mac added up in 16bit chunks
|
||||
|
@ -137,208 +136,218 @@ int pcap_io_init(char *adapter)
|
|||
dev9.eeprom[3] = checksum;
|
||||
|
||||
/* Open the adapter */
|
||||
if ((adhandle= pcap_open_live(adapter, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
if ((adhandle = pcap_open_live(adapter, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
1, // promiscuous for Xlink usage
|
||||
1, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
1, // promiscuous for Xlink usage
|
||||
1, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s", errbuf);
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by pcap\n", adapter);
|
||||
fprintf(stderr, "\nUnable to open the adapter. %s is not supported by pcap\n", adapter);
|
||||
return -1;
|
||||
}
|
||||
char virtual_mac_str[18];
|
||||
sprintf(virtual_mac_str, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" , virtual_mac.bytes[0], virtual_mac.bytes[1], virtual_mac.bytes[2], virtual_mac.bytes[3], virtual_mac.bytes[4], virtual_mac.bytes[5]);
|
||||
strcat(filter,virtual_mac_str);
|
||||
// fprintf(stderr, "Trying pcap filter: %s\n", filter);
|
||||
sprintf(virtual_mac_str, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", virtual_mac.bytes[0], virtual_mac.bytes[1], virtual_mac.bytes[2], virtual_mac.bytes[3], virtual_mac.bytes[4], virtual_mac.bytes[5]);
|
||||
strcat(filter, virtual_mac_str);
|
||||
// fprintf(stderr, "Trying pcap filter: %s\n", filter);
|
||||
|
||||
if(pcap_compile(adhandle,&fp,filter,1,PCAP_NETMASK_UNKNOWN) == -1)
|
||||
if (pcap_compile(adhandle, &fp, filter, 1, PCAP_NETMASK_UNKNOWN) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error calling pcap_compile: %s\n", pcap_geterr(adhandle));
|
||||
fprintf(stderr, "Error calling pcap_compile: %s\n", pcap_geterr(adhandle));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(pcap_setfilter(adhandle,&fp) == -1)
|
||||
if (pcap_setfilter(adhandle, &fp) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error setting filter: %s\n", pcap_geterr(adhandle));
|
||||
fprintf(stderr, "Error setting filter: %s\n", pcap_geterr(adhandle));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
dlt = pcap_datalink(adhandle);
|
||||
dlt_name = (char*)pcap_datalink_val_to_name(dlt);
|
||||
|
||||
fprintf(stderr,"Device uses DLT %d: %s\n",dlt,dlt_name);
|
||||
switch(dlt)
|
||||
fprintf(stderr, "Device uses DLT %d: %s\n", dlt, dlt_name);
|
||||
switch (dlt)
|
||||
{
|
||||
case DLT_EN10MB :
|
||||
//case DLT_IEEE802_11:
|
||||
break;
|
||||
default:
|
||||
SysMessage("ERROR: Unsupported DataLink Type (%d): %s",dlt,dlt_name);
|
||||
pcap_close(adhandle);
|
||||
return -1;
|
||||
case DLT_EN10MB:
|
||||
//case DLT_IEEE802_11:
|
||||
break;
|
||||
default:
|
||||
SysMessage("ERROR: Unsupported DataLink Type (%d): %s", dlt, dlt_name);
|
||||
pcap_close(adhandle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
const std::string plfile(s_strLogPath + "/pkt_log.pcap");
|
||||
dump_pcap = pcap_dump_open(adhandle, plfile.c_str());
|
||||
|
||||
pcap_io_running=1;
|
||||
pcap_io_running = 1;
|
||||
emu_printf("Ok.\n");
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
int gettimeofday (struct timeval *tv, void* tz)
|
||||
int gettimeofday(struct timeval* tv, void* tz)
|
||||
{
|
||||
unsigned __int64 ns100; /*time since 1 Jan 1601 in 100ns units */
|
||||
unsigned __int64 ns100; /*time since 1 Jan 1601 in 100ns units */
|
||||
|
||||
GetSystemTimeAsFileTime((LPFILETIME)&ns100);
|
||||
tv->tv_usec = (long) ((ns100 / 10L) % 1000000L);
|
||||
tv->tv_sec = (long) ((ns100 - 116444736000000000L) / 10000000L);
|
||||
return (0);
|
||||
}
|
||||
GetSystemTimeAsFileTime((LPFILETIME)&ns100);
|
||||
tv->tv_usec = (long)((ns100 / 10L) % 1000000L);
|
||||
tv->tv_sec = (long)((ns100 - 116444736000000000L) / 10000000L);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int pcap_io_send(void* packet, int plen)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
if(pcap_io_running<=0)
|
||||
#ifndef _WIN32
|
||||
if (pcap_io_running <= 0)
|
||||
return -1;
|
||||
|
||||
if(dump_pcap)
|
||||
if (dump_pcap)
|
||||
{
|
||||
static struct pcap_pkthdr ph;
|
||||
gettimeofday(&ph.ts,NULL);
|
||||
ph.caplen=plen;
|
||||
ph.len=plen;
|
||||
pcap_dump((u_char*)dump_pcap,&ph,(u_char*)packet);
|
||||
gettimeofday(&ph.ts, NULL);
|
||||
ph.caplen = plen;
|
||||
ph.len = plen;
|
||||
pcap_dump((u_char*)dump_pcap, &ph, (u_char*)packet);
|
||||
}
|
||||
|
||||
return pcap_sendpacket(adhandle, (u_char*)packet, plen);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_io_recv(void* packet, int max_len)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
static struct pcap_pkthdr *header;
|
||||
static const u_char *pkt_data1;
|
||||
#ifndef _WIN32
|
||||
static struct pcap_pkthdr* header;
|
||||
static const u_char* pkt_data1;
|
||||
|
||||
if(pcap_io_running<=0)
|
||||
if (pcap_io_running <= 0)
|
||||
return -1;
|
||||
|
||||
if((pcap_next_ex(adhandle, &header, &pkt_data1)) > 0)
|
||||
if ((pcap_next_ex(adhandle, &header, &pkt_data1)) > 0)
|
||||
{
|
||||
memcpy(packet,pkt_data1,header->len);
|
||||
memcpy(packet, pkt_data1, header->len);
|
||||
|
||||
if(dump_pcap)
|
||||
pcap_dump((u_char*)dump_pcap,header,(u_char*)packet);
|
||||
if (dump_pcap)
|
||||
pcap_dump((u_char*)dump_pcap, header, (u_char*)packet);
|
||||
|
||||
return header->len;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void pcap_io_close()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
if(dump_pcap)
|
||||
#ifndef _WIN32
|
||||
if (dump_pcap)
|
||||
pcap_dump_close(dump_pcap);
|
||||
if (adhandle)
|
||||
pcap_close(adhandle);
|
||||
pcap_io_running=0;
|
||||
#endif
|
||||
pcap_close(adhandle);
|
||||
pcap_io_running = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int pcap_io_get_dev_num()
|
||||
{
|
||||
int i=0;
|
||||
#ifndef _WIN32
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
int i = 0;
|
||||
#ifndef _WIN32
|
||||
pcap_if_t* alldevs;
|
||||
pcap_if_t* d;
|
||||
|
||||
if (pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
d=alldevs;
|
||||
while(d!=NULL) {d=d->next; i++;}
|
||||
|
||||
d = alldevs;
|
||||
while (d != NULL)
|
||||
{
|
||||
d = d->next;
|
||||
i++;
|
||||
}
|
||||
|
||||
pcap_freealldevs(alldevs);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
return i;
|
||||
}
|
||||
|
||||
char* pcap_io_get_dev_name(int num)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
int i=0;
|
||||
#ifndef _WIN32
|
||||
pcap_if_t* alldevs;
|
||||
pcap_if_t* d;
|
||||
int i = 0;
|
||||
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
if (pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
d=alldevs;
|
||||
while(d!=NULL) {
|
||||
if(num==i)
|
||||
|
||||
d = alldevs;
|
||||
while (d != NULL)
|
||||
{
|
||||
if (num == i)
|
||||
{
|
||||
strcpy(namebuff,d->name);
|
||||
strcpy(namebuff, d->name);
|
||||
pcap_freealldevs(alldevs);
|
||||
return namebuff;
|
||||
}
|
||||
d=d->next; i++;
|
||||
d = d->next;
|
||||
i++;
|
||||
}
|
||||
|
||||
pcap_freealldevs(alldevs);
|
||||
#endif
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* pcap_io_get_dev_desc(int num)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
int i=0;
|
||||
#ifndef _WIN32
|
||||
pcap_if_t* alldevs;
|
||||
pcap_if_t* d;
|
||||
int i = 0;
|
||||
|
||||
if(pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
if (pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
d=alldevs;
|
||||
while(d!=NULL) {
|
||||
if(num==i)
|
||||
|
||||
d = alldevs;
|
||||
while (d != NULL)
|
||||
{
|
||||
if (num == i)
|
||||
{
|
||||
strcpy(namebuff,d->description);
|
||||
strcpy(namebuff, d->description);
|
||||
pcap_freealldevs(alldevs);
|
||||
return namebuff;
|
||||
}
|
||||
d=d->next; i++;
|
||||
d = d->next;
|
||||
i++;
|
||||
}
|
||||
|
||||
pcap_freealldevs(alldevs);
|
||||
#endif
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
PCAPAdapter::PCAPAdapter()
|
||||
{
|
||||
if (config.ethEnable == 0) return;
|
||||
if (pcap_io_init(config.Eth) == -1) {
|
||||
if (config.ethEnable == 0)
|
||||
return;
|
||||
if (pcap_io_init(config.Eth) == -1)
|
||||
{
|
||||
SysMessage("Can't open Device '%s'\n", config.Eth);
|
||||
}
|
||||
}
|
||||
|
@ -353,21 +362,21 @@ bool PCAPAdapter::isInitialised()
|
|||
//gets a packet.rv :true success
|
||||
bool PCAPAdapter::recv(NetPacket* pkt)
|
||||
{
|
||||
int size=pcap_io_recv(pkt->buffer,sizeof(pkt->buffer));
|
||||
if(size<=0)
|
||||
int size = pcap_io_recv(pkt->buffer, sizeof(pkt->buffer));
|
||||
if (size <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pkt->size=size;
|
||||
pkt->size = size;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//sends the packet .rv :true success
|
||||
bool PCAPAdapter::send(NetPacket* pkt)
|
||||
{
|
||||
if(pcap_io_send(pkt->buffer,pkt->size))
|
||||
if (pcap_io_send(pkt->buffer, pkt->size))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -45,86 +45,91 @@ typedef struct _ethernet_header
|
|||
|
||||
typedef struct _arp_packet
|
||||
{
|
||||
u_short hw_type;
|
||||
u_short protocol;
|
||||
u_char h_addr_len;
|
||||
u_char p_addr_len;
|
||||
u_short operation;
|
||||
u_short hw_type;
|
||||
u_short protocol;
|
||||
u_char h_addr_len;
|
||||
u_char p_addr_len;
|
||||
u_short operation;
|
||||
mac_address h_src;
|
||||
ip_address p_src;
|
||||
ip_address p_src;
|
||||
mac_address h_dst;
|
||||
ip_address p_dst;
|
||||
ip_address p_dst;
|
||||
} arp_packet;
|
||||
|
||||
typedef struct _ip_header {
|
||||
u_char ver_hlen; /* version << 4 | header length >> 2 */
|
||||
u_char type; /* type of service */
|
||||
u_short len; /* total length */
|
||||
u_short id; /* identification */
|
||||
u_short offset; /* fragment offset field */
|
||||
u_char ttl; /* time to live */
|
||||
u_char proto; /* protocol */
|
||||
u_short hdr_csum; /* checksum */
|
||||
ip_address src; /* source and dest address */
|
||||
ip_address dst;
|
||||
typedef struct _ip_header
|
||||
{
|
||||
u_char ver_hlen; /* version << 4 | header length >> 2 */
|
||||
u_char type; /* type of service */
|
||||
u_short len; /* total length */
|
||||
u_short id; /* identification */
|
||||
u_short offset; /* fragment offset field */
|
||||
u_char ttl; /* time to live */
|
||||
u_char proto; /* protocol */
|
||||
u_short hdr_csum; /* checksum */
|
||||
ip_address src; /* source and dest address */
|
||||
ip_address dst;
|
||||
} ip_header;
|
||||
|
||||
/* Internet Control Message Protocol Constants and Packet Format */
|
||||
|
||||
/* ic_type field */
|
||||
#define ICT_ECHORP 0 /* Echo reply */
|
||||
#define ICT_DESTUR 3 /* Destination unreachable */
|
||||
#define ICT_SRCQ 4 /* Source quench */
|
||||
#define ICT_REDIRECT 5 /* Redirect message type */
|
||||
#define ICT_ECHORQ 8 /* Echo request */
|
||||
#define ICT_TIMEX 11 /* Time exceeded */
|
||||
#define ICT_PARAMP 12 /* Parameter Problem */
|
||||
#define ICT_TIMERQ 13 /* Timestamp request */
|
||||
#define ICT_TIMERP 14 /* Timestamp reply */
|
||||
#define ICT_INFORQ 15 /* Information request */
|
||||
#define ICT_INFORP 16 /* Information reply */
|
||||
#define ICT_MASKRQ 17 /* Mask request */
|
||||
#define ICT_MASKRP 18 /* Mask reply */
|
||||
#define ICT_ECHORP 0 /* Echo reply */
|
||||
#define ICT_DESTUR 3 /* Destination unreachable */
|
||||
#define ICT_SRCQ 4 /* Source quench */
|
||||
#define ICT_REDIRECT 5 /* Redirect message type */
|
||||
#define ICT_ECHORQ 8 /* Echo request */
|
||||
#define ICT_TIMEX 11 /* Time exceeded */
|
||||
#define ICT_PARAMP 12 /* Parameter Problem */
|
||||
#define ICT_TIMERQ 13 /* Timestamp request */
|
||||
#define ICT_TIMERP 14 /* Timestamp reply */
|
||||
#define ICT_INFORQ 15 /* Information request */
|
||||
#define ICT_INFORP 16 /* Information reply */
|
||||
#define ICT_MASKRQ 17 /* Mask request */
|
||||
#define ICT_MASKRP 18 /* Mask reply */
|
||||
|
||||
/* ic_code field */
|
||||
#define ICC_NETUR 0 /* dest unreachable, net unreachable */
|
||||
#define ICC_HOSTUR 1 /* dest unreachable, host unreachable */
|
||||
#define ICC_PROTOUR 2 /* dest unreachable, proto unreachable */
|
||||
#define ICC_PORTUR 3 /* dest unreachable, port unreachable */
|
||||
#define ICC_FNADF 4 /* dest unr, frag needed & don't frag */
|
||||
#define ICC_SRCRT 5 /* dest unreachable, src route failed */
|
||||
#define ICC_NETUR 0 /* dest unreachable, net unreachable */
|
||||
#define ICC_HOSTUR 1 /* dest unreachable, host unreachable */
|
||||
#define ICC_PROTOUR 2 /* dest unreachable, proto unreachable */
|
||||
#define ICC_PORTUR 3 /* dest unreachable, port unreachable */
|
||||
#define ICC_FNADF 4 /* dest unr, frag needed & don't frag */
|
||||
#define ICC_SRCRT 5 /* dest unreachable, src route failed */
|
||||
|
||||
#define ICC_NETRD 0 /* redirect: net */
|
||||
#define ICC_HOSTRD 1 /* redirect: host */
|
||||
#define IC_TOSNRD 2 /* redirect: type of service, net */
|
||||
#define IC_TOSHRD 3 /* redirect: type of service, host */
|
||||
#define ICC_NETRD 0 /* redirect: net */
|
||||
#define ICC_HOSTRD 1 /* redirect: host */
|
||||
#define IC_TOSNRD 2 /* redirect: type of service, net */
|
||||
#define IC_TOSHRD 3 /* redirect: type of service, host */
|
||||
|
||||
#define ICC_TIMEX 0 /* time exceeded, ttl */
|
||||
#define ICC_FTIMEX 1 /* time exceeded, frag */
|
||||
#define ICC_TIMEX 0 /* time exceeded, ttl */
|
||||
#define ICC_FTIMEX 1 /* time exceeded, frag */
|
||||
|
||||
#define IC_HLEN 8 /* octets */
|
||||
#define IC_PADLEN 3 /* pad length (octets) */
|
||||
#define IC_HLEN 8 /* octets */
|
||||
#define IC_PADLEN 3 /* pad length (octets) */
|
||||
|
||||
#define IC_RDTTL 300 /* ttl for redirect routes */
|
||||
#define IC_RDTTL 300 /* ttl for redirect routes */
|
||||
|
||||
|
||||
/* ICMP packet format (following the IP header) */
|
||||
typedef struct _icmp_header { /* ICMP packet */
|
||||
char type; /* type of message (ICT_* above)*/
|
||||
char code; /* code (ICC_* above) */
|
||||
short csum; /* checksum of ICMP header+data */
|
||||
typedef struct _icmp_header
|
||||
{ /* ICMP packet */
|
||||
char type; /* type of message (ICT_* above)*/
|
||||
char code; /* code (ICC_* above) */
|
||||
short csum; /* checksum of ICMP header+data */
|
||||
|
||||
union {
|
||||
struct {
|
||||
int ic1_id:16; /* echo type, a message id */
|
||||
int ic1_seq:16;/* echo type, a seq. number */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
int ic1_id : 16; /* echo type, a message id */
|
||||
int ic1_seq : 16; /* echo type, a seq. number */
|
||||
} ic1;
|
||||
ip_address ic2_gw; /* for redirect, gateway */
|
||||
struct {
|
||||
char ic3_ptr;/* pointer, for ICT_PARAMP */
|
||||
char ic3_pad[IC_PADLEN];
|
||||
ip_address ic2_gw; /* for redirect, gateway */
|
||||
struct
|
||||
{
|
||||
char ic3_ptr; /* pointer, for ICT_PARAMP */
|
||||
char ic3_pad[IC_PADLEN];
|
||||
} ic3;
|
||||
int ic4_mbz; /* must be zero */
|
||||
int ic4_mbz; /* must be zero */
|
||||
} icu;
|
||||
} icmp_header;
|
||||
|
||||
|
@ -148,8 +153,8 @@ typedef struct _full_arp_packet
|
|||
extern mac_address virtual_mac;
|
||||
extern mac_address broadcast_mac;
|
||||
|
||||
#define mac_compare(a,b) (memcmp(&(a),&(b),6))
|
||||
#define ip_compare(a,b) (memcmp(&(a),&(b),4))
|
||||
#define mac_compare(a, b) (memcmp(&(a), &(b), 6))
|
||||
#define ip_compare(a, b) (memcmp(&(a), &(b), 4))
|
||||
|
||||
#endif
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -31,7 +31,7 @@
|
|||
#include "net.h"
|
||||
#include "pcap_io.h"
|
||||
|
||||
bool has_link=true;
|
||||
bool has_link = true;
|
||||
volatile bool fireIntR = false;
|
||||
std::mutex frame_counter_mutex;
|
||||
std::mutex reset_mutex;
|
||||
|
@ -65,21 +65,21 @@ void test()
|
|||
bool rx_fifo_can_rx()
|
||||
{
|
||||
//check if RX is on & stuff like that here
|
||||
|
||||
|
||||
//Check if there is space on RXBD
|
||||
if (dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT)==64)
|
||||
if (dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT) == 64)
|
||||
return false;
|
||||
|
||||
|
||||
//Check if there is space on fifo
|
||||
int rd_ptr = dev9Ru32(SMAP_R_RXFIFO_RD_PTR);
|
||||
int space = sizeof(dev9.rxfifo) -
|
||||
((dev9.rxfifo_wr_ptr-rd_ptr)&16383);
|
||||
((dev9.rxfifo_wr_ptr - rd_ptr) & 16383);
|
||||
|
||||
|
||||
if(space==0)
|
||||
if (space == 0)
|
||||
space = sizeof(dev9.rxfifo);
|
||||
|
||||
if (space<1514)
|
||||
if (space < 1514)
|
||||
return false;
|
||||
|
||||
//we can recv a packet !
|
||||
|
@ -88,33 +88,33 @@ bool rx_fifo_can_rx()
|
|||
|
||||
void rx_process(NetPacket* pk)
|
||||
{
|
||||
smap_bd_t *pbd= ((smap_bd_t *)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff])+dev9.rxbdi;
|
||||
smap_bd_t* pbd = ((smap_bd_t*)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff]) + dev9.rxbdi;
|
||||
|
||||
int bytes=(pk->size+3)&(~3);
|
||||
int bytes = (pk->size + 3) & (~3);
|
||||
|
||||
if (!(pbd->ctrl_stat & SMAP_BD_RX_EMPTY))
|
||||
if (!(pbd->ctrl_stat & SMAP_BD_RX_EMPTY))
|
||||
{
|
||||
emu_printf("ERROR : Discarding %d bytes (RX%d not ready)\n", bytes, dev9.rxbdi);
|
||||
return;
|
||||
}
|
||||
|
||||
int pstart=(dev9.rxfifo_wr_ptr)&16383;
|
||||
int i=0;
|
||||
while(i<bytes)
|
||||
int pstart = (dev9.rxfifo_wr_ptr) & 16383;
|
||||
int i = 0;
|
||||
while (i < bytes)
|
||||
{
|
||||
dev9_rxfifo_write(pk->buffer[i++]);
|
||||
dev9.rxfifo_wr_ptr&=16383;
|
||||
dev9.rxfifo_wr_ptr &= 16383;
|
||||
}
|
||||
|
||||
//increase RXBD
|
||||
std::unique_lock<std::mutex> reset_lock(reset_mutex);
|
||||
dev9.rxbdi++;
|
||||
dev9.rxbdi&=(SMAP_BD_SIZE/8)-1;
|
||||
dev9.rxbdi &= (SMAP_BD_SIZE / 8) - 1;
|
||||
|
||||
//Fill the BD with info !
|
||||
pbd->length = pk->size;
|
||||
pbd->pointer = 0x4000 + pstart;
|
||||
pbd->ctrl_stat&= ~SMAP_BD_RX_EMPTY;
|
||||
pbd->ctrl_stat &= ~SMAP_BD_RX_EMPTY;
|
||||
|
||||
//increase frame count
|
||||
std::unique_lock<std::mutex> counter_lock(frame_counter_mutex);
|
||||
|
@ -124,49 +124,49 @@ void rx_process(NetPacket* pk)
|
|||
//spams// emu_printf("Got packet, %d bytes (%d fifo)\n", pk->size,bytes);
|
||||
fireIntR = true;
|
||||
//_DEV9irq(SMAP_INTR_RXEND,0);//now ? or when the fifo is full ? i guess now atm
|
||||
//note that this _is_ wrong since the IOP interrupt system is not thread safe.. but nothing i can do about that
|
||||
//note that this _is_ wrong since the IOP interrupt system is not thread safe.. but nothing i can do about that
|
||||
}
|
||||
|
||||
u32 wswap(u32 d)
|
||||
{
|
||||
return (d>>16)|(d<<16);
|
||||
return (d >> 16) | (d << 16);
|
||||
}
|
||||
|
||||
void tx_process()
|
||||
{
|
||||
//we loop based on count ? or just *use* it ?
|
||||
u32 cnt=dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT);
|
||||
u32 cnt = dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT);
|
||||
//spams// printf("tx_process : %u cnt frames !\n",cnt);
|
||||
|
||||
NetPacket pk;
|
||||
u32 fc=0;
|
||||
for (fc=0;fc<cnt;fc++)
|
||||
u32 fc = 0;
|
||||
for (fc = 0; fc < cnt; fc++)
|
||||
{
|
||||
smap_bd_t *pbd= ((smap_bd_t *)&dev9.dev9R[SMAP_BD_TX_BASE & 0xffff])+dev9.txbdi;
|
||||
smap_bd_t* pbd = ((smap_bd_t*)&dev9.dev9R[SMAP_BD_TX_BASE & 0xffff]) + dev9.txbdi;
|
||||
|
||||
if (! (pbd->ctrl_stat&SMAP_BD_TX_READY))
|
||||
if (!(pbd->ctrl_stat & SMAP_BD_TX_READY))
|
||||
{
|
||||
emu_printf("ERROR : !pbd->ctrl_stat&SMAP_BD_TX_READY\n");
|
||||
break;
|
||||
}
|
||||
if (pbd->length&3)
|
||||
if (pbd->length & 3)
|
||||
{
|
||||
//spams// emu_printf("WARN : pbd->length not aligned %u\n",pbd->length);
|
||||
}
|
||||
|
||||
if(pbd->length>1514)
|
||||
if (pbd->length > 1514)
|
||||
{
|
||||
emu_printf("ERROR : Trying to send packet too big.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 base=(pbd->pointer-0x1000)&16383;
|
||||
u32 base = (pbd->pointer - 0x1000) & 16383;
|
||||
DEV9_LOG("Sending Packet from base %x, size %d\n", base, pbd->length);
|
||||
//spams// emu_printf("Sending Packet from base %x, size %u\n", base, pbd->length);
|
||||
|
||||
pk.size=pbd->length;
|
||||
|
||||
if (!(pbd->pointer>=0x1000))
|
||||
|
||||
pk.size = pbd->length;
|
||||
|
||||
if (!(pbd->pointer >= 0x1000))
|
||||
{
|
||||
emu_printf("ERROR: odd , !pbd->pointer>0x1000 | 0x%X %u\n", pbd->pointer, pbd->length);
|
||||
}
|
||||
|
@ -205,26 +205,26 @@ void tx_process()
|
|||
}
|
||||
*/
|
||||
|
||||
if(base+pbd->length > 16384)
|
||||
if (base + pbd->length > 16384)
|
||||
{
|
||||
u32 was=16384-base;
|
||||
memcpy(pk.buffer,dev9.txfifo+base,was);
|
||||
memcpy(pk.buffer+was,dev9.txfifo,pbd->length-was);
|
||||
printf("Warped read, was=%u, sz=%u, sz-was=%u\n", was, pbd->length, pbd->length-was);
|
||||
u32 was = 16384 - base;
|
||||
memcpy(pk.buffer, dev9.txfifo + base, was);
|
||||
memcpy(pk.buffer + was, dev9.txfifo, pbd->length - was);
|
||||
printf("Warped read, was=%u, sz=%u, sz-was=%u\n", was, pbd->length, pbd->length - was);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(pk.buffer,dev9.txfifo+base,pbd->length);
|
||||
memcpy(pk.buffer, dev9.txfifo + base, pbd->length);
|
||||
}
|
||||
tx_put(&pk);
|
||||
}
|
||||
|
||||
|
||||
pbd->ctrl_stat&= ~SMAP_BD_TX_READY;
|
||||
pbd->ctrl_stat &= ~SMAP_BD_TX_READY;
|
||||
|
||||
//increase TXBD
|
||||
dev9.txbdi++;
|
||||
dev9.txbdi&=(SMAP_BD_SIZE/8)-1;
|
||||
dev9.txbdi &= (SMAP_BD_SIZE / 8) - 1;
|
||||
|
||||
//decrease frame count -- this is not thread safe
|
||||
dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT)--;
|
||||
|
@ -232,112 +232,112 @@ void tx_process()
|
|||
|
||||
//spams// emu_printf("processed %u frames, %u count, cnt = %u\n",fc,dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT),cnt);
|
||||
//if some error/early exit signal TXDNV
|
||||
if (fc!=cnt || cnt==0)
|
||||
if (fc != cnt || cnt == 0)
|
||||
{
|
||||
printf("WARN : (fc!=cnt || cnt==0) but packet send request was made oO..\n");
|
||||
_DEV9irq(SMAP_INTR_TXDNV,0);
|
||||
_DEV9irq(SMAP_INTR_TXDNV, 0);
|
||||
}
|
||||
//if we actualy send something send TXEND
|
||||
if(fc!=0)
|
||||
_DEV9irq(SMAP_INTR_TXEND,100);//now ? or when the fifo is empty ? i guess now atm
|
||||
if (fc != 0)
|
||||
_DEV9irq(SMAP_INTR_TXEND, 100); //now ? or when the fifo is empty ? i guess now atm
|
||||
}
|
||||
|
||||
|
||||
void emac3_write(u32 addr)
|
||||
{
|
||||
u32 value=wswap(dev9Ru32(addr));
|
||||
switch(addr)
|
||||
u32 value = wswap(dev9Ru32(addr));
|
||||
switch (addr)
|
||||
{
|
||||
case SMAP_R_EMAC3_MODE0_L:
|
||||
DEV9_LOG("SMAP: SMAP_R_EMAC3_MODE0 write %x\n", value);
|
||||
value = (value & (~SMAP_E3_SOFT_RESET)) | SMAP_E3_TXMAC_IDLE | SMAP_E3_RXMAC_IDLE;
|
||||
dev9Ru16(SMAP_R_EMAC3_STA_CTRL_H)|= SMAP_E3_PHY_OP_COMP;
|
||||
break;
|
||||
case SMAP_R_EMAC3_TxMODE0_L:
|
||||
DEV9_LOG("SMAP: SMAP_R_EMAC3_TxMODE0_L write %x\n", value);
|
||||
//spams// emu_printf("SMAP: SMAP_R_EMAC3_TxMODE0_L write %x\n", value);
|
||||
//Process TX here ?
|
||||
if (!(value & SMAP_E3_TX_GNP_0))
|
||||
emu_printf("SMAP_R_EMAC3_TxMODE0_L: SMAP_E3_TX_GNP_0 not set\n");
|
||||
case SMAP_R_EMAC3_MODE0_L:
|
||||
DEV9_LOG("SMAP: SMAP_R_EMAC3_MODE0 write %x\n", value);
|
||||
value = (value & (~SMAP_E3_SOFT_RESET)) | SMAP_E3_TXMAC_IDLE | SMAP_E3_RXMAC_IDLE;
|
||||
dev9Ru16(SMAP_R_EMAC3_STA_CTRL_H) |= SMAP_E3_PHY_OP_COMP;
|
||||
break;
|
||||
case SMAP_R_EMAC3_TxMODE0_L:
|
||||
DEV9_LOG("SMAP: SMAP_R_EMAC3_TxMODE0_L write %x\n", value);
|
||||
//spams// emu_printf("SMAP: SMAP_R_EMAC3_TxMODE0_L write %x\n", value);
|
||||
//Process TX here ?
|
||||
if (!(value & SMAP_E3_TX_GNP_0))
|
||||
emu_printf("SMAP_R_EMAC3_TxMODE0_L: SMAP_E3_TX_GNP_0 not set\n");
|
||||
|
||||
tx_process();
|
||||
value = value& ~SMAP_E3_TX_GNP_0;
|
||||
if (value)
|
||||
emu_printf("SMAP_R_EMAC3_TxMODE0_L: extra bits set !\n");
|
||||
break;
|
||||
case SMAP_R_EMAC3_TxMODE1_L:
|
||||
emu_printf("SMAP_R_EMAC3_TxMODE1_L 32bit write %x\n", value);
|
||||
if (value == 0x380f0000)
|
||||
{
|
||||
emu_printf("Adapter Detection Hack - Resetting RX/TX\n");
|
||||
_DEV9irq(SMAP_INTR_RXEND | SMAP_INTR_TXEND | SMAP_INTR_TXDNV, 5);
|
||||
}
|
||||
break;
|
||||
case SMAP_R_EMAC3_STA_CTRL_L:
|
||||
DEV9_LOG("SMAP: SMAP_R_EMAC3_STA_CTRL write %x\n", value);
|
||||
{
|
||||
if (value & (SMAP_E3_PHY_READ))
|
||||
tx_process();
|
||||
value = value & ~SMAP_E3_TX_GNP_0;
|
||||
if (value)
|
||||
emu_printf("SMAP_R_EMAC3_TxMODE0_L: extra bits set !\n");
|
||||
break;
|
||||
case SMAP_R_EMAC3_TxMODE1_L:
|
||||
emu_printf("SMAP_R_EMAC3_TxMODE1_L 32bit write %x\n", value);
|
||||
if (value == 0x380f0000)
|
||||
{
|
||||
value|= SMAP_E3_PHY_OP_COMP;
|
||||
int reg = value & (SMAP_E3_PHY_REG_ADDR_MSK);
|
||||
u16 val = dev9.phyregs[reg];
|
||||
switch (reg)
|
||||
{
|
||||
case SMAP_DsPHYTER_BMSR:
|
||||
if (has_link)
|
||||
val|= SMAP_PHY_BMSR_LINK | SMAP_PHY_BMSR_ANCP;
|
||||
break;
|
||||
case SMAP_DsPHYTER_PHYSTS:
|
||||
if (has_link)
|
||||
val|= SMAP_PHY_STS_LINK |SMAP_PHY_STS_100M | SMAP_PHY_STS_FDX | SMAP_PHY_STS_ANCP;
|
||||
break;
|
||||
}
|
||||
DEV9_LOG("phy_read %d: %x\n", reg, val);
|
||||
value=(value&0xFFFF)|(val<<16);
|
||||
}
|
||||
if (value & (SMAP_E3_PHY_WRITE))
|
||||
{
|
||||
value|= SMAP_E3_PHY_OP_COMP;
|
||||
int reg = value & (SMAP_E3_PHY_REG_ADDR_MSK);
|
||||
u16 val = value>>16;
|
||||
switch (reg)
|
||||
{
|
||||
case SMAP_DsPHYTER_BMCR:
|
||||
val&= ~SMAP_PHY_BMCR_RST;
|
||||
val|= 0x1;
|
||||
break;
|
||||
}
|
||||
DEV9_LOG("phy_write %d: %x\n", reg, val);
|
||||
dev9.phyregs[reg] = val;
|
||||
emu_printf("Adapter Detection Hack - Resetting RX/TX\n");
|
||||
_DEV9irq(SMAP_INTR_RXEND | SMAP_INTR_TXEND | SMAP_INTR_TXDNV, 5);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEV9_LOG("SMAP: emac3 write %x=%x\n",addr, value);
|
||||
break;
|
||||
case SMAP_R_EMAC3_STA_CTRL_L:
|
||||
DEV9_LOG("SMAP: SMAP_R_EMAC3_STA_CTRL write %x\n", value);
|
||||
{
|
||||
if (value & (SMAP_E3_PHY_READ))
|
||||
{
|
||||
value |= SMAP_E3_PHY_OP_COMP;
|
||||
int reg = value & (SMAP_E3_PHY_REG_ADDR_MSK);
|
||||
u16 val = dev9.phyregs[reg];
|
||||
switch (reg)
|
||||
{
|
||||
case SMAP_DsPHYTER_BMSR:
|
||||
if (has_link)
|
||||
val |= SMAP_PHY_BMSR_LINK | SMAP_PHY_BMSR_ANCP;
|
||||
break;
|
||||
case SMAP_DsPHYTER_PHYSTS:
|
||||
if (has_link)
|
||||
val |= SMAP_PHY_STS_LINK | SMAP_PHY_STS_100M | SMAP_PHY_STS_FDX | SMAP_PHY_STS_ANCP;
|
||||
break;
|
||||
}
|
||||
DEV9_LOG("phy_read %d: %x\n", reg, val);
|
||||
value = (value & 0xFFFF) | (val << 16);
|
||||
}
|
||||
if (value & (SMAP_E3_PHY_WRITE))
|
||||
{
|
||||
value |= SMAP_E3_PHY_OP_COMP;
|
||||
int reg = value & (SMAP_E3_PHY_REG_ADDR_MSK);
|
||||
u16 val = value >> 16;
|
||||
switch (reg)
|
||||
{
|
||||
case SMAP_DsPHYTER_BMCR:
|
||||
val &= ~SMAP_PHY_BMCR_RST;
|
||||
val |= 0x1;
|
||||
break;
|
||||
}
|
||||
DEV9_LOG("phy_write %d: %x\n", reg, val);
|
||||
dev9.phyregs[reg] = val;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEV9_LOG("SMAP: emac3 write %x=%x\n", addr, value);
|
||||
}
|
||||
dev9Ru32(addr)=wswap(value);
|
||||
dev9Ru32(addr) = wswap(value);
|
||||
}
|
||||
EXPORT_C_(u8)
|
||||
smap_read8(u32 addr)
|
||||
{
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SMAP_R_TXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_TXFIFO_FRAME_CNT read 8\n");
|
||||
break;
|
||||
case SMAP_R_RXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_RXFIFO_FRAME_CNT read 8\n");
|
||||
break;
|
||||
case SMAP_R_TXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_TXFIFO_FRAME_CNT read 8\n");
|
||||
break;
|
||||
case SMAP_R_RXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_RXFIFO_FRAME_CNT read 8\n");
|
||||
break;
|
||||
|
||||
case SMAP_R_BD_MODE:
|
||||
return dev9.bd_swap;
|
||||
case SMAP_R_BD_MODE:
|
||||
return dev9.bd_swap;
|
||||
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 8 bit read @ %X,v=%X\n",addr,dev9Ru8(addr));
|
||||
return dev9Ru8(addr);
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 8 bit read @ %X,v=%X\n", addr, dev9Ru8(addr));
|
||||
return dev9Ru8(addr);
|
||||
}
|
||||
|
||||
DEV9_LOG("SMAP : error , 8 bit read @ %X,v=%X\n",addr,dev9Ru8(addr));
|
||||
DEV9_LOG("SMAP : error , 8 bit read @ %X,v=%X\n", addr, dev9Ru8(addr));
|
||||
return dev9Ru8(addr);
|
||||
}
|
||||
EXPORT_C_(u16)
|
||||
|
@ -415,7 +415,7 @@ smap_read16(u32 addr)
|
|||
*/
|
||||
}
|
||||
#ifdef DEV9_LOG_ENABLE
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SMAP_R_TXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_TXFIFO_FRAME_CNT read 16\n");
|
||||
|
@ -487,7 +487,7 @@ smap_read16(u32 addr)
|
|||
DEV9_LOG("SMAP_R_EMAC3_STA_CTRL_H 16bit read %x\n", dev9Ru16(addr));
|
||||
return dev9Ru16(addr);
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 16 bit read @ %X,v=%X\n",addr,dev9Ru16(addr));
|
||||
DEV9_LOG("SMAP : Unknown 16 bit read @ %X,v=%X\n", addr, dev9Ru16(addr));
|
||||
return dev9Ru16(addr);
|
||||
}
|
||||
#endif
|
||||
|
@ -497,41 +497,41 @@ smap_read16(u32 addr)
|
|||
EXPORT_C_(u32)
|
||||
smap_read32(u32 addr)
|
||||
{
|
||||
if (addr>=SMAP_EMAC3_REGBASE && addr<SMAP_EMAC3_REGEND)
|
||||
if (addr >= SMAP_EMAC3_REGBASE && addr < SMAP_EMAC3_REGEND)
|
||||
{
|
||||
u32 hi=smap_read16(addr);
|
||||
u32 lo=smap_read16(addr+2)<<16;
|
||||
return hi|lo;
|
||||
u32 hi = smap_read16(addr);
|
||||
u32 lo = smap_read16(addr + 2) << 16;
|
||||
return hi | lo;
|
||||
}
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SMAP_R_TXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_TXFIFO_FRAME_CNT read 32\n");
|
||||
return dev9Ru32(addr);
|
||||
case SMAP_R_RXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_RXFIFO_FRAME_CNT read 32\n");
|
||||
return dev9Ru32(addr);
|
||||
case SMAP_R_EMAC3_STA_CTRL_L:
|
||||
DEV9_LOG("SMAP_R_EMAC3_STA_CTRL_L 32bit read value %x\n", dev9Ru32(addr));
|
||||
return dev9Ru32(addr);
|
||||
case SMAP_R_TXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_TXFIFO_FRAME_CNT read 32\n");
|
||||
return dev9Ru32(addr);
|
||||
case SMAP_R_RXFIFO_FRAME_CNT:
|
||||
printf("SMAP_R_RXFIFO_FRAME_CNT read 32\n");
|
||||
return dev9Ru32(addr);
|
||||
case SMAP_R_EMAC3_STA_CTRL_L:
|
||||
DEV9_LOG("SMAP_R_EMAC3_STA_CTRL_L 32bit read value %x\n", dev9Ru32(addr));
|
||||
return dev9Ru32(addr);
|
||||
|
||||
case SMAP_R_RXFIFO_DATA:
|
||||
case SMAP_R_RXFIFO_DATA:
|
||||
{
|
||||
int rd_ptr = dev9Ru32(SMAP_R_RXFIFO_RD_PTR)&16383;
|
||||
int rd_ptr = dev9Ru32(SMAP_R_RXFIFO_RD_PTR) & 16383;
|
||||
|
||||
int rv = *((u32*)(dev9.rxfifo + rd_ptr));
|
||||
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR) = ((rd_ptr+4)&16383);
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR) = ((rd_ptr + 4) & 16383);
|
||||
|
||||
if(dev9.bd_swap)
|
||||
rv=(rv<<24)|(rv>>24)|((rv>>8)&0xFF00)|((rv<<8)&0xFF0000);
|
||||
if (dev9.bd_swap)
|
||||
rv = (rv << 24) | (rv >> 24) | ((rv >> 8) & 0xFF00) | ((rv << 8) & 0xFF0000);
|
||||
|
||||
DEV9_LOG("SMAP_R_RXFIFO_DATA 32bit read %x\n", rv);
|
||||
return rv;
|
||||
}
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 32 bit read @ %X,v=%X\n",addr,dev9Ru32(addr));
|
||||
return dev9Ru32(addr);
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 32 bit read @ %X,v=%X\n", addr, dev9Ru32(addr));
|
||||
return dev9Ru32(addr);
|
||||
}
|
||||
}
|
||||
EXPORT_C_(void)
|
||||
|
@ -539,83 +539,84 @@ smap_write8(u32 addr, u8 value)
|
|||
{
|
||||
std::unique_lock<std::mutex> reset_lock(reset_mutex, std::defer_lock);
|
||||
std::unique_lock<std::mutex> counter_lock(frame_counter_mutex, std::defer_lock);
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SMAP_R_TXFIFO_FRAME_INC:
|
||||
DEV9_LOG("SMAP_R_TXFIFO_FRAME_INC 8bit write %x\n", value);
|
||||
{
|
||||
dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT)++;
|
||||
}
|
||||
return;
|
||||
case SMAP_R_TXFIFO_FRAME_INC:
|
||||
DEV9_LOG("SMAP_R_TXFIFO_FRAME_INC 8bit write %x\n", value);
|
||||
{
|
||||
dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT)++;
|
||||
}
|
||||
return;
|
||||
|
||||
case SMAP_R_RXFIFO_FRAME_DEC:
|
||||
DEV9_LOG("SMAP_R_RXFIFO_FRAME_DEC 8bit write %x\n", value);
|
||||
counter_lock.lock();
|
||||
dev9Ru8(addr) = value;
|
||||
{
|
||||
dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT)--;
|
||||
}
|
||||
counter_lock.unlock();
|
||||
return;
|
||||
|
||||
case SMAP_R_TXFIFO_CTRL:
|
||||
DEV9_LOG("SMAP_R_TXFIFO_CTRL 8bit write %x\n", value);
|
||||
if(value&SMAP_TXFIFO_RESET)
|
||||
{
|
||||
dev9.txbdi=0;
|
||||
dev9.txfifo_rd_ptr=0;
|
||||
dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT)=0; //this actualy needs to be atomic (lock mov ...)
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR)=0;
|
||||
dev9Ru32(SMAP_R_TXFIFO_SIZE)=16384;
|
||||
}
|
||||
value&= ~SMAP_TXFIFO_RESET;
|
||||
dev9Ru8(addr) = value;
|
||||
return;
|
||||
|
||||
case SMAP_R_RXFIFO_CTRL:
|
||||
DEV9_LOG("SMAP_R_RXFIFO_CTRL 8bit write %x\n", value);
|
||||
if(value&SMAP_RXFIFO_RESET)
|
||||
{
|
||||
reset_lock.lock(); //lock reset mutex 1st
|
||||
case SMAP_R_RXFIFO_FRAME_DEC:
|
||||
DEV9_LOG("SMAP_R_RXFIFO_FRAME_DEC 8bit write %x\n", value);
|
||||
counter_lock.lock();
|
||||
dev9.rxbdi=0;
|
||||
dev9.rxfifo_wr_ptr=0;
|
||||
dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT)=0;
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR)=0;
|
||||
dev9Ru32(SMAP_R_RXFIFO_SIZE)=16384;
|
||||
reset_lock.unlock();
|
||||
dev9Ru8(addr) = value;
|
||||
{
|
||||
dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT)--;
|
||||
}
|
||||
counter_lock.unlock();
|
||||
}
|
||||
value&= ~SMAP_RXFIFO_RESET;
|
||||
dev9Ru8(addr) = value;
|
||||
return;
|
||||
return;
|
||||
|
||||
case SMAP_R_BD_MODE:
|
||||
if(value&SMAP_BD_SWAP)
|
||||
{
|
||||
DEV9_LOG("SMAP_R_BD_MODE: byteswapped.\n");
|
||||
emu_printf("BD Byteswapping enabled.\n");
|
||||
dev9.bd_swap=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEV9_LOG("SMAP_R_BD_MODE: NOT byteswapped.\n");
|
||||
emu_printf("BD Byteswapping disabled.\n");
|
||||
dev9.bd_swap=0;
|
||||
}
|
||||
return;
|
||||
default :
|
||||
DEV9_LOG("SMAP : Unknown 8 bit write @ %X,v=%X\n",addr,value);
|
||||
dev9Ru8(addr) = value;
|
||||
return;
|
||||
case SMAP_R_TXFIFO_CTRL:
|
||||
DEV9_LOG("SMAP_R_TXFIFO_CTRL 8bit write %x\n", value);
|
||||
if (value & SMAP_TXFIFO_RESET)
|
||||
{
|
||||
dev9.txbdi = 0;
|
||||
dev9.txfifo_rd_ptr = 0;
|
||||
dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT) = 0; //this actualy needs to be atomic (lock mov ...)
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR) = 0;
|
||||
dev9Ru32(SMAP_R_TXFIFO_SIZE) = 16384;
|
||||
}
|
||||
value &= ~SMAP_TXFIFO_RESET;
|
||||
dev9Ru8(addr) = value;
|
||||
return;
|
||||
|
||||
case SMAP_R_RXFIFO_CTRL:
|
||||
DEV9_LOG("SMAP_R_RXFIFO_CTRL 8bit write %x\n", value);
|
||||
if (value & SMAP_RXFIFO_RESET)
|
||||
{
|
||||
reset_lock.lock(); //lock reset mutex 1st
|
||||
counter_lock.lock();
|
||||
dev9.rxbdi = 0;
|
||||
dev9.rxfifo_wr_ptr = 0;
|
||||
dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT) = 0;
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR) = 0;
|
||||
dev9Ru32(SMAP_R_RXFIFO_SIZE) = 16384;
|
||||
reset_lock.unlock();
|
||||
counter_lock.unlock();
|
||||
}
|
||||
value &= ~SMAP_RXFIFO_RESET;
|
||||
dev9Ru8(addr) = value;
|
||||
return;
|
||||
|
||||
case SMAP_R_BD_MODE:
|
||||
if (value & SMAP_BD_SWAP)
|
||||
{
|
||||
DEV9_LOG("SMAP_R_BD_MODE: byteswapped.\n");
|
||||
emu_printf("BD Byteswapping enabled.\n");
|
||||
dev9.bd_swap = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEV9_LOG("SMAP_R_BD_MODE: NOT byteswapped.\n");
|
||||
emu_printf("BD Byteswapping disabled.\n");
|
||||
dev9.bd_swap = 0;
|
||||
}
|
||||
return;
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 8 bit write @ %X,v=%X\n", addr, value);
|
||||
dev9Ru8(addr) = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
EXPORT_C_(void)
|
||||
smap_write16(u32 addr, u16 value)
|
||||
{
|
||||
if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE)) {
|
||||
if(dev9.bd_swap)
|
||||
value = (value>>8)|(value<<8);
|
||||
if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE))
|
||||
{
|
||||
if (dev9.bd_swap)
|
||||
value = (value >> 8) | (value << 8);
|
||||
dev9Ru16(addr) = value;
|
||||
/*
|
||||
switch (addr & 0x7)
|
||||
|
@ -641,13 +642,13 @@ smap_write16(u32 addr, u16 value)
|
|||
*/
|
||||
return;
|
||||
}
|
||||
else if (addr >= SMAP_BD_RX_BASE && addr < (SMAP_BD_RX_BASE + SMAP_BD_SIZE))
|
||||
else if (addr >= SMAP_BD_RX_BASE && addr < (SMAP_BD_RX_BASE + SMAP_BD_SIZE))
|
||||
{
|
||||
//int rx_index=(addr - SMAP_BD_RX_BASE)>>3;
|
||||
if(dev9.bd_swap)
|
||||
value = (value>>8)|(value<<8);
|
||||
if (dev9.bd_swap)
|
||||
value = (value >> 8) | (value << 8);
|
||||
dev9Ru16(addr) = value;
|
||||
/*
|
||||
/*
|
||||
switch (addr & 0x7)
|
||||
{
|
||||
case 0: // ctrl_stat
|
||||
|
@ -675,88 +676,88 @@ smap_write16(u32 addr, u16 value)
|
|||
return;
|
||||
}
|
||||
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SMAP_R_INTR_CLR:
|
||||
DEV9_LOG("SMAP: SMAP_R_INTR_CLR 16bit write %x\n", value);
|
||||
dev9.irqcause&= ~value;
|
||||
return;
|
||||
case SMAP_R_INTR_CLR:
|
||||
DEV9_LOG("SMAP: SMAP_R_INTR_CLR 16bit write %x\n", value);
|
||||
dev9.irqcause &= ~value;
|
||||
return;
|
||||
|
||||
case SMAP_R_TXFIFO_WR_PTR:
|
||||
DEV9_LOG("SMAP: SMAP_R_TXFIFO_WR_PTR 16bit write %x\n", value);
|
||||
dev9Ru16(addr) = value;
|
||||
return;
|
||||
#define EMAC3_L_WRITE(name) \
|
||||
case name: \
|
||||
case SMAP_R_TXFIFO_WR_PTR:
|
||||
DEV9_LOG("SMAP: SMAP_R_TXFIFO_WR_PTR 16bit write %x\n", value);
|
||||
dev9Ru16(addr) = value;
|
||||
return;
|
||||
#define EMAC3_L_WRITE(name) \
|
||||
case name: \
|
||||
DEV9_LOG("SMAP: " #name " 16 bit write %x\n", value); \
|
||||
dev9Ru16(addr) = value; \
|
||||
dev9Ru16(addr) = value; \
|
||||
return;
|
||||
//handle L writes
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_MODE0_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_MODE1_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_TxMODE0_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_TxMODE1_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_RxMODE_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_INTR_STAT_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_INTR_ENABLE_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_ADDR_HI_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_ADDR_LO_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_VLAN_TPID )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_PAUSE_TIMER_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_INDIVID_HASH1 )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_INDIVID_HASH2 )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_INDIVID_HASH3 )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_INDIVID_HASH4 )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_GROUP_HASH1 )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_GROUP_HASH2 )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_GROUP_HASH3 )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_GROUP_HASH4 )
|
||||
//handle L writes
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_MODE0_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_MODE1_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_TxMODE0_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_TxMODE1_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_RxMODE_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_INTR_STAT_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_INTR_ENABLE_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_ADDR_HI_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_ADDR_LO_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_VLAN_TPID)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_PAUSE_TIMER_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_INDIVID_HASH1)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_INDIVID_HASH2)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_INDIVID_HASH3)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_INDIVID_HASH4)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_GROUP_HASH1)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_GROUP_HASH2)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_GROUP_HASH3)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_GROUP_HASH4)
|
||||
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_LAST_SA_HI )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_LAST_SA_LO )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_INTER_FRAME_GAP_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_STA_CTRL_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_TX_THRESHOLD_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_RX_WATERMARK_L )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_TX_OCTETS )
|
||||
EMAC3_L_WRITE( SMAP_R_EMAC3_RX_OCTETS )
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_LAST_SA_HI)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_LAST_SA_LO)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_INTER_FRAME_GAP_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_STA_CTRL_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_TX_THRESHOLD_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_RX_WATERMARK_L)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_TX_OCTETS)
|
||||
EMAC3_L_WRITE(SMAP_R_EMAC3_RX_OCTETS)
|
||||
|
||||
#define EMAC3_H_WRITE(name) \
|
||||
case name: \
|
||||
#define EMAC3_H_WRITE(name) \
|
||||
case name: \
|
||||
DEV9_LOG("SMAP: " #name " 16 bit write %x\n", value); \
|
||||
dev9Ru16(addr) = value; \
|
||||
emac3_write(addr-2); \
|
||||
dev9Ru16(addr) = value; \
|
||||
emac3_write(addr - 2); \
|
||||
return;
|
||||
//handle H writes
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_MODE0_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_MODE1_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_TxMODE0_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_TxMODE1_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_RxMODE_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_INTR_STAT_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_INTR_ENABLE_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_ADDR_HI_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_ADDR_LO_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_VLAN_TPID+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_PAUSE_TIMER_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_INDIVID_HASH1+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_INDIVID_HASH2+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_INDIVID_HASH3+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_INDIVID_HASH4+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_GROUP_HASH1+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_GROUP_HASH2+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_GROUP_HASH3+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_GROUP_HASH4+2 )
|
||||
//handle H writes
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_MODE0_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_MODE1_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_TxMODE0_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_TxMODE1_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_RxMODE_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_INTR_STAT_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_INTR_ENABLE_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_ADDR_HI_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_ADDR_LO_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_VLAN_TPID + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_PAUSE_TIMER_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_INDIVID_HASH1 + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_INDIVID_HASH2 + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_INDIVID_HASH3 + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_INDIVID_HASH4 + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_GROUP_HASH1 + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_GROUP_HASH2 + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_GROUP_HASH3 + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_GROUP_HASH4 + 2)
|
||||
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_LAST_SA_HI+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_LAST_SA_LO+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_INTER_FRAME_GAP_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_STA_CTRL_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_TX_THRESHOLD_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_RX_WATERMARK_H )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_TX_OCTETS+2 )
|
||||
EMAC3_H_WRITE( SMAP_R_EMAC3_RX_OCTETS+2 )
|
||||
/*
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_LAST_SA_HI + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_LAST_SA_LO + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_INTER_FRAME_GAP_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_STA_CTRL_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_TX_THRESHOLD_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_RX_WATERMARK_H)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_TX_OCTETS + 2)
|
||||
EMAC3_H_WRITE(SMAP_R_EMAC3_RX_OCTETS + 2)
|
||||
/*
|
||||
case SMAP_R_EMAC3_MODE0_L:
|
||||
DEV9_LOG("SMAP: SMAP_R_EMAC3_MODE0 write %x\n", value);
|
||||
dev9Ru16(addr) = value;
|
||||
|
@ -785,52 +786,52 @@ smap_write16(u32 addr, u16 value)
|
|||
return;
|
||||
*/
|
||||
|
||||
default :
|
||||
DEV9_LOG("SMAP : Unknown 16 bit write @ %X,v=%X\n",addr,value);
|
||||
dev9Ru16(addr) = value;
|
||||
return;
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 16 bit write @ %X,v=%X\n", addr, value);
|
||||
dev9Ru16(addr) = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
EXPORT_C_(void)
|
||||
smap_write32(u32 addr, u32 value)
|
||||
{
|
||||
if (addr>=SMAP_EMAC3_REGBASE && addr<SMAP_EMAC3_REGEND)
|
||||
if (addr >= SMAP_EMAC3_REGBASE && addr < SMAP_EMAC3_REGEND)
|
||||
{
|
||||
smap_write16(addr,value&0xFFFF);
|
||||
smap_write16(addr+2,value>>16);
|
||||
smap_write16(addr, value & 0xFFFF);
|
||||
smap_write16(addr + 2, value >> 16);
|
||||
return;
|
||||
}
|
||||
switch(addr)
|
||||
switch (addr)
|
||||
{
|
||||
case SMAP_R_TXFIFO_DATA:
|
||||
if(dev9.bd_swap)
|
||||
value=(value<<24)|(value>>24)|((value>>8)&0xFF00)|((value<<8)&0xFF0000);
|
||||
case SMAP_R_TXFIFO_DATA:
|
||||
if (dev9.bd_swap)
|
||||
value = (value << 24) | (value >> 24) | ((value >> 8) & 0xFF00) | ((value << 8) & 0xFF0000);
|
||||
|
||||
DEV9_LOG("SMAP_R_TXFIFO_DATA 32bit write %x\n", value);
|
||||
*((u32*)(dev9.txfifo+dev9Ru32(SMAP_R_TXFIFO_WR_PTR)))=value;
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR) = (dev9Ru32(SMAP_R_TXFIFO_WR_PTR)+4)&16383;
|
||||
return;
|
||||
default :
|
||||
DEV9_LOG("SMAP : Unknown 32 bit write @ %X,v=%X\n",addr,value);
|
||||
dev9Ru32(addr) = value;
|
||||
return;
|
||||
DEV9_LOG("SMAP_R_TXFIFO_DATA 32bit write %x\n", value);
|
||||
*((u32*)(dev9.txfifo + dev9Ru32(SMAP_R_TXFIFO_WR_PTR))) = value;
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR) = (dev9Ru32(SMAP_R_TXFIFO_WR_PTR) + 4) & 16383;
|
||||
return;
|
||||
default:
|
||||
DEV9_LOG("SMAP : Unknown 32 bit write @ %X,v=%X\n", addr, value);
|
||||
dev9Ru32(addr) = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
EXPORT_C_(void)
|
||||
smap_readDMA8Mem(u32 *pMem, int size)
|
||||
smap_readDMA8Mem(u32* pMem, int size)
|
||||
{
|
||||
if(dev9Ru16(SMAP_R_RXFIFO_CTRL)&SMAP_RXFIFO_DMAEN)
|
||||
if (dev9Ru16(SMAP_R_RXFIFO_CTRL) & SMAP_RXFIFO_DMAEN)
|
||||
{
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR)&=16383;
|
||||
size>>=1;
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR) &= 16383;
|
||||
size >>= 1;
|
||||
DEV9_LOG(" * * SMAP DMA READ START: rd_ptr=%d, wr_ptr=%d\n", dev9Ru32(SMAP_R_RXFIFO_RD_PTR), dev9.rxfifo_wr_ptr);
|
||||
while(size>0)
|
||||
while (size > 0)
|
||||
{
|
||||
*pMem = *((u32*)(dev9.rxfifo+dev9Ru32(SMAP_R_RXFIFO_RD_PTR)));
|
||||
*pMem = *((u32*)(dev9.rxfifo + dev9Ru32(SMAP_R_RXFIFO_RD_PTR)));
|
||||
pMem++;
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR) = (dev9Ru32(SMAP_R_RXFIFO_RD_PTR)+4)&16383;
|
||||
|
||||
size-=4;
|
||||
dev9Ru32(SMAP_R_RXFIFO_RD_PTR) = (dev9Ru32(SMAP_R_RXFIFO_RD_PTR) + 4) & 16383;
|
||||
|
||||
size -= 4;
|
||||
}
|
||||
DEV9_LOG(" * * SMAP DMA READ END: rd_ptr=%d, wr_ptr=%d\n", dev9Ru32(SMAP_R_RXFIFO_RD_PTR), dev9.rxfifo_wr_ptr);
|
||||
|
||||
|
@ -840,25 +841,24 @@ smap_readDMA8Mem(u32 *pMem, int size)
|
|||
EXPORT_C_(void)
|
||||
smap_writeDMA8Mem(u32* pMem, int size)
|
||||
{
|
||||
if(dev9Ru16(SMAP_R_TXFIFO_CTRL)&SMAP_TXFIFO_DMAEN)
|
||||
if (dev9Ru16(SMAP_R_TXFIFO_CTRL) & SMAP_TXFIFO_DMAEN)
|
||||
{
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR)&=16383;
|
||||
size>>=1;
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR) &= 16383;
|
||||
size >>= 1;
|
||||
DEV9_LOG(" * * SMAP DMA WRITE START: wr_ptr=%d, rd_ptr=%d\n", dev9Ru32(SMAP_R_TXFIFO_WR_PTR), dev9.txfifo_rd_ptr);
|
||||
while(size>0)
|
||||
while (size > 0)
|
||||
{
|
||||
int value=*pMem;
|
||||
int value = *pMem;
|
||||
// value=(value<<24)|(value>>24)|((value>>8)&0xFF00)|((value<<8)&0xFF0000);
|
||||
pMem++;
|
||||
|
||||
*((u32*)(dev9.txfifo+dev9Ru32(SMAP_R_TXFIFO_WR_PTR)))=value;
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR) = (dev9Ru32(SMAP_R_TXFIFO_WR_PTR)+4)&16383;
|
||||
size-=4;
|
||||
*((u32*)(dev9.txfifo + dev9Ru32(SMAP_R_TXFIFO_WR_PTR))) = value;
|
||||
dev9Ru32(SMAP_R_TXFIFO_WR_PTR) = (dev9Ru32(SMAP_R_TXFIFO_WR_PTR) + 4) & 16383;
|
||||
size -= 4;
|
||||
}
|
||||
DEV9_LOG(" * * SMAP DMA WRITE END: wr_ptr=%d, rd_ptr=%d\n", dev9Ru32(SMAP_R_TXFIFO_WR_PTR), dev9.txfifo_rd_ptr);
|
||||
|
||||
dev9Ru16(SMAP_R_TXFIFO_CTRL) &= ~SMAP_TXFIFO_DMAEN;
|
||||
|
||||
}
|
||||
}
|
||||
EXPORT_C_(void)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
* 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-
|
||||
|
@ -31,8 +31,8 @@ EXPORT_C_(void)
|
|||
smap_write32(u32 addr, u32 value);
|
||||
|
||||
EXPORT_C_(void)
|
||||
smap_readDMA8Mem(u32 *pMem, int size);
|
||||
smap_readDMA8Mem(u32* pMem, int size);
|
||||
EXPORT_C_(void)
|
||||
smap_writeDMA8Mem(u32 *pMem, int size);
|
||||
smap_writeDMA8Mem(u32* pMem, int size);
|
||||
EXPORT_C_(void)
|
||||
smap_async(u32 cycles);
|
||||
|
|
Loading…
Reference in New Issue