=================================================================== RCS file: /cvs/funnyos/dev/fcons/fcons.c,v retrieving revision 1.2 retrieving revision 1.5 diff -u -r1.2 -r1.5 --- funnyos/dev/fcons/fcons.c 2007/10/16 22:41:36 1.2 +++ funnyos/dev/fcons/fcons.c 2008/01/11 15:36:01 1.5 @@ -1,10 +1,11 @@ /* - * $Id: fcons.c,v 1.2 2007/10/16 21:41:36 init Exp $ + * $Id: fcons.c,v 1.5 2008/01/11 15:36:01 nbrk Exp $ */ #include #include #include #include +#include /* * funnyOS console. @@ -25,6 +26,7 @@ struct driver fcons_dr = { sizeof(struct fcons_dd), fcons_attach, + NULL, NULL }; @@ -33,9 +35,17 @@ { struct fcons_dd *ddp = self->dv_devdata; + /* link our parent's dv_aux (fcons_handle) to us */ + ddp->fd_fh = self->dv_parent->dv_aux; + ddp->fd_currow = 0; ddp->fd_curcol = 0; + /* initialize iqueue */ +// ddp->fd_iqhead = SIMPLEQ_HEAD_INITIALIZER(ddp->fd_iqhead); + SIMPLEQ_INIT(ddp->head); + ddp->fd_iqlength = 0; + /* make current console default */ curcons = ddp; @@ -52,7 +62,7 @@ fcons_putchar(void *ddp, char ch) { struct fcons_dd *fdp = ddp; - struct fcons_handle *fhp = &fdp->fd_fh; + struct fcons_handle *fhp = fdp->fd_fh; /* if we reach screen width */ if (fdp->fd_curcol == (FCONS_WIDTH - 1)) { @@ -92,6 +102,42 @@ fcons_putchar(curcons, ch); return; +} + + +void +fcons_ienqueue(char ch) +{ + /* + * Enqueue character into the input data queue. + */ + struct fcons_dd *ddp; + struct fcons_char *curfc; + uint32_t i; + + /* XXX will use curcons devdata */ + ddp = curcons; + +#if 0 + if (ddp->fd_iqueue == NULL) { + /* first insertion */ + curfc = kmalloc(sizeof(struct fcons_char)); + + if(curfc == NULL) + panic("fcons_ienqueue: can't allocate memory for new element\n"); + } else { + curfc = ddp->fd_iqueue; + + /* locate last element */ + for(i = 0; i < ddp->fd_iqlength - 1; i++) + curfc = curfc->fc_next; + } +#endif + curfc = kmalloc(sizeof(struct fcons_char)); + if(curfc == NULL) + panic("fcons_ienqueue: can't allocate memory for new element\n"); + + SIMPLEQ_INSERT_TAIL(ddp->fd_iqhead, curfc, fc_next); } #if 0