=================================================================== RCS file: /cvs/funnyos/arch/testarm/dev/tacons.c,v retrieving revision 1.1.1.1 retrieving revision 1.7 diff -u -r1.1.1.1 -r1.7 --- funnyos/arch/testarm/dev/tacons.c 2007/10/16 09:41:04 1.1.1.1 +++ funnyos/arch/testarm/dev/tacons.c 2008/01/11 15:25:20 1.7 @@ -1,10 +1,12 @@ /* - * $Id: tacons.c,v 1.1.1.1 2007/10/16 08:41:04 init Exp $ + * $Id: tacons.c,v 1.7 2008/01/11 15:25:20 nbrk Exp $ */ #include #include #include + #include +#include #include #include @@ -12,62 +14,72 @@ * 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); +void tacons_interrupt(struct device *self); +struct driver tacons_dr = { + sizeof(struct tacons_dd), + tacons_attach, + NULL, + tacons_interrupt +}; + 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 fcons_handle *fhp = &ddp->td_fh; - 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 fcons_handle */ + fhp->getc = tacons_getc; + fhp->putc = tacons_putc; + /* give our dd to fcons_handle */ + fhp->fh_ownerdd = ddp; + + self->dv_aux = fhp; + + 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; + bus_write_1(tdp->td_bhp, tdp->td_ioaddr, ch); } -#endif /* not 0 */ + void tacons_early_putc(char ch) { @@ -77,5 +89,17 @@ */ *(char *)(TACONS_REG_BASE + TACONS_OFF_IO) = ch; +} + + +void +tacons_interrupt(struct device *self) +{ + struct tacons_dd *ddp = (struct tacons_dd *)self->dv_devdata; + char ch; + + ch = bus_read_1(ddp->td_bhp, ddp->td_ioaddr); + + fcons_ienqueue(ch); }