use the portable 8250 uart code. this also fixes console printing oddities. Reference: /n/atom/patch/applied2013/rbserial Date: Mon Aug 5 03:36:53 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/rb/main.c Mon Aug 5 03:36:24 2013 +++ /sys/src/9/rb/main.c Mon Aug 5 03:36:25 2013 @@ -11,6 +11,7 @@ #include #include "reboot.h" +extern char bootmethod[]; usize segpgsizes = (1<regs; + if(on) + intrenable(c->irq, rbinterrupt, u /*, u->name*/); + else + /* this causes hangs. please debug. (on a pc; not tried yet) */ +// return intrdisable(c->irq, rbinterrupt, u, u->name); + return -1; + return 0; +} + +PhysUart rbphysuart; + +static Ctlr rbctlr = { + .reg = (void*)PHYSCONS, + .get = ioget, + .set = ioset, + .itr = itr, + .irq = ILduart0, +}; + +static Uart rbuart = { + .regs = &rbctlr, + .name = "cons", + .freq = 3686000, /* Not used, we use the global i8250freq */ + .baud = 115200, /* switching doesn't work */ + .phys = &rbphysuart, + .special = 1, + .console = 0, + .next = nil, +}; + +static Uart* +rb8250pnp(void) +{ + return &rbuart; +} + +void* +i8250alloc(int io, int irq, int tbdf) +{ + Ctlr *ctlr; + + if((ctlr = malloc(sizeof(Ctlr))) != nil){ + ctlr->reg = (void*)io; + ctlr->irq = irq; + ctlr->tbdf = tbdf; + ctlr->get = ioget; + ctlr->set = ioset; + ctlr->itr = itr; + } + return ctlr; +} + +int +i8250console(void) +{ + int n; + char *cmd; + static int once; + + if(once == 0){ + once = 1; + memmove(&rbphysuart, &p8250physuart, sizeof(PhysUart)); + rbphysuart.name = "rb"; + rbphysuart.pnp = rb8250pnp; + } + + n = uartconsconf(&cmd); + if(n == 0){ + qlock(&rbuart); + uartctl(&rbuart, "z"); + uartctl(&rbuart, cmd); + qunlock(&rbuart); + } + return 0; +}