diff --git a/arch/arm/core/aarch32/irq_manage.c b/arch/arm/core/aarch32/irq_manage.c index 13d59d8457d..918a8a8170c 100644 --- a/arch/arm/core/aarch32/irq_manage.c +++ b/arch/arm/core/aarch32/irq_manage.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include extern void z_arm_reserved(void); diff --git a/arch/arm/core/aarch64/irq_manage.c b/arch/arm/core/aarch64/irq_manage.c index e5717550bd9..edd27c1a065 100644 --- a/arch/arm/core/aarch64/irq_manage.c +++ b/arch/arm/core/aarch64/irq_manage.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/nios2/core/irq_manage.c b/arch/nios2/core/irq_manage.c index cd0ee540e8d..09ed2fd9ae5 100644 --- a/arch/nios2/core/irq_manage.c +++ b/arch/nios2/core/irq_manage.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include LOG_MODULE_DECLARE(os); diff --git a/arch/posix/core/cpuhalt.c b/arch/posix/core/cpuhalt.c index adae4182ac9..f43f0ed1864 100644 --- a/arch/posix/core/cpuhalt.c +++ b/arch/posix/core/cpuhalt.c @@ -22,7 +22,7 @@ #include "posix_core.h" #include -#include +#include void arch_cpu_idle(void) { diff --git a/arch/x86/core/cpuhalt.c b/arch/x86/core/cpuhalt.c index af6247fdbc5..f124f900bff 100644 --- a/arch/x86/core/cpuhalt.c +++ b/arch/x86/core/cpuhalt.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include void arch_cpu_idle(void) diff --git a/arch/x86/core/ia32/irq_manage.c b/arch/x86/core/ia32/irq_manage.c index c79a07251f2..25a87a10eb3 100644 --- a/arch/x86/core/ia32/irq_manage.c +++ b/arch/x86/core/ia32/irq_manage.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/xtensa/core/cpu_idle.c b/arch/xtensa/core/cpu_idle.c index 8f0c04a4c18..7ce4ca6c341 100644 --- a/arch/xtensa/core/cpu_idle.c +++ b/arch/xtensa/core/cpu_idle.c @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include void arch_cpu_idle(void) { diff --git a/boards/posix/native_posix/irq_handler.c b/boards/posix/native_posix/irq_handler.c index 9e15853dbdb..9099e70857d 100644 --- a/boards/posix/native_posix/irq_handler.c +++ b/boards/posix/native_posix/irq_handler.c @@ -18,7 +18,7 @@ #include "board_soc.h" #include "sw_isr_table.h" #include "soc.h" -#include +#include typedef void (*normal_irq_f_ptr)(void *); typedef int (*direct_irq_f_ptr)(void); diff --git a/boards/posix/nrf52_bsim/irq_handler.c b/boards/posix/nrf52_bsim/irq_handler.c index 43594d8c722..72ecd726022 100644 --- a/boards/posix/nrf52_bsim/irq_handler.c +++ b/boards/posix/nrf52_bsim/irq_handler.c @@ -17,7 +17,7 @@ #include "sw_isr_table.h" #include "soc.h" #include "bs_tracing.h" -#include +#include #include "bstests.h" static bool CPU_will_be_awaken_from_WFE; diff --git a/doc/guides/tracing/index.rst b/doc/guides/tracing/index.rst index e9e64ddf352..4c7447446b8 100644 --- a/doc/guides/tracing/index.rst +++ b/doc/guides/tracing/index.rst @@ -11,7 +11,7 @@ your application and allows enabled backends to visualize the inner-working of the kernel and various subsystems. Applications and tracing tools can create a backend that redefines the -macros declared in :zephyr_file:`include/debug/tracing.h` that are called +macros declared in :zephyr_file:`include/tracing/tracing.h` that are called across the kernel in key spots. .. doxygengroup:: tracing_apis diff --git a/include/arch/x86/ia32/arch.h b/include/arch/x86/ia32/arch.h index f200396125f..364f7ff54a6 100644 --- a/include/arch/x86/ia32/arch.h +++ b/include/arch/x86/ia32/arch.h @@ -239,7 +239,9 @@ static inline void arch_irq_direct_pm(void) #define ARCH_ISR_DIRECT_HEADER() arch_isr_direct_header() #define ARCH_ISR_DIRECT_FOOTER(swap) arch_isr_direct_footer(swap) -/* FIXME: debug/tracing.h cannot be included here due to circular dependency */ +/* FIXME: + * tracing/tracing.h cannot be included here due to circular dependency + */ #if defined(CONFIG_TRACING) extern void sys_trace_isr_enter(void); extern void sys_trace_isr_exit(void); diff --git a/include/debug/tracing.h b/include/debug/tracing.h index 5425aafbe44..956359866f1 100644 --- a/include/debug/tracing.h +++ b/include/debug/tracing.h @@ -1,139 +1,12 @@ -/* - * Copyright (c) 2018 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef ZEPHYR_INCLUDE_DEBUG_TRACING_H_ -#define ZEPHYR_INCLUDE_DEBUG_TRACING_H_ + /* + * Copyright (c) 2020 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ -#include - -/* Below IDs are used with systemview, not final to the zephyr tracing API */ -#define SYS_TRACE_ID_OFFSET (32u) - -#define SYS_TRACE_ID_MUTEX_INIT (1u + SYS_TRACE_ID_OFFSET) -#define SYS_TRACE_ID_MUTEX_UNLOCK (2u + SYS_TRACE_ID_OFFSET) -#define SYS_TRACE_ID_MUTEX_LOCK (3u + SYS_TRACE_ID_OFFSET) -#define SYS_TRACE_ID_SEMA_INIT (4u + SYS_TRACE_ID_OFFSET) -#define SYS_TRACE_ID_SEMA_GIVE (5u + SYS_TRACE_ID_OFFSET) -#define SYS_TRACE_ID_SEMA_TAKE (6u + SYS_TRACE_ID_OFFSET) - -#ifdef CONFIG_SEGGER_SYSTEMVIEW -#include "tracing_sysview.h" - -#elif defined CONFIG_TRACING_CPU_STATS -#include "tracing_cpu_stats.h" - -#elif defined CONFIG_TRACING_CTF -#include "tracing_ctf.h" - -#elif defined CONFIG_TRACING_TEST -#include "tracing_test.h" - -#else - -/** - * @brief Tracing APIs - * @defgroup tracing_apis Tracing APIs - * @{ - */ -/** - * @brief Called before a thread has been selected to run - */ -#define sys_trace_thread_switched_out() - -/** - * @brief Called after a thread has been selected to run - */ -#define sys_trace_thread_switched_in() - -/** - * @brief Called when setting priority of a thread - */ -#define sys_trace_thread_priority_set(thread) - -/** - * @brief Called when a thread is being created - */ -#define sys_trace_thread_create(thread) - -/** - * @brief Called when a thread is being aborted - * - */ -#define sys_trace_thread_abort(thread) - -/** - * @brief Called when a thread is being suspended - * @param thread Thread structure - */ -#define sys_trace_thread_suspend(thread) - -/** - * @brief Called when a thread is being resumed from suspension - * @param thread Thread structure - */ -#define sys_trace_thread_resume(thread) - -/** - * @brief Called when a thread is ready to run - * @param thread Thread structure - */ -#define sys_trace_thread_ready(thread) - -/** - * @brief Called when a thread is pending - * @param thread Thread structure - */ -#define sys_trace_thread_pend(thread) - -/** - * @brief Provide information about specific thread - * @param thread Thread structure - */ -#define sys_trace_thread_info(thread) - -/** - * @brief Called when a thread name is set - * @param thread Thread structure - */ -#define sys_trace_thread_name_set(thread) - -/** - * @brief Called when entering an ISR - */ -#define sys_trace_isr_enter() - -/** - * @brief Called when exiting an ISR - */ -#define sys_trace_isr_exit() - -/** - * @brief Called when exiting an ISR and switching to scheduler - */ -#define sys_trace_isr_exit_to_scheduler() - -/** - * @brief Can be called with any id signifying a new call - * @param id ID of the operation that was started - */ -#define sys_trace_void(id) - -/** - * @brief Can be called with any id signifying ending a call - * @param id ID of the operation that was completed - */ -#define sys_trace_end_call(id) - -/** - * @brief Called when the cpu enters the idle state - */ -#define sys_trace_idle() - -/** - * @} - */ +#ifndef ZEPHYR_INCLUDE_DEBUG_TRACING_H +#define ZEPHYR_INCLUDE_DEBUG_TRACING_H +#warning "This header file has moved, include instead." -#endif +#include #endif diff --git a/include/kernel.h b/include/kernel.h index 040626c3b60..f51fd3046bb 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -5357,7 +5357,7 @@ __syscall int k_float_disable(struct k_thread *thread); } #endif -#include +#include #include #endif /* !_ASMLANGUAGE */ diff --git a/include/tracing/tracing.h b/include/tracing/tracing.h new file mode 100644 index 00000000000..39f4b542af5 --- /dev/null +++ b/include/tracing/tracing.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2018 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_INCLUDE_TRACING_TRACING_H_ +#define ZEPHYR_INCLUDE_TRACING_TRACING_H_ + +#include + +/* Below IDs are used with systemview, not final to the zephyr tracing API */ +#define SYS_TRACE_ID_OFFSET (32u) + +#define SYS_TRACE_ID_MUTEX_INIT (1u + SYS_TRACE_ID_OFFSET) +#define SYS_TRACE_ID_MUTEX_UNLOCK (2u + SYS_TRACE_ID_OFFSET) +#define SYS_TRACE_ID_MUTEX_LOCK (3u + SYS_TRACE_ID_OFFSET) +#define SYS_TRACE_ID_SEMA_INIT (4u + SYS_TRACE_ID_OFFSET) +#define SYS_TRACE_ID_SEMA_GIVE (5u + SYS_TRACE_ID_OFFSET) +#define SYS_TRACE_ID_SEMA_TAKE (6u + SYS_TRACE_ID_OFFSET) + +#ifdef CONFIG_SEGGER_SYSTEMVIEW +#include "tracing_sysview.h" + +#elif defined CONFIG_TRACING_CPU_STATS +#include "tracing_cpu_stats.h" + +#elif defined CONFIG_TRACING_CTF +#include "tracing_ctf.h" + +#elif defined CONFIG_TRACING_TEST +#include "tracing_test.h" + +#else + +/** + * @brief Tracing APIs + * @defgroup tracing_apis Tracing APIs + * @{ + */ +/** + * @brief Called before a thread has been selected to run + */ +#define sys_trace_thread_switched_out() + +/** + * @brief Called after a thread has been selected to run + */ +#define sys_trace_thread_switched_in() + +/** + * @brief Called when setting priority of a thread + */ +#define sys_trace_thread_priority_set(thread) + +/** + * @brief Called when a thread is being created + */ +#define sys_trace_thread_create(thread) + +/** + * @brief Called when a thread is being aborted + * + */ +#define sys_trace_thread_abort(thread) + +/** + * @brief Called when a thread is being suspended + * @param thread Thread structure + */ +#define sys_trace_thread_suspend(thread) + +/** + * @brief Called when a thread is being resumed from suspension + * @param thread Thread structure + */ +#define sys_trace_thread_resume(thread) + +/** + * @brief Called when a thread is ready to run + * @param thread Thread structure + */ +#define sys_trace_thread_ready(thread) + +/** + * @brief Called when a thread is pending + * @param thread Thread structure + */ +#define sys_trace_thread_pend(thread) + +/** + * @brief Provide information about specific thread + * @param thread Thread structure + */ +#define sys_trace_thread_info(thread) + +/** + * @brief Called when a thread name is set + * @param thread Thread structure + */ +#define sys_trace_thread_name_set(thread) + +/** + * @brief Called when entering an ISR + */ +#define sys_trace_isr_enter() + +/** + * @brief Called when exiting an ISR + */ +#define sys_trace_isr_exit() + +/** + * @brief Called when exiting an ISR and switching to scheduler + */ +#define sys_trace_isr_exit_to_scheduler() + +/** + * @brief Can be called with any id signifying a new call + * @param id ID of the operation that was started + */ +#define sys_trace_void(id) + +/** + * @brief Can be called with any id signifying ending a call + * @param id ID of the operation that was completed + */ +#define sys_trace_end_call(id) + +/** + * @brief Called when the cpu enters the idle state + */ +#define sys_trace_idle() + +/** + * @} + */ + +#endif +#endif diff --git a/include/debug/tracing_format.h b/include/tracing/tracing_format.h similarity index 94% rename from include/debug/tracing_format.h rename to include/tracing/tracing_format.h index 48b0396e9e7..24acf8df6fd 100644 --- a/include/debug/tracing_format.h +++ b/include/tracing/tracing_format.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_INCLUDE_TRACE_FORMAT_H -#define ZEPHYR_INCLUDE_TRACE_FORMAT_H +#ifndef ZEPHYR_INCLUDE_TRACING_TRACING_FORMAT_H +#define ZEPHYR_INCLUDE_TRACING_TRACING_FORMAT_H #include diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 5d707056ccd..51509307092 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include BUILD_ASSERT(K_LOWEST_APPLICATION_THREAD_PRIO diff --git a/kernel/init.c b/kernel/init.c index 85f7d86c623..aba8cb5c1e3 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/kernel/mutex.c b/kernel/mutex.c index ecf9e135f66..fb40b87315b 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include /* We use a global spinlock here because some of the synchronization diff --git a/kernel/sem.c b/kernel/sem.c index 9b0514358ab..db317c80a77 100644 --- a/kernel/sem.c +++ b/kernel/sem.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include /* We use a system-wide lock to synchronize semaphores, which has diff --git a/kernel/thread.c b/kernel/thread.c index 54f932c7a91..43adff87c8d 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/soc/riscv/riscv-privilege/common/idle.c b/soc/riscv/riscv-privilege/common/idle.c index 3c7e4e291b8..cdb32436429 100644 --- a/soc/riscv/riscv-privilege/common/idle.c +++ b/soc/riscv/riscv-privilege/common/idle.c @@ -9,7 +9,7 @@ #include #include -#include +#include static ALWAYS_INLINE void riscv_idle(unsigned int key) { diff --git a/subsys/tracing/ctf/ctf_top.h b/subsys/tracing/ctf/ctf_top.h index d1abdef8948..39ed7b357e2 100644 --- a/subsys/tracing/ctf/ctf_top.h +++ b/subsys/tracing/ctf/ctf_top.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include /* Limit strings to 20 bytes to optimize bandwidth */ #define CTF_MAX_STRING_LEN 20 diff --git a/subsys/tracing/include/tracing_format_common.h b/subsys/tracing/include/tracing_format_common.h index e22b4a8d9d2..2451b6e569d 100644 --- a/subsys/tracing/include/tracing_format_common.h +++ b/subsys/tracing/include/tracing_format_common.h @@ -9,7 +9,7 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { diff --git a/tests/subsys/debug/tracing/src/tracing_string_format_test.c b/tests/subsys/debug/tracing/src/tracing_string_format_test.c index 5aeb3b116e6..ee0bdcaf163 100644 --- a/tests/subsys/debug/tracing/src/tracing_string_format_test.c +++ b/tests/subsys/debug/tracing/src/tracing_string_format_test.c @@ -6,7 +6,7 @@ #include #include -#include +#include void sys_trace_thread_switched_out(void) {