blob: 874078a7664dc66ccdc3f1137ea5b3382cd7e093 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Generic 16550 kgdb support intended to be useful on a variety
3 * of platforms. To enable this support, it is necessary to set
4 * the CONFIG_GEN550 option. Any virtual mapping of the serial
5 * port(s) to be used can be accomplished by setting
6 * ppc_md.early_serial_map to a platform-specific mapping function.
7 *
8 * Adapted from ppc4xx_kgdb.c.
9 *
10 * Author: Matt Porter <mporter@kernel.crashing.org>
11 *
12 * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under
13 * the terms of the GNU General Public License version 2. This program
14 * is licensed "as is" without any warranty of any kind, whether express
15 * or implied.
16 */
17
18#include <linux/config.h>
19#include <linux/types.h>
20#include <linux/kernel.h>
21
22#include <asm/machdep.h>
23
24extern unsigned long serial_init(int, void *);
25extern unsigned long serial_getc(unsigned long);
26extern unsigned long serial_putc(unsigned long, unsigned char);
27
28#if defined(CONFIG_KGDB_TTYS0)
29#define KGDB_PORT 0
30#elif defined(CONFIG_KGDB_TTYS1)
31#define KGDB_PORT 1
32#elif defined(CONFIG_KGDB_TTYS2)
33#define KGDB_PORT 2
34#elif defined(CONFIG_KGDB_TTYS3)
35#define KGDB_PORT 3
36#else
37#error "invalid kgdb_tty port"
38#endif
39
40static volatile unsigned int kgdb_debugport;
41
42void putDebugChar(unsigned char c)
43{
44 if (kgdb_debugport == 0)
45 kgdb_debugport = serial_init(KGDB_PORT, NULL);
46
47 serial_putc(kgdb_debugport, c);
48}
49
50int getDebugChar(void)
51{
52 if (kgdb_debugport == 0)
53 kgdb_debugport = serial_init(KGDB_PORT, NULL);
54
55 return(serial_getc(kgdb_debugport));
56}
57
58void kgdb_interruptible(int enable)
59{
60 return;
61}
62
63void putDebugString(char* str)
64{
65 while (*str != '\0') {
66 putDebugChar(*str);
67 str++;
68 }
69 putDebugChar('\r');
70 return;
71}
72
73/*
74 * Note: gen550_init() must be called already on the port we are going
75 * to use.
76 */
77void
78gen550_kgdb_map_scc(void)
79{
80 printk(KERN_DEBUG "kgdb init\n");
81 if (ppc_md.early_serial_map)
82 ppc_md.early_serial_map();
83 kgdb_debugport = serial_init(KGDB_PORT, NULL);
84}