From d62e3a328aee8ddb0ed53c47265f8f88c603072c Mon Sep 17 00:00:00 2001 From: Dirk Best Date: Sat, 30 Nov 2024 16:07:03 +0100 Subject: bus/amiga/zorro: Cleanups and 32-bit zorro support for various cards --- src/devices/bus/amiga/zorro/a2052.cpp | 60 ++++---- src/devices/bus/amiga/zorro/a2052.h | 12 +- src/devices/bus/amiga/zorro/a2058.cpp | 48 +++--- src/devices/bus/amiga/zorro/a2058.h | 9 +- src/devices/bus/amiga/zorro/a2065.cpp | 125 +++++++--------- src/devices/bus/amiga/zorro/a2065.h | 10 +- src/devices/bus/amiga/zorro/buddha.cpp | 260 +++++++++++++-------------------- src/devices/bus/amiga/zorro/buddha.h | 14 +- src/devices/bus/amiga/zorro/ripple.cpp | 59 +++++--- src/devices/bus/amiga/zorro/ripple.h | 1 + 10 files changed, 269 insertions(+), 329 deletions(-) diff --git a/src/devices/bus/amiga/zorro/a2052.cpp b/src/devices/bus/amiga/zorro/a2052.cpp index 66eb712f7ff..a342e4eb267 100644 --- a/src/devices/bus/amiga/zorro/a2052.cpp +++ b/src/devices/bus/amiga/zorro/a2052.cpp @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Commodore A2052 @@ -21,12 +21,20 @@ DEFINE_DEVICE_TYPE(ZORRO_A2052, bus::amiga::zorro::a2052_device, "zorro_a2052", "CBM A2052 Fast Memory") - namespace bus::amiga::zorro { -//------------------------------------------------- -// input_ports - device-specific input ports -//------------------------------------------------- +a2052_device::a2052_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ZORRO_A2052, tag, owner, clock), + device_zorro2_card_interface(mconfig, *this), + m_config(*this, "config"), + m_ram_size(0) +{ +} + + +//************************************************************************** +// INPUT DEFINITIONS +//************************************************************************** static INPUT_PORTS_START( a2052 ) PORT_START("config") @@ -43,31 +51,21 @@ ioport_constructor a2052_device::device_input_ports() const //************************************************************************** -// LIVE DEVICE +// MACHINE EMULATION //************************************************************************** -//------------------------------------------------- -// a2052_device - constructor -//------------------------------------------------- - -a2052_device::a2052_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, ZORRO_A2052, tag, owner, clock), - device_zorro2_card_interface(mconfig, *this), - m_config(*this, "config") -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - void a2052_device::device_start() { + // setup ram + m_ram = make_unique_clear(0x200000/2); + + // register for save states + save_pointer(NAME(m_ram), 0x200000/2); } //************************************************************************** -// IMPLEMENTATION +// AUTOCONFIG //************************************************************************** void a2052_device::autoconfig_base_address(offs_t address) @@ -79,7 +77,7 @@ void a2052_device::autoconfig_base_address(offs_t address) m_slot->space().unmap_readwrite(0xe80000, 0xe8007f); // install access to the rom space - m_slot->space().install_ram(address, address + m_ram.size()*2 - 1, &m_ram[0]); + m_slot->space().install_ram(address, address + (m_ram_size << 20) - 1, m_ram.get()); // we're done m_slot->cfgout_w(0); @@ -99,20 +97,20 @@ void a2052_device::cfgin_w(int state) { case 0: autoconfig_board_size(BOARD_SIZE_512K); - m_ram.resize(0x080000/2); + m_ram_size = 0x080000 >> 20; break; case 1: autoconfig_board_size(BOARD_SIZE_1M); - m_ram.resize(0x100000/2); + m_ram_size = 0x100000 >> 20; break; case 2: autoconfig_board_size(BOARD_SIZE_2M); - m_ram.resize(0x200000/2); + m_ram_size = 0x200000 >> 20; break; } - autoconfig_product(0x0a); - autoconfig_manufacturer(0x0202); + autoconfig_product(10); + autoconfig_manufacturer(514); autoconfig_serial(0x00000000); autoconfig_link_into_memory(true); @@ -123,8 +121,8 @@ void a2052_device::cfgin_w(int state) // install autoconfig handler m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f, - read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), - write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffff); + read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), + write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffffffff); } } diff --git a/src/devices/bus/amiga/zorro/a2052.h b/src/devices/bus/amiga/zorro/a2052.h index 89cb17ee09b..6bea75b19a5 100644 --- a/src/devices/bus/amiga/zorro/a2052.h +++ b/src/devices/bus/amiga/zorro/a2052.h @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Commodore A2052 @@ -23,12 +23,9 @@ namespace bus::amiga::zorro { // TYPE DEFINITIONS //************************************************************************** -// ======================> a2052_device - class a2052_device : public device_t, public device_zorro2_card_interface, public amiga_autoconfig { public: - // construction/destruction a2052_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: @@ -43,12 +40,13 @@ protected: private: required_ioport m_config; - std::vector m_ram; + std::unique_ptr m_ram; + int m_ram_size; }; } // namespace bus::amiga::zorro -// device type definition +// device type declaration DECLARE_DEVICE_TYPE_NS(ZORRO_A2052, bus::amiga::zorro, a2052_device) #endif // MAME_BUS_AMIGA_ZORRO_A2052_H diff --git a/src/devices/bus/amiga/zorro/a2058.cpp b/src/devices/bus/amiga/zorro/a2058.cpp index 4077306ad6b..905334ed1bb 100644 --- a/src/devices/bus/amiga/zorro/a2058.cpp +++ b/src/devices/bus/amiga/zorro/a2058.cpp @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Commodore A2058 @@ -21,12 +21,20 @@ DEFINE_DEVICE_TYPE(ZORRO_A2058, bus::amiga::zorro::a2058_device, "zorro_a2058", "CBM A2058 Fast Memory") - namespace bus::amiga::zorro { -//------------------------------------------------- -// input_ports - device-specific input ports -//------------------------------------------------- +a2058_device::a2058_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ZORRO_A2058, tag, owner, clock), + device_zorro2_card_interface(mconfig, *this), + m_config(*this, "config"), + m_ram_size(0) +{ +} + + +//************************************************************************** +// INPUT DEFINITIONS +//************************************************************************** static INPUT_PORTS_START( a2058 ) PORT_START("config") @@ -44,25 +52,9 @@ ioport_constructor a2058_device::device_input_ports() const //************************************************************************** -// LIVE DEVICE +// MACHINE EMULATION //************************************************************************** -//------------------------------------------------- -// a2058_device - constructor -//------------------------------------------------- - -a2058_device::a2058_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, ZORRO_A2058, tag, owner, clock), - device_zorro2_card_interface(mconfig, *this), - m_config(*this, "config"), - m_ram_size(0) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - void a2058_device::device_start() { // setup ram @@ -74,7 +66,7 @@ void a2058_device::device_start() //************************************************************************** -// IMPLEMENTATION +// AUTOCONFIG //************************************************************************** void a2058_device::autoconfig_base_address(offs_t address) @@ -122,8 +114,8 @@ void a2058_device::cfgin_w(int state) return; } - autoconfig_product(0x0a); - autoconfig_manufacturer(0x0202); + autoconfig_product(10); + autoconfig_manufacturer(514); autoconfig_serial(0x00000000); autoconfig_link_into_memory(true); @@ -134,8 +126,8 @@ void a2058_device::cfgin_w(int state) // install autoconfig handler m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f, - read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), - write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffff); + read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), + write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffffffff); } } diff --git a/src/devices/bus/amiga/zorro/a2058.h b/src/devices/bus/amiga/zorro/a2058.h index 1b9badf9382..aeecdbc0702 100644 --- a/src/devices/bus/amiga/zorro/a2058.h +++ b/src/devices/bus/amiga/zorro/a2058.h @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Commodore A2058 @@ -23,12 +23,9 @@ namespace bus::amiga::zorro { // TYPE DEFINITIONS //************************************************************************** -// ======================> a2058_device - class a2058_device : public device_t, public device_zorro2_card_interface, public amiga_autoconfig { public: - // construction/destruction a2058_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: @@ -49,7 +46,7 @@ private: } // namespace bus::amiga::zorro -// device type definition +// device type declaration DECLARE_DEVICE_TYPE_NS(ZORRO_A2058, bus::amiga::zorro, a2058_device) #endif // MAME_BUS_AMIGA_ZORRO_A2058_H diff --git a/src/devices/bus/amiga/zorro/a2065.cpp b/src/devices/bus/amiga/zorro/a2065.cpp index 0c283e19f16..819bc10da78 100644 --- a/src/devices/bus/amiga/zorro/a2065.cpp +++ b/src/devices/bus/amiga/zorro/a2065.cpp @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Commodore A2065 @@ -11,27 +11,29 @@ #include "emu.h" #include "a2065.h" - -//************************************************************************** -// CONSTANTS / MACROS -//************************************************************************** - #define VERBOSE 1 #include "logmacro.h" //************************************************************************** -// DEVICE DEFINITIONS +// TYPE DEFINITIONS //************************************************************************** DEFINE_DEVICE_TYPE(ZORRO_A2065, bus::amiga::zorro::a2065_device, "zorro_a2065", "CBM A2065 Ethernet Card") - namespace bus::amiga::zorro { -//------------------------------------------------- -// device_add_mconfig - add device configuration -//------------------------------------------------- +a2065_device::a2065_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ZORRO_A2065, tag, owner, clock), + device_zorro2_card_interface(mconfig, *this), + m_lance(*this, "lance") +{ +} + + +//************************************************************************** +// MACHINE DEFINITIONS +//************************************************************************** void a2065_device::device_add_mconfig(machine_config &config) { @@ -43,24 +45,9 @@ void a2065_device::device_add_mconfig(machine_config &config) //************************************************************************** -// LIVE DEVICE +// MACHINE EMULATION //************************************************************************** -//------------------------------------------------- -// a2065_device - constructor -//------------------------------------------------- - -a2065_device::a2065_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, ZORRO_A2065, tag, owner, clock), - device_zorro2_card_interface(mconfig, *this), - m_lance(*this, "lance") -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - void a2065_device::device_start() { // setup ram @@ -71,9 +58,41 @@ void a2065_device::device_start() save_pointer(NAME(m_ram), 0x4000); } +uint16_t a2065_device::host_ram_r(offs_t offset) +{ + // logerror("host read offset %04x\n", offset); + return m_ram[offset & 0x3fff]; +} + +void a2065_device::host_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + // logerror("host write %04x = %04x\n", offset, data); + COMBINE_DATA(&m_ram[offset]); +} + +uint16_t a2065_device::lance_ram_r(offs_t offset) +{ + offset = (offset >> 1) & 0x3fff; + // logerror("lance read offset %04x\n", offset); + return m_ram[offset]; +} + +void a2065_device::lance_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + offset = (offset >> 1) & 0x3fff; + // logerror("lance write %04x = %04x\n", offset, data); + COMBINE_DATA(&m_ram[offset]); +} + +void a2065_device::lance_irq_w(int state) +{ + // default is irq 2, can be changed via jumper + m_slot->int2_w(!state); +} + //************************************************************************** -// IMPLEMENTATION +// AUTOCONFIG //************************************************************************** void a2065_device::autoconfig_base_address(offs_t address) @@ -87,19 +106,19 @@ void a2065_device::autoconfig_base_address(offs_t address) // install autoconfig handler to new location m_slot->space().install_readwrite_handler(address, address + 0x7f, read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), - write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffff); + write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffffffff); // install access to lance registers m_slot->space().install_read_handler(address + 0x4000, address + 0x4003, - read16m_delegate(*m_lance, FUNC(am7990_device::regs_r)), 0xffff); + read16m_delegate(*m_lance, FUNC(am7990_device::regs_r)), 0xffffffff); m_slot->space().install_write_handler(address + 0x4000, address + 0x4003, - write16sm_delegate(*m_lance, FUNC(am7990_device::regs_w)), 0xffff); + write16sm_delegate(*m_lance, FUNC(am7990_device::regs_w)), 0xffffffff); // install access to onboard ram (32k) m_slot->space().install_read_handler(address + 0x8000, address + 0x8000 + 0x7fff, - read16sm_delegate(*this, FUNC(a2065_device::host_ram_r)), 0xffff); + read16sm_delegate(*this, FUNC(a2065_device::host_ram_r)), 0xffffffff); m_slot->space().install_write_handler(address + 0x8000, address + 0x8000 + 0x7fff, - write16s_delegate(*this, FUNC(a2065_device::host_ram_w)), 0xffff); + write16s_delegate(*this, FUNC(a2065_device::host_ram_w)), 0xffffffff); // we're done m_slot->cfgout_w(0); @@ -115,8 +134,8 @@ void a2065_device::cfgin_w(int state) autoconfig_board_type(BOARD_TYPE_ZORRO2); autoconfig_board_size(BOARD_SIZE_64K); - autoconfig_product(0x70); - autoconfig_manufacturer(0x0202); + autoconfig_product(112); + autoconfig_manufacturer(514); autoconfig_serial(0x00123456); // last 3 bytes = last 3 bytes of mac address autoconfig_link_into_memory(false); @@ -128,40 +147,8 @@ void a2065_device::cfgin_w(int state) // install autoconfig handler m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f, read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), - write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffff); + write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffffffff); } } -uint16_t a2065_device::host_ram_r(offs_t offset) -{ - // logerror("host read offset %04x\n", offset); - return m_ram[offset & 0x3fff]; -} - -void a2065_device::host_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - // logerror("host write %04x = %04x\n", offset, data); - COMBINE_DATA(&m_ram[offset]); -} - -uint16_t a2065_device::lance_ram_r(offs_t offset) -{ - offset = (offset >> 1) & 0x3fff; - // logerror("lance read offset %04x\n", offset); - return m_ram[offset]; -} - -void a2065_device::lance_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - offset = (offset >> 1) & 0x3fff; - // logerror("lance write %04x = %04x\n", offset, data); - COMBINE_DATA(&m_ram[offset]); -} - -void a2065_device::lance_irq_w(int state) -{ - // default is irq 2, can be changed via jumper - m_slot->int2_w(!state); -} - } // namespace bus::amiga::zorro diff --git a/src/devices/bus/amiga/zorro/a2065.h b/src/devices/bus/amiga/zorro/a2065.h index 7730370255e..3e638d84585 100644 --- a/src/devices/bus/amiga/zorro/a2065.h +++ b/src/devices/bus/amiga/zorro/a2065.h @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Commodore A2065 @@ -24,12 +24,9 @@ namespace bus::amiga::zorro { // TYPE DEFINITIONS //************************************************************************** -// ======================> a2065_device - class a2065_device : public device_t, public device_zorro2_card_interface, public amiga_autoconfig { public: - // construction/destruction a2065_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); uint16_t host_ram_r(offs_t offset); @@ -40,7 +37,6 @@ public: void lance_irq_w(int state); protected: - // device-level overrides virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual void device_start() override ATTR_COLD; @@ -58,7 +54,7 @@ private: } // namespace bus::amiga::zorro -// device type definition +// device type declaration DECLARE_DEVICE_TYPE_NS(ZORRO_A2065, bus::amiga::zorro, a2065_device) #endif // MAME_BUS_AMIGA_ZORRO_A2065_H diff --git a/src/devices/bus/amiga/zorro/buddha.cpp b/src/devices/bus/amiga/zorro/buddha.cpp index c515096a28a..685bdd2780d 100644 --- a/src/devices/bus/amiga/zorro/buddha.cpp +++ b/src/devices/bus/amiga/zorro/buddha.cpp @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Buddha @@ -35,28 +35,42 @@ DEFINE_DEVICE_TYPE(ZORRO_BUDDHA, bus::amiga::zorro::buddha_device, "zorro_buddha", "Buddha IDE controller") - namespace bus::amiga::zorro { -//------------------------------------------------- -// mmio_map - device-specific memory mapped I/O -//------------------------------------------------- +buddha_device::buddha_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ZORRO_BUDDHA, tag, owner, clock), + device_zorro2_card_interface(mconfig, *this), + m_ata_0(*this, "ata_0"), + m_ata_1(*this, "ata_1"), + m_bootrom(*this, "bootrom"), + m_ide_interrupts_enabled(false), + m_ide_0_interrupt(0), + m_ide_1_interrupt(0) +{ +} + + +//************************************************************************** +// ADDRESS MAPS +//************************************************************************** void buddha_device::mmio_map(address_map &map) { - map(0x7fe, 0x7ff).rw(FUNC(buddha_device::speed_r), FUNC(buddha_device::speed_w)); - map(0x800, 0x8ff).rw(FUNC(buddha_device::ide_0_cs0_r), FUNC(buddha_device::ide_0_cs0_w)); - map(0x900, 0x9ff).rw(FUNC(buddha_device::ide_0_cs1_r), FUNC(buddha_device::ide_0_cs1_w)); - map(0xa00, 0xaff).rw(FUNC(buddha_device::ide_1_cs0_r), FUNC(buddha_device::ide_1_cs0_w)); - map(0xb00, 0xbff).rw(FUNC(buddha_device::ide_1_cs1_r), FUNC(buddha_device::ide_1_cs1_w)); - map(0xf00, 0xf3f).r(FUNC(buddha_device::ide_0_interrupt_r)); - map(0xf40, 0xf7f).r(FUNC(buddha_device::ide_1_interrupt_r)); - map(0xfc0, 0xfff).w(FUNC(buddha_device::ide_interrupt_enable_w)); + map(0x07fe, 0x07ff).rw(FUNC(buddha_device::speed_r), FUNC(buddha_device::speed_w)); + map(0x0800, 0x08ff).rw(FUNC(buddha_device::ide_0_cs0_r), FUNC(buddha_device::ide_0_cs0_w)); + map(0x0900, 0x09ff).rw(FUNC(buddha_device::ide_0_cs1_r), FUNC(buddha_device::ide_0_cs1_w)); + map(0x0a00, 0x0aff).rw(FUNC(buddha_device::ide_1_cs0_r), FUNC(buddha_device::ide_1_cs0_w)); + map(0x0b00, 0x0bff).rw(FUNC(buddha_device::ide_1_cs1_r), FUNC(buddha_device::ide_1_cs1_w)); + map(0x0f00, 0x0f3f).r(FUNC(buddha_device::ide_0_interrupt_r)); + map(0x0f40, 0x0f7f).r(FUNC(buddha_device::ide_1_interrupt_r)); + map(0x0fc0, 0x0fff).w(FUNC(buddha_device::ide_interrupt_enable_w)); + map(0x1000, 0xffff).r(FUNC(buddha_device::rom_r)).umask16(0xff00); } -//------------------------------------------------- -// device_add_mconfig - add device configuration -//------------------------------------------------- + +//************************************************************************** +// MACHINE DEFINITIONS +//************************************************************************** void buddha_device::device_add_mconfig(machine_config &config) { @@ -67,17 +81,18 @@ void buddha_device::device_add_mconfig(machine_config &config) m_ata_1->irq_handler().set(FUNC(buddha_device::ide_1_interrupt_w)); } -//------------------------------------------------- -// rom_region - device-specific ROM region -//------------------------------------------------- + +//************************************************************************** +// ROM DEFINITIONS +//************************************************************************** ROM_START( buddha ) - ROM_REGION16_BE(0x10000, "bootrom", ROMREGION_ERASEFF) + ROM_REGION(0x8000, "bootrom", 0) ROM_DEFAULT_BIOS("v103-17") ROM_SYSTEM_BIOS(0, "v103-8", "Version 103.8") - ROMX_LOAD("buddha_103-8.rom", 0x0000, 0x8000, CRC(44f81426) SHA1(95555c6690b5c697e1cdca2726e47c1c6c194d7c), ROM_SKIP(1) | ROM_BIOS(0)) + ROMX_LOAD("buddha_103-8.rom", 0x0000, 0x8000, CRC(44f81426) SHA1(95555c6690b5c697e1cdca2726e47c1c6c194d7c), ROM_BIOS(0)) ROM_SYSTEM_BIOS(1, "v103-17", "Version 103.17") - ROMX_LOAD("buddha_103-17.rom", 0x0000, 0x8000, CRC(2b7b24e0) SHA1(ec17a58962c373a2892090ec9b1722d2c326d631), ROM_SKIP(1) | ROM_BIOS(1)) + ROMX_LOAD("buddha_103-17.rom", 0x0000, 0x8000, CRC(2b7b24e0) SHA1(ec17a58962c373a2892090ec9b1722d2c326d631), ROM_BIOS(1)) ROM_END const tiny_rom_entry *buddha_device::device_rom_region() const @@ -87,28 +102,9 @@ const tiny_rom_entry *buddha_device::device_rom_region() const //************************************************************************** -// LIVE DEVICE +// MACHINE EMULATION //************************************************************************** -//------------------------------------------------- -// buddha_device - constructor -//------------------------------------------------- - -buddha_device::buddha_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, ZORRO_BUDDHA, tag, owner, clock), - device_zorro2_card_interface(mconfig, *this), - m_ata_0(*this, "ata_0"), - m_ata_1(*this, "ata_1"), - m_ide_interrupts_enabled(false), - m_ide_0_interrupt(0), - m_ide_1_interrupt(0) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - void buddha_device::device_start() { save_item(NAME(m_ide_interrupts_enabled)); @@ -116,10 +112,6 @@ void buddha_device::device_start() save_item(NAME(m_ide_1_interrupt)); } -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - void buddha_device::device_reset() { m_ide_interrupts_enabled = false; @@ -127,58 +119,10 @@ void buddha_device::device_reset() m_ide_1_interrupt = 0; } - -//************************************************************************** -// IMPLEMENTATION -//************************************************************************** - -void buddha_device::autoconfig_base_address(offs_t address) -{ - LOG("autoconfig_base_address received: 0x%06x\n", address); - LOG("-> installing buddha\n"); - - // stop responding to default autoconfig - m_slot->space().unmap_readwrite(0xe80000, 0xe8007f); - - // buddha registers - m_slot->space().install_device(address, address + 0xfff, *this, &buddha_device::mmio_map); - - // install autoconfig handler to new location - m_slot->space().install_readwrite_handler(address, address + 0x7f, - read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), - write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffff); - - // install access to the rom space - m_slot->space().install_rom(address + 0x1000, address + 0xffff, memregion("bootrom")->base() + 0x1000); - - // we're done - m_slot->cfgout_w(0); -} - -void buddha_device::cfgin_w(int state) +uint8_t buddha_device::rom_r(offs_t offset) { - LOG("configin_w (%d)\n", state); - - if (state == 0) - { - // setup autoconfig - autoconfig_board_type(BOARD_TYPE_ZORRO2); - autoconfig_board_size(BOARD_SIZE_64K); - autoconfig_link_into_memory(false); - autoconfig_rom_vector_valid(true); - autoconfig_multi_device(false); - autoconfig_8meg_preferred(false); - autoconfig_can_shutup(true); - autoconfig_product(0x00); - autoconfig_manufacturer(0x1212); - autoconfig_serial(0x00000000); - autoconfig_rom_vector(0x1000); - - // install autoconfig handler - m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f, - read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), - write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffff); - } + // the first 0x800 bytes cannot be read + return m_bootrom[0x800 + offset]; } uint16_t buddha_device::speed_r(offs_t offset, uint16_t mem_mask) @@ -218,24 +162,14 @@ void buddha_device::ide_1_interrupt_w(int state) uint16_t buddha_device::ide_0_interrupt_r(offs_t offset, uint16_t mem_mask) { - uint16_t data; - - data = m_ide_0_interrupt << 15; - -// LOG("ide_0_interrupt_r %04x [mask = %04x]\n", data, mem_mask); - - return data; +// LOG("ide_0_interrupt_r %04x [mask = %04x]\n", m_ide_0_interrupt << 15, mem_mask); + return m_ide_0_interrupt << 15; } uint16_t buddha_device::ide_1_interrupt_r(offs_t offset, uint16_t mem_mask) { - uint16_t data; - - data = m_ide_1_interrupt << 15; - -// LOG("ide_1_interrupt_r %04x [mask = %04x]\n", data, mem_mask); - - return data; +// LOG("ide_1_interrupt_r %04x [mask = %04x]\n", m_ide_1_interrupt << 15, mem_mask); + return m_ide_1_interrupt << 15; } void buddha_device::ide_interrupt_enable_w(offs_t offset, uint16_t data, uint16_t mem_mask) @@ -248,82 +182,96 @@ void buddha_device::ide_interrupt_enable_w(offs_t offset, uint16_t data, uint16_ uint16_t buddha_device::ide_0_cs0_r(offs_t offset, uint16_t mem_mask) { - uint16_t data = m_ata_0->cs0_r((offset >> 1) & 0x07, swapendian_int16(mem_mask)); - data = swapendian_int16(data); - - LOG("ide_0_cs0_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); - - return data; + return m_ata_0->cs0_swap_r((offset >> 1) & 0x07, mem_mask); } void buddha_device::ide_0_cs0_w(offs_t offset, uint16_t data, uint16_t mem_mask) { - LOG("ide_0_cs0_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); - - mem_mask = swapendian_int16(mem_mask); - data = swapendian_int16(data); - - m_ata_0->cs0_w((offset >> 1) & 0x07, data, mem_mask); + m_ata_0->cs0_swap_w((offset >> 1) & 0x07, data, mem_mask); } uint16_t buddha_device::ide_0_cs1_r(offs_t offset, uint16_t mem_mask) { - uint16_t data = m_ata_0->cs1_r((offset >> 1) & 0x07, swapendian_int16(mem_mask)); - data = swapendian_int16(data); - - LOG("ide_0_cs1_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); - - return data; + return m_ata_0->cs1_swap_r((offset >> 1) & 0x07, mem_mask); } void buddha_device::ide_0_cs1_w(offs_t offset, uint16_t data, uint16_t mem_mask) { - LOG("ide_0_cs1_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); - - mem_mask = swapendian_int16(mem_mask); - data = swapendian_int16(data); - - m_ata_0->cs1_w((offset >> 1) & 0x07, data, mem_mask); + m_ata_0->cs1_swap_w((offset >> 1) & 0x07, data, mem_mask); } uint16_t buddha_device::ide_1_cs0_r(offs_t offset, uint16_t mem_mask) { - uint16_t data = m_ata_1->cs0_r((offset >> 1) & 0x07, swapendian_int16(mem_mask)); - data = swapendian_int16(data); - - LOG("ide_1_cs0_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); - - return data; + return m_ata_1->cs0_swap_r((offset >> 1) & 0x07, mem_mask); } void buddha_device::ide_1_cs0_w(offs_t offset, uint16_t data, uint16_t mem_mask) { - LOG("ide_1_cs0_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); + m_ata_1->cs0_swap_w((offset >> 1) & 0x07, data, mem_mask); +} - mem_mask = swapendian_int16(mem_mask); - data = swapendian_int16(data); +uint16_t buddha_device::ide_1_cs1_r(offs_t offset, uint16_t mem_mask) +{ + return m_ata_1->cs1_swap_r((offset >> 1) & 0x07, mem_mask); +} - m_ata_1->cs0_w((offset >> 1) & 0x07, data, mem_mask); +void buddha_device::ide_1_cs1_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + m_ata_1->cs1_swap_w((offset >> 1) & 0x07, data, mem_mask); } -uint16_t buddha_device::ide_1_cs1_r(offs_t offset, uint16_t mem_mask) + +//************************************************************************** +// AUTOCONFIG +//************************************************************************** + +void buddha_device::autoconfig_base_address(offs_t address) { - uint16_t data = m_ata_1->cs1_r((offset >> 1) & 0x07, swapendian_int16(mem_mask)); - data = swapendian_int16(data); + LOG("autoconfig_base_address received: 0x%06x\n", address); + LOG("-> installing buddha\n"); - LOG("ide_1_cs1_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); + // stop responding to initial location + m_slot->space().unmap_readwrite(0xe80000, 0xe8ffff); - return data; + // install buddha memory access to final location + m_slot->space().install_device(address, address + 0xffff, *this, &buddha_device::mmio_map); + + // install autoconfig handler to new location + m_slot->space().install_readwrite_handler(address, address + 0x7f, + read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), + write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffffffff); + + // we're done + m_slot->cfgout_w(0); } -void buddha_device::ide_1_cs1_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void buddha_device::cfgin_w(int state) { - LOG("ide_1_cs1_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask); + LOG("configin_w (%d)\n", state); - mem_mask = swapendian_int16(mem_mask); - data = swapendian_int16(data); + if (state == 0) + { + // buddha memory is also active at this point + m_slot->space().install_device(0xe80000, 0xe8ffff, *this, &buddha_device::mmio_map); - m_ata_1->cs1_w((offset >> 1) & 0x07, data, mem_mask); + // setup autoconfig + autoconfig_board_type(BOARD_TYPE_ZORRO2); + autoconfig_board_size(BOARD_SIZE_64K); + autoconfig_link_into_memory(false); + autoconfig_rom_vector_valid(true); + autoconfig_multi_device(false); + autoconfig_8meg_preferred(false); + autoconfig_can_shutup(true); + autoconfig_product(0); + autoconfig_manufacturer(4626); + autoconfig_serial(0x00000000); + autoconfig_rom_vector(0x1000); + + // install autoconfig handler + m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f, + read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), + write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffffffff); + } } } // namespace bus::amiga::zorro diff --git a/src/devices/bus/amiga/zorro/buddha.h b/src/devices/bus/amiga/zorro/buddha.h index 9ea0f3c0631..6a3e6d7b888 100644 --- a/src/devices/bus/amiga/zorro/buddha.h +++ b/src/devices/bus/amiga/zorro/buddha.h @@ -1,5 +1,5 @@ -// license:GPL-2.0+ -// copyright-holders:Dirk Best +// license: GPL-2.0+ +// copyright-holders: Dirk Best /*************************************************************************** Buddha @@ -24,8 +24,6 @@ namespace bus::amiga::zorro { // TYPE DEFINITIONS //************************************************************************** -// ======================> buddha_device - class buddha_device : public device_t, public device_zorro2_card_interface, public amiga_autoconfig { public: @@ -33,7 +31,6 @@ public: buddha_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - // device-level overrides virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD; @@ -47,6 +44,8 @@ protected: virtual void autoconfig_base_address(offs_t address) override; private: + void mmio_map(address_map &map) ATTR_COLD; + // speed register uint16_t speed_r(offs_t offset, uint16_t mem_mask = ~0); void speed_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); @@ -68,10 +67,11 @@ private: void ide_0_interrupt_w(int state); void ide_1_interrupt_w(int state); - void mmio_map(address_map &map) ATTR_COLD; + uint8_t rom_r(offs_t offset); required_device m_ata_0; required_device m_ata_1; + required_region_ptr m_bootrom; bool m_ide_interrupts_enabled; int m_ide_0_interrupt; @@ -80,7 +80,7 @@ private: } // namespace bus::amiga::zorro -// device type definition +// device type declaration DECLARE_DEVICE_TYPE_NS(ZORRO_BUDDHA, bus::amiga::zorro, buddha_device) #endif // MAME_BUS_AMIGA_ZORRO_BUDDHA_H diff --git a/src/devices/bus/amiga/zorro/ripple.cpp b/src/devices/bus/amiga/zorro/ripple.cpp index 39ca1c350da..fc6a2c9bf15 100644 --- a/src/devices/bus/amiga/zorro/ripple.cpp +++ b/src/devices/bus/amiga/zorro/ripple.cpp @@ -179,26 +179,49 @@ void ripple_ide_device::autoconfig_base_address(offs_t address) // flash occupies our space until the ide registers are switched in m_slot->space().install_readwrite_handler(address, address + 0x1ffff, emu::rw_delegate(m_flash, FUNC(intelfsh8_device::read)), - emu::rw_delegate(m_flash, FUNC(intelfsh8_device::write)), 0xff00); + emu::rw_delegate(m_flash, FUNC(intelfsh8_device::write)), 0xff00ff00); // install write tap to handle switching in ide registers m_write_tap.remove(); - m_write_tap = m_slot->space().install_write_tap( - address, address + 0x1ffff, - "rom_disable_w", - [this] (offs_t offset, uint16_t &data, uint16_t mem_mask) - { - m_write_tap.remove(); - - // ripple registers are now available - m_slot->space().install_device(m_base_address, m_base_address + 0x1ffff, *this, &ripple_ide_device::mmio_map); - - // we need to repeat the write here as this tap won't hit it yet - // the initial write will instead hit the flash, but it's harmless - m_slot->space().write_word(offset, data, mem_mask); - }, - &m_write_tap - ); + + if (m_slot->space().data_width() == 16) + { + m_write_tap = m_slot->space().install_write_tap( + address, address + 0x1ffff, + "flash_disable_w", + [this] (offs_t offset, uint16_t &data, uint16_t mem_mask) + { + m_write_tap.remove(); + + // ripple registers are now available + m_slot->space().install_device(m_base_address, m_base_address + 0x1ffff, *this, &ripple_ide_device::mmio_map); + + // we need to repeat the write here as this tap won't hit it yet + // the initial write will instead hit the flash, but it's harmless + m_slot->space().write_word(offset, data, mem_mask); + }, + &m_write_tap + ); + } + else + { + m_write_tap = m_slot->space().install_write_tap( + address, address + 0x1ffff, + "flash_disable_w", + [this] (offs_t offset, uint32_t &data, uint32_t mem_mask) + { + m_write_tap.remove(); + + // ripple registers are now available + m_slot->space().install_device(m_base_address, m_base_address + 0x1ffff, *this, &ripple_ide_device::mmio_map); + + // we need to repeat the write here as this tap won't hit it yet + // the initial write will instead hit the flash, but it's harmless + m_slot->space().write_dword(offset, data, mem_mask); + }, + &m_write_tap + ); + } // we're done m_slot->cfgout_w(0); @@ -226,7 +249,7 @@ void ripple_ide_device::cfgin_w(int state) // install autoconfig handler m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f, read16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_read)), - write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffff); + write16_delegate(*this, FUNC(amiga_autoconfig::autoconfig_write)), 0xffffffff); } } diff --git a/src/devices/bus/amiga/zorro/ripple.h b/src/devices/bus/amiga/zorro/ripple.h index d967f4c1584..9849cb4bf38 100644 --- a/src/devices/bus/amiga/zorro/ripple.h +++ b/src/devices/bus/amiga/zorro/ripple.h @@ -18,6 +18,7 @@ #include "machine/intelfsh.h" #include "bus/ata/ataintf.h" + namespace bus::amiga::zorro { class ripple_ide_device : public device_t, public device_zorro2_card_interface, public amiga_autoconfig -- cgit v1.2.3