Skip to content

Commit

Permalink
(ATAD) Added Makefile options for DMA Enable compatibility (for clone…
Browse files Browse the repository at this point in the history
…/compatible network adaptors).
  • Loading branch information
sp193 committed Jul 25, 2017
1 parent a5b16ed commit 7faf72a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions iop/dev9/atad/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

#Enable to support compatible adaptors by enabling/disabling DMA as in the old ATAD design.
ATA_COMPAT_COMPAT ?= 0

#Enable to perform the SCE HDD check at the end of ATA device initialization.
ATA_SCE_AUTH_HDD ?= 0

Expand All @@ -20,6 +23,10 @@ IOP_BIN ?= ps2atad.irx
IOP_INCS += -I$(PS2SDKSRC)/iop/dev9/dev9/include
IOP_OBJS = ps2atad.o imports.o exports.o

ifeq ($(ATA_COMPAT_COMPAT),1)
IOP_CFLAGS += -DATA_DMAEN_COMPAT=1
endif

ifeq ($(ATA_SCE_AUTH_HDD),1)
IOP_CFLAGS += -DATA_SCE_AUTH_HDD=1
endif
Expand Down
21 changes: 16 additions & 5 deletions iop/dev9/atad/src/ps2atad.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,25 @@ static void ata_ultra_dma_mode(int mode);

extern struct irx_export_table _exp_atad;

#ifndef ATA_DMAEN_COMPAT
//In v1.04, DMA was enabled in ata_set_dir() instead.
static void AtadPreDmaCb(int bcr, int dir){
static void ata_pre_dma_cb(int bcr, int dir)
{
USE_SPD_REGS;

SPD_REG16(SPD_R_XFR_CTRL)|=0x80;
}

static void AtadPostDmaCb(int bcr, int dir){
static void ata_post_dma_cb(int bcr, int dir)
{
USE_SPD_REGS;

SPD_REG16(SPD_R_XFR_CTRL)&=~0x80;
}
#endif

static int ata_create_event_flag(void) {
static int ata_create_event_flag(void)
{
iop_event_t event;

event.attr = EA_SINGLE; //In v1.04, EA_MULTI was specified.
Expand Down Expand Up @@ -228,8 +233,10 @@ int _start(int argc, char *argv[])
/* In v1.04, PIO mode 0 was set here. In late versions, it is set in ata_init_devices(). */
dev9RegisterIntrCb(1, &ata_intr_cb);
dev9RegisterIntrCb(0, &ata_intr_cb);
dev9RegisterPreDmaCb(0, &AtadPreDmaCb);
dev9RegisterPostDmaCb(0, &AtadPostDmaCb);
#ifndef ATA_DMAEN_COMPAT
dev9RegisterPreDmaCb(0, &ata_pre_dma_cb);
dev9RegisterPostDmaCb(0, &ata_post_dma_cb);
#endif

if ((res = RegisterLibraryEntries(&_exp_atad)) != 0) {
M_PRINTF("Library is already registered, exiting.\n");
Expand Down Expand Up @@ -1056,7 +1063,11 @@ static void ata_set_dir(int dir)
val = SPD_REG16(SPD_R_IF_CTRL) & 1;
val |= (dir == ATA_DIR_WRITE) ? 0x4c : 0x4e;
SPD_REG16(SPD_R_IF_CTRL) = val;
#ifdef ATA_DMAEN_COMPAT
SPD_REG16(SPD_R_XFR_CTRL) = dir | 0x86;
#else
SPD_REG16(SPD_R_XFR_CTRL) = dir | 0x6; //In v1.04, DMA was enabled here (0x86 instead of 0x6)
#endif
}

static void ata_pio_mode(int mode)
Expand Down

0 comments on commit 7faf72a

Please sign in to comment.