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

unix.superglobalmegacorp.com

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