[BACK]Return to tacons.c CVS log [TXT][DIR] Up to [local] / funnyos / arch / testarm / dev

Annotation of funnyos/arch/testarm/dev/tacons.c, Revision 1.6

1.1       init        1: /*
1.6     ! init        2:  * $Id: tacons.c,v 1.5 2007/10/16 21:34:49 init Exp $
1.1       init        3:  */
                      4: #include <sys/types.h>
                      5: #include <sys/device.h>
                      6: #include <sys/bus.h>
1.2       init        7:
1.1       init        8: #include <arch/testarm/dev/taconsreg.h>
1.4       init        9: #include <arch/testarm/dev/taconsvar.h>
1.1       init       10: #include <dev/fcons/fconsvar.h>
                     11: #include <libkern/printf.h>
                     12:
                     13: /*
                     14:  * testarm console support.
                     15:  */
                     16:
1.2       init       17: int    tacons_attach(struct device *, uint32_t, uint8_t);
                     18: char   tacons_getc(void *);
                     19: void   tacons_putc(void *, char);
                     20: void   tacons_early_putc(char);
1.1       init       21:
1.2       init       22: struct driver tacons_dr = {
                     23:        sizeof(struct tacons_dd),
                     24:        tacons_attach,
1.6     ! init       25:        NULL,
1.2       init       26:        NULL
                     27: };
1.1       init       28:
                     29:
                     30: int
1.2       init       31: tacons_attach(struct device *self, uint32_t loc, uint8_t flags)
1.1       init       32: {
1.2       init       33:        struct tacons_dd *ddp = self->dv_devdata;
1.4       init       34:        struct fcons_handle *fhp = &ddp->td_fh;
1.2       init       35:
                     36:        /* aquire bus handle from parent */
                     37:        ddp->td_bhp = self->dv_parent->dv_aux;
1.1       init       38:
1.2       init       39:        /* all reads/writes will use this addr; in testarm cons this is the same addr for getc/putc */
                     40:        ddp->td_ioaddr = loc;
                     41:
1.3       init       42:        /* we export struct fcons_handle */
                     43:        fhp->getc = tacons_getc;
                     44:        fhp->putc = tacons_putc;
1.4       init       45:
                     46:        /* give our dd to fcons_handle */
                     47:        fhp->fh_ownerdd = ddp;
1.2       init       48:
1.3       init       49:        self->dv_aux = fhp;
1.1       init       50:
                     51:        printf("testarm simple console (non-blocking, halt)\n");
                     52:
                     53:        return(0);
                     54: }
                     55:
                     56:
                     57: char
1.2       init       58: tacons_getc(void *ddp)
1.1       init       59: {
                     60:        /*
                     61:         * Get a character from the console.
                     62:         * Remember that this console is non-blocking.
                     63:         */
1.2       init       64:        struct tacons_dd *tdp = ddp;
                     65:
                     66:        return( bus_read_1(tdp->td_bhp, tdp->td_ioaddr) );
1.1       init       67: }
                     68:
                     69:
                     70: void
1.2       init       71: tacons_putc(void *ddp, char ch)
1.1       init       72: {
                     73:        /*
                     74:         * Write a character to the console.
                     75:         */
1.2       init       76:        struct tacons_dd *tdp = ddp;
1.1       init       77:
1.5       init       78:        bus_write_1(tdp->td_bhp, tdp->td_ioaddr, ch);
1.1       init       79: }
                     80:
1.2       init       81:
1.1       init       82: void
                     83: tacons_early_putc(char ch)
                     84: {
                     85:        /*
                     86:         * put a character on the unconfigured console device.
                     87:         * This will be used during devconfig until fcons/0 is configured.
                     88:         */
                     89:
                     90:        *(char *)(TACONS_REG_BASE + TACONS_OFF_IO) = ch;
                     91: }
                     92:

CVSweb