summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/fmt_scsi/fmt_scsi.cpp
diff options
context:
space:
mode:
author r09 <rzero9@gmail.com>2020-10-07 18:20:32 +0200
committer GitHub <noreply@github.com>2020-10-08 03:20:32 +1100
commitdd73e03c08b6e6058d55b73a6557f4c3d1355248 (patch)
tree6a49ae40774c136dd5a7e5274f3afb9fd4cd5eef /src/devices/bus/fmt_scsi/fmt_scsi.cpp
parentc552c38ac6ae039d04fbba2c7b2639953e994ccd (diff)
fmtowns: add devices for the SCSI card slot and the FMT-121 card (#7306)
* fmtowns: add a SCSI card slot for the original models - Add a slot device for the Model 1/2 dedicated SCSI slot - Add a device for the FMT-121 SCSI Card - Modify the I/O maps and machine configurations so the slot and the integrated controller don't overlap
Diffstat (limited to 'src/devices/bus/fmt_scsi/fmt_scsi.cpp')
-rw-r--r--src/devices/bus/fmt_scsi/fmt_scsi.cpp158
1 files changed, 158 insertions, 0 deletions
diff --git a/src/devices/bus/fmt_scsi/fmt_scsi.cpp b/src/devices/bus/fmt_scsi/fmt_scsi.cpp
new file mode 100644
index 00000000000..b5d62fb3577
--- /dev/null
+++ b/src/devices/bus/fmt_scsi/fmt_scsi.cpp
@@ -0,0 +1,158 @@
+// license:BSD-3-Clause
+// copyright-holders:r09
+/****************************************************************************
+
+ Fujitsu FM Towns SCSI card slot
+
+ This is a dedicated 30-pin slot for the FMT-121 SCSI Card. It is only
+ present on the Model 1 and 2; all later models integrate the SCSI
+ controller directly on the motherboard.
+
+****************************************************************************/
+
+#include "emu.h"
+#include "fmt_scsi.h"
+
+#include "fmt121.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE(FMT_SCSI_SLOT, fmt_scsi_slot_device, "fmt_scsi_slot", "FM Towns SCSI card slot")
+
+//**************************************************************************
+// FMT_SCSI SLOT DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// fmt_scsi_slot_device - construction
+//-------------------------------------------------
+
+fmt_scsi_slot_device::fmt_scsi_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, FMT_SCSI_SLOT, tag, owner, clock)
+ , device_single_card_slot_interface<fmt_scsi_card_interface>(mconfig, *this)
+ , m_card(nullptr)
+ , m_irq_handler(*this)
+ , m_drq_handler(*this)
+{
+}
+
+
+//-------------------------------------------------
+// device_resolve_objects - resolve objects that
+// may be needed for other devices to set
+// initial conditions at start time
+//-------------------------------------------------
+
+void fmt_scsi_slot_device::device_resolve_objects()
+{
+ m_card = get_card_device();
+ if (m_card != nullptr)
+ m_card->m_slot = this;
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void fmt_scsi_slot_device::device_start()
+{
+ m_irq_handler.resolve_safe();
+ m_drq_handler.resolve_safe();
+}
+
+
+//-------------------------------------------------
+// read - I/O read access
+//-------------------------------------------------
+
+u8 fmt_scsi_slot_device::read(address_space &space, offs_t offset)
+{
+ if (m_card)
+ return m_card->fmt_scsi_read(offset);
+ else
+ return space.unmap();
+}
+
+
+//-------------------------------------------------
+// write - I/O write access
+//-------------------------------------------------
+
+void fmt_scsi_slot_device::write(offs_t offset, u8 data)
+{
+ if (m_card)
+ m_card->fmt_scsi_write(offset, data);
+}
+
+//-------------------------------------------------
+// data_read - data read access
+//-------------------------------------------------
+
+u8 fmt_scsi_slot_device::data_read()
+{
+ if (m_card)
+ return m_card->fmt_scsi_data_read();
+ else
+ return 0;
+}
+
+//-------------------------------------------------
+// data_write - data write access
+//-------------------------------------------------
+
+void fmt_scsi_slot_device::data_write(u8 data)
+{
+ if (m_card)
+ m_card->fmt_scsi_data_write(data);
+}
+
+void fmt_scsi_slot_device::irq_w(int state)
+{
+ m_irq_handler(state);
+}
+
+void fmt_scsi_slot_device::drq_w(int state)
+{
+ m_drq_handler(state);
+}
+
+//**************************************************************************
+// FMT_SCSI CARD INTERFACE
+//**************************************************************************
+
+//-------------------------------------------------
+// fmt_scsi_card_interface - construction
+//-------------------------------------------------
+
+fmt_scsi_card_interface::fmt_scsi_card_interface(const machine_config &mconfig, device_t &device)
+ : device_interface(device, "fmtscsicard")
+ , m_slot(nullptr)
+{
+}
+
+
+//-------------------------------------------------
+// interface_pre_start - called before the
+// device's own start function
+//-------------------------------------------------
+
+void fmt_scsi_card_interface::interface_pre_start()
+{
+ if (!m_slot)
+ throw device_missing_dependencies();
+}
+
+
+//-------------------------------------------------
+// fmt_scsi_default_devices - add standard options
+// for main slots
+//-------------------------------------------------
+
+void fmt_scsi_default_devices(device_slot_interface &device)
+{
+ device.option_add("fmt121", FMT121);
+}