From b1f59befc06e66050c73674a627071c189683001 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 24 Sep 2016 14:24:27 +0300 Subject: [PATCH] Expansion Systems Dataflyer+ --- idecontrollers.cpp | 121 ++++++++++++++++++++++++++++++++++++++- include/idecontrollers.h | 3 + include/rommgr.h | 4 +- include/scsi.h | 3 + rommgr.cpp | 4 +- scsi.cpp | 66 +++++++++++++++++---- 6 files changed, 186 insertions(+), 15 deletions(-) diff --git a/idecontrollers.cpp b/idecontrollers.cpp index 24f76aef..4a7b4d1e 100644 --- a/idecontrollers.cpp +++ b/idecontrollers.cpp @@ -45,7 +45,8 @@ #define x86_AT_IDE (ROCHARD_IDE + 2 * MAX_DUPLICATE_EXPANSION_BOARDS) #define GOLEMFAST_IDE (x86_AT_IDE + 2 * MAX_DUPLICATE_EXPANSION_BOARDS) #define BUDDHA_IDE (GOLEMFAST_IDE + 2 * MAX_DUPLICATE_EXPANSION_BOARDS) -#define TOTAL_IDE (BUDDHA_IDE + 3 * MAX_DUPLICATE_EXPANSION_BOARDS) +#define DATAFLYERPLUS_IDE (BUDDHA_IDE + 3 * MAX_DUPLICATE_EXPANSION_BOARDS) +#define TOTAL_IDE (DATAFLYERPLUS_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) #define ALF_ROM_OFFSET 0x0100 #define GVP_IDE_ROM_OFFSET 0x8000 @@ -97,6 +98,7 @@ static struct ide_board *rochard_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *x86_at_ide_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *golemfast_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *buddha_board[MAX_DUPLICATE_EXPANSION_BOARDS]; +static struct ide_board *dataflyerplus_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_hdf *idecontroller_drive[TOTAL_IDE * 2]; static struct ide_thread_state idecontroller_its; @@ -352,11 +354,11 @@ static void put_ide_reg_multi(struct ide_board *board, int reg, uae_u32 v, int p } static uae_u32 get_ide_reg(struct ide_board *board, int reg) { - return get_ide_reg_multi(board, reg, 0, 1); + return get_ide_reg_multi(board, reg, 0, reg == 0 ? 1 : 0); } static void put_ide_reg(struct ide_board *board, int reg, uae_u32 v) { - put_ide_reg_multi(board, reg, v, 0, 1); + put_ide_reg_multi(board, reg, v, 0, reg == 0 ? 1 : 0); } static uae_u32 get_ide_reg_8bitdata(struct ide_board *board, int reg) { @@ -467,6 +469,15 @@ static int get_rochard_reg(uaecptr addr, struct ide_board *board, int *portnum) return reg; } +static int get_dataflyerplus_reg(uaecptr addr, struct ide_board *board) +{ + int reg = -1; + if (!(addr & 0x8000)) + return -1; + reg = (addr / 0x40) & 7; + return reg; +} + static int get_golemfast_reg(uaecptr addr, struct ide_board *board) { int reg = -1; @@ -689,6 +700,22 @@ static uae_u32 ide_read_byte(struct ide_board *board, uaecptr addr) v = board->rom[addr & board->rom_mask]; + } else if (board->type == DATAFLYERPLUS_IDE) { + + v = board->rom[addr & board->rom_mask]; + if (board->configured) { + if (addr == 0x10) { + v = ide_irq_check(board->ide[0], false) ? 0x08 : 0x00; + } else if (addr < 0x80) { + v = rochard_scsi_get(oaddr); + } + } + if (addr & 0x8000) { + int regnum = get_dataflyerplus_reg(addr, board); + if (regnum >= 0) + v = get_ide_reg(board, regnum); + } + } else if (board->type == ROCHARD_IDE) { if (addr & 0x8000) { @@ -733,6 +760,16 @@ static uae_u32 ide_read_word(struct ide_board *board, uaecptr addr) } } + } else if (board->type == DATAFLYERPLUS_IDE) { + + if (!(addr & 0x8000)) { + if (board->rom) { + v = board->rom[(addr + 0) & board->rom_mask]; + v <<= 8; + v |= board->rom[(addr + 1) & board->rom_mask]; + } + } + } else if (board->type == ROCHARD_IDE) { if (addr < 8192) { @@ -867,6 +904,14 @@ static uae_u32 ide_read_word(struct ide_board *board, uaecptr addr) v = ide_read_byte(board, addr) << 8; } + } else if (board->type == DATAFLYERPLUS_IDE) { + + if (board->configured) { + int reg = get_dataflyerplus_reg(addr, board); + if (reg >= 0) + v = get_ide_reg_multi(board, reg, 0, 1); + } + } else if (board->type == ROCHARD_IDE) { if (board->configured && (addr & 0x8020) == 0x8000) { @@ -905,6 +950,8 @@ static void ide_write_byte(struct ide_board *board, uaecptr addr, uae_u8 v) ncr_masoboshi_autoconfig_init(board->original_rc, board->baseaddress); } else if (board->type == GOLEMFAST_IDE) { ncr_golemfast_autoconfig_init(board->original_rc, board->baseaddress); + } else if (board->type == DATAFLYERPLUS_IDE) { + dataflyerplus_scsi_init(board->original_rc, board->baseaddress); } expamem_next(ab, NULL); return; @@ -1018,6 +1065,18 @@ static void ide_write_byte(struct ide_board *board, uaecptr addr, uae_u8 v) put_ide_reg(board, (addr >> 8) & 7, v); } + } else if (board->type == DATAFLYERPLUS_IDE) { + + if (board->configured) { + if (addr & 0x8000) { + int regnum = get_dataflyerplus_reg(addr, board); + if (regnum >= 0) + put_ide_reg(board, regnum, v); + } else if (addr < 0x80) { + rochard_scsi_put(oaddr, v); + } + } + } else if (board->type == ROCHARD_IDE) { if (board->configured) { @@ -1152,6 +1211,14 @@ static void ide_write_word(struct ide_board *board, uaecptr addr, uae_u16 v) ide_write_byte(board, addr, v >> 8); } + } else if (board->type == DATAFLYERPLUS_IDE) { + + if (board->configured) { + int reg = get_dataflyerplus_reg(addr, board); + if (reg >= 0) + put_ide_reg_multi(board, reg, v, 0, 1); + } + } else if (board->type == ROCHARD_IDE) { if (board->configured && (addr & 0x8020) == 0x8000) { @@ -1784,6 +1851,54 @@ void golemfast_add_idescsi_unit(int ch, struct uaedev_config_info *ci, struct ro } } +bool dataflyerplus_init(struct autoconfig_info *aci) +{ + int rom_size = 16384; + uae_u8 *rom; + + rom = xcalloc(uae_u8, rom_size); + memset(rom, 0xff, rom_size); + load_rom_rc(aci->rc, ROMTYPE_DATAFLYER, 32768, aci->rc->autoboot_disabled ? 8192 : 0, rom, 16384, LOADROM_EVENONLY_ODDONE); + + if (!aci->doinit) { + memcpy(aci->autoconfig_raw, rom, sizeof aci->autoconfig_raw); + xfree(rom); + return true; + } + + struct ide_board *ide = getide(aci->rc); + + ide->rom = rom; + ide->configured = 0; + ide->bank = &ide_bank_generic; + ide->rom_size = rom_size; + ide->mask = 65536 - 1; + ide->keepautoconfig = false; + + ide->rom_mask = ide->rom_size - 1; + memcpy(ide->acmemory, ide->rom, sizeof ide->acmemory); + aci->addrbank = ide->bank; + + return true; +} + +static void dataflyerplus_add_ide_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc) +{ + add_ide_standard_unit(ch, ci, rc, dataflyerplus_board, DATAFLYERPLUS_IDE, true, false, 2); +} + +void dataflyerplus_add_idescsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc) +{ + if (ch < 0) { + dataflyerplus_add_ide_unit(ch, ci, rc); + dataflyerplus_add_scsi_unit(ch, ci, rc); + } else { + if (ci->controller_type < HD_CONTROLLER_TYPE_SCSI_FIRST) + dataflyerplus_add_ide_unit(ch, ci, rc); + else + dataflyerplus_add_scsi_unit(ch, ci, rc); + } +} extern void x86_xt_ide_bios(struct zfile*, struct romconfig*); static bool x86_at_hd_init(struct autoconfig_info *aci, int type) diff --git a/include/idecontrollers.h b/include/idecontrollers.h index a4e5396b..38d5e222 100644 --- a/include/idecontrollers.h +++ b/include/idecontrollers.h @@ -39,6 +39,9 @@ void golemfast_add_idescsi_unit(int ch, struct uaedev_config_info *ci, struct ro bool buddha_init(struct autoconfig_info *aci); void buddha_add_ide_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); +bool dataflyerplus_init(struct autoconfig_info *aci); +void dataflyerplus_add_idescsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); + uae_u32 REGPARAM3 apollo_ide_lget (uaecptr addr) REGPARAM; uae_u32 REGPARAM3 apollo_ide_wget (uaecptr addr) REGPARAM; uae_u32 REGPARAM3 apollo_ide_bget (uaecptr addr) REGPARAM; diff --git a/include/rommgr.h b/include/rommgr.h index 8b394278..2be49a31 100644 --- a/include/rommgr.h +++ b/include/rommgr.h @@ -79,7 +79,7 @@ extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size); #define ROMTYPE_ROCHARD 0x0010001a #define ROMTYPE_CLTDSCSI 0x0010001b #define ROMTYPE_PTNEXUS 0x0010001c -#define ROMTYPE_DATAFLYER 0x0010001d +#define ROMTYPE_DATAFLYERP 0x0010001d #define ROMTYPE_SUPRADMA 0x0010001e #define ROMTYPE_GREX 0x0010001f #define ROMTYPE_PROMETHEUS 0x00100020 @@ -135,6 +135,8 @@ extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size); #define ROMTYPE_SCRAM5380 0x00100052 #define ROMTYPE_SCRAM5394 0x00100053 #define ROMTYPE_OSSI 0x00100054 +#define ROMTYPE_HARLEQUIN 0x00100055 +#define ROMTYPE_DATAFLYER 0x00100056 #define ROMTYPE_NOT 0x00800000 #define ROMTYPE_QUAD 0x01000000 diff --git a/include/scsi.h b/include/scsi.h index 206d0c17..554db5e1 100644 --- a/include/scsi.h +++ b/include/scsi.h @@ -218,6 +218,9 @@ void ptnexus_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconf bool dataflyer_init(struct autoconfig_info *aci); void dataflyer_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); +bool dataflyerplus_scsi_init(struct romconfig *rc, uaecptr baseaddress); +void dataflyerplus_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); + bool tecmar_init(struct autoconfig_info *aci); void tecmar_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); diff --git a/rommgr.cpp b/rommgr.cpp index 0c6903cc..c4504f78 100644 --- a/rommgr.cpp +++ b/rommgr.cpp @@ -95,7 +95,7 @@ struct romdata *getromdatabypath (const TCHAR *path) return NULL; } -#define NEXT_ROM_ID 169 +#define NEXT_ROM_ID 170 #define ALTROM(id,grp,num,size,flags,crc32,a,b,c,d,e) \ { _T("X"), 0, 0, 0, 0, 0, size, id, 0, 0, flags, (grp << 16) | num, 0, NULL, crc32, a, b, c, d, e }, @@ -463,6 +463,8 @@ static struct romdata roms[] = { 0x1f672e4b, 0xb20d50b8, 0x31ec9823, 0xfa732fc6, 0x522ecc6a, 0xae36ec33, NULL, NULL }, { _T("IVS GramdSlam/Trumpcard Pro v4.9"), 4, 9, 4, 9, _T("IVSPRO\0"), 16384, 161, 0, 0, ROMTYPE_IVSTPRO, 0, 0, NULL, 0x4a15f224, 0x29500b47, 0x289e84ac, 0x575e3c7d, 0x82199b45, 0x605d8fc9, NULL, NULL }, + { _T("Expansion Systems Dataflyer+ v2.1"), 2, 1, 2, 1, _T("DATAFLYERPLUS\0"), 32768, 169, 0, 0, ROMTYPE_DATAFLYER, 0, 0, NULL, + 0xc49daa65, 0x20275716, 0xdc7eb00e, 0x5dc53680, 0xb5c8a90a, 0x7c00e390, NULL, NULL }, { _T("CyberStorm MK I 68040"), 0, 0, 0, 0, _T("CSMKI\0"), 32768, 95, 0, 0, ROMTYPE_CB_CSMK1, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk1_040.rom") }, diff --git a/scsi.cpp b/scsi.cpp index b4cf7b28..b9b2a62a 100644 --- a/scsi.cpp +++ b/scsi.cpp @@ -58,7 +58,8 @@ #define NCR5380_IVSVECTOR 27 // nearly identical to trumpcard pro #define NCR5380_SCRAM 28 #define NCR5380_OSSI 29 -#define NCR_LAST 30 +#define NCR5380_DATAFLYERPLUS 30 +#define NCR_LAST 31 extern int log_scsiemu; @@ -359,8 +360,9 @@ void scsi_emulate_cmd(struct scsi_data *sd) sd->cmd[1] |= lun << 5; } #if SCSI_EMU_DEBUG - write_log (_T("CMD=%02x.%02x.%02x.%02x.%02x.%02x (%d,%d)\n"), - sd->cmd[0], sd->cmd[1], sd->cmd[2], sd->cmd[3], sd->cmd[4], sd->cmd[5], sd->device_type, sd->nativescsiunit); + write_log (_T("CMD=%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x (%d,%d)\n"), + sd->cmd[0], sd->cmd[1], sd->cmd[2], sd->cmd[3], sd->cmd[4], sd->cmd[5], sd->cmd[6], sd->cmd[7], sd->cmd[8], sd->cmd[9], + sd->device_type, sd->nativescsiunit); #endif if (sd->device_type == UAEDEV_CD && sd->cd_emu_unit >= 0) { uae_u32 ua = 0; @@ -2157,6 +2159,18 @@ static int trumpcardpro_reg(struct soft_scsi *ncr, uaecptr addr, bool vector) addr &= 7; return addr; } + +static int dataflyerplus_reg(uaecptr addr) +{ + if (!(addr & 1)) + return -1; + if (addr == 0x41) + return 8; + if (addr >= 0x10) + return -1; + return (addr >> 1) & 7; +} + static uae_u8 read_supra_dma(struct soft_scsi *ncr, uaecptr addr) { uae_u8 val = 0; @@ -2582,6 +2596,14 @@ static uae_u32 ncr80_bget2(struct soft_scsi *ncr, uaecptr addr, int size) reg = addr & 0xff; v = ncr5380_bget(ncr, reg); + } else if (ncr->type == NCR5380_DATAFLYERPLUS) { + + if (addr < 0x80 && ncr->configured) { + reg = dataflyerplus_reg(addr); + if (reg >= 0) + v = ncr5380_bget(ncr, reg); + } + } else if (ncr->type == NONCR_TECMAR) { v = ncr->rom[addr]; @@ -2725,7 +2747,7 @@ static uae_u32 ncr80_bget2(struct soft_scsi *ncr, uaecptr addr, int size) } #if NCR5380_DEBUG > 1 - if (!(origaddr & 0x8000)) + if (1 || origaddr >= 0x8000) write_log(_T("GET %08x %02x %d %08x %d\n"), origaddr, v, reg, M68K_GETPC, regs.intmask); #endif @@ -2736,7 +2758,7 @@ static void ncr80_bput2(struct soft_scsi *ncr, uaecptr addr, uae_u32 val, int si { int reg = -1; int addresstype = -1; - uaecptr origddr = addr; + uaecptr origaddr = addr; addr &= ncr->board_mask; @@ -2814,7 +2836,7 @@ static void ncr80_bput2(struct soft_scsi *ncr, uaecptr addr, uae_u32 val, int si } else if (ncr->type == NONCR_KOMMOS) { struct raw_scsi *rs = &ncr->rscsi; - if (!(addr & 0x8000) && (origddr & 0xf00000) != 0xf00000) { + if (!(addr & 0x8000) && (origaddr & 0xf00000) != 0xf00000) { if (!(addr & 8)) { raw_scsi_put_data(rs, val, true); } else { @@ -2892,6 +2914,15 @@ static void ncr80_bput2(struct soft_scsi *ncr, uaecptr addr, uae_u32 val, int si reg = addr & 0xff; ncr5380_bput(ncr, reg, val); + } else if (ncr->type == NCR5380_DATAFLYERPLUS) { + + if (ncr->configured && addr < 0x80) { + reg = dataflyerplus_reg(addr); + if (reg >= 0) { + ncr5380_bput(ncr, reg, val); + } + } + } else if (ncr->type == NONCR_TECMAR) { if (addr == 0x22) { @@ -3022,8 +3053,8 @@ static void ncr80_bput2(struct soft_scsi *ncr, uaecptr addr, uae_u32 val, int si } #if NCR5380_DEBUG > 1 - if (1) - write_log(_T("PUT %08x %02x %d %08x %d\n"), origddr, val, reg, M68K_GETPC, regs.intmask); + if (1 || origaddr >= 0x8000) + write_log(_T("PUT %08x %02x %d %08x %d\n"), origaddr, val, reg, M68K_GETPC, regs.intmask); #endif } @@ -3562,11 +3593,12 @@ void trumpcardpro_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct ro bool rochard_scsi_init(struct romconfig *rc, uaecptr baseaddress) { struct soft_scsi *scsi = getscsi(rc); - scsi->configured = 1; + scsi->configured = true; scsi->dma_controller = true; scsi->baseaddress = baseaddress; return scsi != NULL; } + void rochard_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc) { generic_soft_scsi_add(ch, ci, rc, NCR5380_ROCHARD, 65536, -1, ROMTYPE_ROCHARD); @@ -3659,7 +3691,7 @@ bool dataflyer_init(struct autoconfig_info *aci) void dataflyer_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc) { - generic_soft_scsi_add(ch, ci, rc, NCR5380_DATAFLYER, 4096, 0, ROMTYPE_DATAFLYER); + generic_soft_scsi_add(ch, ci, rc, NCR5380_DATAFLYER, 4096, 0, ROMTYPE_DATAFLYERP); } static void expansion_add_protoautoconfig_data(uae_u8 *p, uae_u16 manufacturer_id, uae_u8 product_id) @@ -4097,3 +4129,17 @@ void ossi_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig { generic_soft_scsi_add(ch, ci, rc, NCR5380_OSSI, 65536, 16384, ROMTYPE_OSSI); } + +bool dataflyerplus_scsi_init(struct romconfig *rc, uaecptr baseaddress) +{ + struct soft_scsi *scsi = getscsi(rc); + scsi->configured = true; + scsi->baseaddress = baseaddress; + scsi->intena = true; + return scsi != NULL; +} + +void dataflyerplus_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc) +{ + generic_soft_scsi_add(ch, ci, rc, NCR5380_DATAFLYERPLUS, 65536, -1, ROMTYPE_DATAFLYER); +} -- 2.47.3