Annotation of Net2/arch/hp300/stand/ite.c, revision 1.1.1.2

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.20 91/01/21$
                     39:  *
1.1.1.2 ! root       40:  *     from: @(#)ite.c 7.3 (Berkeley) 5/7/91
        !            41:  *     ite.c,v 1.2 1993/05/22 07:59:02 cgd Exp
1.1       root       42:  */
                     43: 
                     44: /*
                     45:  * Standalone Internal Terminal Emulator (CRT and keyboard)
                     46:  */
                     47: #include "samachdep.h"
                     48: 
                     49: #ifdef ITECONSOLE
                     50: 
                     51: #include "sys/param.h"
                     52: #include "../hp300/cons.h"
                     53: #include "../dev/device.h"
                     54: #include "../dev/itevar.h"
                     55: #include "../dev/grfvar.h"
                     56: 
                     57: int nodev();
                     58: 
                     59: int topcat_init(), topcat_putc();
                     60: int topcat_clear(), topcat_cursor(), topcat_scroll();
                     61: int gatorbox_init(), gatorbox_clear();
                     62: int gatorbox_putc(), gatorbox_cursor(), gatorbox_scroll();
                     63: int rbox_init(), rbox_clear();
                     64: int rbox_putc(), rbox_cursor(), rbox_scroll();
                     65: int dvbox_init(), dvbox_clear();
                     66: int dvbox_putc(), dvbox_cursor(), dvbox_scroll();
                     67: 
                     68: struct itesw itesw[] = {
                     69:        topcat_init,            nodev,                  topcat_clear,
                     70:        topcat_putc,            topcat_cursor,          topcat_scroll,
                     71: 
                     72:        gatorbox_init,          nodev,                  gatorbox_clear,
                     73:        gatorbox_putc,          gatorbox_cursor,        gatorbox_scroll,
                     74: 
                     75:        rbox_init,              nodev,                  rbox_clear,
                     76:        rbox_putc,              rbox_cursor,            rbox_scroll,
                     77: 
                     78:        dvbox_init,             nodev,                  dvbox_clear,
                     79:        dvbox_putc,             dvbox_cursor,           dvbox_scroll,
                     80: };
                     81: 
                     82: /* these guys need to be in initialized data */
                     83: int itecons = -1;
                     84: struct  ite_softc ite_softc[NITE] = { 0 };
                     85: 
                     86: /*
                     87:  * Locate all bitmapped displays
                     88:  */
                     89: iteconfig()
                     90: {
                     91:        extern struct hp_hw sc_table[];
                     92:        int dtype, fboff, i;
                     93:        struct hp_hw *hw;
                     94:        struct grfreg *gr;
                     95:        struct ite_softc *ip;
                     96: 
                     97:        i = 0;
                     98:        for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++) {
                     99:                if (!HW_ISDEV(hw, D_BITMAP))
                    100:                        continue;
                    101:                gr = (struct grfreg *) hw->hw_kva;
                    102:                /* XXX: redundent but safe */
                    103:                if (badaddr((caddr_t)gr) || gr->gr_id != GRFHWID)
                    104:                        continue;
                    105:                switch (gr->gr_id2) {
                    106:                case GID_GATORBOX:
                    107:                        dtype = ITE_GATORBOX;
                    108:                        break;
                    109:                case GID_TOPCAT:
                    110:                case GID_LRCATSEYE:
                    111:                case GID_HRCCATSEYE:
                    112:                case GID_HRMCATSEYE:
                    113:                        dtype = ITE_TOPCAT;
                    114:                        break;
                    115:                case GID_RENAISSANCE:
                    116:                        dtype = ITE_RENAISSANCE;
                    117:                        break;
                    118:                case GID_DAVINCI:
                    119:                        dtype = ITE_DAVINCI;
                    120:                        break;
                    121:                default:
                    122:                        continue;
                    123:                }
                    124:                if (i >= NITE)
                    125:                        break;
                    126:                ip = &ite_softc[i];
                    127:                ip->regbase = (caddr_t) gr;
                    128:                fboff = (gr->gr_fbomsb << 8) | gr->gr_fbolsb;
                    129:                ip->fbbase = (caddr_t) (*((u_char *)ip->regbase+fboff) << 16);
                    130:                /* DIO II: FB offset is relative to select code space */
                    131:                if (ip->regbase >= (caddr_t)DIOIIBASE)
                    132:                        ip->fbbase += (int)ip->regbase;
                    133:                ip->flags = ITE_ALIVE|ITE_CONSOLE;
                    134:                ip->type = dtype;
                    135:                i++;
                    136:        }
                    137: }
                    138: 
                    139: #ifdef CONSDEBUG
                    140: /*
                    141:  * Allows us to cycle through all possible consoles (NITE ites and serial port)
                    142:  * by using SHIFT-RESET on the keyboard.
                    143:  */
                    144: int    whichconsole = -1;
                    145: #endif
                    146: 
                    147: iteprobe(cp)
                    148:        struct consdev *cp;
                    149: {
                    150:        register int ite;
                    151:        register struct ite_softc *ip;
                    152:        int unit, pri;
                    153: 
                    154: #ifdef CONSDEBUG
                    155:        whichconsole = ++whichconsole % (NITE+1);
                    156: #endif
                    157: 
                    158:        if (itecons != -1)
                    159:                return(1);
                    160: 
                    161:        iteconfig();
                    162:        unit = -1;
                    163:        pri = CN_DEAD;
                    164:        for (ite = 0; ite < NITE; ite++) {
                    165: #ifdef CONSDEBUG
                    166:                if (ite < whichconsole)
                    167:                        continue;
                    168: #endif
                    169:                ip = &ite_softc[ite];
                    170:                if ((ip->flags & (ITE_ALIVE|ITE_CONSOLE))
                    171:                    != (ITE_ALIVE|ITE_CONSOLE))
                    172:                        continue;
                    173:                if ((int)ip->regbase == GRFIADDR) {
                    174:                        pri = CN_INTERNAL;
                    175:                        unit = ite;
                    176:                } else if (unit < 0) {
                    177:                        pri = CN_NORMAL;
                    178:                        unit = ite;
                    179:                }
                    180:        }
                    181:        cp->cn_dev = unit;
                    182:        cp->cn_pri = pri;
                    183: }
                    184: 
                    185: iteinit(cp)
                    186:        struct consdev *cp;
                    187: {
                    188:        int ite = cp->cn_dev;
                    189:        struct ite_softc *ip;
                    190: 
                    191:        if (itecons != -1)
                    192:                return(1);
                    193: 
                    194:        ip = &ite_softc[ite];
                    195: 
                    196:        ip->curx = 0;
                    197:        ip->cury = 0;
                    198:        ip->cursorx = 0;
                    199:        ip->cursory = 0;
                    200: 
                    201:        (*itesw[ip->type].ite_init)(ip);
                    202:        (*itesw[ip->type].ite_cursor)(ip, DRAW_CURSOR);
                    203: 
                    204:        itecons = ite;
                    205:        kbdinit();
                    206: }
                    207: 
                    208: iteputchar(c)
                    209:        register int c;
                    210: {
                    211:        register struct ite_softc *ip = &ite_softc[itecons];
                    212:        register struct itesw *sp = &itesw[ip->type];
                    213: 
                    214:        c &= 0x7F;
                    215:        switch (c) {
                    216: 
                    217:        case '\n':
                    218:                if (++ip->cury == ip->rows) {
                    219:                        ip->cury--;
                    220:                        (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
                    221:                        ite_clrtoeol(ip, sp, ip->cury, 0);
                    222:                }
                    223:                else
                    224:                        (*sp->ite_cursor)(ip, MOVE_CURSOR);
                    225:                break;
                    226: 
                    227:        case '\r':
                    228:                ip->curx = 0;
                    229:                (*sp->ite_cursor)(ip, MOVE_CURSOR);
                    230:                break;
                    231: 
                    232:        case '\b':
                    233:                if (--ip->curx < 0)
                    234:                        ip->curx = 0;
                    235:                else
                    236:                        (*sp->ite_cursor)(ip, MOVE_CURSOR);
                    237:                break;
                    238: 
                    239:        default:
                    240:                if (c < ' ' || c == 0177)
                    241:                        break;
                    242:                (*sp->ite_putc)(ip, c, ip->cury, ip->curx, ATTR_NOR);
                    243:                (*sp->ite_cursor)(ip, DRAW_CURSOR);
                    244:                itecheckwrap(ip, sp);
                    245:                break;
                    246:        }
                    247: }
                    248: 
                    249: itecheckwrap(ip, sp)
                    250:      register struct ite_softc *ip;
                    251:      register struct itesw *sp;
                    252: {
                    253:        if (++ip->curx == ip->cols) {
                    254:                ip->curx = 0;
                    255:                if (++ip->cury == ip->rows) {
                    256:                        --ip->cury;
                    257:                        (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
                    258:                        ite_clrtoeol(ip, sp, ip->cury, 0);
                    259:                        return;
                    260:                }
                    261:        }
                    262:        (*sp->ite_cursor)(ip, MOVE_CURSOR);
                    263: }
                    264: 
                    265: ite_clrtoeol(ip, sp, y, x)
                    266:      register struct ite_softc *ip;
                    267:      register struct itesw *sp;
                    268:      register int y, x;
                    269: {
                    270:        (*sp->ite_clear)(ip, y, x, 1, ip->cols - x);
                    271:        (*sp->ite_cursor)(ip, DRAW_CURSOR);
                    272: }
                    273: 
                    274: itegetchar()
                    275: {
                    276: #ifdef SMALL
                    277:        return (0);
                    278: #else
                    279:        return (kbdgetc());
                    280: #endif
                    281: }
                    282: #endif

unix.superglobalmegacorp.com

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