source: trunk/minix/kernel/kprintf.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.8 KB
Line 
1/*
2 * printf for the kernel
3 *
4 * Changes:
5 * Dec 10, 2004 kernel printing to circular buffer (Jorrit N. Herder)
6 *
7 * This file contains the routines that take care of kernel messages, i.e.,
8 * diagnostic output within the kernel. Kernel messages are not directly
9 * displayed on the console, because this must be done by the output driver.
10 * Instead, the kernel accumulates characters in a buffer and notifies the
11 * output driver when a new message is ready.
12 */
13
14#include "kernel.h"
15#include "proc.h"
16#include <signal.h>
17
18#define printf kprintf
19
20#include "../lib/sysutil/kprintf.c"
21
22#define END_OF_KMESS 0
23FORWARD _PROTOTYPE( void ser_putc, (char c));
24
25/*===========================================================================*
26 * kputc *
27 *===========================================================================*/
28PUBLIC void kputc(c)
29int c; /* character to append */
30{
31/* Accumulate a single character for a kernel message. Send a notification
32 * to the output driver if an END_OF_KMESS is encountered.
33 */
34 if (c != END_OF_KMESS) {
35 if (do_serial_debug)
36 ser_putc(c);
37 kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */
38 if (kmess.km_size < KMESS_BUF_SIZE)
39 kmess.km_size += 1;
40 kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE;
41 } else {
42 int p, outprocs[] = OUTPUT_PROCS_ARRAY;
43 for(p = 0; outprocs[p] != NONE; p++) {
44 if(isokprocn(outprocs[p]) && !isemptyn(outprocs[p])) {
45 send_sig(outprocs[p], SIGKMESS);
46 }
47 }
48 }
49}
50
51#define COM1_BASE 0x3F8
52#define COM1_THR (COM1_BASE + 0)
53#define LSR_THRE 0x20
54#define COM1_LSR (COM1_BASE + 5)
55
56PRIVATE void ser_putc(char c)
57{
58 int i;
59 int lsr, thr;
60
61 return;
62
63 lsr= COM1_LSR;
64 thr= COM1_THR;
65 for (i= 0; i<100000; i++)
66 {
67 if (inb(lsr) & LSR_THRE)
68 break;
69 }
70 outb(thr, c);
71}
Note: See TracBrowser for help on using the repository browser.