0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/kernel.h>
0009 #include <linux/console.h>
0010 #include <linux/init.h>
0011 #include <linux/string.h>
0012
0013 extern void printascii(const char *);
0014
0015 static void early_write(const char *s, unsigned n)
0016 {
0017 char buf[128];
0018 while (n) {
0019 unsigned l = min(n, sizeof(buf)-1);
0020 memcpy(buf, s, l);
0021 buf[l] = 0;
0022 s += l;
0023 n -= l;
0024 printascii(buf);
0025 }
0026 }
0027
0028 static void early_console_write(struct console *con, const char *s, unsigned n)
0029 {
0030 early_write(s, n);
0031 }
0032
0033 static struct console early_console_dev = {
0034 .name = "earlycon",
0035 .write = early_console_write,
0036 .flags = CON_PRINTBUFFER | CON_BOOT,
0037 .index = -1,
0038 };
0039
0040 static int __init setup_early_printk(char *buf)
0041 {
0042 early_console = &early_console_dev;
0043 register_console(&early_console_dev);
0044 return 0;
0045 }
0046
0047 early_param("earlyprintk", setup_early_printk);