X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=sys%2Fsrc%2F9%2Fpc%2Fuarti8250.c;h=de5156d2cc47b9dfc95f7b27ecca60fc4dc5970e;hb=e38f75fc45bba789ceea05d5e62f1d8662bf508b;hp=aba0be90c1630035b00f03c400d36c8588ba8d03;hpb=bf3476d661e05208b78f70cdaa5656ff77264d23;p=plan9front.git diff --git a/sys/src/9/pc/uarti8250.c b/sys/src/9/pc/uarti8250.c index aba0be90c..de5156d2c 100644 --- a/sys/src/9/pc/uarti8250.c +++ b/sys/src/9/pc/uarti8250.c @@ -14,8 +14,6 @@ enum { Uart0IRQ = 4, Uart1 = 0x2F8, /* COM2 */ Uart1IRQ = 3, - Uart2 = 0x200, /* COM3 */ - Uart2IRQ = 5, UartFREQ = 1843200, }; @@ -123,7 +121,7 @@ typedef struct Ctlr { extern PhysUart i8250physuart; -static Ctlr i8250ctlr[3] = { +static Ctlr i8250ctlr[2] = { { .io = Uart0, .irq = Uart0IRQ, .tbdf = BUSUNKNOWN, }, @@ -131,13 +129,9 @@ static Ctlr i8250ctlr[3] = { { .io = Uart1, .irq = Uart1IRQ, .tbdf = BUSUNKNOWN, }, - -{ .io = Uart2, - .irq = Uart2IRQ, - .tbdf = BUSUNKNOWN, }, }; -static Uart i8250uart[3] = { +static Uart i8250uart[2] = { { .regs = &i8250ctlr[0], .name = "COM1", .freq = UartFREQ, @@ -150,13 +144,6 @@ static Uart i8250uart[3] = { .freq = UartFREQ, .phys = &i8250physuart, .special= 0, - .next = &i8250uart[2], }, - -{ .regs = &i8250ctlr[2], - .name = "COM3", - .freq = UartFREQ, - .phys = &i8250physuart, - .special= 0, .next = nil, }, }; @@ -555,8 +542,8 @@ i8250disable(Uart* uart) csr8w(ctlr, Ier, ctlr->sticky[Ier]); if(ctlr->iena != 0){ - if(intrdisable(ctlr->irq, i8250interrupt, uart, ctlr->tbdf, uart->name) == 0) - ctlr->iena = 0; + ctlr->iena = 0; + intrdisable(ctlr->irq, i8250interrupt, uart, ctlr->tbdf, uart->name); } } @@ -634,12 +621,14 @@ i8250alloc(int io, int irq, int tbdf) { Ctlr *ctlr; - if((ctlr = malloc(sizeof(Ctlr))) != nil){ - ctlr->io = io; - ctlr->irq = irq; - ctlr->tbdf = tbdf; + ctlr = malloc(sizeof(Ctlr)); + if(ctlr == nil){ + print("i8250alloc: no memory for Ctlr\n"); + return nil; } - + ctlr->io = io; + ctlr->irq = irq; + ctlr->tbdf = tbdf; return ctlr; } @@ -704,21 +693,9 @@ i8250console(void) if((p = getconf("console")) == nil) return; n = strtoul(p, &cmd, 0); - if(p == cmd) + if(p == cmd || n < 0 || n >= nelem(i8250uart)) return; - switch(n){ - default: - return; - case 0: - uart = &i8250uart[0]; - break; - case 1: - uart = &i8250uart[1]; - break; - case 2: - uart = &i8250uart[2]; - break; - } + uart = &i8250uart[n]; (*uart->phys->enable)(uart, 0); uartctl(uart, "b9600 l8 pn s1"); @@ -728,28 +705,3 @@ i8250console(void) consuart = uart; uart->console = 1; } - -void -i8250mouse(char* which, int (*putc)(Queue*, int), int setb1200) -{ - char *p; - int port; - - port = strtol(which, &p, 0); - if(p == which || port < 0 || port > 1) - error(Ebadarg); - uartmouse(&i8250uart[port], putc, setb1200); -} - -void -i8250setmouseputc(char* which, int (*putc)(Queue*, int)) -{ - char *p; - int port; - - port = strtol(which, &p, 0); - if(p == which || port < 0 || port > 1) - error(Ebadarg); - uartsetmouseputc(&i8250uart[port], putc); - -}