Commit | Line | Data |
---|---|---|
867e359b CM |
1 | /* |
2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | |
3 | * | |
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. | |
7 | * | |
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 | |
12 | * more details. | |
13 | */ | |
14 | ||
15 | #include <linux/console.h> | |
16 | #include <linux/kernel.h> | |
17 | #include <linux/init.h> | |
18 | #include <linux/string.h> | |
bd119c69 | 19 | #include <linux/irqflags.h> |
d0380e6c | 20 | #include <linux/printk.h> |
867e359b CM |
21 | #include <asm/setup.h> |
22 | #include <hv/hypervisor.h> | |
23 | ||
24 | static void early_hv_write(struct console *con, const char *s, unsigned n) | |
25 | { | |
bda0f5ba CM |
26 | tile_console_write(s, n); |
27 | ||
28 | /* | |
29 | * Convert NL to NLCR (close enough to CRNL) during early boot. | |
30 | * We assume newlines are at the ends of strings, which turns out | |
31 | * to be good enough for early boot console output. | |
32 | */ | |
33 | if (n && s[n-1] == '\n') | |
34 | tile_console_write("\r", 1); | |
867e359b CM |
35 | } |
36 | ||
37 | static struct console early_hv_console = { | |
38 | .name = "earlyhv", | |
39 | .write = early_hv_write, | |
bda0f5ba | 40 | .flags = CON_PRINTBUFFER | CON_BOOT, |
867e359b CM |
41 | .index = -1, |
42 | }; | |
43 | ||
867e359b CM |
44 | void early_panic(const char *fmt, ...) |
45 | { | |
1dc6244b JP |
46 | struct va_format vaf; |
47 | va_list args; | |
48 | ||
5d966115 | 49 | arch_local_irq_disable_all(); |
1dc6244b JP |
50 | |
51 | va_start(args, fmt); | |
52 | ||
53 | vaf.fmt = fmt; | |
54 | vaf.va = &args; | |
55 | ||
56 | early_printk("Kernel panic - not syncing: %pV", &vaf); | |
57 | ||
58 | va_end(args); | |
59 | ||
867e359b CM |
60 | dump_stack(); |
61 | hv_halt(); | |
62 | } | |
63 | ||
867e359b CM |
64 | static int __init setup_early_printk(char *str) |
65 | { | |
d0380e6c | 66 | if (early_console) |
867e359b CM |
67 | return 1; |
68 | ||
867e359b | 69 | early_console = &early_hv_console; |
867e359b CM |
70 | register_console(early_console); |
71 | ||
72 | return 0; | |
73 | } | |
74 | ||
867e359b | 75 | early_param("earlyprintk", setup_early_printk); |