As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>. This patch proposes to then include <zephyr/kernel.h> instead of <zephyr/zephyr.h> since it is more clear that you are including the Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a catch-all header that may be confusing. Most applications need to include a bunch of other things to compile, e.g. driver headers or subsystem headers like BT, logging, etc. The idea of a catch-all header in Zephyr is probably not feasible anyway. Reason is that Zephyr is not a library, like it could be for example `libpython`. Zephyr provides many utilities nowadays: a kernel, drivers, subsystems, etc and things will likely grow. A catch-all header would be massive, difficult to keep up-to-date. It is also likely that an application will only build a small subset. Note that subsystem-level headers may use a catch-all approach to make things easier, though. NOTE: This patch is **NOT** removing the header, just removing its usage in-tree. I'd advocate for its deprecation (add a #warning on it), but I understand many people will have concerns. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
81 lines
1.3 KiB
C
81 lines
1.3 KiB
C
/*
|
|
* Copyright (c) 2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/kernel_structs.h>
|
|
#include <zephyr/init.h>
|
|
#include <ksched.h>
|
|
|
|
#include <SEGGER_SYSVIEW.h>
|
|
|
|
|
|
static uint32_t interrupt;
|
|
|
|
uint32_t sysview_get_timestamp(void)
|
|
{
|
|
return k_cycle_get_32();
|
|
}
|
|
|
|
uint32_t sysview_get_interrupt(void)
|
|
{
|
|
#ifdef CONFIG_CPU_CORTEX_M
|
|
interrupt = ((SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) >>
|
|
SCB_ICSR_VECTACTIVE_Pos);
|
|
#endif
|
|
return interrupt;
|
|
}
|
|
|
|
void sys_trace_k_thread_switched_in(void)
|
|
{
|
|
struct k_thread *thread;
|
|
|
|
thread = k_current_get();
|
|
|
|
if (z_is_idle_thread_object(thread)) {
|
|
SEGGER_SYSVIEW_OnIdle();
|
|
} else {
|
|
SEGGER_SYSVIEW_OnTaskStartExec((uint32_t)(uintptr_t)thread);
|
|
}
|
|
}
|
|
|
|
void sys_trace_k_thread_switched_out(void)
|
|
{
|
|
SEGGER_SYSVIEW_OnTaskStopExec();
|
|
}
|
|
|
|
void sys_trace_isr_enter(void)
|
|
{
|
|
SEGGER_SYSVIEW_RecordEnterISR();
|
|
}
|
|
|
|
void sys_trace_isr_exit(void)
|
|
{
|
|
SEGGER_SYSVIEW_RecordExitISR();
|
|
}
|
|
|
|
void sys_trace_isr_exit_to_scheduler(void)
|
|
{
|
|
SEGGER_SYSVIEW_RecordExitISRToScheduler();
|
|
}
|
|
|
|
void sys_trace_idle(void)
|
|
{
|
|
SEGGER_SYSVIEW_OnIdle();
|
|
}
|
|
|
|
static int sysview_init(const struct device *arg)
|
|
{
|
|
ARG_UNUSED(arg);
|
|
|
|
SEGGER_SYSVIEW_Conf();
|
|
if (IS_ENABLED(CONFIG_SEGGER_SYSTEMVIEW_BOOT_ENABLE)) {
|
|
SEGGER_SYSVIEW_Start();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
SYS_INIT(sysview_init, POST_KERNEL, 0);
|