diff options
author | Richard Weinberger <richard@nod.at> | 2011-05-24 20:13:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-25 11:39:41 -0400 |
commit | d634f194d4e2e58d57927c812aca097e67a2287d (patch) | |
tree | ca17ff43725293ea0bda7a7d7e8ed23ad4f89e14 /arch/um | |
parent | 2525e70d492f8c7bbe1292db8fcd973607a56ac6 (diff) |
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>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/Kconfig.debug | 10 | ||||
-rw-r--r-- | arch/um/include/shared/os.h | 1 | ||||
-rw-r--r-- | arch/um/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/um/kernel/early_printk.c | 33 | ||||
-rw-r--r-- | arch/um/os-Linux/util.c | 5 |
5 files changed, 50 insertions, 0 deletions
diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug index 8fce5e536b0f..85c86edd1e67 100644 --- a/arch/um/Kconfig.debug +++ b/arch/um/Kconfig.debug | |||
@@ -37,4 +37,14 @@ config DEBUG_STACK_USAGE | |||
37 | stack seen so far. | 37 | stack seen so far. |
38 | 38 | ||
39 | This option will slow down process creation and destruction somewhat. | 39 | This option will slow down process creation and destruction somewhat. |
40 | |||
41 | config EARLY_PRINTK | ||
42 | bool "Early printk" | ||
43 | default y | ||
44 | ---help--- | ||
45 | Write kernel log output directly to stdout. | ||
46 | |||
47 | This is useful for kernel debugging when your machine crashes very | ||
48 | early before the console code is initialized. | ||
49 | |||
40 | endmenu | 50 | endmenu |
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index f06a5da71a8f..83c7c2ecd614 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h | |||
@@ -244,6 +244,7 @@ extern int raw(int fd); | |||
244 | extern void setup_machinename(char *machine_out); | 244 | extern void setup_machinename(char *machine_out); |
245 | extern void setup_hostinfo(char *buf, int len); | 245 | extern void setup_hostinfo(char *buf, int len); |
246 | extern void os_dump_core(void) __attribute__ ((noreturn)); | 246 | extern void os_dump_core(void) __attribute__ ((noreturn)); |
247 | extern void um_early_printk(const char *s, unsigned int n); | ||
247 | 248 | ||
248 | /* time.c */ | 249 | /* time.c */ |
249 | extern void idle_sleep(unsigned long long nsecs); | 250 | extern void idle_sleep(unsigned long long nsecs); |
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 1119233597a1..c4491c15afb2 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
@@ -17,6 +17,7 @@ obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \ | |||
17 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o | 17 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o |
18 | obj-$(CONFIG_GPROF) += gprof_syms.o | 18 | obj-$(CONFIG_GPROF) += gprof_syms.o |
19 | obj-$(CONFIG_GCOV) += gmon_syms.o | 19 | obj-$(CONFIG_GCOV) += gmon_syms.o |
20 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | ||
20 | 21 | ||
21 | USER_OBJS := config.o | 22 | USER_OBJS := config.o |
22 | 23 | ||
diff --git a/arch/um/kernel/early_printk.c b/arch/um/kernel/early_printk.c new file mode 100644 index 000000000000..ec649bf72f68 --- /dev/null +++ b/arch/um/kernel/early_printk.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Richard Weinberger <richrd@nod.at> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/console.h> | ||
11 | #include <linux/init.h> | ||
12 | #include "os.h" | ||
13 | |||
14 | static void early_console_write(struct console *con, const char *s, unsigned int n) | ||
15 | { | ||
16 | um_early_printk(s, n); | ||
17 | } | ||
18 | |||
19 | static struct console early_console = { | ||
20 | .name = "earlycon", | ||
21 | .write = early_console_write, | ||
22 | .flags = CON_BOOT, | ||
23 | .index = -1, | ||
24 | }; | ||
25 | |||
26 | static int __init setup_early_printk(char *buf) | ||
27 | { | ||
28 | register_console(&early_console); | ||
29 | |||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | early_param("earlyprintk", setup_early_printk); | ||
diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c index 42827cafa6af..5803b1887672 100644 --- a/arch/um/os-Linux/util.c +++ b/arch/um/os-Linux/util.c | |||
@@ -139,3 +139,8 @@ void os_dump_core(void) | |||
139 | 139 | ||
140 | uml_abort(); | 140 | uml_abort(); |
141 | } | 141 | } |
142 | |||
143 | void um_early_printk(const char *s, unsigned int n) | ||
144 | { | ||
145 | printf("%.*s", n, s); | ||
146 | } | ||