From 400e51198b763d3e57ea8e7240a71f90b8809619 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 29 May 2012 06:44:54 +0000 Subject: [PATCH] Sync with MESS, Curt changes related to Wang PC (no whatsnew) --- .gitattributes | 2 + src/emu/cpu/mcs51/mcs51.c | 13 +- src/emu/diserial.c | 8 +- src/emu/diserial.h | 2 +- src/emu/emu.mak | 1 + src/emu/machine/im6402.c | 40 +++++- src/emu/machine/im6402.h | 7 +- src/emu/machine/scn2661.c | 293 ++++++++++++++++++++++++++++++++++++++ src/emu/machine/scn2661.h | 152 ++++++++++++++++++++ 9 files changed, 501 insertions(+), 17 deletions(-) create mode 100644 src/emu/machine/scn2661.c create mode 100644 src/emu/machine/scn2661.h diff --git a/.gitattributes b/.gitattributes index 9126ee94faa..bacf229adc3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -981,6 +981,8 @@ src/emu/machine/s3c2410.h svneol=native#text/plain src/emu/machine/s3c2440.c svneol=native#text/plain src/emu/machine/s3c2440.h svneol=native#text/plain src/emu/machine/s3c24xx.c svneol=native#text/plain +src/emu/machine/scn2661.c svneol=native#text/plain +src/emu/machine/scn2661.h svneol=native#text/plain src/emu/machine/scsi.c svneol=native#text/plain src/emu/machine/scsi.h svneol=native#text/plain src/emu/machine/scsicd.c svneol=native#text/plain diff --git a/src/emu/cpu/mcs51/mcs51.c b/src/emu/cpu/mcs51/mcs51.c index 57a02562c83..2496afbff7d 100644 --- a/src/emu/cpu/mcs51/mcs51.c +++ b/src/emu/cpu/mcs51/mcs51.c @@ -952,6 +952,7 @@ INLINE void transmit_receive(mcs51_state_t *mcs51_state, int source) SET_SBUF(data); //Flag the IRQ SET_RI(1); + SET_RB8(1); // HACK force 2nd stop bit } } } @@ -1221,7 +1222,7 @@ INLINE void serial_transmit(mcs51_state_t *mcs51_state, UINT8 data) //Flag that we're sending data mcs51_state->uart.data_out = data; - LOG(("serial_tansmit: %x %x\n", mode, data)); + LOG(("serial_transmit: %x %x\n", mode, data)); switch(mode) { //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12 case 0: @@ -1234,7 +1235,7 @@ INLINE void serial_transmit(mcs51_state_t *mcs51_state, UINT8 data) //9 bit uart case 2: case 3: - LOG(("Serial mode %d not supported in mcs51!\n", mode)); + mcs51_state->uart.bits_to_send = 8+3; break; } } @@ -1256,7 +1257,7 @@ INLINE void serial_receive(mcs51_state_t *mcs51_state) //9 bit uart case 2: case 3: - LOG(("Serial mode %d not supported in mcs51!\n", mode)); + mcs51_state->uart.delay_cycles = 8+3; break; } } @@ -1727,7 +1728,7 @@ static void check_irqs(mcs51_state_t *mcs51_state) LOG(("Request: %d\n", priority_request)); if (mcs51_state->irq_active && (priority_request <= mcs51_state->cur_irq_prio)) { - LOG(("higher or equal priority irq in progress already, skipping ...\n")); + LOG(("higher or equal priority irq (%u) in progress already, skipping ...\n", mcs51_state->cur_irq_prio)); return; } @@ -2191,6 +2192,10 @@ static CPU_RESET( mcs51 ) mcs51_state->ds5002fp.range = (GET_RG1 << 1) | GET_RG0; } + mcs51_state->uart.rx_clk = 0; + mcs51_state->uart.tx_clk = 0; + mcs51_state->uart.bits_to_send = 0; + mcs51_state->uart.delay_cycles = 0; } /* Shut down CPU core */ diff --git a/src/emu/diserial.c b/src/emu/diserial.c index e312be2c0f9..f28c8b73588 100644 --- a/src/emu/diserial.c +++ b/src/emu/diserial.c @@ -340,11 +340,9 @@ UINT8 device_serial_interface::transmit_register_get_data_bit() return bit; } -void device_serial_interface::transmit_register_send_bit() +UINT8 device_serial_interface::transmit_register_send_bit() { - int data; - - data = transmit_register_get_data_bit(); + UINT8 data = transmit_register_get_data_bit(); /* set tx data bit */ m_connection_state &=~SERIAL_STATE_TX_DATA; @@ -352,6 +350,8 @@ void device_serial_interface::transmit_register_send_bit() /* state out through connection */ serial_connection_out(); + + return data; } diff --git a/src/emu/diserial.h b/src/emu/diserial.h index 4e604f4ba0f..aa59ac569d1 100644 --- a/src/emu/diserial.h +++ b/src/emu/diserial.h @@ -98,7 +98,7 @@ public: void transmit_register_add_bit(int bit); void transmit_register_setup(UINT8 data_byte); UINT8 transmit_register_get_data_bit(); - void transmit_register_send_bit(); + UINT8 transmit_register_send_bit(); UINT8 serial_helper_get_parity(UINT8 data) { return m_serial_parity_table[data]; } diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 2bface55244..396b5dad532 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -239,6 +239,7 @@ EMUMACHINEOBJS = \ $(EMUMACHINE)/s3c2400.o \ $(EMUMACHINE)/s3c2410.o \ $(EMUMACHINE)/s3c2440.o \ + $(EMUMACHINE)/scn2661.o \ $(EMUMACHINE)/scsi.o \ $(EMUMACHINE)/scsicd.o \ $(EMUMACHINE)/scsidev.o \ diff --git a/src/emu/machine/im6402.c b/src/emu/machine/im6402.c index 9e03a188fd8..420cdca9e0e 100644 --- a/src/emu/machine/im6402.c +++ b/src/emu/machine/im6402.c @@ -23,7 +23,7 @@ const device_type IM6402 = &device_creator; // MACROS / CONSTANTS //************************************************************************** -#define LOG 0 +#define LOG 1 @@ -73,19 +73,27 @@ inline void im6402_device::set_tre(int state) inline void im6402_device::receive() { + int bit = 1; + if (m_in_rri_func.isnull()) { - receive_register_update_bit(get_in_data_bit()); + bit = get_in_data_bit(); } else { - receive_register_update_bit(m_in_rri_func()); + bit = m_in_rri_func(); } +// if (LOG) logerror("IM6402 '%s' Receive Bit %u\n", tag(), bit); + + receive_register_update_bit(bit); + if (is_receive_register_full()) { receive_register_extract(); m_rbr = get_received_char(); + + if (LOG) logerror("IM6402 '%s' Receive Data %02x\n", tag(), m_rbr); if (m_dr) { @@ -105,6 +113,8 @@ inline void im6402_device::transmit() { if (is_transmit_register_empty() && !m_tbre) { + if (LOG) logerror("IM6402 '%s' Transmit Data %02x\n", tag(), m_tbr); + transmit_register_setup(m_tbr); set_tbre(ASSERT_LINE); @@ -113,10 +123,11 @@ inline void im6402_device::transmit() if (!is_transmit_register_empty()) { - int bit = transmit_register_get_data_bit(); + int bit = transmit_register_send_bit(); + + if (LOG) logerror("IM6402 '%s' Transmit Bit %u\n", tag(), bit); m_out_tro_func(bit); - serial_connection_out(); if (is_transmit_register_empty()) { @@ -219,6 +230,9 @@ void im6402_device::device_start() void im6402_device::device_reset() { + transmit_register_reset(); + receive_register_reset(); + m_rrc_count = 0; m_trc_count = 0; @@ -277,6 +291,8 @@ READ8_MEMBER( im6402_device::read ) WRITE8_MEMBER( im6402_device::write ) { + if (LOG) logerror("IM6402 '%s' Transmit Buffer Register %02x\n", tag(), data); + m_tbr = data; set_tbre(CLEAR_LINE); @@ -433,8 +449,10 @@ WRITE_LINE_MEMBER( im6402_device::crl_w ) { if (state) { + if (LOG) logerror("IM6402 '%s' Control Register Load\n", tag()); + int word_length = 5 + ((m_cls2 << 1) | m_cls1); - int stop_bits = 1 + m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0; + int stop_bits = 1 + (m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0); int parity_code; if (m_pi) parity_code = SERIAL_PARITY_NONE; @@ -452,6 +470,8 @@ WRITE_LINE_MEMBER( im6402_device::crl_w ) WRITE_LINE_MEMBER( im6402_device::pi_w ) { + if (LOG) logerror("IM6402 '%s' Parity Inhibit %u\n", tag(), state); + m_pi = state; } @@ -462,6 +482,8 @@ WRITE_LINE_MEMBER( im6402_device::pi_w ) WRITE_LINE_MEMBER( im6402_device::sbs_w ) { + if (LOG) logerror("IM6402 '%s' Stop Bit Select %u\n", tag(), state); + m_sbs = state; } @@ -472,6 +494,8 @@ WRITE_LINE_MEMBER( im6402_device::sbs_w ) WRITE_LINE_MEMBER( im6402_device::cls1_w ) { + if (LOG) logerror("IM6402 '%s' Character Length Select 1 %u\n", tag(), state); + m_cls1 = state; } @@ -482,6 +506,8 @@ WRITE_LINE_MEMBER( im6402_device::cls1_w ) WRITE_LINE_MEMBER( im6402_device::cls2_w ) { + if (LOG) logerror("IM6402 '%s' Character Length Select 2 %u\n", tag(), state); + m_cls2 = state; } @@ -492,5 +518,7 @@ WRITE_LINE_MEMBER( im6402_device::cls2_w ) WRITE_LINE_MEMBER( im6402_device::epe_w ) { + if (LOG) logerror("IM6402 '%s' Even Parity Enable %u\n", tag(), state); + m_epe = state; } diff --git a/src/emu/machine/im6402.h b/src/emu/machine/im6402.h index 254fa8027ce..3d73010c4d1 100644 --- a/src/emu/machine/im6402.h +++ b/src/emu/machine/im6402.h @@ -129,8 +129,11 @@ private: inline void receive(); inline void transmit(); - static const device_timer_id TIMER_RX = 0; - static const device_timer_id TIMER_TX = 1; + enum + { + TIMER_RX, + TIMER_TX + }; devcb_resolved_read_line m_in_rri_func; devcb_resolved_write_line m_out_tro_func; diff --git a/src/emu/machine/scn2661.c b/src/emu/machine/scn2661.c new file mode 100644 index 00000000000..49deb411701 --- /dev/null +++ b/src/emu/machine/scn2661.c @@ -0,0 +1,293 @@ +/*************************************************************************** + + Philips SCN2661 Enhanced Programmable Communications Interface emulation + + Copyright the MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +***************************************************************************/ + +#include "scn2661.h" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type SCN2661 = &device_creator; + + + +//************************************************************************** +// MACROS / CONSTANTS +//************************************************************************** + +#define LOG 1 + +enum +{ + REGISTER_HOLDING = 0, + REGISTER_STATUS, + REGISTER_SYNC = REGISTER_STATUS, + REGISTER_MODE, + REGISTER_COMMAND +}; + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// receive - +//------------------------------------------------- + +inline void scn2661_device::receive() +{ +} + + +//------------------------------------------------- +// transmit - +//------------------------------------------------- + +inline void scn2661_device::transmit() +{ +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// scn2661_device - constructor +//------------------------------------------------- + +scn2661_device::scn2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, SCN2661, "SCN2661", tag, owner, clock), + device_serial_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void scn2661_device::device_config_complete() +{ + // inherit a copy of the static data + const scn2661_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb)); + memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb)); + memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb)); + memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb)); + memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb)); + memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb)); + memset(&m_out_txemt_dschg_cb, 0, sizeof(m_out_txemt_dschg_cb)); + memset(&m_out_bkdet_cb, 0, sizeof(m_out_bkdet_cb)); + memset(&m_out_xsync_cb, 0, sizeof(m_out_xsync_cb)); + } +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void scn2661_device::device_start() +{ + // resolve callbacks + m_in_rxd_func.resolve(m_in_rxd_cb, *this); + m_out_txd_func.resolve(m_out_txd_cb, *this); + m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this); + m_out_txrdy_func.resolve(m_out_txrdy_cb, *this); + m_out_rts_func.resolve(m_out_rts_cb, *this); + m_out_dtr_func.resolve(m_out_dtr_cb, *this); + m_out_txemt_dschg_func.resolve(m_out_txemt_dschg_cb, *this); + m_out_bkdet_func.resolve(m_out_bkdet_cb, *this); + m_out_xsync_func.resolve(m_out_xsync_cb, *this); + + // create the timers + if (m_rxc > 0) + { + m_rx_timer = timer_alloc(TIMER_RX); + m_rx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_rxc)); + } + + if (m_txc > 0) + { + m_tx_timer = timer_alloc(TIMER_TX); + m_tx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_txc)); + } +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void scn2661_device::device_reset() +{ + transmit_register_reset(); + receive_register_reset(); +} + + +//------------------------------------------------- +// device_timer - handler timer events +//------------------------------------------------- + +void scn2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case TIMER_RX: + rxc_w(1); + break; + + case TIMER_TX: + txc_w(1); + break; + } +} + + +//------------------------------------------------- +// input_callback - +//------------------------------------------------- + +void scn2661_device::input_callback(UINT8 state) +{ +} + + +//------------------------------------------------- +// read - +//------------------------------------------------- + +READ8_MEMBER( scn2661_device::read ) +{ + UINT8 data = 0; + + switch (offset & 0x03) + { + case REGISTER_HOLDING: + data = m_rhr; + break; + + case REGISTER_STATUS: + data = m_sr; + break; + + case REGISTER_MODE: + break; + + case REGISTER_COMMAND: + data = m_cr; + break; + } + + return data; +} + + +//------------------------------------------------- +// write - transmitter buffer register write +//------------------------------------------------- + +WRITE8_MEMBER( scn2661_device::write ) +{ + switch (offset & 0x03) + { + case REGISTER_HOLDING: + m_thr = data; + break; + + case REGISTER_SYNC: + break; + + case REGISTER_MODE: + break; + + case REGISTER_COMMAND: + m_cr = data; + break; + } +} + + +//------------------------------------------------- +// rxc_w - receiver clock +//------------------------------------------------- + +WRITE_LINE_MEMBER( scn2661_device::rxc_w ) +{ +} + + +//------------------------------------------------- +// txc_w - transmitter clock +//------------------------------------------------- + +WRITE_LINE_MEMBER( scn2661_device::txc_w ) +{ +} + + +//------------------------------------------------- +// dsr_w - data set ready +//------------------------------------------------- + +WRITE_LINE_MEMBER( scn2661_device::dsr_w ) +{ +} + + +//------------------------------------------------- +// dcd_w - data carrier detect +//------------------------------------------------- + +WRITE_LINE_MEMBER( scn2661_device::dcd_w ) +{ +} + + +//------------------------------------------------- +// cts_w - clear to send +//------------------------------------------------- + +WRITE_LINE_MEMBER( scn2661_device::cts_w ) +{ +} + + +//------------------------------------------------- +// rxrdy_r - receiver ready +//------------------------------------------------- + +READ_LINE_MEMBER( scn2661_device::rxrdy_r ) +{ + return CLEAR_LINE; +} + + +//------------------------------------------------- +// txemt_r - transmitter empty +//------------------------------------------------- + +READ_LINE_MEMBER( scn2661_device::txemt_r ) +{ + return CLEAR_LINE; +} diff --git a/src/emu/machine/scn2661.h b/src/emu/machine/scn2661.h new file mode 100644 index 00000000000..e0ad34aab6a --- /dev/null +++ b/src/emu/machine/scn2661.h @@ -0,0 +1,152 @@ +/*************************************************************************** + + Philips SCN2661 Enhanced Programmable Communications Interface emulation + + Copyright the MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**************************************************************************** + _____ _____ + D2 1 |* \_/ | 28 D1 + D3 2 | | 27 D0 + RxD 3 | | 26 Vcc + GND 4 | | 25 _RxC/BKDET + D4 5 | | 24 _DTR + D5 6 | | 23 _RTS + D6 7 | SCN2661 | 22 _DSR + D7 8 | | 21 RESET + _TxC/XSYNC 9 | | 20 BRCLK + A1 10 | | 19 TxD + _CE 11 | | 18 _TxEMT/DSCHG + A0 12 | | 17 _CTS + _R/W 13 | | 16 _DCD + _RxRDY 14 |_____________| 15 _TxRDY + +***************************************************************************/ + +#pragma once + +#ifndef __SCN2661__ +#define __SCN2661__ + +#include "emu.h" + + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_SCN2661_ADD(_tag, _clock, _config) \ + MCFG_DEVICE_ADD(_tag, SCN2661, _clock) \ + MCFG_DEVICE_CONFIG(_config) + + +#define SCN2661_INTERFACE(_name) \ + const scn2661_interface (_name) = + + + +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +// ======================> scn2661_interface + +struct scn2661_interface +{ + int m_rxc; + int m_txc; + + devcb_read_line m_in_rxd_cb; + devcb_write_line m_out_txd_cb; + + devcb_write_line m_out_rxrdy_cb; + devcb_write_line m_out_txrdy_cb; + devcb_write_line m_out_rts_cb; + devcb_write_line m_out_dtr_cb; + devcb_write_line m_out_txemt_dschg_cb; + devcb_write_line m_out_bkdet_cb; + devcb_write_line m_out_xsync_cb; +}; + + +// ======================> scn2661_device + +class scn2661_device : public device_t, + public device_serial_interface, + public scn2661_interface +{ +public: + // construction/destruction + scn2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + + DECLARE_WRITE_LINE_MEMBER( rxc_w ); + DECLARE_WRITE_LINE_MEMBER( txc_w ); + + DECLARE_WRITE_LINE_MEMBER( dsr_w ); + DECLARE_WRITE_LINE_MEMBER( dcd_w ); + DECLARE_WRITE_LINE_MEMBER( cts_w ); + + DECLARE_READ_LINE_MEMBER( rxrdy_r ); + DECLARE_READ_LINE_MEMBER( txemt_r ); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + + // device_serial_interface overrides + virtual void input_callback(UINT8 state); + +private: + inline void receive(); + inline void transmit(); + + enum + { + TIMER_RX, + TIMER_TX + }; + + devcb_resolved_read_line m_in_rxd_func; + devcb_resolved_write_line m_out_txd_func; + + devcb_resolved_write_line m_out_rxrdy_func; + devcb_resolved_write_line m_out_txrdy_func; + devcb_resolved_write_line m_out_rts_func; + devcb_resolved_write_line m_out_dtr_func; + devcb_resolved_write_line m_out_txemt_dschg_func; + devcb_resolved_write_line m_out_bkdet_func; + devcb_resolved_write_line m_out_xsync_func; + + UINT8 m_rhr; + UINT8 m_thr; + UINT8 m_cr; + UINT8 m_sr; + UINT8 m_mr1; + UINT8 m_mr2; + UINT8 m_syn1; + UINT8 m_syn2; + UINT8 m_dle; + + int m_mr_index; + int m_sync_index; + + // timers + emu_timer *m_rx_timer; + emu_timer *m_tx_timer; +}; + + +// device type definition +extern const device_type SCN2661; + + + +#endif