From 8c87cbae370d4e756ff4334a1d28f44cd1de4f23 Mon Sep 17 00:00:00 2001 From: Joakim Larsson Edstrom Date: Thu, 21 Sep 2017 14:19:46 +0200 Subject: z80sio/z80scc: now returns cpu specific default vector when no interrupt found to acknowledge --- src/devices/machine/z80scc.cpp | 44 +++++++++++++++++++++++++++--------------- src/devices/machine/z80scc.h | 7 +++++++ src/devices/machine/z80sio.cpp | 19 +++++++++++------- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/devices/machine/z80scc.cpp b/src/devices/machine/z80scc.cpp index 805018d00f2..64a424f993d 100644 --- a/src/devices/machine/z80scc.cpp +++ b/src/devices/machine/z80scc.cpp @@ -81,17 +81,16 @@ DONE (x) (p=partly) NMOS CMOS ESCC EMSCC #define LOG_GENERAL (1U << 0) #define LOG_SETUP (1U << 1) -#define LOG_PRINTF (1U << 2) -#define LOG_READ (1U << 3) -#define LOG_INT (1U << 4) -#define LOG_CMD (1U << 5) -#define LOG_TX (1U << 6) -#define LOG_RCV (1U << 7) -#define LOG_CTS (1U << 8) -#define LOG_DCD (1U << 9) -#define LOG_SYNC (1U << 10) - -//#define VERBOSE (LOG_CMD|LOG_INT|LOG_SETUP|LOG_TX|LOG_RCV|LOG_READ|LOG_CTS|LOG_DCD) +#define LOG_READ (1U << 2) +#define LOG_INT (1U << 3) +#define LOG_CMD (1U << 4) +#define LOG_TX (1U << 5) +#define LOG_RCV (1U << 6) +#define LOG_CTS (1U << 7) +#define LOG_DCD (1U << 8) +#define LOG_SYNC (1U << 9) + +//#define VERBOSE (LOG_INT|LOG_READ|LOG_SETUP|LOG_TX|LOG_CMD) //#define LOG_OUTPUT_FUNC printf #include "logmacro.h" @@ -187,7 +186,8 @@ z80scc_device::z80scc_device(const machine_config &mconfig, device_type type, co m_out_rxdrqb_cb(*this), m_out_txdrqb_cb(*this), m_variant(variant), - m_wr0_ptrbits(0) + m_wr0_ptrbits(0), + m_cputag(nullptr) { for (auto & elem : m_int_state) elem = 0; @@ -371,6 +371,8 @@ int z80scc_device::z80daisy_irq_state() //------------------------------------------------- int z80scc_device::z80daisy_irq_ack() { + int ret = -1; // Indicate default vector + LOGINT("%s %s \n",tag(), FUNCNAME); // loop over all interrupt sources for (auto & elem : m_int_state) @@ -383,18 +385,28 @@ int z80scc_device::z80daisy_irq_ack() LOGINT(" - Found an INT request, "); if (m_wr9 & z80scc_channel::WR9_BIT_VIS) { - LOGINT("but WR9 D1 set to use autovector, returning -1\n"); - return -1; + LOGINT("but WR9 D1 set to use autovector, returning the default vector\n"); + break; } else { LOGINT("returning RR2: %02x\n", m_chanB->m_rr2 ); - return m_chanB->m_rr2; + ret = m_chanB->m_rr2; + break; } } } - return -1; + // Did we not find a vector? Get the notion of a default vector from the CPU implementation + if (ret == -1 && m_cputag != nullptr) + { + // default irq vector is -1 for 68000 but 0 for z80 for example... + ret = owner()->subdevice(m_cputag)->default_irq_vector(); + LOGINT(" - failed to find an interrupt to ack, returning default IRQ vector: %02x\n", ret ); + logerror("z80sio_irq_ack: failed to find an interrupt to ack!\n"); + } + + return ret; } diff --git a/src/devices/machine/z80scc.h b/src/devices/machine/z80scc.h index 2b0cae0ea76..33729f23efb 100644 --- a/src/devices/machine/z80scc.h +++ b/src/devices/machine/z80scc.h @@ -661,6 +661,12 @@ public: template static devcb_base &set_out_rxdrqb_callback(device_t &device, Object &&cb) { return downcast(device).m_out_rxdrqb_cb.set_callback(std::forward(cb)); } template static devcb_base &set_out_txdrqb_callback(device_t &device, Object &&cb) { return downcast(device).m_out_txdrqb_cb.set_callback(std::forward(cb)); } + static void static_set_cputag(device_t &device, const char *tag) + { + z80scc_device &dev = downcast(device); + dev.m_cputag = tag; + } + static void configure_channels(device_t &device, int rxa, int txa, int rxb, int txb) { z80scc_device &dev = downcast(device); @@ -798,6 +804,7 @@ protected: int const m_variant; uint8_t m_wr0_ptrbits; + const char *m_cputag; }; class scc8030_device : public z80scc_device diff --git a/src/devices/machine/z80sio.cpp b/src/devices/machine/z80sio.cpp index 83a8479f638..cfc56d209eb 100644 --- a/src/devices/machine/z80sio.cpp +++ b/src/devices/machine/z80sio.cpp @@ -142,7 +142,7 @@ z80sio_device::z80sio_device(const machine_config &mconfig, device_type type, co m_out_rxdrqb_cb(*this), m_out_txdrqb_cb(*this), m_variant(variant), - m_cputag("maincpu") + m_cputag(nullptr) { for (auto & elem : m_int_state) elem = 0; @@ -245,8 +245,7 @@ int z80sio_device::z80daisy_irq_state() //------------------------------------------------- int z80sio_device::z80daisy_irq_ack() { - // default irq vector is -1 for 68000 but 0 for z80 for example... - int ret = owner()->subdevice(m_cputag)->default_irq_vector(); + int ret = -1; // Indicate default vector LOGINT("%s %s \n",tag(), FUNCNAME); // loop over all interrupt sources @@ -260,12 +259,18 @@ int z80sio_device::z80daisy_irq_ack() LOGINT(" - Found an INT request, "); LOGINT("returning RR2: %02x\n", m_chanB->m_rr2 ); check_interrupts(); - return m_chanB->m_rr2; + ret = m_chanB->m_rr2; + break; } } - ret = m_chanB->m_rr2; - LOGINT(" - failed to find an interrupt to ack, returning default IRQ vector: %02x\n", ret ); - logerror("z80sio_irq_ack: failed to find an interrupt to ack!\n"); + // Did we not find a vector? Get the notion of a default vector from the CPU implementation + if (ret == -1 && m_cputag != nullptr) + { + // default irq vector is -1 for 68000 but 0 for z80 for example... + ret = owner()->subdevice(m_cputag)->default_irq_vector(); + LOGINT(" - failed to find an interrupt to ack [%s], returning default IRQ vector: %02x\n", m_cputag, ret ); + logerror("z80sio_irq_ack: failed to find an interrupt to ack!\n"); + } return ret; } -- cgit v1.2.3