summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/amiga/zorro/a2232.h
blob: 52bf187d70fbbcff6689185f174a36a773624cb0 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// license:GPL-2.0+
// copyright-holders:Dirk Best
/***************************************************************************

    Commodore A2232

    Zorro-II Serial Card

    Provides the Amiga with 7 additional RS232 ports.

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

#ifndef MAME_BUS_AMIGA_ZORRO_A2232_H
#define MAME_BUS_AMIGA_ZORRO_A2232_H

#pragma once

#include "zorro.h"
#include "machine/autoconfig.h"
#include "cpu/m6502/m65ce02.h"
#include "machine/mos6551.h"
#include "machine/mos6526.h"
#include "bus/rs232/rs232.h"


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> a2232_device

class a2232_device : public device_t, public device_zorro2_card_interface, public amiga_autoconfig
{
public:
	// construction/destruction
	a2232_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// cpu
	WRITE8_MEMBER( int2_w );
	WRITE8_MEMBER( irq_ack8_w );

	// zorro slot
	DECLARE_READ16_MEMBER( shared_ram_r );
	DECLARE_WRITE16_MEMBER( shared_ram_w );
	DECLARE_READ16_MEMBER( irq_ack_r );
	DECLARE_WRITE16_MEMBER( irq_ack_w );
	DECLARE_READ16_MEMBER( reset_low_r );
	DECLARE_WRITE16_MEMBER( reset_low_w );
	DECLARE_READ16_MEMBER( irq_r );
	DECLARE_WRITE16_MEMBER( irq_w );
	DECLARE_READ16_MEMBER( reset_high_r );
	DECLARE_WRITE16_MEMBER( reset_high_w );

	// acia
	DECLARE_READ8_MEMBER( acia_0_r );
	DECLARE_WRITE8_MEMBER( acia_0_w );
	DECLARE_READ8_MEMBER( acia_1_r );
	DECLARE_WRITE8_MEMBER( acia_1_w );
	DECLARE_READ8_MEMBER( acia_2_r );
	DECLARE_WRITE8_MEMBER( acia_2_w );
	DECLARE_READ8_MEMBER( acia_3_r );
	DECLARE_WRITE8_MEMBER( acia_3_w );
	DECLARE_READ8_MEMBER( acia_4_r );
	DECLARE_WRITE8_MEMBER( acia_4_w );
	DECLARE_READ8_MEMBER( acia_5_r );
	DECLARE_WRITE8_MEMBER( acia_5_w );
	DECLARE_READ8_MEMBER( acia_6_r );
	DECLARE_WRITE8_MEMBER( acia_6_w );

	// cia
	DECLARE_READ8_MEMBER( cia_r );
	DECLARE_WRITE8_MEMBER( cia_w );

	void iocpu_map(address_map &map);
protected:
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual void device_reset_after_children() override;

	// device_zorro2_card_interface overrides
	virtual DECLARE_WRITE_LINE_MEMBER( cfgin_w ) override;

	// amiga_autoconfig overrides
	virtual void autoconfig_base_address(offs_t address) override;

private:
	enum
	{
		IRQ_ACIA_0,
		IRQ_ACIA_1,
		IRQ_ACIA_2,
		IRQ_ACIA_3,
		IRQ_ACIA_4,
		IRQ_ACIA_5,
		IRQ_ACIA_6,
		IRQ_CIA,
		IRQ_AMIGA,
		IRQ_SOURCE_COUNT
	};

	void update_irqs();

	// acia
	DECLARE_WRITE_LINE_MEMBER( acia_0_irq_w );
	DECLARE_WRITE_LINE_MEMBER( acia_1_irq_w );
	DECLARE_WRITE_LINE_MEMBER( acia_2_irq_w );
	DECLARE_WRITE_LINE_MEMBER( acia_3_irq_w );
	DECLARE_WRITE_LINE_MEMBER( acia_4_irq_w );
	DECLARE_WRITE_LINE_MEMBER( acia_5_irq_w );
	DECLARE_WRITE_LINE_MEMBER( acia_6_irq_w );

	// cia
	DECLARE_WRITE_LINE_MEMBER( cia_irq_w );
	DECLARE_READ8_MEMBER( cia_port_a_r );
	DECLARE_READ8_MEMBER( cia_port_b_r );
	DECLARE_WRITE8_MEMBER( cia_port_b_w );

	// rs232
	DECLARE_WRITE_LINE_MEMBER( rs232_1_rxd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_1_dcd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_1_cts_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_2_dcd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_2_cts_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_3_dcd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_3_cts_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_4_dcd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_4_cts_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_5_dcd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_5_cts_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_6_dcd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_6_cts_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_7_dcd_w );
	DECLARE_WRITE_LINE_MEMBER( rs232_7_cts_w );

	required_device<m65ce02_device> m_iocpu;
	required_device<mos6551_device> m_acia_0;
	required_device<mos6551_device> m_acia_1;
	required_device<mos6551_device> m_acia_2;
	required_device<mos6551_device> m_acia_3;
	required_device<mos6551_device> m_acia_4;
	required_device<mos6551_device> m_acia_5;
	required_device<mos6551_device> m_acia_6;
	required_device<mos8520_device> m_cia;
	required_shared_ptr<uint8_t> m_shared_ram;

	int m_irqs[IRQ_SOURCE_COUNT];

	uint8_t m_cia_port_a;
	uint8_t m_cia_port_b;
};

// device type definition
DECLARE_DEVICE_TYPE(A2232, a2232_device)

#endif // MAME_BUS_AMIGA_ZORRO_A2232_H