diff options
Diffstat (limited to 'arch/powerpc/kernel/udbg.c')
-rw-r--r-- | arch/powerpc/kernel/udbg.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c index 0d878e72fc4..3774e80094f 100644 --- a/arch/powerpc/kernel/udbg.c +++ b/arch/powerpc/kernel/udbg.c | |||
@@ -15,11 +15,36 @@ | |||
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/console.h> | 16 | #include <linux/console.h> |
17 | #include <asm/processor.h> | 17 | #include <asm/processor.h> |
18 | #include <asm/udbg.h> | ||
18 | 19 | ||
19 | void (*udbg_putc)(unsigned char c); | 20 | void (*udbg_putc)(char c); |
20 | unsigned char (*udbg_getc)(void); | 21 | int (*udbg_getc)(void); |
21 | int (*udbg_getc_poll)(void); | 22 | int (*udbg_getc_poll)(void); |
22 | 23 | ||
24 | /* | ||
25 | * Early debugging facilities. You can enable _one_ of these via .config, | ||
26 | * if you do so your kernel _will not boot_ on anything else. Be careful. | ||
27 | */ | ||
28 | void __init udbg_early_init(void) | ||
29 | { | ||
30 | #if defined(CONFIG_PPC_EARLY_DEBUG_LPAR) | ||
31 | /* For LPAR machines that have an HVC console on vterm 0 */ | ||
32 | udbg_init_debug_lpar(); | ||
33 | #elif defined(CONFIG_PPC_EARLY_DEBUG_G5) | ||
34 | /* For use on Apple G5 machines */ | ||
35 | udbg_init_pmac_realmode(); | ||
36 | #elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS) | ||
37 | /* RTAS panel debug */ | ||
38 | udbg_init_rtas(); | ||
39 | #elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE) | ||
40 | /* Maple real mode debug */ | ||
41 | udbg_init_maple_realmode(); | ||
42 | #elif defined(CONFIG_PPC_EARLY_DEBUG_ISERIES) | ||
43 | /* For iSeries - hit Ctrl-x Ctrl-x to see the output */ | ||
44 | udbg_init_iseries(); | ||
45 | #endif | ||
46 | } | ||
47 | |||
23 | /* udbg library, used by xmon et al */ | 48 | /* udbg library, used by xmon et al */ |
24 | void udbg_puts(const char *s) | 49 | void udbg_puts(const char *s) |
25 | { | 50 | { |
@@ -57,8 +82,8 @@ int udbg_write(const char *s, int n) | |||
57 | 82 | ||
58 | int udbg_read(char *buf, int buflen) | 83 | int udbg_read(char *buf, int buflen) |
59 | { | 84 | { |
60 | char c, *p = buf; | 85 | char *p = buf; |
61 | int i; | 86 | int i, c; |
62 | 87 | ||
63 | if (!udbg_getc) | 88 | if (!udbg_getc) |
64 | return 0; | 89 | return 0; |
@@ -66,8 +91,11 @@ int udbg_read(char *buf, int buflen) | |||
66 | for (i = 0; i < buflen; ++i) { | 91 | for (i = 0; i < buflen; ++i) { |
67 | do { | 92 | do { |
68 | c = udbg_getc(); | 93 | c = udbg_getc(); |
94 | if (c == -1 && i == 0) | ||
95 | return -1; | ||
96 | |||
69 | } while (c == 0x11 || c == 0x13); | 97 | } while (c == 0x11 || c == 0x13); |
70 | if (c == 0) | 98 | if (c == 0 || c == -1) |
71 | break; | 99 | break; |
72 | *p++ = c; | 100 | *p++ = c; |
73 | } | 101 | } |
@@ -78,7 +106,7 @@ int udbg_read(char *buf, int buflen) | |||
78 | #define UDBG_BUFSIZE 256 | 106 | #define UDBG_BUFSIZE 256 |
79 | void udbg_printf(const char *fmt, ...) | 107 | void udbg_printf(const char *fmt, ...) |
80 | { | 108 | { |
81 | unsigned char buf[UDBG_BUFSIZE]; | 109 | char buf[UDBG_BUFSIZE]; |
82 | va_list args; | 110 | va_list args; |
83 | 111 | ||
84 | va_start(args, fmt); | 112 | va_start(args, fmt); |
@@ -87,6 +115,12 @@ void udbg_printf(const char *fmt, ...) | |||
87 | va_end(args); | 115 | va_end(args); |
88 | } | 116 | } |
89 | 117 | ||
118 | void __init udbg_progress(char *s, unsigned short hex) | ||
119 | { | ||
120 | udbg_puts(s); | ||
121 | udbg_puts("\n"); | ||
122 | } | ||
123 | |||
90 | /* | 124 | /* |
91 | * Early boot console based on udbg | 125 | * Early boot console based on udbg |
92 | */ | 126 | */ |
@@ -99,7 +133,7 @@ static void udbg_console_write(struct console *con, const char *s, | |||
99 | static struct console udbg_console = { | 133 | static struct console udbg_console = { |
100 | .name = "udbg", | 134 | .name = "udbg", |
101 | .write = udbg_console_write, | 135 | .write = udbg_console_write, |
102 | .flags = CON_PRINTBUFFER, | 136 | .flags = CON_PRINTBUFFER | CON_ENABLED, |
103 | .index = -1, | 137 | .index = -1, |
104 | }; | 138 | }; |
105 | 139 | ||
@@ -107,15 +141,19 @@ static int early_console_initialized; | |||
107 | 141 | ||
108 | void __init disable_early_printk(void) | 142 | void __init disable_early_printk(void) |
109 | { | 143 | { |
144 | #if 1 | ||
110 | if (!early_console_initialized) | 145 | if (!early_console_initialized) |
111 | return; | 146 | return; |
112 | unregister_console(&udbg_console); | 147 | unregister_console(&udbg_console); |
113 | early_console_initialized = 0; | 148 | early_console_initialized = 0; |
149 | #endif | ||
114 | } | 150 | } |
115 | 151 | ||
116 | /* called by setup_system */ | 152 | /* called by setup_system */ |
117 | void register_early_udbg_console(void) | 153 | void register_early_udbg_console(void) |
118 | { | 154 | { |
155 | if (early_console_initialized) | ||
156 | return; | ||
119 | early_console_initialized = 1; | 157 | early_console_initialized = 1; |
120 | register_console(&udbg_console); | 158 | register_console(&udbg_console); |
121 | } | 159 | } |