⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mips-lite.patch

📁 Linux-2.6.18内核调试工具补丁程序KGDB。
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
This adds basic support to the MIPS architecture as well as supportspecifically for the MIPS Malta (via 8250) and SiByte 1250-SWARM(32 and 64bit, custom uart), all from Manish Lachwani.  This looks like itshould work on anything with an 8250-compatible uart, and be fairly easyto convert other boards with custom uarts.  This also adds the base functionsfor debugging into the serial_txx9 driver, from Ralf.Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>Signed-off-by: Tom Rini <trini@kernel.crashing.org> arch/mips/Kconfig.debug                   |   19 arch/mips/kernel/Makefile                 |    3 arch/mips/kernel/gdb-low.S                |  369 ---------- arch/mips/kernel/gdb-stub.c               | 1096 ------------------------------ arch/mips/kernel/irq.c                    |   32 arch/mips/kernel/kgdb-jmp.c               |  116 +++ arch/mips/kernel/kgdb-setjmp.S            |   28 arch/mips/kernel/kgdb.c                   |  297 ++++++++ arch/mips/kernel/kgdb_handler.S           |   57 + arch/mips/kernel/traps.c                  |   24 arch/mips/mips-boards/generic/Makefile    |    1 arch/mips/mips-boards/generic/init.c      |   62 - arch/mips/mips-boards/malta/malta_setup.c |    8 arch/mips/mm/extable.c                    |    7 arch/mips/sibyte/cfe/setup.c              |   14 arch/mips/sibyte/sb1250/Makefile          |    1 arch/mips/sibyte/sb1250/irq.c             |   59 - arch/mips/sibyte/sb1250/irq_handler.S     |    2 arch/mips/sibyte/sb1250/kgdb_sibyte.c     |  164 ++++ arch/mips/sibyte/swarm/Makefile           |    2 arch/mips/sibyte/swarm/dbg_io.c           |   76 -- arch/mips/tx4938/common/Makefile          |    2 drivers/serial/serial_txx9.c              |   90 ++ include/asm-mips/kdebug.h                 |   47 + include/asm-mips/kgdb.h                   |   29 lib/Kconfig.debug                         |    7 26 files changed, 889 insertions(+), 1723 deletions(-)Index: linux-2.6.16/drivers/serial/serial_txx9.c===================================================================--- linux-2.6.16.orig/drivers/serial/serial_txx9.c	2006-03-20 00:53:29.000000000 -0500+++ linux-2.6.16/drivers/serial/serial_txx9.c	2006-04-25 08:01:03.942041168 -0400@@ -1174,6 +1174,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 = (unsigned long)up->port.membase;+	kgdb_resource.end = (unsigned long)(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;Index: linux-2.6.16/lib/Kconfig.debug===================================================================--- linux-2.6.16.orig/lib/Kconfig.debug	2006-04-25 08:01:02.886201680 -0400+++ linux-2.6.16/lib/Kconfig.debug	2006-04-25 08:01:04.012030528 -0400@@ -232,7 +232,7 @@ config KGDB 	bool "KGDB: kernel debugging with remote gdb" 	select WANT_EXTRA_DEBUG_INFORMATION-	depends on DEBUG_KERNEL && (X86 || PPC)+	depends on DEBUG_KERNEL && (X86 || MIPS || PPC) 	help 	  If you say Y here, it will be possible to remotely debug the 	  kernel using gdb. It is strongly suggested that you enable@@ -260,6 +260,7 @@ 	default KGDB_8250_NOMODULE 	default KGDB_MPSC if SERIAL_MPSC 	default KGDB_CPM_UART if (8xx || 8260)+	default KGDB_SIBYTE if SIBYTE_SB1xxx_SOC 	help 	  There are a number of different ways in which you can communicate 	  with KGDB.  The most common is via serial, with the 8250 driver@@ -310,6 +311,10 @@ 	depends on PPC && (CPM2 || 8xx)  	help  	  Uses CPM UART to communicate with the host GDB.++config KGDB_SIBYTE+	bool "KGDB: On the Broadcom SWARM serial port"+	depends on MIPS && SIBYTE_SB1xxx_SOC endchoice  config KGDBOEIndex: linux-2.6.16/arch/mips/kernel/kgdb-setjmp.S===================================================================--- linux-2.6.16.orig/arch/mips/kernel/kgdb-setjmp.S	2006-04-25 03:03:31.107356424 -0400+++ linux-2.6.16/arch/mips/kernel/kgdb-setjmp.S	2006-04-25 08:01:04.005031592 -0400@@ -0,0 +1,28 @@+/*+ * arch/mips/kernel/kgdb-jmp.c+ *+ * Save and restore system registers so that within a limited frame we+ * may have a fault and "jump back" to a known safe location.+ *+ * Copyright (C) 2005 by MontaVista Software.+ * Author: Manish Lachwani (mlachwani@mvista.com)+ *+ * This file is licensed under the terms of the GNU General Public License+ * version 2. This program as licensed "as is" without any warranty of+ * any kind, whether express or implied.+ */++#include <asm/asm.h>+#include <asm/mipsregs.h>+#include <asm/regdef.h>+#include <asm/stackframe.h>++	.ent	kgdb_fault_setjmp,0+ENTRY (kgdb_fault_setjmp)+	move    a1, sp+	move	a2, fp+#ifdef CONFIG_MIPS64+	nop+#endif+	j	kgdb_fault_setjmp_aux+	.end	kgdb_fault_setjmpIndex: linux-2.6.16/arch/mips/kernel/gdb-stub.c===================================================================--- linux-2.6.16.orig/arch/mips/kernel/gdb-stub.c	2006-03-20 00:53:29.000000000 -0500+++ linux-2.6.16/arch/mips/kernel/gdb-stub.c	2006-04-25 03:03:31.107356424 -0400@@ -1,1096 +0,0 @@-/*- *  arch/mips/kernel/gdb-stub.c- *- *  Originally written by Glenn Engel, Lake Stevens Instrument Division- *- *  Contributed by HP Systems- *- *  Modified for SPARC by Stu Grossman, Cygnus Support.- *- *  Modified for Linux/MIPS (and MIPS in general) by Andreas Busse- *  Send complaints, suggestions etc. to <andy@waldorf-gmbh.de>- *- *  Copyright (C) 1995 Andreas Busse- *- *  Copyright (C) 2003 MontaVista Software Inc.- *  Author: Jun Sun, jsun@mvista.com or jsun@junsun.net- */--/*- *  To enable debugger support, two things need to happen.  One, a- *  call to set_debug_traps() is necessary in order to allow any breakpoints- *  or error conditions to be properly intercepted and reported to gdb.- *  Two, a breakpoint needs to be generated to begin communication.  This- *  is most easily accomplished by a call to breakpoint().  Breakpoint()- *  simulates a breakpoint by executing a BREAK instruction.- *- *- *    The following gdb commands are supported:- *- * command          function                               Return value- *- *    g             return the value of the CPU registers  hex data or ENN- *    G             set the value of the CPU registers     OK or ENN- *- *    mAA..AA,LLLL  Read LLLL bytes at address AA..AA      hex data or ENN- *    MAA..AA,LLLL: Write LLLL bytes at address AA.AA      OK or ENN- *- *    c             Resume at current address              SNN   ( signal NN)- *    cAA..AA       Continue at address AA..AA             SNN- *- *    s             Step one instruction                   SNN- *    sAA..AA       Step one instruction from AA..AA       SNN- *- *    k             kill- *- *    ?             What was the last sigval ?             SNN   (signal NN)- *- *    bBB..BB	    Set baud rate to BB..BB		   OK or BNN, then sets- *							   baud rate- *- * All commands and responses are sent with a packet which includes a- * checksum.  A packet consists of- *- * $<packet info>#<checksum>.- *- * where- * <packet info> :: <characters representing the command or response>- * <checksum>    :: < two hex digits computed as modulo 256 sum of <packetinfo>>- *- * When a packet is received, it is first acknowledged with either '+' or '-'.- * '+' indicates a successful transfer.  '-' indicates a failed transfer.- *- * Example:- *- * Host:                  Reply:- * $m0,10#2a               +$00010203040506070809101112131415#42- *- *- *  ==============- *  MORE EXAMPLES:- *  ==============- *- *  For reference -- the following are the steps that one- *  company took (RidgeRun Inc) to get remote gdb debugging- *  going. In this scenario the host machine was a PC and the- *  target platform was a Galileo EVB64120A MIPS evaluation- *  board.- *- *  Step 1:- *  First download gdb-5.0.tar.gz from the internet.- *  and then build/install the package.- *- *  Example:- *    $ tar zxf gdb-5.0.tar.gz- *    $ cd gdb-5.0- *    $ ./configure --target=mips-linux-elf- *    $ make- *    $ install- *    $ which mips-linux-elf-gdb- *    /usr/local/bin/mips-linux-elf-gdb- *- *  Step 2:- *  Configure linux for remote debugging and build it.- *- *  Example:- *    $ cd ~/linux- *    $ make menuconfig <go to "Kernel Hacking" and turn on remote debugging>- *    $ make- *- *  Step 3:- *  Download the kernel to the remote target and start- *  the kernel running. It will promptly halt and wait- *  for the host gdb session to connect. It does this- *  since the "Kernel Hacking" option has defined- *  CONFIG_KGDB which in turn enables your calls- *  to:- *     set_debug_traps();- *     breakpoint();- *- *  Step 4:- *  Start the gdb session on the host.- *- *  Example:- *    $ mips-linux-elf-gdb vmlinux- *    (gdb) set remotebaud 115200- *    (gdb) target remote /dev/ttyS1- *    ...at this point you are connected to- *       the remote target and can use gdb- *       in the normal fasion. Setting- *       breakpoints, single stepping,- *       printing variables, etc.- */-#include <linux/config.h>-#include <linux/string.h>-#include <linux/kernel.h>-#include <linux/signal.h>-#include <linux/sched.h>-#include <linux/mm.h>-#include <linux/console.h>-#include <linux/init.h>-#include <linux/smp.h>-#include <linux/spinlock.h>-#include <linux/slab.h>-#include <linux/reboot.h>--#include <asm/asm.h>-#include <asm/cacheflush.h>-#include <asm/mipsregs.h>-#include <asm/pgtable.h>-#include <asm/system.h>-#include <asm/gdb-stub.h>-#include <asm/inst.h>--/*- * external low-level support routines- */--extern int putDebugChar(char c);    /* write a single character      */-extern char getDebugChar(void);     /* read and return a single char */-extern void trap_low(void);--/*- * breakpoint and test functions- */-extern void breakpoint(void);-extern void breakinst(void);-extern void async_breakpoint(void);-extern void async_breakinst(void);-extern void adel(void);--/*- * local prototypes- */--static void getpacket(char *buffer);-static void putpacket(char *buffer);-static int computeSignal(int tt);-static int hex(unsigned char ch);-static int hexToInt(char **ptr, int *intValue);-static int hexToLong(char **ptr, long *longValue);-static unsigned char *mem2hex(char *mem, char *buf, int count, int may_fault);-void handle_exception(struct gdb_regs *regs);--int kgdb_enabled;--/*- * spin locks for smp case- */-static DEFINE_SPINLOCK(kgdb_lock);-static raw_spinlock_t kgdb_cpulock[NR_CPUS] = {-	[0 ... NR_CPUS-1] = __RAW_SPIN_LOCK_UNLOCKED,-};--/*- * BUFMAX defines the maximum number of characters in inbound/outbound buffers- * at least NUMREGBYTES*2 are needed for register packets- */-#define BUFMAX 2048--static char input_buffer[BUFMAX];-static char output_buffer[BUFMAX];-static int initialized;	/* !0 means we've been initialized */-static int kgdb_started;-static const char hexchars[]="0123456789abcdef";--/* Used to prevent crashes in memory access.  Note that they'll crash anyway if-   we haven't set up fault handlers yet... */-int kgdb_read_byte(unsigned char *address, unsigned char *dest);-int kgdb_write_byte(unsigned char val, unsigned char *dest);--/*- * Convert ch from a hex digit to an int- */-static int hex(unsigned char ch)-{-	if (ch >= 'a' && ch <= 'f')-		return ch-'a'+10;-	if (ch >= '0' && ch <= '9')-		return ch-'0';-	if (ch >= 'A' && ch <= 'F')-		return ch-'A'+10;-	return -1;-}--/*- * scan for the sequence $<data>#<checksum>- */-static void getpacket(char *buffer)-{-	unsigned char checksum;-	unsigned char xmitcsum;-	int i;-	int count;-	unsigned char ch;--	do {-		/*-		 * wait around for the start character,-		 * ignore all other characters-		 */-		while ((ch = (getDebugChar() & 0x7f)) != '$') ;--		checksum = 0;-		xmitcsum = -1;-		count = 0;--		/*-		 * now, read until a # or end of buffer is found-		 */-		while (count < BUFMAX) {-			ch = getDebugChar();-			if (ch == '#')-				break;-			checksum = checksum + ch;-			buffer[count] = ch;-			count = count + 1;-		}--		if (count >= BUFMAX)-			continue;--		buffer[count] = 0;--		if (ch == '#') {-			xmitcsum = hex(getDebugChar() & 0x7f) << 4;-			xmitcsum |= hex(getDebugChar() & 0x7f);--			if (checksum != xmitcsum)-				putDebugChar('-');	/* failed checksum */-			else {-				putDebugChar('+'); /* successful transfer */--				/*-				 * if a sequence char is present,-				 * reply the sequence ID-				 */-				if (buffer[2] == ':') {-					putDebugChar(buffer[0]);-					putDebugChar(buffer[1]);--					/*-					 * remove sequence chars from buffer-					 */-					count = strlen(buffer);-					for (i=3; i <= count; i++)-						buffer[i-3] = buffer[i];-				}-			}-		}-	}-	while (checksum != xmitcsum);-}--/*- * send the packet in buffer.- */-static void putpacket(char *buffer)-{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -