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

unix.superglobalmegacorp.com

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