The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/drivers/log/kputc.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* A server must occasionally print some message.  It uses a simple version of 
    2  * printf() found in the system library that calls putk() to output characters.
    3  * The LOG driver cannot use the regular putk().  Hence, it uses a special
    4  * version of putk() that directly sends to the TTY task. 
    5  *
    6  * Changes:
    7  *      21 July 2005:   Created  (Jorrit N. Herder)
    8  */
    9 
   10 #include "log.h"
   11 
   12 /*===========================================================================*
   13  *                              kputc                                        *
   14  *===========================================================================*/
   15 void kputc(c)
   16 int c;
   17 {
   18 /* Accumulate another character.  If 0 or buffer full, print it. */
   19   static int buf_count;         /* # characters in the buffer */
   20   static char print_buf[80];    /* output is buffered here */
   21   message m;
   22 
   23   if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
   24         m.DIAG_BUF_COUNT = buf_count;
   25         m.DIAG_PRINT_BUF = print_buf;
   26         m.DIAG_PROC_NR = SELF;
   27         m.m_type = DIAGNOSTICS;         /* request TTY to output this buffer */
   28         _sendrec(TTY_PROC_NR, &m);      /* if it fails, we give up */ 
   29         buf_count = 0;                  /* clear buffer for next batch */
   30   }
   31   if (c != 0) {
   32         print_buf[buf_count++] = c;
   33   }
   34 }
   35 

Cache object: eb6ca081e035114a398ba2ddce4007ca


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.