Commit 8d9273918635f0301368c01b56c03a6f339e8d51
Committed by
Paul Mackerras
1 parent
188d2ce78f
Exists in
master
and in
4 other branches
[PATCH] ppc64: Consolidate early console and PPCDBG code
Consolidate the early console and PPCDBG code in udbg.c Signed-off-by: Milton Miller <miltonm@bga.com> Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Showing 3 changed files with 50 additions and 39 deletions Side-by-side Diff
arch/ppc64/kernel/setup.c
| ... | ... | @@ -108,7 +108,6 @@ |
| 108 | 108 | int boot_cpuid_phys = 0; |
| 109 | 109 | dev_t boot_dev; |
| 110 | 110 | u64 ppc64_pft_size; |
| 111 | -u64 ppc64_debug_switch; | |
| 112 | 111 | |
| 113 | 112 | struct ppc64_caches ppc64_caches; |
| 114 | 113 | EXPORT_SYMBOL_GPL(ppc64_caches); |
| ... | ... | @@ -154,34 +153,6 @@ |
| 154 | 153 | .orig_video_points = 16 |
| 155 | 154 | }; |
| 156 | 155 | |
| 157 | -/* | |
| 158 | - * Initialize the PPCDBG state. Called before relocation has been enabled. | |
| 159 | - */ | |
| 160 | -void __init ppcdbg_initialize(void) | |
| 161 | -{ | |
| 162 | - ppc64_debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | */ | |
| 163 | - /* PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */; | |
| 164 | -} | |
| 165 | - | |
| 166 | -/* | |
| 167 | - * Early boot console based on udbg | |
| 168 | - */ | |
| 169 | -static struct console udbg_console = { | |
| 170 | - .name = "udbg", | |
| 171 | - .write = udbg_console_write, | |
| 172 | - .flags = CON_PRINTBUFFER, | |
| 173 | - .index = -1, | |
| 174 | -}; | |
| 175 | -static int early_console_initialized; | |
| 176 | - | |
| 177 | -void __init disable_early_printk(void) | |
| 178 | -{ | |
| 179 | - if (!early_console_initialized) | |
| 180 | - return; | |
| 181 | - unregister_console(&udbg_console); | |
| 182 | - early_console_initialized = 0; | |
| 183 | -} | |
| 184 | - | |
| 185 | 156 | #if defined(CONFIG_PPC_MULTIPLATFORM) && defined(CONFIG_SMP) |
| 186 | 157 | |
| 187 | 158 | static int smt_enabled_cmdline; |
| ... | ... | @@ -630,8 +601,7 @@ |
| 630 | 601 | /* |
| 631 | 602 | * Register early console |
| 632 | 603 | */ |
| 633 | - early_console_initialized = 1; | |
| 634 | - register_console(&udbg_console); | |
| 604 | + register_early_udbg_console(); | |
| 635 | 605 | |
| 636 | 606 | /* Save unparsed command line copy for /proc/cmdline */ |
| 637 | 607 | strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE); |
arch/ppc64/kernel/udbg.c
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #include <linux/config.h> |
| 15 | 15 | #include <linux/types.h> |
| 16 | 16 | #include <linux/sched.h> |
| 17 | +#include <linux/console.h> | |
| 17 | 18 | #include <asm/ppcdebug.h> |
| 18 | 19 | #include <asm/processor.h> |
| 19 | 20 | |
| ... | ... | @@ -21,6 +22,7 @@ |
| 21 | 22 | unsigned char (*udbg_getc)(void); |
| 22 | 23 | int (*udbg_getc_poll)(void); |
| 23 | 24 | |
| 25 | +/* udbg library, used by xmon et al */ | |
| 24 | 26 | void udbg_puts(const char *s) |
| 25 | 27 | { |
| 26 | 28 | if (udbg_putc) { |
| ... | ... | @@ -75,11 +77,6 @@ |
| 75 | 77 | return i; |
| 76 | 78 | } |
| 77 | 79 | |
| 78 | -void udbg_console_write(struct console *con, const char *s, unsigned int n) | |
| 79 | -{ | |
| 80 | - udbg_write(s, n); | |
| 81 | -} | |
| 82 | - | |
| 83 | 80 | #define UDBG_BUFSIZE 256 |
| 84 | 81 | void udbg_printf(const char *fmt, ...) |
| 85 | 82 | { |
| ... | ... | @@ -92,6 +89,10 @@ |
| 92 | 89 | va_end(args); |
| 93 | 90 | } |
| 94 | 91 | |
| 92 | +/* PPCDBG stuff */ | |
| 93 | + | |
| 94 | +u64 ppc64_debug_switch; | |
| 95 | + | |
| 95 | 96 | /* Special print used by PPCDBG() macro */ |
| 96 | 97 | void udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...) |
| 97 | 98 | { |
| ... | ... | @@ -131,4 +132,44 @@ |
| 131 | 132 | { |
| 132 | 133 | return (flags & ppc64_debug_switch); |
| 133 | 134 | } |
| 135 | + | |
| 136 | +/* | |
| 137 | + * Initialize the PPCDBG state. Called before relocation has been enabled. | |
| 138 | + */ | |
| 139 | +void __init ppcdbg_initialize(void) | |
| 140 | +{ | |
| 141 | + ppc64_debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | */ | |
| 142 | + /* PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */; | |
| 143 | +} | |
| 144 | + | |
| 145 | +/* | |
| 146 | + * Early boot console based on udbg | |
| 147 | + */ | |
| 148 | +static void udbg_console_write(struct console *con, const char *s, | |
| 149 | + unsigned int n) | |
| 150 | +{ | |
| 151 | + udbg_write(s, n); | |
| 152 | +} | |
| 153 | + | |
| 154 | +static struct console udbg_console = { | |
| 155 | + .name = "udbg", | |
| 156 | + .write = udbg_console_write, | |
| 157 | + .flags = CON_PRINTBUFFER, | |
| 158 | + .index = -1, | |
| 159 | +}; | |
| 160 | + | |
| 161 | +void __init disable_early_printk(void) | |
| 162 | +{ | |
| 163 | + unregister_console(&udbg_console); | |
| 164 | +} | |
| 165 | + | |
| 166 | +/* called by setup_system */ | |
| 167 | +void register_early_udbg_console(void) | |
| 168 | +{ | |
| 169 | + register_console(&udbg_console); | |
| 170 | +} | |
| 171 | + | |
| 172 | +#if 0 /* if you want to use this as a regular output console */ | |
| 173 | +console_initcall(register_udbg_console); | |
| 174 | +#endif |
include/asm-ppc64/udbg.h
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | #define __UDBG_HDR |
| 3 | 3 | |
| 4 | 4 | #include <linux/compiler.h> |
| 5 | +#include <linux/init.h> | |
| 5 | 6 | |
| 6 | 7 | /* |
| 7 | 8 | * c 2001 PPC 64 Team, IBM Corp |
| 8 | 9 | |
| ... | ... | @@ -20,12 +21,11 @@ |
| 20 | 21 | extern int udbg_write(const char *s, int n); |
| 21 | 22 | extern int udbg_read(char *buf, int buflen); |
| 22 | 23 | |
| 23 | -struct console; | |
| 24 | -extern void udbg_console_write(struct console *con, const char *s, unsigned int n); | |
| 24 | +extern void register_early_udbg_console(void); | |
| 25 | 25 | extern void udbg_printf(const char *fmt, ...); |
| 26 | 26 | extern void udbg_ppcdbg(unsigned long flags, const char *fmt, ...); |
| 27 | 27 | extern unsigned long udbg_ifdebug(unsigned long flags); |
| 28 | - | |
| 28 | +extern void __init ppcdbg_initialize(void); | |
| 29 | 29 | |
| 30 | 30 | extern void udbg_init_uart(void __iomem *comport, unsigned int speed); |
| 31 | 31 | #endif |