blob: 488d4e5ca39b951a814d92489093d79ae13f8aa2 [file] [log] [blame]
Eric Biederman8ca8d762003-04-22 19:02:15 +00001/*
2 * blantantly copied from linux/kernel/printk.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 */
Eric Biederman8ca8d762003-04-22 19:02:15 +00007
Eric Biederman8ca8d762003-04-22 19:02:15 +00008#include <smp/spinlock.h>
Stefan Reinauer52fc6b12009-10-24 13:06:04 +00009#include <console/vtxprintf.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000010#include <console/console.h>
11
Stefan Reinauer08670622009-06-30 15:17:49 +000012int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
Stefan Reinauer08670622009-06-30 15:17:49 +000013int default_console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
Eric Biederman8ca8d762003-04-22 19:02:15 +000014
Myles Watson2e672732009-11-12 16:38:03 +000015DECLARE_SPIN_LOCK(console_lock)
Eric Biederman8ca8d762003-04-22 19:02:15 +000016
17int do_printk(int msg_level, const char *fmt, ...)
18{
19 va_list args;
20 int i;
21
Myles Watson03646182009-10-16 19:29:45 +000022 if (msg_level > console_loglevel) {
Eric Biederman8ca8d762003-04-22 19:02:15 +000023 return 0;
24 }
25
26 spin_lock(&console_lock);
27
28 va_start(args, fmt);
29 i = vtxprintf(console_tx_byte, fmt, args);
30 va_end(args);
31
32 console_tx_flush();
33
34 spin_unlock(&console_lock);
35
36 return i;
37}