=================================================================== RCS file: /cvs/funnyos/dev/fcons/fcons.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- funnyos/dev/fcons/fcons.c 2007/10/16 09:41:04 1.1 +++ funnyos/dev/fcons/fcons.c 2007/10/16 22:41:36 1.2 @@ -1,5 +1,5 @@ /* - * $Id: fcons.c,v 1.1 2007/10/16 08:41:04 init Exp $ + * $Id: fcons.c,v 1.2 2007/10/16 21:41:36 init Exp $ */ #include #include @@ -11,37 +11,34 @@ * 80x25, monochrome. */ -struct fcons_devdata fcons_dd[NFCONS]; - /* current console device */ -struct device *curcons; +struct fcons_dd *curcons; extern void (*putchar)(char); -int fcons_attach(struct device *); -void fcons_putchar(struct device *, char); -char fcons_getchar(struct device *); +int fcons_attach(struct device *, uint32_t loc, uint8_t flags); +void fcons_putchar(void *ddp, char); +char fcons_getchar(void *ddp); void fcons_dfltputchar(char); int fcons_devctl(struct device *, uint8_t, void *); +struct driver fcons_dr = { + sizeof(struct fcons_dd), + fcons_attach, + NULL +}; + int -fcons_attach(struct device *self) +fcons_attach(struct device *self, uint32_t loc, uint8_t size) { - /* - * Attach fcons abstraction using parent's getc & putc. - */ - /* associate dev data */ - self->dv_devdata = &fcons_dd[self->dv_minor]; + struct fcons_dd *ddp = self->dv_devdata; - fcons_dd[self->dv_minor].currow = 0; - fcons_dd[self->dv_minor].curcol = 0; + ddp->fd_currow = 0; + ddp->fd_curcol = 0; - /* make cureent console default */ - curcons = self; + /* make current console default */ + curcons = ddp; - /* - * XXX Register system printf's , etc.. - */ /* override early putchar */ putchar = fcons_dfltputchar; @@ -52,33 +49,34 @@ void -fcons_putchar(struct device *devp, char ch) +fcons_putchar(void *ddp, char ch) { - struct consoleops *copsp; + struct fcons_dd *fdp = ddp; + struct fcons_handle *fhp = &fdp->fd_fh; - copsp = devp->dv_parent->dv_devdata; - - if (fcons_dd[devp->dv_minor].curcol == (FCONS_WIDTH - 1)) { + /* if we reach screen width */ + if (fdp->fd_curcol == (FCONS_WIDTH - 1)) { /* CRLF */ - fcons_dd[devp->dv_minor].curcol = 0; - fcons_dd[devp->dv_minor].currow++; + fdp->fd_curcol = 0; + fdp->fd_currow++; /* XXX pass \n to lower level (not all devices work this way) */ - copsp->putc(devp->dv_parent, '\n'); + fhp->putc(fhp->fh_ownerdd, '\n'); } /* XXX do something if col == FCONS_HEIGHT; console buffer? */ - if (fcons_dd[devp->dv_minor].currow == FCONS_HEIGHT) { - /* tmp hack; should really follow clrscr */ - fcons_dd[devp->dv_minor].currow = 0; + /* if we reach the bottom of the screen */ + if (fdp->fd_currow == FCONS_HEIGHT) { + /* XXX tmp hack; should really follow clrscr */ + fdp->fd_currow = 0; } - copsp->putc(devp->dv_parent, ch); + fhp->putc(fhp->fh_ownerdd, ch); } char -fcons_getchar(struct device *devp) +fcons_getchar(void *ddp) { /* TODO */ return ' '; @@ -96,7 +94,7 @@ return; } - +#if 0 int fcons_devctl(struct device *devp, uint8_t ctl, void *data) { @@ -126,4 +124,5 @@ } } +#endif /* not 0 */