54#define COMTICK (1843200/16)
55#define SPEED_TOLERANCE 30
64#define IIR_FIFO_MASK 0xc0
75#define FIFO_ENABLE 0x01
76#define FIFO_RCV_RST 0x02
77#define FIFO_XMT_RST 0x04
78#define FIFO_DMA_MODE 0x08
79#define FIFO_TRIGGER_1 0x00
80#define FIFO_TRIGGER_4 0x40
81#define FIFO_TRIGGER_8 0x80
82#define FIFO_TRIGGER_14 0xc0
86#define CFCR_SBREAK 0x40
87#define CFCR_PZERO 0x30
89#define CFCR_PEVEN 0x10
91#define CFCR_PENAB 0x08
92#define CFCR_STOPB 0x04
93#define CFCR_8BITS 0x03
94#define CFCR_7BITS 0x02
95#define CFCR_6BITS 0x01
96#define CFCR_5BITS 0x00
99#define MCR_LOOPBACK 0x10
100#define MCR_IENABLE 0x08
106#define LSR_RCV_FIFO 0x80
108#define LSR_TXRDY 0x20
113#define LSR_RXRDY 0x01
114#define LSR_RCV_MASK 0x1f
133#define FIFO_TRIGGER FIFO_TRIGGER_4
148static size_t cnts[NCNT];
149static char *cntnames[NCNT] =
152 "mlsc",
"nopend",
"txrdy",
"?3",
153 "rxrdy",
"?5",
"rls",
"?7",
154 "?8",
"?9",
"?a",
"?b",
155 "rxtout",
"?d",
"?e",
"?f",
157 "rxcnt",
"txcnt",
"stray",
"swoflo"
160#define COUNT(x) cnts[x]++
167#define ICU_OCW2 (ICU_BASE + 0)
168#define ICU_MASK (ICU_BASE + 1)
210 COM1ADDR, 4, 0, NULL, 0, 0,
"", 0, 0, 0, 0, 0, 0, 0, 0
214 COM2ADDR, 3, 0, NULL, 0, 0,
"", 0, 0, 0, 0, 0, 0, 0, 0
218 COM3ADDR, 4, 0, NULL, 0, 0,
"", 0, 0, 0, 0, 0, 0, 0, 0
222 COM4ADDR, 3, 0, NULL, 0, 0,
"", 0, 0, 0, 0, 0, 0, 0, 0
230static int dos_write (
struct serial *scb,
const void *buf,
size_t count);
236#define inb(p,a) inportb((p)->base + (a))
237#define outb(p,a,v) outportb((p)->base + (a), (v))
238#define disable() asm volatile ("cli");
239#define enable() asm volatile ("sti");
275 unsigned char iir, lsr, c;
351#define ISRNAME(x) dos_comisr##x
352#define ISR(x) static void ISRNAME(x)(void) {dos_comisr(x);}
357typedef
void (*isr_t) (
void);
359static isr_t isrs[
NINTR] =
385 _go32_dpmi_get_real_mode_interrupt_vector (vec, &intr->
old_rmhandler);
389 if (_go32_dpmi_allocate_real_mode_callback_iret (&intr->
new_rmhandler,
395 if (_go32_dpmi_set_real_mode_interrupt_vector (vec, &intr->
new_rmhandler))
401 _go32_dpmi_get_protected_mode_interrupt_vector (vec, &intr->
old_pmhandler);
407 if (_go32_dpmi_set_protected_mode_interrupt_vector (vec,
426 unsigned int irq, vec;
439 _go32_dpmi_set_real_mode_interrupt_vector (vec, &intr->
old_rmhandler);
443 _go32_dpmi_set_protected_mode_interrupt_vector (vec, &intr->
old_pmhandler);
456 if (strncasecmp (
name,
"/dev/", 5) == 0)
458 else if (strncasecmp (
name,
"\\dev\\", 5) == 0)
461 if (strlen (
name) != 4 || strncasecmp (
name,
"com", 3) != 0)
489 for (i = 0; i < 17; i++)
588 "Serial input overruns occurred.\n");
590 port->
fifo ?
"cannot" :
"needs a 16550 to",
633 then = rawclock () + (timeout *
RAWHZ);
638 if (timeout >= 0 && (rawclock () - then) >= 0)
661 if (scb->
fd >= 3 || !isatty (scb->
fd))
720#define divrnd(n, q) (((n) * 2 / (q) + 1) / 2)
798 size_t fifosize = port->
fifo ? 16 : 1;
801 const char *str = (
const char *) buf;
812#ifdef UART_FIFO_WORKS
817 for ( ; cnt > 0; cnt--,
count--)
824 then = rawclock () +
RAWHZ;
827 if ((rawclock () - then) >= 0)
849 then = rawclock () +
RAWHZ / 4;
850 while ((rawclock () - then) < 0)
878 (void (*)(
struct serial *, int))NULL
906 gdb_printf (
"Errs:\tframing %d parity %d overflow %d\n\n",
911 gdb_printf (
"\nTotal interrupts: %d\n", intrcnt);
912 for (i = 0; i < NCNT; i++)
914 gdb_printf (
"%s:\t%lu\n", cntnames[i], (
unsigned long) cnts[i]);
933Set COM1 base i/o port address."), _(
"\
934Show COM1 base i/o port address."), NULL,
940Set COM1 interrupt request."), _(
"\
941Show COM1 interrupt request."), NULL,
947Set COM2 base i/o port address."), _(
"\
948Show COM2 base i/o port address."), NULL,
954Set COM2 interrupt request."), _(
"\
955Show COM2 interrupt request."), NULL,
961Set COM3 base i/o port address."), _(
"\
962Show COM3 base i/o port address."), NULL,
968Set COM3 interrupt request."), _(
"\
969Show COM3 interrupt request."), NULL,
975Set COM4 base i/o port address."), _(
"\
976Show COM4 base i/o port address."), NULL,
982Set COM4 interrupt request."), _(
"\
983Show COM4 interrupt request."), NULL,
989 _(
"Print DOS serial port status."));
struct cmd_list_element * showlist
struct cmd_list_element * setlist
set_show_commands add_setshow_zinteger_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
static int dos_setstopbits(struct serial *scb, int num)
static int dos_set_tty_state(struct serial *scb, serial_ttystate state)
static void dos_unhookirq(struct intrupt *intr)
static int dos_flush_input(struct serial *scb)
static int dos_open(struct serial *scb, const char *name)
static void dos_comisr(int irq)
int gdb_pipe(int pdes[2])
static void dos_print_tty_state(struct serial *scb, serial_ttystate ttystate, struct ui_file *stream)
static int dos_drain_output(struct serial *scb)
static serial_ttystate dos_copy_tty_state(struct serial *scb, serial_ttystate ttystate)
static int dos_sendbreak(struct serial *scb)
static struct intrupt intrupts[NINTR]
static int dos_flush_output(struct serial *scb)
static serial_ttystate dos_get_tty_state(struct serial *scb)
static void dos_raw(struct serial *scb)
unsigned char icu_oldmask
static int dos_getc(volatile struct dos_ttystate *port)
static void info_serial_command(const char *arg, int from_tty)
static int dos_write(struct serial *scb, const void *buf, size_t count)
static int dos_setparity(struct serial *scb, int parity)
static struct dos_ttystate ports[4]
static int dos_setbaudrate(struct serial *scb, int rate)
static struct intrupt * dos_hookirq(unsigned int irq)
static const struct serial_ops dos_ops
static int dos_putc(int c, struct dos_ttystate *port)
static int dos_baudconv(int rate)
static void dos_close(struct serial *scb)
static int dos_readchar(struct serial *scb, int timeout)
void _initialize_ser_dos()
static const char * parity
void serial_add_interface(const struct serial_ops *optable)
#define SERIAL_2_STOPBITS
#define SERIAL_1_AND_A_HALF_STOPBITS
#define SERIAL_1_STOPBITS
unsigned char cbuf[CBSIZE]
_go32_dpmi_registers regs
_go32_dpmi_seginfo old_pmhandler
_go32_dpmi_seginfo old_rmhandler
_go32_dpmi_seginfo new_pmhandler
_go32_dpmi_seginfo new_rmhandler
struct dos_ttystate * port
void gdb_printf(struct ui_file *stream, const char *format,...)