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