Annotation of sys/arch/hp300/stand/common/ite.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: ite.c,v 1.7 2006/08/17 06:31:10 miod Exp $ */
! 2: /* $NetBSD: ite.c,v 1.12 1997/01/30 10:32:55 thorpej Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1988 University of Utah.
! 6: * Copyright (c) 1990, 1993
! 7: * The Regents of the University of California. All rights reserved.
! 8: *
! 9: * This code is derived from software contributed to Berkeley by
! 10: * the Systems Programming Group of the University of Utah Computer
! 11: * Science Department.
! 12: *
! 13: * Redistribution and use in source and binary forms, with or without
! 14: * modification, are permitted provided that the following conditions
! 15: * are met:
! 16: * 1. Redistributions of source code must retain the above copyright
! 17: * notice, this list of conditions and the following disclaimer.
! 18: * 2. Redistributions in binary form must reproduce the above copyright
! 19: * notice, this list of conditions and the following disclaimer in the
! 20: * documentation and/or other materials provided with the distribution.
! 21: * 3. Neither the name of the University nor the names of its contributors
! 22: * may be used to endorse or promote products derived from this software
! 23: * without specific prior written permission.
! 24: *
! 25: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 26: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 27: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 28: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 29: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 30: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 31: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 32: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 33: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 34: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 35: * SUCH DAMAGE.
! 36: *
! 37: * from: Utah $Hdr: ite.c 1.24 93/06/25$
! 38: *
! 39: * @(#)ite.c 8.1 (Berkeley) 7/8/93
! 40: */
! 41:
! 42: /*
! 43: * Standalone Internal Terminal Emulator (CRT and keyboard)
! 44: */
! 45:
! 46: #ifdef ITECONSOLE
! 47:
! 48: #include <sys/param.h>
! 49:
! 50: #include <hp300/dev/sgcreg.h>
! 51: #include <dev/ic/stireg.h>
! 52:
! 53: #include "samachdep.h"
! 54: #include "consdefs.h"
! 55: #include "device.h"
! 56: #include "grfreg.h"
! 57: #include "itevar.h"
! 58: #include "kbdvar.h"
! 59:
! 60: void itecheckwrap(struct ite_data *, struct itesw *);
! 61: void iteconfig(void);
! 62: void ite_clrtoeol(struct ite_data *, struct itesw *, int, int);
! 63:
! 64: struct itesw itesw[] = {
! 65: { GID_TOPCAT,
! 66: topcat_init, ite_dio_clear, ite_dio_putc8bpp,
! 67: ite_dio_cursor, ite_dio_scroll },
! 68:
! 69: { GID_GATORBOX,
! 70: gbox_init, ite_dio_clear, ite_dio_putc8bpp,
! 71: ite_dio_cursor, gbox_scroll },
! 72:
! 73: { GID_RENAISSANCE,
! 74: rbox_init, ite_dio_clear, ite_dio_putc8bpp,
! 75: ite_dio_cursor, ite_dio_scroll },
! 76:
! 77: { GID_LRCATSEYE,
! 78: topcat_init, ite_dio_clear, ite_dio_putc8bpp,
! 79: ite_dio_cursor, ite_dio_scroll },
! 80:
! 81: { GID_HRCCATSEYE,
! 82: topcat_init, ite_dio_clear, ite_dio_putc8bpp,
! 83: ite_dio_cursor, ite_dio_scroll },
! 84:
! 85: { GID_HRMCATSEYE,
! 86: topcat_init, ite_dio_clear, ite_dio_putc8bpp,
! 87: ite_dio_cursor, ite_dio_scroll },
! 88:
! 89: { GID_DAVINCI,
! 90: dvbox_init, ite_dio_clear, ite_dio_putc8bpp,
! 91: ite_dio_cursor, ite_dio_scroll },
! 92:
! 93: { GID_HYPERION,
! 94: hyper_init, ite_dio_clear, ite_dio_putc1bpp,
! 95: ite_dio_cursor, ite_dio_scroll },
! 96:
! 97: { GID_TIGER,
! 98: tvrx_init, ite_dio_clear, ite_dio_putc1bpp,
! 99: ite_dio_cursor, ite_dio_scroll },
! 100:
! 101: { GID_STI,
! 102: sti_iteinit, sti_clear, sti_putc,
! 103: sti_cursor, sti_scroll },
! 104: };
! 105: int nitesw = sizeof(itesw) / sizeof(itesw[0]);
! 106:
! 107: /* these guys need to be in initialized data */
! 108: int itecons = -1;
! 109: struct ite_data ite_data[NITE] = { { 0 } };
! 110:
! 111: /*
! 112: * Locate all bitmapped displays
! 113: */
! 114: void
! 115: iteconfig()
! 116: {
! 117: extern struct hp_hw sc_table[];
! 118: int dtype, fboff, slotno, i;
! 119: u_int8_t *va;
! 120: struct hp_hw *hw;
! 121: struct grfreg *gr;
! 122: struct ite_data *ip;
! 123:
! 124: i = 0;
! 125: for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++) {
! 126: if (!HW_ISDEV(hw, D_BITMAP))
! 127: continue;
! 128: gr = (struct grfreg *) hw->hw_kva;
! 129: /* XXX: redundent but safe */
! 130: if (badaddr((caddr_t)gr) || gr->gr_id != GRFHWID)
! 131: continue;
! 132: for (dtype = 0; dtype < nitesw; dtype++)
! 133: if (itesw[dtype].ite_hwid == gr->gr_id2)
! 134: break;
! 135: if (dtype == nitesw)
! 136: continue;
! 137: if (i >= NITE)
! 138: break;
! 139: ip = &ite_data[i];
! 140: ip->isw = &itesw[dtype];
! 141: ip->regbase = (caddr_t) gr;
! 142: fboff = (gr->gr_fbomsb << 8) | gr->gr_fbolsb;
! 143: ip->fbbase = (caddr_t) (*((u_char *)ip->regbase+fboff) << 16);
! 144: /* DIO II: FB offset is relative to select code space */
! 145: if (ip->regbase >= (caddr_t)DIOIIBASE)
! 146: ip->fbbase += (int)ip->regbase;
! 147: ip->fbwidth = gr->gr_fbwidth_h << 8 | gr->gr_fbwidth_l;
! 148: ip->fbheight = gr->gr_fbheight_h << 8 | gr->gr_fbheight_l;
! 149: ip->dwidth = gr->gr_dwidth_h << 8 | gr->gr_dwidth_l;
! 150: ip->dheight = gr->gr_dheight_h << 8 | gr->gr_dheight_l;
! 151: /*
! 152: * XXX some displays (e.g. the davinci) appear
! 153: * to return a display height greater than the
! 154: * returned FB height. Guess we should go back
! 155: * to getting the display dimensions from the
! 156: * fontrom...
! 157: */
! 158: if (ip->dwidth > ip->fbwidth)
! 159: ip->dwidth = ip->fbwidth;
! 160: if (ip->dheight > ip->fbheight)
! 161: ip->dheight = ip->fbheight;
! 162: ip->alive = 1;
! 163: i++;
! 164: }
! 165:
! 166: /*
! 167: * Now probe for SGC frame buffers
! 168: */
! 169: if (machineid != HP_400 && machineid != HP_425 &&
! 170: machineid != HP_433)
! 171: return;
! 172:
! 173: for (dtype = 0; dtype < nitesw; dtype++)
! 174: if (itesw[dtype].ite_hwid == GID_STI)
! 175: break;
! 176: if (dtype == nitesw)
! 177: return;
! 178:
! 179: for (slotno = 0; slotno < SGC_NSLOTS; slotno++) {
! 180: va = (u_int8_t *)IIOV(SGC_BASE + (slotno * SGC_DEVSIZE));
! 181:
! 182: /* Check to see if hardware exists. */
! 183: if (badaddr(va) != 0)
! 184: continue;
! 185:
! 186: /* Check hardware. */
! 187: if (va[3] == STI_DEVTYPE1) {
! 188: if (i >= NITE)
! 189: break;
! 190: ip = &ite_data[i];
! 191: ip->isw = &itesw[dtype];
! 192: ip->regbase = (caddr_t)GRFIADDR;/* to get CN_INTERNAL */
! 193: ip->fbbase = (caddr_t)slotno;
! 194: ip->alive = 1;
! 195: i++;
! 196: /* we only support one SGC frame buffer at the moment */
! 197: break;
! 198: }
! 199: }
! 200: }
! 201:
! 202: void
! 203: iteprobe(struct consdev *cp)
! 204: {
! 205: int ite;
! 206: struct ite_data *ip;
! 207: int unit, pri;
! 208:
! 209: iteconfig();
! 210: unit = -1;
! 211: pri = CN_DEAD;
! 212: for (ite = 0; ite < NITE; ite++) {
! 213: ip = &ite_data[ite];
! 214: if (ip->alive == 0)
! 215: continue;
! 216: if ((int)ip->regbase == GRFIADDR) {
! 217: pri = CN_INTERNAL;
! 218: unit = ite;
! 219: } else if (unit < 0) {
! 220: pri = CN_NORMAL;
! 221: unit = ite;
! 222: }
! 223: }
! 224: cp->cn_dev = unit;
! 225: cp->cn_pri = pri;
! 226: }
! 227:
! 228: void
! 229: iteinit(struct consdev *cp)
! 230: {
! 231: int ite = cp->cn_dev;
! 232: struct ite_data *ip;
! 233:
! 234: ip = &ite_data[ite];
! 235:
! 236: ip->curx = 0;
! 237: ip->cury = 0;
! 238: ip->cursorx = 0;
! 239: ip->cursory = 0;
! 240:
! 241: (*ip->isw->ite_init)(ip);
! 242: (*ip->isw->ite_cursor)(ip, DRAW_CURSOR);
! 243:
! 244: itecons = ite;
! 245: kbdinit();
! 246: }
! 247:
! 248: /* ARGSUSED */
! 249: void
! 250: iteputchar(dev_t dev, int c)
! 251: {
! 252: struct ite_data *ip = &ite_data[itecons];
! 253: struct itesw *sp = ip->isw;
! 254:
! 255: c &= 0x7F;
! 256: switch (c) {
! 257:
! 258: case '\n':
! 259: if (++ip->cury == ip->rows) {
! 260: ip->cury--;
! 261: (*sp->ite_scroll)(ip);
! 262: ite_clrtoeol(ip, sp, ip->cury, 0);
! 263: }
! 264: else
! 265: (*sp->ite_cursor)(ip, MOVE_CURSOR);
! 266: break;
! 267:
! 268: case '\r':
! 269: ip->curx = 0;
! 270: (*sp->ite_cursor)(ip, MOVE_CURSOR);
! 271: break;
! 272:
! 273: case '\b':
! 274: if (--ip->curx < 0)
! 275: ip->curx = 0;
! 276: else
! 277: (*sp->ite_cursor)(ip, MOVE_CURSOR);
! 278: break;
! 279:
! 280: default:
! 281: if (c < ' ' || c == 0177)
! 282: break;
! 283: (*sp->ite_putc)(ip, c, ip->cury, ip->curx);
! 284: (*sp->ite_cursor)(ip, DRAW_CURSOR);
! 285: itecheckwrap(ip, sp);
! 286: break;
! 287: }
! 288: }
! 289:
! 290: void
! 291: itecheckwrap(struct ite_data *ip, struct itesw *sp)
! 292: {
! 293: if (++ip->curx == ip->cols) {
! 294: ip->curx = 0;
! 295: if (++ip->cury == ip->rows) {
! 296: --ip->cury;
! 297: (*sp->ite_scroll)(ip);
! 298: ite_clrtoeol(ip, sp, ip->cury, 0);
! 299: return;
! 300: }
! 301: }
! 302: (*sp->ite_cursor)(ip, MOVE_CURSOR);
! 303: }
! 304:
! 305: void
! 306: ite_clrtoeol(struct ite_data *ip, struct itesw *sp, int y, int x)
! 307: {
! 308: (*sp->ite_clear)(ip, y, x, 1, ip->cols - x);
! 309: (*sp->ite_cursor)(ip, DRAW_CURSOR);
! 310: }
! 311:
! 312: /* ARGSUSED */
! 313: int
! 314: itegetchar(dev_t dev)
! 315: {
! 316: #ifdef SMALL
! 317: return (0);
! 318: #else
! 319: return (kbdgetc());
! 320: #endif
! 321: }
! 322: #endif
CVSweb