1 #include <linux/config.h>
2 #include <linux/types.h>
3 #include <asm/ibm4xx.h>
4 #include <linux/kernel.h>
8 #define LSR_DR 0x01 /* Data ready */
9 #define LSR_OE 0x02 /* Overrun */
10 #define LSR_PE 0x04 /* Parity error */
11 #define LSR_FE 0x08 /* Framing error */
12 #define LSR_BI 0x10 /* Break */
13 #define LSR_THRE 0x20 /* Xmit holding register empty */
14 #define LSR_TEMT 0x40 /* Xmitter empty */
15 #define LSR_ERR 0x80 /* Error */
17 #include <platforms/4xx/ibm_ocp.h>
19 extern struct NS16550
* COM_PORTS
[];
24 static volatile struct NS16550
*kgdb_debugport
= NULL
;
26 volatile struct NS16550
*
27 NS16550_init(int chan
)
29 volatile struct NS16550
*com_port
;
32 quot
= BASE_BAUD
/ 9600;
34 quot
= 0x000c; /* 0xc = 9600 baud (on a pc) */
37 com_port
= (struct NS16550
*) COM_PORTS
[chan
];
42 com_port
->lcr
= com_port
->lcr
| 0x80; /* Access baud rate */
43 com_port
->dll
= ( quot
& 0x00ff ); /* 0xc = 9600 baud */
44 com_port
->dlm
= ( quot
& 0xff00 ) >> 8;
45 com_port
->lcr
= 0x03; /* 8 data, 1 stop, no parity */
46 com_port
->mcr
= 0x00; /* RTS/DTR */
47 com_port
->fcr
= 0x07; /* Clear & enable FIFOs */
54 NS16550_putc(volatile struct NS16550
*com_port
, unsigned char c
)
56 while ((com_port
->lsr
& LSR_THRE
) == 0)
63 NS16550_getc(volatile struct NS16550
*com_port
)
65 while ((com_port
->lsr
& LSR_DR
) == 0)
67 return (com_port
->rbr
);
71 NS16550_tstc(volatile struct NS16550
*com_port
)
73 return ((com_port
->lsr
& LSR_DR
) != 0);
77 #if defined(CONFIG_KGDB_TTYS0)
79 #elif defined(CONFIG_KGDB_TTYS1)
81 #elif defined(CONFIG_KGDB_TTYS2)
83 #elif defined(CONFIG_KGDB_TTYS3)
86 #error "invalid kgdb_tty port"
89 void putDebugChar( unsigned char c
)
91 if ( kgdb_debugport
== NULL
)
92 kgdb_debugport
= NS16550_init(KGDB_PORT
);
93 NS16550_putc( kgdb_debugport
, c
);
96 int getDebugChar( void )
98 if (kgdb_debugport
== NULL
)
99 kgdb_debugport
= NS16550_init(KGDB_PORT
);
101 return(NS16550_getc(kgdb_debugport
));
104 void kgdb_interruptible(int enable
)
109 void putDebugString(char* str
)
111 while (*str
!= '\0') {
122 printk("kgdb init \n");
123 kgdb_debugport
= NS16550_init(KGDB_PORT
);