The original idea of z_current_get() was to be the counterpart of k_current_get() when thread local variable for current has not been initialized if TLS is enabled, otherwise they are the same function. Now since z_current_get() is being used outside of core kernel, rename it under kernel namespace so other subsystem can conceptually use them too. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
/*
|
|
* Copyright (c) 2020 Lexmark International, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <tracing_user.h>
|
|
|
|
static int nested_interrupts[CONFIG_MP_MAX_NUM_CPUS];
|
|
|
|
void sys_trace_thread_switched_in_user(void)
|
|
{
|
|
unsigned int key = irq_lock();
|
|
|
|
__ASSERT_NO_MSG(nested_interrupts[_current_cpu->id] == 0);
|
|
/* Can't use k_current_get as thread base and z_tls_current might be incorrect */
|
|
printk("%s: %p\n", __func__, k_sched_current_thread_query());
|
|
|
|
irq_unlock(key);
|
|
}
|
|
|
|
void sys_trace_thread_switched_out_user(void)
|
|
{
|
|
unsigned int key = irq_lock();
|
|
|
|
__ASSERT_NO_MSG(nested_interrupts[_current_cpu->id] == 0);
|
|
/* Can't use k_current_get as thread base and z_tls_current might be incorrect */
|
|
printk("%s: %p\n", __func__, k_sched_current_thread_query());
|
|
|
|
irq_unlock(key);
|
|
}
|
|
|
|
void sys_trace_isr_enter_user(void)
|
|
{
|
|
unsigned int key = irq_lock();
|
|
_cpu_t *curr_cpu = _current_cpu;
|
|
|
|
printk("%s: %d\n", __func__, nested_interrupts[curr_cpu->id]);
|
|
nested_interrupts[curr_cpu->id]++;
|
|
|
|
irq_unlock(key);
|
|
}
|
|
|
|
void sys_trace_isr_exit_user(void)
|
|
{
|
|
unsigned int key = irq_lock();
|
|
_cpu_t *curr_cpu = _current_cpu;
|
|
|
|
nested_interrupts[curr_cpu->id]--;
|
|
printk("%s: %d\n", __func__, nested_interrupts[curr_cpu->id]);
|
|
|
|
irq_unlock(key);
|
|
}
|
|
|
|
void sys_trace_idle_user(void)
|
|
{
|
|
printk("%s\n", __func__);
|
|
}
|