Commit d634f194d4e2e58d57927c812aca097e67a2287d
Committed by
Linus Torvalds
1 parent
2525e70d49
Exists in
master
and in
7 other branches
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>
Showing 5 changed files with 50 additions and 0 deletions Side-by-side Diff
arch/um/Kconfig.debug
... | ... | @@ -37,5 +37,15 @@ |
37 | 37 | stack seen so far. |
38 | 38 | |
39 | 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 | 50 | endmenu |
arch/um/include/shared/os.h
... | ... | @@ -244,6 +244,7 @@ |
244 | 244 | extern void setup_machinename(char *machine_out); |
245 | 245 | extern void setup_hostinfo(char *buf, int len); |
246 | 246 | extern void os_dump_core(void) __attribute__ ((noreturn)); |
247 | +extern void um_early_printk(const char *s, unsigned int n); | |
247 | 248 | |
248 | 249 | /* time.c */ |
249 | 250 | extern void idle_sleep(unsigned long long nsecs); |
arch/um/kernel/Makefile
arch/um/kernel/early_printk.c
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); |