98d78b3fc4aea24a0ee583689a49dee5df5db020
[coreboot.git] / src / arch / ppc / lib / printk_init.c
1 /*
2  *  blantantly copied from linux/kernel/printk.c
3  *
4  *  Copyright (C) 1991, 1992  Linus Torvalds
5  *
6  */
7 #include <stdarg.h>
8 #include <console/loglevel.h>
9
10 /* printk's without a loglevel use this.. */
11 #define DEFAULT_MESSAGE_LOGLEVEL 4 /* BIOS_WARNING */
12
13 /* Keep together for sysctl support */
14
15 int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
16
17 extern int vtxprintf(void (*)(unsigned char), const char *, va_list);
18 extern void uart8250_tx_byte(unsigned, unsigned char);
19
20 void console_tx_byte(unsigned char byte)
21 {
22         if (byte == '\n')
23                 uart8250_tx_byte(CONFIG_TTYS0_BASE, '\r');
24         uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
25 }
26
27 int do_printk(int msg_level, const char *fmt, ...)
28 {
29         va_list args;
30         int i;
31
32         if (msg_level >= console_loglevel) {
33                 return 0;
34         }
35
36         va_start(args, fmt);
37         i = vtxprintf(console_tx_byte, fmt, args);
38         va_end(args);
39
40         return i;
41 }