summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ivan Vangelista <mesgnet@yahoo.it>2014-04-11 16:40:07 +0000
committer Ivan Vangelista <mesgnet@yahoo.it>2014-04-11 16:40:07 +0000
commit29225a4dbbab572f3ea1f01a77f9cd549bc52cd3 (patch)
tree9bb38db252604dcda9b45174fefd8e018053637b
parent0b4e78bc26db01773acaea541cf8ef2711de44ae (diff)
kbdc8042_device: converted to devcb2 (nw)
-rw-r--r--src/emu/machine/8042kbdc.c58
-rw-r--r--src/emu/machine/8042kbdc.h56
-rw-r--r--src/mame/machine/pcshare.c24
-rw-r--r--src/mess/drivers/bebox.c18
-rw-r--r--src/mess/drivers/ip22.c15
5 files changed, 63 insertions, 108 deletions
diff --git a/src/emu/machine/8042kbdc.c b/src/emu/machine/8042kbdc.c
index c3e1fc917c7..0d4662bd096 100644
--- a/src/emu/machine/8042kbdc.c
+++ b/src/emu/machine/8042kbdc.c
@@ -197,6 +197,11 @@ const device_type KBDC8042 = &device_creator<kbdc8042_device>;
kbdc8042_device::kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, KBDC8042, "Keyboard Controller 8042", tag, owner, clock, "kbdc8042", __FILE__)
, m_keyboard_dev(*this, "at_keyboard")
+ , m_system_reset_cb(*this)
+ , m_gate_a20_cb(*this)
+ , m_input_buffer_full_cb(*this)
+ , m_output_buffer_empty_cb(*this)
+ , m_speaker_cb(*this)
{
}
@@ -209,33 +214,6 @@ machine_config_constructor kbdc8042_device::device_mconfig_additions() const
return MACHINE_CONFIG_NAME( keyboard );
}
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void kbdc8042_device::device_config_complete()
-{
- // inherit a copy of the static data
- const kbdc8042_interface *intf = reinterpret_cast<const kbdc8042_interface *>(static_config());
-
- if (intf != NULL)
- {
- *static_cast<kbdc8042_interface *>(this) = *intf;
- }
-
- // or initialize to defaults if none provided
- else
- {
- memset(&m_system_reset_cb, 0, sizeof(m_system_reset_cb));
- memset(&m_gate_a20_cb, 0, sizeof(m_gate_a20_cb));
- memset(&m_input_buffer_full_func, 0, sizeof(m_input_buffer_full_func));
- memset(&m_output_buffer_empty_cb, 0, sizeof(m_output_buffer_empty_cb));
- memset(&m_speaker_cb, 0, sizeof(m_speaker_cb));
- }
-}
-
/*-------------------------------------------------
device_start - device-specific startup
-------------------------------------------------*/
@@ -243,11 +221,11 @@ void kbdc8042_device::device_config_complete()
void kbdc8042_device::device_start()
{
// resolve callbacks
- m_system_reset_func.resolve(m_system_reset_cb, *this);
- m_gate_a20_func.resolve(m_gate_a20_cb, *this);
- m_input_buffer_full_func.resolve(m_input_buffer_full_cb, *this);
- m_output_buffer_empty_func.resolve(m_output_buffer_empty_cb, *this);
- m_speaker_func.resolve(m_speaker_cb, *this);
+ m_system_reset_cb.resolve_safe();
+ m_gate_a20_cb.resolve();
+ m_input_buffer_full_cb.resolve();
+ m_output_buffer_empty_cb.resolve_safe();
+ m_speaker_cb.resolve();
m_operation_write_state = 0; /* first write to 0x60 might occur before anything can set this */
}
@@ -271,8 +249,8 @@ void kbdc8042_device::at_8042_set_outport(UINT8 data, int initial)
m_outport = data;
if (change & 0x02)
{
- if (!m_gate_a20_func.isnull())
- m_gate_a20_func(data & 0x02 ? 1 : 0);
+ if (!m_gate_a20_cb.isnull())
+ m_gate_a20_cb(data & 0x02 ? 1 : 0);
}
}
@@ -286,7 +264,7 @@ TIMER_CALLBACK_MEMBER( kbdc8042_device::kbdc8042_clr_int )
{
/* Lets 8952's timers do their job before clear the interrupt line, */
/* else Keyboard interrupt never happens. */
- m_input_buffer_full_func(0);
+ m_input_buffer_full_cb(0);
}
void kbdc8042_device::at_8042_receive(UINT8 data)
@@ -297,9 +275,9 @@ void kbdc8042_device::at_8042_receive(UINT8 data)
m_data = data;
m_keyboard.received = 1;
- if (!m_input_buffer_full_func.isnull())
+ if (!m_input_buffer_full_cb.isnull())
{
- m_input_buffer_full_func(1);
+ m_input_buffer_full_cb(1);
/* Lets 8952's timers do their job before clear the interrupt line, */
/* else Keyboard interrupt never happens. */
machine().scheduler().timer_set(attotime::from_usec(2), timer_expired_delegate(FUNC(kbdc8042_device::kbdc8042_clr_int),this));
@@ -515,8 +493,8 @@ WRITE8_MEMBER(kbdc8042_device::data_w)
case 1:
m_speaker = data;
- if (!m_speaker_func.isnull())
- m_speaker_func(0, m_speaker);
+ if (!m_speaker_cb.isnull())
+ m_speaker_cb((offs_t)0, m_speaker);
break;
@@ -617,7 +595,7 @@ WRITE8_MEMBER(kbdc8042_device::data_w)
* the bits low set in the command byte. The only pulse that has
* an effect currently is bit 0, which pulses the CPU's reset line
*/
- m_system_reset_func(PULSE_LINE);
+ m_system_reset_cb(PULSE_LINE);
at_8042_set_outport(m_outport | 0x02, 0);
break;
}
diff --git a/src/emu/machine/8042kbdc.h b/src/emu/machine/8042kbdc.h
index 81f2d63a323..c7e14ec1609 100644
--- a/src/emu/machine/8042kbdc.h
+++ b/src/emu/machine/8042kbdc.h
@@ -24,39 +24,44 @@ enum kbdc8042_type_t
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
-#define MCFG_KBDC8042_ADD(_tag, _interface) \
- MCFG_DEVICE_ADD(_tag, KBDC8042, 0) \
- MCFG_DEVICE_CONFIG(_interface)
+#define MCFG_KBDC8042_KEYBOARD_TYPE(_kbdt) \
+ kbdc8042_device::set_keyboard_type(*device, _kbdt);
+#define MCFG_KBDC8042_SYSTEM_RESET_CB(_devcb) \
+ devcb = &kbdc8042_device::set_system_reset_callback(*device, DEVCB2_##_devcb);
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
+#define MCFG_KBDC8042_GATE_A20_CB(_devcb) \
+ devcb = &kbdc8042_device::set_gate_a20_callback(*device, DEVCB2_##_devcb);
-// ======================> kbdc8042_interface
+#define MCFG_KBDC8042_INPUT_BUFFER_FULL_CB(_devcb) \
+ devcb = &kbdc8042_device::set_input_buffer_full_callback(*device, DEVCB2_##_devcb);
-struct kbdc8042_interface
-{
- kbdc8042_type_t m_keybtype;
- // interface to the host pc
- devcb_write_line m_system_reset_cb;
- devcb_write_line m_gate_a20_cb;
- devcb_write_line m_input_buffer_full_cb;
- devcb_write_line m_output_buffer_empty_cb;
+#define MCFG_KBDC8042_OUTPUT_BUFFER_EMPTY_CB(_devcb) \
+ devcb = &kbdc8042_device::set_output_buffer_empty_callback(*device, DEVCB2_##_devcb);
- devcb_write8 m_speaker_cb;
-};
+#define MCFG_KBDC8042_SPEAKER_CB(_devcb) \
+ devcb = &kbdc8042_device::set_speaker_callback(*device, DEVCB2_##_devcb);
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
// ======================> kbdc8042_device
-class kbdc8042_device : public device_t,
- public kbdc8042_interface
+class kbdc8042_device : public device_t
{
public:
// construction/destruction
kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual machine_config_constructor device_mconfig_additions() const;
+
+ static void set_keyboard_type(device_t &device, kbdc8042_type_t keybtype) { downcast<kbdc8042_device &>(device).m_keybtype = keybtype; }
+ template<class _Object> static devcb2_base &set_system_reset_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_system_reset_cb.set_callback(object); }
+ template<class _Object> static devcb2_base &set_gate_a20_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_gate_a20_cb.set_callback(object); }
+ template<class _Object> static devcb2_base &set_input_buffer_full_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_input_buffer_full_cb.set_callback(object); }
+ template<class _Object> static devcb2_base &set_output_buffer_empty_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_output_buffer_empty_cb.set_callback(object); }
+ template<class _Object> static devcb2_base &set_speaker_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_speaker_cb.set_callback(object); }
DECLARE_READ8_MEMBER( data_r );
DECLARE_WRITE8_MEMBER( data_w );
@@ -74,7 +79,6 @@ protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
- virtual void device_config_complete();
UINT8 m_inport, m_outport, m_data, m_command;
@@ -104,12 +108,14 @@ protected:
required_device<at_keyboard_device> m_keyboard_dev;
- devcb_resolved_write_line m_system_reset_func;
- devcb_resolved_write_line m_gate_a20_func;
- devcb_resolved_write_line m_input_buffer_full_func;
- devcb_resolved_write_line m_output_buffer_empty_func;
+ kbdc8042_type_t m_keybtype;
+
+ devcb2_write_line m_system_reset_cb;
+ devcb2_write_line m_gate_a20_cb;
+ devcb2_write_line m_input_buffer_full_cb;
+ devcb2_write_line m_output_buffer_empty_cb;
- devcb_resolved_write8 m_speaker_func;
+ devcb2_write8 m_speaker_cb;
};
// device type definition
diff --git a/src/mame/machine/pcshare.c b/src/mame/machine/pcshare.c
index 9d0c5bfd412..636889e861a 100644
--- a/src/mame/machine/pcshare.c
+++ b/src/mame/machine/pcshare.c
@@ -164,24 +164,8 @@ WRITE_LINE_MEMBER( pcat_base_state::at_pit8254_out2_changed )
m_kbdc->write_out2(state);
}
-/*************************************************************
- *
- * Keyboard
- *
- *************************************************************/
-static const struct kbdc8042_interface at8042 =
-{
- KBDC8042_AT386,
- DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_RESET),
- DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_A20),
- DEVCB_DEVICE_LINE_MEMBER("pic8259_1", pic8259_device, ir1_w),
- DEVCB_NULL,
-
- DEVCB_NULL
-};
-
-ADDRESS_MAP_START( pcat32_io_common, AS_IO, 32, pcat_base_state )
+ ADDRESS_MAP_START( pcat32_io_common, AS_IO, 32, pcat_base_state )
AM_RANGE(0x0000, 0x001f) AM_DEVREADWRITE8("dma8237_1", am9517a_device, read, write, 0xffffffff)
AM_RANGE(0x0020, 0x003f) AM_DEVREADWRITE8("pic8259_1", pic8259_device, read, write, 0xffffffff)
AM_RANGE(0x0040, 0x005f) AM_DEVREADWRITE8("pit8254", pit8254_device, read, write, 0xffffffff)
@@ -209,5 +193,9 @@ MACHINE_CONFIG_FRAGMENT(pcat_common)
MCFG_MC146818_IRQ_HANDLER(DEVWRITELINE("pic8259_2", pic8259_device, ir0_w))
MCFG_MC146818_CENTURY_INDEX(0x32)
- MCFG_KBDC8042_ADD("kbdc", at8042)
+ MCFG_DEVICE_ADD("kbdc", KBDC8042, 0)
+ MCFG_KBDC8042_KEYBOARD_TYPE(KBDC8042_AT386)
+ MCFG_KBDC8042_SYSTEM_RESET_CB(INPUTLINE("maincpu", INPUT_LINE_RESET))
+ MCFG_KBDC8042_GATE_A20_CB(INPUTLINE("maincpu", INPUT_LINE_A20))
+ MCFG_KBDC8042_INPUT_BUFFER_FULL_CB(DEVWRITELINE("pic8259_1", pic8259_device, ir1_w))
MACHINE_CONFIG_END
diff --git a/src/mess/drivers/bebox.c b/src/mess/drivers/bebox.c
index 86565c34a01..daa63ded323 100644
--- a/src/mess/drivers/bebox.c
+++ b/src/mess/drivers/bebox.c
@@ -21,7 +21,6 @@
#include "bus/pci/pci.h"
#include "machine/am9517a.h"
#include "machine/pckeybrd.h"
-#include "machine/8042kbdc.h"
#include "machine/idectrl.h"
#include "bus/pci/mpc105.h"
#include "machine/intelfsh.h"
@@ -155,17 +154,6 @@ WRITE_LINE_MEMBER(bebox_state::bebox_keyboard_interrupt)
m_pic8259_1->ir1_w(state);
}
-static const struct kbdc8042_interface bebox_8042_interface =
-{
- KBDC8042_STANDARD,
- DEVCB_CPU_INPUT_LINE("ppc1", INPUT_LINE_RESET),
- DEVCB_NULL,
- DEVCB_DRIVER_LINE_MEMBER(bebox_state,bebox_keyboard_interrupt),
- DEVCB_NULL,
-
- DEVCB_NULL
-};
-
static SLOT_INTERFACE_START( pci_devices )
SLOT_INTERFACE_INTERNAL("mpc105", MPC105)
SLOT_INTERFACE("cirrus", CIRRUS)
@@ -235,7 +223,11 @@ static MACHINE_CONFIG_START( bebox, bebox_state )
MCFG_MC146818_ADD( "rtc", XTAL_32_768kHz )
- MCFG_KBDC8042_ADD("kbdc", bebox_8042_interface)
+ MCFG_DEVICE_ADD("kbdc", KBDC8042, 0)
+ MCFG_KBDC8042_KEYBOARD_TYPE(KBDC8042_STANDARD)
+ MCFG_KBDC8042_SYSTEM_RESET_CB(INPUTLINE("ppc1", INPUT_LINE_RESET))
+ MCFG_KBDC8042_INPUT_BUFFER_FULL_CB(WRITELINE(bebox_state, bebox_keyboard_interrupt))
+
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)
MCFG_RAM_DEFAULT_SIZE("32M")
diff --git a/src/mess/drivers/ip22.c b/src/mess/drivers/ip22.c
index cadaa249d24..1d26ea90d37 100644
--- a/src/mess/drivers/ip22.c
+++ b/src/mess/drivers/ip22.c
@@ -1488,17 +1488,6 @@ void ip22_state::machine_start()
machine().device<nvram_device>("nvram")->set_base(m_RTC.nRAM, 0x200);
}
-static const struct kbdc8042_interface at8042 =
-{
- KBDC8042_STANDARD,
- DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_RESET),
- DEVCB_NULL,
- DEVCB_NULL,
- DEVCB_NULL,
-
- DEVCB_NULL
-};
-
DRIVER_INIT_MEMBER(ip22_state,ip225015)
{
// IP22 uses 2 pieces of PC-compatible hardware: the 8042 PS/2 keyboard/mouse
@@ -1643,7 +1632,9 @@ static MACHINE_CONFIG_START( ip225015, ip22_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "^^^lspeaker", 1.0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "^^^rspeaker", 1.0)
- MCFG_KBDC8042_ADD("kbdc", at8042)
+ MCFG_DEVICE_ADD("kbdc", KBDC8042, 0)
+ MCFG_KBDC8042_KEYBOARD_TYPE(KBDC8042_STANDARD)
+ MCFG_KBDC8042_SYSTEM_RESET_CB(INPUTLINE("maincpu", INPUT_LINE_RESET))
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( ip224613, ip225015 )