Skip to content

Commit

Permalink
sh: Bring kgdb back from the dead.
Browse files Browse the repository at this point in the history
This code has suffered quite a bit of bitrot, do some basic
tidying to get it to a reasonably functional state again.
This gets the basic support and the console working again.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Paul Mundt authored and Paul Mundt committed May 7, 2007
1 parent 1570077 commit fa5da2f
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 369 deletions.
15 changes: 7 additions & 8 deletions arch/sh/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ config 4KSTACKS
on the VM subsystem for higher order allocations. This option
will also use IRQ stacks to compensate for the reduced stackspace.

config KGDB
config SH_KGDB
bool "Include KGDB kernel debugger"
select FRAME_POINTER
select DEBUG_INFO
help
Include in-kernel hooks for kgdb, the Linux kernel source level
debugger. See <http://kgdb.sourceforge.net/> for more information.
Unless you are intending to debug the kernel, say N here.

menu "KGDB configuration options"
depends on KGDB
depends on SH_KGDB

config MORE_COMPILE_OPTIONS
bool "Add any additional compile options"
Expand All @@ -109,16 +110,14 @@ config KGDB_THREAD

config SH_KGDB_CONSOLE
bool "Console messages through GDB"
depends on !SERIAL_SH_SCI_CONSOLE
select SERIAL_CORE_CONSOLE
default n

config KGDB_SYSRQ
bool "Allow SysRq 'G' to enter KGDB"
default y

config KGDB_KERNEL_ASSERTS
bool "Include KGDB kernel assertions"
default n

comment "Serial port setup"

config KGDB_DEFPORT
Expand All @@ -131,7 +130,7 @@ config KGDB_DEFBAUD

choice
prompt "Parity"
depends on KGDB
depends on SH_KGDB
default KGDB_DEFPARITY_N

config KGDB_DEFPARITY_N
Expand All @@ -147,7 +146,7 @@ endchoice

choice
prompt "Data bits"
depends on KGDB
depends on SH_KGDB
default KGDB_DEFBITS_8

config KGDB_DEFBITS_8
Expand Down
1 change: 0 additions & 1 deletion arch/sh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml
cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) -ffreestanding

cflags-$(CONFIG_SH_DSP) += -Wa,-dsp
cflags-$(CONFIG_SH_KGDB) += -g

cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
$(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
Expand Down
148 changes: 0 additions & 148 deletions arch/sh/boards/se/7751/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,153 +14,6 @@
#include <asm/se7751.h>
#include <asm/io.h>

void init_7751se_IRQ(void);

#ifdef CONFIG_SH_KGDB
#include <asm/kgdb.h>
static int kgdb_uart_setup(void);
static struct kgdb_sermap kgdb_uart_sermap =
{ "ttyS", 0, kgdb_uart_setup, NULL };
#endif

/*
* Initialize the board
*/
static void __init sh7751se_setup(char **cmdline_p)
{
/* Call init_smsc() replacement to set up SuperIO. */
/* XXX: RTC setting comes here */
#ifdef CONFIG_SH_KGDB
kgdb_register_sermap(&kgdb_uart_sermap);
#endif
}

/*********************************************************************
* Currently a hack (e.g. does not interact well w/serial.c, lots of *
* hardcoded stuff) but may be useful if SCI/F needs debugging. *
* Mostly copied from x86 code (see files asm-i386/kgdb_local.h and *
* arch/i386/lib/kgdb_serial.c). *
*********************************************************************/

#ifdef CONFIG_SH_KGDB
#include <linux/types.h>
#include <linux/serial.h>
#include <linux/serialP.h>
#include <linux/serial_reg.h>

#define COM1_PORT 0x3f8 /* Base I/O address */
#define COM1_IRQ 4 /* IRQ not used yet */
#define COM2_PORT 0x2f8 /* Base I/O address */
#define COM2_IRQ 3 /* IRQ not used yet */

#define SB_CLOCK 1843200 /* Serial baud clock */
#define SB_BASE (SB_CLOCK/16)
#define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS

struct uart_port {
int base;
};
#define UART_NPORTS 2
struct uart_port uart_ports[] = {
{ COM1_PORT },
{ COM2_PORT },
};
struct uart_port *kgdb_uart_port;

#define UART_IN(reg) inb_p(kgdb_uart_port->base + reg)
#define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg)

/* Basic read/write functions for the UART */
#define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)
static int kgdb_uart_getchar(void)
{
int lsr;
int c = -1;

while (c == -1) {
lsr = UART_IN(UART_LSR);
if (lsr & UART_LSR_DR)
c = UART_IN(UART_RX);
if ((lsr & UART_LSR_RXCERR))
c = -1;
}
return c;
}

static void kgdb_uart_putchar(int c)
{
while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)
;
UART_OUT(UART_TX, c);
}

/*
* Initialize UART to configured/requested values.
* (But we don't interrupts yet, or interact w/serial.c)
*/
static int kgdb_uart_setup(void)
{
int port;
int lcr = 0;
int bdiv = 0;

if (kgdb_portnum >= UART_NPORTS) {
KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);
return -1;
}

kgdb_uart_port = &uart_ports[kgdb_portnum];

/* Init sequence from gdb_hook_interrupt */
UART_IN(UART_RX);
UART_OUT(UART_IER, 0);

UART_IN(UART_RX); /* Serial driver comments say */
UART_IN(UART_IIR); /* this clears interrupt regs */
UART_IN(UART_MSR);

/* Figure basic LCR values */
switch (kgdb_bits) {
case '7':
lcr |= UART_LCR_WLEN7;
break;
default: case '8':
lcr |= UART_LCR_WLEN8;
break;
}
switch (kgdb_parity) {
case 'O':
lcr |= UART_LCR_PARITY;
break;
case 'E':
lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);
break;
default: break;
}

/* Figure the baud rate divisor */
bdiv = (SB_BASE/kgdb_baud);

/* Set the baud rate and LCR values */
UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));
UART_OUT(UART_DLL, (bdiv & 0xff));
UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));
UART_OUT(UART_LCR, lcr);

/* Set the MCR */
UART_OUT(UART_MCR, SB_MCR);

/* Turn off FIFOs for now */
UART_OUT(UART_FCR, 0);

/* Setup complete: initialize function pointers */
kgdb_getchar = kgdb_uart_getchar;
kgdb_putchar = kgdb_uart_putchar;

return 0;
}
#endif /* CONFIG_SH_KGDB */

static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };

static struct resource heartbeat_resources[] = {
Expand Down Expand Up @@ -197,7 +50,6 @@ __initcall(se7751_devices_setup);
*/
struct sh_machine_vector mv_7751se __initmv = {
.mv_name = "7751 SolutionEngine",
.mv_setup = sh7751se_setup,
.mv_nr_irqs = 72,

.mv_inb = sh7751se_inb,
Expand Down
Loading

0 comments on commit fa5da2f

Please sign in to comment.