Previous 15994 Revisions Next

r14104 Friday 20th January, 2012 at 09:20:48 UTC by Curt Coder
[WANGPC] Added bus interface. (nw)
[src/mess]mess.mak
[src/mess/drivers]wangpc.c
[src/mess/includes]wangpc.h
[src/mess/machine]wangpcbus.c* wangpcbus.h*

src/mess/machine/wangpcbus.c
r0r14104
1/**********************************************************************
2 
3    Wang Professional Computer bus emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10#include "emu.h"
11#include "emuopts.h"
12#include "machine/wangpcbus.h"
13 
14 
15//**************************************************************************
16//  GLOBAL VARIABLES
17//**************************************************************************
18 
19const device_type WANGPC_BUS_SLOT = &device_creator<wangpcbus_slot_device>;
20 
21 
22 
23//**************************************************************************
24//  LIVE DEVICE
25//**************************************************************************
26 
27//-------------------------------------------------
28//  wangpcbus_slot_device - constructor
29//-------------------------------------------------
30 
31wangpcbus_slot_device::wangpcbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
32        device_t(mconfig, WANGPC_BUS_SLOT, "Wang PC bus slot", tag, owner, clock),
33      device_slot_interface(mconfig, *this)
34{
35}
36 
37void wangpcbus_slot_device::static_set_wangpcbus_slot(device_t &device, int sid)
38{
39   wangpcbus_slot_device &wangpcbus_card = dynamic_cast<wangpcbus_slot_device &>(device);
40   wangpcbus_card.m_sid = sid;
41}
42 
43 
44//-------------------------------------------------
45//  device_start - device-specific startup
46//-------------------------------------------------
47 
48void wangpcbus_slot_device::device_start()
49{
50   m_bus = machine().device<wangpcbus_device>(WANGPC_BUS_TAG);
51   device_wangpcbus_card_interface *dev = dynamic_cast<device_wangpcbus_card_interface *>(get_card_device());
52   if (dev) m_bus->add_wangpcbus_card(dev);
53}
54 
55 
56 
57//**************************************************************************
58//  GLOBAL VARIABLES
59//**************************************************************************
60 
61const device_type WANGPC_BUS = &device_creator<wangpcbus_device>;
62 
63 
64//-------------------------------------------------
65//  device_config_complete - perform any
66//  operations now that the configuration is
67//  complete
68//-------------------------------------------------
69 
70void wangpcbus_device::device_config_complete()
71{
72   // inherit a copy of the static data
73   const wangpcbus_interface *intf = reinterpret_cast<const wangpcbus_interface *>(static_config());
74   if (intf != NULL)
75   {
76      *static_cast<wangpcbus_interface *>(this) = *intf;
77   }
78 
79   // or initialize to defaults if none provided
80   else
81   {
82       memset(&m_out_irq2_cb, 0, sizeof(m_out_irq2_cb));
83       memset(&m_out_irq3_cb, 0, sizeof(m_out_irq3_cb));
84       memset(&m_out_irq4_cb, 0, sizeof(m_out_irq4_cb));
85       memset(&m_out_irq5_cb, 0, sizeof(m_out_irq5_cb));
86       memset(&m_out_irq6_cb, 0, sizeof(m_out_irq6_cb));
87       memset(&m_out_irq7_cb, 0, sizeof(m_out_irq7_cb));
88       memset(&m_out_drq1_cb, 0, sizeof(m_out_drq1_cb));
89       memset(&m_out_drq2_cb, 0, sizeof(m_out_drq2_cb));
90       memset(&m_out_drq3_cb, 0, sizeof(m_out_drq3_cb));
91       memset(&m_out_ioerror_cb, 0, sizeof(m_out_ioerror_cb));
92   }
93}
94 
95 
96 
97//**************************************************************************
98//  LIVE DEVICE
99//**************************************************************************
100 
101//-------------------------------------------------
102//  wangpcbus_device - constructor
103//-------------------------------------------------
104 
105wangpcbus_device::wangpcbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
106        device_t(mconfig, WANGPC_BUS, "Wang PC bus", tag, owner, clock)
107{
108}
109 
110 
111//-------------------------------------------------
112//  device_start - device-specific startup
113//-------------------------------------------------
114 
115void wangpcbus_device::device_start()
116{
117   // resolve callbacks
118   m_out_irq2_func.resolve(m_out_irq2_cb, *this);
119   m_out_irq3_func.resolve(m_out_irq3_cb, *this);
120   m_out_irq4_func.resolve(m_out_irq4_cb, *this);
121   m_out_irq5_func.resolve(m_out_irq5_cb, *this);
122   m_out_irq6_func.resolve(m_out_irq6_cb, *this);
123   m_out_irq7_func.resolve(m_out_irq7_cb, *this);
124   m_out_drq1_func.resolve(m_out_drq1_cb, *this);
125   m_out_drq2_func.resolve(m_out_drq2_cb, *this);
126   m_out_drq3_func.resolve(m_out_drq3_cb, *this);
127   m_out_ioerror_func.resolve(m_out_ioerror_cb, *this);
128}
129 
130 
131//-------------------------------------------------
132//  device_reset - device-specific reset
133//-------------------------------------------------
134 
135void wangpcbus_device::device_reset()
136{
137}
138 
139 
140//-------------------------------------------------
141//  add_wangpcbus_card - add S100 card
142//-------------------------------------------------
143 
144void wangpcbus_device::add_wangpcbus_card(device_wangpcbus_card_interface *card)
145{
146   m_device_list.append(*card);
147}
148 
149 
150//-------------------------------------------------
151//  mrdc_r - memory read
152//-------------------------------------------------
153 
154READ8_MEMBER( wangpcbus_device::mrdc_r )
155{
156   UINT8 data = 0;
157 
158   device_wangpcbus_card_interface *entry = m_device_list.first();
159 
160   while (entry)
161   {
162      data |= entry->wangpcbus_mrdc_r(offset);
163      entry = entry->next();
164   }
165 
166   return data;
167}
168 
169 
170//-------------------------------------------------
171//  amwc_w - memory write
172//-------------------------------------------------
173 
174WRITE8_MEMBER( wangpcbus_device::amwc_w )
175{
176   device_wangpcbus_card_interface *entry = m_device_list.first();
177 
178   while (entry)
179   {
180      entry->wangpcbus_amwc_w(offset, data);
181      entry = entry->next();
182   }
183}
184 
185 
186//-------------------------------------------------
187//  iorc_r - I/O read
188//-------------------------------------------------
189 
190READ8_MEMBER( wangpcbus_device::iorc_r )
191{
192   UINT8 data = 0;
193 
194   device_wangpcbus_card_interface *entry = m_device_list.first();
195 
196   while (entry)
197   {
198      data |= entry->wangpcbus_iorc_r(offset);
199      entry = entry->next();
200   }
201 
202   return data;
203}
204 
205 
206//-------------------------------------------------
207//  aiowc_w - I/O write
208//-------------------------------------------------
209 
210WRITE8_MEMBER( wangpcbus_device::aiowc_w )
211{
212   device_wangpcbus_card_interface *entry = m_device_list.first();
213 
214   while (entry)
215   {
216      entry->wangpcbus_aiowc_w(offset, data);
217      entry = entry->next();
218   }
219}
220 
221 
222WRITE_LINE_MEMBER( wangpcbus_device::irq2_w ) { m_out_irq2_func(state); }
223WRITE_LINE_MEMBER( wangpcbus_device::irq3_w ) { m_out_irq3_func(state); }
224WRITE_LINE_MEMBER( wangpcbus_device::irq4_w ) { m_out_irq4_func(state); }
225WRITE_LINE_MEMBER( wangpcbus_device::irq5_w ) { m_out_irq5_func(state); }
226WRITE_LINE_MEMBER( wangpcbus_device::irq6_w ) { m_out_irq6_func(state); }
227WRITE_LINE_MEMBER( wangpcbus_device::irq7_w ) { m_out_irq7_func(state); }
228WRITE_LINE_MEMBER( wangpcbus_device::drq1_w ) { m_out_drq1_func(state); }
229WRITE_LINE_MEMBER( wangpcbus_device::drq2_w ) { m_out_drq2_func(state); }
230WRITE_LINE_MEMBER( wangpcbus_device::drq3_w ) { m_out_drq3_func(state); }
231WRITE_LINE_MEMBER( wangpcbus_device::ioerror_w ) { m_out_ioerror_func(state); }
232 
233 
234//-------------------------------------------------
235//  dack_r - DMA read
236//-------------------------------------------------
237 
238UINT8 wangpcbus_device::dack_r(int line)
239{
240   UINT8 retVal = 0xff;
241   device_wangpcbus_card_interface *entry = m_device_list.first();
242   
243   while (entry)
244   {
245      if (entry->wangpcbus_have_dack(line)) 
246      {
247         retVal = entry->wangpcbus_dack_r(line);
248         break;
249      }
250       
251      entry = entry->next();
252   }
253   
254   return retVal;
255}
256 
257 
258//-------------------------------------------------
259//  dack_w - DMA write
260//-------------------------------------------------
261 
262void wangpcbus_device::dack_w(int line,UINT8 data)
263{
264   device_wangpcbus_card_interface *entry = m_device_list.first();
265   
266   while (entry)
267   {
268      if (entry->wangpcbus_have_dack(line))
269      {
270         entry->wangpcbus_dack_w(line,data);
271      }
272       
273      entry = entry->next();
274   }
275}
276 
277 
278//-------------------------------------------------
279//  tc_w - terminal count
280//-------------------------------------------------
281 
282void wangpcbus_device::tc_w(int state)
283{
284   device_wangpcbus_card_interface *entry = m_device_list.first();
285   
286   while (entry)
287   {
288      entry->wangpcbus_tc_w(state);
289      entry = entry->next();
290   }
291}
292 
293 
294//**************************************************************************
295//  DEVICE S100 CARD INTERFACE
296//**************************************************************************
297 
298//-------------------------------------------------
299//  device_wangpcbus_card_interface - constructor
300//-------------------------------------------------
301 
302device_wangpcbus_card_interface::device_wangpcbus_card_interface(const machine_config &mconfig, device_t &device)
303   : device_slot_card_interface(mconfig, device)
304{
305}
306 
307 
308//-------------------------------------------------
309//  ~device_wangpcbus_card_interface - destructor
310//-------------------------------------------------
311 
312device_wangpcbus_card_interface::~device_wangpcbus_card_interface()
313{
314}
src/mess/machine/wangpcbus.h
r0r14104
1/**********************************************************************
2 
3    Wang Professional Computer bus emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************
9 
10 
11**********************************************************************/
12 
13#pragma once
14 
15#ifndef __WANGPC_BUS__
16#define __WANGPC_BUS__
17 
18#include "emu.h"
19 
20 
21 
22//**************************************************************************
23//  CONSTANTS
24//**************************************************************************
25 
26#define WANGPC_BUS_TAG      "wangpcbus"
27 
28 
29 
30//**************************************************************************
31//  INTERFACE CONFIGURATION MACROS
32//**************************************************************************
33 
34#define MCFG_WANGPC_BUS_ADD(_config) \
35    MCFG_DEVICE_ADD(WANGPC_BUS_TAG, WANGPC_BUS, 0) \
36    MCFG_DEVICE_CONFIG(_config)
37 
38 
39#define WANGPC_BUS_INTERFACE(_name) \
40   const wangpcbus_interface (_name) =
41 
42 
43#define MCFG_WANGPC_BUS_SLOT_ADD(_tag, _sid, _slot_intf, _def_slot, _def_inp) \
44    MCFG_DEVICE_ADD(_tag, WANGPC_BUS_SLOT, 0) \
45   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp) \
46   wangpcbus_slot_device::static_set_wangpcbus_slot(*device, _sid);
47 
48 
49 
50//**************************************************************************
51//  TYPE DEFINITIONS
52//**************************************************************************
53 
54// ======================> wangpcbus_slot_device
55 
56class wangpcbus_device;
57 
58class wangpcbus_slot_device : public device_t,
59                       public device_slot_interface
60{
61public:
62   // construction/destruction
63   wangpcbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
64 
65   // device-level overrides
66   virtual void device_start();
67 
68    // inline configuration
69    static void static_set_wangpcbus_slot(device_t &device, int sid);
70 
71private:
72   // configuration
73   wangpcbus_device  *m_bus;
74   int m_sid;
75};
76 
77 
78// device type definition
79extern const device_type WANGPC_BUS_SLOT;
80 
81 
82// ======================> wangpcbus_interface
83 
84struct wangpcbus_interface
85{
86    devcb_write_line   m_out_irq2_cb;
87    devcb_write_line   m_out_irq3_cb;
88    devcb_write_line   m_out_irq4_cb;
89    devcb_write_line   m_out_irq5_cb;
90    devcb_write_line   m_out_irq6_cb;
91    devcb_write_line   m_out_irq7_cb;
92    devcb_write_line   m_out_drq1_cb;
93    devcb_write_line   m_out_drq2_cb;
94    devcb_write_line   m_out_drq3_cb;
95    devcb_write_line   m_out_ioerror_cb;
96};
97 
98class device_wangpcbus_card_interface;
99 
100 
101// ======================> wangpcbus_device
102 
103class wangpcbus_device : public device_t,
104                   public wangpcbus_interface
105{
106public:
107   // construction/destruction
108   wangpcbus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
109 
110   void add_wangpcbus_card(device_wangpcbus_card_interface *card);
111 
112   DECLARE_READ8_MEMBER( mrdc_r );
113   DECLARE_WRITE8_MEMBER( amwc_w );
114 
115   DECLARE_READ8_MEMBER( iorc_r );
116   DECLARE_WRITE8_MEMBER( aiowc_w );
117 
118   DECLARE_WRITE_LINE_MEMBER( irq2_w );
119   DECLARE_WRITE_LINE_MEMBER( irq3_w );
120   DECLARE_WRITE_LINE_MEMBER( irq4_w );
121   DECLARE_WRITE_LINE_MEMBER( irq5_w );
122   DECLARE_WRITE_LINE_MEMBER( irq6_w );
123   DECLARE_WRITE_LINE_MEMBER( irq7_w );
124   DECLARE_WRITE_LINE_MEMBER( drq1_w );
125   DECLARE_WRITE_LINE_MEMBER( drq2_w );
126   DECLARE_WRITE_LINE_MEMBER( drq3_w );
127   DECLARE_WRITE_LINE_MEMBER( ioerror_w );
128 
129   UINT8 dack_r(int line);
130   void dack_w(int line, UINT8 data);
131   void tc_w(int state);
132 
133protected:
134   // device-level overrides
135   virtual void device_start();
136   virtual void device_reset();
137   virtual void device_config_complete();
138 
139private:
140   devcb_resolved_write_line   m_out_irq2_func;
141   devcb_resolved_write_line   m_out_irq3_func;
142   devcb_resolved_write_line   m_out_irq4_func;
143   devcb_resolved_write_line   m_out_irq5_func;
144   devcb_resolved_write_line   m_out_irq6_func;
145   devcb_resolved_write_line   m_out_irq7_func;
146   devcb_resolved_write_line   m_out_drq1_func;
147   devcb_resolved_write_line   m_out_drq2_func;
148   devcb_resolved_write_line   m_out_drq3_func;
149   devcb_resolved_write_line   m_out_ioerror_func;
150 
151   simple_list<device_wangpcbus_card_interface> m_device_list;
152};
153 
154 
155// device type definition
156extern const device_type WANGPC_BUS;
157 
158 
159// ======================> device_wangpcbus_card_interface
160 
161// class representing interface-specific live wangpcbus card
162class device_wangpcbus_card_interface : public device_slot_card_interface
163{
164   friend class wangpcbus_device;
165 
166public:
167   // construction/destruction
168   device_wangpcbus_card_interface(const machine_config &mconfig, device_t &device);
169   virtual ~device_wangpcbus_card_interface();
170 
171   device_wangpcbus_card_interface *next() const { return m_next; }
172 
173   // memory access
174   virtual UINT8 wangpcbus_mrdc_r(offs_t offset) { return 0; };
175   virtual void wangpcbus_amwc_w(offs_t offset, UINT8 data) { };
176 
177   // I/O access
178   virtual UINT8 wangpcbus_iorc_r(offs_t offset) { return 0; };
179   virtual void wangpcbus_aiowc_w(offs_t offset, UINT8 data) { };
180 
181   // DMA
182   virtual UINT8 wangpcbus_dack_r(int line) { return 0; }
183   virtual void wangpcbus_dack_w(int line, UINT8 data) { }
184   virtual void wangpcbus_tc_w(int state) { }
185   virtual bool wangpcbus_have_dack(int line) { return false; }
186 
187public:
188   wangpcbus_device  *m_wangpcbus;
189   device_wangpcbus_card_interface *m_next;
190};
191 
192#endif
src/mess/includes/wangpc.h
r14103r14104
1313#include "machine/pit8253.h"
1414#include "machine/ram.h"
1515#include "machine/upd765.h"
16#include "machine/wangpcbus.h"
1617#include "machine/wangpckb.h"
1718 
1819#define I8086_TAG      "i8086"
src/mess/mess.mak
r14103r14104
17181718
17191719$(MESSOBJ)/wang.a:            \
17201720   $(MESS_DRIVERS)/wangpc.o   \
1721   $(MESS_MACHINE)/wangpcbus.o   \
17211722   $(MESS_MACHINE)/wangpckb.o   \
17221723
17231724$(MESSOBJ)/wavemate.a:         \
src/mess/drivers/wangpc.c
r14103r14104
539539};
540540 
541541 
542//-------------------------------------------------
543//  WANGPC_BUS_INTERFACE( kb_intf )
544//-------------------------------------------------
542545 
546static WANGPC_BUS_INTERFACE( bus_intf )
547{
548   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir2_w),
549   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir3_w),
550   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir4_w),
551   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir5_w),
552   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir6_w),
553   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir7_w),
554   DEVCB_DEVICE_LINE(AM9517A_TAG, i8237_dreq1_w),
555   DEVCB_DEVICE_LINE(AM9517A_TAG, i8237_dreq2_w),
556   DEVCB_DEVICE_LINE(AM9517A_TAG, i8237_dreq3_w),
557   DEVCB_NULL
558};
559 
560static SLOT_INTERFACE_START( wangpc_cards )
561SLOT_INTERFACE_END
562 
563 
564 
543565//**************************************************************************
544566//  MACHINE INITIALIZATION
545567//**************************************************************************
r14103r14104
565587//-------------------------------------------------
566588 
567589static MACHINE_CONFIG_START( wangpc, wangpc_state )
568   MCFG_CPU_ADD(I8086_TAG, I8086, 4000000)
590   MCFG_CPU_ADD(I8086_TAG, I8086, 8000000)
569591   MCFG_CPU_PROGRAM_MAP(wangpc_mem)
570592   MCFG_CPU_IO_MAP(wangpc_io)
571593 
r14103r14104
586608   MCFG_UPD765A_ADD(UPD765_TAG, fdc_intf)
587609   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(floppy_intf)
588610   MCFG_WANGPC_KEYBOARD_ADD(kb_intf)
611   
612   // bus
613   MCFG_WANGPC_BUS_ADD(bus_intf)
614   MCFG_WANGPC_BUS_SLOT_ADD("slot1", 1, wangpc_cards, NULL, NULL)
615   MCFG_WANGPC_BUS_SLOT_ADD("slot2", 2, wangpc_cards, NULL, NULL)
616   MCFG_WANGPC_BUS_SLOT_ADD("slot3", 3, wangpc_cards, NULL, NULL)
617   MCFG_WANGPC_BUS_SLOT_ADD("slot4", 4, wangpc_cards, NULL, NULL)
618   MCFG_WANGPC_BUS_SLOT_ADD("slot5", 5, wangpc_cards, NULL, NULL)
589619 
590620   // internal ram
591621   MCFG_RAM_ADD(RAM_TAG)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team