nubus: Use required_address_space rather than old-style CPU lookup (nw)

This commit is contained in:
AJR 2019-02-26 09:17:30 -05:00
parent e02a5cf1f5
commit b5758a744a
3 changed files with 30 additions and 37 deletions

View File

@ -70,23 +70,24 @@ nubus_device::nubus_device(const machine_config &mconfig, const char *tag, devic
nubus_device::nubus_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_maincpu(nullptr),
m_space(*this, finder_base::DUMMY_TAG, -1),
m_out_irq9_cb(*this),
m_out_irqa_cb(*this),
m_out_irqb_cb(*this),
m_out_irqc_cb(*this),
m_out_irqd_cb(*this),
m_out_irqe_cb(*this),
m_cputag(nullptr)
m_out_irqe_cb(*this)
{
}
//-------------------------------------------------
// device_start - device-specific startup
// device_resolve_objects - resolve objects that
// may be needed for other devices to set
// initial conditions at start time
//-------------------------------------------------
void nubus_device::device_start()
void nubus_device::device_resolve_objects()
{
m_maincpu = machine().device<cpu_device>(m_cputag);
// resolve callbacks
m_out_irq9_cb.resolve_safe();
m_out_irqa_cb.resolve_safe();
@ -97,10 +98,10 @@ void nubus_device::device_start()
}
//-------------------------------------------------
// device_reset - device-specific reset
// device_start - device-specific startup
//-------------------------------------------------
void nubus_device::device_reset()
void nubus_device::device_start()
{
}
@ -111,15 +112,14 @@ void nubus_device::add_nubus_card(device_nubus_card_interface *card)
void nubus_device::install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler, uint32_t mask)
{
m_maincpu = machine().device<cpu_device>(m_cputag);
int buswidth = m_maincpu->space_config(AS_PROGRAM)->data_width();
int buswidth = m_space->data_width();
switch(buswidth)
{
case 32:
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(start, end, rhandler, whandler, mask);
m_space->install_readwrite_handler(start, end, rhandler, whandler, mask);
break;
case 64:
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(start, end, rhandler, whandler, ((uint64_t)mask<<32)|mask);
m_space->install_readwrite_handler(start, end, rhandler, whandler, ((uint64_t)mask<<32)|mask);
break;
default:
fatalerror("NUBUS: Bus width %d not supported\n", buswidth);
@ -128,15 +128,14 @@ void nubus_device::install_device(offs_t start, offs_t end, read8_delegate rhand
void nubus_device::install_device(offs_t start, offs_t end, read16_delegate rhandler, write16_delegate whandler, uint32_t mask)
{
m_maincpu = machine().device<cpu_device>(m_cputag);
int buswidth = m_maincpu->space_config(AS_PROGRAM)->data_width();
int buswidth = m_space->data_width();
switch(buswidth)
{
case 32:
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(start, end, rhandler, whandler, mask);
m_space->install_readwrite_handler(start, end, rhandler, whandler, mask);
break;
case 64:
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(start, end, rhandler, whandler, ((uint64_t)mask<<32)|mask);
m_space->install_readwrite_handler(start, end, rhandler, whandler, ((uint64_t)mask<<32)|mask);
break;
default:
fatalerror("NUBUS: Bus width %d not supported\n", buswidth);
@ -145,15 +144,14 @@ void nubus_device::install_device(offs_t start, offs_t end, read16_delegate rhan
void nubus_device::install_device(offs_t start, offs_t end, read32_delegate rhandler, write32_delegate whandler, uint32_t mask)
{
m_maincpu = machine().device<cpu_device>(m_cputag);
int buswidth = m_maincpu->space_config(AS_PROGRAM)->data_width();
int buswidth = m_space->data_width();
switch(buswidth)
{
case 32:
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(start, end, rhandler, whandler, mask);
m_space->install_readwrite_handler(start, end, rhandler, whandler, mask);
break;
case 64:
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(start, end, rhandler, whandler, ((uint64_t)mask<<32)|mask);
m_space->install_readwrite_handler(start, end, rhandler, whandler, ((uint64_t)mask<<32)|mask);
break;
default:
fatalerror("NUBUS: Bus width %d not supported\n", buswidth);
@ -162,15 +160,14 @@ void nubus_device::install_device(offs_t start, offs_t end, read32_delegate rhan
void nubus_device::install_readonly_device(offs_t start, offs_t end, read32_delegate rhandler, uint32_t mask)
{
m_maincpu = machine().device<cpu_device>(m_cputag);
int buswidth = m_maincpu->space_config(AS_PROGRAM)->data_width();
int buswidth = m_space->data_width();
switch(buswidth)
{
case 32:
m_maincpu->space(AS_PROGRAM).install_read_handler(start, end, rhandler, mask);
m_space->install_read_handler(start, end, rhandler, mask);
break;
case 64:
m_maincpu->space(AS_PROGRAM).install_read_handler(start, end, rhandler, ((uint64_t)mask<<32)|mask);
m_space->install_read_handler(start, end, rhandler, ((uint64_t)mask<<32)|mask);
break;
default:
fatalerror("NUBUS: Bus width %d not supported\n", buswidth);
@ -179,15 +176,14 @@ void nubus_device::install_readonly_device(offs_t start, offs_t end, read32_dele
void nubus_device::install_writeonly_device(offs_t start, offs_t end, write32_delegate whandler, uint32_t mask)
{
m_maincpu = machine().device<cpu_device>(m_cputag);
int buswidth = m_maincpu->space_config(AS_PROGRAM)->data_width();
int buswidth = m_space->data_width();
switch(buswidth)
{
case 32:
m_maincpu->space(AS_PROGRAM).install_write_handler(start, end, whandler, mask);
m_space->install_write_handler(start, end, whandler, mask);
break;
case 64:
m_maincpu->space(AS_PROGRAM).install_write_handler(start, end, whandler, ((uint64_t)mask<<32)|mask);
m_space->install_write_handler(start, end, whandler, ((uint64_t)mask<<32)|mask);
break;
default:
fatalerror("NUBUS: Bus width %d not supported\n", buswidth);
@ -197,9 +193,7 @@ void nubus_device::install_writeonly_device(offs_t start, offs_t end, write32_de
void nubus_device::install_bank(offs_t start, offs_t end, const char *tag, uint8_t *data)
{
// printf("install_bank: %s @ %x->%x\n", tag, start, end);
m_maincpu = machine().device<cpu_device>(m_cputag);
address_space &space = m_maincpu->space(AS_PROGRAM);
space.install_readwrite_bank(start, end, 0, tag );
m_space->install_readwrite_bank(start, end, 0, tag);
machine().root_device().membank(siblingtag(tag).c_str())->set_base(data);
}

View File

@ -62,7 +62,7 @@ public:
~nubus_device() { m_device_list.detach_all(); }
// inline configuration
void set_cputag(const char *tag) { m_cputag = tag; }
template <typename T> void set_space(T &&tag, int spacenum) { m_space.set_tag(std::forward<T>(tag), spacenum); }
auto out_irq9_callback() { return m_out_irq9_cb.bind(); }
auto out_irqa_callback() { return m_out_irqa_cb.bind(); }
auto out_irqb_callback() { return m_out_irqb_cb.bind(); }
@ -90,11 +90,11 @@ protected:
nubus_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;
virtual void device_reset() override;
// internal state
cpu_device *m_maincpu;
required_address_space m_space;
devcb_write_line m_out_irq9_cb;
devcb_write_line m_out_irqa_cb;
@ -104,7 +104,6 @@ protected:
devcb_write_line m_out_irqe_cb;
simple_list<device_nubus_card_interface> m_device_list;
const char *m_cputag;
};

View File

@ -1095,7 +1095,7 @@ void mac_state::add_macplus_additions(machine_config &config)
void mac_state::add_nubus(machine_config &config, bool bank1, bool bank2)
{
nubus_device &nubus(NUBUS(config, "nubus", 0));
nubus.set_cputag("maincpu");
nubus.set_space(m_maincpu, AS_PROGRAM);
nubus.out_irq9_callback().set(FUNC(mac_state::nubus_irq_9_w));
nubus.out_irqa_callback().set(FUNC(mac_state::nubus_irq_a_w));
nubus.out_irqb_callback().set(FUNC(mac_state::nubus_irq_b_w));
@ -1119,7 +1119,7 @@ void mac_state::add_nubus(machine_config &config, bool bank1, bool bank2)
template <typename T> void mac_state::add_nubus_pds(machine_config &config, const char *slot_tag, T &&opts)
{
nubus_device &nubus(NUBUS(config, "pds", 0));
nubus.set_cputag("maincpu");
nubus.set_space(m_maincpu, AS_PROGRAM);
nubus.out_irq9_callback().set(FUNC(mac_state::nubus_irq_9_w));
nubus.out_irqa_callback().set(FUNC(mac_state::nubus_irq_a_w));
nubus.out_irqb_callback().set(FUNC(mac_state::nubus_irq_b_w));