From b23321005180d4ede07182d755ecd972ed9c7711 Mon Sep 17 00:00:00 2001 From: Sergey Svishchev Date: Wed, 24 Sep 2025 20:07:55 +0300 Subject: [PATCH] qbus: add bus error and BEVENT (periodic timer) callbacks. Support systems with entire memory space covered by a view (uknc) -- views are not initialized at device_start() time. Correct initial state of PC11 device. --- src/devices/bus/qbus/dvk_kgd.cpp | 13 ++++++++++--- src/devices/bus/qbus/dvk_kgd.h | 2 ++ src/devices/bus/qbus/dvk_mx.cpp | 14 +++++++++++--- src/devices/bus/qbus/dvk_mx.h | 2 ++ src/devices/bus/qbus/pc11.cpp | 21 +++++++++++++++------ src/devices/bus/qbus/pc11.h | 1 + src/devices/bus/qbus/qbus.cpp | 8 +++++++- src/devices/bus/qbus/qbus.h | 10 ++++++++++ 8 files changed, 58 insertions(+), 13 deletions(-) diff --git a/src/devices/bus/qbus/dvk_kgd.cpp b/src/devices/bus/qbus/dvk_kgd.cpp index 1c7f28c5fc893..75dbfe6a7c8b0 100644 --- a/src/devices/bus/qbus/dvk_kgd.cpp +++ b/src/devices/bus/qbus/dvk_kgd.cpp @@ -33,6 +33,7 @@ DEFINE_DEVICE_TYPE(DVK_KGD, dvk_kgd_device, "kgd", "DVK KGD framebuffer") dvk_kgd_device::dvk_kgd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, DVK_KGD, tag, owner, clock) , device_qbus_card_interface(mconfig, *this) + , m_installed(false) , m_screen(*this, "screen") { } @@ -80,10 +81,8 @@ void dvk_kgd_device::device_add_mconfig(machine_config &config) void dvk_kgd_device::device_start() { - m_bus->install_device(0176640, 0176647, read16sm_delegate(*this, FUNC(dvk_kgd_device::read)), - write16sm_delegate(*this, FUNC(dvk_kgd_device::write))); - // save state + save_item(NAME(m_installed)); save_item(NAME(m_cr)); save_item(NAME(m_dr)); save_item(NAME(m_ar)); @@ -91,6 +90,8 @@ void dvk_kgd_device::device_start() m_videoram_base = std::make_unique(16384); m_videoram = m_videoram_base.get(); + + m_installed = false; } @@ -100,6 +101,12 @@ void dvk_kgd_device::device_start() void dvk_kgd_device::device_reset() { + if (!m_installed) + { + m_bus->install_device(0176640, 0176647, read16sm_delegate(*this, FUNC(dvk_kgd_device::read)), + write16sm_delegate(*this, FUNC(dvk_kgd_device::write))); + m_installed = true; + } m_cr = m_dr = m_ar = m_ct = 0; } diff --git a/src/devices/bus/qbus/dvk_kgd.h b/src/devices/bus/qbus/dvk_kgd.h index dfcb027706ddc..948290c51439e 100644 --- a/src/devices/bus/qbus/dvk_kgd.h +++ b/src/devices/bus/qbus/dvk_kgd.h @@ -46,6 +46,8 @@ class dvk_kgd_device : public device_t, virtual void device_reset() override ATTR_COLD; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; + bool m_installed; + required_device m_screen; private: diff --git a/src/devices/bus/qbus/dvk_mx.cpp b/src/devices/bus/qbus/dvk_mx.cpp index 757262481ec54..c95914df805e2 100644 --- a/src/devices/bus/qbus/dvk_mx.cpp +++ b/src/devices/bus/qbus/dvk_mx.cpp @@ -97,6 +97,7 @@ dvk_mx_device::dvk_mx_device(const machine_config &mconfig, const char *tag, dev : device_t(mconfig, DVK_MX, tag, owner, clock) , device_qbus_card_interface(mconfig, *this) , m_connectors(*this, "%u", 0U) + , m_installed(false) { } @@ -126,6 +127,7 @@ void dvk_mx_device::device_start() } // save state + save_item(NAME(m_installed)); save_item(NAME(m_mxcs)); save_item(NAME(m_rbuf)); save_item(NAME(m_wbuf)); @@ -133,11 +135,10 @@ void dvk_mx_device::device_start() m_timer_2khz = timer_alloc(FUNC(dvk_mx_device::twokhz_tick), this); - m_bus->install_device(0177130, 0177133, read16sm_delegate(*this, FUNC(dvk_mx_device::read)), - write16sm_delegate(*this, FUNC(dvk_mx_device::write))); - m_mxcs = 0; selected_drive = -1; + + m_installed = false; } //------------------------------------------------- @@ -146,6 +147,13 @@ void dvk_mx_device::device_start() void dvk_mx_device::device_reset() { + if (!m_installed) + { + m_bus->install_device(0177130, 0177133, read16sm_delegate(*this, FUNC(dvk_mx_device::read)), + write16sm_delegate(*this, FUNC(dvk_mx_device::write))); + m_installed = true; + } + m_rbuf = m_wbuf = 0; m_mxcs &= ~MXCSR_ERR; diff --git a/src/devices/bus/qbus/dvk_mx.h b/src/devices/bus/qbus/dvk_mx.h index 556ec5839fbb1..536b877a017a6 100644 --- a/src/devices/bus/qbus/dvk_mx.h +++ b/src/devices/bus/qbus/dvk_mx.h @@ -126,6 +126,8 @@ class dvk_mx_device : public device_t, public device_qbus_card_interface required_device_array m_connectors; + bool m_installed; + uint16_t m_mxcs; uint16_t m_rbuf; uint16_t m_wbuf; diff --git a/src/devices/bus/qbus/pc11.cpp b/src/devices/bus/qbus/pc11.cpp index c27e240cc0891..4ce89b58f7a89 100644 --- a/src/devices/bus/qbus/pc11.cpp +++ b/src/devices/bus/qbus/pc11.cpp @@ -56,6 +56,7 @@ const char* pc11_regnames[] = { pc11_device::pc11_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : paper_tape_reader_device(mconfig, DEC_PC11, tag, owner, clock) , device_qbus_card_interface(mconfig, *this) + , m_installed(false) , m_rxvec(070) , m_txvec(074) { @@ -69,12 +70,8 @@ pc11_device::pc11_device(const machine_config &mconfig, const char *tag, device_ void pc11_device::device_start() { - m_bus->install_device(0177550, 0177557, read16sm_delegate(*this, FUNC(pc11_device::read)), - write16sm_delegate(*this, FUNC(pc11_device::write))); - - // resolve callbacks - // save state + save_item(NAME(m_installed)); save_item(NAME(m_rcsr)); save_item(NAME(m_rbuf)); save_item(NAME(m_tcsr)); @@ -83,6 +80,11 @@ void pc11_device::device_start() // about 300 cps m_read_timer = timer_alloc(FUNC(pc11_device::read_tick), this); m_read_timer->adjust(attotime::from_usec(333), 0, attotime::from_usec(333)); + + m_fd = nullptr; + m_rcsr = CSR_ERR; + + m_installed = false; } @@ -94,7 +96,14 @@ void pc11_device::device_reset() { LOG("Reset, rxvec %03o txvec %03o\n", m_rxvec, m_txvec); - m_rcsr = m_rbuf = m_tbuf = 0; + if (!m_installed) + { + m_bus->install_device(0177550, 0177557, read16sm_delegate(*this, FUNC(pc11_device::read)), + write16sm_delegate(*this, FUNC(pc11_device::write))); + m_installed = true; + } + + m_rbuf = m_tbuf = 0; m_tcsr = CSR_DONE; m_rxrdy = m_txrdy = CLEAR_LINE; diff --git a/src/devices/bus/qbus/pc11.h b/src/devices/bus/qbus/pc11.h index 1793808826c19..527a293fe63a9 100644 --- a/src/devices/bus/qbus/pc11.h +++ b/src/devices/bus/qbus/pc11.h @@ -59,6 +59,7 @@ class pc11_device : public paper_tape_reader_device, TIMER_CALLBACK_MEMBER(read_tick); private: + bool m_installed; int m_rxvec; int m_txvec; diff --git a/src/devices/bus/qbus/qbus.cpp b/src/devices/bus/qbus/qbus.cpp index d3b639c801f42..85bd1d03db3d5 100644 --- a/src/devices/bus/qbus/qbus.cpp +++ b/src/devices/bus/qbus/qbus.cpp @@ -98,6 +98,8 @@ qbus_device::qbus_device(const machine_config &mconfig, const char *tag, device_ device_z80daisy_interface(mconfig, *this), m_program_config("a18", ENDIANNESS_BIG, 16, 16, 0, address_map_constructor()), m_space(*this, finder_base::DUMMY_TAG, -1), + m_out_bus_error_cb(*this), + m_out_bevnt_cb(*this), m_out_birq4_cb(*this), m_out_birq5_cb(*this), m_out_birq6_cb(*this), @@ -124,6 +126,7 @@ device_memory_interface::space_config_vector qbus_device::memory_space_config() void qbus_device::device_start() { + m_view = nullptr; } @@ -156,7 +159,10 @@ void qbus_device::add_card(device_qbus_card_interface &card) void qbus_device::install_device(offs_t start, offs_t end, read16sm_delegate rhandler, write16sm_delegate whandler, uint32_t mask) { - m_space->install_readwrite_handler(start, end, rhandler, whandler, mask); + if (m_view) + m_view->install_readwrite_handler(start, end, rhandler, whandler, mask); + else + m_space->install_readwrite_handler(start, end, rhandler, whandler, mask); } diff --git a/src/devices/bus/qbus/qbus.h b/src/devices/bus/qbus/qbus.h index c33af439080c3..b36ffce16d691 100644 --- a/src/devices/bus/qbus/qbus.h +++ b/src/devices/bus/qbus/qbus.h @@ -71,10 +71,14 @@ class qbus_device : public device_t, // inline configuration template void set_space(T &&tag, int spacenum) { m_space.set_tag(std::forward(tag), spacenum); } + void set_view(memory_view::memory_view_entry &view) { m_view = &view; }; virtual space_config_vector memory_space_config() const override; address_space &program_space() const { return *m_space; } + auto bus_error_callback() { return m_out_bus_error_cb.bind(); } + + auto bevnt() { return m_out_bevnt_cb.bind(); } auto birq4() { return m_out_birq4_cb.bind(); } auto birq5() { return m_out_birq6_cb.bind(); } auto birq6() { return m_out_birq6_cb.bind(); } @@ -84,7 +88,9 @@ class qbus_device : public device_t, void install_device(offs_t start, offs_t end, read16sm_delegate rhandler, write16sm_delegate whandler, uint32_t mask=0xffffffff); void init_w(); + void bus_error_w(int state) { m_out_bus_error_cb(state); } + void bevnt_w(int state) { m_out_bevnt_cb(state); } void birq4_w(int state) { m_out_birq4_cb(state); } void birq5_w(int state) { m_out_birq5_cb(state); } void birq6_w(int state) { m_out_birq6_cb(state); } @@ -106,10 +112,14 @@ class qbus_device : public device_t, // internal state required_address_space m_space; + memory_view::memory_view_entry *m_view; private: using card_vector = std::vector >; + devcb_write_line m_out_bus_error_cb; + + devcb_write_line m_out_bevnt_cb; devcb_write_line m_out_birq4_cb; devcb_write_line m_out_birq5_cb; devcb_write_line m_out_birq6_cb;