[arch][arm-m] move the debugger structure out of kernel/thread

The arm-m specific debugger structure really should live in arm-m code,
so move it there to clean things up a bit.
This commit is contained in:
Travis Geiselbrecht
2023-12-16 16:44:25 -08:00
parent 74192acef5
commit 71a413dab4
3 changed files with 30 additions and 34 deletions

View File

@@ -6,6 +6,7 @@
* https://opensource.org/licenses/MIT
*/
#include <arch/arm/cm.h>
#include <kernel/thread.h>
#include <lk/compiler.h>
#include <stdint.h>
@@ -28,7 +29,30 @@ extern void _pendsv(void);
extern void _systick(void);
#if defined(WITH_DEBUGGER_INFO)
extern struct __debugger_info__ _debugger_info;
// Contains sufficient information for a remote debugger to walk
// the thread list without needing the symbols and debug sections in
// the elf binary for lk or the ability to parse them.
static const struct __debugger_info__ {
u32 version; // flags:16 major:8 minor:8
void *thread_list_ptr;
void *current_thread_ptr;
u8 off_list_node;
u8 off_state;
u8 off_saved_sp;
u8 off_was_preempted;
u8 off_name;
u8 off_waitq;
} _debugger_info = {
.version = 0x0100,
.thread_list_ptr = &thread_list,
.current_thread_ptr = &_current_thread,
.off_list_node = __builtin_offsetof(thread_t, thread_list_node),
.off_state = __builtin_offsetof(thread_t, state),
.off_saved_sp = __builtin_offsetof(thread_t, arch.sp),
.off_was_preempted = __builtin_offsetof(thread_t, arch.was_preempted),
.off_name = __builtin_offsetof(thread_t, name),
.off_waitq = __builtin_offsetof(thread_t, blocking_wait_queue),
};
#endif
// ARMv7m+ have more vectors than armv6m
@@ -49,6 +73,7 @@ const void *const __SECTION(".text.boot.vectab1") vectab[] = {
ARMV7M_VECTOR(_usagefault), // usage fault
0, // reserved
#if defined(WITH_DEBUGGER_INFO)
// stick a pointer to the debugger info structure in unused vectors
(void *) 0x52474244,
&_debugger_info,
#else
@@ -63,5 +88,3 @@ const void *const __SECTION(".text.boot.vectab1") vectab[] = {
_systick, // systick
};

View File

@@ -200,6 +200,9 @@ static inline void set_current_thread(thread_t *t) {
arch_set_current_thread(t);
}
/* list of all threads, unsafe to traverse without holding thread_lock */
extern struct list_node thread_list;
/* scheduler lock */
extern spin_lock_t thread_lock;

View File

@@ -45,7 +45,7 @@ struct thread_stats thread_stats[SMP_MAX_CPUS];
#define DEBUG_THREAD_CONTEXT_SWITCH 0
/* global thread list */
static struct list_node thread_list;
struct list_node thread_list;
/* master thread spinlock */
spin_lock_t thread_lock = SPIN_LOCK_INITIAL_VALUE;
@@ -1287,33 +1287,3 @@ status_t thread_unblock_from_wait_queue(thread_t *t, status_t wait_queue_error)
return NO_ERROR;
}
#if defined(WITH_DEBUGGER_INFO)
// This is, by necessity, arch-specific, and arm-m specific right now,
// but lives here due to thread_list being static.
//
// It contains sufficient information for a remote debugger to walk
// the thread list without needing the symbols and debug sections in
// the elf binary for lk or the ability to parse them.
const struct __debugger_info__ {
u32 version; // flags:16 major:8 minor:8
void *thread_list_ptr;
void *current_thread_ptr;
u8 off_list_node;
u8 off_state;
u8 off_saved_sp;
u8 off_was_preempted;
u8 off_name;
u8 off_waitq;
} _debugger_info = {
.version = 0x0100,
.thread_list_ptr = &thread_list,
.current_thread_ptr = &_current_thread,
.off_list_node = __builtin_offsetof(thread_t, thread_list_node),
.off_state = __builtin_offsetof(thread_t, state),
.off_saved_sp = __builtin_offsetof(thread_t, arch.sp),
.off_was_preempted = __builtin_offsetof(thread_t, arch.was_preempted),
.off_name = __builtin_offsetof(thread_t, name),
.off_waitq = __builtin_offsetof(thread_t, blocking_wait_queue),
};
#endif