Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Richard Weinberger and committed by
Linus Torvalds
d634f194 2525e70d

+50
+10
arch/um/Kconfig.debug
··· 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
+1
arch/um/include/shared/os.h
··· 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);
+1
arch/um/kernel/Makefile
··· 17 17 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 18 18 obj-$(CONFIG_GPROF) += gprof_syms.o 19 19 obj-$(CONFIG_GCOV) += gmon_syms.o 20 + obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 20 21 21 22 USER_OBJS := config.o 22 23
+33
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);
+5
arch/um/os-Linux/util.c
··· 139 139 140 140 uml_abort(); 141 141 } 142 + 143 + void um_early_printk(const char *s, unsigned int n) 144 + { 145 + printf("%.*s", n, s); 146 + }