Skip to content

Commit b0a2668

Browse files
committed
sh7042: Start introducing the interrupts
1 parent 6bccd58 commit b0a2668

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

src/devices/cpu/sh/sh7042.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,10 @@ void sh7042_device::pcf_if_w(offs_t, u16 data, u16 mem_mask)
297297
COMBINE_DATA(&m_pcf_if);
298298
logerror("pcf if = %04x\n", m_pcf_if);
299299
}
300+
301+
void sh7042_device::set_internal_interrupt(int level, u32 vector)
302+
{
303+
m_sh2_state->internal_irq_level = level;
304+
m_internal_irq_vector = vector;
305+
m_test_irq = 1;
306+
}

src/devices/cpu/sh/sh7042.h

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class sh7042_device : public sh2_device
4444

4545
u64 current_cycles() { return machine().time().as_ticks(clock()); }
4646

47+
void set_internal_interrupt(int level, u32 vector);
48+
4749
protected:
4850
const char *m_port16_names;
4951
const char *m_port32_names;

src/devices/cpu/sh/sh_intc.cpp

+37-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@
1515

1616
DEFINE_DEVICE_TYPE(SH_INTC, sh_intc_device, "sh_intc", "SH interrupt controller")
1717

18+
const u8 sh_intc_device::pribit[0x100] = {
19+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23+
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 9, 9, 9, 9,
24+
10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13,
25+
14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17,
26+
18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
27+
22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25,
28+
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,
30+
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
31+
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
32+
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
33+
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
34+
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
35+
};
36+
1837
sh_intc_device::sh_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
1938
device_t(mconfig, SH_INTC, tag, owner, clock),
2039
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
2342

2443
void sh_intc_device::device_start()
2544
{
45+
save_item(NAME(m_ipr));
46+
save_item(NAME(m_icr));
47+
save_item(NAME(m_isr));
48+
49+
std::fill(m_ipr.begin(), m_ipr.end(), 0);
50+
m_isr = 0;
51+
m_icr = 0;
2652
}
2753

2854
void sh_intc_device::device_reset()
@@ -36,7 +62,11 @@ int sh_intc_device::interrupt_taken(int vector)
3662

3763
void sh_intc_device::internal_interrupt(int vector)
3864
{
39-
logerror("Internal interrupt %d\n", vector);
65+
u32 slot = pribit[vector];
66+
u32 shift = 12-4*(slot & 3);
67+
u32 level = (m_ipr[slot >> 2] >> shift) & 15;
68+
logerror("Internal interrupt %d / %d (ipr%c %d-%d)\n", vector, level, 'a' + (slot >> 2), shift + 3, shift);
69+
m_cpu->set_internal_interrupt(level, vector);
4070
}
4171

4272
void sh_intc_device::set_input(int inputnum, int state)
@@ -45,31 +75,34 @@ void sh_intc_device::set_input(int inputnum, int state)
4575

4676
u16 sh_intc_device::icr_r()
4777
{
48-
return 0;
78+
return m_icr;
4979
}
5080

5181
void sh_intc_device::icr_w(offs_t, u16 data, u16 mem_mask)
5282
{
83+
COMBINE_DATA(&m_icr);
5384
logerror("icr_w %04x @ %04x\n", data, mem_mask);
5485
}
5586

5687
u16 sh_intc_device::isr_r()
5788
{
58-
return 0;
89+
return m_isr;
5990
}
6091

6192
void sh_intc_device::isr_w(offs_t, u16 data, u16 mem_mask)
6293
{
94+
COMBINE_DATA(&m_isr);
6395
logerror("isr_w %04x @ %04x\n", data, mem_mask);
6496
}
6597

6698
u16 sh_intc_device::ipr_r(offs_t offset)
6799
{
68-
return 0;
100+
return m_ipr[offset];
69101
}
70102

71103
void sh_intc_device::ipr_w(offs_t offset, u16 data, u16 mem_mask)
72104
{
105+
COMBINE_DATA(&m_ipr[offset]);
73106
logerror("ipr_w %x, %04x @ %04x\n", offset, data, mem_mask);
74107
}
75108

src/devices/cpu/sh/sh_intc.h

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ class sh_intc_device : public device_t {
3636
void ipr_w(offs_t offset, u16 data, u16 mem_mask);
3737

3838
protected:
39+
static const u8 pribit[256];
40+
41+
std::array<u16, 8> m_ipr;
42+
43+
u16 m_isr, m_icr;
44+
3945
required_device<sh7042_device> m_cpu;
4046

4147
virtual void device_start() override;

0 commit comments

Comments
 (0)