mirror of
https://github.com/holub/mame
synced 2025-07-03 17:08:39 +03:00
gio64: simplify (nw)
This commit is contained in:
parent
564a068065
commit
891f079028
@ -21,24 +21,16 @@ void gio64_cards(device_slot_interface &device)
|
||||
|
||||
DEFINE_DEVICE_TYPE(GIO64_SLOT, gio64_slot_device, "gio64_slot", "SGI GIO64 Slot")
|
||||
|
||||
gio64_slot_device::gio64_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: gio64_slot_device(mconfig, GIO64_SLOT, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
gio64_slot_device::gio64_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)
|
||||
gio64_slot_device::gio64_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, slot_type_t slot_type)
|
||||
: device_t(mconfig, GIO64_SLOT, tag, owner, clock)
|
||||
, device_slot_interface(mconfig, *this)
|
||||
, m_gio64(*this, finder_base::DUMMY_TAG)
|
||||
, m_slot_type(GIO64_SLOT_COUNT)
|
||||
, m_slot_type(slot_type)
|
||||
{
|
||||
}
|
||||
|
||||
void gio64_slot_device::device_validity_check(validity_checker &valid) const
|
||||
{
|
||||
if (m_slot_type == GIO64_SLOT_COUNT)
|
||||
osd_printf_error("Slot type not defined\n");
|
||||
|
||||
device_t *const card(get_card_device());
|
||||
if (card && !dynamic_cast<device_gio64_card_interface *>(card))
|
||||
osd_printf_error("Card device %s (%s) does not implement device_gio64_card_interface\n", card->tag(), card->name());
|
||||
@ -76,8 +68,7 @@ gio64_device::gio64_device(const machine_config &mconfig, const char *tag, devic
|
||||
gio64_device::gio64_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_memory_interface(mconfig, *this)
|
||||
, m_space_config("GIO64 Space", ENDIANNESS_BIG, 64, 32, 0, address_map_constructor())
|
||||
, m_maincpu(*this, finder_base::DUMMY_TAG)
|
||||
, m_space_config("GIO64 Space", ENDIANNESS_BIG, 64, 32, 0)
|
||||
, m_interrupt_cb(*this)
|
||||
{
|
||||
}
|
||||
@ -90,28 +81,16 @@ void gio64_device::device_resolve_objects()
|
||||
void gio64_device::device_start()
|
||||
{
|
||||
std::fill(std::begin(m_device_list), std::end(m_device_list), nullptr);
|
||||
|
||||
m_space = &space(0);
|
||||
m_space->install_readwrite_handler(0x00000000, 0x003fffff, read64_delegate(*this, FUNC(gio64_device::no_gfx_r)), write64_delegate(*this, FUNC(gio64_device::no_gfx_w)));
|
||||
m_space->install_readwrite_handler(0x00400000, 0x005fffff, read64_delegate(*this, FUNC(gio64_device::no_exp0_r)), write64_delegate(*this, FUNC(gio64_device::no_exp0_w)));
|
||||
m_space->install_readwrite_handler(0x00600000, 0x009fffff, read64_delegate(*this, FUNC(gio64_device::no_exp1_r)), write64_delegate(*this, FUNC(gio64_device::no_exp1_w)));
|
||||
}
|
||||
|
||||
READ64_MEMBER(gio64_device::no_gfx_r) { return ~0ULL; }
|
||||
READ64_MEMBER(gio64_device::no_exp0_r) { return ~0ULL; }
|
||||
READ64_MEMBER(gio64_device::no_exp1_r) { return ~0ULL; }
|
||||
WRITE64_MEMBER(gio64_device::no_gfx_w) { }
|
||||
WRITE64_MEMBER(gio64_device::no_exp0_w) { }
|
||||
WRITE64_MEMBER(gio64_device::no_exp1_w) { }
|
||||
|
||||
READ64_MEMBER(gio64_device::read)
|
||||
u64 gio64_device::read(offs_t offset, u64 mem_mask)
|
||||
{
|
||||
return m_space->read_qword(offset << 3, mem_mask);
|
||||
return space(0).read_qword(offset << 3, mem_mask);
|
||||
}
|
||||
|
||||
WRITE64_MEMBER(gio64_device::write)
|
||||
void gio64_device::write(offs_t offset, u64 data, u64 mem_mask)
|
||||
{
|
||||
m_space->write_qword(offset << 3, data, mem_mask);
|
||||
space(0).write_qword(offset << 3, data, mem_mask);
|
||||
}
|
||||
|
||||
device_gio64_card_interface *gio64_device::get_gio64_card(int slot)
|
||||
@ -129,20 +108,10 @@ device_gio64_card_interface *gio64_device::get_gio64_card(int slot)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void gio64_device::add_gio64_card(gio64_slot_device::slot_type_t slot_type, device_gio64_card_interface *card)
|
||||
{
|
||||
assert(slot_type >= 0 && slot_type < gio64_slot_device::GIO64_SLOT_COUNT);
|
||||
m_device_list[slot_type] = card;
|
||||
card->install_device();
|
||||
}
|
||||
|
||||
|
||||
|
||||
device_gio64_card_interface::device_gio64_card_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_interface(device, "sgigio64")
|
||||
, m_gio64(nullptr)
|
||||
, m_gio64_slottag(nullptr)
|
||||
, m_slot_type(gio64_slot_device::GIO64_SLOT_COUNT)
|
||||
{
|
||||
}
|
||||
|
||||
@ -150,10 +119,6 @@ device_gio64_card_interface::~device_gio64_card_interface()
|
||||
{
|
||||
}
|
||||
|
||||
void device_gio64_card_interface::interface_validity_check(validity_checker &valid) const
|
||||
{
|
||||
}
|
||||
|
||||
void device_gio64_card_interface::interface_pre_start()
|
||||
{
|
||||
if (!m_gio64)
|
||||
@ -165,13 +130,9 @@ void device_gio64_card_interface::interface_pre_start()
|
||||
throw device_missing_dependencies();
|
||||
}
|
||||
|
||||
void device_gio64_card_interface::interface_post_start()
|
||||
{
|
||||
m_gio64->add_gio64_card(m_slot_type, this);
|
||||
}
|
||||
|
||||
void device_gio64_card_interface::set_gio64(gio64_device *gio64, gio64_slot_device::slot_type_t slot_type)
|
||||
{
|
||||
m_gio64 = gio64;
|
||||
m_slot_type = slot_type;
|
||||
|
||||
m_gio64->install_card(slot_type, *this, &device_gio64_card_interface::mem_map);
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpu/mips/r4000.h"
|
||||
|
||||
class gio64_device;
|
||||
|
||||
class gio64_slot_device : public device_t, public device_slot_interface
|
||||
@ -20,11 +18,9 @@ class gio64_slot_device : public device_t, public device_slot_interface
|
||||
public:
|
||||
enum slot_type_t : uint32_t
|
||||
{
|
||||
GIO64_SLOT_GFX,
|
||||
GIO64_SLOT_EXP0,
|
||||
GIO64_SLOT_EXP1,
|
||||
|
||||
GIO64_SLOT_COUNT
|
||||
GIO64_SLOT_GFX = 0,
|
||||
GIO64_SLOT_EXP0 = 1,
|
||||
GIO64_SLOT_EXP1 = 2,
|
||||
};
|
||||
|
||||
// construction/destruction
|
||||
@ -37,13 +33,10 @@ public:
|
||||
set_default_option(dflt);
|
||||
set_fixed(false);
|
||||
m_gio64.set_tag(std::forward<T>(gio64_tag));
|
||||
m_slot_type = slot_type;
|
||||
}
|
||||
gio64_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
gio64_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, slot_type_t slot_type = GIO64_SLOT_EXP0);
|
||||
|
||||
protected:
|
||||
gio64_slot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// device-level overrides
|
||||
virtual void device_validity_check(validity_checker &valid) const override;
|
||||
virtual void device_resolve_objects() override;
|
||||
@ -51,7 +44,7 @@ protected:
|
||||
|
||||
// configuration
|
||||
required_device<gio64_device> m_gio64;
|
||||
slot_type_t m_slot_type;
|
||||
slot_type_t const m_slot_type;
|
||||
|
||||
DECLARE_READ32_MEMBER(timeout_r);
|
||||
DECLARE_WRITE32_MEMBER(timeout_w);
|
||||
@ -76,16 +69,9 @@ public:
|
||||
protected:
|
||||
device_gio64_card_interface(const machine_config &mconfig, device_t &device);
|
||||
|
||||
virtual void interface_validity_check(validity_checker &valid) const override;
|
||||
virtual void interface_pre_start() override;
|
||||
virtual void interface_post_start() override;
|
||||
virtual void install_device() = 0;
|
||||
|
||||
gio64_device &gio64() { assert(m_gio64); return *m_gio64; }
|
||||
|
||||
gio64_device *m_gio64;
|
||||
const char *m_gio64_slottag;
|
||||
gio64_slot_device::slot_type_t m_slot_type;
|
||||
};
|
||||
|
||||
|
||||
@ -99,41 +85,35 @@ public:
|
||||
gio64_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu_tag)
|
||||
: gio64_device(mconfig, tag, owner, (uint32_t)0)
|
||||
{
|
||||
set_cpu_tag(std::forward<T>(cpu_tag));
|
||||
}
|
||||
|
||||
gio64_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// inline configuration
|
||||
template <typename T> void set_cpu_tag(T &&tag) { m_maincpu.set_tag(std::forward<T>(tag)); }
|
||||
template <int N> auto interrupt_cb() { return m_interrupt_cb[N].bind(); }
|
||||
|
||||
virtual space_config_vector memory_space_config() const override;
|
||||
|
||||
const address_space_config m_space_config;
|
||||
|
||||
void add_gio64_card(gio64_slot_device::slot_type_t slot_type, device_gio64_card_interface *card);
|
||||
device_gio64_card_interface *get_gio64_card(int slot);
|
||||
|
||||
template<typename T> void install_graphics(T &device, void (T::*map)(class address_map &map), uint64_t unitmask = ~u64(0))
|
||||
template<typename T> void install_card(gio64_slot_device::slot_type_t slot_type, T &device, void (T::*map)(class address_map &map))
|
||||
{
|
||||
m_space->install_device(0x000000, 0x3fffff, device, map, unitmask);
|
||||
}
|
||||
m_device_list[slot_type] = &device;
|
||||
|
||||
template<typename T> void install_expansion(int index, T &device, void (T::*map)(class address_map &map), uint64_t unitmask = ~u64(0))
|
||||
{
|
||||
if (index == 0)
|
||||
m_space->install_device(0x400000, 0x5fffff, device, map, unitmask);
|
||||
else if (index == 1)
|
||||
m_space->install_device(0x600000, 0x9fffff, device, map, unitmask);
|
||||
else
|
||||
fatalerror("Invalid SGI GIO64 expansion slot index: %d\n", index);
|
||||
switch (slot_type)
|
||||
{
|
||||
case gio64_slot_device::GIO64_SLOT_GFX: space(0).install_device(0x000000, 0x3fffff, device, map); break;
|
||||
case gio64_slot_device::GIO64_SLOT_EXP0: space(0).install_device(0x400000, 0x5fffff, device, map); break;
|
||||
case gio64_slot_device::GIO64_SLOT_EXP1: space(0).install_device(0x600000, 0x9fffff, device, map); break;
|
||||
}
|
||||
}
|
||||
|
||||
template <int N> DECLARE_WRITE_LINE_MEMBER(interrupt) { m_interrupt_cb[N](state); }
|
||||
|
||||
DECLARE_READ64_MEMBER(read);
|
||||
DECLARE_WRITE64_MEMBER(write);
|
||||
u64 read(offs_t offset, u64 mem_mask);
|
||||
void write(offs_t offset, u64 data, u64 mem_mask);
|
||||
|
||||
protected:
|
||||
gio64_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
@ -143,20 +123,10 @@ protected:
|
||||
virtual void device_start() override;
|
||||
|
||||
// internal state
|
||||
required_device<r4000_base_device> m_maincpu;
|
||||
address_space *m_space;
|
||||
|
||||
device_gio64_card_interface *m_device_list[3];
|
||||
|
||||
private:
|
||||
devcb_write_line::array<3> m_interrupt_cb;
|
||||
|
||||
DECLARE_READ64_MEMBER(no_gfx_r);
|
||||
DECLARE_READ64_MEMBER(no_exp0_r);
|
||||
DECLARE_READ64_MEMBER(no_exp1_r);
|
||||
DECLARE_WRITE64_MEMBER(no_gfx_w);
|
||||
DECLARE_WRITE64_MEMBER(no_exp0_w);
|
||||
DECLARE_WRITE64_MEMBER(no_exp1_w);
|
||||
};
|
||||
|
||||
DECLARE_DEVICE_TYPE(GIO64, gio64_device)
|
||||
|
@ -4436,11 +4436,6 @@ WRITE64_MEMBER(newport_base_device::rex3_w)
|
||||
}
|
||||
}
|
||||
|
||||
void newport_base_device::install_device()
|
||||
{
|
||||
m_gio64->install_graphics(*this, &newport_base_device::mem_map);
|
||||
}
|
||||
|
||||
void newport_base_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
VC2(config, m_vc2, 0);
|
||||
|
@ -292,9 +292,6 @@ class newport_base_device : public device_t
|
||||
public:
|
||||
newport_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// device_gio_slot_interface overrides
|
||||
virtual void install_device() override;
|
||||
|
||||
DECLARE_READ64_MEMBER(rex3_r);
|
||||
DECLARE_WRITE64_MEMBER(rex3_w);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user