From c5dd18d75fe54ac681d44e2ff8df001259d0653d Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Thu, 3 Aug 2017 20:17:01 +0300 Subject: [PATCH] Emplant SCSI controller --- expansion.cpp | 9 ++++++ include/rommgr.h | 1 + include/scsi.h | 3 ++ scsi.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/expansion.cpp b/expansion.cpp index 4f4cbed2..c7ae0d3a 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -4841,6 +4841,15 @@ const struct expansionromtype expansionroms[] = { supra_sub, 0, true, EXPANSIONTYPE_SCSI }, + { + _T("emplant"), _T("Emplant (SCSI only)"), _T("Utilities Unlimited"), + NULL, emplant_init, NULL, emplant_add_scsi_unit, ROMTYPE_EMPLANT | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false, + NULL, 0, + false, EXPANSIONTYPE_SCSI, + 0, 0, 0, false, NULL, + false, 0, NULL, + { 0xd1, 0x15, 0x40, 0x00, 0x08, 0x7b, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00 }, + }, #if 0 /* driver is MIA, 3rd party ScottDevice driver is not enough for full implementation. */ { NULL, _T("microforge"), _T("Hard Disk"), _T("Micro Forge"), diff --git a/include/rommgr.h b/include/rommgr.h index c7e852c0..69f03a88 100644 --- a/include/rommgr.h +++ b/include/rommgr.h @@ -157,6 +157,7 @@ extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size); #define ROMTYPE_A2090B 0x00100067 #define ROMTYPE_FASTATA4K 0x00100068 #define ROMTYPE_INMATE 0x00100069 +#define ROMTYPE_EMPLANT 0x0010006a #define ROMTYPE_NOT 0x00800000 #define ROMTYPE_QUAD 0x01000000 diff --git a/include/scsi.h b/include/scsi.h index 49634c32..f05d8c06 100644 --- a/include/scsi.h +++ b/include/scsi.h @@ -271,6 +271,9 @@ void addhard_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconf bool inmate_init(struct autoconfig_info*); void inmate_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); +bool emplant_init(struct autoconfig_info*); +void emplant_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc); + uae_u8 idescsi_scsi_get(uaecptr addr); void idescsi_scsi_put(uaecptr addr, uae_u8 v); diff --git a/scsi.cpp b/scsi.cpp index d8d29d96..b1bd7937 100644 --- a/scsi.cpp +++ b/scsi.cpp @@ -63,7 +63,8 @@ #define NCR5380_MALIBU 32 #define NCR5380_ADDHARD 33 #define NONCR_INMATE 34 -#define NCR_LAST 35 +#define NCR5380_EMPLANT 35 +#define NCR_LAST 36 extern int log_scsiemu; @@ -762,6 +763,7 @@ struct soft_scsi int subtype; int dma_direction; bool dma_active; + bool dma_started; bool dma_controller; struct romconfig *rc; struct soft_scsi **self_ptr; @@ -1902,6 +1904,7 @@ void ncr5380_bput(struct soft_scsi *scsi, int reg, uae_u8 v) if (scsi->regs[2] & 2) { scsi->dma_direction = 1; scsi->dma_active = true; + scsi->dma_started = true; } #if NCR5380_DEBUG write_log(_T("DMA target recv PC=%08x\n"), M68K_GETPC); @@ -1911,6 +1914,7 @@ void ncr5380_bput(struct soft_scsi *scsi, int reg, uae_u8 v) if (scsi->regs[2] & 2) { scsi->dma_direction = -1; scsi->dma_active = true; + scsi->dma_started = true; dma_check(scsi); } #if NCR5380_DEBUG @@ -2478,6 +2482,19 @@ static int addhardreg(uaecptr addr) return addr; } +static int emplantreg(uaecptr addr) +{ + if (addr & 1) + return -1; + if ((addr & 0xf000) == 0x6000) + return 8; + if ((addr & 0xf000) != 0x5000) + return -1; + addr >>= 4; + addr &= 7; + return addr; +} + static int malibureg(uaecptr addr) { if ((addr & 0xc000) == 0x8000) @@ -2662,6 +2679,19 @@ static uae_u32 ncr80_bget2(struct soft_scsi *ncr, uaecptr addr, int size) } } + } else if (ncr->type == NCR5380_EMPLANT) { + + if ((addr & 0xf000) >= 0xc000) { + v = ncr->rom[addr & 0x3fff]; + } else { + reg = emplantreg(addr); + if (reg == 8 && !ncr->dma_active) + reg = -1; + if (reg >= 0) { + v = ncr5380_bget(ncr, reg); + } + } + } else if (ncr->type == NONCR_HARDFRAME) { if (addr == 0xc0) { @@ -3166,6 +3196,21 @@ static void ncr80_bput2(struct soft_scsi *ncr, uaecptr addr, uae_u32 val, int si } } + } else if (ncr->type == NCR5380_EMPLANT) { + + reg = emplantreg(addr); + if (reg == 8 && !ncr->dma_active) + reg = -1; + if (reg >= 0) { + ncr5380_bput(ncr, reg, val); + } else if ((addr & 0xff00) == 0x3800) { + if ((val & 0x88) == 0x88) { + ncr->intena = true; + } else if ((val & 0x88) == 0x08) { + ncr->intena = false; + } + } + } else if (ncr->type == NONCR_HARDFRAME) { if (addr == 0xc0) { @@ -4680,3 +4725,29 @@ void addhard_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconf { generic_soft_scsi_add(ch, ci, rc, NCR5380_ADDHARD, 65536, 32768, ROMTYPE_ADDHARD); } + +bool emplant_init(struct autoconfig_info *aci) +{ + const struct expansionromtype *ert = get_device_expansion_rom(ROMTYPE_EMPLANT); + if (!aci->doinit) { + aci->autoconfigp = ert->autoconfig; + return true; + } + + struct soft_scsi *scsi = getscsi(aci->rc); + if (!scsi) + return false; + + load_rom_rc(aci->rc, ROMTYPE_EMPLANT, 8192, 0, scsi->rom, 16384, LOADROM_EVENONLY_ODDONE); + for (int i = 0; i < 16; i++) { + uae_u8 b = ert->autoconfig[i]; + ew(scsi, i * 4, b); + } + aci->addrbank = scsi->bank; + return true; +} + +void emplant_add_scsi_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc) +{ + generic_soft_scsi_add(ch, ci, rc, NCR5380_EMPLANT, 65536, 16384, ROMTYPE_EMPLANT); +} -- 2.47.3