Annotation of coherent/b/STREAMS/conf/streams/src/_putcon.c, revision 1.1.1.1

1.1       root        1: #define        _DDI_DKI        1
                      2: #define        _SYSV4          1
                      3: 
                      4: /*
                      5:  * Simple console output for kernel debugging.
                      6:  *
                      7:  * This module exists to service the DDI/DKI cmn_err () function, which takes
                      8:  * care of details like locking. This function is a simple debugging output
                      9:  * which on PC's expects to write to the screen memory.
                     10:  */
                     11: 
                     12: /*
                     13:  *-IMPORTS:
                     14:  *     <common/ccompat.h>
                     15:  *             __USE_PROTO__
                     16:  *             __ARGS ()
                     17:  *     <common/xdebug.h>
                     18:  *             __LOCAL__
                     19:  */
                     20: 
                     21: #include <common/ccompat.h>
                     22: #include <common/xdebug.h>
                     23: 
                     24: 
                     25: /*
                     26:  * For the IBM PC, simply define a way of making the console directly-
                     27:  * addressable memory. A plausible and useful alternative would be to define
                     28:  * a "console" virtual terminal that audiovisually signals the operator (via
                     29:  * the speaker and by palette "flash") when new information is written to it.
                     30:  *
                     31:  * That's a creature feature for later.
                     32:  */
                     33: 
                     34: #if    defined (GNUDOS)
                     35: 
                     36: #include <pc.h>
                     37: 
                     38: #define        _putconsole(x,y,c)      ScreenPutChar (c, 0x07, x, y)   
                     39: #define        _setcursor(x,y)         ScreenSetCursor (y, x)
                     40: 
                     41: #elif  __BORLANDC__
                     42: 
                     43: #include <dos.h>
                     44: 
                     45: #define        _putconsole(x,y,c)      (* ((int __far *) MK_FP (0xB800, \
                     46:                                        ((x) - 1 + ((y) - 1) * 80) * 2)) \
                     47:                                                 = (c) | 0x700)
                     48: __LOCAL__ void _setcursor (int x, int y) {
                     49:        union REGS      regs;
                     50:        regs.h.ah = 0x2;
                     51:        regs.h.dh = y;
                     52:        regs.h.dl = x;
                     53:        regs.h.bh = 0;
                     54:        int86 (0x10, & regs, & regs);
                     55: }
                     56: 
                     57: #else
                     58: 
                     59: #error I do not know how to perform debugging output on this system
                     60: 
                     61: #endif
                     62: 
                     63: 
                     64: /*
                     65:  * Local state for the simple debug output.
                     66:  */
                     67: 
                     68: __LOCAL__ struct {
                     69:        unsigned        x;
                     70:        unsigned        y;
                     71:        unsigned        width;
                     72:        unsigned        height;
                     73: } _console = {
                     74:        1, 1, 80, 25
                     75: };
                     76: 
                     77: 
                     78: /*
                     79:  *-STATUS:
                     80:  *     Private to cmn_err ()
                     81:  *
                     82:  *-NAME:
                     83:  *     _put_console () simple console debugging output
                     84:  *
                     85:  *-ARGUMENTS:
                     86:  *     outch           The character to display on the system console. The
                     87:  *                     '\n' and '\r' characters are interpreted as carriage-
                     88:  *                     return+line-feed and carriage-return respectively.
                     89:  *                     It is recommended that '\a' also be interpreted and
                     90:  *                     audibly signal the console operator if the
                     91:  *                     implementation can possibly do so.
                     92:  *
                     93:  *-DESCRIPTION:
                     94:  *     This function provides system-specific debugging output support for
                     95:  *     the DDI/DKI cnm_err () function, interfacing to the system console
                     96:  *     hardware.
                     97:  *
                     98:  *-NOTES:
                     99:  *     This function does not sleep.
                    100:  *
                    101:  *     Driver-defined basic locks, read/write locks and sleep locks may
                    102:  *     be held across calls to this function.
                    103:  */
                    104: 
                    105: #if    __USE_PROTO__
                    106: void (_put_console) (unsigned char outch)
                    107: #else
                    108: void
                    109: _put_console __ARGS ((outch))
                    110: unsigned char  outch;
                    111: #endif
                    112: {
                    113:        switch (outch) {
                    114: 
                    115:        case '\n':                      /* Carriage return... clear to eol */
                    116: 
                    117:                while (_console.x < _console.width)
                    118:                        _putconsole (_console.x ++, _console.y, ' ');
                    119: nextline:
                    120:                _console.x = 1;
                    121: 
                    122:                /*
                    123:                 * Don't bother scrolling, just wrap around will do.
                    124:                 */
                    125: 
                    126:                _console.y = _console.y % _console.height + 1;
                    127:                break;
                    128: 
                    129:        case '\r':
                    130:                _console.x = 0;
                    131:                break;
                    132: 
                    133:        case '\a':
                    134:                break;
                    135: 
                    136:        default:
                    137:                _putconsole (_console.x ++, _console.y, outch);
                    138: 
                    139:                if (_console.x > _console.width)
                    140:                        goto nextline;
                    141: 
                    142:                break;
                    143:        }
                    144: 
                    145:        _setcursor (_console.x, _console.y);
                    146: }

unix.superglobalmegacorp.com

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