Annotation of coherent/b/STREAMS/io.386/mm.c, revision 1.1

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

unix.superglobalmegacorp.com

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