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

unix.superglobalmegacorp.com

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