Change console code to emit SPEW with DEFAULT_CONSOLE_LOGLEVEL==8.
[coreboot.git] / src / arch / i386 / lib / printk_init.c
1 /*
2  *  blantantly copied from linux/kernel/printk.c
3  *
4  *  Copyright (C) 1991, 1992  Linus Torvalds
5  *
6  *  by yhlu moved from arch/ppc/lib/printk_init.c, removed the global variable console_loglevel
7  */
8 #include <stdarg.h>
9 #include <console/loglevel.h>
10
11 /* printk's without a loglevel use this.. */
12 #define DEFAULT_MESSAGE_LOGLEVEL 4 /* BIOS_WARNING */
13
14 /* Keep together for sysctl support */
15 /* Using an global varible can cause problem when we reset the stack from cache as ram to ram*/
16 #if 0
17 int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
18 #else
19 #define console_loglevel ASM_CONSOLE_LOGLEVEL
20 #endif
21
22 extern int vtxprintf(void (*)(unsigned char), const char *, va_list);
23 extern void uart8250_tx_byte(unsigned, unsigned char);
24
25 void console_tx_byte(unsigned char byte)
26 {
27         if (byte == '\n')
28                 uart8250_tx_byte(CONFIG_TTYS0_BASE, '\r');
29         uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
30 }
31
32 int do_printk(int msg_level, const char *fmt, ...)
33 {
34         va_list args;
35         int i;
36
37         if (msg_level > console_loglevel) {
38                 return 0;
39         }
40
41         va_start(args, fmt);
42         i = vtxprintf(console_tx_byte, fmt, args);
43         va_end(args);
44
45         return i;
46 }