~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Minix Cross Reference
Minix/mm/putk.c


  1 /* MM must occasionally print some message.  It uses the standard library
  2  * routine printk().  (The name "printf" is really a macro defined as 
  3  * "printk"). Printing is done by calling the TTY task directly, not going 
  4  * through FS.
  5  */
  6 
  7 #include "mm.h"
  8 #include <minix/com.h>
  9 
 10 #define BUF_SIZE          100   /* print buffer size */
 11 
 12 PRIVATE int buf_count;          /* # characters in the buffer */
 13 PRIVATE char print_buf[BUF_SIZE];       /* output is buffered here */
 14 PRIVATE message putch_msg;      /* used for message to TTY task */
 15 
 16 _PROTOTYPE( FORWARD void flush, (void) );
 17 
 18 /*===========================================================================*
 19  *                              putk                                         *
 20  *===========================================================================*/
 21 PUBLIC void putk(c)
 22 int c;
 23 {
 24 /* Accumulate another character.  If 0 or buffer full, print it. */
 25 
 26   if (c == 0 || buf_count == BUF_SIZE) flush();
 27   if (c == '\n') putk('\r');
 28   if (c != 0) print_buf[buf_count++] = c;
 29 }
 30 
 31 
 32 /*===========================================================================*
 33  *                              flush                                        *
 34  *===========================================================================*/
 35 PRIVATE void flush()
 36 {
 37 /* Flush the print buffer by calling TTY task. */
 38 
 39   if (buf_count == 0) return;
 40   putch_msg.m_type = DEV_WRITE;
 41   putch_msg.PROC_NR  = 0;
 42   putch_msg.TTY_LINE = 0;
 43   putch_msg.ADDRESS  = print_buf;
 44   putch_msg.COUNT = buf_count;
 45   sendrec(TTY, &putch_msg);
 46   buf_count = 0;
 47 }
 48 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.