Previous 15994 Revisions Next

r13865 Thursday 5th January, 2012 at 02:22:10 UTC by Robbbert
reserving a spot for my new device while i work on it.
[src/mess]mess.mak
[src/mess/machine]i8279.c* i8279.h*

src/mess/machine/i8279.c
r0r13865
1/**********************************************************************
2
3    8279 DMA interface and emulation
4
5    The DMA works like this:
6    (summarized from http://www.infran.ru/TechInfo/BSD/handbook258.html#410)
7
8    1.  The device asserts the DRQn line
9    2.  The DMA clears the TC (terminal count) line
10    3.  The DMA asserts the CPU's HRQ (halt request) line
11    4.  Upon acknowledgement of the halt, the DMA will let the device
12        know that it needs to send information by asserting the DACKn
13        line
14    5.  The DMA will read the byte from the device
15    6.  The device clears the DRQn line
16    7.  The DMA clears the CPU's HRQ line
17    8.  (steps 3-7 are repeated for every byte in the chain)
18
19**********************************************************************/
20
21#include "emu.h"
22#include "memconv.h"
23#include "i8279.h"
24#include "machine/devhelpr.h"
25
26/***************************************************************************
27    MACROS
28***************************************************************************/
29
30#define DMA_MODE_CHANNEL(mode)      ((mode) & 0x03)
31#define DMA_MODE_OPERATION(mode)   ((mode) & 0x0c)
32#define DMA_MODE_AUTO_INIT(mode)   ((mode) & 0x10)
33#define DMA_MODE_DIRECTION(mode)   ((mode) & 0x20)
34#define DMA_MODE_TRANSFERMODE(mode)   ((mode) & 0xc0)
35
36#define DMA8279_VERIFY_TRANSFER      0x00
37#define DMA8279_WRITE_TRANSFER      0x04
38#define DMA8279_READ_TRANSFER      0x08
39#define DMA8279_ILLEGAL_TRANSFER   0x0c
40
41#define DMA8279_DEMAND_MODE      0x00
42#define DMA8279_SINGLE_MODE      0x40
43#define DMA8279_BLOCK_MODE      0x80
44#define DMA8279_CASCADE_MODE   0xc0
45
46
47//**************************************************************************
48//  LIVE DEVICE
49//**************************************************************************
50
51// device type definition
52const device_type I8279 = &device_creator<i8279_device>;
53
54//-------------------------------------------------
55//  i8279_device - constructor
56//-------------------------------------------------
57
58i8279_device::i8279_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
59    : device_t(mconfig, I8279, "Intel 8279", tag, owner, clock)
60{
61}
62
63//-------------------------------------------------
64//  device_config_complete - perform any
65//  operations now that the configuration is
66//  complete
67//-------------------------------------------------
68
69void i8279_device::device_config_complete()
70{
71   // inherit a copy of the static data
72   const i8279_interface *intf = reinterpret_cast<const i8279_interface *>(static_config());
73   if (intf != NULL)
74   {
75      *static_cast<i8279_interface *>(this) = *intf;
76   }
77
78   // or initialize to defaults if none provided
79   else
80   {
81       memset(&m_out_hrq_cb, 0, sizeof(m_out_hrq_cb));
82       memset(&m_out_eop_cb, 0, sizeof(m_out_eop_cb));
83       memset(&m_in_memr_cb, 0, sizeof(m_in_memr_cb));
84       memset(&m_out_memw_cb, 0, sizeof(m_out_memw_cb));
85       memset(&m_in_ior_cb[0], 0, sizeof(m_in_ior_cb[0]));
86       memset(&m_in_ior_cb[1], 0, sizeof(m_in_ior_cb[1]));
87       memset(&m_in_ior_cb[2], 0, sizeof(m_in_ior_cb[2]));
88       memset(&m_in_ior_cb[3], 0, sizeof(m_in_ior_cb[3]));
89       memset(&m_out_iow_cb[0], 0, sizeof(m_out_iow_cb[0]));
90       memset(&m_out_iow_cb[1], 0, sizeof(m_out_iow_cb[1]));
91       memset(&m_out_iow_cb[2], 0, sizeof(m_out_iow_cb[2]));
92       memset(&m_out_iow_cb[3], 0, sizeof(m_out_iow_cb[3]));
93       memset(&m_out_dack_cb[0], 0, sizeof(m_out_dack_cb[0]));
94       memset(&m_out_dack_cb[1], 0, sizeof(m_out_dack_cb[1]));
95       memset(&m_out_dack_cb[2], 0, sizeof(m_out_dack_cb[2]));
96       memset(&m_out_dack_cb[3], 0, sizeof(m_out_dack_cb[3]));
97   }
98}
99
100
101//-------------------------------------------------
102//  device_start - device-specific startup
103//-------------------------------------------------
104
105void i8279_device::device_start()
106{
107   /* resolve callbacks */
108   m_out_hrq_func.resolve(m_out_hrq_cb, *this);
109   m_out_eop_func.resolve(m_out_eop_cb, *this);
110   m_in_memr_func.resolve(m_in_memr_cb, *this);
111   m_out_memw_func.resolve(m_out_memw_cb, *this);
112
113   for (int i = 0; i < 4; i++)
114   {
115      m_chan[i].m_in_ior_func.resolve(m_in_ior_cb[i], *this);
116      m_chan[i].m_out_iow_func.resolve(m_out_iow_cb[i], *this);
117      m_chan[i].m_out_dack_func.resolve(m_out_dack_cb[i], *this);
118   }
119
120   m_timer = machine().scheduler().timer_alloc(FUNC(i8279_timerproc_callback), (void *)this);
121}
122
123
124//-------------------------------------------------
125//  device_reset - device-specific reset
126//-------------------------------------------------
127
128void i8279_device::device_reset()
129{
130   m_status = 0x0F;
131   m_eop = 1;
132   m_state = DMA8279_SI;
133   m_last_service_channel = 3;
134
135   m_command = 0;
136   m_drq = 0;
137   m_mask = 0x00;
138   m_status = 0x0F;
139   m_hrq = 0;
140   m_hlda = 0;
141   m_chan[0].m_mode = 0;
142   m_chan[1].m_mode = 0;
143   m_chan[2].m_mode = 0;
144   m_chan[3].m_mode = 0;
145
146   m_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
147}
148
149
150void i8279_device::i8279_do_read()
151{
152   int channel = m_service_channel;
153
154   switch( DMA_MODE_OPERATION( m_chan[ channel ].m_mode ) )
155   {
156   case DMA8279_WRITE_TRANSFER:
157      m_temporary_data = m_chan[channel].m_in_ior_func(0);
158      break;
159   case DMA8279_READ_TRANSFER:
160      m_temporary_data = m_in_memr_func(m_chan[ channel ].m_address);
161      break;
162   case DMA8279_VERIFY_TRANSFER:
163   case DMA8279_ILLEGAL_TRANSFER:
164      break;
165   }
166}
167
168
169void i8279_device::i8279_do_write()
170{
171   int channel = m_service_channel;
172
173   switch( DMA_MODE_OPERATION( m_chan[ channel ].m_mode ) )
174   {
175   case DMA8279_WRITE_TRANSFER:
176      m_out_memw_func(m_chan[ channel ].m_address, m_temporary_data);
177      break;
178   case DMA8279_READ_TRANSFER:
179      m_chan[channel].m_out_iow_func(0, m_temporary_data);
180      break;
181   case DMA8279_VERIFY_TRANSFER:
182   case DMA8279_ILLEGAL_TRANSFER:
183      break;
184   }
185}
186
187
188void i8279_device::i8279_advance()
189{
190   int channel = m_service_channel;
191   int mode = m_chan[channel].m_mode;
192
193   switch ( DMA_MODE_OPERATION( mode ) )
194   {
195   case DMA8279_VERIFY_TRANSFER:
196   case DMA8279_WRITE_TRANSFER:
197   case DMA8279_READ_TRANSFER:
198      m_chan[channel].m_high_address_changed = 0;
199
200      if ( DMA_MODE_DIRECTION( mode ) )
201      {
202         m_chan[channel].m_address -= 1;
203         if ( ( m_chan[channel].m_address & 0xFF ) == 0xFF )
204         {
205            m_chan[channel].m_high_address_changed  = 1;
206         }
207      }
208      else
209      {
210         m_chan[channel].m_address += 1;
211         if ( ( m_chan[channel].m_address & 0xFF ) == 0x00 )
212         {
213            m_chan[channel].m_high_address_changed = 1;
214         }
215      }
216
217      m_chan[channel].m_count--;
218
219      if ( m_chan[channel].m_count == 0xFFFF )
220      {
221         /* Set TC bit for this channel */
222         m_status |= ( 0x01 << channel );
223
224         if ( DMA_MODE_AUTO_INIT( mode ) )
225         {
226            m_chan[channel].m_address = m_chan[channel].m_base_address;
227            m_chan[channel].m_count = m_chan[channel].m_base_count;
228            m_chan[channel].m_high_address_changed = 1;
229         }
230         else
231         {
232            m_mask |= ( 0x01 << channel );
233         }
234      }
235      break;
236   case DMA8279_ILLEGAL_TRANSFER:
237      break;
238   }
239}
240
241
242void i8279_device::i8327_set_dack(int channel)
243{
244   for (int i = 0; i < 4; i++)
245   {
246      int state = (i == channel) ^ !BIT(m_command, 7);
247
248      m_chan[i].m_out_dack_func(state);
249   }
250}
251
252
253TIMER_CALLBACK( i8279_device::i8279_timerproc_callback )
254{
255   reinterpret_cast<i8279_device*>(ptr)->i8279_timerproc();
256}
257
258
259void i8279_device::i8279_timerproc()
260{
261   /* Check if operation is disabled */
262   if ( m_command & 0x04 )
263   {
264      return;
265   }
266
267   switch ( m_state )
268   {
269
270   case DMA8279_SI:
271   {
272      /* Make sure EOP is high */
273      if ( !m_eop )
274      {
275         m_eop = 1;
276         m_out_eop_func(m_eop ? ASSERT_LINE : CLEAR_LINE);
277      }
278
279      /* Check if a new DMA request has been received. */
280      /* Bit 6 of the command register determines whether the DREQ signals are active
281          high or active low. */
282      UINT16 pending_request = ( ( m_command & 0x40 ) ? ~m_drq : m_drq ) & ~m_mask;
283
284      if ( pending_request & 0x0f )
285      {
286         int prio_channel = 0;
287
288         /* Determine the channel that should be serviced */
289         int channel = ( m_command & 0x10 ) ? m_last_service_channel : 3;
290         for ( int i = 0; i < 4; i++ )
291         {
292            if ( pending_request & ( 1 << channel ) )
293            {
294               prio_channel = channel;
295            }
296            channel = ( channel - 1 ) & 0x03;
297         }
298
299         /* Store the channel we will be servicing and go to the next state */
300         m_service_channel = prio_channel;
301         m_last_service_channel = prio_channel;
302
303         m_hrq = 1;
304         m_out_hrq_func(m_hrq);
305         m_state = DMA8279_S0;
306
307         m_timer->enable( true );
308      }
309      else if (m_command == 3 && (m_drq & 1))
310      {
311         /* Memory-to-memory transfers */
312         m_hlda = 1;
313         m_state = DMA8279_S0;
314      }
315      else
316      {
317         m_timer->enable( false );
318      }
319      break;
320   }
321
322   case DMA8279_S0:
323      /* S0 is the first of the DMA service. We have requested a hold but are waiting
324          for confirmation. */
325      if ( m_hlda )
326      {
327         if ( DMA_MODE_TRANSFERMODE( m_chan[m_service_channel].m_mode ) == DMA8279_CASCADE_MODE )
328         {
329            /* Cascade Mode, set DACK */
330            i8327_set_dack(m_service_channel);
331
332            /* Wait until peripheral is done */
333            m_state = DMA8279_SC;
334         }
335         else
336         {
337            if ( m_command & 0x01 )
338            {
339               /* Memory-to-memory transfers */
340               m_state = DMA8279_S11;
341            }
342            else
343            {
344               /* Regular transfers */
345               m_state = DMA8279_S1;
346            }
347         }
348      }
349      break;
350
351   case DMA8279_SC:   /* Cascade mode, waiting until peripheral is done */
352      if ( ! ( m_drq & ( 0x01 << m_service_channel ) ) )
353      {
354         m_hrq = 0;
355         m_hlda = 0;
356         m_out_hrq_func(m_hrq);
357         m_state = DMA8279_SI;
358
359         /* Clear DACK */
360         i8327_set_dack(-1);
361      }
362
363      /* Not sure if this is correct, documentation is not clear */
364      /* Check if EOP output needs to be asserted  */
365      if ( m_status & ( 0x01 << m_service_channel ) )
366      {
367         m_eop = 0;
368         m_out_eop_func(m_eop ? ASSERT_LINE : CLEAR_LINE);
369      }
370      break;
371
372   case DMA8279_S1:   /* Output A8-A15 */
373      m_state = DMA8279_S2;
374      break;
375
376   case DMA8279_S2:   /* Output A7-A0 */
377      /* set DACK */
378      i8327_set_dack(m_service_channel);
379
380      /* Check for compressed timing */
381      if ( m_command & 0x08 )
382      {
383         m_state = DMA8279_S4;
384      }
385      else
386      {
387         m_state = DMA8279_S3;
388      }
389      break;
390
391   case DMA8279_S3:   /* Initiate read */
392      i8279_do_read();
393      m_state = DMA8279_S4;
394      break;
395
396   case DMA8279_S4:   /* Perform read/write */
397      /* Perform read when in compressed timing mode */
398      if ( m_command & 0x08 )
399      {
400         i8279_do_read();
401      }
402
403      /* Perform write */
404      i8279_do_write();
405
406
407      /* Advance */
408      i8279_advance();
409
410      {
411         int channel = m_service_channel;
412
413         switch( DMA_MODE_TRANSFERMODE( m_chan[channel].m_mode ) )
414         {
415         case DMA8279_DEMAND_MODE:
416            /* Check for terminal count or EOP signal or DREQ begin de-asserted */
417            if ( ( m_status & ( 0x01 << channel ) ) || !m_eop || !( m_drq & ( 0x01 << channel ) ) )
418            {
419               m_hrq = 0;
420               m_hlda = 0;
421               m_out_hrq_func(m_hrq);
422               m_state = DMA8279_SI;
423            }
424            else
425            {
426               m_state = m_chan[channel].m_high_address_changed ? DMA8279_S1 : DMA8279_S2;
427            }
428            break;
429
430         case DMA8279_SINGLE_MODE:
431            m_hrq = 0;
432            m_hlda = 0;
433            m_out_hrq_func(m_hrq);
434            m_state = DMA8279_SI;
435            break;
436
437         case DMA8279_BLOCK_MODE:
438            /* Check for terminal count or EOP signal */
439            if ( ( m_status & ( 0x01 << channel ) ) || !m_eop )
440            {
441               m_hrq = 0;
442               m_hlda = 0;
443               m_out_hrq_func(m_hrq);
444               m_state = DMA8279_SI;
445            }
446            else
447            {
448               m_state = m_chan[channel].m_high_address_changed ? DMA8279_S1 : DMA8279_S2;
449            }
450            break;
451         }
452
453         /* Check if EOP output needs to be asserted */
454         if ( m_status & ( 0x01 << channel ) )
455         {
456            m_eop = 0;
457            m_out_eop_func(m_eop ? ASSERT_LINE : CLEAR_LINE);
458         }
459      }
460
461      /* clear DACK */
462      if ( m_state == DMA8279_SI )
463      {
464         i8327_set_dack(-1);
465      }
466      break;
467
468   case DMA8279_S11: /* Output A8-A15 */
469
470//      logerror("###### dma8279_timerproc %s: from %04x count=%x to %04x count=%x\n", tag(),
471//              m_chan[0].m_address, m_chan[0].m_count,
472//              m_chan[1].m_address, m_chan[1].m_count);
473
474      // FIXME: this will copy bytes correct, but not 16 bit words
475      m_temporary_data = m_in_memr_func(m_chan[0].m_address);
476      m_out_memw_func(m_chan[1].m_address, m_temporary_data);
477
478      m_service_channel = 0;
479
480      /* Advance */
481      i8279_advance();
482
483      // advance destination channel as well
484      m_chan[1].m_count--;
485      m_chan[1].m_address++;
486
487      if (m_chan[0].m_count == 0xFFFF || m_chan[1].m_count == 0xFFFF) {
488         m_hrq = 0;
489         m_hlda = 0;
490         m_out_hrq_func(m_hrq);
491         m_state = DMA8279_SI;
492         m_status |= 3; // set TC for channel 0 and 1
493         m_drq &= ~3; // clear drq for channel 0 and 1
494
495      //  logerror("!!! dma8279_timerproc DMA8279_S11 %s: m_drq=%x m_command=%x\n", tag(), m_drq, m_command);
496      }
497      break;
498   }
499}
500
501
502READ8_DEVICE_HANDLER_TRAMPOLINE(i8279, i8279_r)
503{
504   UINT8 data = 0xFF;
505
506   offset &= 0x0F;
507
508   switch(offset) {
509   case 0:
510   case 2:
511   case 4:
512   case 6:
513      /* DMA address register */
514      data = m_chan[offset / 2].m_address >> (m_msb ? 8 : 0);
515      m_msb ^= 1;
516      break;
517
518   case 1:
519   case 3:
520   case 5:
521   case 7:
522      /* DMA count register */
523      data = m_chan[offset / 2].m_count >> (m_msb ? 8 : 0);
524      m_msb ^= 1;
525      break;
526
527   case 8:
528      /* DMA status register */
529      data = (UINT8) m_status;
530
531      /* TC bits are cleared on a status read */
532      m_status &= 0xF0;
533      break;
534
535   case 10:
536      /* DMA mask register */
537      data = m_mask;
538      break;
539
540   case 13:
541      /* DMA master clear */
542      data = m_temp;
543      break;
544
545   case 9:      /* DMA write request register */
546   case 11:   /* DMA mode register */
547   case 12:   /* DMA clear byte pointer flip-flop */
548   case 14:   /* DMA clear mask register */
549   case 15:   /* DMA write mask register */
550      data = 0xFF;
551      break;
552   }
553
554   return data;
555}
556
557
558WRITE8_DEVICE_HANDLER_TRAMPOLINE(i8279, i8279_w)
559{
560   offset &= 0x0F;
561
562//  logerror("i8279_w: offset = %02x, data = %02x\n", offset, data );
563
564   switch(offset) {
565   case 0:
566   case 2:
567   case 4:
568   case 6:
569   {
570      /* DMA address register */
571      int channel = offset / 2;
572      if (m_msb)
573      {
574         m_chan[channel].m_base_address = ( m_chan[channel].m_base_address & 0x00FF ) | ( data << 8 );
575         m_chan[channel].m_address = ( m_chan[channel].m_address & 0x00FF ) | ( data << 8 );
576      }
577      else
578      {
579         m_chan[channel].m_base_address = ( m_chan[channel].m_base_address & 0xFF00 ) | data;
580         m_chan[channel].m_address = ( m_chan[channel].m_address & 0xFF00 ) | data;
581      }
582      m_msb ^= 1;
583      break;
584   }
585
586   case 1:
587   case 3:
588   case 5:
589   case 7:
590   {
591      /* DMA count register */
592      int channel = offset / 2;
593      if (m_msb)
594      {
595         m_chan[channel].m_base_count = ( m_chan[channel].m_base_count & 0x00FF ) | ( data << 8 );
596         m_chan[channel].m_count = ( m_chan[channel].m_count & 0x00FF ) | ( data << 8 );
597      }
598      else
599      {
600         m_chan[channel].m_base_count = ( m_chan[channel].m_base_count & 0xFF00 ) | data;
601         m_chan[channel].m_count = ( m_chan[channel].m_count & 0xFF00 ) | data;
602      }
603      m_msb ^= 1;
604      break;
605   }
606
607   case 8:
608      /* DMA command register */
609      m_command = data;
610      m_timer->enable( ( m_command & 0x04 ) ? 0 : 1 );
611      break;
612
613   case 9:
614   {
615      /* DMA request register */
616      int channel = DMA_MODE_CHANNEL(data);
617      if ( data & 0x04 )
618      {
619         m_drq |= 0x01 << channel;
620         m_timer->enable( ( m_command & 0x04 ) ? 0 : 1 );
621      }
622      else
623      {
624         m_status &= ~ ( 0x10 << channel );
625         m_drq &= ~ ( 0x01 << channel );
626      }
627      break;
628   }
629
630   case 10:
631   {
632      /* DMA mask register */
633      int channel = DMA_MODE_CHANNEL(data);
634      if (data & 0x04)
635      {
636         m_mask |= 0x11 << channel;
637      }
638      else
639      {
640         m_mask &= ~(0x11 << channel);
641      }
642      break;
643   }
644
645   case 11:
646   {
647      /* DMA mode register */
648      int channel = DMA_MODE_CHANNEL(data);
649      m_chan[channel].m_mode = data;
650      /* Apparently mode writes also clear the TC bit(?) */
651      m_status &= ~ ( 1 << channel );
652      break;
653   }
654
655   case 12:
656      /* DMA clear byte pointer flip-flop */
657      m_temp = data;
658      m_msb = 0;
659      break;
660
661   case 13:
662      /* DMA master clear */
663      m_msb = 0;
664      m_mask = 0x0f;
665      m_state = DMA8279_SI;
666      m_status &= 0xF0;
667      m_temp = 0;
668      break;
669
670   case 14:
671      /* DMA clear mask register */
672      m_mask &= ~data;
673      m_mask = 0;
674      break;
675
676   case 15:
677      /* DMA write mask register */
678      m_mask = data & 0x0f;
679      break;
680   }
681}
682
683
684void i8279_device::i8279_drq_write(int channel, int state)
685{
686   if (state)
687   {
688      m_drq |= ( 0x01 << channel );
689   }
690   else
691   {
692      m_drq &= ~( 0x01 << channel );
693   }
694
695   m_timer->enable( ( m_command & 0x04 ) ? 0 : 1 );
696
697}
698
699
700
701/***************************************************************************
702    TRAMPOLINES
703***************************************************************************/
704
705WRITE_LINE_DEVICE_HANDLER( i8279_hlda_w ) { downcast<i8279_device*>(device)->i8279_hlda_w(state); }
706WRITE_LINE_DEVICE_HANDLER( i8279_ready_w ) { }
707WRITE_LINE_DEVICE_HANDLER( i8279_dreq0_w ) { downcast<i8279_device*>(device)->i8279_drq_write(0, state); }
708WRITE_LINE_DEVICE_HANDLER( i8279_dreq1_w ) { downcast<i8279_device*>(device)->i8279_drq_write(1, state); }
709WRITE_LINE_DEVICE_HANDLER( i8279_dreq2_w ) { downcast<i8279_device*>(device)->i8279_drq_write(2, state); }
710WRITE_LINE_DEVICE_HANDLER( i8279_dreq3_w ) { downcast<i8279_device*>(device)->i8279_drq_write(3, state); }
711WRITE_LINE_DEVICE_HANDLER( i8279_eop_w ) { }
src/mess/machine/i8279.h
r0r13865
1/***************************************************************************
2
3    Intel 8237 Programmable DMA Controller emulation
4
5    Copyright Nicola Salmoria and the MAME Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8****************************************************************************
9                            _____   _____
10                 _I/OR   1 |*    \_/     | 40  A7
11                 _I/OW   2 |             | 39  A6
12                 _MEMR   3 |             | 38  A5
13                 _MEMW   4 |             | 37  A4
14                         5 |             | 36  _EOP
15                 READY   6 |             | 35  A3
16                  HLDA   7 |             | 34  A2
17                 ADSTB   8 |             | 33  A1
18                   AEN   9 |             | 32  A0
19                   HRQ  10 |     8237    | 31  Vcc
20                   _CS  11 |             | 30  DB0
21                   CLK  12 |             | 29  DB1
22                 RESET  13 |             | 28  DB2
23                 DACK2  14 |             | 27  DB3
24                 DACK3  15 |             | 26  DB4
25                 DREQ3  16 |             | 25  DACK0
26                 DREQ2  17 |             | 24  DACK1
27                 DREQ1  18 |             | 23  DB5
28                 DREQ0  19 |             | 22  DB6
29                   GND  20 |_____________| 21  DB7
30
31***************************************************************************/
32
33#pragma once
34
35#ifndef __I8279__
36#define __I8279__
37
38#include "emu.h"
39
40
41
42/***************************************************************************
43    DEVICE CONFIGURATION MACROS
44***************************************************************************/
45
46#define MCFG_I8279_ADD(_tag, _clock, _config) \
47   MCFG_DEVICE_ADD(_tag, I8279, _clock) \
48   MCFG_DEVICE_CONFIG(_config)
49
50#define I8279_INTERFACE(_name) \
51   const i8279_interface (_name) =
52
53
54/***************************************************************************
55    TYPE DEFINITIONS
56***************************************************************************/
57
58
59// ======================> i8279_interface
60
61struct i8279_interface
62{
63   devcb_write_line   m_out_hrq_cb;
64   devcb_write_line   m_out_eop_cb;
65
66   /* accessors to main memory */
67   devcb_read8         m_in_memr_cb;
68   devcb_write8      m_out_memw_cb;
69
70   /* channel accessors */
71   devcb_read8         m_in_ior_cb[4];
72   devcb_write8      m_out_iow_cb[4];
73   devcb_write_line   m_out_dack_cb[4];
74};
75
76
77
78// ======================> i8279_device
79
80class i8279_device :  public device_t,
81                      public i8279_interface
82{
83public:
84    // construction/destruction
85    i8279_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
86
87   /* register access */
88   UINT8 i8279_r(UINT32 offset);
89   void i8279_w(UINT32 offset, UINT8 data);
90
91   /* hold acknowledge */
92   void i8279_hlda_w(UINT8 state) { m_hlda = state; }
93
94   /* data request */
95   void i8279_drq_write(int channel, int state);
96
97   void i8279_timerproc();
98
99protected:
100    // device-level overrides
101    virtual void device_config_complete();
102    virtual void device_start();
103    virtual void device_reset();
104    virtual void device_post_load() { }
105    virtual void device_clock_changed() { }
106
107   static TIMER_CALLBACK( i8279_timerproc_callback );
108   static TIMER_CALLBACK( receive_event_callback );
109
110private:
111
112   void i8279_do_read();
113   void i8279_do_write();
114   void i8279_advance();
115   void i8327_set_dack(int channel);
116
117   /* States that the i8279 device can be in */
118   enum dma8279_state
119   {
120      DMA8279_SI,         /* Idle state */
121      DMA8279_S0,         /* HRQ has been triggered, waiting to receive HLDA */
122   //  DMA8279_SW,         /* Wait state */
123      DMA8279_SC,         /* Cascade mode, waiting for peripheral */
124
125      /* Normal transfer states */
126      DMA8279_S1,         /* Output A8-A15; only used when A8-A15 really needs to be output */
127      DMA8279_S2,         /* Output A0-A7 */
128      DMA8279_S3,         /* Initiate read; skipped in compressed timing. On the S2->S3 transition DACK is set. */
129      DMA8279_S4,         /* Perform read/write */
130
131      /* Memory to memory transfer states */
132      DMA8279_S11,      /* Output A8-A15 */
133   //  DMA8279_S12,        /* Output A0-A7 */
134   //  DMA8279_S13,        /* Initiate read */
135   //  DMA8279_S14,        /* Perform read/write */
136   //  DMA8279_S21,        /* Output A8-A15 */
137   //  DMA8279_S22,        /* Output A0-A7 */
138   //  DMA8279_S23,        /* Initiate read */
139   //  DMA8279_S24,        /* Perform read/write */
140   };
141
142   devcb_resolved_write_line   m_out_hrq_func;
143   devcb_resolved_write_line   m_out_eop_func;
144   devcb_resolved_read8      m_in_memr_func;
145   devcb_resolved_write8      m_out_memw_func;
146
147   emu_timer *m_timer;
148
149   struct
150   {
151      devcb_resolved_read8      m_in_ior_func;
152      devcb_resolved_write8      m_out_iow_func;
153      devcb_resolved_write_line   m_out_dack_func;
154      UINT16 m_base_address;
155      UINT16 m_base_count;
156      UINT16 m_address;
157      UINT16 m_count;
158      UINT8 m_mode;
159      int m_high_address_changed;
160   } m_chan[4];
161
162   UINT32 m_msb : 1;
163   UINT32 m_eop : 1;
164   UINT8 m_temp;
165   UINT8 m_temporary_data;
166   UINT8 m_command;
167   UINT8 m_drq;
168   UINT8 m_mask;
169   UINT8 m_hrq;
170   UINT8 m_hlda;
171
172   /* bits  0- 3 :  Terminal count for channels 0-3
173     * bits  4- 7 :  Transfer in progress for channels 0-3 */
174   UINT8 m_status;
175
176   dma8279_state m_state;      /* State the device is currently in */
177   int m_service_channel;      /* Channel we will be servicing */
178   int m_last_service_channel;   /* Previous channel we serviced; used to determine channel priority. */
179};
180
181
182// device type definition
183extern const device_type I8279;
184
185
186
187/***************************************************************************
188    PROTOTYPES
189***************************************************************************/
190
191/* register access */
192READ8_DEVICE_HANDLER( i8279_r );
193WRITE8_DEVICE_HANDLER( i8279_w );
194
195/* hold acknowledge */
196WRITE_LINE_DEVICE_HANDLER( i8279_hlda_w );
197
198/* ready */
199WRITE_LINE_DEVICE_HANDLER( i8279_ready_w );
200
201/* data request */
202WRITE_LINE_DEVICE_HANDLER( i8279_dreq0_w );
203WRITE_LINE_DEVICE_HANDLER( i8279_dreq1_w );
204WRITE_LINE_DEVICE_HANDLER( i8279_dreq2_w );
205WRITE_LINE_DEVICE_HANDLER( i8279_dreq3_w );
206
207/* end of process */
208WRITE_LINE_DEVICE_HANDLER( i8279_eop_w );
209
210#endif
src/mess/mess.mak
r13864r13865
497497   $(MESS_MACHINE)/i82371ab.o   \
498498   $(MESS_MACHINE)/i82439tx.o   \
499499   $(MESS_MACHINE)/i8271.o      \
500   $(MESS_MACHINE)/i8279.o      \
500501   $(MESS_MACHINE)/ieee488.o   \
501502   $(MESS_MACHINE)/isa.o      \
502503   $(MESS_MACHINE)/kb3600.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team