=================================================================== RCS file: /cvs/funnyos/arch/testarm/dev/tacons.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- funnyos/arch/testarm/dev/tacons.c 2007/10/16 09:41:04 1.1 +++ funnyos/arch/testarm/dev/tacons.c 2007/10/16 21:28:24 1.2 @@ -1,9 +1,10 @@ /* - * $Id: tacons.c,v 1.1 2007/10/16 08:41:04 init Exp $ + * $Id: tacons.c,v 1.2 2007/10/16 20:28:24 init Exp $ */ #include #include #include + #include #include #include @@ -12,62 +13,67 @@ * testarm console support. */ -#if 0 -struct consoleops tacons_dd[NTACONS]; - -int tacons_attach(struct device *); -char tacons_getc(struct device *); -void tacons_putc(struct device *, char); +int tacons_attach(struct device *, uint32_t, uint8_t); +char tacons_getc(void *); +void tacons_putc(void *, char); void tacons_early_putc(char); +struct driver tacons_dr = { + sizeof(struct tacons_dd), + tacons_attach, + NULL +}; + int -tacons_attach(struct device *self) +tacons_attach(struct device *self, uint32_t loc, uint8_t flags) { - struct consoleops *aux = self->dv_aux; - aux = kmalloc(sizeof(struct consoleops)); + struct tacons_dd *ddp = self->dv_devdata; + struct consoleops *cop = &ddp->td_consops; - aux->getc = tacons_getc; - aux->putc = tacons_putc; + /* aquire bus handle from parent */ + ddp->td_bhp = self->dv_parent->dv_aux; - printf("testarm simple console (non-blocking, halt)\n"); + /* all reads/writes will use this addr; in testarm cons this is the same addr for getc/putc */ + ddp->td_ioaddr = loc; - /* - * XXX test putc() & getc() - * and TODO: think carefully about console abstraction layer and early printf's - * in particular printing root/0, obio and cpu at the fcons during attachment. - */ + /* we export struct consoleops */ + cop->getc = tacons_getc; + cop->putc = tacons_putc; + self->dv_aux = cop; + + printf("testarm simple console (non-blocking, halt)\n"); + return(0); } char -tacons_getc(struct device *devp) +tacons_getc(void *ddp) { /* * Get a character from the console. * Remember that this console is non-blocking. */ - - return( bus_read_1(devp->dv_parent, devp->dv_locator ? devp->dv_locator + TACONS_OFF_IO : TACONS_REG_BASE + TACONS_OFF_IO) ); - + struct tacons_dd *tdp = ddp; + + return( bus_read_1(tdp->td_bhp, tdp->td_ioaddr) ); } void -tacons_putc(struct device *devp, char ch) +tacons_putc(void *ddp, char ch) { /* * Write a character to the console. */ + struct tacons_dd *tdp = ddp; - bus_write_1(devp->dv_parent, devp->dv_locator ? devp->dv_locator + TACONS_OFF_IO : TACONS_REG_BASE + TACONS_OFF_IO, ch); - - return; + return( bus_write_1(tdp->td_dhp, tdp->td_ioaddr, ch) ); } -#endif /* not 0 */ + void tacons_early_putc(char ch) {