Annotation of coherent/d/kernel/USRSRC/i8086/drv/mm.c, revision 1.1.1.1

1.1       root        1: /* (-lgl
                      2:  *     COHERENT Driver Kit Version 1.1.0
                      3:  *     Copyright (c) 1982, 1990 by Mark Williams Company.
                      4:  *     All rights reserved. May not be copied without permission.
                      5:  -lgl) */
                      6: /*
                      7:  * Memory Mapped Video
                      8:  * High level output routines.
                      9:  */
                     10: #include <sys/coherent.h>
                     11: #include <sys/sched.h>
                     12: #include <errno.h>
                     13: #include <sys/stat.h>
                     14: #include <sys/io.h>
                     15: #include <sys/tty.h>
                     16: #include <sys/uproc.h>
                     17: #include <sys/timeout.h>
                     18: 
                     19: /* For beeper */
                     20: #define        TIMCTL  0x43                    /* Timer control port */
                     21: #define        TIMCNT  0x42                    /* Counter timer port */
                     22: #define        PORTB   0x61                    /* Port containing speaker enable */
                     23: #define        FREQ    ((int)(1193181L/440))   /* Counter for 440 Hz. tone */
                     24: 
                     25: int mmtime();
                     26: 
                     27: char mmbeeps;          /* number of ticks remaining on bell */
                     28: char mmesc;            /* last unserviced escape character */
                     29: int  mmcrtsav = 1;     /* crt saver enabled */
                     30: int  mmvcnt   = 900;   /* seconds remaining before crt saver is activated */
                     31: 
                     32: extern TTY istty;
                     33: 
                     34: /*
                     35:  * Start the output stream.
                     36:  * Called from `ttwrite' and `isrint' routines.
                     37:  */
                     38: TIM mmtim;
                     39: 
                     40: mmstart(tp)
                     41: register TTY *tp;
                     42: {
                     43:        int c;
                     44:        IO iob;
                     45:        static int mmbegun;
                     46: 
                     47:        while ((tp->t_flags&T_STOP) == 0) {
                     48:                if ((c = ttout(tp)) < 0)
                     49:                        break;
                     50:                iob.io_seg  = IOSYS;
                     51:                iob.io_ioc  = 1;
                     52:                iob.io_base = &c;
                     53:                iob.io_flag = 0;
                     54:                mmwrite( makedev(2,0), &iob );
                     55:        }
                     56: 
                     57:        if (mmbegun == 0) {
                     58:                ++mmbegun;
                     59:                timeout(&mmtim, HZ/10, mmtime, (char *)tp);
                     60:        }
                     61: }
                     62: 
                     63: mmtime(xp)
                     64: char *xp;
                     65: {
                     66:        register int s;
                     67: 
                     68:        s = sphi();
                     69:        if (mmbeeps < 0) {
                     70:                mmbeeps = 2;
                     71:                outb(TIMCTL, 0xB6);     /* Timer 2, lsb, msb, binary */
                     72:                outb(TIMCNT, FREQ&0xFF);
                     73:                outb(TIMCNT, FREQ>>8);
                     74:                outb(PORTB, inb(PORTB) | 03);   /* Turn speaker on */
                     75:        }
                     76:        else if ((mmbeeps > 0) && (--mmbeeps == 0))
                     77:                outb( PORTB, inb(PORTB) & ~03 );
                     78: 
                     79:        if (mmesc) {
                     80:                ismmfunc(mmesc);
                     81:                mmesc = 0;
                     82:        }
                     83:        spl(s);
                     84: 
                     85:        ttstart( (TTY *) xp );
                     86: 
                     87:        timeout(&mmtim, HZ/10, mmtime, xp);
                     88: }
                     89: 
                     90: /**
                     91:  *
                     92:  * void
                     93:  * mmwatch()   -- turn video display off after 15 minutes inactivity.
                     94:  */
                     95: void
                     96: mmwatch()
                     97: {
                     98:        if ( (mmcrtsav > 0) && (mmvcnt > 0) && (--mmvcnt == 0) )
                     99:                mm_voff();
                    100: }
                    101: 
                    102: mmwrite( dev, iop )
                    103: dev_t dev;
                    104: register IO *iop;
                    105: {
                    106:        int ioc;
                    107:        int s;
                    108: 
                    109:        ioc = iop->io_ioc;
                    110: 
                    111:        /*
                    112:         * Kernel writes.
                    113:         */
                    114:        if (iop->io_seg == IOSYS) {
                    115:                while (mmgo(iop))
                    116:                        ;
                    117:        }
                    118: 
                    119:        /*
                    120:         * Blocking user writes.
                    121:         */
                    122:        else if ( (iop->io_flag & IONDLY) == 0 ) {
                    123:                do {
                    124:                        while (istty.t_flags & T_STOP) {
                    125:                                s = sphi();
                    126:                                istty.t_flags |= T_HILIM;
                    127:                                sleep((char*) &istty.t_oq,
                    128:                                        CVTTOUT, IVTTOUT, SVTTOUT);
                    129:                                spl( s );
                    130:                        }
                    131:                        /*
                    132:                         * Signal received.
                    133:                         */
                    134:                        if ( SELF->p_ssig && nondsig() ) {
                    135:                                kbunscroll();   /* update kbd LEDS */
                    136:                                /*
                    137:                                 * No data transferred yet.
                    138:                                 */
                    139:                                if ( ioc == iop->io_ioc )
                    140:                                        u.u_error = EINTR;
                    141:                                /*
                    142:                                 * Transfer remaining data
                    143:                                 * without pausing after scrolling.
                    144:                                 */
                    145:                                else while ( mmgo(iop) )
                    146:                                        ;
                    147: 
                    148:                                return;
                    149:                        }
                    150:                        mmgo(iop);
                    151:                } while ( iop->io_ioc );
                    152:        }
                    153: 
                    154:        /*
                    155:         * Non-blocking user writes with output stopped.
                    156:         */
                    157:        else if ( istty.t_flags & T_STOP ) {
                    158:                u.u_error = EAGAIN;
                    159:                return;
                    160:        }
                    161: 
                    162:        /*
                    163:         * Non-blocking user writes do not pause after scrolling.
                    164:         */
                    165:        else {
                    166:                while ( mmgo(iop) )
                    167:                        ;
                    168:        }
                    169: }

unix.superglobalmegacorp.com

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