|
|
1.1 root 1: /*
2: * Copyright (c) 1988 University of Utah.
3: * Copyright (c) 1990 The Regents of the University of California.
4: * All rights reserved.
5: *
6: * This code is derived from software contributed to Berkeley by
7: * the Systems Programming Group of the University of Utah Computer
8: * Science Department.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by the University of
21: * California, Berkeley and its contributors.
22: * 4. Neither the name of the University nor the names of its contributors
23: * may be used to endorse or promote products derived from this software
24: * without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: * SUCH DAMAGE.
37: *
38: * from: Utah $Hdr: ite.c 1.1 90/07/09$
39: *
1.1.1.2 ! root 40: * from: @(#)ite.c 7.6 (Berkeley) 5/16/91
! 41: * ite.c,v 1.8 1993/07/12 11:38:13 mycroft Exp
1.1 root 42: */
43:
44: /*
45: * Bit-mapped display terminal emulator machine independent code.
46: * This is a very rudimentary. Much more can be abstracted out of
47: * the hardware dependent routines.
48: */
49: #include "ite.h"
50: #if NITE > 0
51:
52: #include "grf.h"
53:
54: #undef NITE
55: #define NITE NGRF
56:
57: #include "param.h"
58: #include "conf.h"
59: #include "proc.h"
60: #include "ioctl.h"
61: #include "tty.h"
62: #include "systm.h"
63:
64: #include "itevar.h"
65: #include "iteioctl.h"
66: #include "kbdmap.h"
67:
68: #include "machine/cpu.h"
69:
70: #define set_attr(ip, attr) ((ip)->attribute |= (attr))
71: #define clr_attr(ip, attr) ((ip)->attribute &= ~(attr))
72:
73: extern int nodev();
74:
75: int topcat_scroll(), topcat_init(), topcat_deinit();
76: int topcat_clear(), topcat_putc(), topcat_cursor();
77: int gatorbox_scroll(), gatorbox_init(), gatorbox_deinit();
78: int gatorbox_clear(), gatorbox_putc(), gatorbox_cursor();
79: int rbox_scroll(), rbox_init(), rbox_deinit();
80: int rbox_clear(), rbox_putc(), rbox_cursor();
81: int dvbox_scroll(), dvbox_init(), dvbox_deinit();
82: int dvbox_clear(), dvbox_putc(), dvbox_cursor();
83:
84: struct itesw itesw[] =
85: {
86: topcat_init, topcat_deinit, topcat_clear,
87: topcat_putc, topcat_cursor, topcat_scroll,
88:
89: gatorbox_init, gatorbox_deinit, gatorbox_clear,
90: gatorbox_putc, gatorbox_cursor, gatorbox_scroll,
91:
92: rbox_init, rbox_deinit, rbox_clear,
93: rbox_putc, rbox_cursor, rbox_scroll,
94:
95: dvbox_init, dvbox_deinit, dvbox_clear,
96: dvbox_putc, dvbox_cursor, dvbox_scroll,
97: };
98:
99: /*
100: * # of chars are output in a single itestart() call.
101: * If this is too big, user processes will be blocked out for
102: * long periods of time while we are emptying the queue in itestart().
103: * If it is too small, console output will be very ragged.
104: */
105: int iteburst = 64;
106:
107: int nite = NITE;
108: struct tty *kbd_tty = NULL;
1.1.1.2 ! root 109: struct tty *ite_tty[NITE];
1.1 root 110: struct ite_softc ite_softc[NITE];
111:
112: int itestart();
113: extern int ttrstrt();
114: extern struct tty *constty;
115:
116: /*
117: * Primary attribute buffer to be used by the first bitmapped console
118: * found. Secondary displays alloc the attribute buffer as needed.
119: * Size is based on a 68x128 display, which is currently our largest.
120: */
121: u_char console_attributes[0x2200];
122:
123: /*
124: * Perform functions necessary to setup device as a terminal emulator.
125: */
126: iteon(dev, flag)
127: dev_t dev;
128: {
129: int unit = UNIT(dev);
1.1.1.2 ! root 130: struct tty *tp = ite_tty[unit];
1.1 root 131: struct ite_softc *ip = &ite_softc[unit];
132:
133: if (unit < 0 || unit >= NITE || (ip->flags&ITE_ALIVE) == 0)
134: return(ENXIO);
135: /* force ite active, overriding graphics mode */
136: if (flag & 1) {
137: ip->flags |= ITE_ACTIVE;
138: ip->flags &= ~(ITE_INGRF|ITE_INITED);
139: }
140: /* leave graphics mode */
141: if (flag & 2) {
142: ip->flags &= ~ITE_INGRF;
143: if ((ip->flags & ITE_ACTIVE) == 0)
144: return(0);
145: }
146: ip->flags |= ITE_ACTIVE;
147: if (ip->flags & ITE_INGRF)
148: return(0);
149: if (kbd_tty == NULL || kbd_tty == tp) {
150: kbd_tty = tp;
151: kbdenable();
152: }
153: iteinit(dev);
154: return(0);
155: }
156:
157: iteinit(dev)
158: dev_t dev;
159: {
160: int unit = UNIT(dev);
161: struct ite_softc *ip = &ite_softc[unit];
162:
163: if (ip->flags & ITE_INITED)
164: return;
165:
166: ip->curx = 0;
167: ip->cury = 0;
168: ip->cursorx = 0;
169: ip->cursory = 0;
170:
171: (*itesw[ip->type].ite_init)(ip);
172: (*itesw[ip->type].ite_cursor)(ip, DRAW_CURSOR);
173:
174: ip->attribute = 0;
175: if (ip->attrbuf == NULL)
176: ip->attrbuf = (u_char *)
177: malloc(ip->rows * ip->cols, M_DEVBUF, M_WAITOK);
178: bzero(ip->attrbuf, (ip->rows * ip->cols));
179:
180: ip->imode = 0;
181: ip->flags |= ITE_INITED;
182: }
183:
184: /*
185: * "Shut down" device as terminal emulator.
186: * Note that we do not deinit the console device unless forced.
187: * Deinit'ing the console every time leads to a very active
188: * screen when processing /etc/rc.
189: */
190: iteoff(dev, flag)
191: dev_t dev;
192: {
193: register struct ite_softc *ip = &ite_softc[UNIT(dev)];
194:
195: if (flag & 2)
196: ip->flags |= ITE_INGRF;
197: if ((ip->flags & ITE_ACTIVE) == 0)
198: return;
199: if ((flag & 1) ||
200: (ip->flags & (ITE_INGRF|ITE_ISCONS|ITE_INITED)) == ITE_INITED)
201: (*itesw[ip->type].ite_deinit)(ip);
202: if ((flag & 2) == 0)
203: ip->flags &= ~ITE_ACTIVE;
204: }
205:
206: /* ARGSUSED */
207: #ifdef __STDC__
208: iteopen(dev_t dev, int mode, int devtype, struct proc *p)
209: #else
210: iteopen(dev, mode, devtype, p)
211: dev_t dev;
212: int mode, devtype;
213: struct proc *p;
214: #endif
215: {
216: int unit = UNIT(dev);
1.1.1.2 ! root 217: register struct tty *tp;
1.1 root 218: register struct ite_softc *ip = &ite_softc[unit];
219: register int error;
220: int first = 0;
221:
1.1.1.2 ! root 222: if(!ite_tty[unit])
! 223: tp = ite_tty[unit] = ttymalloc();
! 224: else
! 225: tp = ite_tty[unit];
1.1 root 226: if ((tp->t_state&(TS_ISOPEN|TS_XCLUDE)) == (TS_ISOPEN|TS_XCLUDE)
227: && p->p_ucred->cr_uid != 0)
228: return (EBUSY);
229: if ((ip->flags & ITE_ACTIVE) == 0) {
230: error = iteon(dev, 0);
231: if (error)
232: return (error);
233: first = 1;
234: }
235: tp->t_oproc = itestart;
236: tp->t_param = NULL;
237: tp->t_dev = dev;
238: if ((tp->t_state&TS_ISOPEN) == 0) {
239: ttychars(tp);
240: tp->t_iflag = TTYDEF_IFLAG;
241: tp->t_oflag = TTYDEF_OFLAG;
242: tp->t_cflag = CS8|CREAD;
243: tp->t_lflag = TTYDEF_LFLAG;
244: tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
245: tp->t_state = TS_ISOPEN|TS_CARR_ON;
246: ttsetwater(tp);
247: }
248: error = (*linesw[tp->t_line].l_open)(dev, tp);
249: if (error == 0) {
250: tp->t_winsize.ws_row = ip->rows;
251: tp->t_winsize.ws_col = ip->cols;
252: } else if (first)
253: iteoff(dev, 0);
254: return (error);
255: }
256:
257: /*ARGSUSED*/
258: iteclose(dev, flag, mode, p)
259: dev_t dev;
260: int flag, mode;
261: struct proc *p;
262: {
1.1.1.2 ! root 263: register struct tty *tp = ite_tty[UNIT(dev)];
1.1 root 264:
265: (*linesw[tp->t_line].l_close)(tp, flag);
266: ttyclose(tp);
267: iteoff(dev, 0);
1.1.1.2 ! root 268: ttyfree(tp);
! 269: ite_tty[UNIT(dev)] = (struct tty *)NULL;
1.1 root 270: return(0);
271: }
272:
273: iteread(dev, uio, flag)
274: dev_t dev;
275: struct uio *uio;
276: {
1.1.1.2 ! root 277: register struct tty *tp = ite_tty[UNIT(dev)];
1.1 root 278:
279: return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
280: }
281:
282: itewrite(dev, uio, flag)
283: dev_t dev;
284: struct uio *uio;
285: {
286: int unit = UNIT(dev);
1.1.1.2 ! root 287: register struct tty *tp = ite_tty[unit];
1.1 root 288:
289: if ((ite_softc[unit].flags & ITE_ISCONS) && constty &&
290: (constty->t_state&(TS_CARR_ON|TS_ISOPEN))==(TS_CARR_ON|TS_ISOPEN))
291: tp = constty;
292: return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
293: }
294:
295: iteioctl(dev, cmd, addr, flag)
296: dev_t dev;
297: caddr_t addr;
298: {
1.1.1.2 ! root 299: register struct tty *tp = ite_tty[UNIT(dev)];
1.1 root 300: int error;
301:
302: error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr, flag);
303: if (error >= 0)
304: return (error);
305: error = ttioctl(tp, cmd, addr, flag);
306: if (error >= 0)
307: return (error);
308: return (ENOTTY);
309: }
310:
311: itestart(tp)
312: register struct tty *tp;
313: {
314: register int cc, s;
315: int hiwat = 0;
316:
317: s = spltty();
318: if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) {
319: splx(s);
320: return;
321: }
322: tp->t_state |= TS_BUSY;
323: cc = tp->t_outq.c_cc;
324: if (cc <= tp->t_lowat) {
325: if (tp->t_state & TS_ASLEEP) {
326: tp->t_state &= ~TS_ASLEEP;
1.1.1.2 ! root 327: wakeup(&tp->t_out);
1.1 root 328: }
1.1.1.2 ! root 329: selwakeup(&tp->t_wsel);
1.1 root 330: }
331: /*
332: * Limit the amount of output we do in one burst
333: * to prevent hogging the CPU.
334: */
335: if (cc > iteburst) {
336: hiwat++;
337: cc = iteburst;
338: }
339: while (--cc >= 0) {
340: register int c;
341:
342: c = getc(&tp->t_outq);
343: /*
344: * iteputchar() may take a long time and we don't want to
345: * block all interrupts for long periods of time. Since
346: * there is no need to stay at high priority while outputing
347: * the character (since we don't have to worry about
348: * interrupts), we don't. We just need to make sure that
349: * we don't reenter iteputchar, which is guarenteed by the
350: * earlier setting of TS_BUSY.
351: */
352: splx(s);
353: iteputchar(c, tp->t_dev);
354: spltty();
355: }
356: if (hiwat) {
357: tp->t_state |= TS_TIMEOUT;
358: timeout(ttrstrt, tp, 1);
359: }
360: tp->t_state &= ~TS_BUSY;
361: splx(s);
362: }
363:
364: itefilter(stat, c)
365: register char stat, c;
366: {
367: static int capsmode = 0;
368: static int metamode = 0;
369: register char code, *str;
370:
371: if (kbd_tty == NULL)
372: return;
373:
374: switch (c & 0xFF) {
375: case KBD_CAPSLOCK:
376: capsmode = !capsmode;
377: return;
378:
379: case KBD_EXT_LEFT_DOWN:
380: case KBD_EXT_RIGHT_DOWN:
381: metamode = 1;
382: return;
383:
384: case KBD_EXT_LEFT_UP:
385: case KBD_EXT_RIGHT_UP:
386: metamode = 0;
387: return;
388: }
389:
390: c &= KBD_CHARMASK;
391: switch ((stat>>KBD_SSHIFT) & KBD_SMASK) {
392:
393: case KBD_KEY:
394: if (!capsmode) {
395: code = kbd_keymap[c];
396: break;
397: }
398: /* fall into... */
399:
400: case KBD_SHIFT:
401: code = kbd_shiftmap[c];
402: break;
403:
404: case KBD_CTRL:
405: code = kbd_ctrlmap[c];
406: break;
407:
408: case KBD_CTRLSHIFT:
409: code = kbd_ctrlshiftmap[c];
410: break;
411: }
412:
413: if (code == NULL && (str = kbd_stringmap[c]) != NULL) {
414: while (*str)
415: (*linesw[kbd_tty->t_line].l_rint)(*str++, kbd_tty);
416: } else {
417: if (metamode)
418: code |= 0x80;
419: (*linesw[kbd_tty->t_line].l_rint)(code, kbd_tty);
420: }
421: }
422:
423: iteputchar(c, dev)
424: register int c;
425: dev_t dev;
426: {
427: int unit = UNIT(dev);
428: register struct ite_softc *ip = &ite_softc[unit];
429: register struct itesw *sp = &itesw[ip->type];
430: register int n;
431:
432: if ((ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE)
433: return;
434:
435: if (ip->escape) {
436: doesc:
437: switch (ip->escape) {
438:
439: case '&': /* Next can be a,d, or s */
440: if (ip->fpd++) {
441: ip->escape = c;
442: ip->fpd = 0;
443: }
444: return;
445:
446: case 'a': /* cursor change */
447: switch (c) {
448:
449: case 'Y': /* Only y coord. */
450: ip->cury = MIN(ip->pos, ip->rows-1);
451: ip->pos = 0;
452: ip->escape = 0;
453: (*sp->ite_cursor)(ip, MOVE_CURSOR);
454: clr_attr(ip, ATTR_INV);
455: break;
456:
457: case 'y': /* y coord first */
458: ip->cury = MIN(ip->pos, ip->rows-1);
459: ip->pos = 0;
460: ip->fpd = 0;
461: break;
462:
463: case 'C': /* x coord */
464: ip->curx = MIN(ip->pos, ip->cols-1);
465: ip->pos = 0;
466: ip->escape = 0;
467: (*sp->ite_cursor)(ip, MOVE_CURSOR);
468: clr_attr(ip, ATTR_INV);
469: break;
470:
471: default: /* Possibly a 3 digit number. */
472: if (c >= '0' && c <= '9' && ip->fpd < 3) {
473: ip->pos = ip->pos * 10 + (c - '0');
474: ip->fpd++;
475: } else {
476: ip->pos = 0;
477: ip->escape = 0;
478: }
479: break;
480: }
481: return;
482:
483: case 'd': /* attribute change */
484: switch (c) {
485:
486: case 'B':
487: set_attr(ip, ATTR_INV);
488: break;
489: case 'D':
490: /* XXX: we don't do anything for underline */
491: set_attr(ip, ATTR_UL);
492: break;
493: case '@':
494: clr_attr(ip, ATTR_ALL);
495: break;
496: }
497: ip->escape = 0;
498: return;
499:
500: case 's': /* keypad control */
501: switch (ip->fpd) {
502:
503: case 0:
504: ip->hold = c;
505: ip->fpd++;
506: return;
507:
508: case 1:
509: if (c == 'A') {
510: switch (ip->hold) {
511:
512: case '0':
513: clr_attr(ip, ATTR_KPAD);
514: break;
515: case '1':
516: set_attr(ip, ATTR_KPAD);
517: break;
518: }
519: }
520: ip->hold = 0;
521: }
522: ip->escape = 0;
523: return;
524:
525: case 'i': /* back tab */
526: if (ip->curx > TABSIZE) {
527: n = ip->curx - (ip->curx & (TABSIZE - 1));
528: ip->curx -= n;
529: } else
530: ip->curx = 0;
531: (*sp->ite_cursor)(ip, MOVE_CURSOR);
532: ip->escape = 0;
533: return;
534:
535: case '3': /* clear all tabs */
536: goto ignore;
537:
538: case 'K': /* clear_eol */
539: ite_clrtoeol(ip, sp, ip->cury, ip->curx);
540: ip->escape = 0;
541: return;
542:
543: case 'J': /* clear_eos */
544: ite_clrtoeos(ip, sp);
545: ip->escape = 0;
546: return;
547:
548: case 'B': /* cursor down 1 line */
549: if (++ip->cury == ip->rows) {
550: --ip->cury;
551: (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
552: ite_clrtoeol(ip, sp, ip->cury, 0);
553: }
554: else
555: (*sp->ite_cursor)(ip, MOVE_CURSOR);
556: clr_attr(ip, ATTR_INV);
557: ip->escape = 0;
558: return;
559:
560: case 'C': /* cursor forward 1 char */
561: ip->escape = 0;
562: itecheckwrap(ip, sp);
563: return;
564:
565: case 'A': /* cursor up 1 line */
566: if (ip->cury > 0) {
567: ip->cury--;
568: (*sp->ite_cursor)(ip, MOVE_CURSOR);
569: }
570: ip->escape = 0;
571: clr_attr(ip, ATTR_INV);
572: return;
573:
574: case 'P': /* delete character */
575: ite_dchar(ip, sp);
576: ip->escape = 0;
577: return;
578:
579: case 'M': /* delete line */
580: ite_dline(ip, sp);
581: ip->escape = 0;
582: return;
583:
584: case 'Q': /* enter insert mode */
585: ip->imode = 1;
586: ip->escape = 0;
587: return;
588:
589: case 'R': /* exit insert mode */
590: ip->imode = 0;
591: ip->escape = 0;
592: return;
593:
594: case 'L': /* insert blank line */
595: ite_iline(ip, sp);
596: ip->escape = 0;
597: return;
598:
599: case 'h': /* home key */
600: ip->cury = ip->curx = 0;
601: (*sp->ite_cursor)(ip, MOVE_CURSOR);
602: ip->escape = 0;
603: return;
604:
605: case 'D': /* left arrow key */
606: if (ip->curx > 0) {
607: ip->curx--;
608: (*sp->ite_cursor)(ip, MOVE_CURSOR);
609: }
610: ip->escape = 0;
611: return;
612:
613: case '1': /* set tab in all rows */
614: goto ignore;
615:
616: case ESC:
617: if ((ip->escape = c) == ESC)
618: break;
619: ip->fpd = 0;
620: goto doesc;
621:
622: default:
623: ignore:
624: ip->escape = 0;
625: return;
626:
627: }
628: }
629:
630: switch (c &= 0x7F) {
631:
632: case '\n':
633:
634: if (++ip->cury == ip->rows) {
635: --ip->cury;
636: (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
637: ite_clrtoeol(ip, sp, ip->cury, 0);
638: }
639: else
640: (*sp->ite_cursor)(ip, MOVE_CURSOR);
641: clr_attr(ip, ATTR_INV);
642: break;
643:
644: case '\r':
645: if (ip->curx) {
646: ip->curx = 0;
647: (*sp->ite_cursor)(ip, MOVE_CURSOR);
648: }
649: break;
650:
651: case '\b':
652: if (--ip->curx < 0)
653: ip->curx = 0;
654: else
655: (*sp->ite_cursor)(ip, MOVE_CURSOR);
656: break;
657:
658: case '\t':
659: if (ip->curx < TABEND(unit)) {
660: n = TABSIZE - (ip->curx & (TABSIZE - 1));
661: ip->curx += n;
662: (*sp->ite_cursor)(ip, MOVE_CURSOR);
663: } else
664: itecheckwrap(ip, sp);
665: break;
666:
667: case CTRL('G'):
1.1.1.2 ! root 668: if (ite_tty[unit] == kbd_tty)
1.1 root 669: kbdbell();
670: break;
671:
672: case ESC:
673: ip->escape = ESC;
674: break;
675:
676: default:
677: if (c < ' ' || c == DEL)
678: break;
679: if (ip->imode)
680: ite_ichar(ip, sp);
681: if ((ip->attribute & ATTR_INV) || attrtest(ip, ATTR_INV)) {
682: attrset(ip, ATTR_INV);
683: (*sp->ite_putc)(ip, c, ip->cury, ip->curx, ATTR_INV);
684: }
685: else
686: (*sp->ite_putc)(ip, c, ip->cury, ip->curx, ATTR_NOR);
687: (*sp->ite_cursor)(ip, DRAW_CURSOR);
688: itecheckwrap(ip, sp);
689: break;
690: }
691: }
692:
693: itecheckwrap(ip, sp)
694: register struct ite_softc *ip;
695: register struct itesw *sp;
696: {
697: if (++ip->curx == ip->cols) {
698: ip->curx = 0;
699: clr_attr(ip, ATTR_INV);
700: if (++ip->cury == ip->rows) {
701: --ip->cury;
702: (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
703: ite_clrtoeol(ip, sp, ip->cury, 0);
704: return;
705: }
706: }
707: (*sp->ite_cursor)(ip, MOVE_CURSOR);
708: }
709:
710: ite_dchar(ip, sp)
711: register struct ite_softc *ip;
712: register struct itesw *sp;
713: {
714: (*sp->ite_scroll)(ip, ip->cury, ip->curx + 1, 1, SCROLL_LEFT);
715: attrmov(ip, ip->cury, ip->curx + 1, ip->cury, ip->curx,
716: 1, ip->cols - ip->curx - 1);
717: attrclr(ip, ip->cury, ip->cols - 1, 1, 1);
718: (*sp->ite_putc)(ip, ' ', ip->cury, ip->cols - 1, ATTR_NOR);
719: (*sp->ite_cursor)(ip, DRAW_CURSOR);
720: }
721:
722: ite_ichar(ip, sp)
723: register struct ite_softc *ip;
724: register struct itesw *sp;
725: {
726: (*sp->ite_scroll)(ip, ip->cury, ip->curx, 1, SCROLL_RIGHT);
727: attrmov(ip, ip->cury, ip->curx, ip->cury, ip->curx + 1,
728: 1, ip->cols - ip->curx - 1);
729: attrclr(ip, ip->cury, ip->curx, 1, 1);
730: (*sp->ite_putc)(ip, ' ', ip->cury, ip->curx, ATTR_NOR);
731: (*sp->ite_cursor)(ip, DRAW_CURSOR);
732: }
733:
734: ite_dline(ip, sp)
735: register struct ite_softc *ip;
736: register struct itesw *sp;
737: {
738: (*sp->ite_scroll)(ip, ip->cury + 1, 0, 1, SCROLL_UP);
739: attrmov(ip, ip->cury + 1, 0, ip->cury, 0,
740: ip->rows - ip->cury - 1, ip->cols);
741: ite_clrtoeol(ip, sp, ip->rows - 1, 0);
742: }
743:
744: ite_iline(ip, sp)
745: register struct ite_softc *ip;
746: register struct itesw *sp;
747: {
748: (*sp->ite_scroll)(ip, ip->cury, 0, 1, SCROLL_DOWN);
749: attrmov(ip, ip->cury, 0, ip->cury + 1, 0,
750: ip->rows - ip->cury - 1, ip->cols);
751: ite_clrtoeol(ip, sp, ip->cury, 0);
752: }
753:
754: ite_clrtoeol(ip, sp, y, x)
755: register struct ite_softc *ip;
756: register struct itesw *sp;
757: register int y, x;
758: {
759: (*sp->ite_clear)(ip, y, x, 1, ip->cols - x);
760: attrclr(ip, y, x, 1, ip->cols - x);
761: (*sp->ite_cursor)(ip, DRAW_CURSOR);
762: }
763:
764: ite_clrtoeos(ip, sp)
765: register struct ite_softc *ip;
766: register struct itesw *sp;
767: {
768: (*sp->ite_clear)(ip, ip->cury, 0, ip->rows - ip->cury, ip->cols);
769: attrclr(ip, ip->cury, 0, ip->rows - ip->cury, ip->cols);
770: (*sp->ite_cursor)(ip, DRAW_CURSOR);
771: }
772:
773: /*
774: * Console functions
775: */
776: #include "../hp300/cons.h"
777: #include "grfioctl.h"
778: #include "grfvar.h"
779:
780: #ifdef DEBUG
781: /*
782: * Minimum ITE number at which to start looking for a console.
783: * Setting to 0 will do normal search, 1 will skip first ITE device,
784: * NITE will skip ITEs and use serial port.
785: */
786: int whichconsole = 0;
787: #endif
788:
789: itecnprobe(cp)
790: struct consdev *cp;
791: {
792: register struct ite_softc *ip;
793: int i, maj, unit, pri;
794:
795: /* locate the major number */
796: for (maj = 0; maj < nchrdev; maj++)
797: if (cdevsw[maj].d_open == iteopen)
798: break;
799:
800: /* urk! */
801: grfconfig();
802:
803: /* check all the individual displays and find the best */
804: unit = -1;
805: pri = CN_DEAD;
806: for (i = 0; i < NITE; i++) {
807: struct grf_softc *gp = &grf_softc[i];
808:
809: ip = &ite_softc[i];
810: if ((gp->g_flags & GF_ALIVE) == 0)
811: continue;
812: ip->flags = (ITE_ALIVE|ITE_CONSOLE);
813:
814: /* XXX - we need to do something about mapping these */
815: switch (gp->g_type) {
816:
817: case GT_TOPCAT:
818: case GT_LRCATSEYE:
819: case GT_HRCCATSEYE:
820: case GT_HRMCATSEYE:
821: ip->type = ITE_TOPCAT;
822: break;
823: case GT_GATORBOX:
824: ip->type = ITE_GATORBOX;
825: break;
826: case GT_RENAISSANCE:
827: ip->type = ITE_RENAISSANCE;
828: break;
829: case GT_DAVINCI:
830: ip->type = ITE_DAVINCI;
831: break;
832: }
833: #ifdef DEBUG
834: if (i < whichconsole)
835: continue;
836: #endif
837: if ((int)gp->g_display.gd_regaddr == GRFIADDR) {
838: pri = CN_INTERNAL;
839: unit = i;
840: } else if (unit < 0) {
841: pri = CN_NORMAL;
842: unit = i;
843: }
844: }
845:
846: /* initialize required fields */
847: cp->cn_dev = makedev(maj, unit);
848: cp->cn_pri = pri;
849: }
850:
851: itecninit(cp)
852: struct consdev *cp;
853: {
854: int unit = UNIT(cp->cn_dev);
855: struct ite_softc *ip = &ite_softc[unit];
856:
857: ip->attrbuf = console_attributes;
858: iteinit(cp->cn_dev);
859: ip->flags |= (ITE_ACTIVE|ITE_ISCONS);
1.1.1.2 ! root 860: kbd_tty = ite_tty[unit];
1.1 root 861: }
862:
863: /*ARGSUSED*/
864: itecngetc(dev)
865: dev_t dev;
866: {
867: register int c;
868: int stat;
869:
870: c = kbdgetc(&stat);
871: switch ((stat >> KBD_SSHIFT) & KBD_SMASK) {
872: case KBD_SHIFT:
873: c = kbd_shiftmap[c & KBD_CHARMASK];
874: break;
875: case KBD_CTRL:
876: c = kbd_ctrlmap[c & KBD_CHARMASK];
877: break;
878: case KBD_KEY:
879: c = kbd_keymap[c & KBD_CHARMASK];
880: break;
881: default:
882: c = 0;
883: break;
884: }
885: return(c);
886: }
887:
888: itecnputc(dev, c)
889: dev_t dev;
890: int c;
891: {
892: static int paniced = 0;
893: struct ite_softc *ip = &ite_softc[UNIT(dev)];
894: extern char *panicstr;
895:
896: if (panicstr && !paniced &&
897: (ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE) {
898: (void) iteon(dev, 3);
899: paniced = 1;
900: }
901: iteputchar(c, dev);
902: }
903: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.