2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
15 #include <linux/console.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/string.h>
19 #include <asm/setup.h>
20 #include <hv/hypervisor.h>
22 static void early_hv_write(struct console
*con
, const char *s
, unsigned n
)
24 hv_console_write((HV_VirtAddr
) s
, n
);
27 static struct console early_hv_console
= {
29 .write
= early_hv_write
,
30 .flags
= CON_PRINTBUFFER
,
34 /* Direct interface for emergencies */
35 static struct console
*early_console
= &early_hv_console
;
36 static int early_console_initialized
;
37 static int early_console_complete
;
39 static void early_vprintk(const char *fmt
, va_list ap
)
42 int n
= vscnprintf(buf
, sizeof(buf
), fmt
, ap
);
43 early_console
->write(early_console
, buf
, n
);
46 void early_printk(const char *fmt
, ...)
50 early_vprintk(fmt
, ap
);
54 void early_panic(const char *fmt
, ...)
57 arch_local_irq_disable_all();
59 early_printk("Kernel panic - not syncing: ");
60 early_vprintk(fmt
, ap
);
61 early_console
->write(early_console
, "\n", 1);
67 static int __initdata keep_early
;
69 static int __init
setup_early_printk(char *str
)
71 if (early_console_initialized
)
74 if (str
!= NULL
&& strncmp(str
, "keep", 4) == 0)
77 early_console
= &early_hv_console
;
78 early_console_initialized
= 1;
79 register_console(early_console
);
84 void __init
disable_early_printk(void)
86 early_console_complete
= 1;
87 if (!early_console_initialized
|| !early_console
)
90 early_printk("disabling early console\n");
91 unregister_console(early_console
);
92 early_console_initialized
= 0;
94 early_printk("keeping early console\n");
98 void warn_early_printk(void)
100 if (early_console_complete
|| early_console_initialized
)
103 Machine shutting down before console output is fully initialized.\n\
104 You may wish to reboot and add the option 'earlyprintk' to your\n\
105 boot command line to see any diagnostic early console output.\n\
109 early_param("earlyprintk", setup_early_printk
);