From 88449d6055dfdce4204da0a85f54ce50ea2bd835 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Thu, 3 Jan 2019 11:47:37 +0100 Subject: [PATCH] indy_indigo2: Switch to using new wd33c9x core, nw --- src/devices/machine/nscsi_bus.h | 9 ++++ src/mame/drivers/indy_indigo2.cpp | 83 +++++++++++++++++++++---------- src/mame/machine/hpc3.cpp | 46 ++++++++++------- src/mame/machine/hpc3.h | 10 ++-- 4 files changed, 100 insertions(+), 48 deletions(-) diff --git a/src/devices/machine/nscsi_bus.h b/src/devices/machine/nscsi_bus.h index 5e7d7dcecab..82640ae5287 100644 --- a/src/devices/machine/nscsi_bus.h +++ b/src/devices/machine/nscsi_bus.h @@ -52,6 +52,15 @@ class nscsi_connector: public device_t, public device_slot_interface { public: + template + nscsi_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, bool fixed = false) + : nscsi_connector(mconfig, tag, owner, 0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(fixed); + } nscsi_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); virtual ~nscsi_connector(); diff --git a/src/mame/drivers/indy_indigo2.cpp b/src/mame/drivers/indy_indigo2.cpp index 1c19fa6777e..4cc5f2e3a5d 100644 --- a/src/mame/drivers/indy_indigo2.cpp +++ b/src/mame/drivers/indy_indigo2.cpp @@ -60,13 +60,13 @@ \*********************************************************************/ #include "emu.h" -#include "bus/scsi/scsi.h" -#include "bus/scsi/scsicd.h" -#include "bus/scsi/scsihd.h" #include "cpu/mips/mips3.h" #include "machine/hpc3.h" +#include "machine/nscsi_bus.h" +#include "machine/nscsi_cd.h" +#include "machine/nscsi_hd.h" #include "machine/sgi.h" #include "sound/cdda.h" @@ -84,7 +84,7 @@ public: , m_maincpu(*this, "maincpu") , m_mainram(*this, "mainram") , m_mem_ctrl(*this, "memctrl") - , m_scsi_ctrl(*this, "wd33c93") + , m_scsi_ctrl(*this, "scsibus:0:wd33c93") , m_newport(*this, "newport") , m_hpc3(*this, "hpc3") { @@ -103,12 +103,12 @@ protected: void ip22_map(address_map &map); - static void cdrom_config(device_t *device); + void wd33c93(device_t *device); required_device m_maincpu; required_shared_ptr m_mainram; required_device m_mem_ctrl; - required_device m_scsi_ctrl; + required_device m_scsi_ctrl; required_device m_newport; required_device m_hpc3; }; @@ -118,14 +118,16 @@ class ip24_state : public ip22_state public: ip24_state(const machine_config &mconfig, device_type type, const char *tag) : ip22_state(mconfig, type, tag) - , m_scsi_ctrl2(*this, "wd33c93_2") + , m_scsi_ctrl2(*this, "scsibus2:0:wd33c93") { } void ip244415(machine_config &config); private: - required_device m_scsi_ctrl2; + void wd33c93_2(device_t *device); + + required_device m_scsi_ctrl2; }; READ32_MEMBER(ip22_state::eisa_io_r) @@ -180,11 +182,26 @@ static INPUT_PORTS_START( ip225015 ) PORT_INCLUDE( at_keyboard ) /* IN4 - IN11 */ INPUT_PORTS_END -void ip22_state::cdrom_config(device_t *device) +//static void cdrom_config(device_t *device) +//{ +// cdda_device *cdda = device->subdevice("cdda"); +// cdda->add_route(0, ":hpc3:lspeaker", 1.0); +// cdda->add_route(1, ":hpc3:rspeaker", 1.0); +//} + +void ip22_state::wd33c93(device_t *device) { - cdda_device *cdda = device->subdevice("cdda"); - cdda->add_route(0, ":hpc3:lspeaker", 1.0); - cdda->add_route(1, ":hpc3:rspeaker", 1.0); + device->set_clock(10000000); + downcast(device)->irq_cb().set(m_hpc3, FUNC(hpc3_device::scsi0_irq)); + downcast(device)->drq_cb().set(m_hpc3, FUNC(hpc3_device::scsi0_drq)); +} + +static void ip22_scsi_devices(device_slot_interface &device) +{ + device.option_add("cdrom", NSCSI_CDROM); + device.option_add("harddisk", NSCSI_HARDDISK); + device.option_add_internal("wd33c93", WD33C93N); + //device.set_option_machine_config("cdrom", cdrom_config); } void ip22_state::ip22_base(machine_config &config) @@ -204,15 +221,16 @@ void ip22_state::ip22_base(machine_config &config) SGI_MC(config, m_mem_ctrl, m_maincpu, ":hpc3:eeprom"); - scsi_port_device &scsi(SCSI_PORT(config, "scsi")); - scsi.set_slot_device(1, "harddisk", SCSIHD, DEVICE_INPUT_DEFAULTS_NAME(SCSI_ID_1)); - scsi.set_slot_device(2, "cdrom", SCSICD, DEVICE_INPUT_DEFAULTS_NAME(SCSI_ID_4)); - scsi.slot(2).set_option_machine_config("cdrom", cdrom_config); - - WD33C93(config, m_scsi_ctrl); - m_scsi_ctrl->set_scsi_port("scsi"); - m_scsi_ctrl->irq_cb().set(m_hpc3, FUNC(hpc3_device::scsi0_irq)); - //m_scsi_ctrl->drq_cb().set(m_hpc3, FUNC(hpc3_device::scsi0_drq)); + NSCSI_BUS(config, "scsibus", 0); + NSCSI_CONNECTOR(config, "scsibus:0", ip22_scsi_devices, "wd33c93", true) + .set_option_machine_config("wd33c93", [this](device_t *device) { wd33c93(device); }); + NSCSI_CONNECTOR(config, "scsibus:1", ip22_scsi_devices, "harddisk", false); + NSCSI_CONNECTOR(config, "scsibus:2", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus:3", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus:4", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus:5", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus:6", ip22_scsi_devices, "cdrom", false); + NSCSI_CONNECTOR(config, "scsibus:7", ip22_scsi_devices, nullptr, false); } void ip22_state::ip225015(machine_config &config) @@ -239,6 +257,13 @@ void ip22_state::ip224613(machine_config &config) SGI_HPC3(config, m_hpc3, m_maincpu, m_scsi_ctrl); } +void ip24_state::wd33c93_2(device_t *device) +{ + device->set_clock(10000000); + downcast(device)->irq_cb().set(m_hpc3, FUNC(hpc3_device::scsi1_irq)); + downcast(device)->drq_cb().set(m_hpc3, FUNC(hpc3_device::scsi1_drq)); +} + void ip24_state::ip244415(machine_config &config) { ip22_base(config); @@ -248,12 +273,16 @@ void ip24_state::ip244415(machine_config &config) m_maincpu->set_dcache_size(32768); m_maincpu->set_addrmap(AS_PROGRAM, &ip24_state::ip22_map); - SCSI_PORT(config, "scsi2"); - - WD33C93(config, m_scsi_ctrl2); - m_scsi_ctrl2->set_scsi_port("scsi2"); - m_scsi_ctrl->irq_cb().set(m_hpc3, FUNC(hpc3_device::scsi1_irq)); - //m_scsi_ctrl->drq_cb().set(m_hpc3, FUNC(hpc3_device::scsi1_drq)); + NSCSI_BUS(config, "scsibus2", 0); + NSCSI_CONNECTOR(config, "scsibus2:0", ip22_scsi_devices, "wd33c93", true) + .set_option_machine_config("wd33c93", [this](device_t *device) { wd33c93_2(device); }); + NSCSI_CONNECTOR(config, "scsibus2:1", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus2:2", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus2:3", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus2:4", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus2:5", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus2:6", ip22_scsi_devices, nullptr, false); + NSCSI_CONNECTOR(config, "scsibus2:7", ip22_scsi_devices, nullptr, false); SGI_HPC3(config, m_hpc3, m_maincpu, m_scsi_ctrl, m_scsi_ctrl2); } diff --git a/src/mame/machine/hpc3.cpp b/src/mame/machine/hpc3.cpp index 3728be15dc7..b39c6bc9b07 100644 --- a/src/mame/machine/hpc3.cpp +++ b/src/mame/machine/hpc3.cpp @@ -52,6 +52,7 @@ void hpc3_device::device_start() save_item(NAME(m_scsi_dma[i].m_length), i); save_item(NAME(m_scsi_dma[i].m_next), i); save_item(NAME(m_scsi_dma[i].m_irq), i); + save_item(NAME(m_scsi_dma[i].m_drq), i); save_item(NAME(m_scsi_dma[i].m_big_endian), i); save_item(NAME(m_scsi_dma[i].m_to_device), i); save_item(NAME(m_scsi_dma[i].m_active), i); @@ -265,11 +266,17 @@ WRITE32_MEMBER(hpc3_device::hd_enet_w) break; case 0x1004/4: LOGMASKED(LOG_SCSI, "%s: HPC3 SCSI0 DMA Control Write: %08x\n", machine().describe_context(), data); + printf("HPC3 SCSI0 DMA Control Write: %08x\n", data); m_scsi_dma[0].m_ctrl = data; m_scsi_dma[0].m_to_device = (m_scsi_dma[0].m_ctrl & HPC3_DMACTRL_DIR); m_scsi_dma[0].m_big_endian = (m_scsi_dma[0].m_ctrl & HPC3_DMACTRL_ENDIAN); m_scsi_dma[0].m_active = (m_scsi_dma[0].m_ctrl & HPC3_DMACTRL_ENABLE); m_scsi_dma[0].m_irq = (m_scsi_dma[0].m_ctrl & HPC3_DMACTRL_IRQ); + m_wd33c93->reset_w(BIT(data, 6)); + if (m_scsi_dma[0].m_drq && m_scsi_dma[0].m_active) + { + do_scsi_dma(0); + } break; case 0x4000/4: LOGMASKED(LOG_ETHERNET, "%s: HPC3 Ethernet CBP Write: %08x\n", machine().describe_context(), data); @@ -297,7 +304,7 @@ READ32_MEMBER(hpc3_device::hd_r) case 0x4000/4: if (ACCESSING_BITS_0_7) { - const uint8_t ret = index ? m_wd33c93_2->read(space, 0) : m_wd33c93->read(space, 0); + const uint8_t ret = index ? m_wd33c93_2->indir_r(space, 0) : m_wd33c93->indir_r(space, 0); LOGMASKED(LOG_SCSI, "%s: SCSI%d Read 0: %02x\n", machine().describe_context(), index, ret); return ret; } @@ -306,7 +313,7 @@ READ32_MEMBER(hpc3_device::hd_r) case 0x4004/4: if (ACCESSING_BITS_0_7) { - const uint8_t ret = index ? m_wd33c93_2->read(space, 1) : m_wd33c93->read(space, 1); + const uint8_t ret = index ? m_wd33c93_2->indir_r(space, 1) : m_wd33c93->indir_r(space, 1); LOGMASKED(LOG_SCSI, "%s: SCSI%d Read 1: %02x\n", machine().describe_context(), index, ret); return ret; } @@ -331,14 +338,14 @@ WRITE32_MEMBER(hpc3_device::hd_w) if (ACCESSING_BITS_0_7) { LOGMASKED(LOG_SCSI, "%s: SCSI%d Write 0 = %02x\n", machine().describe_context(), index, (uint8_t)data); - index ? m_wd33c93_2->write(space, 0, data & 0xff) : m_wd33c93->write(space, 0, data & 0xff); + index ? m_wd33c93_2->indir_w(space, 0, data & 0xff) : m_wd33c93->indir_w(space, 0, data & 0xff); } break; case 0x0001: if (ACCESSING_BITS_0_7) { LOGMASKED(LOG_SCSI, "%s: SCSI%d Write 1 = %02x\n", machine().describe_context(), index, (uint8_t)data); - index ? m_wd33c93_2->write(space, 1, data & 0xff) : m_wd33c93->write(space, 1, data & 0xff); + index ? m_wd33c93_2->indir_w(space, 1, data & 0xff) : m_wd33c93->indir_w(space, 1, data & 0xff); } break; default: @@ -664,16 +671,20 @@ void hpc3_device::decrement_chain(int channel) void hpc3_device::scsi_drq(bool state, int channel) { -#if 0 - scsi_dma_t &dma = m_scsi_dma[channel]; + scsi_dma_t &dma = m_scsi_dma[channel]; + dma.m_drq = state; - if (!dma.m_active) - { - LOGMASKED(LOG_SCSI_DMA, "HPC3: SCSI%d DRQ set while no active SCSI DMA!\n", channel); - return; - } + if (dma.m_drq && dma.m_active) + { + do_scsi_dma(channel); + } +} - if (dma.m_to_device) +void hpc3_device::do_scsi_dma(int channel) +{ + scsi_dma_t &dma = m_scsi_dma[channel]; + + if (dma.m_to_device) m_wd33c93->dma_w(m_cpu_space->read_byte(dma.m_big_endian ? BYTE4_XOR_BE(dma.m_addr) : BYTE4_XOR_LE(dma.m_addr))); else m_cpu_space->write_byte(dma.m_big_endian ? BYTE4_XOR_BE(dma.m_addr) : BYTE4_XOR_LE(dma.m_addr), m_wd33c93->dma_r()); @@ -686,7 +697,6 @@ void hpc3_device::scsi_drq(bool state, int channel) // clear HPC3 DMA active flag dma.m_ctrl &= ~HPC3_DMACTRL_ENABLE; } -#endif } WRITE_LINE_MEMBER(hpc3_device::scsi0_drq) @@ -699,6 +709,7 @@ WRITE_LINE_MEMBER(hpc3_device::scsi1_drq) scsi_drq(state, 1); } +#if 0 void hpc3_device::scsi_dma(int channel) { int byte_count = channel ? m_wd33c93_2->get_dma_count() : m_wd33c93->get_dma_count(); @@ -812,13 +823,14 @@ void hpc3_device::scsi_dma(int channel) // clear DMA on the controller m_wd33c93->clear_dma(); } +#endif WRITE_LINE_MEMBER(hpc3_device::scsi0_irq) { if (state) { - if (m_wd33c93->get_dma_count() && m_scsi_dma[0].m_active) - scsi_dma(0); + //if (m_wd33c93->get_dma_count() && m_scsi_dma[0].m_active) + // scsi_dma(0); m_ioc2->raise_local_irq(0, ioc2_device::INT3_LOCAL0_SCSI0); } @@ -832,8 +844,8 @@ WRITE_LINE_MEMBER(hpc3_device::scsi1_irq) { if (state) { - if (m_wd33c93_2->get_dma_count() && m_scsi_dma[1].m_active) - scsi_dma(1); + //if (m_wd33c93_2->get_dma_count() && m_scsi_dma[1].m_active) + // scsi_dma(1); m_ioc2->raise_local_irq(0, ioc2_device::INT3_LOCAL0_SCSI1); } diff --git a/src/mame/machine/hpc3.h b/src/mame/machine/hpc3.h index 94d6c65e595..35c967c2769 100644 --- a/src/mame/machine/hpc3.h +++ b/src/mame/machine/hpc3.h @@ -16,7 +16,7 @@ #include "machine/eepromser.h" #include "machine/hal2.h" #include "machine/ioc2.h" -#include "machine/wd33c93.h" +#include "machine/wd33c9x.h" #include "sound/dac.h" #include "sound/volt_reg.h" #include "speaker.h" @@ -78,12 +78,13 @@ protected: DECLARE_WRITE32_MEMBER(pio_config_w); void do_pbus_dma(uint32_t channel); + void do_scsi_dma(int channel); void dump_chain(uint32_t base); void fetch_chain(int channel); void decrement_chain(int channel); void scsi_drq(bool state, int channel); - void scsi_dma(int channel); + //void scsi_dma(int channel); static const device_timer_id TIMER_PBUS_DMA = 0; @@ -132,8 +133,8 @@ protected: }; required_device m_maincpu; - required_device m_wd33c93; - optional_device m_wd33c93_2; + required_device m_wd33c93; + optional_device m_wd33c93_2; required_device m_eeprom; required_device m_rtc; required_device m_ioc2; @@ -153,6 +154,7 @@ protected: uint32_t m_length; uint32_t m_next; bool m_irq; + bool m_drq; bool m_big_endian; bool m_to_device; bool m_active;