2019-01-30 08:19:24 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Oticon A/S
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zephyr.h>
|
|
|
|
#include <kernel_structs.h>
|
2019-09-22 02:54:37 +02:00
|
|
|
#include <kernel_internal.h>
|
2020-01-31 19:29:20 +01:00
|
|
|
#include <ctf_top.h>
|
2019-01-30 08:19:24 +01:00
|
|
|
|
|
|
|
void sys_trace_thread_switched_out(void)
|
|
|
|
{
|
|
|
|
struct k_thread *thread = k_current_get();
|
|
|
|
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_switched_out((uint32_t)(uintptr_t)thread);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_switched_in(void)
|
|
|
|
{
|
|
|
|
struct k_thread *thread = k_current_get();
|
|
|
|
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_switched_in((uint32_t)(uintptr_t)thread);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_priority_set(struct k_thread *thread)
|
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_priority_set((uint32_t)(uintptr_t)thread,
|
2019-09-16 19:24:07 +02:00
|
|
|
thread->base.prio);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_create(struct k_thread *thread)
|
|
|
|
{
|
|
|
|
ctf_bounded_string_t name = { "Unnamed thread" };
|
|
|
|
|
|
|
|
#if defined(CONFIG_THREAD_NAME)
|
2019-11-11 14:02:33 +01:00
|
|
|
const char *tname = k_thread_name_get(thread);
|
|
|
|
|
|
|
|
if (tname != NULL) {
|
|
|
|
strncpy(name.buf, tname, sizeof(name.buf));
|
2019-01-30 08:19:24 +01:00
|
|
|
/* strncpy may not always null-terminate */
|
|
|
|
name.buf[sizeof(name.buf) - 1] = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_thread_create(
|
2020-05-27 18:26:57 +02:00
|
|
|
(uint32_t)(uintptr_t)thread,
|
2019-01-30 08:19:24 +01:00
|
|
|
thread->base.prio,
|
|
|
|
name
|
|
|
|
);
|
|
|
|
|
|
|
|
#if defined(CONFIG_THREAD_STACK_INFO)
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_thread_info(
|
2020-05-27 18:26:57 +02:00
|
|
|
(uint32_t)(uintptr_t)thread,
|
2019-12-22 18:47:17 +01:00
|
|
|
thread->stack_info.start,
|
|
|
|
thread->stack_info.size
|
2019-01-30 08:19:24 +01:00
|
|
|
);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_abort(struct k_thread *thread)
|
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_abort((uint32_t)(uintptr_t)thread);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_suspend(struct k_thread *thread)
|
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_suspend((uint32_t)(uintptr_t)thread);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_resume(struct k_thread *thread)
|
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_resume((uint32_t)(uintptr_t)thread);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_ready(struct k_thread *thread)
|
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_ready((uint32_t)(uintptr_t)thread);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_pend(struct k_thread *thread)
|
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
ctf_top_thread_pend((uint32_t)(uintptr_t)thread);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_thread_info(struct k_thread *thread)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_THREAD_STACK_INFO)
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_thread_info(
|
2020-05-27 18:26:57 +02:00
|
|
|
(uint32_t)(uintptr_t)thread,
|
2020-01-31 20:51:48 +01:00
|
|
|
thread->stack_info.start,
|
|
|
|
thread->stack_info.size
|
2019-01-30 08:19:24 +01:00
|
|
|
);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-07-16 17:05:35 +02:00
|
|
|
void sys_trace_thread_name_set(struct k_thread *thread)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_THREAD_NAME)
|
|
|
|
ctf_bounded_string_t name = { "Unnamed thread" };
|
2019-11-11 14:02:33 +01:00
|
|
|
const char *tname = k_thread_name_get(thread);
|
2019-07-16 17:05:35 +02:00
|
|
|
|
2019-11-11 14:02:33 +01:00
|
|
|
if (tname != NULL) {
|
|
|
|
strncpy(name.buf, tname, sizeof(name.buf));
|
2019-07-16 17:05:35 +02:00
|
|
|
/* strncpy may not always null-terminate */
|
|
|
|
name.buf[sizeof(name.buf) - 1] = 0;
|
|
|
|
}
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_thread_name_set(
|
2020-05-27 18:26:57 +02:00
|
|
|
(uint32_t)(uintptr_t)thread,
|
2019-07-16 17:05:35 +02:00
|
|
|
name
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-01-30 08:19:24 +01:00
|
|
|
void sys_trace_isr_enter(void)
|
|
|
|
{
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_isr_enter();
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_isr_exit(void)
|
|
|
|
{
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_isr_exit();
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_isr_exit_to_scheduler(void)
|
|
|
|
{
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_isr_exit_to_scheduler();
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_idle(void)
|
|
|
|
{
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_idle();
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_void(unsigned int id)
|
|
|
|
{
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_void(id);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sys_trace_end_call(unsigned int id)
|
|
|
|
{
|
2019-09-16 19:24:07 +02:00
|
|
|
ctf_top_end_call(id);
|
2019-01-30 08:19:24 +01:00
|
|
|
}
|