Annotation of 43BSDReno/sys/hpstand/ite.c, revision 1.1

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 is only permitted until one year after the first shipment
        !            11:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
        !            12:  * binary forms are permitted provided that: (1) source distributions retain
        !            13:  * this entire copyright notice and comment, and (2) distributions including
        !            14:  * binaries display the following acknowledgement:  This product includes
        !            15:  * software developed by the University of California, Berkeley and its
        !            16:  * contributors'' in the documentation or other materials provided with the
        !            17:  * distribution and in all advertising materials mentioning features or use
        !            18:  * of this software.  Neither the name of the University nor the names of
        !            19:  * its contributors may be used to endorse or promote products derived from
        !            20:  * this software without specific prior written permission.
        !            21:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            22:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            23:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            24:  *
        !            25:  * from: Utah $Hdr: ite.c 1.19 89/08/22$
        !            26:  *
        !            27:  *     @(#)ite.c       7.1 (Berkeley) 5/8/90
        !            28:  */
        !            29: 
        !            30: /*
        !            31:  * Standalone Internal Terminal Emulator (CRT and keyboard)
        !            32:  */
        !            33: #include "samachdep.h"
        !            34: 
        !            35: #ifdef ITECONSOLE
        !            36: 
        !            37: #include "param.h"
        !            38: #include "machine/cons.h"
        !            39: #include "../hpdev/device.h"
        !            40: #include "../hpdev/itevar.h"
        !            41: #include "../hpdev/grfvar.h"
        !            42: 
        !            43: int nodev();
        !            44: 
        !            45: int topcat_init(), topcat_putc();
        !            46: int topcat_clear(), topcat_cursor(), topcat_scroll();
        !            47: int gatorbox_init(), gatorbox_clear();
        !            48: int gatorbox_putc(), gatorbox_cursor(), gatorbox_scroll();
        !            49: int rbox_init(), rbox_clear();
        !            50: int rbox_putc(), rbox_cursor(), rbox_scroll();
        !            51: int dvbox_init(), dvbox_clear();
        !            52: int dvbox_putc(), dvbox_cursor(), dvbox_scroll();
        !            53: 
        !            54: struct itesw itesw[] = {
        !            55:        topcat_init,            nodev,                  topcat_clear,
        !            56:        topcat_putc,            topcat_cursor,          topcat_scroll,
        !            57: 
        !            58:        gatorbox_init,          nodev,                  gatorbox_clear,
        !            59:        gatorbox_putc,          gatorbox_cursor,        gatorbox_scroll,
        !            60: 
        !            61:        rbox_init,              nodev,                  rbox_clear,
        !            62:        rbox_putc,              rbox_cursor,            rbox_scroll,
        !            63: 
        !            64:        dvbox_init,             nodev,                  dvbox_clear,
        !            65:        dvbox_putc,             dvbox_cursor,           dvbox_scroll,
        !            66: };
        !            67: 
        !            68: /* these guys need to be in initialized data */
        !            69: int itecons = -1;
        !            70: struct  ite_softc ite_softc[NITE] = { 0 };
        !            71: 
        !            72: /*
        !            73:  * Locate all bitmapped displays
        !            74:  */
        !            75: iteconfig()
        !            76: {
        !            77:        extern struct hp_hw sc_table[];
        !            78:        int dtype, fboff, i;
        !            79:        struct hp_hw *hw;
        !            80:        struct grfreg *gr;
        !            81:        struct ite_softc *ip;
        !            82: 
        !            83:        i = 0;
        !            84:        for (hw = sc_table; hw < &sc_table[MAX_CTLR]; hw++) {
        !            85:                if (hw->hw_type != BITMAP)
        !            86:                        continue;
        !            87:                gr = (struct grfreg *) hw->hw_addr;
        !            88:                /* XXX: redundent but safe */
        !            89:                if (badaddr((caddr_t)gr) || gr->gr_id != GRFHWID)
        !            90:                        continue;
        !            91:                switch (gr->gr_id2) {
        !            92:                case GID_GATORBOX:
        !            93:                        dtype = ITE_GATORBOX;
        !            94:                        break;
        !            95:                case GID_TOPCAT:
        !            96:                case GID_LRCATSEYE:
        !            97:                case GID_HRCCATSEYE:
        !            98:                case GID_HRMCATSEYE:
        !            99:                        dtype = ITE_TOPCAT;
        !           100:                        break;
        !           101:                case GID_RENAISSANCE:
        !           102:                        dtype = ITE_RENAISSANCE;
        !           103:                        break;
        !           104:                case GID_DAVINCI:
        !           105:                        dtype = ITE_DAVINCI;
        !           106:                        break;
        !           107:                default:
        !           108:                        continue;
        !           109:                }
        !           110:                if (i >= NITE)
        !           111:                        break;
        !           112:                ip = &ite_softc[i];
        !           113:                ip->regbase = (caddr_t) gr;
        !           114:                fboff = (gr->gr_fbomsb << 8) | gr->gr_fbolsb;
        !           115:                ip->fbbase = (caddr_t) (*((u_char *)ip->regbase+fboff) << 16);
        !           116:                /* DIO II: FB offset is relative to select code space */
        !           117:                if (ip->regbase >= (caddr_t)0x1000000)
        !           118:                        ip->fbbase += (int)ip->regbase;
        !           119:                ip->flags = ITE_ALIVE|ITE_CONSOLE;
        !           120:                ip->type = dtype;
        !           121:                i++;
        !           122:        }
        !           123: }
        !           124: 
        !           125: #ifdef CONSDEBUG
        !           126: /*
        !           127:  * Allows us to cycle through all possible consoles (NITE ites and serial port)
        !           128:  * by using SHIFT-RESET on the keyboard.
        !           129:  */
        !           130: int    whichconsole = -1;
        !           131: #endif
        !           132: 
        !           133: iteprobe(cp)
        !           134:        struct consdev *cp;
        !           135: {
        !           136:        register int ite;
        !           137:        register struct ite_softc *ip;
        !           138:        int unit, pri;
        !           139: 
        !           140: #ifdef CONSDEBUG
        !           141:        whichconsole = ++whichconsole % (NITE+1);
        !           142: #endif
        !           143: 
        !           144:        if (itecons != -1)
        !           145:                return(1);
        !           146: 
        !           147:        iteconfig();
        !           148:        unit = -1;
        !           149:        pri = CN_DEAD;
        !           150:        for (ite = 0; ite < NITE; ite++) {
        !           151: #ifdef CONSDEBUG
        !           152:                if (ite < whichconsole)
        !           153:                        continue;
        !           154: #endif
        !           155:                ip = &ite_softc[ite];
        !           156:                if ((ip->flags & (ITE_ALIVE|ITE_CONSOLE))
        !           157:                    != (ITE_ALIVE|ITE_CONSOLE))
        !           158:                        continue;
        !           159:                if ((int)ip->regbase == GRFIADDR) {
        !           160:                        pri = CN_INTERNAL;
        !           161:                        unit = ite;
        !           162:                } else if (unit < 0) {
        !           163:                        pri = CN_NORMAL;
        !           164:                        unit = ite;
        !           165:                }
        !           166:        }
        !           167:        cp->cn_dev = unit;
        !           168:        cp->cn_pri = pri;
        !           169: }
        !           170: 
        !           171: iteinit(cp)
        !           172:        struct consdev *cp;
        !           173: {
        !           174:        int ite = cp->cn_dev;
        !           175:        struct ite_softc *ip;
        !           176: 
        !           177:        if (itecons != -1)
        !           178:                return(1);
        !           179: 
        !           180:        ip = &ite_softc[ite];
        !           181: 
        !           182:        ip->curx = 0;
        !           183:        ip->cury = 0;
        !           184:        ip->cursorx = 0;
        !           185:        ip->cursory = 0;
        !           186: 
        !           187:        (*itesw[ip->type].ite_init)(ip);
        !           188:        (*itesw[ip->type].ite_cursor)(ip, DRAW_CURSOR);
        !           189: 
        !           190:        itecons = ite;
        !           191:        kbdinit();
        !           192: }
        !           193: 
        !           194: iteputchar(c)
        !           195:        register int c;
        !           196: {
        !           197:        register struct ite_softc *ip = &ite_softc[itecons];
        !           198:        register struct itesw *sp = &itesw[ip->type];
        !           199: 
        !           200:        c &= 0x7F;
        !           201:        switch (c) {
        !           202: 
        !           203:        case '\n':
        !           204:                if (++ip->cury == ip->rows) {
        !           205:                        ip->cury--;
        !           206:                        (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
        !           207:                        ite_clrtoeol(ip, sp, ip->cury, 0);
        !           208:                }
        !           209:                else
        !           210:                        (*sp->ite_cursor)(ip, MOVE_CURSOR);
        !           211:                break;
        !           212: 
        !           213:        case '\r':
        !           214:                ip->curx = 0;
        !           215:                (*sp->ite_cursor)(ip, MOVE_CURSOR);
        !           216:                break;
        !           217: 
        !           218:        case '\b':
        !           219:                if (--ip->curx < 0)
        !           220:                        ip->curx = 0;
        !           221:                else
        !           222:                        (*sp->ite_cursor)(ip, MOVE_CURSOR);
        !           223:                break;
        !           224: 
        !           225:        default:
        !           226:                if (c < ' ' || c == 0177)
        !           227:                        break;
        !           228:                (*sp->ite_putc)(ip, c, ip->cury, ip->curx, ATTR_NOR);
        !           229:                (*sp->ite_cursor)(ip, DRAW_CURSOR);
        !           230:                itecheckwrap(ip, sp);
        !           231:                break;
        !           232:        }
        !           233: }
        !           234: 
        !           235: itecheckwrap(ip, sp)
        !           236:      register struct ite_softc *ip;
        !           237:      register struct itesw *sp;
        !           238: {
        !           239:        if (++ip->curx == ip->cols) {
        !           240:                ip->curx = 0;
        !           241:                if (++ip->cury == ip->rows) {
        !           242:                        --ip->cury;
        !           243:                        (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
        !           244:                        ite_clrtoeol(ip, sp, ip->cury, 0);
        !           245:                        return;
        !           246:                }
        !           247:        }
        !           248:        (*sp->ite_cursor)(ip, MOVE_CURSOR);
        !           249: }
        !           250: 
        !           251: ite_clrtoeol(ip, sp, y, x)
        !           252:      register struct ite_softc *ip;
        !           253:      register struct itesw *sp;
        !           254:      register int y, x;
        !           255: {
        !           256:        (*sp->ite_clear)(ip, y, x, 1, ip->cols - x);
        !           257:        (*sp->ite_cursor)(ip, DRAW_CURSOR);
        !           258: }
        !           259: 
        !           260: itegetchar()
        !           261: {
        !           262: #ifdef SMALL
        !           263:        return (0);
        !           264: #else
        !           265:        return (kbdgetc());
        !           266: #endif
        !           267: }
        !           268: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.