Increase CBMEM to accommodate larger console.
[coreboot.git] / src / console / printk.c
1 /*
2  *  blantantly copied from linux/kernel/printk.c
3  *
4  *  Copyright (C) 1991, 1992  Linus Torvalds
5  *
6  */
7
8 #include <smp/spinlock.h>
9 #include <console/vtxprintf.h>
10 #include <console/console.h>
11 #include <trace.h>
12
13 int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
14 int default_console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
15
16 DECLARE_SPIN_LOCK(console_lock)
17
18 int do_printk(int msg_level, const char *fmt, ...)
19 {
20         va_list args;
21         int i;
22
23         if (msg_level > console_loglevel) {
24                 return 0;
25         }
26
27         DISABLE_TRACE;
28         spin_lock(&console_lock);
29
30         va_start(args, fmt);
31         i = vtxprintf(console_tx_byte, fmt, args);
32         va_end(args);
33
34         console_tx_flush();
35
36         spin_unlock(&console_lock);
37         ENABLE_TRACE;
38
39         return i;
40 }