Previous 15994 Revisions Next

r10772 Saturday 12th March, 2011 at 17:10:53 UTC by Miodrag Milanović
- Made ISA FDC card, and connected it to generic PC driver
- Propagated DMA and PIC signals on ISA bus
note this is still a WIP, so some things are not cleaned yet
[src/mess]mess.mak
[src/mess/drivers]genpc.c
[src/mess/machine]genpc.c isa.c isa.h isa_com.c isa_com.h isa_fdc.c* isa_fdc.h*
[src/mess/video]isa_mda.c isa_mda.h

src/mess/machine/isa_fdc.c
r0r10772
1/**********************************************************************
2
3    ISA 8 bit Floppy Disk Controller
4
5**********************************************************************/
6
7#include "emu.h"
8#include "machine/isa_fdc.h"
9#include "machine/upd765.h"
10#include "imagedev/flopdrv.h"
11#include "formats/pc_dsk.h"
12#include "memconv.h"
13
14static READ8_DEVICE_HANDLER ( pc_fdc_r );
15static WRITE8_DEVICE_HANDLER ( pc_fdc_w );
16
17/* if not 1, DACK and TC inputs to FDC are disabled, and DRQ and IRQ are held
18 * at high impedance i.e they are not affective */
19#define PC_FDC_FLAGS_DOR_DMA_ENABLED   (1<<3)
20#define PC_FDC_FLAGS_DOR_FDC_ENABLED   (1<<2)
21#define PC_FDC_FLAGS_DOR_MOTOR_ON      (1<<4)
22
23#define LOG_FDC      0
24
25static const floppy_config ibmpc_floppy_config =
26{
27   DEVCB_NULL,
28   DEVCB_NULL,
29   DEVCB_NULL,
30   DEVCB_NULL,
31   DEVCB_NULL,
32   FLOPPY_STANDARD_5_25_DSHD,
33   FLOPPY_OPTIONS_NAME(pc),
34   NULL
35};
36
37static WRITE_LINE_DEVICE_HANDLER( pc_fdc_hw_interrupt );
38static WRITE_LINE_DEVICE_HANDLER( pc_fdc_hw_dma_drq );
39
40const upd765_interface pc_fdc_upd765_not_connected_interface =
41{
42   DEVCB_LINE(pc_fdc_hw_interrupt),
43   DEVCB_LINE(pc_fdc_hw_dma_drq),
44   NULL,
45   UPD765_RDY_PIN_NOT_CONNECTED,
46   {FLOPPY_0, FLOPPY_1, NULL, NULL}
47};
48
49static MACHINE_CONFIG_FRAGMENT( fdc_config )
50   MCFG_UPD765A_ADD("upd765", pc_fdc_upd765_not_connected_interface)
51
52   MCFG_FLOPPY_2_DRIVES_ADD(ibmpc_floppy_config)
53MACHINE_CONFIG_END
54
55//**************************************************************************
56//  GLOBAL VARIABLES
57//**************************************************************************
58 
59const device_type ISA8_FDC = isa8_fdc_device_config::static_alloc_device_config;
60 
61//**************************************************************************
62//  DEVICE CONFIGURATION
63//**************************************************************************
64 
65//-------------------------------------------------
66//  isa8_fdc_device_config - constructor
67//-------------------------------------------------
68 
69isa8_fdc_device_config::isa8_fdc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
70        : device_config(mconfig, static_alloc_device_config, "ISA8_FDC", tag, owner, clock),
71         device_config_isa8_card_interface(mconfig, *this)
72{
73}
74 
75//-------------------------------------------------
76//  static_alloc_device_config - allocate a new
77//  configuration object
78//-------------------------------------------------
79 
80device_config *isa8_fdc_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
81{
82        return global_alloc(isa8_fdc_device_config(mconfig, tag, owner, clock));
83}
84 
85//-------------------------------------------------
86//  alloc_device - allocate a new device object
87//-------------------------------------------------
88 
89device_t *isa8_fdc_device_config::alloc_device(running_machine &machine) const
90{
91        return auto_alloc(&machine, isa8_fdc_device(machine, *this));
92}
93 
94//-------------------------------------------------
95//  machine_config_additions - device-specific
96//  machine configurations
97//-------------------------------------------------
98
99machine_config_constructor isa8_fdc_device_config::machine_config_additions() const
100{
101   return MACHINE_CONFIG_NAME( fdc_config );
102}
103
104//**************************************************************************
105//  LIVE DEVICE
106//**************************************************************************
107 
108//-------------------------------------------------
109//  isa8_fdc_device - constructor
110//-------------------------------------------------
111 
112isa8_fdc_device::isa8_fdc_device(running_machine &_machine, const isa8_fdc_device_config &config) :
113        device_t(_machine, config),
114      device_isa8_card_interface( _machine, config, *this ),
115        m_config(config),
116      m_upd765(*this, "upd765"),
117      m_isa(*this->owner(), config.m_isa_tag)
118{
119}
120 
121//-------------------------------------------------
122//  device_start - device-specific startup
123//-------------------------------------------------
124 
125void isa8_fdc_device::device_start()
126{       
127   m_isa->add_isa_card(this, m_config.m_isa_num);
128   m_isa->install_device(this, 0x03f0, 0x03f7, 0, 0, pc_fdc_r, pc_fdc_w );   
129}
130
131//-------------------------------------------------
132//  device_reset - device-specific reset
133//-------------------------------------------------
134 
135void isa8_fdc_device::device_reset()
136{
137   status_register_a = 0;
138   status_register_b = 0;
139   digital_output_register = 0;
140   tape_drive_register = 0;
141   data_rate_register = 2;
142   digital_input_register = 0x07f;
143   configuration_control_register = 0;
144   tc_state = 0;
145   dma_state = 0;
146   int_state = 0;
147   
148   upd765_reset(m_upd765,0);
149
150   /* set FDC at reset */
151   upd765_reset_w(m_upd765, 1);
152}
153
154static WRITE_LINE_DEVICE_HANDLER( pc_fdc_set_tc_state)
155{
156   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device);
157   /* store state */
158   fdc->tc_state = state;
159
160   /* if dma is not enabled, tc's are not acknowledged */
161   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0)
162   {
163      upd765_tc_w(fdc->m_upd765, state);
164   }
165}
166
167static WRITE_LINE_DEVICE_HANDLER(  pc_fdc_hw_interrupt )
168{
169   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device->owner());
170   
171   fdc->int_state = state;
172
173   /* if dma is not enabled, irq's are masked */
174   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)==0)
175      return;
176
177   /* send irq */
178   fdc->m_isa->set_irq_line(6, state);
179}
180
181
182static READ8_DEVICE_HANDLER(pc_fdc_dack_r)
183{
184   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device);
185   /* what is output if dack is not acknowledged? */
186   int data = 0x0ff;
187
188   /* if dma is not enabled, dacks are not acknowledged */
189   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0)
190   {
191      data = upd765_dack_r(fdc->m_upd765, 0);
192   }
193
194   return data;
195}
196
197
198
199static WRITE8_DEVICE_HANDLER(pc_fdc_dack_w)
200{
201   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device);
202   /* if dma is not enabled, dacks are not issued */
203   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)!=0)
204   {
205      /* dma acknowledge - and send byte to fdc */
206      upd765_dack_w(fdc->m_upd765, 0,data);
207   }
208}
209
210
211
212static WRITE_LINE_DEVICE_HANDLER( pc_fdc_hw_dma_drq )
213{
214   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device->owner());
215   fdc->dma_state = state;
216
217   /* if dma is not enabled, drqs are masked */
218   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_DMA_ENABLED)==0)
219      return;
220
221   fdc->m_isa->set_dreq_line(2,state);
222}
223
224
225
226static WRITE8_DEVICE_HANDLER( pc_fdc_data_rate_w )
227{
228   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device);
229   if ((data & 0x080)!=0)
230   {
231      /* set ready state */
232      upd765_ready_w(fdc->m_upd765,1);
233
234      /* toggle reset state */
235      upd765_reset_w(fdc->m_upd765, 1);
236      upd765_reset_w(fdc->m_upd765, 0);
237
238      /* bit is self-clearing */
239      data &= ~0x080;
240   }
241
242   fdc->data_rate_register = data;
243}
244
245
246
247/*  FDC Digitial Output Register (DOR)
248
249    |7|6|5|4|3|2|1|0|
250     | | | | | | `------ floppy drive select (0=A, 1=B, 2=floppy C, ...)
251     | | | | | `-------- 1 = FDC enable, 0 = hold FDC at reset
252     | | | | `---------- 1 = DMA & I/O interface enabled
253     | | | `------------ 1 = turn floppy drive A motor on
254     | | `-------------- 1 = turn floppy drive B motor on
255     | `---------------- 1 = turn floppy drive C motor on
256     `------------------ 1 = turn floppy drive D motor on
257 */
258
259static WRITE8_DEVICE_HANDLER( pc_fdc_dor_w )
260{
261   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device);
262   int selected_drive;
263   int floppy_count;
264
265   floppy_count = floppy_get_count(device->machine);
266
267   if (floppy_count > (fdc->digital_output_register & 0x03))
268      floppy_drive_set_ready_state(floppy_get_device(device->machine, fdc->digital_output_register & 0x03), 1, 0);
269
270   fdc->digital_output_register = data;
271
272   selected_drive = data & 0x03;
273
274   /* set floppy drive motor state */
275   if (floppy_count > 0)
276      floppy_mon_w(floppy_get_device(device->machine, 0), !BIT(data, 4));
277   if (floppy_count > 1)
278      floppy_mon_w(floppy_get_device(device->machine, 1), !BIT(data, 5));
279   if (floppy_count > 2)
280      floppy_mon_w(floppy_get_device(device->machine, 2), !BIT(data, 6));
281   if (floppy_count > 3)
282      floppy_mon_w(floppy_get_device(device->machine, 3), !BIT(data, 7));
283
284   if ((data>>4) & (1<<selected_drive))
285   {
286      if (floppy_count > selected_drive)
287         floppy_drive_set_ready_state(floppy_get_device(device->machine, selected_drive), 1, 0);
288   }
289
290   /* changing the DMA enable bit, will affect the terminal count state
291    from reaching the fdc - if dma is enabled this will send it through
292    otherwise it will be ignored */
293   pc_fdc_set_tc_state(device, fdc->tc_state);
294
295   /* changing the DMA enable bit, will affect the dma drq state
296    from reaching us - if dma is enabled this will send it through
297    otherwise it will be ignored */
298   pc_fdc_hw_dma_drq(fdc->m_upd765, fdc->dma_state);
299
300   /* changing the DMA enable bit, will affect the irq state
301    from reaching us - if dma is enabled this will send it through
302    otherwise it will be ignored */
303   pc_fdc_hw_interrupt(fdc->m_upd765, fdc->int_state);
304
305   /* reset? */
306   if ((fdc->digital_output_register & PC_FDC_FLAGS_DOR_FDC_ENABLED)==0)
307   {
308      /* yes */
309
310         /* pc-xt expects a interrupt to be generated
311            when the fdc is reset.
312            In the FDC docs, it states that a INT will
313            be generated if READY input is true when the
314            fdc is reset.
315
316                It also states, that outputs to drive are set to 0.
317                Maybe this causes the drive motor to go on, and therefore
318                the ready line is set.
319
320            This in return causes a int?? ---
321
322
323        what is not yet clear is if this is a result of the drives ready state
324        changing...
325        */
326      upd765_ready_w(fdc->m_upd765, 1);
327
328      /* set FDC at reset */
329      upd765_reset_w(fdc->m_upd765, 1);
330   }
331   else
332   {
333      pc_fdc_set_tc_state(device, 0);
334
335      /* release reset on fdc */
336      upd765_reset_w(fdc->m_upd765, 0);
337   }
338}
339
340static READ8_DEVICE_HANDLER ( pc_fdc_r )
341{
342   UINT8 data = 0xff;
343
344   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device);
345   
346   switch(offset)
347   {
348      case 0: /* status register a */
349      case 1: /* status register b */
350         data = 0x00;
351      case 2:
352         data = fdc->digital_output_register;
353         break;
354      case 3: /* tape drive select? */
355         break;
356      case 4:
357         data = upd765_status_r(fdc->m_upd765, 0);
358         break;
359      case 5:
360         data = upd765_data_r(fdc->m_upd765, offset);
361         break;
362      case 6: /* FDC reserved */
363         break;
364      case 7:
365         data = fdc->digital_input_register;
366         break;
367    }
368
369   if (LOG_FDC)
370      logerror("pc_fdc_r(): pc=0x%08x offset=%d result=0x%02X\n", (unsigned) cpu_get_reg(device->machine->firstcpu,STATE_GENPC), offset, data);
371   return data;
372}
373
374
375
376static WRITE8_DEVICE_HANDLER ( pc_fdc_w )
377{
378   isa8_fdc_device   *fdc  = downcast<isa8_fdc_device *>(device);
379   
380   if (LOG_FDC)
381      logerror("pc_fdc_w(): pc=0x%08x offset=%d data=0x%02X\n", (unsigned) cpu_get_reg(device->machine->firstcpu,STATE_GENPC), offset, data);
382
383   switch(offset)
384   {
385      case 0:   /* n/a */
386      case 1:   /* n/a */
387         break;
388      case 2:
389         pc_fdc_dor_w(device, 0, data);
390         break;
391      case 3:
392         /* tape drive select? */
393         break;
394      case 4:
395         pc_fdc_data_rate_w(device, 0, data);
396         break;
397      case 5:
398         upd765_data_w(fdc->m_upd765, 0, data);
399         break;
400      case 6:
401         /* FDC reserved */
402         break;
403      case 7:
404         /* Configuration Control Register
405             *
406             * Currently unimplemented; bits 1-0 are supposed to control data
407             * flow rates:
408             *      0 0      500 kbps
409             *      0 1      300 kbps
410             *      1 0      250 kbps
411             *      1 1     1000 kbps
412             */
413         break;
414   }
415}
416
417UINT8 isa8_fdc_device::dack_r(int line)
418{
419   return pc_fdc_dack_r(this,0);   
420}
421void isa8_fdc_device::dack_w(int line,UINT8 data)
422{
423   pc_fdc_dack_w( this, 0, data );
424}
425void isa8_fdc_device::eop_w(int state)
426{
427   pc_fdc_set_tc_state( this, state);
428}
429
430bool isa8_fdc_device::have_dack(int line)
431{
432   if (line==2) return TRUE;
433   return FALSE;
434}
src/mess/machine/isa_fdc.h
r0r10772
1/**********************************************************************
2
3    ISA 8 bit Floppy Disk Controller
4
5**********************************************************************/
6#pragma once
7 
8#ifndef ISA_FDC_H
9#define ISA_FDC_H
10
11#include "emu.h"
12#include "machine/isa.h"
13
14//**************************************************************************
15//  TYPE DEFINITIONS
16//**************************************************************************
17 
18// ======================> isa8_fdc_device_config
19 
20class isa8_fdc_device_config :
21      public device_config,
22      public device_config_isa8_card_interface
23{
24        friend class isa8_device;
25      friend class isa8_fdc_device;
26 
27        // construction/destruction
28        isa8_fdc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
29 
30public:
31        // allocators
32        static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
33        virtual device_t *alloc_device(running_machine &machine) const;
34     
35      // optional information overrides
36      virtual machine_config_constructor machine_config_additions() const;
37};
38 
39 
40// ======================> isa8_fdc_device
41 
42class isa8_fdc_device :
43      public device_t,
44      public device_isa8_card_interface
45{
46        friend class isa8_fdc_device_config;
47 
48        // construction/destruction
49        isa8_fdc_device(running_machine &_machine, const isa8_fdc_device_config &config);
50
51protected:
52        // device-level overrides
53        virtual void device_start();
54        virtual void device_reset();
55
56private:
57        // internal state
58        const isa8_fdc_device_config &m_config;
59public:
60      virtual UINT8 dack_r(int line);
61      virtual void dack_w(int line,UINT8 data);
62      virtual void eop_w(int state);
63      virtual bool have_dack(int line);
64     
65      int status_register_a;
66      int status_register_b;
67      int digital_output_register;
68      int tape_drive_register;
69      int data_rate_register;
70      int digital_input_register;
71      int configuration_control_register;
72
73      /* stored tc state - state present at pins */
74      int tc_state;
75      /* stored dma drq state */
76      int dma_state;
77      /* stored int state */
78      int int_state;
79     
80      required_device<device_t> m_upd765;
81      required_device<isa8_device> m_isa;
82};
83 
84 
85// device type definition
86extern const device_type ISA8_FDC;
87
88#endif  /* ISA_FDC_H */
src/mess/machine/genpc.c
r10771r10772
100100
101101static READ8_DEVICE_HANDLER( pc_dma8237_2_dack_r )
102102{
103   return 0;//return pc_fdc_dack_r(device->machine);
103   genpc_state *st = device->machine->driver_data<genpc_state>();
104   return st->isabus->dack_r(2);
104105}
105106
106107
r10771r10772
116117
117118static WRITE8_DEVICE_HANDLER( pc_dma8237_2_dack_w )
118119{
119   //pc_fdc_dack_w( device->machine, data );
120   genpc_state *st = device->machine->driver_data<genpc_state>();
121   st->isabus->dack_w(2,data);
120122}
121123
122124
r10771r10772
136138
137139static WRITE_LINE_DEVICE_HANDLER( pc_dma8237_out_eop )
138140{
139   //pc_fdc_set_tc_state( device->machine, state == ASSERT_LINE ? 0 : 1 );
141   genpc_state *st = device->machine->driver_data<genpc_state>();   
142   return st->isabus->eop_w(state == ASSERT_LINE ? 0 : 1 );
140143}
141144
142145static void set_dma_channel(device_t *device, int channel, int state)
src/mess/machine/isa_com.c
r10771r10772
135135isa8_com_device::isa8_com_device(running_machine &_machine, const isa8_com_device_config &config) :
136136        device_t(_machine, config),
137137      device_isa8_card_interface( _machine, config, *this ),
138        m_config(config)
138        m_config(config),
139      m_isa(*this->owner(), config.m_isa_tag)
139140{
140141}
141142 
r10771r10772
145146 
146147void isa8_com_device::device_start()
147148{       
148   int buswidth;
149   buswidth = device_memory(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width;
150   switch(buswidth)
151   {
152      case 8:
153         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), subdevice("ins8250_0"), 0x03f8, 0x03ff, 0, 0, ins8250_r, ins8250_w );
154         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), subdevice("ins8250_1"), 0x02f8, 0x02ff, 0, 0, ins8250_r, ins8250_w );
155         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), subdevice("ins8250_2"), 0x03e8, 0x03ef, 0, 0, ins8250_r, ins8250_w );
156         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), subdevice("ins8250_3"), 0x02e8, 0x02ef, 0, 0, ins8250_r, ins8250_w );
157         break;
158
159      default:
160         fatalerror("COM: Bus width %d not supported", buswidth);
161         break;
162   }
149   m_isa->add_isa_card(this, m_config.m_isa_num);
150   m_isa->install_device(subdevice("ins8250_0"), 0x03f8, 0x03ff, 0, 0, ins8250_r, ins8250_w );
151   m_isa->install_device(subdevice("ins8250_1"), 0x02f8, 0x02ff, 0, 0, ins8250_r, ins8250_w );
152   m_isa->install_device(subdevice("ins8250_2"), 0x03e8, 0x03ef, 0, 0, ins8250_r, ins8250_w );
153   m_isa->install_device(subdevice("ins8250_3"), 0x02e8, 0x02ef, 0, 0, ins8250_r, ins8250_w );
163154}
164155
165156//-------------------------------------------------
src/mess/machine/isa_com.h
r10771r10772
5151private:
5252        // internal state
5353        const isa8_com_device_config &m_config;
54
54      required_device<isa8_device> m_isa;
5555public:
5656};
5757 
src/mess/machine/isa.c
r10771r10772
66 
77#include "emu.h"
88#include "machine/isa.h"
9#include "machine/pic8259.h"
10#include "machine/8237dma.h"
11
912 
1013 
1114//**************************************************************************
r10771r10772
5154        isa8_device_config *isa = downcast<isa8_device_config *>(device);
5255        isa->m_cputag = tag;
5356}
57void isa8_device_config::static_set_dmatag(device_config *device, const char *tag)
58{
59        isa8_device_config *isa = downcast<isa8_device_config *>(device);
60        isa->m_dmatag = tag;
61}
62void isa8_device_config::static_set_pictag(device_config *device, const char *tag)
63{
64        isa8_device_config *isa = downcast<isa8_device_config *>(device);
65        isa->m_pictag = tag;
66}
5467 
5568//**************************************************************************
5669//  LIVE DEVICE
r10771r10772
6275 
6376isa8_device::isa8_device(running_machine &_machine, const isa8_device_config &config) :
6477        device_t(_machine, config),
65        m_config(config)
78        m_config(config),
79      m_maincpu(NULL),
80      m_pic8259(NULL),
81      m_dma8237(NULL)
6682{
83   for(int i=0;i<8;i++)
84      m_isa_device[i] = NULL;
6785}
6886 
6987//-------------------------------------------------
r10771r10772
7290 
7391void isa8_device::device_start()
7492{       
75        device_t *cpu = m_machine.device(m_config.m_cputag);
76        m_space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM);
93   m_maincpu = m_machine.device(m_config.m_cputag);
94   m_pic8259 = m_machine.device(m_config.m_pictag);
95   m_dma8237 = m_machine.device(m_config.m_dmatag);
7796}
7897 
7998//-------------------------------------------------
8099//  device_reset - device-specific reset
81100//-------------------------------------------------
82 
101 
83102void isa8_device::device_reset()
84103{
85104}
86105
106void isa8_device::add_isa_card(device_isa8_card_interface *card,int pos)
107{
108   m_isa_device[pos] = card;
109}
87110
111void isa8_device::install_device(device_t *dev, offs_t start, offs_t end, offs_t mask, offs_t mirror, read8_device_func rhandler, write8_device_func whandler)
112{   
113   int buswidth = device_memory(m_maincpu)->space_config(AS_PROGRAM)->m_databus_width;
114   switch(buswidth)
115   {
116      case 8:
117         memory_install_readwrite8_device_handler(cpu_get_address_space(m_maincpu, ADDRESS_SPACE_IO), dev, start, end, mask, mirror, rhandler, whandler );
118         break;
119
120      default:
121         fatalerror("ISA8: Bus width %d not supported", buswidth);
122         break;
123   }
124}
125
126void isa8_device::install_bank(offs_t start, offs_t end, offs_t mask, offs_t mirror, const char *tag, UINT8 *data)
127{
128   address_space *space = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
129   memory_install_readwrite_bank(space, start, end, mask, mirror, tag );
130   memory_set_bankptr(&m_machine, tag, data);
131}
132
133void isa8_device::set_irq_line(int irq, int state)
134{
135   switch (irq)
136   {
137      case 0: pic8259_ir0_w(m_pic8259, state); break;
138      case 1: pic8259_ir1_w(m_pic8259, state); break;
139      case 2: pic8259_ir2_w(m_pic8259, state); break;
140      case 3: pic8259_ir3_w(m_pic8259, state); break;
141      case 4: pic8259_ir4_w(m_pic8259, state); break;
142      case 5: pic8259_ir5_w(m_pic8259, state); break;
143      case 6: pic8259_ir6_w(m_pic8259, state); break;
144      case 7: pic8259_ir7_w(m_pic8259, state); break;
145   }
146}
147
148void isa8_device::set_dreq_line(int line, int state)
149{
150   switch (line)
151   {
152      case 0: i8237_dreq0_w(m_dma8237, state); break;
153      case 1: i8237_dreq1_w(m_dma8237, state); break;
154      case 2: i8237_dreq2_w(m_dma8237, state); break;
155      case 3: i8237_dreq3_w(m_dma8237, state); break;
156   }
157}
158
159UINT8 isa8_device::dack_r(int line)
160{
161   UINT8 retVal = 0xff;
162   for(int i=0;i<8;i++) {
163      if (m_isa_device[i] != NULL && m_isa_device[i]->have_dack(line)) {
164         retVal = m_isa_device[i]->dack_r(line);
165      }     
166   }
167   return retVal;
168}
169void isa8_device::dack_w(int line,UINT8 data)
170{
171   for(int i=0;i<8;i++) {
172      if (m_isa_device[i] != NULL && m_isa_device[i]->have_dack(line)) {
173         m_isa_device[i]->dack_w(line,data);
174      }     
175   }
176}
177void isa8_device::eop_w(int state)
178{
179   for(int i=0;i<8;i++) {
180      if (m_isa_device[i] != NULL) m_isa_device[i]->eop_w(state);
181   }
182}
183
184
88185//**************************************************************************
89186//  DEVICE CONFIG ISA8 CARD INTERFACE
90187//**************************************************************************
r10771r10772
142239device_isa8_card_interface::~device_isa8_card_interface()
143240{
144241}
242
243UINT8 device_isa8_card_interface::dack_r(int line)
244{
245   return 0;
246}
247void device_isa8_card_interface::dack_w(int line,UINT8 data)
248{
249}
250void device_isa8_card_interface::eop_w(int state)
251{
252}
253
254bool device_isa8_card_interface::have_dack(int line)
255{
256   return FALSE;
257}
src/mess/machine/isa.h
r10771r10772
1616//  INTERFACE CONFIGURATION MACROS
1717//**************************************************************************
1818 
19#define MCFG_ISA8_BUS_ADD(_tag, _cputag) \
19#define MCFG_ISA8_BUS_ADD(_tag, _cputag, _dmatag, _pictag) \
2020    MCFG_DEVICE_ADD(_tag, ISA8, 0) \
2121    isa8_device_config::static_set_cputag(device, _cputag); \
22   isa8_device_config::static_set_dmatag(device, _dmatag); \
23   isa8_device_config::static_set_pictag(device, _pictag); \
2224 
2325#define MCFG_ISA8_BUS_DEVICE(_isatag, _num, _tag, _dev_type) \
2426    MCFG_DEVICE_ADD(_tag, _dev_type, 0) \
r10771r10772
4648 
4749        // inline configuration
4850        static void static_set_cputag(device_config *device, const char *tag);
51      static void static_set_dmatag(device_config *device, const char *tag);
52      static void static_set_pictag(device_config *device, const char *tag);
4953 
5054        const char *m_cputag;
55      const char *m_dmatag;
56      const char *m_pictag;
5157};
5258 
5359 
5460// ======================> isa8_device
55
61class device_isa8_card_interface;
5662class isa8_device : public device_t
5763{
5864        friend class isa8_device_config;
5965 
6066        // construction/destruction
6167        isa8_device(running_machine &_machine, const isa8_device_config &config);
68public:
69      void add_isa_card(device_isa8_card_interface *card,int pos);
70      void install_device(device_t *dev, offs_t start, offs_t end, offs_t mask, offs_t mirror, read8_device_func rhandler, write8_device_func whandler);
71      void install_bank(offs_t start, offs_t end, offs_t mask, offs_t mirror, const char *tag, UINT8 *data);
6272
73      void set_irq_line(int irq, int state);
74      void set_dreq_line(int line, int state);
75     
76      UINT8 dack_r(int line);
77      void dack_w(int line,UINT8 data);
78      void eop_w(int state);
6379protected:
6480        // device-level overrides
6581        virtual void device_start();
r10771r10772
6985        // internal state
7086        const isa8_device_config &m_config;
7187 
72        address_space *m_space;
88        device_t *m_maincpu;     
89      device_t *m_pic8259;
90      device_t *m_dma8237;
91     
92      device_isa8_card_interface *m_isa_device[8];
7393};
7494 
7595 
r10771r10772
82102// class representing interface-specific configuration isa8 card
83103class device_config_isa8_card_interface : public device_config_interface
84104{
105   friend class device_isa8_card_interface;
85106public:
86107   // construction/destruction
87108   device_config_isa8_card_interface(const machine_config &mconfig, device_config &device);
r10771r10772
100121// class representing interface-specific live isa8 card
101122class device_isa8_card_interface : public device_interface
102123{
124   friend class isa8_device;
125   friend class device_config_isa8_card_interface;
103126public:
104127   // construction/destruction
105128   device_isa8_card_interface(running_machine &machine, const device_config &config, device_t &device);
r10771r10772
107130
108131   // configuration access
109132   const device_config_isa8_card_interface &isa8_card_config() const { return m_isa8_card_config; }
110
133     
134   virtual UINT8 dack_r(int line);
135   virtual void dack_w(int line,UINT8 data);
136   virtual void eop_w(int state);
137   virtual bool have_dack(int line);
111138protected:
112139
113140   // configuration
114   const device_config_isa8_card_interface &m_isa8_card_config;   // reference to our device_config_execute_interface
141   const device_config_isa8_card_interface &m_isa8_card_config;   // reference to our device_config_execute_interface   
115142};
116143 
117144#endif  /* __ISA_H__ */
src/mess/video/isa_mda.c
r10771r10772
179179isa8_mda_device::isa8_mda_device(running_machine &_machine, const isa8_mda_device_config &config) :
180180        device_t(_machine, config),
181181      device_isa8_card_interface( _machine, config, *this ),
182        m_config(config)
182        m_config(config),
183      m_isa(*this->owner(), config.m_isa_tag)
183184{
184185}
185186 
r10771r10772
189190 
190191void isa8_mda_device::device_start()
191192{       
192   int buswidth;
193   address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM);
194
195   buswidth = device_memory(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width;
196   switch(buswidth)
197   {
198      case 8:
199         memory_install_readwrite_bank(space, 0xb0000, 0xb0fff, 0, 0x07000, "bank_mda" );
200         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, pc_MDA_r, pc_MDA_w );
201         break;
202
203      default:
204         fatalerror("MDA: Bus width %d not supported", buswidth);
205         break;
206   }
207
193   m_isa->add_isa_card(this, m_config.m_isa_num);
208194   videoram = auto_alloc_array(machine, UINT8, 0x1000);
195   m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, pc_MDA_r, pc_MDA_w );
196   m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", videoram);   
209197   
210   memory_set_bankptr(machine,"bank_mda", videoram);
211
212198   /* Initialise the mda palette */
213199   for(int i = 0; i < (sizeof(mda_palette) / 3); i++)
214200      palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]);   
r10771r10772
643629 
644630void isa8_hercules_device::device_start()
645631{       
646   int buswidth;
647   address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM);
648
649   buswidth = device_memory(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width;
650   switch(buswidth)
651   {
652      case 8:
653         memory_install_readwrite_bank(space, 0xb0000, 0xbffff, 0, 0, "bank_hercules" );
654         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, hercules_r, hercules_w );
655         break;
656
657      default:
658         fatalerror("MDA: Bus width %d not supported", buswidth);
659         break;
660   }
661
662632   videoram = auto_alloc_array(machine, UINT8, 0x10000);
663   
664   memory_set_bankptr(machine,"bank_hercules", videoram);
665633
634   m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, hercules_r, hercules_w );
635   m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", videoram);
636
666637   /* Initialise the mda palette */
667638   for(int i = 0; i < (sizeof(mda_palette) / 3); i++)
668639      palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]);   
src/mess/video/isa_mda.h
r10771r10772
1818      public device_config_isa8_card_interface
1919{
2020        friend class isa8_device;
21      friend class isa8_mda_device;
2122      friend class isa8_hercules_device_config;
2223 
2324        // construction/destruction
r10771r10772
5556private:
5657        // internal state
5758        const isa8_mda_device_config &m_config;
58
59      required_device<isa8_device> m_isa;
5960public:
6061      int  framecnt;
6162
src/mess/mess.mak
r10771r10772
12931293   $(MESS_MACHINE)/pc_joy.o   \
12941294   $(MESS_MACHINE)/kb_keytro.o   \
12951295   $(MESS_MACHINE)/isa_com.o   \
1296   $(MESS_MACHINE)/isa_fdc.o   \
12961297   $(MESS_VIDEO)/isa_mda.o      \
12971298   $(MESS_VIDEO)/pc_cga.o      \
12981299   $(MESS_VIDEO)/cgapal.o      \
src/mess/drivers/genpc.c
r10771r10772
2727#include "machine/isa.h"
2828
2929#include "machine/isa_com.h"
30#include "machine/isa_fdc.h"
3031
3132#include "sound/speaker.h"
3233
r10771r10772
155156
156157   MCFG_PALETTE_LENGTH( 256 )
157158     
158   MCFG_ISA8_BUS_ADD("isa","maincpu")
159   MCFG_ISA8_BUS_ADD("isa","maincpu","dma8237","pic8259")
159160   MCFG_ISA8_BUS_DEVICE("isa", 0, "mda", ISA8_MDA)
160161   MCFG_ISA8_BUS_DEVICE("isa", 1, "com", ISA8_COM)
162   MCFG_ISA8_BUS_DEVICE("isa", 2, "fdc", ISA8_FDC)
161163
162164   /* sound hardware */
163165   MCFG_SPEAKER_STANDARD_MONO("mono")
r10771r10772
192194
193195   MCFG_PALETTE_LENGTH( 256 )   
194196   
195   MCFG_ISA8_BUS_ADD("isa","maincpu")
197   MCFG_ISA8_BUS_ADD("isa","maincpu","dma8237","pic8259")
196198   MCFG_ISA8_BUS_DEVICE("isa", 0, "hercules", ISA8_HERCULES)
197199   MCFG_ISA8_BUS_DEVICE("isa", 1, "com", ISA8_COM)
200   MCFG_ISA8_BUS_DEVICE("isa", 2, "fdc", ISA8_FDC)
198201
199202   /* sound hardware */
200203   MCFG_SPEAKER_STANDARD_MONO("mono")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team