diff options
author | 2018-04-18 19:15:22 +0200 | |
---|---|---|
committer | 2018-04-18 19:17:11 +0200 | |
commit | 5ae175ff115ab674fd3de623175c6571b522e765 (patch) | |
tree | 8de457766b80b699264f24e2bc724a377a9cd601 /src/devices/machine | |
parent | bbf2aa2476fc2c7e9ea3c9321a9bd0e62aa11015 (diff) |
vp415 skeleton updates, nw
Diffstat (limited to 'src/devices/machine')
-rw-r--r-- | src/devices/machine/ncr5385.cpp | 120 | ||||
-rw-r--r-- | src/devices/machine/ncr5385.h | 141 |
2 files changed, 261 insertions, 0 deletions
diff --git a/src/devices/machine/ncr5385.cpp b/src/devices/machine/ncr5385.cpp new file mode 100644 index 00000000000..df2d61f07d0 --- /dev/null +++ b/src/devices/machine/ncr5385.cpp @@ -0,0 +1,120 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/*********************************************************************** + + NCR 5385E SCSI Controller + + TOOD: + - Everything. + +***********************************************************************/ + +#include "emu.h" +#include "ncr5385.h" + +DEFINE_DEVICE_TYPE(NCR5385, ncr5385_device, "ncr5385", "NCR 5385E SCSI Controller") + +ncr5385_device::ncr5385_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, NCR5385, tag, owner, clock) + , m_int(*this) +{ +} + +void ncr5385_device::device_start() +{ + m_int.resolve_safe(); +} + +void ncr5385_device::device_reset() +{ + m_state = STATE_IDLE; + m_int_reg = 0; + m_ctrl_reg = 0; + m_aux_status_reg = AUX_STATUS_TC_ZERO; + m_diag_status_reg = DIAG_COMPLETE; +} + +WRITE8_MEMBER(ncr5385_device::write) +{ + switch (offset) + { + case 0x0: // Data Register + switch (m_state) + { + case STATE_DIAGNOSTIC_GOOD_PARITY: + m_aux_status_reg &= ~AUX_STATUS_PARITY_ERR; + m_aux_status_reg |= AUX_STATUS_DATA_FULL; + m_int_reg = INT_FUNC_COMPLETE; + m_diag_status_reg = DIAG_COMPLETE | DIAG_TURN_GOOD_PARITY; + m_state = STATE_IDLE; + m_int(1); + logerror("%s: ncr5385_w: data=%02x (diagnostic w/ good parity)\n", machine().describe_context(), data); + break; + case STATE_DIAGNOSTIC_BAD_PARITY: + m_aux_status_reg |= AUX_STATUS_PARITY_ERR | AUX_STATUS_DATA_FULL; + m_int_reg = INT_FUNC_COMPLETE; + m_diag_status_reg = DIAG_COMPLETE | DIAG_TURN_BAD_PARITY; + m_state = STATE_IDLE; + m_int(1); + logerror("%s: ncr5385_w: data=%02x (diagnostic w/ bad parity)\n", machine().describe_context(), data); + break; + default: + logerror("%s: ncr5385_w: data=%02x\n", machine().describe_context(), data); + break; + } + break; + case 0x1: // Command Register + switch (data & 0x3f) + { + case 0x00: // Chip Reset + logerror("%s: ncr5385_w: command: reset\n", machine().describe_context()); + m_state = STATE_IDLE; + m_int_reg = 0; + m_aux_status_reg = AUX_STATUS_TC_ZERO; + m_diag_status_reg = DIAG_COMPLETE; + m_int(0); + break; + case 0x0b: // Diagnostic + logerror("%s: ncr5385_w: command: diagnostic (%s parity)\n", machine().describe_context(), BIT(data, 6) ? "bad" : "good"); + if (BIT(data, 6)) + m_state = STATE_DIAGNOSTIC_BAD_PARITY; + else + m_state = STATE_DIAGNOSTIC_GOOD_PARITY; + break; + default: + logerror("%s: ncr5385_w: command: %02x\n", machine().describe_context(), data); + break; + } + break; + case 0x2: // Control Register + m_ctrl_reg = data & 0x07; + logerror("%s: ncr5385_w: control: parity_en=%d, reselect_en=%d, select_en=%d\n", machine().describe_context(), BIT(data, CTRL_PARITY_BIT), BIT(data, CTRL_RESELECT_BIT), BIT(data, CTRL_SELECT_BIT)); + break; + default: + logerror("%s: ncr5385_w: %x=%02x\n", machine().describe_context(), offset, data); + break; + } +} + +READ8_MEMBER(ncr5385_device::read) +{ + switch (offset) + { + case 0x2: + logerror("%s: ncr5385_r: control (%02x)\n", machine().describe_context(), m_ctrl_reg); + return m_ctrl_reg; + case 0x4: + logerror("%s: ncr5385_r: aux status (%02x)\n", machine().describe_context(), m_aux_status_reg); + return m_aux_status_reg; + case 0x6: + logerror("%s: ncr5385_r: interrupt (%02x)\n", machine().describe_context(), m_int_reg); + m_int(1); + return m_int_reg; + case 0x9: + logerror("%s: ncr5385_r: diagnostic status (%02x)\n", machine().describe_context(), m_diag_status_reg); + return m_diag_status_reg; + default: + logerror("%s: ncr5385_r: %x (%02x)\n", machine().describe_context(), offset, 0); + return 0; + } +} diff --git a/src/devices/machine/ncr5385.h b/src/devices/machine/ncr5385.h new file mode 100644 index 00000000000..576b7f2b065 --- /dev/null +++ b/src/devices/machine/ncr5385.h @@ -0,0 +1,141 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/*********************************************************************** + + NCR 5385 SCSI Controller emulation + + TODO: + - Everything. Currently, just enough is implemented to make the + Philips VP415 CPU / Datagrabber board satisfied that the + controller has passed its internal diagnostics. + +************************************************************************ + _____ _____ + D2 1 |* \_/ | 48 VCC + D1 2 | | 47 D3 + D0 3 | | 46 D4 + RESET 4 | | 45 D5 + ATN 5 | | 44 D6 + IGS 6 | | 43 D7 + I/O 7 | | 42 BSYOUT + C/D 8 | | 41 SB7 + MSG 9 | | 40 SB6 + ACK 10 | | 39 SB5 + REQ 11 | | 38 SB4 + /ID2 12 | NCR 5385E | 37 SB3 + /ID1 13 | | 36 SB2 + /ID0 14 | | 35 SB1 + ARB 15 | | 34 SB9 + CLK 16 | | 33 SBP + BSY IN 17 | | 32 SELOUT + SEL IN 18 | | 31 /RD + INT 19 | | 30 /WR + /SBEN 20 | | 29 DREQ + /CS 21 | | 28 TGS + A0 22 | | 27 /DACK + A1 23 | | 26 A3 + GND 24 |_____________| 25 A2 + +************************************************************************/ + +#ifndef MAME_MACHINE_NCR5385_H +#define MAME_MACHINE_NCR5385_H + +#pragma once + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_NCR5385_INT_CB(_int) \ + devcb = &downcast<ncr5385_device &>(*device).set_int_callback(DEVCB_##_int); + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> ncr5385_device + +class ncr5385_device : public device_t +{ +public: + // construction/destruction + ncr5385_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + template <class Object> devcb_base &set_int_callback(Object &&cb) { return m_int.set_callback(std::forward<Object>(cb)); } + + DECLARE_WRITE8_MEMBER(write); + DECLARE_READ8_MEMBER(read); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + +private: + enum + { + STATE_IDLE, + STATE_DIAGNOSTIC_GOOD_PARITY, + STATE_DIAGNOSTIC_BAD_PARITY, + }; + + enum + { + DIAG_TURN_MISCOMPARE_INITIAL = 0x08, + DIAG_TURN_MISCOMPARE_FINAL = 0x10, + DIAG_TURN_GOOD_PARITY = 0x18, + DIAG_TURN_BAD_PARITY = 0x20, + DIAG_COMPLETE = 0x80, + + DIAG_COMPLETE_BIT = 7, + }; + + enum + { + INT_FUNC_COMPLETE = 0x01, + INT_INVALID_CMD = 0x40, + + INT_FUNC_COMPLETE_BIT = 0, + INT_INVALID_CMD_BIT = 6, + }; + + enum + { + AUX_STATUS_TC_ZERO = 0x02, + AUX_STATUS_PAUSED = 0x04, + AUX_STATUS_PARITY_ERR = 0x40, + AUX_STATUS_DATA_FULL = 0x80, + + AUX_STATUS_TC_ZERO_BIT = 1, + AUX_STATUS_PAUSED_BIT = 2, + AUX_STATUS_PARITY_ERR_BIT = 6, + AUX_STATUS_DATA_FULL_BIT = 7, + }; + + enum + { + CTRL_SELECT = 0x01, + CTRL_RESELECT = 0x02, + CTRL_PARITY = 0x04, + + CTRL_SELECT_BIT = 0, + CTRL_RESELECT_BIT = 1, + CTRL_PARITY_BIT = 2, + }; + + devcb_write_line m_int; + + uint32_t m_state; + uint8_t m_ctrl_reg; + uint8_t m_int_reg; + uint8_t m_aux_status_reg; + uint8_t m_diag_status_reg; +}; + +// device type definition +DECLARE_DEVICE_TYPE(NCR5385, ncr5385_device) + +#endif // MAME_MACHINE_NCR5385_H |