Previous 199869 Revisions Next

r29538 Friday 11th April, 2014 at 16:40:07 UTC by Osso
kbdc8042_device: converted to devcb2 (nw)
[src/emu/machine]8042kbdc.c 8042kbdc.h
[src/mame/machine]pcshare.c
[src/mess/drivers]bebox.c ip22.c

trunk/src/emu/machine/8042kbdc.c
r29537r29538
197197kbdc8042_device::kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
198198   : device_t(mconfig, KBDC8042, "Keyboard Controller 8042", tag, owner, clock, "kbdc8042", __FILE__)
199199   , m_keyboard_dev(*this, "at_keyboard")
200   , m_system_reset_cb(*this)
201   , m_gate_a20_cb(*this)
202   , m_input_buffer_full_cb(*this)
203   , m_output_buffer_empty_cb(*this)
204   , m_speaker_cb(*this)
200205{
201206}
202207
r29537r29538
209214   return MACHINE_CONFIG_NAME( keyboard );
210215}
211216
212//-------------------------------------------------
213//  device_config_complete - perform any
214//  operations now that the configuration is
215//  complete
216//-------------------------------------------------
217
218void kbdc8042_device::device_config_complete()
219{
220   // inherit a copy of the static data
221   const kbdc8042_interface *intf = reinterpret_cast<const kbdc8042_interface *>(static_config());
222
223   if (intf != NULL)
224   {
225      *static_cast<kbdc8042_interface *>(this) = *intf;
226   }
227
228   // or initialize to defaults if none provided
229   else
230   {
231      memset(&m_system_reset_cb, 0, sizeof(m_system_reset_cb));
232      memset(&m_gate_a20_cb, 0, sizeof(m_gate_a20_cb));
233      memset(&m_input_buffer_full_func, 0, sizeof(m_input_buffer_full_func));
234      memset(&m_output_buffer_empty_cb, 0, sizeof(m_output_buffer_empty_cb));
235      memset(&m_speaker_cb, 0, sizeof(m_speaker_cb));
236   }
237}
238
239217/*-------------------------------------------------
240218    device_start - device-specific startup
241219-------------------------------------------------*/
r29537r29538
243221void kbdc8042_device::device_start()
244222{
245223   // resolve callbacks
246   m_system_reset_func.resolve(m_system_reset_cb, *this);
247   m_gate_a20_func.resolve(m_gate_a20_cb, *this);
248   m_input_buffer_full_func.resolve(m_input_buffer_full_cb, *this);
249   m_output_buffer_empty_func.resolve(m_output_buffer_empty_cb, *this);
250   m_speaker_func.resolve(m_speaker_cb, *this);
224   m_system_reset_cb.resolve_safe();
225   m_gate_a20_cb.resolve();
226   m_input_buffer_full_cb.resolve();
227   m_output_buffer_empty_cb.resolve_safe();
228   m_speaker_cb.resolve();
251229   m_operation_write_state = 0; /* first write to 0x60 might occur before anything can set this */
252230}
253231
r29537r29538
271249   m_outport = data;
272250   if (change & 0x02)
273251   {
274      if (!m_gate_a20_func.isnull())
275         m_gate_a20_func(data & 0x02 ? 1 : 0);
252      if (!m_gate_a20_cb.isnull())
253         m_gate_a20_cb(data & 0x02 ? 1 : 0);
276254   }
277255}
278256
r29537r29538
286264{
287265   /* Lets 8952's timers do their job before clear the interrupt line, */
288266   /* else Keyboard interrupt never happens. */
289   m_input_buffer_full_func(0);
267   m_input_buffer_full_cb(0);
290268}
291269
292270void kbdc8042_device::at_8042_receive(UINT8 data)
r29537r29538
297275   m_data = data;
298276   m_keyboard.received = 1;
299277
300   if (!m_input_buffer_full_func.isnull())
278   if (!m_input_buffer_full_cb.isnull())
301279   {
302      m_input_buffer_full_func(1);
280      m_input_buffer_full_cb(1);
303281      /* Lets 8952's timers do their job before clear the interrupt line, */
304282      /* else Keyboard interrupt never happens. */
305283      machine().scheduler().timer_set(attotime::from_usec(2), timer_expired_delegate(FUNC(kbdc8042_device::kbdc8042_clr_int),this));
r29537r29538
515493
516494   case 1:
517495      m_speaker = data;
518      if (!m_speaker_func.isnull())
519               m_speaker_func(0, m_speaker);
496      if (!m_speaker_cb.isnull())
497               m_speaker_cb((offs_t)0, m_speaker);
520498
521499      break;
522500
r29537r29538
617595          * the bits low set in the command byte.  The only pulse that has
618596          * an effect currently is bit 0, which pulses the CPU's reset line
619597          */
620         m_system_reset_func(PULSE_LINE);
598         m_system_reset_cb(PULSE_LINE);
621599         at_8042_set_outport(m_outport | 0x02, 0);
622600         break;
623601      }
trunk/src/emu/machine/8042kbdc.h
r29537r29538
2424//  INTERFACE CONFIGURATION MACROS
2525//**************************************************************************
2626
27#define MCFG_KBDC8042_ADD(_tag, _interface) \
28   MCFG_DEVICE_ADD(_tag, KBDC8042, 0) \
29   MCFG_DEVICE_CONFIG(_interface)
27#define MCFG_KBDC8042_KEYBOARD_TYPE(_kbdt) \
28   kbdc8042_device::set_keyboard_type(*device, _kbdt);
3029
30#define MCFG_KBDC8042_SYSTEM_RESET_CB(_devcb) \
31   devcb = &kbdc8042_device::set_system_reset_callback(*device, DEVCB2_##_devcb);
3132
33#define MCFG_KBDC8042_GATE_A20_CB(_devcb) \
34   devcb = &kbdc8042_device::set_gate_a20_callback(*device, DEVCB2_##_devcb);
35
36#define MCFG_KBDC8042_INPUT_BUFFER_FULL_CB(_devcb) \
37   devcb = &kbdc8042_device::set_input_buffer_full_callback(*device, DEVCB2_##_devcb);
38
39#define MCFG_KBDC8042_OUTPUT_BUFFER_EMPTY_CB(_devcb) \
40   devcb = &kbdc8042_device::set_output_buffer_empty_callback(*device, DEVCB2_##_devcb);
41
42#define MCFG_KBDC8042_SPEAKER_CB(_devcb) \
43    devcb = &kbdc8042_device::set_speaker_callback(*device, DEVCB2_##_devcb);
44
3245//**************************************************************************
3346//  TYPE DEFINITIONS
3447//**************************************************************************
3548
36// ======================> kbdc8042_interface
37
38struct kbdc8042_interface
39{
40   kbdc8042_type_t     m_keybtype;
41   // interface to the host pc
42   devcb_write_line    m_system_reset_cb;
43   devcb_write_line    m_gate_a20_cb;
44   devcb_write_line    m_input_buffer_full_cb;
45   devcb_write_line    m_output_buffer_empty_cb;
46
47   devcb_write8        m_speaker_cb;
48};
49
5049// ======================> kbdc8042_device
5150
52class kbdc8042_device : public device_t,
53                  public kbdc8042_interface
51class kbdc8042_device : public device_t
5452{
5553public:
5654   // construction/destruction
5755   kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5856
5957   virtual machine_config_constructor device_mconfig_additions() const;
58   
59   static void set_keyboard_type(device_t &device, kbdc8042_type_t keybtype) { downcast<kbdc8042_device &>(device).m_keybtype = keybtype; }
60   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); }
61   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); }
62   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); }
63   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); }
64   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); }
6065
6166   DECLARE_READ8_MEMBER( data_r );
6267   DECLARE_WRITE8_MEMBER( data_w );
r29537r29538
7479   // device-level overrides
7580   virtual void device_start();
7681   virtual void device_reset();
77   virtual void device_config_complete();
7882
7983   UINT8 m_inport, m_outport, m_data, m_command;
8084
r29537r29538
104108
105109   required_device<at_keyboard_device> m_keyboard_dev;
106110
107   devcb_resolved_write_line   m_system_reset_func;
108   devcb_resolved_write_line   m_gate_a20_func;
109   devcb_resolved_write_line   m_input_buffer_full_func;
110   devcb_resolved_write_line   m_output_buffer_empty_func;
111   kbdc8042_type_t     m_keybtype;
112   
113   devcb2_write_line    m_system_reset_cb;
114   devcb2_write_line    m_gate_a20_cb;
115   devcb2_write_line    m_input_buffer_full_cb;
116   devcb2_write_line    m_output_buffer_empty_cb;
111117
112   devcb_resolved_write8       m_speaker_func;
118   devcb2_write8        m_speaker_cb;
113119};
114120
115121// device type definition
trunk/src/mess/drivers/ip22.c
r29537r29538
14881488   machine().device<nvram_device>("nvram")->set_base(m_RTC.nRAM, 0x200);
14891489}
14901490
1491static const struct kbdc8042_interface at8042 =
1492{
1493   KBDC8042_STANDARD,
1494   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_RESET),
1495   DEVCB_NULL,
1496   DEVCB_NULL,
1497   DEVCB_NULL,
1498
1499   DEVCB_NULL
1500};
1501
15021491DRIVER_INIT_MEMBER(ip22_state,ip225015)
15031492{
15041493   // IP22 uses 2 pieces of PC-compatible hardware: the 8042 PS/2 keyboard/mouse
r29537r29538
16431632   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "^^^lspeaker", 1.0)
16441633   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "^^^rspeaker", 1.0)
16451634
1646   MCFG_KBDC8042_ADD("kbdc", at8042)
1635   MCFG_DEVICE_ADD("kbdc", KBDC8042, 0)
1636   MCFG_KBDC8042_KEYBOARD_TYPE(KBDC8042_STANDARD)
1637   MCFG_KBDC8042_SYSTEM_RESET_CB(INPUTLINE("maincpu", INPUT_LINE_RESET))
16471638MACHINE_CONFIG_END
16481639
16491640static MACHINE_CONFIG_DERIVED( ip224613, ip225015 )
trunk/src/mess/drivers/bebox.c
r29537r29538
2121#include "bus/pci/pci.h"
2222#include "machine/am9517a.h"
2323#include "machine/pckeybrd.h"
24#include "machine/8042kbdc.h"
2524#include "machine/idectrl.h"
2625#include "bus/pci/mpc105.h"
2726#include "machine/intelfsh.h"
r29537r29538
155154   m_pic8259_1->ir1_w(state);
156155}
157156
158static const struct kbdc8042_interface bebox_8042_interface =
159{
160   KBDC8042_STANDARD,
161   DEVCB_CPU_INPUT_LINE("ppc1", INPUT_LINE_RESET),
162   DEVCB_NULL,
163   DEVCB_DRIVER_LINE_MEMBER(bebox_state,bebox_keyboard_interrupt),
164   DEVCB_NULL,
165
166   DEVCB_NULL
167};
168
169157static SLOT_INTERFACE_START( pci_devices )
170158   SLOT_INTERFACE_INTERNAL("mpc105", MPC105)
171159   SLOT_INTERFACE("cirrus", CIRRUS)
r29537r29538
235223
236224   MCFG_MC146818_ADD( "rtc", XTAL_32_768kHz )
237225
238   MCFG_KBDC8042_ADD("kbdc", bebox_8042_interface)
226   MCFG_DEVICE_ADD("kbdc", KBDC8042, 0)
227   MCFG_KBDC8042_KEYBOARD_TYPE(KBDC8042_STANDARD)
228   MCFG_KBDC8042_SYSTEM_RESET_CB(INPUTLINE("ppc1", INPUT_LINE_RESET))
229   MCFG_KBDC8042_INPUT_BUFFER_FULL_CB(WRITELINE(bebox_state, bebox_keyboard_interrupt))
230   
239231   /* internal ram */
240232   MCFG_RAM_ADD(RAM_TAG)
241233   MCFG_RAM_DEFAULT_SIZE("32M")
trunk/src/mame/machine/pcshare.c
r29537r29538
164164   m_kbdc->write_out2(state);
165165}
166166
167/*************************************************************
168 *
169 * Keyboard
170 *
171 *************************************************************/
172167
173static const struct kbdc8042_interface at8042 =
174{
175   KBDC8042_AT386,
176   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_RESET),
177   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_A20),
178   DEVCB_DEVICE_LINE_MEMBER("pic8259_1", pic8259_device, ir1_w),
179   DEVCB_NULL,
180
181   DEVCB_NULL
182};
183
184ADDRESS_MAP_START( pcat32_io_common, AS_IO, 32, pcat_base_state )
168 ADDRESS_MAP_START( pcat32_io_common, AS_IO, 32, pcat_base_state )
185169   AM_RANGE(0x0000, 0x001f) AM_DEVREADWRITE8("dma8237_1", am9517a_device, read, write, 0xffffffff)
186170   AM_RANGE(0x0020, 0x003f) AM_DEVREADWRITE8("pic8259_1", pic8259_device, read, write, 0xffffffff)
187171   AM_RANGE(0x0040, 0x005f) AM_DEVREADWRITE8("pit8254", pit8254_device, read, write, 0xffffffff)
r29537r29538
209193   MCFG_MC146818_IRQ_HANDLER(DEVWRITELINE("pic8259_2", pic8259_device, ir0_w))
210194   MCFG_MC146818_CENTURY_INDEX(0x32)
211195
212   MCFG_KBDC8042_ADD("kbdc", at8042)
196   MCFG_DEVICE_ADD("kbdc", KBDC8042, 0)
197   MCFG_KBDC8042_KEYBOARD_TYPE(KBDC8042_AT386)
198   MCFG_KBDC8042_SYSTEM_RESET_CB(INPUTLINE("maincpu", INPUT_LINE_RESET))
199   MCFG_KBDC8042_GATE_A20_CB(INPUTLINE("maincpu", INPUT_LINE_A20))
200   MCFG_KBDC8042_INPUT_BUFFER_FULL_CB(DEVWRITELINE("pic8259_1", pic8259_device, ir1_w))
213201MACHINE_CONFIG_END

Previous 199869 Revisions Next


© 1997-2024 The MAME Team