switch-coreboot/lib/console.c
Stefan Reinauer 25ebd9110b * start using arch/foo.h again instead of archfoo.h (trivial)
* make constructor an initializer.
* fix memory leak/code flow error in current code
* add spinlocking
* drop malloc and use new_device for device allocation instead.
* add CONFIG_SMP as it is needed by spinlocks and soon other stuff.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@418 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-06-29 16:57:23 +00:00

69 lines
1.2 KiB
C

#include <types.h>
#include <hlt.h>
#include <console.h>
#include <uart8250.h>
#include <stdarg.h>
int vtxprintf(void (*)(unsigned char, void *arg),
void *arg, const char *, va_list);
static int console_loglevel(void)
{
return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
}
void console_tx_byte(unsigned char byte, void *arg)
{
if (byte == '\n') {
uart8250_tx_byte(TTYSx_BASE, '\r');
#if defined(CONFIG_CONSOLE_PREFIX) && (CONFIG_CONSOLE_PREFIX == 1)
uart8250_tx_byte(TTYSx_BASE, '\n');
uart8250_tx_byte(TTYSx_BASE, '(');
uart8250_tx_byte(TTYSx_BASE, 'L');
uart8250_tx_byte(TTYSx_BASE, 'B');
uart8250_tx_byte(TTYSx_BASE, ')');
uart8250_tx_byte(TTYSx_BASE, ' ');
return;
#endif
}
uart8250_tx_byte(TTYSx_BASE, byte);
}
int printk(int msg_level, const char *fmt, ...)
{
va_list args;
int i;
if (msg_level > console_loglevel()) {
return 0;
}
va_start(args, fmt);
i = vtxprintf(console_tx_byte, (void *)0, fmt, args);
va_end(args);
return i;
}
void console_init(void)
{
static const char console_test[] =
"\n\nLinuxBIOS-"
LINUXBIOS_VERSION
LINUXBIOS_EXTRA_VERSION
" "
LINUXBIOS_BUILD
" starting...\n";
printk(BIOS_INFO, console_test);
}
void die(const char *str)
{
printk(BIOS_EMERG, str);
do {
hlt();
} while (1);
}