From bf56e64a4c564cd31300ccea8dbaf84670800e6a Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 25 Feb 2018 18:42:59 +0000 Subject: [PATCH] Add support for booting into kdb on arm platforms when the RB_KDB is set (using "boot -d" at the loader propmt or setting boot_ddb in loader.conf). Submitted by: Thomas Skibo Differential Revision: https://reviews.freebsd.org/D14428 --- sys/arm/arm/machdep.c | 15 +++++++++++++-- sys/arm/arm/machdep_boot.c | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index 491850130ba7..1d65b12b5a63 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -785,6 +786,16 @@ set_stackptrs(int cpu) } #endif +static void +arm_kdb_init(void) +{ + + kdb_init(); +#ifdef KDB + if (boothowto & RB_KDB) + kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); +#endif +} #ifdef FDT #if __ARM_ARCH < 6 @@ -1054,7 +1065,7 @@ initarm(struct arm_boot_params *abp) init_param2(physmem); dbg_monitor_init(); - kdb_init(); + arm_kdb_init(); return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP - sizeof(struct pcb))); @@ -1263,7 +1274,7 @@ initarm(struct arm_boot_params *abp) /* Init message buffer. */ msgbufinit(msgbufp, msgbufsize); dbg_monitor_init(); - kdb_init(); + arm_kdb_init(); /* Apply possible BP hardening. */ cpuinfo_init_bp_hardening(); return ((void *)STACKALIGN(thread0.td_pcb)); diff --git a/sys/arm/arm/machdep_boot.c b/sys/arm/arm/machdep_boot.c index adb15f427be3..eb53967527e0 100644 --- a/sys/arm/arm/machdep_boot.c +++ b/sys/arm/arm/machdep_boot.c @@ -27,6 +27,7 @@ */ #include "opt_platform.h" +#include "opt_ddb.h" #include __FBSDID("$FreeBSD$"); @@ -57,6 +58,10 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef DDB +#include +#endif + #ifdef DEBUG #define debugf(fmt, args...) printf(fmt, ##args) #else