--- Gnu-Mach/i386/i386at/com.c 2020/09/02 04:36:58 1.1.1.1 +++ Gnu-Mach/i386/i386at/com.c 2020/09/02 04:46:54 1.1.1.3 @@ -24,14 +24,18 @@ * the rights to redistribute these changes. */ -#include #if NCOM > 0 +#include +#include + #include #include +#include +#include #include #include -#include +#include #include #include @@ -39,17 +43,17 @@ #include #include #include +#include +#include #include -#include -#include - -extern void timeout(), ttrstrt(); +#include -int comprobe(), comintr(), comstart(), commctl(); -void comattach(); +int comprobe(), commctl(); +void comstart(struct tty *); +void comstop(), comattach(), comintr(); static void comparam(); -int comstop(), comgetstat(), comsetstat(); +int comgetstat(), comsetstat(); static vm_offset_t com_std[NCOM] = { 0 }; struct bus_device *cominfo[NCOM]; @@ -63,14 +67,12 @@ boolean_t comfifo[NCOM]; boolean_t comtimer_active; int comtimer_state[NCOM]; -#if RCLINE >= 0 #define RCBAUD B9600 +static int rcline = -1; static struct bus_device *comcndev; -int comcnprobe(struct consdev *cp); -int comcninit(struct consdev *cp); -int comcngetc(dev_t dev, int wait); -int comcnputc(dev_t dev, int c); -#endif + +/* XX */ +extern char *kernel_cmdline; #ifndef PORTSELECTOR #define ISPEED B9600 @@ -85,7 +87,7 @@ u_short divisorreg[] = { 857, 768, 576, 384, 192, /* 134.5, 150, 200, 300, 600*/ 96, 64, 48, /* 1200, 1800, 2000, 2400 */ 24, 12, /* 3600, 4800, 7200, 9600 */ - 6, 3, 2}; /* 19200, 38400, 56000 */ + 6, 3, 2, 1}; /* 19200, 38400, 56000,115200 */ /* @@ -176,7 +178,6 @@ comprobe(int port, struct bus_device *de return comprobe_general(dev, /*noisy*/ 0); } -#if RCLINE >= 0 /* * Probe routine for use by the console */ @@ -186,13 +187,19 @@ comcnprobe(struct consdev *cp) struct bus_device *b; int maj, unit, pri; +#define CONSOLE_PARAMETER " console=com" + u_char *console = (u_char *) strstr(kernel_cmdline, CONSOLE_PARAMETER); + + if (console) + mach_atoi(console + strlen(CONSOLE_PARAMETER), &rcline); + maj = 0; unit = -1; pri = CN_DEAD; for (b = bus_device_init; b->driver; b++) if (strcmp(b->name, "com") == 0 - && b->unit == RCLINE + && b->unit == rcline && comprobe_general(b, /*quiet*/ 0)) { /* Found one */ @@ -204,8 +211,9 @@ comcnprobe(struct consdev *cp) cp->cn_dev = makedev(maj, unit); cp->cn_pri = pri; + + return 0; } -#endif /* @@ -221,7 +229,7 @@ comattach(struct bus_device *dev) u_short addr = dev->address; take_dev_irq(dev); - printf(", port = %x, spl = %d, pic = %d. (DOS COM%d)", + printf(", port = %lx, spl = %ld, pic = %d. (DOS COM%d)", dev->address, dev->sysdep, dev->sysdep1, unit+1); /* comcarrier[unit] = addr->flags;*/ @@ -236,7 +244,6 @@ comattach(struct bus_device *dev) } } -#if RCLINE >= 0 /* * Attach/init routine for console. This isn't called by * configure_bus_device which sets the alive, adaptor, and minfo @@ -258,7 +265,7 @@ comcninit(struct consdev *cp) outb(LINE_CTL(addr), iDLAB); outb(BAUD_LSB(addr), divisorreg[RCBAUD] & 0xff); outb(BAUD_MSB(addr), divisorreg[RCBAUD] >>8); - outb(LINE_CTL(addr), i7BITS|iPEN); + outb(LINE_CTL(addr), i8BITS); outb(INTR_ENAB(addr), 0); outb(MODEM_CTL(addr), iDTR|iRTS|iOUT2); @@ -278,8 +285,8 @@ comcninit(struct consdev *cp) } } + return 0; } -#endif /* * Probe for COM after autoconfiguration. @@ -328,13 +335,13 @@ io_return_t comopen( io_return_t result; if (unit >= NCOM) - return ENXIO; /* no such device */ + return D_NO_SUCH_DEVICE; /* no such device */ if ((isai = cominfo[unit]) == 0 || isai->alive == 0) { /* * Try to probe it again */ if (!com_reprobe(unit)) - return ENXIO; + return D_NO_SUCH_DEVICE; } tp = &com_tty[unit]; @@ -382,7 +389,7 @@ io_return_t comopen( if (!comtimer_active) { comtimer_active = TRUE; - comtimer(); + comtimer(NULL); } s = spltty(); @@ -432,7 +439,7 @@ io_return_t comportdeath(dev, port) dev_t dev; mach_port_t port; { - return (tty_portdeath(&com_tty[minor(dev)], port)); + return (tty_portdeath(&com_tty[minor(dev)], (ipc_port_t)port)); } io_return_t @@ -440,7 +447,7 @@ comgetstat(dev, flavor, data, count) dev_t dev; int flavor; int *data; /* pointer to OUT array */ -unsigned int *count; /* out */ +natural_t *count; /* out */ { io_return_t result = D_SUCCESS; int unit = minor(dev); @@ -463,7 +470,7 @@ comsetstat(dev, flavor, data, count) dev_t dev; int flavor; int * data; -unsigned int count; +natural_t count; { io_return_t result = D_SUCCESS; int unit = minor(dev); @@ -488,6 +495,7 @@ unsigned int count; return (D_SUCCESS); } +void comintr(unit) int unit; { @@ -527,7 +535,7 @@ int unit; ((tp->t_flags&(EVENP|ODDP)) == EVENP || (tp->t_flags&(EVENP|ODDP)) == ODDP)) { /* parity error */; - } else if (line&iOR && !comoverrun) { + } else if (line_stat&iOR && !comoverrun) { printf("com%d: overrun\n", unit); comoverrun = 1; } else if (line_stat & (iFE | iBRKINTR)) { @@ -586,6 +594,7 @@ register int unit; splx(s); } +void comparm(int unit, int baud, int intr, int mode, int modem) { u_short addr = (u_short)(cominfo[unit]->address); @@ -607,16 +616,18 @@ comparm(int unit, int baud, int intr, in int comst_1, comst_2, comst_3, comst_4, comst_5 = 14; -int +void comstart(tp) struct tty *tp; { char nch; +#if 0 int i; +#endif if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP|TS_BUSY)) { comst_1++; - return(0); + return; } if ((!queue_empty(&tp->t_delayed_write)) && (tp->t_outq.c_cc <= TTLOWAT(tp))) { @@ -625,7 +636,7 @@ comst_2++; } if (!tp->t_outq.c_cc) { comst_3++; - return(0); + return; } #if 0 @@ -646,21 +657,21 @@ comst_4++; #else nch = getc(&tp->t_outq); if ((nch & 0200) && ((tp->t_flags & LITOUT) == 0)) { - timeout(ttrstrt, (char *)tp, (nch & 0x7f) + 6); + timeout((timer_func_t *)ttrstrt, (char *)tp, (nch & 0x7f) + 6); tp->t_state |= TS_TIMEOUT; comst_4++; - return(0); + return; } outb(TXRX((int)tp->t_addr), nch); tp->t_state |= TS_BUSY; #endif - return(0); } /* Check for stuck xmitters */ int comtimer_interval = 5; -comtimer() +void +comtimer(void * param) { spl_t s = spltty(); struct tty *tp = com_tty; @@ -674,7 +685,7 @@ comtimer() if (++comtimer_state[i] < 2) continue; /* Its stuck */ -printf("Tty %x was stuck\n", tp); +printf("Tty %p was stuck\n", tp); nch = getc(&tp->t_outq); outb(TXRX((int)tp->t_addr), nch); } @@ -686,6 +697,7 @@ printf("Tty %x was stuck\n", tp); /* * Set receive modem state from modem status register. */ +void fix_modem_state(unit, modem_stat) int unit, modem_stat; { @@ -707,6 +719,7 @@ int unit, modem_stat; /* * Modem change (input signals) */ +void commodem_intr( int unit, int stat) @@ -736,6 +749,7 @@ commodem_intr( /* * Set/get modem bits */ +int commctl( register struct tty *tp, int bits, @@ -744,7 +758,7 @@ commctl( spl_t s; int unit; vm_offset_t dev_addr; - register int b; + register int b = 0; /* Suppress gcc warning */ unit = minor(tp->t_dev); @@ -802,6 +816,7 @@ commctl( return commodem[unit]; } +void comstop(tp, flags) register struct tty *tp; int flags; @@ -854,7 +869,6 @@ comgetc(int unit) return c; } -#if RCLINE >= 0 /* * Routines for the console */ @@ -871,6 +885,8 @@ comcnputc(dev_t dev, int c) if (c == '\n') comcnputc(dev, '\r'); outb(addr, c); + + return 0; } int @@ -886,6 +902,5 @@ comcngetc(dev_t dev, int wait) c = inb(TXRX(addr)); return c & 0x7f; } -#endif /* RCLINE */ #endif /* NCOM */