summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--scripts/src/cpu.lua2
-rw-r--r--src/devices/cpu/sh2/sh7604_bus.cpp181
-rw-r--r--src/devices/cpu/sh2/sh7604_bus.h87
-rw-r--r--src/mame/etc/template_device.cpp10
-rw-r--r--src/mame/etc/template_device.h6
5 files changed, 274 insertions, 12 deletions
diff --git a/scripts/src/cpu.lua b/scripts/src/cpu.lua
index a9dfe0ecd70..9c81a05051c 100644
--- a/scripts/src/cpu.lua
+++ b/scripts/src/cpu.lua
@@ -646,6 +646,8 @@ if (CPUS["SH2"]~=null) then
MAME_DIR .. "src/devices/cpu/sh2/sh2.cpp",
MAME_DIR .. "src/devices/cpu/sh2/sh2.h",
MAME_DIR .. "src/devices/cpu/sh2/sh2fe.cpp",
+ MAME_DIR .. "src/devices/cpu/sh2/sh7604_bus.cpp",
+ MAME_DIR .. "src/devices/cpu/sh2/sh7604_bus.h",
--MAME_DIR .. "src/devices/cpu/sh2/sh2comn.cpp",
--MAME_DIR .. "src/devices/cpu/sh2/sh2comn.h",
--MAME_DIR .. "src/devices/cpu/sh2/sh2drc.cpp",
diff --git a/src/devices/cpu/sh2/sh7604_bus.cpp b/src/devices/cpu/sh2/sh7604_bus.cpp
new file mode 100644
index 00000000000..47c7cdccefd
--- /dev/null
+++ b/src/devices/cpu/sh2/sh7604_bus.cpp
@@ -0,0 +1,181 @@
+// license:BSD-3-Clause
+// copyright-holders:Angelo Salese
+/***************************************************************************
+
+ SH7604 BUS Controller
+
+ Lies at 0xffffffe0-0xffffffff
+
+
+
+ TODO:
+ - Host CPU setter (is_slave and clock are needed);
+ - timer clock emulation;
+ - fix fatalerrors;
+ - bus control stuff, someday;
+
+***************************************************************************/
+
+#include "emu.h"
+#include "sh7604_bus.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+const device_type SH7604_BUS = &device_creator<sh7604_bus_device>;
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+READ16_MEMBER(sh7604_bus_device::bus_control_1_r)
+{
+ return (m_bcr1 & 0x1ff7) | (m_is_slave == true ? 0x8000 : 0);
+}
+
+WRITE16_MEMBER(sh7604_bus_device::bus_control_1_w)
+{
+ COMBINE_DATA(&m_bcr1);
+ if(m_bcr1 & 0x1000) // ENDIAN
+ throw emu_fatalerror("%s: enabled little endian for Area 2\n", tag());
+ if(m_bcr1 & 0x0800) // PSHR
+ throw emu_fatalerror("%s: enabled partial space share mode\n", tag());
+}
+
+READ16_MEMBER(sh7604_bus_device::bus_control_2_r) { return m_bcr2 & 0x00fc; }
+WRITE16_MEMBER(sh7604_bus_device::bus_control_2_w)
+{
+ COMBINE_DATA(&m_bcr2);
+ if(m_bcr2 != 0x00fc)
+ throw emu_fatalerror("%s: unexpected bus size register set %04x\n", tag(),data);
+}
+
+READ16_MEMBER(sh7604_bus_device::wait_control_r) { return m_wcr; }
+WRITE16_MEMBER(sh7604_bus_device::wait_control_w) { COMBINE_DATA(&m_wcr); }
+
+READ16_MEMBER(sh7604_bus_device::memory_control_r) { return m_mcr & 0xfefc; }
+WRITE16_MEMBER(sh7604_bus_device::memory_control_w) { COMBINE_DATA(&m_mcr); }
+
+READ16_MEMBER(sh7604_bus_device::refresh_timer_status_r)
+{
+ return m_rtcsr & 0x00f8;
+}
+
+WRITE16_MEMBER(sh7604_bus_device::refresh_timer_control_w)
+{
+ COMBINE_DATA(&m_rtcsr);
+
+ if(m_rtcsr & 0x40)
+ throw emu_fatalerror("%s: enabled timer irq register with clock setting = %02x\n",tag(),data & 0x38);
+}
+
+READ16_MEMBER(sh7604_bus_device::refresh_timer_counter_r)
+{
+ throw emu_fatalerror("%s: reading timer counter!\n",tag());
+ return 0;
+}
+
+WRITE16_MEMBER(sh7604_bus_device::refresh_timer_counter_w)
+{
+ throw emu_fatalerror("%s: writing timer counter %04x\n",tag(),data);
+ //COMBINE_DATA(&m_rtcnt);
+}
+
+READ16_MEMBER(sh7604_bus_device::refresh_timer_constant_r)
+{
+ return m_rtcor & 0xff;
+}
+
+WRITE16_MEMBER(sh7604_bus_device::refresh_timer_constant_w)
+{
+ COMBINE_DATA(&m_rtcor);
+}
+
+static ADDRESS_MAP_START( bus_regs, AS_0, 16, sh7604_bus_device )
+ AM_RANGE(0x00, 0x01) AM_READWRITE(bus_control_1_r, bus_control_1_w)
+ AM_RANGE(0x02, 0x03) AM_READWRITE(bus_control_2_r, bus_control_2_w)
+ AM_RANGE(0x04, 0x05) AM_READWRITE(wait_control_r, wait_control_w)
+ AM_RANGE(0x06, 0x07) AM_READWRITE(memory_control_r, memory_control_w)
+ AM_RANGE(0x08, 0x09) AM_READWRITE(refresh_timer_status_r, refresh_timer_control_w)
+ AM_RANGE(0x0a, 0x0b) AM_READWRITE(refresh_timer_counter_r, refresh_timer_counter_w)
+ AM_RANGE(0x0c, 0x0d) AM_READWRITE(refresh_timer_constant_r, refresh_timer_constant_w)
+// AM_RANGE(0x0e, 0x0f) unmapped, mirror?
+ADDRESS_MAP_END
+
+//-------------------------------------------------
+// sh7604_bus_device - constructor
+//-------------------------------------------------
+
+sh7604_bus_device::sh7604_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, SH7604_BUS, "sh7604_bus_longname", tag, owner, clock, "sh7604_bus", __FILE__),
+ device_memory_interface(mconfig, *this),
+ m_space_config("regs", ENDIANNESS_BIG, 16, 4, 0, nullptr, *ADDRESS_MAP_NAME(bus_regs))
+{
+}
+
+
+const address_space_config *sh7604_bus_device::memory_space_config(address_spacenum spacenum) const
+{
+ return (spacenum == AS_0) ? &m_space_config : nullptr;
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void sh7604_bus_device::device_start()
+{
+}
+
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void sh7604_bus_device::device_reset()
+{
+ m_bcr1 = 0x03f0;
+ m_bcr2 = 0x00fc;
+ m_wcr = 0xaaff;
+ m_mcr = 0x0000;
+ m_rtcsr = 0x0000;
+ m_rtcor = 0x0000;
+}
+
+
+//**************************************************************************
+// READ/WRITE HANDLERS
+//**************************************************************************
+
+inline void sh7604_bus_device::writeword(offs_t address, UINT16 data)
+{
+ space().write_word(address, data);
+}
+
+inline UINT16 sh7604_bus_device::readword(offs_t address)
+{
+ return space().read_word(address);
+}
+
+READ32_MEMBER( sh7604_bus_device::read )
+{
+ // 16 bit access only, TODO
+ return readword(offset);
+}
+
+WRITE32_MEMBER( sh7604_bus_device::write )
+{
+ // TODO: 8 bit access is invalid
+ // if accessing bits 16-31, one must write ID = 0xa55a
+ if(ACCESSING_BITS_16_31)
+ {
+ // throw fatalerror if something trips it, presumably the write is going to be ignored
+ if((data & 0xffff0000) != 0xa55a0000)
+ throw emu_fatalerror("%s: making bus write with ID signature = %04x!\n", tag(),data >> 16);
+ }
+
+ writeword(offset,data & 0xffff);
+}
diff --git a/src/devices/cpu/sh2/sh7604_bus.h b/src/devices/cpu/sh2/sh7604_bus.h
new file mode 100644
index 00000000000..cd97e9064c6
--- /dev/null
+++ b/src/devices/cpu/sh2/sh7604_bus.h
@@ -0,0 +1,87 @@
+// license:BSD-3-Clause
+// copyright-holders:<author_name>
+/***************************************************************************
+
+Template for skeleton device
+
+***************************************************************************/
+
+#pragma once
+
+#ifndef __SH7604_BUSDEV_H__
+#define __SH7604_BUSDEV_H__
+
+
+
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
+
+#define MCFG_SH7604_BUS_ADD(_tag,_freq) \
+ MCFG_DEVICE_ADD(_tag, SH7604_BUS, _freq)
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> sh7604_bus_device
+
+class sh7604_bus_device : public device_t,
+ public device_memory_interface
+{
+public:
+ // construction/destruction
+ sh7604_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ // I/O operations
+ DECLARE_WRITE32_MEMBER( write );
+ DECLARE_READ32_MEMBER( read );
+ DECLARE_READ16_MEMBER( bus_control_1_r );
+ DECLARE_WRITE16_MEMBER( bus_control_1_w );
+ DECLARE_READ16_MEMBER( bus_control_2_r );
+ DECLARE_WRITE16_MEMBER( bus_control_2_w );
+ DECLARE_READ16_MEMBER( wait_control_r );
+ DECLARE_WRITE16_MEMBER( wait_control_w );
+ DECLARE_READ16_MEMBER( memory_control_r );
+ DECLARE_WRITE16_MEMBER( memory_control_w );
+ DECLARE_READ16_MEMBER( refresh_timer_status_r );
+ DECLARE_WRITE16_MEMBER( refresh_timer_control_w );
+ DECLARE_READ16_MEMBER( refresh_timer_counter_r );
+ DECLARE_WRITE16_MEMBER( refresh_timer_counter_w );
+ DECLARE_READ16_MEMBER( refresh_timer_constant_r );
+ DECLARE_WRITE16_MEMBER( refresh_timer_constant_w );
+ virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override;
+
+protected:
+ // device-level overrides
+ //virtual void device_validity_check(validity_checker &valid) const;
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+private:
+ bool m_is_slave;
+ const address_space_config m_space_config;
+ void writeword(offs_t address, UINT16 data);
+ UINT16 readword(offs_t address);
+
+ UINT16 m_bcr1;
+ UINT16 m_bcr2;
+ UINT16 m_wcr;
+ UINT16 m_mcr;
+ UINT16 m_rtcsr;
+ UINT16 m_rtcor;
+};
+
+
+// device type definition
+extern const device_type SH7604_BUS;
+
+
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+
+
+#endif
diff --git a/src/mame/etc/template_device.cpp b/src/mame/etc/template_device.cpp
index 2e325d909d3..903a2c63c73 100644
--- a/src/mame/etc/template_device.cpp
+++ b/src/mame/etc/template_device.cpp
@@ -7,7 +7,7 @@ Template for skeleton device
***************************************************************************/
#include "emu.h"
-#include "machine/xxx.h"
+#include "xxx.h"
@@ -33,14 +33,6 @@ xxx_device::xxx_device(const machine_config &mconfig, const char *tag, device_t
}
-//-------------------------------------------------
-// device_validity_check - perform validity checks
-// on this device
-//-------------------------------------------------
-
-void xxx_device::device_validity_check(validity_checker &valid) const
-{
-}
//-------------------------------------------------
diff --git a/src/mame/etc/template_device.h b/src/mame/etc/template_device.h
index 2173165181c..748e7e34e46 100644
--- a/src/mame/etc/template_device.h
+++ b/src/mame/etc/template_device.h
@@ -38,9 +38,9 @@ public:
protected:
// device-level overrides
- virtual void device_validity_check(validity_checker &valid) const;
- virtual void device_start();
- virtual void device_reset();
+// virtual void device_validity_check(validity_checker &valid) const;
+ virtual void device_start() override;
+ virtual void device_reset() override;
};