Previous 15994 Revisions Next

r11187 Friday 15th April, 2011 at 13:12:22 UTC by Curt Coder
[PC8001] Refactored to use MAME's Intel 8257 DMA controller. (no whatsnew)
[src/emu/machine]8257dma.c 8257dma.h
[src/mess]mess.mak
[src/mess/drivers]pc8001.c
[src/mess/includes]pc8001.h
[src/mess/machine]i8257.c i8257.h

src/emu/machine/8257dma.c
r11186r11187
190190      }
191191      if (&m_out_iow_func[channel].target != NULL)
192192      {
193         devcb_call_write8(&m_out_iow_func[channel], 0, data);
193         devcb_call_write8(&m_out_iow_func[channel], m_address[channel], data);
194194      }
195195      else
196196      {
r11186r11187
205205   case 2:
206206      if (&m_in_ior_func[channel].target != NULL)
207207      {
208         data = devcb_call_read8(&m_in_ior_func[channel], 0);
208         data = devcb_call_read8(&m_in_ior_func[channel], m_address[channel]);
209209      }
210210      else
211211      {
src/emu/machine/8257dma.h
r11186r11187
6767   devcb_write_line   m_out_mark_func;
6868
6969   /* accessors to main memory */
70   devcb_read8         m_in_memr_func;
71   devcb_write8      m_out_memw_func;
70   devcb_read8         m_in_memr_func; // TODO m_in_memr_func[I8257_NUM_CHANNELS];
71   devcb_write8      m_out_memw_func; // TODO m_out_memw_func[I8257_NUM_CHANNELS];
7272
7373   /* channel accesors */
7474   devcb_read8         m_in_ior_func[I8257_NUM_CHANNELS];
src/mess/machine/i8257.c
r11186r11187
1/***************************************************************************
2
3    Intel 8257 Programmable DMA Controller emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8***************************************************************************/
9
10/*
11
12    TODO:
13
14    - use cr/ar directly
15
16*/
17
18#include "emu.h"
19#include "i8257.h"
20
21/***************************************************************************
22    CONSTANTS
23***************************************************************************/
24
25#define LOG 0
26
27#define I8257_STATUS_TC0   0x01
28#define I8257_STATUS_TC1   0x02
29#define I8257_STATUS_TC2   0x04
30#define I8257_STATUS_TC3   0x08
31#define I8257_STATUS_UP      0x10
32
33#define I8257_MODE_EN0      0x01
34#define I8257_MODE_EN1      0x02
35#define I8257_MODE_EN2      0x04
36#define I8257_MODE_EN3      0x08
37#define I8257_MODE_RP      0x10
38#define I8257_MODE_EW      0x20
39#define I8257_MODE_TCS      0x40
40#define I8257_MODE_AL      0x80
41
42enum
43{
44   STATE_SI,
45   STATE_S0,
46   STATE_S1,
47   STATE_S2,
48   STATE_S3,
49   STATE_SW,
50   STATE_SU,
51   STATE_S4
52};
53
54enum
55{
56   MODE_VERIFY = 0,
57   MODE_WRITE,
58   MODE_READ,
59   MODE_ILLEGAL
60};
61
62/***************************************************************************
63    TYPE DEFINITIONS
64***************************************************************************/
65
66typedef struct _dma8257_t i8257_t;
67struct _dma8257_t
68{
69   devcb_resolved_write_line   out_hrq_func;
70   devcb_resolved_write_line   out_tc_func;
71   devcb_resolved_write_line   out_mark_func;
72   devcb_resolved_read8      in_memr_func[I8257_CHANNELS];
73   devcb_resolved_write8      out_memw_func[I8257_CHANNELS];
74   devcb_resolved_read8      in_ior_func[I8257_CHANNELS];
75   devcb_resolved_write8      out_iow_func[I8257_CHANNELS];
76   devcb_resolved_write_line   out_dack_func[I8257_CHANNELS];
77
78   /* registers */
79   UINT8 mr;               /* mode register */
80   UINT8 sr;               /* status register */
81   UINT16 ar[I8257_CHANNELS];   /* address register */
82   UINT16 cr[I8257_CHANNELS];   /* count register */
83   int fl;                  /* first/last flip-flop */
84
85   /* inputs */
86   int drq[I8257_CHANNELS];   /* data request */
87   int hlda;               /* hold acknowledge */
88   int ready;               /* ready */
89
90   /* outputs */
91   int tc;                  /* terminal count */
92   int mark;               /* mark */
93
94   /* transfer */
95   int state;               /* DMA state */
96   int channel;            /* current channel being serviced */
97   int priority;            /* highest priority channel */
98   UINT8 data;               /* DMA data */
99   UINT16 address;            /* DMA address */
100   UINT16 count;            /* DMA counter */
101   int mode;               /* DMA transfer type */
102
103   /* timers */
104   emu_timer *dma_timer;
105};
106
107/***************************************************************************
108    INLINE FUNCTIONS
109***************************************************************************/
110
111INLINE i8257_t *get_safe_token(device_t *device)
112{
113   assert(device != NULL);
114   assert(device->type() == I8257);
115   return (i8257_t *) downcast<legacy_device_base *>(device)->token();
116}
117
118INLINE const i8257_interface *get_interface(device_t *device)
119{
120   assert(device != NULL);
121   assert((device->type() == I8257));
122   return (const i8257_interface *) device->baseconfig().static_config();
123}
124
125/***************************************************************************
126    IMPLEMENTATION
127***************************************************************************/
128
129static void set_hrq(device_t *device, int state)
130{
131   i8257_t *i8257 = get_safe_token(device);
132
133   if (LOG) logerror("I8257 '%s' Hold Request: %u\n", device->tag(), state);
134
135   devcb_call_write_line(&i8257->out_hrq_func, state);
136}
137
138static void set_tc(device_t *device, int state)
139{
140   i8257_t *i8257 = get_safe_token(device);
141
142   if (i8257->tc != state)
143   {
144      if (LOG) logerror("I8257 '%s' Terminal Count: %u\n", device->tag(), state);
145      i8257->tc = state;
146      devcb_call_write_line(&i8257->out_tc_func, state);
147   }
148}
149
150static void set_mark(device_t *device, int state)
151{
152   i8257_t *i8257 = get_safe_token(device);
153
154   if (i8257->mark != state)
155   {
156      if (LOG) logerror("I8257 '%s' Mark: %u\n", device->tag(), state);
157      i8257->mark = state;
158      devcb_call_write_line(&i8257->out_mark_func, state);
159   }
160}
161
162static void set_dack(device_t *device, int active_channel)
163{
164   i8257_t *i8257 = get_safe_token(device);
165   int ch;
166
167   for (ch = 0; ch < I8257_CHANNELS; ch++)
168   {
169      int state = (ch != active_channel);
170
171      if (LOG) logerror("I8257 '%s' DMA Acknowledge %u: %u\n", device->tag(), ch, state);
172
173      devcb_call_write_line(&i8257->out_dack_func[ch], state);
174   }
175}
176
177static int sample_drq(device_t *device)
178{
179   i8257_t *i8257 = get_safe_token(device);
180   int ch;
181
182   for (ch = 0; ch < I8257_CHANNELS; ch++)
183   {
184      if (i8257->drq[ch] && BIT(i8257->mr, ch))
185      {
186         return 1;
187      }
188   }
189
190   return 0;
191}
192
193static void resolve_priorities(device_t *device)
194{
195   i8257_t *i8257 = get_safe_token(device);
196   int i;
197
198   for (i = 0; i < I8257_CHANNELS; i++)
199   {
200      int ch = (i + i8257->priority) % I8257_CHANNELS;
201
202      if (i8257->drq[ch] && BIT(i8257->mr, ch))
203      {
204         i8257->channel = ch;
205         i8257->address = i8257->ar[ch];
206         i8257->count = i8257->cr[ch] & 0x3fff;
207         i8257->mode = i8257->cr[ch] >> 14;
208         break;
209      }
210   }
211}
212
213static void dma_read(device_t *device)
214{
215   i8257_t *i8257 = get_safe_token(device);
216
217   switch (i8257->mode)
218   {
219   case MODE_VERIFY:
220      break;
221
222   case MODE_WRITE:
223      i8257->data = devcb_call_read8(&i8257->in_memr_func[i8257->channel], i8257->address);
224      if (LOG) logerror("I8257 '%s' DMA Memory Read %04x: %02x\n", device->tag(), i8257->address, i8257->data);
225      break;
226
227   case MODE_READ:
228      i8257->data = devcb_call_read8(&i8257->in_ior_func[i8257->channel], i8257->address);
229      if (LOG) logerror("I8257 '%s' DMA I/O Read %04x: %02x\n", device->tag(), i8257->address, i8257->data);
230      break;
231
232   case MODE_ILLEGAL:
233      break;
234   }
235}
236
237static void dma_write(device_t *device)
238{
239   i8257_t *i8257 = get_safe_token(device);
240
241   switch (i8257->mode)
242   {
243   case MODE_VERIFY:
244      break;
245
246   case MODE_WRITE:
247      devcb_call_write8(&i8257->out_iow_func[i8257->channel], i8257->address, i8257->data);
248      if (LOG) logerror("I8257 '%s' DMA I/O Write %04x: %02x\n", device->tag(), i8257->address, i8257->data);
249      break;
250
251   case MODE_READ:
252      devcb_call_write8(&i8257->out_memw_func[i8257->channel], i8257->address, i8257->data);
253      if (LOG) logerror("I8257 '%s' DMA Memory Write %04x: %02x\n", device->tag(), i8257->address, i8257->data);
254      break;
255
256   case MODE_ILLEGAL:
257      break;
258   }
259}
260
261/*-------------------------------------------------
262    TIMER_CALLBACK( dma_tick )
263-------------------------------------------------*/
264
265static TIMER_CALLBACK( dma_tick )
266{
267   device_t *device = (device_t *)ptr;
268   i8257_t *i8257 = get_safe_token(device);
269   int drq = 0;
270
271   switch (i8257->state)
272   {
273   case STATE_SI:
274      /* sample DRQn lines */
275      drq = sample_drq(device);
276
277      /* set HRQ if DRQn = 1 */
278      if (drq)
279      {
280         set_hrq(device, 1);
281         i8257->state = STATE_S0;
282      }
283      break;
284
285   case STATE_S0:
286      /* sample HLDA */
287      if (i8257->hlda)
288      {
289         i8257->state = STATE_S1;
290      }
291
292      /* resolve DRQ priorities */
293      resolve_priorities(device);
294      break;
295
296   case STATE_S1:
297      /* present and data upper address */
298      /* present lower address */
299      i8257->state = STATE_S2;
300      break;
301
302   case STATE_S2:
303      /* activate DACKn */
304      set_dack(device, i8257->channel);
305
306      /* activate read command */
307      dma_read(device);
308
309      /* advanced write command */
310      if (i8257->mr & I8257_MODE_EW)
311      {
312         dma_write(device);
313      }
314
315      i8257->state = STATE_S3;
316      break;
317
318   case STATE_S3:
319      /* activate write command */
320      if (!(i8257->mr & I8257_MODE_EW))
321      {
322         dma_write(device);
323      }
324
325      i8257->address++;
326      i8257->count--;
327
328      /* activate MARK */
329      switch (i8257->count & 0xff)
330      {
331      case 0:   case 0x80:
332         set_mark(device, 1);
333         break;
334      }
335
336      /* activate TC */
337      if (i8257->count == 0)
338      {
339         set_tc(device, 1);
340      }
341
342      if (!i8257->ready)
343      {
344         i8257->state = STATE_SW;
345      }
346      else if (i8257->tc && (i8257->channel == 2) && (i8257->mr & I8257_MODE_AL))
347      {
348         i8257->state = STATE_SU;
349      }
350      else
351      {
352         i8257->state = STATE_S4;
353      }
354      break;
355
356   case STATE_SW:
357      /* sample READY line */
358      if (i8257->ready)
359      {
360         if (i8257->tc && (i8257->channel == 2) && (i8257->mr & I8257_MODE_AL))
361         {
362            i8257->state = STATE_SU;
363         }
364         else
365         {
366            i8257->state = STATE_S4;
367         }
368      }
369      break;
370
371   case STATE_SU:
372      i8257->sr |= I8257_STATUS_UP;
373
374      /* auto load channel 2 parameters */
375      i8257->ar[2] = i8257->ar[3];
376      i8257->cr[2] = i8257->cr[3];
377
378      if (LOG)
379      {
380         logerror("I8257 '%s' DMA Channel 2 Address Register: %04x\n", device->tag(), i8257->ar[2]);
381         logerror("I8257 '%s' DMA Channel 2 Count Register: %04x\n", device->tag(), i8257->cr[2] & 0x3fff);
382         logerror("I8257 '%s' DMA Channel 2 Mode: %u\n", device->tag(), i8257->cr[2] >> 14);
383      }
384
385      i8257->state = STATE_S4;
386      break;
387
388   case STATE_S4:
389      i8257->sr &= ~I8257_STATUS_UP;
390
391      if (i8257->tc)
392      {
393         /* reset enable for channel n if TC stop and TC are active */
394         if ((i8257->mr & I8257_MODE_TCS) &&
395            !((i8257->channel == 2) && (i8257->mr & I8257_MODE_AL)))
396         {
397            i8257->mr &= ~(1 << i8257->channel);
398            if (LOG) logerror("I8257 '%s' DMA Channel %u: disabled\n", device->tag(), i8257->channel);
399         }
400
401         if (i8257->mr & I8257_MODE_RP)
402         {
403            i8257->priority = (i8257->channel + 1) % I8257_CHANNELS;
404         }
405
406         /* resolve DRQ priorities */
407         resolve_priorities(device);
408      }
409
410      /* deactivate DACKn, MARK and TC */
411      set_dack(device, -1);
412      set_mark(device, 0);
413      set_tc(device, 0);
414
415      /* sample DRQn */
416      drq = sample_drq(device);
417
418      /* reset HRQ if HLDA = 0 or DRQ = 0 */
419      if (!i8257->hlda || !drq)
420      {
421         set_hrq(device, 0);
422         i8257->state = STATE_SI;
423         i8257->dma_timer->enable(0);
424      }
425      else
426      {
427         i8257->state = STATE_S1;
428      }
429      break;
430   }
431}
432
433READ8_DEVICE_HANDLER( i8257_r )
434{
435   i8257_t *i8257 = get_safe_token(device);
436   UINT8 data = 0;
437   int ch;
438
439   switch (offset & 0x0f)
440   {
441   case 0:
442   case 2:
443   case 4:
444   case 6:
445      ch = offset / 2;
446
447      if (i8257->fl)
448      {
449         data = i8257->ar[ch] >> 8;
450      }
451      else
452      {
453         data = i8257->ar[ch] & 0xff;
454      }
455
456      i8257->fl = !i8257->fl;
457      break;
458
459   case 1:
460   case 3:
461   case 5:
462   case 7:
463      ch = (offset - 1) / 2;
464
465      if (i8257->fl)
466      {
467         data = i8257->cr[ch] >> 8;
468      }
469      else
470      {
471         data = i8257->cr[ch] & 0xff;
472      }
473
474      i8257->fl = !i8257->fl;
475      break;
476
477   case 8:
478      data = i8257->sr;
479      i8257->sr &= ~(I8257_STATUS_TC3 | I8257_STATUS_TC2 | I8257_STATUS_TC1 | I8257_STATUS_TC0);
480      break;
481   }
482
483   return data;
484}
485
486WRITE8_DEVICE_HANDLER( i8257_w )
487{
488   i8257_t *i8257 = get_safe_token(device);
489   int ch;
490
491   switch (offset & 0x0f)
492   {
493   case 0:
494   case 2:
495   case 4:
496   case 6:
497      ch = offset / 2;
498
499      if (i8257->fl)
500      {
501         i8257->ar[ch] = (data << 8) | (i8257->ar[ch] & 0xff);
502         if (LOG) logerror("I8257 '%s' DMA Channel %u Address Register: %04x\n", device->tag(), ch, i8257->ar[ch]);
503      }
504      else
505      {
506         i8257->ar[ch] = (i8257->ar[ch] & 0xff00) | data;
507      }
508
509      if ((i8257->mr & I8257_MODE_AL) && (ch == 2))
510      {
511         i8257->ar[3] = i8257->ar[2];
512      }
513
514      i8257->fl = !i8257->fl;
515      break;
516
517   case 1:
518   case 3:
519   case 5:
520   case 7:
521      ch = (offset - 1) / 2;
522
523      if (i8257->fl)
524      {
525         i8257->cr[ch] = (data << 8) | (i8257->cr[ch] & 0xff);
526         if (LOG) logerror("I8257 '%s' DMA Channel %u Count Register: %04x\n", device->tag(), ch, i8257->cr[ch] & 0x3fff);
527         if (LOG) logerror("I8257 '%s' DMA Channel %u Mode: %u\n", device->tag(), ch, i8257->cr[ch] >> 14);
528      }
529      else
530      {
531         i8257->cr[ch] = (i8257->cr[ch] & 0xff00) | data;
532      }
533
534      if ((i8257->mr & I8257_MODE_AL) && (ch == 2))
535      {
536         i8257->cr[3] = i8257->cr[2];
537      }
538
539      i8257->fl = !i8257->fl;
540      break;
541
542   case 8:
543      i8257->mr = data;
544      i8257->fl = 0;
545
546      if ((i8257->state == STATE_SI) && sample_drq(device))
547      {
548         i8257->dma_timer->enable(1);
549      }
550
551      if (LOG)
552      {
553         logerror("I8257 '%s' DMA Channel 0: %s\n", device->tag(), BIT(i8257->mr, 0) ? "enabled" : "disabled");
554         logerror("I8257 '%s' DMA Channel 1: %s\n", device->tag(), BIT(i8257->mr, 1) ? "enabled" : "disabled");
555         logerror("I8257 '%s' DMA Channel 2: %s\n", device->tag(), BIT(i8257->mr, 2) ? "enabled" : "disabled");
556         logerror("I8257 '%s' DMA Channel 3: %s\n", device->tag(), BIT(i8257->mr, 3) ? "enabled" : "disabled");
557         if (BIT(i8257->mr, 4)) logerror("I8257 '%s' Rotating Priority\n", device->tag());
558         if (BIT(i8257->mr, 5)) logerror("I8257 '%s' Extended Write\n", device->tag());
559         if (BIT(i8257->mr, 6)) logerror("I8257 '%s' TC Stop\n", device->tag());
560         if (BIT(i8257->mr, 7)) logerror("I8257 '%s' Auto Load\n", device->tag());
561      }
562      break;
563   }
564}
565
566WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w )
567{
568   i8257_t *i8257 = get_safe_token(device);
569
570   i8257->hlda = state;
571
572   if (LOG) logerror("I8257 '%s' Hold Acknowledge: %u\n", device->tag(), state);
573}
574
575WRITE_LINE_DEVICE_HANDLER( i8257_ready_w )
576{
577   i8257_t *i8257 = get_safe_token(device);
578
579   i8257->ready = state;
580
581   if (LOG) logerror("I8257 '%s' Ready: %u\n", device->tag(), state);
582}
583
584static void drq_w(device_t *device, int ch, int state)
585{
586   i8257_t *i8257 = get_safe_token(device);
587
588   i8257->drq[ch] = state;
589
590   if (LOG) logerror("I8257 '%s' Data Request %u: %u\n", device->tag(), ch, state);
591
592   if (state && (i8257->state == STATE_SI))
593   {
594      i8257->dma_timer->enable(1);
595   }
596}
597
598WRITE_LINE_DEVICE_HANDLER( i8257_drq0_w ) { drq_w(device, 0, state); }
599WRITE_LINE_DEVICE_HANDLER( i8257_drq1_w ) { drq_w(device, 1, state); }
600WRITE_LINE_DEVICE_HANDLER( i8257_drq2_w ) { drq_w(device, 2, state); }
601WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w ) { drq_w(device, 3, state); }
602
603/*-------------------------------------------------
604    DEVICE_START( i8257 )
605-------------------------------------------------*/
606
607static DEVICE_START( i8257 )
608{
609   i8257_t *i8257 = get_safe_token(device);
610   i8257_interface *intf = (i8257_interface *)device->baseconfig().static_config();
611   int ch;
612
613   /* resolve callbacks */
614   devcb_resolve_write_line(&i8257->out_hrq_func, &intf->out_hrq_func, device);
615   devcb_resolve_write_line(&i8257->out_tc_func, &intf->out_tc_func, device);
616   devcb_resolve_write_line(&i8257->out_mark_func, &intf->out_mark_func, device);
617
618   for (ch = 0; ch < I8257_CHANNELS; ch++)
619   {
620      devcb_resolve_read8(&i8257->in_memr_func[ch], &intf->in_memr_func[ch], device);
621      devcb_resolve_write8(&i8257->out_memw_func[ch], &intf->out_memw_func[ch], device);
622      devcb_resolve_read8(&i8257->in_ior_func[ch], &intf->in_ior_func[ch], device);
623      devcb_resolve_write8(&i8257->out_iow_func[ch], &intf->out_iow_func[ch], device);
624      devcb_resolve_write_line(&i8257->out_dack_func[ch], &intf->out_dack_func[ch], device);
625   }
626
627   /* create the DMA timer */
628   i8257->dma_timer = device->machine().scheduler().timer_alloc(FUNC(dma_tick), (void *)device);
629   i8257->dma_timer->adjust(attotime::zero, 0, attotime::from_hz(device->clock()));
630
631   /* register for state saving */
632   device->save_item(NAME(i8257->mr));
633   device->save_item(NAME(i8257->sr));
634   device->save_item(NAME(i8257->ar));
635   device->save_item(NAME(i8257->cr));
636   device->save_item(NAME(i8257->fl));
637   device->save_item(NAME(i8257->drq));
638   device->save_item(NAME(i8257->hlda));
639   device->save_item(NAME(i8257->ready));
640   device->save_item(NAME(i8257->tc));
641   device->save_item(NAME(i8257->mark));
642   device->save_item(NAME(i8257->state));
643   device->save_item(NAME(i8257->channel));
644   device->save_item(NAME(i8257->priority));
645   device->save_item(NAME(i8257->data));
646   device->save_item(NAME(i8257->address));
647   device->save_item(NAME(i8257->count));
648   device->save_item(NAME(i8257->mode));
649}
650
651/*-------------------------------------------------
652    DEVICE_RESET( i8257 )
653-------------------------------------------------*/
654
655static DEVICE_RESET( i8257 )
656{
657   i8257_t *i8257 = get_safe_token(device);
658
659   i8257->fl = 0;
660   i8257->mr = 0;
661   i8257->sr = 0;
662   i8257->state = STATE_SI;
663   i8257->priority = 0;
664   i8257->ready = 1;
665
666   set_hrq(device, 0);
667   set_mark(device, 0);
668   set_tc(device, 0);
669   set_dack(device, -1);
670
671   i8257->dma_timer->enable(0);
672}
673
674/*-------------------------------------------------
675    DEVICE_GET_INFO( i8257 )
676-------------------------------------------------*/
677
678DEVICE_GET_INFO( i8257 )
679{
680   switch (state)
681   {
682      /* --- the following bits of info are returned as 64-bit signed integers --- */
683      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(i8257_t);               break;
684      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
685
686      /* --- the following bits of info are returned as pointers to data or functions --- */
687      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(i8257);      break;
688      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
689      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(i8257);      break;
690
691      /* --- the following bits of info are returned as NULL-terminated strings --- */
692      case DEVINFO_STR_NAME:                     strcpy(info->s, "Intel 8257");            break;
693      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Intel 8085");            break;
694      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
695      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
696      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");      break;
697   }
698}
699
700DEFINE_LEGACY_DEVICE(I8257, i8257);
src/mess/machine/i8257.h
r11186r11187
1/***************************************************************************
2
3    Intel 8257 Programmable DMA Controller emulation
4
5    Copyright MESS 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                  MARK   5 |             | 36  TC
15                 READY   6 |             | 35  A3
16                  HLDA   7 |             | 34  A2
17                 ADSTB   8 |             | 33  A1
18                   AEN   9 |             | 32  A0
19                   HRQ  10 |     8257    | 31  Vcc
20                   _CS  11 |             | 30  D0
21                   CLK  12 |             | 29  D1
22                 RESET  13 |             | 28  D2
23                _DACK2  14 |             | 27  D3
24                _DACK3  15 |             | 26  D4
25                  DRQ3  16 |             | 25  _DACK0
26                  DRQ2  17 |             | 24  _DACK1
27                  DRQ1  18 |             | 23  D5
28                  DRQ0  19 |             | 22  D6
29                   GND  20 |_____________| 21  D7
30
31***************************************************************************/
32
33#ifndef __I8257__
34#define __I8257__
35
36#include "devcb.h"
37
38/***************************************************************************
39    MACROS / CONSTANTS
40***************************************************************************/
41
42DECLARE_LEGACY_DEVICE(I8257, i8257);
43
44#define MCFG_I8257_ADD(_tag, _clock, _config) \
45   MCFG_DEVICE_ADD(_tag, I8257, _clock) \
46   MCFG_DEVICE_CONFIG(_config)
47
48#define I8257_INTERFACE(_name) \
49   const i8257_interface (_name) =
50
51#define I8257_MEMORY_HANDLER(_tag, _space, _func) \
52   { DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
53     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
54     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
55     DEVCB_MEMORY_HANDLER(_tag, _space, _func) \
56   }
57
58#define I8257_CHANNELS   4
59
60/***************************************************************************
61    TYPE DEFINITIONS
62***************************************************************************/
63
64typedef struct _i8257_interface i8257_interface;
65struct _i8257_interface
66{
67   devcb_write_line   out_hrq_func;
68   devcb_write_line   out_tc_func;
69   devcb_write_line   out_mark_func;
70
71   /* memory */
72   devcb_read8         in_memr_func[I8257_CHANNELS];
73   devcb_write8      out_memw_func[I8257_CHANNELS];
74
75   /* I/O */
76   devcb_read8         in_ior_func[I8257_CHANNELS];
77   devcb_write8      out_iow_func[I8257_CHANNELS];
78
79   /* DMA acknowledge */
80   devcb_write_line   out_dack_func[I8257_CHANNELS];
81};
82
83/***************************************************************************
84    PROTOTYPES
85***************************************************************************/
86
87/* register access */
88READ8_DEVICE_HANDLER( i8257_r );
89WRITE8_DEVICE_HANDLER( i8257_w );
90
91/* hold acknowledge */
92WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w );
93
94/* ready */
95WRITE_LINE_DEVICE_HANDLER( i8257_ready_w );
96
97/* data request */
98WRITE_LINE_DEVICE_HANDLER( i8257_drq0_w );
99WRITE_LINE_DEVICE_HANDLER( i8257_drq1_w );
100WRITE_LINE_DEVICE_HANDLER( i8257_drq2_w );
101WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w );
102
103#endif
src/mess/includes/pc8001.h
r11186r11187
99#include "cpu/z80/z80.h"
1010#include "imagedev/cassette.h"
1111#include "machine/ctronics.h"
12#include "machine/i8257.h"
12#include "machine/8257dma.h"
1313#include "machine/i8255a.h"
1414#include "machine/msm8251.h"
1515#include "machine/ram.h"
r11186r11187
5858   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
5959
6060   DECLARE_WRITE8_MEMBER( port30_w );
61   DECLARE_WRITE_LINE_MEMBER( crtc_drq_w );
6162   DECLARE_WRITE_LINE_MEMBER( hrq_w );
63   DECLARE_WRITE8_MEMBER( dma_mem_w );
64   DECLARE_READ8_MEMBER( dma_io_r );
65   DECLARE_WRITE8_MEMBER( dma_io_w );
6266   
6367   /* video state */
6468   UINT8 *m_char_rom;
src/mess/mess.mak
r11186r11187
11691169   $(MESS_DRIVERS)/pc8401a.o   \
11701170   $(MESS_VIDEO)/pc8401a.o      \
11711171   $(MESS_DRIVERS)/pc8001.o   \
1172   $(MESS_MACHINE)/i8257.o      \
11731172   $(MESS_DRIVERS)/pc8801.o   \
11741173   $(MESS_DRIVERS)/pc88va.o   \
11751174   $(MESS_DRIVERS)/pc9801.o   \
src/mess/drivers/pc8001.c
r11186r11187
442442   i8257_hlda_w(m_dma, state);
443443}
444444
445static UINT8 memory_read_byte(address_space *space, offs_t address) { return space->read_byte(address); }
446static void memory_write_byte(address_space *space, offs_t address, UINT8 data) { space->write_byte(address, data); }
445WRITE8_MEMBER( pc8001_state::dma_mem_w )
446{
447   //if (channel == 2)
448   {
449      m_crtc->dack_w(space, offset, data);
450   }
451}
447452
448static I8257_INTERFACE( pc8001_8257_intf )
453READ8_MEMBER( pc8001_state::dma_io_r )
449454{
455   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
456   
457   return program->read_byte(offset);
458}
459
460WRITE8_MEMBER( pc8001_state::dma_io_w )
461{
462   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
463   
464   program->write_byte(offset, data);
465}
466
467static I8257_INTERFACE( dmac_intf )
468{
450469   DEVCB_DRIVER_LINE_MEMBER(pc8001_state, hrq_w),
451470   DEVCB_NULL,
452471   DEVCB_NULL,
453   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
454   { DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_MEMBER(UPD3301_TAG, upd3301_device, dack_w), DEVCB_NULL },
455   I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_read_byte),
456   I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_write_byte),
457   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }
472   DEVCB_NULL,
473   DEVCB_DRIVER_MEMBER(pc8001_state, dma_mem_w),
474   { DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_r), DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_r), DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_r), DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_r) },
475   { DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_w), DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_w), DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_w), DEVCB_DRIVER_MEMBER(pc8001_state, dma_io_w) },
458476};
459477
460478/* uPD1990A Interface */
r11186r11187
556574   /* devices */
557575   MCFG_MSM8251_ADD(I8251_TAG, uart_intf)
558576   MCFG_I8255A_ADD(I8255A_TAG, ppi_intf)
559   MCFG_I8257_ADD(I8257_TAG, 4000000, pc8001_8257_intf)
577   MCFG_I8257_ADD(I8257_TAG, 4000000, dmac_intf)
560578   MCFG_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, pc8001_upd1990a_intf)
561579   MCFG_UPD3301_ADD(UPD3301_TAG, 14318180, pc8001_upd3301_intf)
562580
r11186r11187
593611   /* devices */
594612   MCFG_MSM8251_ADD(I8251_TAG, uart_intf)
595613   MCFG_I8255A_ADD(I8255A_TAG, ppi_intf)
596   MCFG_I8257_ADD(I8257_TAG, 4000000, pc8001_8257_intf)
614   MCFG_I8257_ADD(I8257_TAG, 4000000, dmac_intf)
597615   MCFG_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, pc8001_upd1990a_intf)
598616   MCFG_UPD3301_ADD(UPD3301_TAG, 14318180, pc8001_upd3301_intf)
599617

Previous 15994 Revisions Next


© 1998-2018 The MESS Team