2003-04-22 21:02:15 +02:00
|
|
|
/*
|
2013-07-09 00:22:54 +02:00
|
|
|
* blatantly copied from linux/kernel/printk.c
|
2003-04-22 21:02:15 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <console/console.h>
|
2014-02-27 18:30:18 +01:00
|
|
|
#include <console/streams.h>
|
2014-06-17 10:37:08 +02:00
|
|
|
#include <console/vtxprintf.h>
|
|
|
|
#include <smp/spinlock.h>
|
|
|
|
#include <smp/node.h>
|
|
|
|
#include <stddef.h>
|
2011-09-02 23:23:41 +02:00
|
|
|
#include <trace.h>
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2009-11-12 17:38:03 +01:00
|
|
|
DECLARE_SPIN_LOCK(console_lock)
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2014-02-04 18:03:57 +01:00
|
|
|
void do_putchar(unsigned char byte)
|
|
|
|
{
|
|
|
|
console_tx_byte(byte);
|
|
|
|
}
|
|
|
|
|
2014-02-04 18:50:07 +01:00
|
|
|
static void wrap_putchar(unsigned char byte, void *data)
|
2014-02-04 13:28:17 +01:00
|
|
|
{
|
|
|
|
do_putchar(byte);
|
|
|
|
}
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
int do_printk(int msg_level, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
int i;
|
|
|
|
|
2014-02-28 13:37:27 +01:00
|
|
|
if (!console_log_level(msg_level))
|
2003-04-22 21:02:15 +02:00
|
|
|
return 0;
|
|
|
|
|
2014-06-17 10:37:08 +02:00
|
|
|
#if IS_ENABLED (CONFIG_SQUELCH_EARLY_SMP) && defined(__PRE_RAM__)
|
2014-01-27 14:09:13 +01:00
|
|
|
if (!boot_cpu())
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
2011-09-02 23:23:41 +02:00
|
|
|
DISABLE_TRACE;
|
2003-04-22 21:02:15 +02:00
|
|
|
spin_lock(&console_lock);
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
2014-02-04 13:28:17 +01:00
|
|
|
i = vtxprintf(wrap_putchar, fmt, args, NULL);
|
2003-04-22 21:02:15 +02:00
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
console_tx_flush();
|
|
|
|
|
|
|
|
spin_unlock(&console_lock);
|
2011-09-02 23:23:41 +02:00
|
|
|
ENABLE_TRACE;
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2014-03-06 15:55:05 +01:00
|
|
|
|
2014-06-17 10:37:08 +02:00
|
|
|
#if IS_ENABLED (CONFIG_CHROMEOS)
|
2014-03-06 15:55:05 +01:00
|
|
|
void do_vtxprintf(const char *fmt, va_list args)
|
|
|
|
{
|
2014-02-04 13:28:17 +01:00
|
|
|
vtxprintf(wrap_putchar, fmt, args, NULL);
|
2014-03-06 15:55:05 +01:00
|
|
|
console_tx_flush();
|
|
|
|
}
|
2014-06-17 10:37:08 +02:00
|
|
|
#endif /* CONFIG_CHROMEOS */
|