amiga/zorro: Bus modernization (nw)

- Remove all MCFG_ macros and use devcb3 for callback configuration
- Use address space finder to replace one call to machine().device
- Require accessor for slot cards to access bus space
This commit is contained in:
AJR 2019-02-08 14:37:53 -05:00
parent eb35b5eb50
commit cd11ddb495
9 changed files with 91 additions and 131 deletions

View File

@ -81,10 +81,10 @@ void a2052_device::autoconfig_base_address(offs_t address)
logerror("-> installing a2052\n");
// stop responding to default autoconfig
m_slot->m_space->unmap_readwrite(0xe80000, 0xe8007f);
m_slot->space().unmap_readwrite(0xe80000, 0xe8007f);
// install access to the rom space
m_slot->m_space->install_ram(address, address + m_ram.size()*2 - 1, &m_ram[0]);
m_slot->space().install_ram(address, address + m_ram.size()*2 - 1, &m_ram[0]);
// we're done
m_slot->cfgout_w(0);
@ -128,7 +128,7 @@ WRITE_LINE_MEMBER( a2052_device::cfgin_w )
autoconfig_can_shutup(true); // ?
// install autoconfig handler
m_slot->m_space->install_readwrite_handler(0xe80000, 0xe8007f,
m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f,
read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
}

View File

@ -89,10 +89,10 @@ void a2058_device::autoconfig_base_address(offs_t address)
logerror("-> installing a2058\n");
// stop responding to default autoconfig
m_slot->m_space->unmap_readwrite(0xe80000, 0xe8007f);
m_slot->space().unmap_readwrite(0xe80000, 0xe8007f);
// install access to the rom space
m_slot->m_space->install_ram(address, address + (m_ram_size << 20) - 1, m_ram.get());
m_slot->space().install_ram(address, address + (m_ram_size << 20) - 1, m_ram.get());
// we're done
m_slot->cfgout_w(0);
@ -140,7 +140,7 @@ WRITE_LINE_MEMBER( a2058_device::cfgin_w )
autoconfig_can_shutup(true); // ?
// install autoconfig handler
m_slot->m_space->install_readwrite_handler(0xe80000, 0xe8007f,
m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f,
read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
}

View File

@ -81,20 +81,20 @@ void a2065_device::autoconfig_base_address(offs_t address)
LOG("-> installing a2065\n");
// stop responding to default autoconfig
m_slot->m_space->unmap_readwrite(0xe80000, 0xe8007f);
m_slot->space().unmap_readwrite(0xe80000, 0xe8007f);
// install autoconfig handler to new location
m_slot->m_space->install_readwrite_handler(address, address + 0x7f,
m_slot->space().install_readwrite_handler(address, address + 0x7f,
read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
// install access to lance registers
m_slot->m_space->install_readwrite_handler(address + 0x4000, address + 0x4003,
m_slot->space().install_readwrite_handler(address + 0x4000, address + 0x4003,
read16_delegate(FUNC(am7990_device::regs_r), &(*m_lance)),
write16_delegate(FUNC(am7990_device::regs_w), &(*m_lance)), 0xffff);
// install access to onboard ram (32k)
m_slot->m_space->install_readwrite_handler(address + 0x8000, address + 0x8000 + 0x7fff,
m_slot->space().install_readwrite_handler(address + 0x8000, address + 0x8000 + 0x7fff,
read16_delegate(FUNC(a2065_device::host_ram_r), this),
write16_delegate(FUNC(a2065_device::host_ram_w), this), 0xffff);
@ -123,7 +123,7 @@ WRITE_LINE_MEMBER( a2065_device::cfgin_w )
autoconfig_can_shutup(true); // ?
// install autoconfig handler
m_slot->m_space->install_readwrite_handler(0xe80000, 0xe8007f,
m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f,
read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
}

View File

@ -188,25 +188,25 @@ void a2232_device::autoconfig_base_address(offs_t address)
logerror("-> installing a2232\n");
// stop responding to default autoconfig
m_slot->m_space->unmap_readwrite(0xe80000, 0xe8007f);
m_slot->space().unmap_readwrite(0xe80000, 0xe8007f);
m_slot->m_space->install_readwrite_handler(address, address + 0x3fff,
m_slot->space().install_readwrite_handler(address, address + 0x3fff,
read16_delegate(FUNC(a2232_device::shared_ram_r), this),
write16_delegate(FUNC(a2232_device::shared_ram_w), this), 0xffff);
m_slot->m_space->install_readwrite_handler(address + 0x4000, address + 0x4001,
m_slot->space().install_readwrite_handler(address + 0x4000, address + 0x4001,
read16_delegate(FUNC(a2232_device::irq_ack_r), this),
write16_delegate(FUNC(a2232_device::irq_ack_w), this), 0xffff);
m_slot->m_space->install_readwrite_handler(address + 0x8000, address + 0x8001,
m_slot->space().install_readwrite_handler(address + 0x8000, address + 0x8001,
read16_delegate(FUNC(a2232_device::reset_low_r), this),
write16_delegate(FUNC(a2232_device::reset_low_w), this), 0xffff);
m_slot->m_space->install_readwrite_handler(address + 0xa000, address + 0xa001,
m_slot->space().install_readwrite_handler(address + 0xa000, address + 0xa001,
read16_delegate(FUNC(a2232_device::irq_r), this),
write16_delegate(FUNC(a2232_device::irq_w), this), 0xffff);
m_slot->m_space->install_readwrite_handler(address + 0xc000, address + 0xc001,
m_slot->space().install_readwrite_handler(address + 0xc000, address + 0xc001,
read16_delegate(FUNC(a2232_device::reset_high_r), this),
write16_delegate(FUNC(a2232_device::reset_high_w), this), 0xffff);
@ -236,7 +236,7 @@ WRITE_LINE_MEMBER( a2232_device::cfgin_w )
autoconfig_can_shutup(true); // ?
// install autoconfig handler
m_slot->m_space->install_readwrite_handler(0xe80000, 0xe8007f,
m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f,
read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
}

View File

@ -260,7 +260,7 @@ void a590_device::device_start()
set_zorro_device();
// setup DMAC
m_dmac->set_address_space(m_slot->m_space);
m_dmac->set_address_space(&m_slot->space());
m_dmac->set_rom(memregion("bootrom")->base());
}
@ -269,7 +269,7 @@ void a2091_device::device_start()
set_zorro_device();
// setup DMAC
m_dmac->set_address_space(m_slot->m_space);
m_dmac->set_address_space(&m_slot->space());
m_dmac->set_rom(memregion("bootrom")->base());
}

View File

@ -143,18 +143,18 @@ void buddha_device::autoconfig_base_address(offs_t address)
logerror("-> installing buddha\n");
// stop responding to default autoconfig
m_slot->m_space->unmap_readwrite(0xe80000, 0xe8007f);
m_slot->space().unmap_readwrite(0xe80000, 0xe8007f);
// buddha registers
m_slot->m_space->install_device(address, address + 0xfff, *this, &buddha_device::mmio_map);
m_slot->space().install_device(address, address + 0xfff, *this, &buddha_device::mmio_map);
// install autoconfig handler to new location
m_slot->m_space->install_readwrite_handler(address, address + 0x7f,
m_slot->space().install_readwrite_handler(address, address + 0x7f,
read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
// install access to the rom space
m_slot->m_space->install_rom(address + 0x1000, address + 0xffff, memregion("bootrom")->base() + 0x1000);
m_slot->space().install_rom(address + 0x1000, address + 0xffff, memregion("bootrom")->base() + 0x1000);
// we're done
m_slot->cfgout_w(0);
@ -181,7 +181,7 @@ WRITE_LINE_MEMBER( buddha_device::cfgin_w )
autoconfig_rom_vector(0x1000);
// install autoconfig handler
m_slot->m_space->install_readwrite_handler(0xe80000, 0xe8007f,
m_slot->space().install_readwrite_handler(0xe80000, 0xe8007f,
read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)),
write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff);
}

View File

@ -30,7 +30,7 @@ zorro_slot_device::zorro_slot_device(const machine_config &mconfig, const char *
zorro_slot_device::zorro_slot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock),
device_slot_interface(mconfig, *this),
m_zorro_tag(nullptr)
m_zorro_bus(*this, finder_base::DUMMY_TAG)
{
}
@ -43,10 +43,7 @@ void zorro_slot_device::device_start()
device_zorro_card_interface *dev = dynamic_cast<device_zorro_card_interface *>(get_card_device());
if (dev)
{
zorro_device *m_zorro_bus = downcast<zorro_device *>(m_owner->subdevice(m_zorro_tag));
m_zorro_bus->add_card(dev);
}
}
@ -60,24 +57,33 @@ void zorro_slot_device::device_start()
zorro_device::zorro_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock),
m_space(nullptr),
m_cputag(nullptr),
m_space(*this, finder_base::DUMMY_TAG, -1),
m_ovr_handler(*this),
m_int2_handler(*this),
m_int6_handler(*this)
{
}
//-------------------------------------------------
// device_resolve_objects - resolve objects that
// may be needed for other devices to set
// initial conditions at start time
//-------------------------------------------------
void zorro_device::device_resolve_objects()
{
// resolve callbacks
m_ovr_handler.resolve_safe();
m_int2_handler.resolve_safe();
m_int6_handler.resolve_safe();
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void zorro_device::device_start()
{
// get address space
device_t *cpu = machine().device(m_cputag);
m_space = &cpu->memory().space(AS_PROGRAM);
// resolve callbacks
m_ovr_handler.resolve_safe();
m_int2_handler.resolve_safe();

View File

@ -144,76 +144,6 @@
#pragma once
//**************************************************************************
// CONSTANTS / MACROS
//**************************************************************************
#define EXP_SLOT_TAG "exp"
#define ZORROBUS_TAG "zorrobus"
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_ZORRO_SLOT_ADD(_zorrotag, _tag, _slot_intf, _def_slot) \
MCFG_DEVICE_ADD(_tag, ZORRO_SLOT, 0) \
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \
downcast<zorro_slot_device &>(*device).set_zorro_slot(this, _zorrotag);
// ======================> expansion slot
#define MCFG_EXPANSION_SLOT_ADD(_cputag, _slot_intf, _def_slot) \
MCFG_DEVICE_ADD(EXP_SLOT_TAG, EXP_SLOT, 0) \
device_t *temp = device; \
downcast<zorro_device &>(*device).set_cputag(_cputag); \
MCFG_ZORRO_SLOT_ADD(EXP_SLOT_TAG, "slot", _slot_intf, _def_slot) \
device = temp;
// callbacks
#define MCFG_EXPANSION_SLOT_OVR_HANDLER(_devcb) \
downcast<zorro_device &>(*device).set_ovr_handler(DEVCB_##_devcb);
#define MCFG_EXPANSION_SLOT_INT2_HANDLER(_devcb) \
downcast<zorro_device &>(*device).set_int2_handler(DEVCB_##_devcb);
#define MCFG_EXPANSION_SLOT_INT6_HANDLER(_devcb) \
downcast<zorro_device &>(*device).set_int6_handler(DEVCB_##_devcb);
#define MCFG_EXPANSION_SLOT_IPL_HANDLER(_devcb) \
downcast<exp_slot_device &>(*device).set_ipl_handler(DEVCB_##_devcb);
// ======================> zorro 2 bus
#define MCFG_ZORRO2_ADD(_cputag) \
MCFG_DEVICE_ADD(ZORROBUS_TAG, ZORRO2, 0) \
downcast<zorro_device &>(*device).set_cputag(_cputag);
#define MCFG_ZORRO2_SLOT_ADD(_tag, _slot_intf, _def_slot) \
MCFG_ZORRO_SLOT_ADD(ZORROBUS_TAG, _tag, _slot_intf, _def_slot)
#define MCFG_ZORRO2_OVR_HANDLER(_devcb) \
downcast<zorro_device &>(*device).set_ovr_handler(DEVCB_##_devcb);
#define MCFG_ZORRO2_INT2_HANDLER(_devcb) \
downcast<zorro_device &>(*device).set_int2_handler(DEVCB_##_devcb);
#define MCFG_ZORRO2_INT6_HANDLER(_devcb) \
downcast<zorro_device &>(*device).set_int6_handler(DEVCB_##_devcb);
#define MCFG_ZORRO2_EINT1_HANDLER(_devcb) \
downcast<zorro2_device &>(*device).set_eint1_handler(DEVCB_##_devcb);
#define MCFG_ZORRO2_EINT4_HANDLER(_devcb) \
downcast<zorro2_device &>(*device).set_eint4_handler(DEVCB_##_devcb);
#define MCFG_ZORRO2_EINT5_HANDLER(_devcb) \
downcast<zorro2_device &>(*device).set_eint5_handler(DEVCB_##_devcb);
#define MCFG_ZORRO2_EINT7_HANDLER(_devcb) \
downcast<zorro2_device &>(*device).set_eint7_handler(DEVCB_##_devcb);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@ -222,6 +152,7 @@
class device_zorro_card_interface;
class device_exp_card_interface;
class device_zorro2_card_interface;
class zorro_device;
// ======================> zorro slot device
@ -230,18 +161,28 @@ class zorro_slot_device : public device_t, public device_slot_interface
public:
// construction/destruction
zorro_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
template <typename T, typename O>
zorro_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&zorrotag, O &&opts, const char *dflt)
: zorro_slot_device(mconfig, tag, owner, 0)
{
set_zorro_slot(std::forward<T>(zorrotag));
option_reset();
opts(*this);
set_default_option(dflt);
set_fixed(false);
}
// device-level overrides
virtual void device_start() override;
// inline configuration
void set_zorro_slot(device_t *owner, const char *zorro_tag) { m_owner = owner; m_zorro_tag = zorro_tag; }
template <class T> void set_zorro_slot(T &&zorro_tag) { m_zorro_bus.set_tag(zorro_tag); }
protected:
zorro_slot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// configuration
const char *m_zorro_tag;
required_device<zorro_device> m_zorro_bus;
};
// device type definition
@ -253,11 +194,11 @@ class zorro_device : public device_t
{
public:
// configuration helpers
void set_cputag(const char *tag) { m_cputag = tag; }
template <class T> void set_space(T &&tag, int spacenum) { m_space.set_tag(std::forward<T>(tag), spacenum); }
template <class Object> devcb_base &set_int2_handler(Object &&cb) { return m_int2_handler.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_int6_handler(Object &&cb) { return m_int6_handler.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_ovr_handler(Object &&cb) { return m_ovr_handler.set_callback(std::forward<Object>(cb)); }
auto int2_handler() { return m_int2_handler.bind(); }
auto int6_handler() { return m_int6_handler.bind(); }
auto ovr_handler() { return m_ovr_handler.bind(); }
virtual void add_card(device_zorro_card_interface *card) = 0;
@ -272,17 +213,18 @@ public:
virtual void fc_w(int code) = 0;
// access to the host space
address_space *m_space;
address_space &space() const { return *m_space; }
protected:
// construction/destruction
zorro_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
virtual void device_resolve_objects() override;
virtual void device_start() override;
private:
const char *m_cputag;
required_address_space m_space;
devcb_write_line m_ovr_handler;
devcb_write_line m_int2_handler;
@ -297,7 +239,7 @@ public:
// construction/destruction
exp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
template <class Object> devcb_base &set_ipl_handler(Object &&cb) { return m_ipl_handler.set_callback(std::forward<Object>(cb)); }
auto ipl_handler() { return m_ipl_handler.bind(); }
// the expansion slot can only have a single card
virtual void add_card(device_zorro_card_interface *card) override;
@ -333,10 +275,10 @@ public:
zorro2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
~zorro2_device();
template <class Object> devcb_base &set_eint1_handler(Object &&cb) { return m_eint1_handler.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_eint4_handler(Object &&cb) { return m_eint4_handler.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_eint5_handler(Object &&cb) { return m_eint5_handler.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_eint7_handler(Object &&cb) { return m_eint7_handler.set_callback(std::forward<Object>(cb)); }
auto eint1_handler() { return m_eint1_handler.bind(); }
auto eint4_handler() { return m_eint4_handler.bind(); }
auto eint5_handler() { return m_eint5_handler.bind(); }
auto eint7_handler() { return m_eint7_handler.bind(); }
// the zorro2 bus supports multiple cards
virtual void add_card(device_zorro_card_interface *card) override;

View File

@ -28,6 +28,14 @@
#include "speaker.h"
//**************************************************************************
// CONSTANTS / MACROS
//**************************************************************************
#define EXP_SLOT_TAG "exp"
#define ZORROBUS_TAG "zorrobus"
//**************************************************************************
// PRIVATE DEVICES
//**************************************************************************
@ -1687,17 +1695,19 @@ MACHINE_CONFIG_START(a2000_state::a2000)
MSM6242(config, m_rtc, XTAL(32'768));
// cpu slot
MCFG_EXPANSION_SLOT_ADD("maincpu", a2000_expansion_cards, nullptr)
EXP_SLOT(config, EXP_SLOT_TAG, 0).set_space(m_maincpu, AS_PROGRAM);
ZORRO_SLOT(config, "slot", EXP_SLOT_TAG, a2000_expansion_cards, nullptr);
// zorro slots
MCFG_ZORRO2_ADD("maincpu")
MCFG_ZORRO2_INT2_HANDLER(WRITELINE(*this, a2000_state, zorro2_int2_w))
MCFG_ZORRO2_INT6_HANDLER(WRITELINE(*this, a2000_state, zorro2_int6_w))
MCFG_ZORRO2_SLOT_ADD("zorro1", zorro2_cards, nullptr)
MCFG_ZORRO2_SLOT_ADD("zorro2", zorro2_cards, nullptr)
MCFG_ZORRO2_SLOT_ADD("zorro3", zorro2_cards, nullptr)
MCFG_ZORRO2_SLOT_ADD("zorro4", zorro2_cards, nullptr)
MCFG_ZORRO2_SLOT_ADD("zorro5", zorro2_cards, nullptr)
ZORRO2(config, m_zorro, 0);
m_zorro->set_space(m_maincpu, AS_PROGRAM);
m_zorro->int2_handler().set(FUNC(a2000_state::zorro2_int2_w));
m_zorro->int6_handler().set(FUNC(a2000_state::zorro2_int6_w));
ZORRO_SLOT(config, "zorro1", m_zorro, zorro2_cards, nullptr);
ZORRO_SLOT(config, "zorro2", m_zorro, zorro2_cards, nullptr);
ZORRO_SLOT(config, "zorro3", m_zorro, zorro2_cards, nullptr);
ZORRO_SLOT(config, "zorro4", m_zorro, zorro2_cards, nullptr);
ZORRO_SLOT(config, "zorro5", m_zorro, zorro2_cards, nullptr);
MACHINE_CONFIG_END
MACHINE_CONFIG_START(a2000_state::a2000n)
@ -1731,9 +1741,10 @@ MACHINE_CONFIG_START(a500_state::a500)
ADDRESS_MAP_BANK(config, "overlay").set_map(&amiga_state::overlay_1mb_map).set_options(ENDIANNESS_BIG, 16, 22, 0x200000);
// cpu slot
MCFG_EXPANSION_SLOT_ADD("maincpu", a500_expansion_cards, nullptr)
MCFG_EXPANSION_SLOT_INT2_HANDLER(WRITELINE(*this, a500_state, side_int2_w))
MCFG_EXPANSION_SLOT_INT6_HANDLER(WRITELINE(*this, a500_state, side_int6_w))
EXP_SLOT(config, m_side, 0).set_space(m_maincpu, AS_PROGRAM);
m_side->int2_handler().set(FUNC(a500_state::side_int2_w));
m_side->int6_handler().set(FUNC(a500_state::side_int6_w));
ZORRO_SLOT(config, "slot", m_side, a500_expansion_cards, nullptr);
MACHINE_CONFIG_END
MACHINE_CONFIG_START(a500_state::a500n)
@ -1882,7 +1893,8 @@ MACHINE_CONFIG_START(a500p_state::a500p)
MSM6242(config, m_rtc, XTAL(32'768));
// cpu slot
MCFG_EXPANSION_SLOT_ADD("maincpu", a500_expansion_cards, nullptr)
EXP_SLOT(config, m_side, 0).set_space(m_maincpu, AS_PROGRAM);
ZORRO_SLOT(config, "slot", m_side, a500_expansion_cards, nullptr);
// software
SOFTWARE_LIST(config, "ecs_list").set_original("amigaecs_flop");