--- serial.c.orig Fri Nov 13 14:09:10 1998 +++ serial.c Wed Jan 20 03:31:04 1999 @@ -1,3 +1,4 @@ +/* 20/01/1999 - set the speed to 9600bps -- Jacek */ #include #include #include @@ -28,6 +29,8 @@ #define CONSOLE_PORT 0 +int intok=0; + static struct serial_info ports[4]= { { 0x3f8,4,0,0 }, @@ -62,17 +65,35 @@ struct inode *inode; struct file *file; { +int ile=16; + int rs_minor = MINOR(inode->i_rdev) - RS_MINOR_OFFSET; printd_rs("RS_OPEN called\n"); if (!(ports[rs_minor].flags & SERF_EXIST)) return -ENODEV; + +intok=1; /* Let there be interrupts --sq5bpf */ + if (!rs_in_use[rs_minor]) { rs_in_use[rs_minor] = 1; inb_p(ports[rs_minor].io + UART_LSR); do { inb_p(ports[rs_minor].io + UART_RX); - } while (inb_p(ports[rs_minor].io + UART_LSR) & UART_LSR_DR); +ile--; + } while ((ile!=0)&&(inb_p(ports[rs_minor].io + UART_LSR) & UART_LSR_DR)); + +/* set speed to 9600bps */ +/* this should be probably in rs_init() */ +/* DLAB=1 */ +outb_p(inb_p(ports[rs_minor].io+UART_LCR)|0x80,ports[rs_minor].io+UART_LCR); +outb_p(0,ports[rs_minor].io+UART_DLM); +/* 115200/9600=12, change to 48 if you want 2400bps */ +outb_p(12,ports[rs_minor].io+UART_DLL); +/* DLAB=0 */ +outb_p(inb_p(ports[rs_minor].io+UART_LCR)&0x7f,ports[rs_minor].io+UART_LCR); + + inb_p(ports[rs_minor].io + UART_IIR); inb_p(ports[rs_minor].io + UART_MSR); /* outb_p(UART_LCR_WLEN8 | UART_LCR_DLAB, ports[rs_minor].io + UART_LCR); @@ -81,6 +102,7 @@ outb_p(UART_LCR_WLEN8, ports[rs_minor].io + UART_LCR); outb_p(UART_IER_RDI, ports[rs_minor].io + UART_IER); outb_p(UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2, ports[rs_minor].io + UART_MCR); + /* inb_p(ports[rs_minor].io + UART_LSR); inb_p(ports[rs_minor].io + UART_RX); inb_p(ports[rs_minor].io + UART_IIR); @@ -122,8 +144,9 @@ if (ch == '\r') ch = '\n'; chq_addch(&sp->tty->inq, ch); - } while (inb_p(sp->io + UART_LSR) & UART_LSR_DR); + } while (((inb_p(sp->io + UART_LSR) & UART_LSR_DR)>0)&intok); } + /* void transmit_chars(sp) struct serial_info *sp; @@ -143,7 +166,6 @@ register struct serial_info * sp; unsigned char ch; printd_rs1("Serial interrupt %d recieved.\n", irq); - sp = &ports[irq_port[irq -2]]; do { status = inb_p(sp->io + UART_LSR); @@ -152,7 +174,7 @@ } /* if (status & UART_LSR_THRE) transmit_chars(sp); */ - } while (!(inb_p(sp->io + UART_IIR) & UART_IIR_NO_INT)); + } while (intok&(!(inb_p(sp->io + UART_IIR) & UART_IIR_NO_INT))); } .. .