2 * polling mode stateless debugging stuff, originally for NS16550 Serial Ports
4 * c 2001 PPC 64 Team, IBM Corp
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
13 #define WANT_PPCDBG_TAB /* Only defined here */
14 #include <linux/config.h>
15 #include <linux/types.h>
16 #include <linux/sched.h>
17 #include <linux/console.h>
18 #include <asm/ppcdebug.h>
19 #include <asm/processor.h>
21 void (*udbg_putc)(unsigned char c);
22 unsigned char (*udbg_getc)(void);
23 int (*udbg_getc_poll)(void);
25 /* udbg library, used by xmon et al */
26 void udbg_puts(const char *s)
31 if (s && *s != '\0') {
32 while ((c = *s++) != '\0')
43 int udbg_write(const char *s, int n)
51 if (s && *s != '\0') {
52 while (((c = *s++) != '\0') && (remain-- > 0)) {
60 int udbg_read(char *buf, int buflen)
68 for (i = 0; i < buflen; ++i) {
71 } while (c == 0x11 || c == 0x13);
80 #define UDBG_BUFSIZE 256
81 void udbg_printf(const char *fmt, ...)
83 unsigned char buf[UDBG_BUFSIZE];
87 vsnprintf(buf, UDBG_BUFSIZE, fmt, args);
94 u64 ppc64_debug_switch;
96 /* Special print used by PPCDBG() macro */
97 void udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
99 unsigned long active_debugs = debug_flags & ppc64_debug_switch;
103 unsigned char buf[UDBG_BUFSIZE];
104 unsigned long i, len = 0;
106 for (i=0; i < PPCDBG_NUM_FLAGS; i++) {
107 if (((1U << i) & active_debugs) &&
109 len += strlen(trace_names[i]);
110 udbg_puts(trace_names[i]);
115 snprintf(buf, UDBG_BUFSIZE, " [%s]: ", current->comm);
125 vsnprintf(buf, UDBG_BUFSIZE, fmt, ap);
131 unsigned long udbg_ifdebug(unsigned long flags)
133 return (flags & ppc64_debug_switch);
137 * Initialize the PPCDBG state. Called before relocation has been enabled.
139 void __init ppcdbg_initialize(void)
141 ppc64_debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | */
142 /* PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */;
146 * Early boot console based on udbg
148 static void udbg_console_write(struct console *con, const char *s,
154 static struct console udbg_console = {
156 .write = udbg_console_write,
157 .flags = CON_PRINTBUFFER,
161 static int early_console_initialized;
163 void __init disable_early_printk(void)
165 if (!early_console_initialized)
167 unregister_console(&udbg_console);
168 early_console_initialized = 0;
171 /* called by setup_system */
172 void register_early_udbg_console(void)
174 early_console_initialized = 1;
175 register_console(&udbg_console);
178 #if 0 /* if you want to use this as a regular output console */
179 console_initcall(register_udbg_console);