CMOS: Add set_option and rework get_option.
[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 <stdarg.h>
9 #include <smp/spinlock.h>
10 #include <console/console.h>
11
12 /* Keep together for sysctl support */
13
14 unsigned int console_loglevel = DEFAULT_CONSOLE_LOGLEVEL;
15
16 void display(char*);
17 extern int vtxprintf(void (*)(unsigned char), const char *, va_list);
18
19 static spinlock_t console_lock = SPIN_LOCK_UNLOCKED;
20
21 int do_printk(int msg_level, const char *fmt, ...)
22 {
23         va_list args;
24         int i;
25
26         if (msg_level >= console_loglevel) {
27                 return 0;
28         }
29
30         spin_lock(&console_lock);
31
32         va_start(args, fmt);
33         i = vtxprintf(console_tx_byte, fmt, args);
34         va_end(args);
35
36         console_tx_flush();
37
38         spin_unlock(&console_lock);
39
40         return i;
41 }