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