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

1.1       root        1: /*
                      2:  * File:       putchar.c
                      3:  *
                      4:  * $Log:       putchar.c,v $
                      5:  * Revision 1.5  93/04/14  10:12:14  root
                      6:  * r75
                      7:  * 
                      8:  * Revision 1.4  92/06/15  13:06:59  root
                      9:  * Use putchar_init on (2,0) as well as async.
                     10:  * 
                     11:  * Revision 1.3  92/06/11  21:05:27  root
                     12:  * *** empty log message ***
                     13:  * 
                     14:  */
                     15: #include <sys/coherent.h>
                     16: #include <sys/inode.h>
                     17: #include <sys/stat.h>
                     18: #include <sys/con.h>
                     19: #include <sys/io.h>
                     20: #include <sys/devices.h>
                     21: 
                     22: #define P_LEN 1024
                     23: /*
                     24:  * Stash messages in p_buf[] until we can print them.
                     25:  * Note that p_buf[] can not be safely kalloc()'d because even
                     26:  * those routines could generate printf()'s.
                     27:  */
                     28: static char    p_buf[P_LEN];
                     29: static int     p_off;  /* Offset into p_buff.  */
                     30: int ok_to_use_dev = 0; /* Can we use the console device yet?  */
                     31: 
                     32: int coninit = 0;
                     33: dev_t condev = makedev(2,0);
                     34: 
                     35: putchar(c)
                     36: int c;
                     37: {
                     38: #if SERIAL_CONSOLE || GORT || KLAATU
                     39: __putchar(c);
                     40: #else
                     41:        IO iob;
                     42: 
                     43:        /*
                     44:         * If we get a printf before the devices have been initialized,
                     45:         * keep as many characters as we can until we can print them.
                     46:         */
                     47:        if (!ok_to_use_dev) {
                     48:                if (p_off == P_LEN) {
                     49:                        p_buf[P_LEN-1] = '*';   /* Mark an overrun.  */
                     50:                } else {
                     51:                        p_buf[p_off++] = c;     /* Stash the character.  */
                     52:                }
                     53:                return;
                     54:        }
                     55: 
                     56:        if (coninit == 0) {
                     57:                ++coninit;
                     58:                dopen(condev, IPW, DFCHR);
                     59:        }
                     60: 
                     61:        if (c == '\n')
                     62:                putchar('\r');
                     63: 
                     64:        iob.io_seg  = IOSYS;
                     65:        iob.io_ioc  = 1;
                     66: #ifdef _I386
                     67:        iob.io.vbase = &c;
                     68: #else
                     69:        iob.io_base = &c;
                     70: #endif
                     71:        iob.io_flag = 0;
                     72:        dwrite(condev, &iob);
                     73: #endif
                     74: } /* putchar() */
                     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:        /* Dump everything we've stored away.  */
                     89:        for (i = 0; i < p_off; ++i)
                     90:                putchar(p_buf[i]);
                     91: 
                     92:        if ('*' == p_buf[P_LEN-1])
                     93:                printf("\npb buffer overrun detected.\n");
                     94: } /* putchar_init() */

unix.superglobalmegacorp.com

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