mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-01-17 19:13:03 +08:00
support rt-thread
This commit is contained in:
parent
776059f701
commit
ead6f8b0a0
10
SConscript
10
SConscript
@ -1,18 +1,12 @@
|
|||||||
Import('rtconfig')
|
Import('rtconfig')
|
||||||
from building import *
|
from building import *
|
||||||
|
|
||||||
src = ['perf_counter.c', 'os/rt-thread/perf_os_patch_rt_thread.c']
|
src = ['perf_counter.c', 'os/perf_os_patch_rt_thread.c']
|
||||||
|
|
||||||
if rtconfig.PLATFORM in ['armcc', 'armclang']: # Keil-MDK
|
|
||||||
src += ['systick_wrapper_ual.s']
|
|
||||||
|
|
||||||
if rtconfig.PLATFORM == 'gcc':
|
|
||||||
src += ['systick_wrapper_gcc.s']
|
|
||||||
|
|
||||||
cwd = GetCurrentDir()
|
cwd = GetCurrentDir()
|
||||||
path = [cwd]
|
path = [cwd]
|
||||||
group = []
|
group = []
|
||||||
|
|
||||||
group = DefineGroup('perf_counter', src, depend = ['PKG_USING_PERFCOUNTER'], CPPPATH = path)
|
group = DefineGroup('perf_counter', src, depend = ['PKG_USING_PERF_COUNTER'], CPPDEFINES = ['__PERF_CNT_USE_RTOS__'], CPPPATH = path)
|
||||||
|
|
||||||
Return('group')
|
Return('group')
|
||||||
|
@ -52,8 +52,8 @@ struct __task_cycle_info_t {
|
|||||||
|
|
||||||
|
|
||||||
#ifndef RT_USING_HOOK
|
#ifndef RT_USING_HOOK
|
||||||
#error In order to use perf_counter:RT-Thread-Patch, please define RT_USING_HOOK\
|
#error "In order to use perf_counter:RT-Thread-Patch, please define RT_USING_HOOK \
|
||||||
in rtconfig.h. If you don't want to use this patch, please un-select it in RTE.
|
in rtconfig.h. If you don't want to use this patch, please un-select it in RTE."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -75,12 +75,34 @@ void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread *to)
|
|||||||
__on_context_switch_in(to->stack_addr);
|
__on_context_switch_in(to->stack_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __perf_os_patch_init(void)
|
|
||||||
{
|
|
||||||
rt_scheduler_sethook(&__rt_thread_scheduler_hook);
|
|
||||||
}
|
|
||||||
|
|
||||||
task_cycle_info_t * get_rtos_task_cycle_info(void)
|
task_cycle_info_t * get_rtos_task_cycle_info(void)
|
||||||
{
|
{
|
||||||
return &(((struct __task_cycle_info_t *)rt_current_thread->stack_addr)->tInfo);
|
return &(((struct __task_cycle_info_t *)rt_current_thread->stack_addr)->tInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __perf_os_patch_init(void)
|
||||||
|
{
|
||||||
|
#ifdef PKG_USING_PERF_COUNTER
|
||||||
|
rt_tick_sethook(user_code_insert_to_systick_handler);
|
||||||
|
#endif
|
||||||
|
rt_scheduler_sethook(__rt_thread_scheduler_hook);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PKG_USING_PERF_COUNTER
|
||||||
|
void __ensure_systick_wrapper(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DBG_TAG "perf_counter"
|
||||||
|
#define DBG_LVL DBG_INFO
|
||||||
|
#include <rtdbg.h>
|
||||||
|
|
||||||
|
static int _perf_counter_init(void)
|
||||||
|
{
|
||||||
|
extern uint32_t SystemCoreClock;
|
||||||
|
init_cycle_counter(true);
|
||||||
|
LOG_I("perf_counter init, SystemCoreClock:%d", SystemCoreClock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
INIT_PREV_EXPORT(_perf_counter_init);
|
||||||
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user