Hello, This patch includes kgdb support on TX4938(RBHMA4500). Please review it. Hiroshi DOYU ----- --- linux.orig/arch/mips/tx4938/common/dbgio.c 1970-01-01 09:00:00.000000000 +0900 +++ linux/arch/mips/tx4938/common/dbgio.c 2005-06-09 13:49:38.674565752 +0900 @@ -0,0 +1,47 @@ +/* + * linux/arch/mips/tx4938/common/dbgio.c + * + * kgdb interface for gdb + * + * Author: MontaVista Software, Inc. + * source@xxxxxxxxxx + * + * Copyright 2005 MontaVista Software Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <asm/mipsregs.h> +#include <asm/system.h> +#include <asm/tx4928/tx4928_mips.h> + +u8 getDebugChar(void) +{ + extern u8 txx9_sio_kdbg_rd(void); + return (txx9_sio_kdbg_rd()); +} + + +int putDebugChar(u8 byte) +{ + extern int txx9_sio_kdbg_wr( u8 ch ); + return (txx9_sio_kdbg_wr(byte)); +} --- linux.orig/drivers/serial/serial_txx9.c 2005-05-26 18:12:46.000000000 +0900 +++ linux/drivers/serial/serial_txx9.c 2005-06-09 11:17:34.000000000 +0900 @@ -1129,6 +1129,96 @@ MODULE_DEVICE_TABLE(pci, serial_txx9_pci_tbl); #endif /* ENABLE_SERIAL_TXX9_PCI */ +/******************************************************************************/ +/* BEG: KDBG Routines */ +/******************************************************************************/ + +#ifdef CONFIG_KGDB +int kgdb_init_count = 0; + +void txx9_sio_kgdb_hook(unsigned int port, unsigned int baud_rate) +{ + static struct resource kgdb_resource; + int ret; + struct uart_txx9_port *up = &serial_txx9_ports[port]; + + /* prevent initialization by driver */ + kgdb_resource.name = "serial_txx9(debug)"; + kgdb_resource.start = up->port.membase; + kgdb_resource.end = up->port.membase + 36 - 1; + kgdb_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY; + + ret = request_resource(&iomem_resource, &kgdb_resource); + if(ret == -EBUSY) + printk(" serial_txx9(debug): request_resource failed\n"); + + return; +} +void +txx9_sio_kdbg_init( unsigned int port_number ) +{ + if (port_number == 1) { + txx9_sio_kgdb_hook(port_number, 38400); + } else { + printk("Bad Port Number [%u] != [1]\n",port_number); + } + return; +} + +u8 +txx9_sio_kdbg_rd( void ) +{ + unsigned int status,ch; + struct uart_txx9_port *up = &serial_txx9_ports[1]; + + if (kgdb_init_count == 0) { + txx9_sio_kdbg_init(1); + kgdb_init_count = 1; + } + + while (1) { + status = sio_in(up, TXX9_SIDISR); + if ( status & 0x1f ) { + ch = sio_in(up, TXX9_SIRFIFO ); + break; + } + } + + return (ch); +} + +int +txx9_sio_kdbg_wr( u8 ch ) +{ + unsigned int status; + struct uart_txx9_port *up = &serial_txx9_ports[1]; + + if (kgdb_init_count == 0) { + txx9_sio_kdbg_init(1); + kgdb_init_count = 1; + } + + while (1) { + status = sio_in(up, TXX9_SICISR); + if (status & TXX9_SICISR_TRDY) { + if ( ch == '\n' ) { + txx9_sio_kdbg_wr( '\r' ); + } + sio_out(up, TXX9_SITFIFO, (u32)ch ); + + break; + } + } + + return (1); +} +#endif /* CONFIG_KGDB */ + + +/******************************************************************************/ +/* END: KDBG Routines */ +/******************************************************************************/ + static int __init serial_txx9_init(void) { int ret;