[PATCH] ppc64: Remove old includes
[linux-2.6/mini2440.git] / arch / ppc64 / kernel / udbg.c
blob07164020f3a9aa0e446bb86a346f7d97a5d76a0f
1 /*
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.
12 #include <stdarg.h>
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 <asm/ppcdebug.h>
18 #include <asm/processor.h>
20 void (*udbg_putc)(unsigned char c);
21 unsigned char (*udbg_getc)(void);
22 int (*udbg_getc_poll)(void);
24 void udbg_puts(const char *s)
26 if (udbg_putc) {
27 char c;
29 if (s && *s != '\0') {
30 while ((c = *s++) != '\0')
31 udbg_putc(c);
34 #if 0
35 else {
36 printk("%s", s);
38 #endif
41 int udbg_write(const char *s, int n)
43 int remain = n;
44 char c;
46 if (!udbg_putc)
47 return 0;
49 if (s && *s != '\0') {
50 while (((c = *s++) != '\0') && (remain-- > 0)) {
51 udbg_putc(c);
55 return n - remain;
58 int udbg_read(char *buf, int buflen)
60 char c, *p = buf;
61 int i;
63 if (!udbg_getc)
64 return 0;
66 for (i = 0; i < buflen; ++i) {
67 do {
68 c = udbg_getc();
69 } while (c == 0x11 || c == 0x13);
70 if (c == 0)
71 break;
72 *p++ = c;
75 return i;
78 void udbg_console_write(struct console *con, const char *s, unsigned int n)
80 udbg_write(s, n);
83 #define UDBG_BUFSIZE 256
84 void udbg_printf(const char *fmt, ...)
86 unsigned char buf[UDBG_BUFSIZE];
87 va_list args;
89 va_start(args, fmt);
90 vsnprintf(buf, UDBG_BUFSIZE, fmt, args);
91 udbg_puts(buf);
92 va_end(args);
95 /* Special print used by PPCDBG() macro */
96 void udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
98 unsigned long active_debugs = debug_flags & ppc64_debug_switch;
100 if (active_debugs) {
101 va_list ap;
102 unsigned char buf[UDBG_BUFSIZE];
103 unsigned long i, len = 0;
105 for (i=0; i < PPCDBG_NUM_FLAGS; i++) {
106 if (((1U << i) & active_debugs) &&
107 trace_names[i]) {
108 len += strlen(trace_names[i]);
109 udbg_puts(trace_names[i]);
110 break;
114 snprintf(buf, UDBG_BUFSIZE, " [%s]: ", current->comm);
115 len += strlen(buf);
116 udbg_puts(buf);
118 while (len < 18) {
119 udbg_puts(" ");
120 len++;
123 va_start(ap, fmt);
124 vsnprintf(buf, UDBG_BUFSIZE, fmt, ap);
125 udbg_puts(buf);
126 va_end(ap);
130 unsigned long udbg_ifdebug(unsigned long flags)
132 return (flags & ppc64_debug_switch);