um: add earlyprintk support
User Mode Linux can also benefit from earlyprintk. UML's earlyprintk writes kernel messages directly to stdout. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
2525e70d49
Коммит
d634f194d4
|
@ -37,4 +37,14 @@ config DEBUG_STACK_USAGE
|
||||||
stack seen so far.
|
stack seen so far.
|
||||||
|
|
||||||
This option will slow down process creation and destruction somewhat.
|
This option will slow down process creation and destruction somewhat.
|
||||||
|
|
||||||
|
config EARLY_PRINTK
|
||||||
|
bool "Early printk"
|
||||||
|
default y
|
||||||
|
---help---
|
||||||
|
Write kernel log output directly to stdout.
|
||||||
|
|
||||||
|
This is useful for kernel debugging when your machine crashes very
|
||||||
|
early before the console code is initialized.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -244,6 +244,7 @@ extern int raw(int fd);
|
||||||
extern void setup_machinename(char *machine_out);
|
extern void setup_machinename(char *machine_out);
|
||||||
extern void setup_hostinfo(char *buf, int len);
|
extern void setup_hostinfo(char *buf, int len);
|
||||||
extern void os_dump_core(void) __attribute__ ((noreturn));
|
extern void os_dump_core(void) __attribute__ ((noreturn));
|
||||||
|
extern void um_early_printk(const char *s, unsigned int n);
|
||||||
|
|
||||||
/* time.c */
|
/* time.c */
|
||||||
extern void idle_sleep(unsigned long long nsecs);
|
extern void idle_sleep(unsigned long long nsecs);
|
||||||
|
|
|
@ -17,6 +17,7 @@ obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
|
||||||
obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
|
obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
|
||||||
obj-$(CONFIG_GPROF) += gprof_syms.o
|
obj-$(CONFIG_GPROF) += gprof_syms.o
|
||||||
obj-$(CONFIG_GCOV) += gmon_syms.o
|
obj-$(CONFIG_GCOV) += gmon_syms.o
|
||||||
|
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
|
||||||
|
|
||||||
USER_OBJS := config.o
|
USER_OBJS := config.o
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/console.h>
|
||||||
|
#include <linux/init.h>
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
|
static void early_console_write(struct console *con, const char *s, unsigned int n)
|
||||||
|
{
|
||||||
|
um_early_printk(s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct console early_console = {
|
||||||
|
.name = "earlycon",
|
||||||
|
.write = early_console_write,
|
||||||
|
.flags = CON_BOOT,
|
||||||
|
.index = -1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int __init setup_early_printk(char *buf)
|
||||||
|
{
|
||||||
|
register_console(&early_console);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
early_param("earlyprintk", setup_early_printk);
|
|
@ -139,3 +139,8 @@ void os_dump_core(void)
|
||||||
|
|
||||||
uml_abort();
|
uml_abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void um_early_printk(const char *s, unsigned int n)
|
||||||
|
{
|
||||||
|
printf("%.*s", n, s);
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче