Previous 15994 Revisions Next

r2436 Tuesday 22nd April, 2008 at 16:19:51 UTC by Wilbert Pol
Renamed uart8250 to ins8250.
[src/mess]mess.mak
[src/mess/drivers]at.c avigo.c bebox.c pc.c pcw16.c svi318.c
[src/mess/includes]bebox.h pc.h pc_mouse.h svi318.h
[src/mess/machine]bebox.c ins8250.c* ins8250.h* pc.c pc_mouse.c svi318.c uart8250.c uart8250.h

src/mess/includes/bebox.h
r2435r2436
99#ifndef BEBOX_H_
1010#define BEBOX_H_
1111
12#include "machine/uart8250.h"
12#include "machine/ins8250.h"
1313
1414/*----------- defined in machine/bebox.c -----------*/
1515
src/mess/includes/pc_mouse.h
r2435r2436
1111extern "C" {
1212#endif
1313
14#include "machine/uart8250.h"
14#include "machine/ins8250.h"
1515
1616typedef enum
1717{
src/mess/includes/svi318.h
r2435r2436
1010#define SVI318_H_
1111
1212#include "machine/8255ppi.h"
13#include "machine/uart8250.h"
13#include "machine/ins8250.h"
1414
1515/*----------- defined in machine/svi318.c -----------*/
1616
1717extern const ppi8255_interface svi318_ppi8255_interface;
18extern const ins8250_interface svi318_uart8250_interface[2];
18extern const ins8250_interface svi318_ins8250_interface[2];
1919
2020DRIVER_INIT( svi318 );
2121MACHINE_START( svi318_pal );
src/mess/includes/pc.h
r2435r2436
77#ifndef PC_H_
88#define PC_H_
99
10#include "machine/uart8250.h"
10#include "machine/ins8250.h"
1111
1212/*----------- defined in machine/pc.c -----------*/
1313
src/mess/machine/uart8250.c
r2435r2436
1/**********************************************************************
2
3   National Semiconductor 8250 UART interface and emulation
4
5   More information on the different models can be found in
6   section 1.6 at this location:
7     http://www.freebsd.org/doc/en_US.ISO8859-1/articles/serial-uart/
8
9Model overview (from page above):
10
11INS8250
12This part was used in the original IBM PC and IBM PC/XT. The original name
13for this part was the INS8250 ACE (Asynchronous Communications Element) and
14it is made from NMOS technology.
15
16The 8250 uses eight I/O ports and has a one-byte send and a one-byte receive
17buffer. This original UART has several race conditions and other flaws. The
18original IBM BIOS includes code to work around these flaws, but this made
19the BIOS dependent on the flaws being present, so subsequent parts like the
208250A, 16450 or 16550 could not be used in the original IBM PC or IBM PC/XT.
21
22INS8250-B
23This is the slower speed of the INS8250 made from NMOS technology. It contains
24the same problems as the original INS8250.
25
26INS8250A
27An improved version of the INS8250 using XMOS technology with various functional
28flaws corrected. The INS8250A was used initially in PC clone computers by vendors
29who used “clean” BIOS designs. Because of the corrections in the chip, this part
30could not be used with a BIOS compatible with the INS8250 or INS8250B.
31
32INS82C50A
33This is a CMOS version (low power consumption) of the INS8250A and has similar
34functional characteristics.
35
36NS16450
37Same as NS8250A with improvements so it can be used with faster CPU bus designs.
38IBM used this part in the IBM AT and updated the IBM BIOS to no longer rely on
39the bugs in the INS8250.
40
41NS16C450
42This is a CMOS version (low power consumption) of the NS16450.
43
44NS16550
45Same as NS16450 with a 16-byte send and receive buffer but the buffer design
46was flawed and could not be reliably be used.
47
48NS16550A
49Same as NS16550 with the buffer flaws corrected. The 16550A and its successors
50have become the most popular UART design in the PC industry, mainly due to
51its ability to reliably handle higher data rates on operating systems with
52sluggish interrupt response times.
53
54NS16C552
55This component consists of two NS16C550A CMOS UARTs in a single package.
56
57PC16550D
58Same as NS16550A with subtle flaws corrected. This is revision D of the
5916550 family and is the latest design available from National Semiconductor.
60
61
62Known issues:
63- MESS does currently not handle all these model specific features.
64
65
66History:
67   KT - 14-Jun-2000 - Improved Interrupt setting/clearing
68   KT - moved into seperate file so it can be used in Super I/O emulation and
69      any other system which uses a PC type COM port
70   KT - 24-Jun-2000 - removed pc specific input port tests. More compatible
71      with PCW16 and PCW16 doesn't requre the PC input port definitions
72      which are not required by the PCW16 hardware
73
74**********************************************************************/
75
76#include "driver.h"
77#include "machine/uart8250.h"
78#include "includes/pc_mouse.h"
79#include "memconv.h"
80
81
82#define LOG(LEVEL,N,M,A)  \
83if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A;
84
85
86/* device types */
87enum {
88   TYPE_INS8250 = 0,
89   TYPE_INS8250A,
90   TYPE_NS16450,
91   TYPE_NS16550,
92   TYPE_NS16550A,
93   TYPE_PC16550D,
94
95   NUM_TYPES
96};
97
98
99/* device tags */
100static const char * const device_tags[NUM_TYPES] = { "ins8250", "ins8250a", "ns16450", "ns16550", "ns16550a", "pc16550d" };
101
102
103#define VERBOSE_COM 0
104#define COM_LOG(n,m,a) LOG(VERBOSE_COM,n,m,a)
105
106typedef struct {
107   const ins8250_interface *interface;
108   int   device_type;
109
110   UINT8 thr;  /* 0 -W transmitter holding register */
111   UINT8 rbr; /* 0 R- receiver buffer register */
112   UINT8 ier;  /* 1 RW interrupt enable register */
113   UINT8 dll;  /* 0 RW divisor latch lsb (if DLAB = 1) */
114   UINT8 dlm;  /* 1 RW divisor latch msb (if DLAB = 1) */
115   UINT8 iir;  /* 2 R- interrupt identification register */
116   UINT8 lcr;  /* 3 RW line control register (bit 7: DLAB) */
117   UINT8 mcr;  /* 4 RW modem control register */
118   UINT8 lsr;  /* 5 R- line status register */
119   UINT8 msr;  /* 6 R- modem status register */
120   UINT8 scr;  /* 7 RW scratch register */
121
122/* holds int pending state for com */
123   UINT8 int_pending;
124
125   // sending circuit
126   struct {
127      int active;
128      UINT8 data;
129      double time;
130   } send;
131} ins8250_t;
132
133/* int's pending */
134#define COM_INT_PENDING_RECEIVED_DATA_AVAILABLE   0x0001
135#define COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY 0x0002
136#define COM_INT_PENDING_RECEIVER_LINE_STATUS 0x0004
137#define COM_INT_PENDING_MODEM_STATUS_REGISTER 0x0008
138
139#define DLAB(n) (uart[n].lcr&0x80) //divisor latch access bit
140#define LOOP(n) (ins8250->mcr&0x10)
141
142
143
144INLINE ins8250_t *get_safe_token(const device_config *device) {
145   assert( device != NULL );
146   assert( device->token != NULL );
147   assert( ( device->type == DEVICE_GET_INFO_NAME(ins8250) ) ||
148         ( device->type == DEVICE_GET_INFO_NAME(ins8250a) ) ||
149         ( device->type == DEVICE_GET_INFO_NAME(ns16450) ) ||
150         ( device->type == DEVICE_GET_INFO_NAME(ns16550) ) ||
151         ( device->type == DEVICE_GET_INFO_NAME(ns16550a) ) ||
152         ( device->type == DEVICE_GET_INFO_NAME(pc16550d) ) );
153   return ( ins8250_t *) device->token;
154}
155
156
157/* setup iir with the priority id */
158static void ins8250_setup_iir(const device_config *device)
159{
160   ins8250_t   *ins8250 = get_safe_token(device);
161
162   ins8250->iir &= ~(0x04|0x02);
163
164   /* highest to lowest */
165   if (ins8250->int_pending & COM_INT_PENDING_RECEIVER_LINE_STATUS)
166   {
167      ins8250->iir |=0x04|0x02;
168      return;
169   }
170
171   if (ins8250->int_pending & COM_INT_PENDING_RECEIVED_DATA_AVAILABLE)
172   {
173      ins8250->iir |=0x04;
174      return;
175   }
176
177   if (ins8250->int_pending & COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY)
178   {
179      ins8250->iir |=0x02;
180      return;
181   }
182
183   /* modem status has both bits clear */
184}
185
186
187/* ints will continue to be set for as long as there are ints pending */
188static void ins8250_update_interrupt(const device_config *device)
189{
190   ins8250_t   *ins8250 = get_safe_token(device);
191   int state;
192
193   /* disable int output? */
194   if ((ins8250->mcr & 0x08) == 0)
195      return;
196
197   /* if any bits are set and are enabled */
198   if (((ins8250->int_pending&ins8250->ier) & 0x0f) != 0)
199   {
200      /* trigger next highest priority int */
201
202      /* set int */
203      state = 1;
204
205      ins8250_setup_iir(device);
206
207      /* int pending */
208      ins8250->iir |= 0x01;
209   }
210   else
211   {
212      /* clear int */
213      state = 0;
214
215      /* no ints pending */
216      ins8250->iir &= ~0x01;
217      /* priority level */
218      ins8250->iir &= ~(0x04|0x02);
219   }
220
221
222   /* set or clear the int */
223   if (ins8250->interface->interrupt)
224      ins8250->interface->interrupt(device, state);
225}
226
227
228
229/* set pending bit and trigger int */
230static void ins8250_trigger_int(const device_config *device, int flag)
231{
232   ins8250_t   *ins8250 = get_safe_token(device);
233
234   ins8250->int_pending |= flag;
235   ins8250_update_interrupt(device);
236}
237
238
239
240/* clear pending bit, if any ints are pending, then int will be triggered, otherwise it
241will be cleared */
242static void ins8250_clear_int(const device_config *device, int flag)
243{
244   ins8250_t   *ins8250 = get_safe_token(device);
245
246   ins8250->int_pending &= ~flag;
247   ins8250_update_interrupt(device);
248}
249
250
251WRITE8_DEVICE_HANDLER( ins8250_w )
252{
253    static const char P[8] = "NONENHNL";  /* names for parity select */
254   ins8250_t   *ins8250 = get_safe_token(device);
255    int tmp;
256
257   switch (offset)
258   {
259      case 0:
260         if (ins8250->lcr & 0x80)
261         {
262            ins8250->dll = data;
263            tmp = ins8250->dlm * 256 + ins8250->dll;
264            COM_LOG(1,"COM_dll_w",("COM $%02x: [$%04x = %d baud]\n",
265                data, tmp, (tmp)?(int)(ins8250->interface->clockin/16/tmp):0));
266         }
267         else
268         {
269            ins8250->thr = data;
270            COM_LOG(2,"COM_thr_w",("COM $%02x\n", data));
271
272            if (LOOP(n))
273            {
274               ins8250->lsr |= 1;
275               ins8250->rbr = data;
276            }
277            /* writing to thr will clear the int */
278            ins8250_clear_int(device, COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
279         }
280         break;
281      case 1:
282         if (ins8250->lcr & 0x80)
283         {
284            ins8250->dlm = data;
285            tmp = ins8250->dlm * 256 + ins8250->dll;
286                COM_LOG(1,"COM_dlm_w",("COM $%02x: [$%04x = %d baud]\n",
287               data, tmp, (tmp)?(int)(ins8250->interface->clockin/16/tmp):0));
288         }
289         else
290         {
291            ins8250->ier = data;
292            COM_LOG(2,"COM_ier_w",("COM $%02x: enable int on RX %d, THRE %d, RLS %d, MS %d\n",
293               data, data&1, (data>>1)&1, (data>>2)&1, (data>>3)&1));
294         }
295            break;
296      case 2:
297         COM_LOG(1,"COM_fcr_w",("COM $%02x (16550 only)\n", data));
298            break;
299      case 3:
300         ins8250->lcr = data;
301         COM_LOG(1,"COM_lcr_w",("COM $%02x word length %d, stop bits %d, parity %c, break %d, DLAB %d\n",
302            data, 5+(data&3), 1+((data>>2)&1), P[(data>>3)&7], (data>>6)&1, (data>>7)&1));
303            break;
304      case 4:
305         ins8250->mcr = data;
306         COM_LOG(1,"COM_mcr_w",("COM $%02x DTR %d, RTS %d, OUT1 %d, OUT2 %d, loopback %d\n",
307            data, data&1, (data>>1)&1, (data>>2)&1, (data>>3)&1, (data>>4)&1));
308         if (ins8250->interface->handshake_out)
309            ins8250->interface->handshake_out(device,data);
310            break;
311      case 5:
312         break;
313      case 6:
314         break;
315      case 7:
316         ins8250->scr = data;
317         COM_LOG(2,"COM_scr_w",("COM $%02x\n", data));
318            break;
319   }
320
321   if (ins8250->interface->refresh_connected)
322      ins8250->interface->refresh_connected(device);
323}
324
325
326
327READ8_DEVICE_HANDLER( ins8250_r )
328{
329   ins8250_t   *ins8250 = get_safe_token(device);
330   int data = 0x0ff;
331
332   switch (offset)
333   {
334      case 0:
335         if (ins8250->lcr & 0x80)
336         {
337            data = ins8250->dll;
338            COM_LOG(1,"COM_dll_r",("COM $%02x\n", data));
339         }
340         else
341         {
342            data = ins8250->rbr;
343            if( ins8250->lsr & 0x01 )
344            {
345               ins8250->lsr &= ~0x01;      /* clear data ready status */
346               COM_LOG(2,"COM_rbr_r",("COM $%02x\n", data));
347            }
348
349            ins8250_clear_int(device, COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
350         }
351         break;
352      case 1:
353         if (ins8250->lcr & 0x80)
354         {
355            data = ins8250->dlm;
356            COM_LOG(1,"COM_dlm_r",("COM $%02x\n", data));
357         }
358         else
359         {
360            data = ins8250->ier;
361            COM_LOG(2,"COM_ier_r",("COM $%02x\n", data));
362            }
363            break;
364      case 2:
365         data = ins8250->iir;
366         COM_LOG(2,"COM_iir_r",("COM $%02x\n", data));
367         /* this may not be correct. It says that reading this register will
368         clear the int if this is the source of the int?? */
369         ins8250_clear_int(device, COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
370            break;
371      case 3:
372         data = ins8250->lcr;
373         COM_LOG(2,"COM_lcr_r",("COM $%02x\n", data));
374            break;
375      case 4:
376         data = ins8250->mcr;
377         COM_LOG(2,"COM_mcr_r",("COM $%02x\n", data));
378            break;
379      case 5:
380
381#if 0
382         if (ins8250->send.active && (timer_get_time()-ins8250->send.time>uart_byte_time(n)))
383         {
384            // currently polling is enough for pc1512
385            ins8250->lsr |= 0x40; /* set TSRE */
386            ins8250->send.active = 0;
387            if (LOOP(n))
388            {
389               ins8250->lsr |= 1;
390               ins8250->rbr = ins8250->send.data;
391            }
392         }
393#endif
394         ins8250->lsr |= 0x20; /* set THRE */
395         data = ins8250->lsr;
396         if( ins8250->lsr & 0x1f )
397         {
398            ins8250->lsr &= 0xe1; /* clear FE, PE and OE and BREAK bits */
399            COM_LOG(2,"COM_lsr_r",("COM $%02x, DR %d, OE %d, PE %d, FE %d, BREAK %d, THRE %d, TSRE %d\n",
400               data, data&1, (data>>1)&1, (data>>2)&1, (data>>3)&1, (data>>4)&1, (data>>5)&1, (data>>6)&1));
401         }
402
403         /* reading line status register clears int */
404         ins8250_clear_int(device, COM_INT_PENDING_RECEIVER_LINE_STATUS);
405            break;
406      case 6:
407         if (ins8250->mcr & 0x10)   /* loopback test? */
408         {
409            data = ins8250->mcr << 4;
410            /* build delta values */
411            ins8250->msr = (ins8250->msr ^ data) >> 4;
412            ins8250->msr |= data;
413         }
414         data = ins8250->msr;
415         ins8250->msr &= 0xf0; /* reset delta values */
416         COM_LOG(2,"COM_msr_r",("COM $%02x\n", data));
417
418         /* reading msr clears int */
419         ins8250_clear_int(device, COM_INT_PENDING_MODEM_STATUS_REGISTER);
420
421         break;
422      case 7:
423         data = ins8250->scr;
424         COM_LOG(2,"COM_scr_r",("COM $%02x\n", data));
425            break;
426   }
427
428   if (ins8250->interface->refresh_connected)
429      ins8250->interface->refresh_connected(device);
430
431    return data;
432}
433
434
435
436void ins8250_receive(const device_config *device, int data)
437{
438   ins8250_t   *ins8250 = get_safe_token(device);
439
440    /* check if data rate 1200 baud is set */
441   if( ins8250->dlm != 0x00 || ins8250->dll != 0x60 )
442        ins8250->lsr |= 0x08; /* set framing error */
443
444    /* if data not yet serviced */
445   if( ins8250->lsr & 0x01 )
446      ins8250->lsr |= 0x02; /* set overrun error */
447
448    /* put data into receiver buffer register */
449    ins8250->rbr = data;
450
451    /* set data ready status */
452    ins8250->lsr |= 0x01;
453
454   /* set pending state for this interrupt. */
455   ins8250_trigger_int(device, COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
456
457
458//   /* OUT2 + received line data avail interrupt enabled? */
459//   if( (COM_mcr[n] & 0x08) && (COM_ier[n] & 0x01) )
460//   {
461//      if (com_interface.interrupt)
462//         com_interface.interrupt(4-(n&1), 1);
463//
464//   }
465}
466
467/**************************************************************************
468 *   change the modem status register
469 **************************************************************************/
470void ins8250_handshake_in(const device_config *device, int new_msr)
471{
472   ins8250_t   *ins8250 = get_safe_token(device);
473
474   /* no change in modem status bits? */
475   if( ((ins8250->msr ^ new_msr) & 0xf0) == 0 )
476      return;
477
478   /* set delta status bits 0..3 and new modem status bits 4..7 */
479    ins8250->msr = (((ins8250->msr ^ new_msr) >> 4) & 0x0f) | (new_msr & 0xf0);
480
481   ins8250_trigger_int(device, COM_INT_PENDING_MODEM_STATUS_REGISTER);
482
483//   /* set up interrupt information register */
484  //  COM_iir[n] &= ~(0x06 | 0x01);
485
486//    /* OUT2 + modem status interrupt enabled? */
487//   if( (COM_mcr[n] & 0x08) && (COM_ier[n] & 0x08) )
488//   {
489//      if (com_interface.interrupt)
490//         com_interface.interrupt(4-(n&1), 1);
491//   }
492}
493
494
495static void common_start( const device_config *device, int device_type ) {
496   ins8250_t   *ins8250 = get_safe_token(device);
497
498   ins8250->interface = device->static_config;
499   ins8250->device_type = device_type;
500}
501
502
503static DEVICE_START( ins8250 ) {
504   common_start( device, TYPE_INS8250 );
505}
506
507
508static DEVICE_START( ins8250a ) {
509   common_start( device, TYPE_INS8250A );
510}
511
512
513static DEVICE_START( ns16450 ) {
514   common_start( device, TYPE_NS16450 );
515}
516
517
518static DEVICE_START( ns16550 ) {
519   common_start( device, TYPE_NS16550 );
520}
521
522
523static DEVICE_START( ns16550a ) {
524   common_start( device, TYPE_NS16550A );
525}
526
527
528static DEVICE_START( pc16550d ) {
529   common_start( device, TYPE_PC16550D );
530}
531
532
533static DEVICE_RESET( ins8250 ) {
534   ins8250_t   *ins8250 = get_safe_token(device);
535
536   ins8250->ier = 0;
537   ins8250->iir = 1;
538   ins8250->lcr = 0;
539   ins8250->mcr = 0;
540   ins8250->lsr = (1<<5) | (1<<6);
541
542   ins8250->send.active=0;
543
544   /* refresh with reset state of register */
545   if (ins8250->interface->refresh_connected)
546      ins8250->interface->refresh_connected(device);
547}
548
549
550static DEVICE_SET_INFO( ins8250 ) {
551   switch ( state ) {
552      /* no parameters to set */
553   }
554}
555
556
557DEVICE_GET_INFO( ins8250 ) {
558   switch ( state ) {
559      /* --- the following bits of info are returned as 64-bit signed integers --- */
560      case DEVINFO_INT_TOKEN_BYTES:            info->i = sizeof(ins8250_t);            break;
561      case DEVINFO_INT_INLINE_CONFIG_BYTES:      info->i = 0;                        break;
562      case DEVINFO_INT_CLASS:                  info->i = DEVICE_CLASS_PERIPHERAL;         break;
563
564      /* --- the following bits of info are returned as pointers to data or functions --- */
565      case DEVINFO_FCT_SET_INFO:               info->set_info = DEVICE_SET_INFO_NAME(ins8250);   break;
566      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ins8250);   break;
567      case DEVINFO_FCT_STOP:                  /* nothing */                        break;
568      case DEVINFO_FCT_RESET:                  info->reset = DEVICE_RESET_NAME(ins8250);   break;
569
570      /* --- the following bits of info are returned as NULL-terminated strings --- */
571      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor INS8250/INS8250B";   break;
572      case DEVINFO_STR_FAMILY:               info->s = "INS8250";                  break;
573      case DEVINFO_STR_VERSION:               info->s = "1.00";                     break;
574      case DEVINFO_STR_SOURCE_FILE:            info->s = __FILE__;                     break;
575      case DEVINFO_STR_CREDITS:               info->s = "Copyright the MESS Team";      break;
576   }
577}
578
579
580DEVICE_GET_INFO( ins8250a ) {
581   switch ( state ) {
582      /* --- the following bits of info are returned as 64-bit signed integers --- */
583      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor INS8250A/INS82C50A";   break;
584
585      /* --- the following bits of info are returned as pointers to data or functions --- */
586      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ins8250a);   break;
587
588      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
589   }
590}
591
592
593DEVICE_GET_INFO( ns16450 ) {
594   switch ( state ) {
595      /* --- the following bits of info are returned as 64-bit signed integers --- */
596      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor NS16450/PC16450";   break;
597
598      /* --- the following bits of info are returned as pointers to data or functions --- */
599      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ns16450);   break;
600
601      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
602   }
603}
604
605
606DEVICE_GET_INFO( ns16550 ) {
607   switch ( state ) {
608      /* --- the following bits of info are returned as 64-bit signed integers --- */
609      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor NS16550/PC16550";   break;
610
611      /* --- the following bits of info are returned as pointers to data or functions --- */
612      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ns16550);   break;
613
614      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
615   }
616}
617
618
619DEVICE_GET_INFO( ns16550a ) {
620   switch ( state ) {
621      /* --- the following bits of info are returned as 64-bit signed integers --- */
622      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor NS16550A/PC16550A";   break;
623
624      /* --- the following bits of info are returned as pointers to data or functions --- */
625      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ns16550a);   break;
626
627      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
628   }
629}
630
631
632DEVICE_GET_INFO( pc16550d ) {
633   switch ( state ) {
634      /* --- the following bits of info are returned as 64-bit signed integers --- */
635      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor PC16550D";   break;
636
637      /* --- the following bits of info are returned as pointers to data or functions --- */
638      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(pc16550d);   break;
639
640      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
641   }
642}
643
src/mess/machine/uart8250.h
r2435r2436
1/**********************************************************************
2
3   8250 UART interface and emulation
4
5**********************************************************************/
6
7#ifndef __INS8250_H_
8#define __INS8250_H_
9
10#define INS8250      DEVICE_GET_INFO_NAME(ins8250)
11#define INS8250A   DEVICE_GET_INFO_NAME(ins8250a)
12#define NS16450      DEVICE_GET_INFO_NAME(ns16450)
13#define NS16550      DEVICE_GET_INFO_NAME(ns16550)
14#define NS16550A   DEVICE_GET_INFO_NAME(ns16550a)
15#define PC16550D   DEVICE_GET_INFO_NAME(pc16550d)
16
17
18typedef void (*ins8250_interrupt_func)(const device_config *device, int state);
19typedef void (*ins8250_transmit_func)(const device_config *device, int data);
20typedef void (*ins8250_handshake_out_func)(const device_config *device, int data);
21typedef void (*ins8250_refresh_connect_func)(const device_config *device);
22
23#define INS8250_INTERRUPT(name)         void name(const device_config *device, int state)
24#define INS8250_TRANSMIT(name)         void name(const device_config *device, int data)
25#define INS8250_HANDSHAKE_OUT(name)      void name(const device_config *device, int data)
26#define INS8250_REFRESH_CONNECT(name)   void name(const device_config *device)
27
28typedef struct
29{
30   long clockin;
31   ins8250_interrupt_func         interrupt;
32
33#define UART8250_HANDSHAKE_OUT_DTR 0x01
34#define UART8250_HANDSHAKE_OUT_RTS 0x02
35   ins8250_transmit_func         transmit;
36   ins8250_handshake_out_func      handshake_out;
37
38   // refresh object connected to this port
39   ins8250_refresh_connect_func   refresh_connected;
40} ins8250_interface;
41
42
43void ins8250_receive(const device_config *device, int data);
44
45#define UART8250_HANDSHAKE_IN_DSR         0x020
46#define UART8250_HANDSHAKE_IN_CTS         0x010
47#define UART8250_INPUTS_RING_INDICATOR      0x0040
48#define UART8250_INPUTS_DATA_CARRIER_DETECT   0x0080
49
50void ins8250_handshake_in(const device_config *device, int new_msr);
51
52READ8_DEVICE_HANDLER( ins8250_r );
53WRITE8_DEVICE_HANDLER( ins8250_w );
54
55/* device interface */
56DEVICE_GET_INFO( ins8250 );
57DEVICE_GET_INFO( ins8250a );
58DEVICE_GET_INFO( ns16450 );
59DEVICE_GET_INFO( ns16550 );
60DEVICE_GET_INFO( ns16550a );
61DEVICE_GET_INFO( pc16550d );
62
63
64#endif /* __INS8250_H_ */
src/mess/machine/bebox.c
r2435r2436
9797#include "video/pc_vga.h"
9898#include "video/cirrus.h"
9999#include "cpu/powerpc/ppc.h"
100#include "machine/uart8250.h"
100#include "machine/ins8250.h"
101101#include "machine/pc_fdc.h"
102102#include "machine/mpc105.h"
103103#include "machine/mc146818.h"
src/mess/machine/ins8250.c
r0r2436
1/**********************************************************************
2
3   National Semiconductor 8250 UART interface and emulation
4
5   More information on the different models can be found in
6   section 1.6 at this location:
7     http://www.freebsd.org/doc/en_US.ISO8859-1/articles/serial-uart/
8
9Model overview (from page above):
10
11INS8250
12This part was used in the original IBM PC and IBM PC/XT. The original name
13for this part was the INS8250 ACE (Asynchronous Communications Element) and
14it is made from NMOS technology.
15
16The 8250 uses eight I/O ports and has a one-byte send and a one-byte receive
17buffer. This original UART has several race conditions and other flaws. The
18original IBM BIOS includes code to work around these flaws, but this made
19the BIOS dependent on the flaws being present, so subsequent parts like the
208250A, 16450 or 16550 could not be used in the original IBM PC or IBM PC/XT.
21
22INS8250-B
23This is the slower speed of the INS8250 made from NMOS technology. It contains
24the same problems as the original INS8250.
25
26INS8250A
27An improved version of the INS8250 using XMOS technology with various functional
28flaws corrected. The INS8250A was used initially in PC clone computers by vendors
29who used “clean” BIOS designs. Because of the corrections in the chip, this part
30could not be used with a BIOS compatible with the INS8250 or INS8250B.
31
32INS82C50A
33This is a CMOS version (low power consumption) of the INS8250A and has similar
34functional characteristics.
35
36NS16450
37Same as NS8250A with improvements so it can be used with faster CPU bus designs.
38IBM used this part in the IBM AT and updated the IBM BIOS to no longer rely on
39the bugs in the INS8250.
40
41NS16C450
42This is a CMOS version (low power consumption) of the NS16450.
43
44NS16550
45Same as NS16450 with a 16-byte send and receive buffer but the buffer design
46was flawed and could not be reliably be used.
47
48NS16550A
49Same as NS16550 with the buffer flaws corrected. The 16550A and its successors
50have become the most popular UART design in the PC industry, mainly due to
51its ability to reliably handle higher data rates on operating systems with
52sluggish interrupt response times.
53
54NS16C552
55This component consists of two NS16C550A CMOS UARTs in a single package.
56
57PC16550D
58Same as NS16550A with subtle flaws corrected. This is revision D of the
5916550 family and is the latest design available from National Semiconductor.
60
61
62Known issues:
63- MESS does currently not handle all these model specific features.
64
65
66History:
67   KT - 14-Jun-2000 - Improved Interrupt setting/clearing
68   KT - moved into seperate file so it can be used in Super I/O emulation and
69      any other system which uses a PC type COM port
70   KT - 24-Jun-2000 - removed pc specific input port tests. More compatible
71      with PCW16 and PCW16 doesn't requre the PC input port definitions
72      which are not required by the PCW16 hardware
73
74**********************************************************************/
75
76#include "driver.h"
77#include "machine/ins8250.h"
78#include "includes/pc_mouse.h"
79#include "memconv.h"
80
81
82#define LOG(LEVEL,N,M,A)  \
83if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A;
84
85
86/* device types */
87enum {
88   TYPE_INS8250 = 0,
89   TYPE_INS8250A,
90   TYPE_NS16450,
91   TYPE_NS16550,
92   TYPE_NS16550A,
93   TYPE_PC16550D,
94
95   NUM_TYPES
96};
97
98
99/* device tags */
100static const char * const device_tags[NUM_TYPES] = { "ins8250", "ins8250a", "ns16450", "ns16550", "ns16550a", "pc16550d" };
101
102
103#define VERBOSE_COM 0
104#define COM_LOG(n,m,a) LOG(VERBOSE_COM,n,m,a)
105
106typedef struct {
107   const ins8250_interface *interface;
108   int   device_type;
109
110   UINT8 thr;  /* 0 -W transmitter holding register */
111   UINT8 rbr; /* 0 R- receiver buffer register */
112   UINT8 ier;  /* 1 RW interrupt enable register */
113   UINT8 dll;  /* 0 RW divisor latch lsb (if DLAB = 1) */
114   UINT8 dlm;  /* 1 RW divisor latch msb (if DLAB = 1) */
115   UINT8 iir;  /* 2 R- interrupt identification register */
116   UINT8 lcr;  /* 3 RW line control register (bit 7: DLAB) */
117   UINT8 mcr;  /* 4 RW modem control register */
118   UINT8 lsr;  /* 5 R- line status register */
119   UINT8 msr;  /* 6 R- modem status register */
120   UINT8 scr;  /* 7 RW scratch register */
121
122/* holds int pending state for com */
123   UINT8 int_pending;
124
125   // sending circuit
126   struct {
127      int active;
128      UINT8 data;
129      double time;
130   } send;
131} ins8250_t;
132
133/* int's pending */
134#define COM_INT_PENDING_RECEIVED_DATA_AVAILABLE   0x0001
135#define COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY 0x0002
136#define COM_INT_PENDING_RECEIVER_LINE_STATUS 0x0004
137#define COM_INT_PENDING_MODEM_STATUS_REGISTER 0x0008
138
139#define DLAB(n) (uart[n].lcr&0x80) //divisor latch access bit
140#define LOOP(n) (ins8250->mcr&0x10)
141
142
143
144INLINE ins8250_t *get_safe_token(const device_config *device) {
145   assert( device != NULL );
146   assert( device->token != NULL );
147   assert( ( device->type == DEVICE_GET_INFO_NAME(ins8250) ) ||
148         ( device->type == DEVICE_GET_INFO_NAME(ins8250a) ) ||
149         ( device->type == DEVICE_GET_INFO_NAME(ns16450) ) ||
150         ( device->type == DEVICE_GET_INFO_NAME(ns16550) ) ||
151         ( device->type == DEVICE_GET_INFO_NAME(ns16550a) ) ||
152         ( device->type == DEVICE_GET_INFO_NAME(pc16550d) ) );
153   return ( ins8250_t *) device->token;
154}
155
156
157/* setup iir with the priority id */
158static void ins8250_setup_iir(const device_config *device)
159{
160   ins8250_t   *ins8250 = get_safe_token(device);
161
162   ins8250->iir &= ~(0x04|0x02);
163
164   /* highest to lowest */
165   if (ins8250->int_pending & COM_INT_PENDING_RECEIVER_LINE_STATUS)
166   {
167      ins8250->iir |=0x04|0x02;
168      return;
169   }
170
171   if (ins8250->int_pending & COM_INT_PENDING_RECEIVED_DATA_AVAILABLE)
172   {
173      ins8250->iir |=0x04;
174      return;
175   }
176
177   if (ins8250->int_pending & COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY)
178   {
179      ins8250->iir |=0x02;
180      return;
181   }
182
183   /* modem status has both bits clear */
184}
185
186
187/* ints will continue to be set for as long as there are ints pending */
188static void ins8250_update_interrupt(const device_config *device)
189{
190   ins8250_t   *ins8250 = get_safe_token(device);
191   int state;
192
193   /* disable int output? */
194   if ((ins8250->mcr & 0x08) == 0)
195      return;
196
197   /* if any bits are set and are enabled */
198   if (((ins8250->int_pending&ins8250->ier) & 0x0f) != 0)
199   {
200      /* trigger next highest priority int */
201
202      /* set int */
203      state = 1;
204
205      ins8250_setup_iir(device);
206
207      /* int pending */
208      ins8250->iir |= 0x01;
209   }
210   else
211   {
212      /* clear int */
213      state = 0;
214
215      /* no ints pending */
216      ins8250->iir &= ~0x01;
217      /* priority level */
218      ins8250->iir &= ~(0x04|0x02);
219   }
220
221
222   /* set or clear the int */
223   if (ins8250->interface->interrupt)
224      ins8250->interface->interrupt(device, state);
225}
226
227
228
229/* set pending bit and trigger int */
230static void ins8250_trigger_int(const device_config *device, int flag)
231{
232   ins8250_t   *ins8250 = get_safe_token(device);
233
234   ins8250->int_pending |= flag;
235   ins8250_update_interrupt(device);
236}
237
238
239
240/* clear pending bit, if any ints are pending, then int will be triggered, otherwise it
241will be cleared */
242static void ins8250_clear_int(const device_config *device, int flag)
243{
244   ins8250_t   *ins8250 = get_safe_token(device);
245
246   ins8250->int_pending &= ~flag;
247   ins8250_update_interrupt(device);
248}
249
250
251WRITE8_DEVICE_HANDLER( ins8250_w )
252{
253    static const char P[8] = "NONENHNL";  /* names for parity select */
254   ins8250_t   *ins8250 = get_safe_token(device);
255    int tmp;
256
257   switch (offset)
258   {
259      case 0:
260         if (ins8250->lcr & 0x80)
261         {
262            ins8250->dll = data;
263            tmp = ins8250->dlm * 256 + ins8250->dll;
264            COM_LOG(1,"COM_dll_w",("COM $%02x: [$%04x = %d baud]\n",
265                data, tmp, (tmp)?(int)(ins8250->interface->clockin/16/tmp):0));
266         }
267         else
268         {
269            ins8250->thr = data;
270            COM_LOG(2,"COM_thr_w",("COM $%02x\n", data));
271
272            if (LOOP(n))
273            {
274               ins8250->lsr |= 1;
275               ins8250->rbr = data;
276            }
277            /* writing to thr will clear the int */
278            ins8250_clear_int(device, COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
279         }
280         break;
281      case 1:
282         if (ins8250->lcr & 0x80)
283         {
284            ins8250->dlm = data;
285            tmp = ins8250->dlm * 256 + ins8250->dll;
286                COM_LOG(1,"COM_dlm_w",("COM $%02x: [$%04x = %d baud]\n",
287               data, tmp, (tmp)?(int)(ins8250->interface->clockin/16/tmp):0));
288         }
289         else
290         {
291            ins8250->ier = data;
292            COM_LOG(2,"COM_ier_w",("COM $%02x: enable int on RX %d, THRE %d, RLS %d, MS %d\n",
293               data, data&1, (data>>1)&1, (data>>2)&1, (data>>3)&1));
294         }
295            break;
296      case 2:
297         COM_LOG(1,"COM_fcr_w",("COM $%02x (16550 only)\n", data));
298            break;
299      case 3:
300         ins8250->lcr = data;
301         COM_LOG(1,"COM_lcr_w",("COM $%02x word length %d, stop bits %d, parity %c, break %d, DLAB %d\n",
302            data, 5+(data&3), 1+((data>>2)&1), P[(data>>3)&7], (data>>6)&1, (data>>7)&1));
303            break;
304      case 4:
305         ins8250->mcr = data;
306         COM_LOG(1,"COM_mcr_w",("COM $%02x DTR %d, RTS %d, OUT1 %d, OUT2 %d, loopback %d\n",
307            data, data&1, (data>>1)&1, (data>>2)&1, (data>>3)&1, (data>>4)&1));
308         if (ins8250->interface->handshake_out)
309            ins8250->interface->handshake_out(device,data);
310            break;
311      case 5:
312         break;
313      case 6:
314         break;
315      case 7:
316         ins8250->scr = data;
317         COM_LOG(2,"COM_scr_w",("COM $%02x\n", data));
318            break;
319   }
320
321   if (ins8250->interface->refresh_connected)
322      ins8250->interface->refresh_connected(device);
323}
324
325
326
327READ8_DEVICE_HANDLER( ins8250_r )
328{
329   ins8250_t   *ins8250 = get_safe_token(device);
330   int data = 0x0ff;
331
332   switch (offset)
333   {
334      case 0:
335         if (ins8250->lcr & 0x80)
336         {
337            data = ins8250->dll;
338            COM_LOG(1,"COM_dll_r",("COM $%02x\n", data));
339         }
340         else
341         {
342            data = ins8250->rbr;
343            if( ins8250->lsr & 0x01 )
344            {
345               ins8250->lsr &= ~0x01;      /* clear data ready status */
346               COM_LOG(2,"COM_rbr_r",("COM $%02x\n", data));
347            }
348
349            ins8250_clear_int(device, COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
350         }
351         break;
352      case 1:
353         if (ins8250->lcr & 0x80)
354         {
355            data = ins8250->dlm;
356            COM_LOG(1,"COM_dlm_r",("COM $%02x\n", data));
357         }
358         else
359         {
360            data = ins8250->ier;
361            COM_LOG(2,"COM_ier_r",("COM $%02x\n", data));
362            }
363            break;
364      case 2:
365         data = ins8250->iir;
366         COM_LOG(2,"COM_iir_r",("COM $%02x\n", data));
367         /* this may not be correct. It says that reading this register will
368         clear the int if this is the source of the int?? */
369         ins8250_clear_int(device, COM_INT_PENDING_TRANSMITTER_HOLDING_REGISTER_EMPTY);
370            break;
371      case 3:
372         data = ins8250->lcr;
373         COM_LOG(2,"COM_lcr_r",("COM $%02x\n", data));
374            break;
375      case 4:
376         data = ins8250->mcr;
377         COM_LOG(2,"COM_mcr_r",("COM $%02x\n", data));
378            break;
379      case 5:
380
381#if 0
382         if (ins8250->send.active && (timer_get_time()-ins8250->send.time>uart_byte_time(n)))
383         {
384            // currently polling is enough for pc1512
385            ins8250->lsr |= 0x40; /* set TSRE */
386            ins8250->send.active = 0;
387            if (LOOP(n))
388            {
389               ins8250->lsr |= 1;
390               ins8250->rbr = ins8250->send.data;
391            }
392         }
393#endif
394         ins8250->lsr |= 0x20; /* set THRE */
395         data = ins8250->lsr;
396         if( ins8250->lsr & 0x1f )
397         {
398            ins8250->lsr &= 0xe1; /* clear FE, PE and OE and BREAK bits */
399            COM_LOG(2,"COM_lsr_r",("COM $%02x, DR %d, OE %d, PE %d, FE %d, BREAK %d, THRE %d, TSRE %d\n",
400               data, data&1, (data>>1)&1, (data>>2)&1, (data>>3)&1, (data>>4)&1, (data>>5)&1, (data>>6)&1));
401         }
402
403         /* reading line status register clears int */
404         ins8250_clear_int(device, COM_INT_PENDING_RECEIVER_LINE_STATUS);
405            break;
406      case 6:
407         if (ins8250->mcr & 0x10)   /* loopback test? */
408         {
409            data = ins8250->mcr << 4;
410            /* build delta values */
411            ins8250->msr = (ins8250->msr ^ data) >> 4;
412            ins8250->msr |= data;
413         }
414         data = ins8250->msr;
415         ins8250->msr &= 0xf0; /* reset delta values */
416         COM_LOG(2,"COM_msr_r",("COM $%02x\n", data));
417
418         /* reading msr clears int */
419         ins8250_clear_int(device, COM_INT_PENDING_MODEM_STATUS_REGISTER);
420
421         break;
422      case 7:
423         data = ins8250->scr;
424         COM_LOG(2,"COM_scr_r",("COM $%02x\n", data));
425            break;
426   }
427
428   if (ins8250->interface->refresh_connected)
429      ins8250->interface->refresh_connected(device);
430
431    return data;
432}
433
434
435
436void ins8250_receive(const device_config *device, int data)
437{
438   ins8250_t   *ins8250 = get_safe_token(device);
439
440    /* check if data rate 1200 baud is set */
441   if( ins8250->dlm != 0x00 || ins8250->dll != 0x60 )
442        ins8250->lsr |= 0x08; /* set framing error */
443
444    /* if data not yet serviced */
445   if( ins8250->lsr & 0x01 )
446      ins8250->lsr |= 0x02; /* set overrun error */
447
448    /* put data into receiver buffer register */
449    ins8250->rbr = data;
450
451    /* set data ready status */
452    ins8250->lsr |= 0x01;
453
454   /* set pending state for this interrupt. */
455   ins8250_trigger_int(device, COM_INT_PENDING_RECEIVED_DATA_AVAILABLE);
456
457
458//   /* OUT2 + received line data avail interrupt enabled? */
459//   if( (COM_mcr[n] & 0x08) && (COM_ier[n] & 0x01) )
460//   {
461//      if (com_interface.interrupt)
462//         com_interface.interrupt(4-(n&1), 1);
463//
464//   }
465}
466
467/**************************************************************************
468 *   change the modem status register
469 **************************************************************************/
470void ins8250_handshake_in(const device_config *device, int new_msr)
471{
472   ins8250_t   *ins8250 = get_safe_token(device);
473
474   /* no change in modem status bits? */
475   if( ((ins8250->msr ^ new_msr) & 0xf0) == 0 )
476      return;
477
478   /* set delta status bits 0..3 and new modem status bits 4..7 */
479    ins8250->msr = (((ins8250->msr ^ new_msr) >> 4) & 0x0f) | (new_msr & 0xf0);
480
481   ins8250_trigger_int(device, COM_INT_PENDING_MODEM_STATUS_REGISTER);
482
483//   /* set up interrupt information register */
484  //  COM_iir[n] &= ~(0x06 | 0x01);
485
486//    /* OUT2 + modem status interrupt enabled? */
487//   if( (COM_mcr[n] & 0x08) && (COM_ier[n] & 0x08) )
488//   {
489//      if (com_interface.interrupt)
490//         com_interface.interrupt(4-(n&1), 1);
491//   }
492}
493
494
495static void common_start( const device_config *device, int device_type ) {
496   ins8250_t   *ins8250 = get_safe_token(device);
497
498   ins8250->interface = device->static_config;
499   ins8250->device_type = device_type;
500}
501
502
503static DEVICE_START( ins8250 ) {
504   common_start( device, TYPE_INS8250 );
505}
506
507
508static DEVICE_START( ins8250a ) {
509   common_start( device, TYPE_INS8250A );
510}
511
512
513static DEVICE_START( ns16450 ) {
514   common_start( device, TYPE_NS16450 );
515}
516
517
518static DEVICE_START( ns16550 ) {
519   common_start( device, TYPE_NS16550 );
520}
521
522
523static DEVICE_START( ns16550a ) {
524   common_start( device, TYPE_NS16550A );
525}
526
527
528static DEVICE_START( pc16550d ) {
529   common_start( device, TYPE_PC16550D );
530}
531
532
533static DEVICE_RESET( ins8250 ) {
534   ins8250_t   *ins8250 = get_safe_token(device);
535
536   ins8250->ier = 0;
537   ins8250->iir = 1;
538   ins8250->lcr = 0;
539   ins8250->mcr = 0;
540   ins8250->lsr = (1<<5) | (1<<6);
541
542   ins8250->send.active=0;
543
544   /* refresh with reset state of register */
545   if (ins8250->interface->refresh_connected)
546      ins8250->interface->refresh_connected(device);
547}
548
549
550static DEVICE_SET_INFO( ins8250 ) {
551   switch ( state ) {
552      /* no parameters to set */
553   }
554}
555
556
557DEVICE_GET_INFO( ins8250 ) {
558   switch ( state ) {
559      /* --- the following bits of info are returned as 64-bit signed integers --- */
560      case DEVINFO_INT_TOKEN_BYTES:            info->i = sizeof(ins8250_t);            break;
561      case DEVINFO_INT_INLINE_CONFIG_BYTES:      info->i = 0;                        break;
562      case DEVINFO_INT_CLASS:                  info->i = DEVICE_CLASS_PERIPHERAL;         break;
563
564      /* --- the following bits of info are returned as pointers to data or functions --- */
565      case DEVINFO_FCT_SET_INFO:               info->set_info = DEVICE_SET_INFO_NAME(ins8250);   break;
566      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ins8250);   break;
567      case DEVINFO_FCT_STOP:                  /* nothing */                        break;
568      case DEVINFO_FCT_RESET:                  info->reset = DEVICE_RESET_NAME(ins8250);   break;
569
570      /* --- the following bits of info are returned as NULL-terminated strings --- */
571      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor INS8250/INS8250B";   break;
572      case DEVINFO_STR_FAMILY:               info->s = "INS8250";                  break;
573      case DEVINFO_STR_VERSION:               info->s = "1.00";                     break;
574      case DEVINFO_STR_SOURCE_FILE:            info->s = __FILE__;                     break;
575      case DEVINFO_STR_CREDITS:               info->s = "Copyright the MESS Team";      break;
576   }
577}
578
579
580DEVICE_GET_INFO( ins8250a ) {
581   switch ( state ) {
582      /* --- the following bits of info are returned as 64-bit signed integers --- */
583      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor INS8250A/INS82C50A";   break;
584
585      /* --- the following bits of info are returned as pointers to data or functions --- */
586      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ins8250a);   break;
587
588      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
589   }
590}
591
592
593DEVICE_GET_INFO( ns16450 ) {
594   switch ( state ) {
595      /* --- the following bits of info are returned as 64-bit signed integers --- */
596      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor NS16450/PC16450";   break;
597
598      /* --- the following bits of info are returned as pointers to data or functions --- */
599      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ns16450);   break;
600
601      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
602   }
603}
604
605
606DEVICE_GET_INFO( ns16550 ) {
607   switch ( state ) {
608      /* --- the following bits of info are returned as 64-bit signed integers --- */
609      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor NS16550/PC16550";   break;
610
611      /* --- the following bits of info are returned as pointers to data or functions --- */
612      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ns16550);   break;
613
614      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
615   }
616}
617
618
619DEVICE_GET_INFO( ns16550a ) {
620   switch ( state ) {
621      /* --- the following bits of info are returned as 64-bit signed integers --- */
622      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor NS16550A/PC16550A";   break;
623
624      /* --- the following bits of info are returned as pointers to data or functions --- */
625      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(ns16550a);   break;
626
627      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
628   }
629}
630
631
632DEVICE_GET_INFO( pc16550d ) {
633   switch ( state ) {
634      /* --- the following bits of info are returned as 64-bit signed integers --- */
635      case DEVINFO_STR_NAME:                  info->s = "National Semiconductor PC16550D";   break;
636
637      /* --- the following bits of info are returned as pointers to data or functions --- */
638      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(pc16550d);   break;
639
640      default:                           DEVICE_GET_INFO_CALL(ins8250);            break;
641   }
642}
643
src/mess/machine/pc_mouse.c
r2435r2436
88
99#include "driver.h"
1010#include "deprecat.h"
11#include "machine/uart8250.h"
11#include "machine/ins8250.h"
1212#include "includes/pc_mouse.h"
1313
1414
src/mess/machine/ins8250.h
r0r2436
1/**********************************************************************
2
3   8250 UART interface and emulation
4
5**********************************************************************/
6
7#ifndef __INS8250_H_
8#define __INS8250_H_
9
10#define INS8250      DEVICE_GET_INFO_NAME(ins8250)
11#define INS8250A   DEVICE_GET_INFO_NAME(ins8250a)
12#define NS16450      DEVICE_GET_INFO_NAME(ns16450)
13#define NS16550      DEVICE_GET_INFO_NAME(ns16550)
14#define NS16550A   DEVICE_GET_INFO_NAME(ns16550a)
15#define PC16550D   DEVICE_GET_INFO_NAME(pc16550d)
16
17
18typedef void (*ins8250_interrupt_func)(const device_config *device, int state);
19typedef void (*ins8250_transmit_func)(const device_config *device, int data);
20typedef void (*ins8250_handshake_out_func)(const device_config *device, int data);
21typedef void (*ins8250_refresh_connect_func)(const device_config *device);
22
23#define INS8250_INTERRUPT(name)         void name(const device_config *device, int state)
24#define INS8250_TRANSMIT(name)         void name(const device_config *device, int data)
25#define INS8250_HANDSHAKE_OUT(name)      void name(const device_config *device, int data)
26#define INS8250_REFRESH_CONNECT(name)   void name(const device_config *device)
27
28typedef struct
29{
30   long clockin;
31   ins8250_interrupt_func         interrupt;
32
33#define UART8250_HANDSHAKE_OUT_DTR 0x01
34#define UART8250_HANDSHAKE_OUT_RTS 0x02
35   ins8250_transmit_func         transmit;
36   ins8250_handshake_out_func      handshake_out;
37
38   // refresh object connected to this port
39   ins8250_refresh_connect_func   refresh_connected;
40} ins8250_interface;
41
42
43void ins8250_receive(const device_config *device, int data);
44
45#define UART8250_HANDSHAKE_IN_DSR         0x020
46#define UART8250_HANDSHAKE_IN_CTS         0x010
47#define UART8250_INPUTS_RING_INDICATOR      0x0040
48#define UART8250_INPUTS_DATA_CARRIER_DETECT   0x0080
49
50void ins8250_handshake_in(const device_config *device, int new_msr);
51
52READ8_DEVICE_HANDLER( ins8250_r );
53WRITE8_DEVICE_HANDLER( ins8250_w );
54
55/* device interface */
56DEVICE_GET_INFO( ins8250 );
57DEVICE_GET_INFO( ins8250a );
58DEVICE_GET_INFO( ns16450 );
59DEVICE_GET_INFO( ns16550 );
60DEVICE_GET_INFO( ns16550a );
61DEVICE_GET_INFO( pc16550d );
62
63
64#endif /* __INS8250_H_ */
src/mess/machine/svi318.c
r2435r2436
1515#include "cpu/z80/z80.h"
1616#include "video/tms9928a.h"
1717#include "machine/8255ppi.h"
18#include "machine/uart8250.h"
18#include "machine/ins8250.h"
1919#include "machine/wd17xx.h"
2020#include "devices/basicdsk.h"
2121#include "devices/printer.h"
r2435r2436
6565
6666/* Serial ports */
6767
68static INS8250_INTERRUPT( svi318_uart8250_interrupt )
68static INS8250_INTERRUPT( svi318_ins8250_interrupt )
6969{
7070   if (svi.bankLow != SVI_CART) {
7171      cpunum_set_input_line(device->machine, 0, 0, (state ? HOLD_LINE : CLEAR_LINE));
r2435r2436
7878   ins8250_handshake_in(device, UART8250_HANDSHAKE_IN_CTS|UART8250_HANDSHAKE_IN_DSR|UART8250_INPUTS_RING_INDICATOR|UART8250_INPUTS_DATA_CARRIER_DETECT);
7979}
8080
81const ins8250_interface svi318_uart8250_interface[2]=
81const ins8250_interface svi318_ins8250_interface[2]=
8282{
8383   {
8484      1000000,
85      svi318_uart8250_interrupt,
85      svi318_ins8250_interrupt,
8686      NULL,
8787      NULL,
8888      svi318_com_refresh_connected
8989   },
9090   {
9191      3072000,
92      svi318_uart8250_interrupt,
92      svi318_ins8250_interrupt,
9393      NULL,
9494      NULL,
9595      NULL
src/mess/machine/pc.c
r2435r2436
1717#include "includes/pc.h"
1818
1919#include "machine/8255ppi.h"
20#include "machine/uart8250.h"
20#include "machine/ins8250.h"
2121#include "machine/mc146818.h"
2222#include "machine/pic8259.h"
2323#include "machine/pc_turbo.h"
src/mess/mess.mak
r2435r2436
472472   $(MESS_VIDEO)/crtc6845.o   \
473473   $(MESS_MACHINE)/rriot.o    \
474474   $(MESS_MACHINE)/74145.o    \
475   $(MESS_MACHINE)/uart8250.o \
475   $(MESS_MACHINE)/ins8250.o \
476476   $(MESS_MACHINE)/pc_mouse.o \
477477   $(MESS_MACHINE)/pclpt.o    \
478478   $(MESS_MACHINE)/centroni.o \
src/mess/drivers/pcw16.c
r2435r2436
9797#include "includes/pclpt.h"      /* PC-Parallel Port */
9898#include "machine/pckeybrd.h"   /* PC-AT keyboard */
9999#include "machine/pc_fdc.h"      /* change to superio later */
100#include "machine/uart8250.h"   /* pc com port */
100#include "machine/ins8250.h"   /* pc com port */
101101#include "includes/pc_mouse.h"   /* pc serial mouse */
102102#include "sound/beep.h"         /* pcw/pcw16 beeper */
103103#include "machine/intelfsh.h"
src/mess/drivers/at.c
r2435r2436
77#include "driver.h"
88#include "sound/3812intf.h"
99#include "machine/8255ppi.h"
10#include "machine/uart8250.h"
10#include "machine/ins8250.h"
1111#include "machine/mc146818.h"
1212#include "machine/pic8259.h"
1313#include "devices/printer.h"
r2435r2436
118118DEV_READWRITE8TO32LE( at_dma8237_32le, dma8237_r, dma8237_w )
119119DEV_READWRITE8TO32LE( at_pic8259_32le, pic8259_r, pic8259_w )
120120DEV_READWRITE8TO32LE( at_dma8237_1_32le, at_dma8237_1_r, at_dma8237_1_w )
121DEV_READWRITE8TO32LE( uart8250_32le, ins8250_r, ins8250_w )
121DEV_READWRITE8TO32LE( ins8250_32le, ins8250_r, ins8250_w )
122122
123123
124124static ADDRESS_MAP_START(at_io, ADDRESS_SPACE_IO, 8)
r2435r2436
172172   AM_RANGE(0x00a0, 0x00bf) AM_DEVREADWRITE(PIC8259, "pic8259_slave", at_pic8259_32le_r, at_pic8259_32le_w)
173173   AM_RANGE(0x00c0, 0x00df) AM_DEVREADWRITE(DMA8237, "dma8237_2", at_dma8237_1_32le_r, at_dma8237_1_32le_w)
174174   AM_RANGE(0x0278, 0x027f) AM_READWRITE(pc32le_parallelport2_r,   pc32le_parallelport2_w)
175   AM_RANGE(0x02e8, 0x02ef) AM_DEVREADWRITE(NS16450, "ns16450_3", uart8250_32le_r, uart8250_32le_w)
176   AM_RANGE(0x02f8, 0x02ff) AM_DEVREADWRITE(NS16450, "ns16450_1", uart8250_32le_r, uart8250_32le_w)
175   AM_RANGE(0x02e8, 0x02ef) AM_DEVREADWRITE(NS16450, "ns16450_3", ins8250_32le_r, ins8250_32le_w)
176   AM_RANGE(0x02f8, 0x02ff) AM_DEVREADWRITE(NS16450, "ns16450_1", ins8250_32le_r, ins8250_32le_w)
177177   AM_RANGE(0x0320, 0x0323) AM_READWRITE(pc32le_HDC1_r,         pc32le_HDC1_w)
178178   AM_RANGE(0x0324, 0x0327) AM_READWRITE(pc32le_HDC2_r,         pc32le_HDC2_w)
179179   AM_RANGE(0x0378, 0x037f) AM_READWRITE(pc32le_parallelport1_r,   pc32le_parallelport1_w)
180180   AM_RANGE(0x03f0, 0x03f7) AM_READWRITE(pc32le_fdc_r,            pc32le_fdc_w)
181181   AM_RANGE(0x03bc, 0x03bf) AM_READWRITE(pc32le_parallelport0_r,   pc32le_parallelport0_w)
182   AM_RANGE(0x03f8, 0x03ff) AM_DEVREADWRITE(NS16450, "ns16450_0", uart8250_32le_r, uart8250_32le_w)
182   AM_RANGE(0x03f8, 0x03ff) AM_DEVREADWRITE(NS16450, "ns16450_0", ins8250_32le_r, ins8250_32le_w)
183183ADDRESS_MAP_END
184184
185185
r2435r2436
194194   AM_RANGE(0x00a0, 0x00bf) AM_DEVREADWRITE(PIC8259, "pic8259_slave", at_pic8259_32le_r, at_pic8259_32le_w)
195195   AM_RANGE(0x00c0, 0x00df) AM_DEVREADWRITE(DMA8237, "dma8237_2", at_dma8237_1_32le_r, at_dma8237_1_32le_w)
196196   AM_RANGE(0x0278, 0x027f) AM_READWRITE(pc32le_parallelport2_r,      pc32le_parallelport2_w)
197   AM_RANGE(0x02e8, 0x02ef) AM_DEVREADWRITE(NS16450, "ns16450_3", uart8250_32le_r, uart8250_32le_w)
198   AM_RANGE(0x02f8, 0x02ff) AM_DEVREADWRITE(NS16450, "ns16450_1", uart8250_32le_r, uart8250_32le_w)
197   AM_RANGE(0x02e8, 0x02ef) AM_DEVREADWRITE(NS16450, "ns16450_3", ins8250_32le_r, ins8250_32le_w)
198   AM_RANGE(0x02f8, 0x02ff) AM_DEVREADWRITE(NS16450, "ns16450_1", ins8250_32le_r, ins8250_32le_w)
199199   AM_RANGE(0x0320, 0x0323) AM_READWRITE(pc32le_HDC1_r,            pc32le_HDC1_w)
200200   AM_RANGE(0x0324, 0x0327) AM_READWRITE(pc32le_HDC2_r,            pc32le_HDC2_w)
201201   AM_RANGE(0x0378, 0x037f) AM_READWRITE(pc32le_parallelport1_r,      pc32le_parallelport1_w)
202202   AM_RANGE(0x03f0, 0x03f7) AM_READWRITE(pc32le_fdc_r,            pc32le_fdc_w)
203203   AM_RANGE(0x03bc, 0x03bf) AM_READWRITE(pc32le_parallelport0_r,      pc32le_parallelport0_w)
204   AM_RANGE(0x03f8, 0x03ff) AM_DEVREADWRITE(NS16450, "ns16450_0", uart8250_32le_r, uart8250_32le_w)
204   AM_RANGE(0x03f8, 0x03ff) AM_DEVREADWRITE(NS16450, "ns16450_0", ins8250_32le_r, ins8250_32le_w)
205205   AM_RANGE(0x0cf8, 0x0cff) AM_READWRITE(pci_32le_r,            pci_32le_w)
206206ADDRESS_MAP_END
207207
src/mess/drivers/bebox.c
r2435r2436
1616#include "video/pc_vga.h"
1717#include "video/cirrus.h"
1818#include "cpu/powerpc/ppc.h"
19#include "machine/uart8250.h"
19#include "machine/ins8250.h"
2020#include "machine/pic8259.h"
2121#include "machine/mc146818.h"
2222#include "machine/pc_fdc.h"
r2435r2436
5151DEV_READWRITE8TO64BE( bebox_pit8254_64be, pit8253_r, pit8253_w )
5252DEV_READWRITE8TO64BE( bebox_dma8237_64be, dma8237_r, dma8237_w )
5353DEV_READWRITE8TO64BE( bebox_pic8259_64be, pic8259_r, pic8259_w )
54DEV_READWRITE8TO64BE( bebox_uart8250_64be, ins8250_r, ins8250_w )
54DEV_READWRITE8TO64BE( bebox_ins8250_64be, ins8250_r, ins8250_w )
5555
5656
5757static ADDRESS_MAP_START( bebox_mem, ADDRESS_SPACE_PROGRAM, 64 )
r2435r2436
7070   AM_RANGE(0x800000A0, 0x800000BF) AM_DEVREADWRITE( PIC8259, "pic8259_slave", bebox_pic8259_64be_r, bebox_pic8259_64be_w )
7171   AM_RANGE(0x800000C0, 0x800000DF) AM_READWRITE( bebox_dma8237_1_r, bebox_dma8237_1_w)
7272   AM_RANGE(0x800001F0, 0x800001F7) AM_READWRITE( bebox_800001F0_r, bebox_800001F0_w )
73   AM_RANGE(0x800002F8, 0x800002FF) AM_DEVREADWRITE( NS16550, "ns16550_1", bebox_uart8250_64be_r, bebox_uart8250_64be_w )
74   AM_RANGE(0x80000380, 0x80000387) AM_DEVREADWRITE( NS16550, "ns16550_2", bebox_uart8250_64be_r, bebox_uart8250_64be_w )
75   AM_RANGE(0x80000388, 0x8000038F) AM_DEVREADWRITE( NS16550, "ns16550_3", bebox_uart8250_64be_r, bebox_uart8250_64be_w )
73   AM_RANGE(0x800002F8, 0x800002FF) AM_DEVREADWRITE( NS16550, "ns16550_1", bebox_ins8250_64be_r, bebox_ins8250_64be_w )
74   AM_RANGE(0x80000380, 0x80000387) AM_DEVREADWRITE( NS16550, "ns16550_2", bebox_ins8250_64be_r, bebox_ins8250_64be_w )
75   AM_RANGE(0x80000388, 0x8000038F) AM_DEVREADWRITE( NS16550, "ns16550_3", bebox_ins8250_64be_r, bebox_ins8250_64be_w )
7676   AM_RANGE(0x800003F0, 0x800003F7) AM_READWRITE( bebox_800003F0_r, bebox_800003F0_w )
77   AM_RANGE(0x800003F8, 0x800003FF) AM_DEVREADWRITE( NS16550, "ns16550_0", bebox_uart8250_64be_r, bebox_uart8250_64be_w )
77   AM_RANGE(0x800003F8, 0x800003FF) AM_DEVREADWRITE( NS16550, "ns16550_0", bebox_ins8250_64be_r, bebox_ins8250_64be_w )
7878   AM_RANGE(0x80000480, 0x8000048F) AM_READWRITE( bebox_80000480_r, bebox_80000480_w )
7979   AM_RANGE(0x80000CF8, 0x80000CFF) AM_READWRITE( pci_64be_r, pci_64be_w )
8080   AM_RANGE(0x800042E8, 0x800042EF) AM_WRITE( cirrus_64be_42E8_w )
src/mess/drivers/avigo.c
r2435r2436
4343#include "includes/avigo.h"
4444#include "machine/intelfsh.h"
4545#include "machine/tc8521.h"
46#include "machine/uart8250.h"
46#include "machine/ins8250.h"
4747#include "sound/speaker.h"
4848
4949
src/mess/drivers/svi318.c
r2435r2436
310310   MDRV_DEVICE_CONFIG( svi318_ppi8255_interface )
311311
312312   MDRV_DEVICE_ADD( "ins8250_0", INS8250 )
313   MDRV_DEVICE_CONFIG( svi318_uart8250_interface[0] )
313   MDRV_DEVICE_CONFIG( svi318_ins8250_interface[0] )
314314
315315   MDRV_DEVICE_ADD( "ins8250_1", INS8250 )
316   MDRV_DEVICE_CONFIG( svi318_uart8250_interface[1] )
316   MDRV_DEVICE_CONFIG( svi318_ins8250_interface[1] )
317317
318318   /* Video hardware */
319319   MDRV_IMPORT_FROM(tms9928a)
src/mess/drivers/pc.c
r2435r2436
4646#include "devconv.h"
4747
4848#include "machine/8255ppi.h"
49#include "machine/uart8250.h"
49#include "machine/ins8250.h"
5050#include "machine/mc146818.h"
5151#include "machine/pic8259.h"
5252

Previous 15994 Revisions Next


© 1998-2018 The MESS Team