summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2024-03-18 10:16:28 +0100
committer Olivier Galibert <galibert@pobox.com>2024-03-18 22:46:54 +0100
commitb0a26688019fc5e97390ac8ba6503098723e9480 (patch)
tree523f3d4bfbf4b3ccaf75d5e58ad311ee25f3f95d
parent6bccd589c1a429246fba782607f5c24096e78430 (diff)
sh7042: Start introducing the interrupts
-rw-r--r--src/devices/cpu/sh/sh7042.cpp7
-rw-r--r--src/devices/cpu/sh/sh7042.h2
-rw-r--r--src/devices/cpu/sh/sh_intc.cpp41
-rw-r--r--src/devices/cpu/sh/sh_intc.h6
4 files changed, 52 insertions, 4 deletions
diff --git a/src/devices/cpu/sh/sh7042.cpp b/src/devices/cpu/sh/sh7042.cpp
index 7ef10f19ce1..dc2659b7a7e 100644
--- a/src/devices/cpu/sh/sh7042.cpp
+++ b/src/devices/cpu/sh/sh7042.cpp
@@ -297,3 +297,10 @@ void sh7042_device::pcf_if_w(offs_t, u16 data, u16 mem_mask)
COMBINE_DATA(&m_pcf_if);
logerror("pcf if = %04x\n", m_pcf_if);
}
+
+void sh7042_device::set_internal_interrupt(int level, u32 vector)
+{
+ m_sh2_state->internal_irq_level = level;
+ m_internal_irq_vector = vector;
+ m_test_irq = 1;
+}
diff --git a/src/devices/cpu/sh/sh7042.h b/src/devices/cpu/sh/sh7042.h
index 55795fd8282..ac1ee769180 100644
--- a/src/devices/cpu/sh/sh7042.h
+++ b/src/devices/cpu/sh/sh7042.h
@@ -44,6 +44,8 @@ public:
u64 current_cycles() { return machine().time().as_ticks(clock()); }
+ void set_internal_interrupt(int level, u32 vector);
+
protected:
const char *m_port16_names;
const char *m_port32_names;
diff --git a/src/devices/cpu/sh/sh_intc.cpp b/src/devices/cpu/sh/sh_intc.cpp
index d13f8f55853..34bb91dfe86 100644
--- a/src/devices/cpu/sh/sh_intc.cpp
+++ b/src/devices/cpu/sh/sh_intc.cpp
@@ -15,6 +15,25 @@
DEFINE_DEVICE_TYPE(SH_INTC, sh_intc_device, "sh_intc", "SH interrupt controller")
+const u8 sh_intc_device::pribit[0x100] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 9, 9, 9, 9,
+ 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13,
+ 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17,
+ 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
+ 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25,
+ 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+};
+
sh_intc_device::sh_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
device_t(mconfig, SH_INTC, tag, owner, clock),
m_cpu(*this, finder_base::DUMMY_TAG)
@@ -23,6 +42,13 @@ sh_intc_device::sh_intc_device(const machine_config &mconfig, const char *tag, d
void sh_intc_device::device_start()
{
+ save_item(NAME(m_ipr));
+ save_item(NAME(m_icr));
+ save_item(NAME(m_isr));
+
+ std::fill(m_ipr.begin(), m_ipr.end(), 0);
+ m_isr = 0;
+ m_icr = 0;
}
void sh_intc_device::device_reset()
@@ -36,7 +62,11 @@ int sh_intc_device::interrupt_taken(int vector)
void sh_intc_device::internal_interrupt(int vector)
{
- logerror("Internal interrupt %d\n", vector);
+ u32 slot = pribit[vector];
+ u32 shift = 12-4*(slot & 3);
+ u32 level = (m_ipr[slot >> 2] >> shift) & 15;
+ logerror("Internal interrupt %d / %d (ipr%c %d-%d)\n", vector, level, 'a' + (slot >> 2), shift + 3, shift);
+ m_cpu->set_internal_interrupt(level, vector);
}
void sh_intc_device::set_input(int inputnum, int state)
@@ -45,31 +75,34 @@ void sh_intc_device::set_input(int inputnum, int state)
u16 sh_intc_device::icr_r()
{
- return 0;
+ return m_icr;
}
void sh_intc_device::icr_w(offs_t, u16 data, u16 mem_mask)
{
+ COMBINE_DATA(&m_icr);
logerror("icr_w %04x @ %04x\n", data, mem_mask);
}
u16 sh_intc_device::isr_r()
{
- return 0;
+ return m_isr;
}
void sh_intc_device::isr_w(offs_t, u16 data, u16 mem_mask)
{
+ COMBINE_DATA(&m_isr);
logerror("isr_w %04x @ %04x\n", data, mem_mask);
}
u16 sh_intc_device::ipr_r(offs_t offset)
{
- return 0;
+ return m_ipr[offset];
}
void sh_intc_device::ipr_w(offs_t offset, u16 data, u16 mem_mask)
{
+ COMBINE_DATA(&m_ipr[offset]);
logerror("ipr_w %x, %04x @ %04x\n", offset, data, mem_mask);
}
diff --git a/src/devices/cpu/sh/sh_intc.h b/src/devices/cpu/sh/sh_intc.h
index b93444d8e32..be1c1a53633 100644
--- a/src/devices/cpu/sh/sh_intc.h
+++ b/src/devices/cpu/sh/sh_intc.h
@@ -36,6 +36,12 @@ public:
void ipr_w(offs_t offset, u16 data, u16 mem_mask);
protected:
+ static const u8 pribit[256];
+
+ std::array<u16, 8> m_ipr;
+
+ u16 m_isr, m_icr;
+
required_device<sh7042_device> m_cpu;
virtual void device_start() override;