31 #define COM1ADDR 0x3f8 32 #define COM2ADDR 0x2f8 33 #define COM3ADDR 0x3e8 34 #define COM4ADDR 0x3e0 54 #define COMTICK (1843200/16) 55 #define SPEED_TOLERANCE 30 58 #define IER_ERXRDY 0x1 59 #define IER_ETXRDY 0x2 64 #define IIR_FIFO_MASK 0xc0 66 #define IIR_NOPEND 0x1 69 #define IIR_RXTOUT 0xc 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 85 #define CFCR_DLAB 0x80 86 #define CFCR_SBREAK 0x40 87 #define CFCR_PZERO 0x30 88 #define CFCR_PONE 0x20 89 #define CFCR_PEVEN 0x10 90 #define CFCR_PODD 0x00 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 107 #define LSR_TSRE 0x40 108 #define LSR_TXRDY 0x20 113 #define LSR_RXRDY 0x01 114 #define LSR_RCV_MASK 0x1f 121 #define MSR_DDCD 0x08 122 #define MSR_TERI 0x04 123 #define MSR_DDSR 0x02 124 #define MSR_DCTS 0x01 133 #define FIFO_TRIGGER FIFO_TRIGGER_4 148 static size_t cnts[NCNT];
149 static 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]++ 166 #define ICU_BASE 0x20 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
230 static 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);} 357 typedef
void (*isr_t) (
void);
359 static 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
912 for (i = 0; i < NCNT; i++)
932 Set COM1 base i/o port address."),
_(
"\ 933 Show COM1 base i/o port address."), NULL,
939 Set COM1 interrupt request."),
_(
"\ 940 Show COM1 interrupt request."), NULL,
946 Set COM2 base i/o port address."),
_(
"\ 947 Show COM2 base i/o port address."), NULL,
953 Set COM2 interrupt request."),
_(
"\ 954 Show COM2 interrupt request."), NULL,
960 Set COM3 base i/o port address."),
_(
"\ 961 Show COM3 base i/o port address."), NULL,
967 Set COM3 interrupt request."),
_(
"\ 968 Show COM3 interrupt request."), NULL,
974 Set COM4 base i/o port address."),
_(
"\ 975 Show COM4 base i/o port address."), NULL,
981 Set COM4 interrupt request."),
_(
"\ 982 Show COM4 interrupt request."), NULL,
988 _(
"Print DOS serial port status."));
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
_go32_dpmi_seginfo old_pmhandler
_go32_dpmi_seginfo new_rmhandler
static int dos_readchar(struct serial *scb, int timeout)
static int dos_write(struct serial *scb, const void *buf, size_t count)
static int dos_getc(volatile struct dos_ttystate *port)
_go32_dpmi_seginfo new_pmhandler
static int dos_sendbreak(struct serial *scb)
void _initialize_ser_dos(void)
unsigned char icu_oldmask
_go32_dpmi_registers regs
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
static struct dos_ttystate ports[4]
static void dos_raw(struct serial *scb)
static void dos_print_tty_state(struct serial *scb, serial_ttystate ttystate, struct ui_file *stream)
static int dos_setbaudrate(struct serial *scb, int rate)
static int dos_open(struct serial *scb, const char *name)
static void info_serial_command(const char *arg, int from_tty)
void printf_filtered(const char *format,...)
struct cmd_list_element * setlist
static int dos_set_tty_state(struct serial *scb, serial_ttystate state)
static void dos_comisr(int irq)
void 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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
unsigned char cbuf[CBSIZE]
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct cmd_list_element * showlist
static const struct serial_ops dos_ops
static struct intrupt intrupts[NINTR]
static int dos_flush_output(struct serial *scb)
static const char * parity
static void dos_close(struct serial *scb)
static serial_ttystate dos_copy_tty_state(struct serial *scb, serial_ttystate ttystate)
static struct intrupt * dos_hookirq(unsigned int irq)
#define SERIAL_1_AND_A_HALF_STOPBITS
int gdb_pipe(int pdes[2])
#define SERIAL_1_STOPBITS
static int dos_setstopbits(struct serial *scb, int num)
_go32_dpmi_seginfo old_rmhandler
#define SERIAL_2_STOPBITS
void serial_add_interface(const struct serial_ops *optable)
static serial_ttystate dos_get_tty_state(struct serial *scb)
struct dos_ttystate * port
static void dos_unhookirq(struct intrupt *intr)
static int dos_putc(int c, struct dos_ttystate *port)
static int dos_flush_input(struct serial *scb)
static int dos_baudconv(int rate)
static int dos_setparity(struct serial *scb, int parity)
static int dos_drain_output(struct serial *scb)