📄 8250.patch
字号:
+ kgdb8250_needs_request_mem_region = 1;+ if (current_port->flags & UPF_IOREMAP) {+ current_port->membase = ioremap(current_port->mapbase,+ 8 << current_port->regshift);+ if (!current_port->membase)+ return -EIO; /* Failed. */+ }+ kgdb8250_addr = current_port->membase;+ break;+ case UPIO_PORT:+ default:+ kgdb8250_addr = ioport_map(current_port->iobase,+ 8 << current_port->regshift);+ if (!kgdb8250_addr)+ return -EIO; /* Failed. */+ }++ if (kgdb8250_uart_init() == -1) {+ printk(KERN_ERR "kgdb8250: init failed\n");+ return -EIO;+ }+#ifdef CONFIG_KGDB_8250_MODULE+ /* Attach the kgdb irq. When this is built into the kernel, it+ * is called as a part of late_init sequence.+ */+ kgdb8250_late_init();+ if (kgdb_register_io_module(&local_kgdb_io_ops))+ return -EINVAL;++ printk(KERN_INFO "kgdb8250: debugging enabled\n");+#endif /* CONFIG_KGD_8250_MODULE */++ return 0;+}++#ifdef CONFIG_KGDB_8250_MODULE+/* If it is a module the kgdb_io_ops should be a static which+ * is passed to the KGDB I/O initialization+ */+static struct kgdb_io local_kgdb_io_ops = {+#else /* ! CONFIG_KGDB_8250_MODULE */+struct kgdb_io kgdb_io_ops = {+#endif /* ! CONFIG_KGD_8250_MODULE */+ .read_char = kgdb_get_debug_char,+ .write_char = kgdb_put_debug_char,+ .init = kgdb_init_io,+ .late_init = kgdb8250_late_init,+};++/**+ * kgdb8250_add_port - Define a serial port for use with KGDB+ * @i: The index of the port being added+ * @serial_req: The &struct uart_port describing the port+ *+ * On platforms where we must register the serial device+ * dynamically, this is the best option if a platform also normally+ * calls early_serial_setup().+ */+void __init kgdb8250_add_port(int i, struct uart_port *serial_req)+{+ /* Make sure we've got the built-in data before we override. */+ kgdb8250_copy_rs_table();++ /* Copy the whole thing over. */+ if (current_port != &kgdb8250_ports[i])+ memcpy(&kgdb8250_ports[i], serial_req, sizeof(struct uart_port));+}++/**+ * kgdb8250_add_platform_port - Define a serial port for use with KGDB+ * @i: The index of the port being added+ * @p: The &struct plat_serial8250_port describing the port+ *+ * On platforms where we must register the serial device+ * dynamically, this is the best option if a platform normally+ * handles uart setup with an array of &struct plat_serial8250_port.+ */+void __init kgdb8250_add_platform_port(int i, struct plat_serial8250_port *p)+{+ /* Make sure we've got the built-in data before we override. */+ kgdb8250_copy_rs_table();++ kgdb8250_ports[i].iobase = p->iobase;+ kgdb8250_ports[i].membase = p->membase;+ kgdb8250_ports[i].irq = p->irq;+ kgdb8250_ports[i].uartclk = p->uartclk;+ kgdb8250_ports[i].regshift = p->regshift;+ kgdb8250_ports[i].iotype = p->iotype;+ kgdb8250_ports[i].flags = p->flags;+ kgdb8250_ports[i].mapbase = p->mapbase;+}++/*+ * Syntax for this cmdline option is:+ * kgdb8250=<io or mmio>,<address>,<baud rate>,<irq>"+ */+static int __init kgdb8250_opt(char *str)+{+ /* We'll fill out and use the first slot. */+ current_port = &kgdb8250_ports[0];++ if (!strncmp(str, "io", 2)) {+ current_port->iotype = UPIO_PORT;+ str += 2;+ } else if (!strncmp(str, "mmap", 4)) {+ current_port->iotype = UPIO_MEM;+ current_port->flags |= UPF_IOREMAP;+ str += 4;+ } else if (!strncmp(str, "mmio", 4)) {+ current_port->iotype = UPIO_MEM;+ current_port->flags &= ~UPF_IOREMAP;+ str += 4;+ } else+ goto errout;++ if (*str != ',')+ goto errout;+ str++;++ if (current_port->iotype == UPIO_PORT)+ current_port->iobase = simple_strtoul(str, &str, 16);+ else {+ if (current_port->flags & UPF_IOREMAP)+ current_port->mapbase =+ (unsigned long) simple_strtoul(str, &str, 16);+ else+ current_port->membase =+ (void *) simple_strtoul(str, &str, 16);+ }++ if (*str != ',')+ goto errout;+ str++;++ kgdb8250_baud = simple_strtoul(str, &str, 10);+ if (!kgdb8250_baud)+ goto errout;++ if (*str != ',')+ goto errout;+ str++;++ current_port->irq = simple_strtoul(str, &str, 10);++#ifdef CONFIG_KGDB_SIMPLE_SERIAL+ should_copy_rs_table = 0;+#endif++ return 0;++ errout:+ printk(KERN_ERR "Invalid syntax for option kgdb8250=\n");+ return 1;+}++#ifdef CONFIG_KGDB_8250_MODULE+static void cleanup_kgdb8250(void)+{+ kgdb_unregister_io_module(&local_kgdb_io_ops);++ /* Clean up the irq and memory */+ free_irq(current_port->irq, current_port);++ if (kgdb8250_needs_request_mem_region)+ release_mem_region(current_port->mapbase,+ 8 << current_port->regshift);+ /* Hook up the serial port back to what it was previously+ * hooked up to.+ */+#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)+ /* Give the port back to the 8250 driver. */+ serial8250_register_port(current_port);+#endif+}++module_init(kgdb_init_io);+module_exit(cleanup_kgdb8250);+#else /* ! CONFIG_KGDB_8250_MODULE */+early_param("kgdb8250", kgdb8250_opt);+#endif /* ! CONFIG_KGDB_8250_MODULE */Index: linux-2.6.16-x86_64/drivers/serial/Makefile===================================================================--- linux-2.6.16-x86_64.orig/drivers/serial/Makefile 2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16-x86_64/drivers/serial/Makefile 2006-04-26 12:28:57.000000000 +0530@@ -58,3 +58,4 @@ obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o obj-$(CONFIG_SERIAL_AT91) += at91_serial.o+obj-$(CONFIG_KGDB_8250) += 8250_kgdb.oIndex: linux-2.6.16-x86_64/drivers/serial/serial_core.c===================================================================--- linux-2.6.16-x86_64.orig/drivers/serial/serial_core.c 2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16-x86_64/drivers/serial/serial_core.c 2006-04-26 12:28:57.000000000 +0530@@ -34,6 +34,7 @@ #include <linux/serial.h> /* for serial_state and serial_icounter_struct */ #include <linux/delay.h> #include <linux/mutex.h>+#include <linux/kgdb.h> #include <asm/irq.h> #include <asm/uaccess.h>@@ -60,6 +61,12 @@ #define uart_console(port) (0) #endif +#ifdef CONFIG_KGDB_CONSOLE+#define uart_kgdb(port) (port->cons && !strcmp(port->cons->name, "kgdb"))+#else+#define uart_kgdb(port) (0)+#endif+ static void uart_change_speed(struct uart_state *state, struct termios *old_termios); static void uart_wait_until_sent(struct tty_struct *tty, int timeout); static void uart_change_pm(struct uart_state *state, int pm_state);@@ -1666,6 +1673,9 @@ port->iotype == UPIO_MEM ? port->mapbase : (unsigned long) port->iobase, port->irq);+ if (port->iotype == UPIO_MEM)+ ret += sprintf(buf+ret, " membase 0x%08lX",+ (unsigned long) port->membase); if (port->type == PORT_UNKNOWN) { strcat(buf, "\n");@@ -2005,7 +2015,8 @@ case UPIO_MEM32: case UPIO_AU: snprintf(address, sizeof(address),- "MMIO 0x%lx", port->mapbase);+ "MMIO map 0x%lx mem 0x%lx", port->mapbase,+ (unsigned long) port->membase); break; default: strlcpy(address, "*unknown*", sizeof(address));@@ -2057,9 +2068,9 @@ /* * Power down all ports by default, except the- * console if we have one.+ * console (real or kgdb) if we have one. */- if (!uart_console(port))+ if (!uart_console(port) && !uart_kgdb(port)) uart_change_pm(state, 3); } }@@ -2283,6 +2294,12 @@ port->cons && !(port->cons->flags & CON_ENABLED)) register_console(port->cons); +#if defined(CONFIG_KGDB_8250)+ /* Add any 8250-like ports we find later. */+ if (port->type <= PORT_MAX_8250)+ kgdb8250_add_port(port->line, port);+#endif+ out: mutex_unlock(&port_mutex); Index: linux-2.6.16-x86_64/drivers/serial/8250.c===================================================================--- linux-2.6.16-x86_64.orig/drivers/serial/8250.c 2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16-x86_64/drivers/serial/8250.c 2006-04-26 12:48:48.000000000 +0530@@ -2577,6 +2577,25 @@ } EXPORT_SYMBOL(serial8250_unregister_port); +/**+ * serial8250_unregister_by_port - remove a 16x50 serial port+ * at runtime.+ * @port: A &struct uart_port that describes the port to remove.+ *+ * Remove one serial port. This may not be called from interrupt+ * context. We hand the port back to the our control.+ */+void serial8250_unregister_by_port(struct uart_port *port)+{+ struct uart_8250_port *uart;++ uart = serial8250_find_match_or_unused(port);++ if (uart)+ serial8250_unregister_port(uart->port.line);+}+EXPORT_SYMBOL(serial8250_unregister_by_port);+ static int __init serial8250_init(void) { int ret, i;Index: linux-2.6.16-x86_64/lib/Kconfig.debug===================================================================--- linux-2.6.16-x86_64.orig/lib/Kconfig.debug 2006-04-26 12:28:57.000000000 +0530+++ linux-2.6.16-x86_64/lib/Kconfig.debug 2006-04-26 12:28:57.000000000 +0530@@ -257,7 +257,7 @@ choice prompt "Method for KGDB communication" depends on KGDB- default KGDB_ONLY_MODULES+ default KGDB_8250_NOMODULE 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@@ -275,4 +275,60 @@ Use only kernel modules to configure KGDB I/O after the kernel is booted. +config KGDB_8250_NOMODULE+ bool "KGDB: On generic serial port (8250)"+ select KGDB_8250+ help+ Uses generic serial port (8250) to communicate with the host+ GDB. This is independent of the normal (SERIAL_8250) driver+ for this chipset. endchoice++config KGDB_8250+ tristate "KGDB: On generic serial port (8250)" if !KGDB_8250_NOMODULE+ depends on m && KGDB_ONLY_MODULES+ help+ Uses generic serial port (8250) to communicate with the host+ GDB. This is independent of the normal (SERIAL_8250) driver+ for this chipset.++config KGDB_SIMPLE_SERIAL+ bool "Simple selection of KGDB serial port"+ depends on KGDB_8250_NOMODULE+ default y+ help+ If you say Y here, you will only have to pick the baud rate+ and port number that you wish to use for KGDB. Note that this+ only works on architectures that register known serial ports+ early on. If you say N, you will have to provide, either here+ or on the command line, the type (I/O or MMIO), IRQ and+ address to use. If in doubt, say Y.++config KGDB_BAUDRATE+ int "Debug serial port baud rate"+ depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL)+ default "115200"+ help+ gdb and the kernel stub need to agree on the baud rate to be+ used. Standard rates from 9600 to 115200 are allowed, and this+ may be overridden via the commandline.++config KGDB_PORT_NUM+ int "Serial port number for KGDB"+ range 0 1 if KGDB_MPSC+ range 0 3+ depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_MPSC+ default "1"+ help+ Pick the port number (0 based) for KGDB to use.++config KGDB_8250_CONF_STRING+ string "Configuration string for KGDB"+ depends on KGDB_8250_NOMODULE && !KGDB_SIMPLE_SERIAL+ default "io,2f8,115200,3" if X86+ help+ The format of this string should be <io or+ mmio>,<address>,<baud rate>,<irq>. For example, to use the+ serial port on an i386 box located at 0x2f8 and 115200 baud+ on IRQ 3 at use:+ io,2f8,115200,3Index: linux-2.6.16-x86_64/include/linux/serial_8250.h===================================================================--- linux-2.6.16-x86_64.orig/include/linux/serial_8250.h 2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16-x86_64/include/linux/serial_8250.h 2006-04-26 12:28:57.000000000 +0530@@ -55,6 +55,7 @@ int serial8250_register_port(struct uart_port *); void serial8250_unregister_port(int line);+void serial8250_unregister_by_port(struct uart_port *port); void serial8250_suspend_port(int line); void serial8250_resume_port(int line);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -