Annotation of coherent/b/kernel/io.386/console.c, revision 1.1.1.1

1.1       root        1: /* $Header: /src386/kernel/io.386/RCS/console.c,v 1.3 92/08/28 09:02:49 bin Exp Locker: bin $ */
                      2: /*
                      3:  * Tiny console driver.
                      4:  * 8086/8088 Coherent, IBM PC.
                      5:  *
                      6:  * $Log:       console.c,v $
                      7:  * Revision 1.3  92/08/28  09:02:49  bin
                      8:  * update by hal for kernel 61
                      9:  * 
                     10:  * Revision 1.2  92/01/06  12:26:44  hal
                     11:  * Compile with cc.mwc.
                     12:  * 
                     13:  * Revision 2.1        88/09/03  13:03:39      src
                     14:  * *** empty log message ***
                     15:  * 
                     16:  * Revision 1.1        88/03/24  17:04:25      src
                     17:  * Initial revision
                     18:  * 
                     19:  * 86/11/19    Allan Cornish           /usr/src/sys/i8086/drv/console.c
                     20:  * putchar() initializes the (new) (IO).io_flag field to 0.
                     21:  */
                     22: #include <sys/coherent.h>
                     23: #include <sys/inode.h>
                     24: #include <sys/stat.h>
                     25: #include <sys/con.h>
                     26: #include <sys/io.h>
                     27: 
                     28: #define P_LEN 512      /* Keep about six full lines of characters.  */
                     29: /*
                     30:  * Stash messages in p_buf[] until we can print them.
                     31:  * Note that p_buf[] can not be safely kalloc()'d because even
                     32:  * those routines could generate printf()'s.
                     33:  */
                     34: static char    p_buf[P_LEN];
                     35: static int     p_off;  /* Offset into p_buff.  */
                     36: int ok_to_use_dev = 0; /* Can we use the console device yet?  */
                     37: 
                     38: int coninit = 0;
                     39: dev_t condev = makedev(2,0);
                     40: 
                     41: putchar(c)
                     42: int c;
                     43: {
                     44:        IO iob;
                     45: 
                     46: 
                     47:        /*
                     48:         * If we get a printf before the devices have been initialized,
                     49:         * keep as many characters as we can until we can print them.
                     50:         */
                     51:        if (condev != makedev(2,0) && !ok_to_use_dev) {
                     52:                if (p_off == P_LEN) {
                     53:                        p_buf[P_LEN-1] = '*';   /* Mark an overrun.  */
                     54:                } else {
                     55:                        p_buf[p_off++] = c;     /* Stash the character.  */
                     56:                }
                     57:                return;
                     58:        }
                     59: 
                     60:        if (coninit == 0) {
                     61:                ++coninit;
                     62:                dopen( condev, IPW, DFCHR );
                     63:        }
                     64: 
                     65:        if (c == '\n')
                     66:                putchar('\r');
                     67: 
                     68:        iob.io_seg  = IOSYS;
                     69:        iob.io_ioc  = 1;
                     70:        iob.io.vbase = &c;
                     71:        iob.io_flag = 0;
                     72:        dwrite( condev, &iob );
                     73: } /* putchar() */
                     74: 
                     75: 
                     76: /*
                     77:  * putchar_init() is called from main() once devices have been
                     78:  * initialized.  It marks the condev as usable, and then prints
                     79:  * anything that has been stored away.
                     80:  */
                     81: putchar_init()
                     82: {
                     83:        int i;
                     84: 
                     85:        /* Mark condev as usable.  */
                     86:        ok_to_use_dev = 1;
                     87: 
                     88:        /* nothing to do if CRT is console device */
                     89:        if (condev == makedev(2,0))
                     90:                return;
                     91: 
                     92:        /* Dump everything we've stored away.  */
                     93:        for (i = 0; i < p_off; ++i) {
                     94:                putchar(p_buf[i]);
                     95:        }
                     96:        
                     97:        printf("\n-\n");
                     98:        if ('*' == p_buf[P_LEN-1]) {
                     99:                printf("\npb buffer overrun detected.\n");
                    100:        }
                    101: } /* putchar_init() */

unix.superglobalmegacorp.com

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