KGDB: KGDB I/O driver for any 8250-compatible UARTs.
PATCH 4/21 KGDB: KGDB I/O driver for any 8250-compatible UARTs.
Signed-off-by Jason Wessel <[email protected]>
8250.patch
From: Jason Wessel <[email protected]>
CC: [email protected]
Subject: [PATCH] KGDB I/O driver for any 8250-compatible UARTs.
This patch some small hooks into the normal serial core so that a uart can be unregistered to be exclusively used for KGDB. These changes allow for registering and unregistering a port with a struct uart_port.
If KGDB_8250 is enabled, SERIAL_8250_NR_UARTS is set to the default of
4. This is so that if kgdb via rs232 can always depend on that constant in the 8250 driver for giving our table a size.
Signed-off-by Milind Dumbare <[email protected]>
Signed-off-by Dmitry Antipov <[email protected]>
Signed-off-by Tom Rini <[email protected]>
Signed-off-by Jason Wessel <[email protected]>
--- drivers/serial/8250.c | 19 + drivers/serial/8250_kgdb.c | 518 +++++++++++++++++++++++++++++++++++++++++++ drivers/serial/Kconfig | 2 drivers/serial/Makefile | 1 drivers/serial/serial_core.c | 24 + include/linux/serial_8250.h | 1 lib/Kconfig.kgdb | 61 ++++- 7 files changed, 620 insertions(+), 6 deletions(-) create mode 100644 drivers/serial/8250_kgdb.c
drivers/serial/8250.c +19 -0
@@ -2859,6 +2859,25 @@ void serial8250_unregister_port(int line }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;
drivers/serial/8250_kgdb.c new file +518 -0
518 lines not on this page · raw message
drivers/serial/Kconfig +1 -1
@@ -121,7 +121,7 @@ config SERIAL_8250_CS config SERIAL_8250_NR_UARTS int "Maximum number of 8250/16550 serial ports" - depends on SERIAL_8250 + depends on SERIAL_8250 || KGDB_8250 default "4" help Set this to the number of serial ports you want the driver
drivers/serial/Makefile +1 -0
@@ -64,3 +64,4 @@ obj-$(CONFIG_SERIAL_UARTLITE) += uartlit obj-$(CONFIG_SERIAL_NETX) += netx-serial.o obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o +obj-$(CONFIG_KGDB_8250) += 8250_kgdb.o
drivers/serial/serial_core.c +21 -3
@@ -33,6 +33,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>
@@ -58,6 +59,12 @@ static struct lock_class_key port_lock_k#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 ktermios *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);
@@ -1675,6 +1682,9 @@ static int uart_line_info(char *buf, str mmio ? (unsigned long long )port->mapbase : (unsigned long 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" );
@@ -2073,7 +2083,9 @@ uart_report_port(struct uart_driver *drvcase UPIO_TSI :case UPIO_DWAPB :snprintf (address,sizeof (address), -"MMIO 0x%llx" , (unsigned long long )port->mapbase); +"MMIO 0x%llx mem 0x%p" , + (unsigned long long )port->mapbase, + port->membase);break ;default :strlcpy (address,"*unknown*" ,sizeof (address));
@@ -2128,9 +2140,9 @@ uart_configure_port(struct uart_driver */* * 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 ); } }
@@ -2321,6 +2333,12 @@ int uart_add_one_port(struct uart_driver*/ port->flags &= ~UPF_DEAD ; +#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 (&state->mutex);mutex_unlock (&port_mutex);
include/linux/serial_8250.h +1 -0
@@ -57,6 +57,7 @@ struct uart_port;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);
lib/Kconfig.kgdb +59 -2
77 lines not on this page · raw message