summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/sh/sh_intc.h
blob: 9a743f4e778e21b2b2e7a89ccbe49bc7b41befd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
/***************************************************************************

    sh_intc.h

    SH interrupt controllers family

***************************************************************************/

#ifndef MAME_CPU_SH_SH_INTC_H
#define MAME_CPU_SH_SH_INTC_H

#pragma once

class sh7042_device;

class sh_intc_device : public device_t {
public:
	sh_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
	template<typename T> sh_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu) :
		sh_intc_device(mconfig, tag, owner)
	{
		m_cpu.set_tag(std::forward<T>(cpu));
	}

	void interrupt_taken(int irqline, int vector);
	void internal_interrupt(int vector);
	void set_input(int inputnum, int state);

	u16 icr_r();
	void icr_w(offs_t, u16 data, u16 mem_mask);
	u16 isr_r();
	void isr_w(offs_t, u16 data, u16 mem_mask);
	u16 ipr_r(offs_t offset);
	void ipr_w(offs_t offset, u16 data, u16 mem_mask);

protected:
	static const u8 pribit[256];

	std::array<u32, 8> m_pending;
	std::array<u16, 8> m_ipr;

	u16 m_isr, m_icr;

	u8 m_lines;

	required_device<sh7042_device> m_cpu;

	virtual void device_start() override ATTR_COLD;
	virtual void device_reset() override ATTR_COLD;

	void update_irq();
};

DECLARE_DEVICE_TYPE(SH_INTC, sh_intc_device)

#endif // MAME_CPU_SH_SH_INTC_H