From 70a8d1d4656bc678ddada5e56263c9cb4423a623 Mon Sep 17 00:00:00 2001 From: Shell Date: Sat, 21 Oct 2023 20:14:45 +0800 Subject: [kservice] improve backtrace service in kernel (#8144) Signed-off-by: Shell --- include/rthw.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'include/rthw.h') diff --git a/include/rthw.h b/include/rthw.h index ed512ac14f..65764d5635 100644 --- a/include/rthw.h +++ b/include/rthw.h @@ -13,6 +13,7 @@ * 2018-11-17 Jesven add rt_hw_spinlock_t * add smp support * 2019-05-18 Bernard add empty definition for not enable cache case + * 2023-10-16 Shell Support a new backtrace framework */ #ifndef __RT_HW_H__ @@ -20,6 +21,10 @@ #include +#if defined (RT_USING_CACHE) || defined(RT_USING_SMP) +#include /* include spinlock, cache ops, etc. */ +#endif + #ifdef __cplusplus extern "C" { #endif @@ -145,9 +150,20 @@ void rt_hw_context_switch_to(rt_ubase_t to); void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to, rt_thread_t from_thread, rt_thread_t to_thread); #endif /*RT_USING_SMP*/ +/** + * Hardware Layer Backtrace Service + */ +struct rt_hw_backtrace_frame { + rt_base_t fp; + rt_base_t pc; +}; + +rt_err_t rt_hw_backtrace_frame_get(rt_thread_t thread, struct rt_hw_backtrace_frame *frame); + +rt_err_t rt_hw_backtrace_frame_unwind(rt_thread_t thread, struct rt_hw_backtrace_frame *frame); + void rt_hw_console_output(const char *str); -void rt_hw_backtrace(rt_uint32_t *fp, rt_ubase_t thread_entry); void rt_hw_show_memory(rt_uint32_t addr, rt_size_t size); /* @@ -170,7 +186,6 @@ void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask); #endif #ifdef RT_USING_SMP -#include /* for spinlock from arch */ struct rt_spinlock { @@ -216,9 +231,7 @@ struct rt_spinlock }; #endif -#ifdef RT_USING_CACHE -#include -#else +#ifndef RT_USING_CACHE #define rt_hw_isb() #define rt_hw_dmb() #define rt_hw_dsb() -- cgit v1.3.1