Blackfin: add support for kgdb

Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/include/asm-blackfin/config.h b/include/asm-blackfin/config.h
index 0ae838a..7455685 100644
--- a/include/asm-blackfin/config.h
+++ b/include/asm-blackfin/config.h
@@ -66,6 +66,11 @@
 # error CONFIG_PLL_BYPASS: Invalid value: must be 0 or 1
 #endif
 
+/* If we are using KGDB, make sure we defer exceptions */
+#ifdef CONFIG_CMD_KGDB
+# define CONFIG_EXCEPTION_DEFER	1
+#endif
+
 /* Using L1 scratch pad makes sense for everyone by default. */
 #ifndef CONFIG_LINUX_CMDLINE_ADDR
 # define CONFIG_LINUX_CMDLINE_ADDR L1_SRAM_SCRATCH
@@ -138,6 +143,8 @@
 #endif
 #ifndef CONFIG_SYS_CBSIZE
 # define CONFIG_SYS_CBSIZE 1024
+#elif defined(CONFIG_CMD_KGDB) && CONFIG_SYS_CBSIZE < 1024
+# error "kgdb needs cbsize to be >= 1024"
 #endif
 #ifndef CONFIG_SYS_BARGSIZE
 # define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
diff --git a/include/asm-blackfin/deferred.h b/include/asm-blackfin/deferred.h
new file mode 100644
index 0000000..82ceda3
--- /dev/null
+++ b/include/asm-blackfin/deferred.h
@@ -0,0 +1,20 @@
+/*
+ * U-boot - deferred register layout
+ *
+ * Copyright 2004-2009 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#ifndef _BLACKFIN_DEFER_H
+#define _BLACKFIN_DEFER_H
+
+#define deferred_regs_DCPLB_FAULT_ADDR	0
+#define deferred_regs_ICPLB_FAULT_ADDR	1
+#define deferred_regs_retx		2
+#define deferred_regs_SEQSTAT		3
+#define deferred_regs_SYSCFG		4
+#define deferred_regs_IMASK		5
+#define deferred_regs_last		6
+
+#endif /* _BLACKFIN_DEFER_H */
diff --git a/include/asm-blackfin/entry.h b/include/asm-blackfin/entry.h
index ef74d68..404144f 100644
--- a/include/asm-blackfin/entry.h
+++ b/include/asm-blackfin/entry.h
@@ -86,6 +86,11 @@
 	[--sp] = RETE;
 	[--sp] = SEQSTAT;
 	[--sp] = SYSCFG;
+#ifdef CONFIG_CMD_KGDB
+	p0.l = lo(IPEND)
+	p0.h = hi(IPEND)
+	r0 = [p0];
+#endif
 	[--sp] = r0;	/* Skip IPEND as well. */
 .endm
 
@@ -137,6 +142,11 @@
 	[--sp] = RETE;
 	[--sp] = SEQSTAT;
 	[--sp] = SYSCFG;
+#ifdef CONFIG_CMD_KGDB
+	p0.l = lo(IPEND)
+	p0.h = hi(IPEND)
+	r0 = [p0];
+#endif
 	[--sp] = r0;	/* Skip IPEND as well. */
 .endm
 
diff --git a/include/asm-blackfin/mach-common/bits/core.h b/include/asm-blackfin/mach-common/bits/core.h
index d8cee10..6db4f81 100644
--- a/include/asm-blackfin/mach-common/bits/core.h
+++ b/include/asm-blackfin/mach-common/bits/core.h
@@ -105,5 +105,8 @@
 #define SSSTEP			0x00000001	/* Supervisor Single Step */
 #define CCEN			0x00000002	/* Cycle Counter Enable */
 #define SNEN			0x00000004	/* Self-Nesting Interrupt Enable */
+#define SYSCFG_SSSTEP_P	0
+#define SYSCFG_CCEN_P	1
+#define SYSCFG_SCEN_P	2
 
 #endif
diff --git a/include/asm-blackfin/signal.h b/include/asm-blackfin/signal.h
new file mode 100644
index 0000000..7b1573c
--- /dev/null
+++ b/include/asm-blackfin/signal.h
@@ -0,0 +1 @@
+#include <asm-generic/signal.h>