Skip to content

Commit

Permalink
Added workaround for bad GameStar adaptors into DEV9.
Browse files Browse the repository at this point in the history
  • Loading branch information
sp193 authored and Liu Woon Yung committed Jan 11, 2018
1 parent c5de51c commit 48a5a34
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
15 changes: 11 additions & 4 deletions iop/dev9/dev9/Makefile
Expand Up @@ -6,16 +6,23 @@
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

#Enable to disable initialization of SMAP within DEV9 (i.e. clone adaptor compatibility).
SKIP_SMAP_INIT ?= 0
#Enable to entirely disable initialization of SMAP within DEV9.
DEV9_SKIP_SMAP_INIT ?= 0

#Disable to disable the workaround (skip SMAP initialization) for bad GameStar compatible adaptors.
DEV9_GAMESTAR_WORKAROUND ?= 1

IOP_BIN ?= ps2dev9.irx

IOP_INCS += -I$(PS2SDKSRC)/iop/dev9/poweroff/include
IOP_OBJS = ps2dev9.o exports.o imports.o

ifeq ($(SKIP_SMAP_INIT),1)
IOP_CFLAGS += -DSKIP_SMAP_INIT=1
ifeq ($(DEV9_SKIP_SMAP_INIT),1)
IOP_CFLAGS += -DDEV9_SKIP_SMAP_INIT=1
endif

ifeq ($(DEV9_GAMESTAR_WORKAROUND),1)
IOP_CFLAGS += -DDEV9_GAMESTAR_WORKAROUND=1
endif

include $(PS2SDKSRC)/Defs.make
Expand Down
17 changes: 12 additions & 5 deletions iop/dev9/dev9/src/ps2dev9.c
Expand Up @@ -584,7 +584,7 @@ static int dev9_init(int sema_attr)
return 0;
}

#ifndef SKIP_SMAP_INIT
#ifndef DEV9_SKIP_SMAP_INIT
static int dev9_smap_read_phy(volatile u8 *emac3_regbase, unsigned int address, unsigned int *data){
unsigned int i, PHYRegisterValue;
int result;
Expand Down Expand Up @@ -645,7 +645,14 @@ static int dev9_smap_init(void)
int i;

//Do not perform SMAP initialization if the SPEED device does not have such an interface
if (!(SPD_REG16(SPD_R_REV_3)&SPD_CAPS_SMAP)) return 0;
if (!(SPD_REG16(SPD_R_REV_3)&SPD_CAPS_SMAP)
#ifdef DEV9_GAMESTAR_WORKAROUND
/* If this adaptor is a GameStar compatible adaptor, do not initialize SMAP.
A GameStar masquerades as a SCPH-10281, but does not have SMAP implemented correctly.
All official adaptors appear to have different values for these two registers, but not the GameStar. */
|| (SPD_REG16(SPD_R_REV) == SPD_REG16(SPD_R_REV_3))
#endif
) return 0;

SMAP_REG8(SMAP_R_TXFIFO_CTRL) = SMAP_TXFIFO_RESET;
for(i = 9; SMAP_REG8(SMAP_R_TXFIFO_CTRL)&SMAP_TXFIFO_RESET; i--)
Expand Down Expand Up @@ -743,13 +750,13 @@ static int speed_device_init(void)
const char *spdnames[] = { "(unknown)", "TS", "ES1", "ES2" };
int idx, res;
u16 spdrev;
#ifndef SKIP_SMAP_INIT
#ifndef DEV9_SKIP_SMAP_INIT
int i;
#endif

eeprom_data[0] = 0;

#ifndef SKIP_SMAP_INIT
#ifndef DEV9_SKIP_SMAP_INIT
for(i = 0; i < 8; i++) {
#endif
if (dev9_device_probe() < 0) {
Expand All @@ -772,7 +779,7 @@ static int speed_device_init(void)
return -1;
}

#ifndef SKIP_SMAP_INIT
#ifndef DEV9_SKIP_SMAP_INIT
if((res = dev9_smap_init()) == 0){
break;
}
Expand Down

0 comments on commit 48a5a34

Please sign in to comment.