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

unix.superglobalmegacorp.com

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