[coreboot-gerrit] Patch set updated for coreboot: cleanups: Move gdb_stub_breakpoint and make it accesible in C.
Denis Carikli (GNUtoo@no-log.org)
gerrit at coreboot.org
Fri Dec 11 00:26:27 CET 2015
Denis Carikli (GNUtoo at no-log.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12709
-gerrit
commit 649011d81d05d96bfdc79b2b7377608d756c41d8
Author: Denis 'GNUtoo' Carikli <GNUtoo at no-log.org>
Date: Thu Dec 10 21:58:52 2015 +0100
cleanups: Move gdb_stub_breakpoint and make it accesible in C.
The Kconfig description was also improved.
Change-Id: Ia992e7a2077b92c45546ae56c5fb648775f8f63b
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at no-log.org>
---
src/Kconfig | 7 ++++---
src/arch/x86/c_start.S | 27 ++-------------------------
src/console/Makefile.inc | 1 +
src/console/gdb.c | 29 +++++++++++++++++++++++++++++
src/include/console/gdb.h | 6 ++++++
5 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/src/Kconfig b/src/Kconfig
index 293673d..5ce840b 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -721,12 +721,13 @@ config GDB_STUB
If enabled, you will be able to set breakpoints for gdb debugging.
See src/arch/x86/lib/c_start.S for details.
-config GDB_WAIT
- bool "Wait for a GDB connection"
+config GDB_WAIT_RAMSTAGE
+ bool "Wait for a GDB connection in the ramstage"
default n
depends on GDB_STUB
help
- If enabled, coreboot will wait for a GDB connection.
+ If enabled, coreboot will wait for a GDB connection in the ramstage.
+
config FATAL_ASSERTS
bool "Halt when hitting a BUG() or assertion error"
diff --git a/src/arch/x86/c_start.S b/src/arch/x86/c_start.S
index ad4589a..c871f58 100644
--- a/src/arch/x86/c_start.S
+++ b/src/arch/x86/c_start.S
@@ -97,7 +97,7 @@ _start:
*/
post_code(POST_PRE_HARDWAREMAIN) /* post fe */
-#if CONFIG_GDB_WAIT
+#if CONFIG_GDB_WAIT_RAMSTAGE
call gdb_hw_init
call gdb_stub_breakpoint
#endif
@@ -214,6 +214,7 @@ vec19:
push $19 /* vector */
jmp int_hand
+.global int_hand
int_hand:
/* At this point, on x86-32, on the stack there is:
* 0(%esp) vector
@@ -276,33 +277,9 @@ int_hand:
addl $8, %esp /* pop of the vector and error code */
#endif
-
iret
-#if CONFIG_GDB_WAIT
-
- .globl gdb_stub_breakpoint
-gdb_stub_breakpoint:
-#ifdef __x86_64__
- pop %rax /* Return address */
- pushfl
- push %cs
- push %rax /* Return address */
- push $0 /* No error code */
- push $32 /* vector 32 is user defined */
-#else
- popl %eax /* Return address */
- pushfl
- pushl %cs
- pushl %eax /* Return address */
- pushl $0 /* No error code */
- pushl $32 /* vector 32 is user defined */
-#endif
- jmp int_hand
-#endif
-
.globl gdt, gdt_end, idtarg
-
gdtaddr:
.word gdt_end - gdt - 1
#ifdef __x86_64__
diff --git a/src/console/Makefile.inc b/src/console/Makefile.inc
index 94b456c..866ae7f 100644
--- a/src/console/Makefile.inc
+++ b/src/console/Makefile.inc
@@ -2,6 +2,7 @@ ramstage-y += vtxprintf.c printk.c vsprintf.c
ramstage-y += init.c console.c
ramstage-y += post.c
ramstage-y += die.c
+ramstage-$(CONFIG_GDB_WAIT_RAMSTAGE) += gdb.c
smm-$(CONFIG_DEBUG_SMI) += init.c console.c vtxprintf.c printk.c
smm-$(CONFIG_SMM_TSEG) += die.c
diff --git a/src/console/gdb.c b/src/console/gdb.c
new file mode 100644
index 0000000..11b8707
--- /dev/null
+++ b/src/console/gdb.c
@@ -0,0 +1,29 @@
+#include <console/gdb.h>
+
+#ifdef __x86_64__
+void gdb_stub_breakpoint()
+{
+ asm volatile(
+ "pop %rax\n\t" /* Return address */
+ "pushfl\n\t"
+ "push %cs\n\t"
+ "push %rax\n\t" /* Return address */
+ "push $0\n\t" /* No error code */
+ "push $32\n\t" /* vector 32 is user defined */
+ "jmp int_hand\n\t");
+}
+#elif CONFIG_ARCH_X86
+void gdb_stub_breakpoint()
+{
+ asm volatile(
+ "popl %eax\n\t" /* Return address */
+ "pushfl\n\t"
+ "pushl %cs\n\t"
+ "pushl %eax\n\t" /* Return address */
+ "pushl $0\n\t" /* No error code */
+ "pushl $32\n\t" /* vector 32 is user defined */
+ "jmp int_hand\n\t");
+}
+#else
+#error "No gdb_stub_breakpoint is available for this architecture. Write one."
+#endif
diff --git a/src/include/console/gdb.h b/src/include/console/gdb.h
new file mode 100644
index 0000000..b3eca0a
--- /dev/null
+++ b/src/include/console/gdb.h
@@ -0,0 +1,6 @@
+#ifndef CONSOLE_GDB_H
+#define CONSOLE_GDB_H
+
+void gdb_stub_breakpoint(void);
+
+#endif /* CONSOLE_GDB_H */
More information about the coreboot-gerrit
mailing list