Annotation of coherent/b/STREAMS/io.386/vtmm.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * vtmm.c
                      3:  *
                      4:  * Memory Mapped Video
                      5:  * High level output routines.
                      6:  *
                      7:  * $Log:       vtmm.c,v $
                      8:  * Revision 2.3  93/08/09  13:47:17  bin
                      9:  * Kernel 82 changes
                     10:  * 
                     11:  * Revision 2.2  93/07/26  15:33:01  nigel
                     12:  * Nigel's R80
                     13:  * 
                     14:  * Revision 1.2  92/07/16  16:35:31  hal
                     15:  * Kernel #58
                     16:  * 
                     17:  * Revision 1.4  92/04/09  10:25:38  hal
                     18:  * Call mmgo() from mmstart() at low priority.
                     19:  * 
                     20:  */
                     21: 
                     22: #include <kernel/timeout.h>
                     23: 
                     24: #include <sys/coherent.h>
                     25: #include <sys/sched.h>
                     26: #include <sys/errno.h>
                     27: #include <sys/stat.h>
                     28: #include <sys/io.h>
                     29: #include <sys/tty.h>
                     30: 
                     31: #include <sys/kb.h>
                     32: #include <sys/vt.h>
                     33: 
                     34: /* For beeper */
                     35: #define        TIMCTL  0x43                    /* Timer control port */
                     36: #define        TIMCNT  0x42                    /* Counter timer port */
                     37: #define        PORTB   0x61                    /* Port containing speaker enable */
                     38: #define        FREQ    ((int)(1193181L/440))   /* Counter for 440 Hz. tone */
                     39: 
                     40: int vtmmtime();
                     41: 
                     42: char vtmmbeeps;                /* number of ticks remaining on bell */
                     43: char vtmmesc;          /* last unserviced escape character */
                     44: int  vtmmcrtsav = 1;   /* crt saver enabled */
                     45: int  vtmmvcnt   = 900; /* seconds remaining before crt saver is activated */
                     46: 
                     47: extern TTY **vttty;
                     48: 
                     49: /*
                     50:  * Start the output stream.
                     51:  * Called from `ttwrite' and `isrint' routines.
                     52:  */
                     53: TIM vtmmtim;
                     54: 
                     55: vtmmstart(tp)
                     56: register TTY *tp;
                     57: {
                     58:        int c, s;
                     59:        IO iob;
                     60:        static int mmbegun;
                     61: 
                     62:        if (mmbegun == 0) {
                     63:                ++mmbegun;
                     64:                timeout(&vtmmtim, HZ/10, vtmmtime, (char *)tp);
                     65:        }
                     66: 
                     67:        while ((tp->t_flags&T_STOP) == 0) {
                     68:                if ((c = ttout(tp)) < 0)
                     69:                        break;
                     70:                iob.io_seg  = IOSYS;
                     71:                iob.io_ioc  = 1;
                     72:                iob.io.vbase = &c;
                     73:                iob.io_flag = 0;
                     74: #if 0
                     75:                vtmmwrite( ((VTDATA *)tp->t_ddp)->vt_dev, &iob );
                     76: #else
                     77:                s = splo();
                     78:                vtmmgo(&iob, tp->t_ddp, ((VTDATA *)(tp->t_ddp))->vt_ind);
                     79:                spl(s);
                     80: #endif
                     81:        }
                     82: }
                     83: 
                     84: vtmmtime(xp)
                     85: char *xp;
                     86: {
                     87:        register int s;
                     88:        register VTDATA *vp = (VTDATA *)((TTY *)xp)->t_ddp;
                     89: 
                     90:        s = sphi();
                     91:        if (vtmmbeeps < 0) {
                     92:                vtmmbeeps = 2;
                     93:                outb(TIMCTL, 0xB6);     /* Timer 2, lsb, msb, binary */
                     94:                outb(TIMCNT, FREQ&0xFF);
                     95:                outb(TIMCNT, FREQ>>8);
                     96:                outb(PORTB, inb(PORTB) | 03);   /* Turn speaker on */
                     97:        }
                     98:        else if ((vtmmbeeps > 0) && (--vtmmbeeps == 0))
                     99:                outb( PORTB, inb(PORTB) & ~03 );
                    100: 
                    101:        if (vp->vmm_esc) {
                    102:                ismmfunc(vp->vmm_esc);
                    103:                vp->vmm_esc = 0;
                    104:        }
                    105:        spl(s);
                    106: 
                    107:        ttstart( (TTY *) xp );
                    108: 
                    109:        timeout(&vtmmtim, HZ/10, vtmmtime, xp);
                    110: }
                    111: 
                    112: /**
                    113:  *
                    114:  * void
                    115:  * mmwatch()   -- turn video display off after 15 minutes inactivity.
                    116:  */
                    117: void
                    118: vtmmwatch()
                    119: {
                    120:        if ( (vtmmcrtsav > 0) && (vtmmvcnt > 0) && (--vtmmvcnt == 0) ) {
                    121:                vtmm_voff(vtdata[vtactive]);
                    122:        }
                    123: }
                    124: 
                    125: vtmmwrite( dev, iop )
                    126: dev_t dev;
                    127: register IO *iop;
                    128: {
                    129:        int ioc;
                    130:        register TTY *tp = vttty[vtindex(dev)];
                    131: 
                    132:        if (!tp) {
                    133:                printf( "mmwrite: bad dev %x", dev );
                    134:        }
                    135:        /*
                    136:         * Kernel writes.
                    137:         */
                    138:        if (iop->io_seg == IOSYS) {
                    139:                while (vtmmgo(iop, tp->t_ddp, vtindex(dev)))
                    140:                        ;
                    141:                goto mmwdone;
                    142:        }
                    143: 
                    144: #if 0
                    145:        ioc = iop->io_ioc;
                    146:        /*
                    147:         * Blocking user writes.
                    148:         */
                    149:        if ( (iop->io_flag & IONDLY) == 0 ) {
                    150:                do {
                    151:                        while (tp->t_flags & T_STOP) {
                    152:                                register s = sphi();
                    153: 
                    154:                                tp->t_flags |= T_HILIM;
                    155:                                sleep((char*) &tp->t_oq,
                    156:                                        CVTTOUT, IVTTOUT, SVTTOUT);
                    157:                                spl( s );
                    158:                        }
                    159:                        /*
                    160:                         * Signal received.
                    161:                         */
                    162:                        if (nondsig ()) {
                    163:                                kbunscroll();   /* update kbd LEDS */
                    164:                                /*
                    165:                                 * No data transferred yet.
                    166:                                 */
                    167:                                if ( ioc == iop->io_ioc )
                    168:                                        u.u_error = EINTR;
                    169:                                /*
                    170:                                 * Transfer remaining data
                    171:                                 * without pausing after scrolling.
                    172:                                 */
                    173:                                else while ( vtmmgo(iop, tp->t_ddp, vtindex(dev)))
                    174:                                        ;
                    175:                                goto mmwdone;
                    176:                        }
                    177:                        vtmmgo(iop, tp->t_ddp, vtindex(dev));
                    178:                } while ( iop->io_ioc );
                    179:                goto mmwdone;
                    180:        }
                    181: 
                    182:        /*
                    183:         * Non-blocking user writes with output stopped.
                    184:         */
                    185:        if ( tp->t_flags & T_STOP ) {
                    186:                u.u_error = EAGAIN;
                    187:                goto mmwdone;
                    188:        }
                    189: 
                    190:        /*
                    191:         * Non-blocking user writes do not pause after scrolling.
                    192:         */
                    193:        {
                    194:                while ( vtmmgo(iop, tp->t_ddp, vtindex(dev)) )
                    195:                        ;
                    196:        }
                    197: #else
                    198:        ttwrite(tp, iop);
                    199: #endif
                    200: mmwdone:
                    201:        return;
                    202: }
                    203: 
                    204: /******************************************************************************
                    205: *
                    206: * The following routines are called by deferred isr's, i.e., no sleep() calls 
                    207: * allowed 
                    208: *
                    209: *******************************************************************************/
                    210: 
                    211: /*
                    212:  * update the screen to match vtactive
                    213:  */
                    214: vtupdscreen(index)
                    215: int index;
                    216: {
                    217:        register int pos, s;
                    218:        VTDATA *vp;
                    219: 
                    220:        vp = vtdata[index];
                    221:        pos = vp->vmm_voff;
                    222:        PRINTV( "update screen@%x {%d @%x|",
                    223:                vp->vmm_port, index, pos );
                    224: 
                    225:        s = sphi();
                    226:        /* update base of video memory */
                    227:        outb(vp->vmm_port, 0xC);
                    228:        outb(vp->vmm_port+1, pos >> (8 + 1) );
                    229:        outb(vp->vmm_port, 0xD);
                    230:        outb(vp->vmm_port+1, pos >> (0 + 1) );
                    231: 
                    232:        /* update the cursor */
                    233:        pos += vp->vmm_pos;
                    234: 
                    235:        pos |= vp->vmm_invis;           /* Mask cursor, if set */
                    236:        outb(vp->vmm_port, 0xE);
                    237:        outb(vp->vmm_port+1, pos >> (8 + 1) );
                    238:        outb(vp->vmm_port, 0xF);
                    239:        outb(vp->vmm_port+1, pos >> (0 + 1) );
                    240: 
                    241:        spl(s);
                    242:        PRINTV( "%x}\n", pos );
                    243: }

unix.superglobalmegacorp.com

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