trunk/src/emu/bus/zorro/a2232.h
| r0 | r30625 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Commodore A2232 |
| 4 | |
| 5 | license: MAME, GPL-2.0+ |
| 6 | copyright-holders: Dirk Best |
| 7 | |
| 8 | Zorro-II Serial Card |
| 9 | |
| 10 | Provides the Amiga with 7 additional RS232 ports. |
| 11 | |
| 12 | ***************************************************************************/ |
| 13 | |
| 14 | #pragma once |
| 15 | |
| 16 | #ifndef __A2232_H__ |
| 17 | #define __A2232_H__ |
| 18 | |
| 19 | #include "emu.h" |
| 20 | #include "zorro.h" |
| 21 | #include "machine/autoconfig.h" |
| 22 | #include "cpu/m6502/m65ce02.h" |
| 23 | #include "machine/mos6551.h" |
| 24 | #include "machine/mos6526.h" |
| 25 | #include "bus/rs232/rs232.h" |
| 26 | |
| 27 | |
| 28 | //************************************************************************** |
| 29 | // TYPE DEFINITIONS |
| 30 | //************************************************************************** |
| 31 | |
| 32 | // ======================> a2232_device |
| 33 | |
| 34 | class a2232_device : public device_t, public device_zorro2_card_interface, public amiga_autoconfig |
| 35 | { |
| 36 | public: |
| 37 | // construction/destruction |
| 38 | a2232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 39 | |
| 40 | // cpu |
| 41 | WRITE8_MEMBER( int2_w ); |
| 42 | WRITE8_MEMBER( irq_ack_w ); |
| 43 | |
| 44 | // zorro slot |
| 45 | DECLARE_READ16_MEMBER( shared_ram_r ); |
| 46 | DECLARE_WRITE16_MEMBER( shared_ram_w ); |
| 47 | DECLARE_READ16_MEMBER( irq_ack_r ); |
| 48 | DECLARE_WRITE16_MEMBER( irq_ack_w ); |
| 49 | DECLARE_READ16_MEMBER( reset_low_r ); |
| 50 | DECLARE_WRITE16_MEMBER( reset_low_w ); |
| 51 | DECLARE_READ16_MEMBER( irq_r ); |
| 52 | DECLARE_WRITE16_MEMBER( irq_w ); |
| 53 | DECLARE_READ16_MEMBER( reset_high_r ); |
| 54 | DECLARE_WRITE16_MEMBER( reset_high_w ); |
| 55 | |
| 56 | // acia |
| 57 | DECLARE_READ8_MEMBER( acia_0_r ); |
| 58 | DECLARE_WRITE8_MEMBER( acia_0_w ); |
| 59 | DECLARE_WRITE_LINE_MEMBER( acia_0_irq_w ); |
| 60 | DECLARE_READ8_MEMBER( acia_1_r ); |
| 61 | DECLARE_WRITE8_MEMBER( acia_1_w ); |
| 62 | DECLARE_WRITE_LINE_MEMBER( acia_1_irq_w ); |
| 63 | DECLARE_READ8_MEMBER( acia_2_r ); |
| 64 | DECLARE_WRITE8_MEMBER( acia_2_w ); |
| 65 | DECLARE_WRITE_LINE_MEMBER( acia_2_irq_w ); |
| 66 | DECLARE_READ8_MEMBER( acia_3_r ); |
| 67 | DECLARE_WRITE8_MEMBER( acia_3_w ); |
| 68 | DECLARE_WRITE_LINE_MEMBER( acia_3_irq_w ); |
| 69 | DECLARE_READ8_MEMBER( acia_4_r ); |
| 70 | DECLARE_WRITE8_MEMBER( acia_4_w ); |
| 71 | DECLARE_WRITE_LINE_MEMBER( acia_4_irq_w ); |
| 72 | DECLARE_READ8_MEMBER( acia_5_r ); |
| 73 | DECLARE_WRITE8_MEMBER( acia_5_w ); |
| 74 | DECLARE_WRITE_LINE_MEMBER( acia_5_irq_w ); |
| 75 | DECLARE_READ8_MEMBER( acia_6_r ); |
| 76 | DECLARE_WRITE8_MEMBER( acia_6_w ); |
| 77 | DECLARE_WRITE_LINE_MEMBER( acia_6_irq_w ); |
| 78 | |
| 79 | // cia |
| 80 | DECLARE_READ8_MEMBER( cia_r ); |
| 81 | DECLARE_WRITE8_MEMBER( cia_w ); |
| 82 | DECLARE_WRITE_LINE_MEMBER( cia_irq_w ); |
| 83 | DECLARE_READ8_MEMBER( cia_port_a_r ); |
| 84 | DECLARE_READ8_MEMBER( cia_port_b_r ); |
| 85 | DECLARE_WRITE8_MEMBER( cia_port_b_w ); |
| 86 | |
| 87 | // rs232 |
| 88 | DECLARE_WRITE_LINE_MEMBER( rs232_1_rxd_w ); |
| 89 | DECLARE_WRITE_LINE_MEMBER( rs232_1_dcd_w ); |
| 90 | DECLARE_WRITE_LINE_MEMBER( rs232_1_cts_w ); |
| 91 | DECLARE_WRITE_LINE_MEMBER( rs232_2_dcd_w ); |
| 92 | DECLARE_WRITE_LINE_MEMBER( rs232_2_cts_w ); |
| 93 | DECLARE_WRITE_LINE_MEMBER( rs232_3_dcd_w ); |
| 94 | DECLARE_WRITE_LINE_MEMBER( rs232_3_cts_w ); |
| 95 | DECLARE_WRITE_LINE_MEMBER( rs232_4_dcd_w ); |
| 96 | DECLARE_WRITE_LINE_MEMBER( rs232_4_cts_w ); |
| 97 | DECLARE_WRITE_LINE_MEMBER( rs232_5_dcd_w ); |
| 98 | DECLARE_WRITE_LINE_MEMBER( rs232_5_cts_w ); |
| 99 | DECLARE_WRITE_LINE_MEMBER( rs232_6_dcd_w ); |
| 100 | DECLARE_WRITE_LINE_MEMBER( rs232_6_cts_w ); |
| 101 | DECLARE_WRITE_LINE_MEMBER( rs232_7_dcd_w ); |
| 102 | DECLARE_WRITE_LINE_MEMBER( rs232_7_cts_w ); |
| 103 | |
| 104 | protected: |
| 105 | virtual machine_config_constructor device_mconfig_additions() const; |
| 106 | virtual void device_start(); |
| 107 | virtual void device_reset_after_children(); |
| 108 | |
| 109 | // device_zorro2_card_interface overrides |
| 110 | virtual DECLARE_WRITE_LINE_MEMBER( cfgin_w ); |
| 111 | |
| 112 | // amiga_autoconfig overrides |
| 113 | virtual void autoconfig_base_address(offs_t address); |
| 114 | |
| 115 | private: |
| 116 | enum |
| 117 | { |
| 118 | IRQ_ACIA_0, |
| 119 | IRQ_ACIA_1, |
| 120 | IRQ_ACIA_2, |
| 121 | IRQ_ACIA_3, |
| 122 | IRQ_ACIA_4, |
| 123 | IRQ_ACIA_5, |
| 124 | IRQ_ACIA_6, |
| 125 | IRQ_CIA, |
| 126 | IRQ_AMIGA, |
| 127 | IRQ_SOURCE_COUNT |
| 128 | }; |
| 129 | |
| 130 | void update_irqs(); |
| 131 | |
| 132 | required_device<m65ce02_device> m_iocpu; |
| 133 | required_device<mos6551_device> m_acia_0; |
| 134 | required_device<mos6551_device> m_acia_1; |
| 135 | required_device<mos6551_device> m_acia_2; |
| 136 | required_device<mos6551_device> m_acia_3; |
| 137 | required_device<mos6551_device> m_acia_4; |
| 138 | required_device<mos6551_device> m_acia_5; |
| 139 | required_device<mos6551_device> m_acia_6; |
| 140 | required_device<mos8520_device> m_cia; |
| 141 | required_shared_ptr<UINT8> m_shared_ram; |
| 142 | |
| 143 | int m_irqs[IRQ_SOURCE_COUNT]; |
| 144 | |
| 145 | UINT8 m_cia_port_a; |
| 146 | UINT8 m_cia_port_b; |
| 147 | }; |
| 148 | |
| 149 | // device type definition |
| 150 | extern const device_type A2232; |
| 151 | |
| 152 | #endif // __A2232_H__ |
trunk/src/emu/bus/zorro/a2232.c
| r0 | r30625 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Commodore A2232 |
| 4 | |
| 5 | license: MAME, GPL-2.0+ |
| 6 | copyright-holders: Dirk Best |
| 7 | |
| 8 | Zorro-II Serial Card |
| 9 | |
| 10 | ***************************************************************************/ |
| 11 | |
| 12 | #include "a2232.h" |
| 13 | |
| 14 | |
| 15 | //************************************************************************** |
| 16 | // CONSTANTS / MACROS |
| 17 | //************************************************************************** |
| 18 | |
| 19 | #define VERBOSE 0 |
| 20 | #define VERBOSE_DATA 0 |
| 21 | |
| 22 | |
| 23 | //************************************************************************** |
| 24 | // DEVICE DEFINITIONS |
| 25 | //************************************************************************** |
| 26 | |
| 27 | const device_type A2232 = &device_creator<a2232_device>; |
| 28 | |
| 29 | //------------------------------------------------- |
| 30 | // machine_config_additions - device-specific |
| 31 | // machine configurations |
| 32 | //------------------------------------------------- |
| 33 | |
| 34 | static ADDRESS_MAP_START( iocpu_map, AS_PROGRAM, 8, a2232_device) |
| 35 | AM_RANGE(0x0000, 0x3fff) AM_RAM AM_SHARE("shared") |
| 36 | AM_RANGE(0x4000, 0x47ff) AM_READWRITE(acia_0_r, acia_0_w) |
| 37 | AM_RANGE(0x4800, 0x4fff) AM_READWRITE(acia_1_r, acia_1_w) |
| 38 | AM_RANGE(0x5000, 0x57ff) AM_READWRITE(acia_2_r, acia_2_w) |
| 39 | AM_RANGE(0x5800, 0x5fff) AM_READWRITE(acia_3_r, acia_3_w) |
| 40 | AM_RANGE(0x6000, 0x67ff) AM_READWRITE(acia_4_r, acia_4_w) |
| 41 | AM_RANGE(0x6800, 0x6fff) AM_READWRITE(acia_5_r, acia_5_w) |
| 42 | AM_RANGE(0x7000, 0x73ff) AM_WRITE(int2_w) |
| 43 | AM_RANGE(0x7400, 0x77ff) AM_READWRITE(acia_6_r, acia_6_w) |
| 44 | AM_RANGE(0x7800, 0x7fff) AM_READWRITE(cia_r, cia_w) |
| 45 | AM_RANGE(0x8000, 0x8000) AM_WRITE(irq_ack_w) |
| 46 | AM_RANGE(0xc000, 0xffff) AM_RAM AM_SHARE("shared") |
| 47 | ADDRESS_MAP_END |
| 48 | |
| 49 | static MACHINE_CONFIG_FRAGMENT( a2232 ) |
| 50 | // main cpu |
| 51 | MCFG_CPU_ADD("iocpu", M65CE02, XTAL_28_37516MHz / 8) // should run at Amiga clock 7M / 2 |
| 52 | MCFG_CPU_PROGRAM_MAP(iocpu_map) |
| 53 | |
| 54 | // acia |
| 55 | MCFG_DEVICE_ADD("acia_0", MOS6551, XTAL_28_37516MHz / 8) |
| 56 | MCFG_MOS6551_XTAL(XTAL_1_8432MHz) |
| 57 | MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232_1", rs232_port_device, write_txd)) |
| 58 | MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2232_device, acia_0_irq_w)) |
| 59 | |
| 60 | MCFG_DEVICE_ADD("acia_1", MOS6551, XTAL_28_37516MHz / 8) |
| 61 | MCFG_MOS6551_XTAL(XTAL_1_8432MHz) |
| 62 | MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232_2", rs232_port_device, write_txd)) |
| 63 | MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2232_device, acia_1_irq_w)) |
| 64 | |
| 65 | MCFG_DEVICE_ADD("acia_2", MOS6551, XTAL_28_37516MHz / 8) |
| 66 | MCFG_MOS6551_XTAL(XTAL_1_8432MHz) |
| 67 | MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232_3", rs232_port_device, write_txd)) |
| 68 | MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2232_device, acia_2_irq_w)) |
| 69 | |
| 70 | MCFG_DEVICE_ADD("acia_3", MOS6551, XTAL_28_37516MHz / 8) |
| 71 | MCFG_MOS6551_XTAL(XTAL_1_8432MHz) |
| 72 | MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232_4", rs232_port_device, write_txd)) |
| 73 | MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2232_device, acia_3_irq_w)) |
| 74 | |
| 75 | MCFG_DEVICE_ADD("acia_4", MOS6551, XTAL_28_37516MHz / 8) |
| 76 | MCFG_MOS6551_XTAL(XTAL_1_8432MHz) |
| 77 | MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232_5", rs232_port_device, write_txd)) |
| 78 | MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2232_device, acia_4_irq_w)) |
| 79 | |
| 80 | MCFG_DEVICE_ADD("acia_5", MOS6551, XTAL_28_37516MHz / 8) |
| 81 | MCFG_MOS6551_XTAL(XTAL_1_8432MHz) |
| 82 | MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232_6", rs232_port_device, write_txd)) |
| 83 | MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2232_device, acia_5_irq_w)) |
| 84 | |
| 85 | MCFG_DEVICE_ADD("acia_6", MOS6551, XTAL_28_37516MHz / 8) |
| 86 | MCFG_MOS6551_XTAL(XTAL_1_8432MHz) |
| 87 | MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232_7", rs232_port_device, write_txd)) |
| 88 | MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2232_device, acia_6_irq_w)) |
| 89 | |
| 90 | // cia |
| 91 | MCFG_DEVICE_ADD("cia", MOS8520, XTAL_1_8432MHz) |
| 92 | MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(a2232_device, cia_irq_w)) |
| 93 | MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(a2232_device, cia_port_a_r)) |
| 94 | MCFG_MOS6526_PB_INPUT_CALLBACK(READ8(a2232_device, cia_port_b_r)) |
| 95 | MCFG_MOS6526_PB_OUTPUT_CALLBACK(WRITE8(a2232_device, cia_port_b_w)) |
| 96 | |
| 97 | // rs232 ports |
| 98 | MCFG_RS232_PORT_ADD("rs232_1", default_rs232_devices, NULL) |
| 99 | MCFG_RS232_RXD_HANDLER(WRITELINE(a2232_device, rs232_1_rxd_w)) |
| 100 | MCFG_RS232_DCD_HANDLER(WRITELINE(a2232_device, rs232_1_dcd_w)) |
| 101 | MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia_0", mos6551_device, write_dsr)) |
| 102 | MCFG_RS232_CTS_HANDLER(WRITELINE(a2232_device, rs232_1_cts_w)) |
| 103 | |
| 104 | MCFG_RS232_PORT_ADD("rs232_2", default_rs232_devices, NULL) |
| 105 | MCFG_RS232_RXD_HANDLER(DEVWRITELINE("acia_1", mos6551_device, write_rxd)) |
| 106 | MCFG_RS232_DCD_HANDLER(WRITELINE(a2232_device, rs232_2_dcd_w)) |
| 107 | MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia_1", mos6551_device, write_dsr)) |
| 108 | MCFG_RS232_CTS_HANDLER(WRITELINE(a2232_device, rs232_2_cts_w)) |
| 109 | |
| 110 | MCFG_RS232_PORT_ADD("rs232_3", default_rs232_devices, NULL) |
| 111 | MCFG_RS232_RXD_HANDLER(DEVWRITELINE("acia_2", mos6551_device, write_rxd)) |
| 112 | MCFG_RS232_DCD_HANDLER(WRITELINE(a2232_device, rs232_3_dcd_w)) |
| 113 | MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia_2", mos6551_device, write_dsr)) |
| 114 | MCFG_RS232_CTS_HANDLER(WRITELINE(a2232_device, rs232_3_cts_w)) |
| 115 | |
| 116 | MCFG_RS232_PORT_ADD("rs232_4", default_rs232_devices, NULL) |
| 117 | MCFG_RS232_RXD_HANDLER(DEVWRITELINE("acia_3", mos6551_device, write_rxd)) |
| 118 | MCFG_RS232_DCD_HANDLER(WRITELINE(a2232_device, rs232_4_dcd_w)) |
| 119 | MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia_3", mos6551_device, write_dsr)) |
| 120 | MCFG_RS232_CTS_HANDLER(WRITELINE(a2232_device, rs232_4_cts_w)) |
| 121 | |
| 122 | MCFG_RS232_PORT_ADD("rs232_5", default_rs232_devices, NULL) |
| 123 | MCFG_RS232_RXD_HANDLER(DEVWRITELINE("acia_4", mos6551_device, write_rxd)) |
| 124 | MCFG_RS232_DCD_HANDLER(WRITELINE(a2232_device, rs232_5_dcd_w)) |
| 125 | MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia_4", mos6551_device, write_dsr)) |
| 126 | MCFG_RS232_CTS_HANDLER(WRITELINE(a2232_device, rs232_5_cts_w)) |
| 127 | |
| 128 | MCFG_RS232_PORT_ADD("rs232_6", default_rs232_devices, NULL) |
| 129 | MCFG_RS232_RXD_HANDLER(DEVWRITELINE("acia_5", mos6551_device, write_rxd)) |
| 130 | MCFG_RS232_DCD_HANDLER(WRITELINE(a2232_device, rs232_6_dcd_w)) |
| 131 | MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia_5", mos6551_device, write_dsr)) |
| 132 | MCFG_RS232_CTS_HANDLER(WRITELINE(a2232_device, rs232_6_cts_w)) |
| 133 | |
| 134 | MCFG_RS232_PORT_ADD("rs232_7", default_rs232_devices, NULL) |
| 135 | MCFG_RS232_RXD_HANDLER(DEVWRITELINE("acia_6", mos6551_device, write_rxd)) |
| 136 | MCFG_RS232_DCD_HANDLER(WRITELINE(a2232_device, rs232_7_dcd_w)) |
| 137 | MCFG_RS232_DSR_HANDLER(DEVWRITELINE("acia_6", mos6551_device, write_dsr)) |
| 138 | MCFG_RS232_CTS_HANDLER(WRITELINE(a2232_device, rs232_7_cts_w)) |
| 139 | MACHINE_CONFIG_END |
| 140 | |
| 141 | machine_config_constructor a2232_device::device_mconfig_additions() const |
| 142 | { |
| 143 | return MACHINE_CONFIG_NAME( a2232 ); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | //************************************************************************** |
| 148 | // LIVE DEVICE |
| 149 | //************************************************************************** |
| 150 | |
| 151 | //------------------------------------------------- |
| 152 | // a2232_device - constructor |
| 153 | //------------------------------------------------- |
| 154 | |
| 155 | a2232_device::a2232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 156 | device_t(mconfig, A2232, "CBM A2232 Serial Card", tag, owner, clock, "a2232", __FILE__), |
| 157 | device_zorro2_card_interface(mconfig, *this), |
| 158 | m_iocpu(*this, "iocpu"), |
| 159 | m_acia_0(*this, "acia_0"), |
| 160 | m_acia_1(*this, "acia_1"), |
| 161 | m_acia_2(*this, "acia_2"), |
| 162 | m_acia_3(*this, "acia_3"), |
| 163 | m_acia_4(*this, "acia_4"), |
| 164 | m_acia_5(*this, "acia_5"), |
| 165 | m_acia_6(*this, "acia_6"), |
| 166 | m_cia(*this, "cia"), |
| 167 | m_shared_ram(*this, "shared"), |
| 168 | m_cia_port_a(0xff), |
| 169 | m_cia_port_b(0xff) |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | //------------------------------------------------- |
| 174 | // device_start - device-specific startup |
| 175 | //------------------------------------------------- |
| 176 | |
| 177 | void a2232_device::device_start() |
| 178 | { |
| 179 | set_zorro_device(); |
| 180 | memset(m_irqs, 0, sizeof(m_irqs)); |
| 181 | } |
| 182 | |
| 183 | //------------------------------------------------- |
| 184 | // device_reset_after_children - reset after child devices |
| 185 | //------------------------------------------------- |
| 186 | |
| 187 | void a2232_device::device_reset_after_children() |
| 188 | { |
| 189 | // reset is kept high at reset, to allow the amiga time to upload its code |
| 190 | m_iocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 191 | |
| 192 | // cts connected to gnd |
| 193 | m_acia_0->write_cts(0); |
| 194 | m_acia_1->write_cts(0); |
| 195 | m_acia_2->write_cts(0); |
| 196 | m_acia_3->write_cts(0); |
| 197 | m_acia_4->write_cts(0); |
| 198 | m_acia_5->write_cts(0); |
| 199 | m_acia_6->write_cts(0); |
| 200 | } |
| 201 | |
| 202 | |
| 203 | //************************************************************************** |
| 204 | // IMPLEMENTATION |
| 205 | //************************************************************************** |
| 206 | |
| 207 | void a2232_device::update_irqs() |
| 208 | { |
| 209 | // look for any active irq |
| 210 | for (int i = 0; i < IRQ_SOURCE_COUNT; i++) |
| 211 | { |
| 212 | if (m_irqs[i]) |
| 213 | { |
| 214 | m_iocpu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE); |
| 215 | return; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | // if we get here no irqs are pending |
| 220 | m_iocpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); |
| 221 | } |
| 222 | |
| 223 | WRITE8_MEMBER( a2232_device::int2_w ) |
| 224 | { |
| 225 | if (VERBOSE) |
| 226 | logerror("%s('%s'): int2_w %04x\n", shortname(), basetag(), data); |
| 227 | |
| 228 | m_slot->int2_w(1); |
| 229 | } |
| 230 | |
| 231 | WRITE8_MEMBER( a2232_device::irq_ack_w ) |
| 232 | { |
| 233 | if (VERBOSE) |
| 234 | logerror("%s('%s'): irq_ack_w %04x\n", shortname(), basetag(), data); |
| 235 | |
| 236 | m_irqs[IRQ_AMIGA] = CLEAR_LINE; |
| 237 | update_irqs(); |
| 238 | } |
| 239 | |
| 240 | |
| 241 | //************************************************************************** |
| 242 | // AUTOCONFIG |
| 243 | //************************************************************************** |
| 244 | |
| 245 | void a2232_device::autoconfig_base_address(offs_t address) |
| 246 | { |
| 247 | if (VERBOSE) |
| 248 | logerror("%s('%s'): autoconfig_base_address received: 0x%06x\n", shortname(), basetag(), address); |
| 249 | |
| 250 | if (VERBOSE) |
| 251 | logerror("-> installing a2232\n"); |
| 252 | |
| 253 | // stop responding to default autoconfig |
| 254 | m_slot->m_space->unmap_readwrite(0xe80000, 0xe8007f); |
| 255 | |
| 256 | m_slot->m_space->install_readwrite_handler(address, address + 0x3fff, |
| 257 | read16_delegate(FUNC(a2232_device::shared_ram_r), this), |
| 258 | write16_delegate(FUNC(a2232_device::shared_ram_w), this), 0xffff); |
| 259 | |
| 260 | m_slot->m_space->install_readwrite_handler(address + 0x4000, address + 0x4001, |
| 261 | read16_delegate(FUNC(a2232_device::irq_ack_r), this), |
| 262 | write16_delegate(FUNC(a2232_device::irq_ack_w), this), 0xffff); |
| 263 | |
| 264 | m_slot->m_space->install_readwrite_handler(address + 0x8000, address + 0x8001, |
| 265 | read16_delegate(FUNC(a2232_device::reset_low_r), this), |
| 266 | write16_delegate(FUNC(a2232_device::reset_low_w), this), 0xffff); |
| 267 | |
| 268 | m_slot->m_space->install_readwrite_handler(address + 0xa000, address + 0xa001, |
| 269 | read16_delegate(FUNC(a2232_device::irq_r), this), |
| 270 | write16_delegate(FUNC(a2232_device::irq_w), this), 0xffff); |
| 271 | |
| 272 | m_slot->m_space->install_readwrite_handler(address + 0xc000, address + 0xc001, |
| 273 | read16_delegate(FUNC(a2232_device::reset_high_r), this), |
| 274 | write16_delegate(FUNC(a2232_device::reset_high_w), this), 0xffff); |
| 275 | |
| 276 | // we're done |
| 277 | m_slot->cfgout_w(0); |
| 278 | } |
| 279 | |
| 280 | WRITE_LINE_MEMBER( a2232_device::cfgin_w ) |
| 281 | { |
| 282 | if (VERBOSE) |
| 283 | logerror("%s('%s'): configin_w (%d)\n", shortname(), basetag(), state); |
| 284 | |
| 285 | if (state == 0) |
| 286 | { |
| 287 | // setup autoconfig |
| 288 | autoconfig_board_type(BOARD_TYPE_ZORRO2); |
| 289 | autoconfig_board_size(BOARD_SIZE_64K); |
| 290 | |
| 291 | autoconfig_product(0x46); |
| 292 | autoconfig_manufacturer(0x0202); |
| 293 | autoconfig_serial(0x00000000); |
| 294 | |
| 295 | autoconfig_link_into_memory(false); |
| 296 | autoconfig_rom_vector_valid(false); |
| 297 | autoconfig_multi_device(false); |
| 298 | autoconfig_8meg_preferred(false); |
| 299 | autoconfig_can_shutup(true); // ? |
| 300 | |
| 301 | // install autoconfig handler |
| 302 | m_slot->m_space->install_readwrite_handler(0xe80000, 0xe8007f, |
| 303 | read16_delegate(FUNC(amiga_autoconfig::autoconfig_read), static_cast<amiga_autoconfig *>(this)), |
| 304 | write16_delegate(FUNC(amiga_autoconfig::autoconfig_write), static_cast<amiga_autoconfig *>(this)), 0xffff); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | |
| 309 | //************************************************************************** |
| 310 | // ZORRO |
| 311 | //************************************************************************** |
| 312 | |
| 313 | READ16_MEMBER( a2232_device::shared_ram_r ) |
| 314 | { |
| 315 | UINT16 data = 0; |
| 316 | |
| 317 | if (ACCESSING_BITS_0_7) |
| 318 | data |= m_shared_ram[(offset << 1) + 1]; |
| 319 | else |
| 320 | data |= 0x00ff; |
| 321 | |
| 322 | if (ACCESSING_BITS_8_15) |
| 323 | data |= m_shared_ram[offset << 1] << 8; |
| 324 | else |
| 325 | data |= 0xff00; |
| 326 | |
| 327 | if (VERBOSE_DATA) |
| 328 | logerror("%s('%s'): shared_ram_r(%04x) %04x [mask = %04x]\n", shortname(), basetag(), offset << 1, data, mem_mask); |
| 329 | |
| 330 | return data; |
| 331 | } |
| 332 | |
| 333 | WRITE16_MEMBER( a2232_device::shared_ram_w ) |
| 334 | { |
| 335 | if (VERBOSE_DATA) |
| 336 | logerror("%s('%s'): shared_ram_w(%04x) %04x [mask = %04x]\n", shortname(), basetag(), offset << 1, data, mem_mask); |
| 337 | |
| 338 | if (ACCESSING_BITS_0_7) |
| 339 | m_shared_ram[(offset << 1) + 1] = data & 0xff; |
| 340 | |
| 341 | if (ACCESSING_BITS_8_15) |
| 342 | m_shared_ram[offset << 1] = (data & 0xff00) >> 8; |
| 343 | } |
| 344 | |
| 345 | READ16_MEMBER( a2232_device::irq_ack_r ) |
| 346 | { |
| 347 | m_slot->int2_w(0); |
| 348 | |
| 349 | return 0xffff; |
| 350 | } |
| 351 | |
| 352 | WRITE16_MEMBER( a2232_device::irq_ack_w ) |
| 353 | { |
| 354 | m_slot->int2_w(0); |
| 355 | } |
| 356 | |
| 357 | READ16_MEMBER( a2232_device::reset_low_r ) |
| 358 | { |
| 359 | m_iocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 360 | |
| 361 | return 0xffff; |
| 362 | } |
| 363 | |
| 364 | WRITE16_MEMBER( a2232_device::reset_low_w ) |
| 365 | { |
| 366 | m_iocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 367 | } |
| 368 | |
| 369 | READ16_MEMBER( a2232_device::irq_r ) |
| 370 | { |
| 371 | m_irqs[IRQ_AMIGA] = ASSERT_LINE; |
| 372 | update_irqs(); |
| 373 | |
| 374 | return 0xffff; |
| 375 | } |
| 376 | |
| 377 | WRITE16_MEMBER( a2232_device::irq_w ) |
| 378 | { |
| 379 | m_irqs[IRQ_AMIGA] = ASSERT_LINE; |
| 380 | update_irqs(); |
| 381 | } |
| 382 | |
| 383 | READ16_MEMBER( a2232_device::reset_high_r ) |
| 384 | { |
| 385 | UINT16 data = 0xffff; |
| 386 | |
| 387 | if (VERBOSE) |
| 388 | logerror("%s('%s'): reset_high_r %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask); |
| 389 | |
| 390 | m_iocpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE); |
| 391 | |
| 392 | return data; |
| 393 | } |
| 394 | |
| 395 | WRITE16_MEMBER( a2232_device::reset_high_w ) |
| 396 | { |
| 397 | if (VERBOSE) |
| 398 | logerror("%s('%s'): reset_high_w %04x [mask = %04x]\n", shortname(), basetag(), data, mem_mask); |
| 399 | |
| 400 | m_iocpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE); |
| 401 | } |
| 402 | |
| 403 | |
| 404 | //************************************************************************** |
| 405 | // ACIA |
| 406 | //************************************************************************** |
| 407 | |
| 408 | READ8_MEMBER( a2232_device::acia_0_r ) |
| 409 | { |
| 410 | return m_acia_0->read(space, offset >> 1); |
| 411 | } |
| 412 | |
| 413 | WRITE8_MEMBER( a2232_device::acia_0_w ) |
| 414 | { |
| 415 | m_acia_0->write(space, offset >> 1, data); |
| 416 | } |
| 417 | |
| 418 | WRITE_LINE_MEMBER( a2232_device::acia_0_irq_w ) |
| 419 | { |
| 420 | m_irqs[IRQ_ACIA_0] = state; |
| 421 | update_irqs(); |
| 422 | } |
| 423 | |
| 424 | READ8_MEMBER( a2232_device::acia_1_r ) |
| 425 | { |
| 426 | return m_acia_1->read(space, offset >> 1); |
| 427 | } |
| 428 | |
| 429 | WRITE8_MEMBER( a2232_device::acia_1_w ) |
| 430 | { |
| 431 | m_acia_1->write(space, offset >> 1, data); |
| 432 | } |
| 433 | |
| 434 | WRITE_LINE_MEMBER( a2232_device::acia_1_irq_w ) |
| 435 | { |
| 436 | m_irqs[IRQ_ACIA_1] = state; |
| 437 | update_irqs(); |
| 438 | } |
| 439 | |
| 440 | READ8_MEMBER( a2232_device::acia_2_r ) |
| 441 | { |
| 442 | return m_acia_2->read(space, offset >> 1); |
| 443 | } |
| 444 | |
| 445 | WRITE8_MEMBER( a2232_device::acia_2_w ) |
| 446 | { |
| 447 | m_acia_2->write(space, offset >> 1, data); |
| 448 | } |
| 449 | |
| 450 | WRITE_LINE_MEMBER( a2232_device::acia_2_irq_w ) |
| 451 | { |
| 452 | m_irqs[IRQ_ACIA_2] = state; |
| 453 | update_irqs(); |
| 454 | } |
| 455 | |
| 456 | READ8_MEMBER( a2232_device::acia_3_r ) |
| 457 | { |
| 458 | return m_acia_3->read(space, offset >> 1); |
| 459 | } |
| 460 | |
| 461 | WRITE8_MEMBER( a2232_device::acia_3_w ) |
| 462 | { |
| 463 | m_acia_3->write(space, offset >> 1, data); |
| 464 | } |
| 465 | |
| 466 | WRITE_LINE_MEMBER( a2232_device::acia_3_irq_w ) |
| 467 | { |
| 468 | m_irqs[IRQ_ACIA_3] = state; |
| 469 | update_irqs(); |
| 470 | } |
| 471 | |
| 472 | READ8_MEMBER( a2232_device::acia_4_r ) |
| 473 | { |
| 474 | return m_acia_4->read(space, offset >> 1); |
| 475 | } |
| 476 | |
| 477 | WRITE8_MEMBER( a2232_device::acia_4_w ) |
| 478 | { |
| 479 | m_acia_4->write(space, offset >> 1, data); |
| 480 | } |
| 481 | |
| 482 | WRITE_LINE_MEMBER( a2232_device::acia_4_irq_w ) |
| 483 | { |
| 484 | m_irqs[IRQ_ACIA_4] = state; |
| 485 | update_irqs(); |
| 486 | } |
| 487 | |
| 488 | READ8_MEMBER( a2232_device::acia_5_r ) |
| 489 | { |
| 490 | return m_acia_5->read(space, offset >> 1); |
| 491 | } |
| 492 | |
| 493 | WRITE8_MEMBER( a2232_device::acia_5_w ) |
| 494 | { |
| 495 | m_acia_5->write(space, offset >> 1, data); |
| 496 | } |
| 497 | |
| 498 | WRITE_LINE_MEMBER( a2232_device::acia_5_irq_w ) |
| 499 | { |
| 500 | m_irqs[IRQ_ACIA_5] = state; |
| 501 | update_irqs(); |
| 502 | } |
| 503 | |
| 504 | READ8_MEMBER( a2232_device::acia_6_r ) |
| 505 | { |
| 506 | return m_acia_6->read(space, offset >> 1); |
| 507 | } |
| 508 | |
| 509 | WRITE8_MEMBER( a2232_device::acia_6_w ) |
| 510 | { |
| 511 | m_acia_6->write(space, offset >> 1, data); |
| 512 | } |
| 513 | |
| 514 | WRITE_LINE_MEMBER( a2232_device::acia_6_irq_w ) |
| 515 | { |
| 516 | m_irqs[IRQ_ACIA_6] = state; |
| 517 | update_irqs(); |
| 518 | } |
| 519 | |
| 520 | |
| 521 | //************************************************************************** |
| 522 | // CIA |
| 523 | //************************************************************************** |
| 524 | |
| 525 | READ8_MEMBER( a2232_device::cia_r ) |
| 526 | { |
| 527 | return m_cia->read(space, offset >> 1); |
| 528 | } |
| 529 | |
| 530 | WRITE8_MEMBER( a2232_device::cia_w ) |
| 531 | { |
| 532 | m_cia->write(space, offset >> 1, data); |
| 533 | } |
| 534 | |
| 535 | WRITE_LINE_MEMBER( a2232_device::cia_irq_w ) |
| 536 | { |
| 537 | m_irqs[IRQ_CIA] = state; |
| 538 | update_irqs(); |
| 539 | } |
| 540 | |
| 541 | READ8_MEMBER( a2232_device::cia_port_a_r ) |
| 542 | { |
| 543 | return m_cia_port_a; |
| 544 | } |
| 545 | |
| 546 | READ8_MEMBER( a2232_device::cia_port_b_r ) |
| 547 | { |
| 548 | return m_cia_port_b; |
| 549 | } |
| 550 | |
| 551 | WRITE8_MEMBER( a2232_device::cia_port_b_w ) |
| 552 | { |
| 553 | // tod clock connected to pb7 |
| 554 | m_cia->tod_w(BIT(data, 7)); |
| 555 | } |
| 556 | |
| 557 | |
| 558 | //************************************************************************** |
| 559 | // RS232 |
| 560 | //************************************************************************** |
| 561 | |
| 562 | WRITE_LINE_MEMBER( a2232_device::rs232_1_rxd_w ) |
| 563 | { |
| 564 | m_acia_0->write_rxd(state); |
| 565 | m_cia->sp_w(state); |
| 566 | } |
| 567 | |
| 568 | WRITE_LINE_MEMBER( a2232_device::rs232_1_dcd_w ) |
| 569 | { |
| 570 | m_cia_port_a &= ~0x01; |
| 571 | m_cia_port_a |= state << 0; |
| 572 | } |
| 573 | |
| 574 | WRITE_LINE_MEMBER( a2232_device::rs232_1_cts_w ) |
| 575 | { |
| 576 | m_cia_port_b &= ~0x01; |
| 577 | m_cia_port_b |= state << 0; |
| 578 | |
| 579 | m_cia->cnt_w(state); |
| 580 | } |
| 581 | |
| 582 | WRITE_LINE_MEMBER( a2232_device::rs232_2_dcd_w ) |
| 583 | { |
| 584 | m_cia_port_a &= ~0x02; |
| 585 | m_cia_port_a |= state << 1; |
| 586 | } |
| 587 | |
| 588 | WRITE_LINE_MEMBER( a2232_device::rs232_2_cts_w ) |
| 589 | { |
| 590 | m_cia_port_b &= ~0x02; |
| 591 | m_cia_port_b |= state << 1; |
| 592 | } |
| 593 | |
| 594 | WRITE_LINE_MEMBER( a2232_device::rs232_3_dcd_w ) |
| 595 | { |
| 596 | m_cia_port_a &= ~0x04; |
| 597 | m_cia_port_a |= state << 2; |
| 598 | } |
| 599 | |
| 600 | WRITE_LINE_MEMBER( a2232_device::rs232_3_cts_w ) |
| 601 | { |
| 602 | m_cia_port_b &= ~0x04; |
| 603 | m_cia_port_b |= state << 2; |
| 604 | } |
| 605 | |
| 606 | WRITE_LINE_MEMBER( a2232_device::rs232_4_dcd_w ) |
| 607 | { |
| 608 | m_cia_port_a &= ~0x08; |
| 609 | m_cia_port_a |= state << 3; |
| 610 | } |
| 611 | |
| 612 | WRITE_LINE_MEMBER( a2232_device::rs232_4_cts_w ) |
| 613 | { |
| 614 | m_cia_port_b &= ~0x08; |
| 615 | m_cia_port_b |= state << 3; |
| 616 | } |
| 617 | |
| 618 | WRITE_LINE_MEMBER( a2232_device::rs232_5_dcd_w ) |
| 619 | { |
| 620 | m_cia_port_a &= ~0x10; |
| 621 | m_cia_port_a |= state << 4; |
| 622 | } |
| 623 | |
| 624 | WRITE_LINE_MEMBER( a2232_device::rs232_5_cts_w ) |
| 625 | { |
| 626 | m_cia_port_b &= ~0x10; |
| 627 | m_cia_port_b |= state << 4; |
| 628 | } |
| 629 | |
| 630 | WRITE_LINE_MEMBER( a2232_device::rs232_6_dcd_w ) |
| 631 | { |
| 632 | m_cia_port_a &= ~0x20; |
| 633 | m_cia_port_a |= state << 5; |
| 634 | } |
| 635 | |
| 636 | WRITE_LINE_MEMBER( a2232_device::rs232_6_cts_w ) |
| 637 | { |
| 638 | m_cia_port_b &= ~0x20; |
| 639 | m_cia_port_b |= state << 5; |
| 640 | } |
| 641 | |
| 642 | WRITE_LINE_MEMBER( a2232_device::rs232_7_dcd_w ) |
| 643 | { |
| 644 | m_cia_port_a &= ~0x40; |
| 645 | m_cia_port_a |= state << 6; |
| 646 | } |
| 647 | |
| 648 | WRITE_LINE_MEMBER( a2232_device::rs232_7_cts_w ) |
| 649 | { |
| 650 | m_cia_port_b &= ~0x40; |
| 651 | m_cia_port_b |= state << 6; |
| 652 | } |