Annotation of funnyos/dev/fcons/fcons.c, Revision 1.4
1.1 init 1: /*
1.4 ! init 2: * $Id: fcons.c,v 1.3 2007/10/29 12:23:06 init Exp $
1.1 init 3: */
4: #include <sys/types.h>
5: #include <sys/device.h>
6: #include <dev/fcons/fconsvar.h>
7: #include <libkern/printf.h>
8:
9: /*
10: * funnyOS console.
11: * 80x25, monochrome.
12: */
13:
14: /* current console device */
1.2 init 15: struct fcons_dd *curcons;
1.1 init 16:
17: extern void (*putchar)(char);
18:
1.2 init 19: int fcons_attach(struct device *, uint32_t loc, uint8_t flags);
20: void fcons_putchar(void *ddp, char);
21: char fcons_getchar(void *ddp);
1.1 init 22: void fcons_dfltputchar(char);
23: int fcons_devctl(struct device *, uint8_t, void *);
24:
1.2 init 25: struct driver fcons_dr = {
26: sizeof(struct fcons_dd),
27: fcons_attach,
1.4 ! init 28: NULL,
1.2 init 29: NULL
30: };
31:
1.1 init 32: int
1.2 init 33: fcons_attach(struct device *self, uint32_t loc, uint8_t size)
1.1 init 34: {
1.2 init 35: struct fcons_dd *ddp = self->dv_devdata;
1.1 init 36:
1.3 init 37: /* link our parent's dv_aux (fcons_handle) to us */
38: ddp->fd_fh = self->dv_parent->dv_aux;
39:
1.2 init 40: ddp->fd_currow = 0;
41: ddp->fd_curcol = 0;
1.1 init 42:
1.2 init 43: /* make current console default */
44: curcons = ddp;
1.1 init 45:
46: /* override early putchar */
47: putchar = fcons_dfltputchar;
48:
49: printf("system console (80x25, monochrome, no video buffer)\n");
50:
51: return(0);
52: }
53:
54:
55: void
1.2 init 56: fcons_putchar(void *ddp, char ch)
1.1 init 57: {
1.2 init 58: struct fcons_dd *fdp = ddp;
1.3 init 59: struct fcons_handle *fhp = fdp->fd_fh;
1.1 init 60:
1.2 init 61: /* if we reach screen width */
62: if (fdp->fd_curcol == (FCONS_WIDTH - 1)) {
1.1 init 63: /* CRLF */
1.2 init 64: fdp->fd_curcol = 0;
65: fdp->fd_currow++;
1.1 init 66:
67: /* XXX pass \n to lower level (not all devices work this way) */
1.2 init 68: fhp->putc(fhp->fh_ownerdd, '\n');
1.1 init 69: }
70: /* XXX do something if col == FCONS_HEIGHT; console buffer? */
71:
1.2 init 72: /* if we reach the bottom of the screen */
73: if (fdp->fd_currow == FCONS_HEIGHT) {
74: /* XXX tmp hack; should really follow clrscr */
75: fdp->fd_currow = 0;
1.1 init 76: }
77:
1.2 init 78: fhp->putc(fhp->fh_ownerdd, ch);
1.1 init 79: }
80:
81:
82: char
1.2 init 83: fcons_getchar(void *ddp)
1.1 init 84: {
85: /* TODO */
86: return ' ';
87: }
88:
89:
90: void
91: fcons_dfltputchar(char ch)
92: {
93: /*
94: * Put a character into default (current) console.
95: */
96: fcons_putchar(curcons, ch);
97:
98: return;
99: }
100:
1.2 init 101: #if 0
1.1 init 102: int
103: fcons_devctl(struct device *devp, uint8_t ctl, void *data)
104: {
105: /*
106: * Devctl support for fcons device.
107: */
108: switch(ctl) {
109: case DCFCONS_GETCURROW:
110: /* return cursor's row */
111: data = &fcons_dd[devp->dv_minor].currow;
112: return(0);
113: case DCFCONS_GETCURCOL:
114: /* return cursor's column */
115: data = &fcons_dd[devp->dv_minor].curcol;
116: return(0);
117: case DCFCONS_PUTCHAR:
118: /* put a character to the device */
119: fcons_putchar(devp, *(char*)data);
120: return(0);
121: case DCFCONS_GETCHAR:
122: /* get a character from the device */
123: /* TODO */
124: return(-1);
125: default:
126: /* unknown devctl */
127: return(-1);
128: }
129:
130: }
1.2 init 131: #endif /* not 0 */
1.1 init 132:
CVSweb