- Implement support for structures, typedefs, and __builtin_rdmsr, __builtin_wrmsr...
[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 #ifndef lint
9 static char rcsid[] = "$Id$";
10 #endif
11
12 //typedef void * va_list;
13
14 #include <stdarg.h>
15 #include <smp/spinlock.h>
16 #include <console/console.h>
17
18 /* printk's without a loglevel use this.. */
19 #define DEFAULT_MESSAGE_LOGLEVEL 4 /* BIOS_WARNING */
20
21 /* We show everything that is MORE important than this.. */
22 #define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
23
24 /* Keep together for sysctl support */
25
26 int console_loglevel = DEFAULT_CONSOLE_LOGLEVEL;
27 int default_message_loglevel = DEFAULT_MESSAGE_LOGLEVEL;
28 int minimum_console_loglevel = MINIMUM_CONSOLE_LOGLEVEL;
29 int default_console_loglevel = DEFAULT_CONSOLE_LOGLEVEL;
30
31 void display(char*);
32 extern int vtxprintf(void (*)(unsigned char), const char *, va_list);
33
34 spinlock_t console_lock = SPIN_LOCK_UNLOCKED;
35
36 int do_printk(int msg_level, const char *fmt, ...)
37 {
38         va_list args;
39         int i;
40
41         if (msg_level >= console_loglevel) {
42                 return 0;
43         }
44
45         spin_lock(&console_lock);
46
47         va_start(args, fmt);
48         i = vtxprintf(console_tx_byte, fmt, args);
49         va_end(args);
50
51         console_tx_flush();
52
53         spin_unlock(&console_lock);
54
55         return i;
56 }