mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-01-31 19:33:04 +08:00
add support for RT-Thread
This commit is contained in:
parent
50d2402bf8
commit
361817d84d
@ -219,6 +219,19 @@ extern void __freertos_evr_on_task_switched_in(void *ptTCB, unsigned int uxTopPr
|
||||
|
||||
</Pre_Include_Global_h>
|
||||
</component>
|
||||
|
||||
<component Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
|
||||
<description>A Patch for RT-Thread</description>
|
||||
<files>
|
||||
<file category="source" name="lib/perf_os_patch_rt_thread.c"/>
|
||||
</files>
|
||||
<Pre_Include_Global_h>
|
||||
|
||||
//! \brief Enable RTOS Patch for perf_counter
|
||||
#define __PERF_CNT_USE_RTOS__
|
||||
</Pre_Include_Global_h>
|
||||
</component>
|
||||
|
||||
</bundle>
|
||||
</components>
|
||||
|
||||
|
Binary file not shown.
@ -16,7 +16,7 @@
|
||||
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
|
||||
|
||||
<releases>
|
||||
<release date="2021-12-23" version="1.7.2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.7.2.pack">
|
||||
<release date="2021-12-27" version="1.7.2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.7.2.pack">
|
||||
- Add support for RT-Thread
|
||||
- Other minor update
|
||||
</release>
|
||||
@ -101,6 +101,11 @@
|
||||
<require Cclass="Utilities" Cgroup="perf_counter" Csub="Core"/>
|
||||
</condition>
|
||||
|
||||
<condition id="perf_counter">
|
||||
<description>Require Perf_Counter Core</description>
|
||||
<require Cclass="Utilities" Cgroup="perf_counter" Csub="Core"/>
|
||||
</condition>
|
||||
|
||||
<condition id="Cortex-M Arm GCC">
|
||||
<description>Compile Cortex-M Processors with GNU Tools for Arm Embedded Processors.</description>
|
||||
<require condition="Arm GCC"/>
|
||||
@ -192,7 +197,7 @@
|
||||
</Pre_Include_Global_h>
|
||||
</component>
|
||||
|
||||
<component Cgroup="perf_counter" Csub="FreeRTOS Patch">
|
||||
<component Cgroup="perf_counter" Csub="FreeRTOS Patch" condition="perf_counter">
|
||||
<description>A Patch for FreeRTOS</description>
|
||||
<files>
|
||||
<file category="source" name="lib/perf_os_patch_freertos.c"/>
|
||||
@ -214,6 +219,19 @@ extern void __freertos_evr_on_task_switched_in(void *ptTCB, unsigned int uxTopPr
|
||||
|
||||
</Pre_Include_Global_h>
|
||||
</component>
|
||||
|
||||
<component Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
|
||||
<description>A Patch for RT-Thread</description>
|
||||
<files>
|
||||
<file category="source" name="lib/perf_os_patch_rt_thread.c"/>
|
||||
</files>
|
||||
<Pre_Include_Global_h>
|
||||
|
||||
//! \brief Enable RTOS Patch for perf_counter
|
||||
#define __PERF_CNT_USE_RTOS__
|
||||
</Pre_Include_Global_h>
|
||||
</component>
|
||||
|
||||
</bundle>
|
||||
</components>
|
||||
|
||||
|
@ -75,7 +75,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>7</CpuCode>
|
||||
<DebugOpt>
|
||||
@ -287,7 +287,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>7</CpuCode>
|
||||
<DebugOpt>
|
||||
|
@ -1887,8 +1887,8 @@
|
||||
<targetInfo name="library"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
<component Cclass="Utilities" Cgroup="Performance" Csub="perf_counter" Cvendor="GorgonMeducer" Cversion="1.6.0">
|
||||
<package name="perf_counter" schemaVersion="1.4" url="" vendor="GorgonMeducer" version="1.6.0"/>
|
||||
<component Cbundle="Performance Counter" Cclass="Utilities" Cgroup="perf_counter" Csub="Core" Cvariant="Library" Cvendor="GorgonMeducer" Cversion="1.7.2">
|
||||
<package name="perf_counter" schemaVersion="1.4" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/" vendor="GorgonMeducer" version="1.7.2"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="example_arm compiler_5"/>
|
||||
<targetInfo name="example_arm_compiler_6"/>
|
||||
|
@ -55,6 +55,7 @@ PACK_BASE_FILES="
|
||||
systick_wrapper_ual.s
|
||||
perf_os_patch_rtx5.c
|
||||
perf_os_patch_freertos.c
|
||||
perf_os_patch_rt_thread.c
|
||||
LICENSE
|
||||
README.md
|
||||
"
|
||||
@ -141,6 +142,7 @@ cp -f ./$PACK_VENDOR.$PACK_NAME.pdsc ${PACK_BUILD}
|
||||
|
||||
cp -f ./perf_os_patch_rtx5.c ./lib
|
||||
cp -f ./perf_os_patch_freertos.c ./lib
|
||||
cp -f ./perf_os_patch_rt_thread.c ./lib
|
||||
cp -f ./perf_counter.h ./lib
|
||||
|
||||
# directories
|
||||
|
Binary file not shown.
84
lib/perf_os_patch_rt_thread.c
Normal file
84
lib/perf_os_patch_rt_thread.c
Normal file
@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* Copyright 2021 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
|
||||
* *
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); *
|
||||
* you may not use this file except in compliance with the License. *
|
||||
* You may obtain a copy of the License at *
|
||||
* *
|
||||
* http://www.apache.org/licenses/LICENSE-2.0 *
|
||||
* *
|
||||
* Unless required by applicable law or agreed to in writing, software *
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, *
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
|
||||
* See the License for the specific language governing permissions and *
|
||||
* limitations under the License. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/*============================ INCLUDES ======================================*/
|
||||
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "perf_counter.h"
|
||||
#include "cmsis_compiler.h"
|
||||
|
||||
/*============================ MACROS ========================================*/
|
||||
|
||||
#undef __WRAP_FUNC
|
||||
#undef WRAP_FUNC
|
||||
#if defined(__IS_COMPILER_ARM_COMPILER__) && __IS_COMPILER_ARM_COMPILER__
|
||||
|
||||
# define __WRAP_FUNC(__NAME) $Sub$$##__NAME
|
||||
# define __ORIG_FUNC(__NAME) $Super$$##__NAME
|
||||
|
||||
#elif (defined(__IS_COMPILER_LLVM__) && __IS_COMPILER_LLVM__) \
|
||||
|| (defined(__IS_COMPILER_GCC__) && __IS_COMPILER_GCC__)
|
||||
|
||||
# define __WRAP_FUNC(__NAME) __wrap_##__NAME
|
||||
# define __ORIG_FUNC(__NAME) __real_##__NAME
|
||||
|
||||
#endif
|
||||
#define WRAP_FUNC(__NAME) __WRAP_FUNC(__NAME)
|
||||
#define ORIG_FUNC(__NAME) __ORIG_FUNC(__NAME)
|
||||
|
||||
struct __task_cycle_info_t {
|
||||
uint64_t dwLastTimeStamp;
|
||||
task_cycle_info_t tInfo;
|
||||
} ;
|
||||
|
||||
|
||||
#ifndef RT_USING_HOOK
|
||||
#error In order to use perf_counter:RT-Thread-Patch, please define RT_USING_HOOK\
|
||||
rtconfig.h. If you don't want to use this patch, please un-select it in RTE.
|
||||
#endif
|
||||
|
||||
/*============================ TYPES =========================================*/
|
||||
/*============================ GLOBAL VARIABLES ==============================*/
|
||||
/*============================ LOCAL VARIABLES ===============================*/
|
||||
/*============================ PROTOTYPES ====================================*/
|
||||
extern void __on_context_switch_in(uint32_t *pwStack);
|
||||
extern void __on_context_switch_out(uint32_t *pwStack);
|
||||
extern struct rt_thread *rt_current_thread;
|
||||
/*============================ IMPLEMENTATION ================================*/
|
||||
|
||||
void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread *to)
|
||||
{
|
||||
if (NULL != from) {
|
||||
__on_context_switch_out(from->stack_addr);
|
||||
}
|
||||
|
||||
__on_context_switch_in(to->stack_addr);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
void __perf_os_patch_init(void)
|
||||
{
|
||||
rt_scheduler_sethook(&__rt_thread_scheduler_hook);
|
||||
}
|
||||
#endif
|
||||
|
||||
task_cycle_info_t * get_rtos_task_cycle_info(void)
|
||||
{
|
||||
return &(((struct __task_cycle_info_t *)rt_current_thread->stack_addr)->tInfo);
|
||||
}
|
@ -213,6 +213,12 @@ void user_code_insert_to_systick_handler(void)
|
||||
s_lSystemClockCounts += wLoad;
|
||||
}
|
||||
|
||||
__WEAK
|
||||
void __perf_os_patch_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! \brief initialise cycle counter service
|
||||
*! and don't forget to tell the function whether the systick is already
|
||||
*! used by user applications.
|
||||
@ -241,6 +247,8 @@ void init_cycle_counter(bool bSysTickIsOccupied)
|
||||
extern void __ensure_systick_wrapper(void);
|
||||
__ensure_systick_wrapper();
|
||||
#endif
|
||||
|
||||
__perf_os_patch_init();
|
||||
}
|
||||
|
||||
/*! \brief try to start the performance counter
|
||||
|
84
perf_os_patch_rt_thread.c
Normal file
84
perf_os_patch_rt_thread.c
Normal file
@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* Copyright 2021 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
|
||||
* *
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); *
|
||||
* you may not use this file except in compliance with the License. *
|
||||
* You may obtain a copy of the License at *
|
||||
* *
|
||||
* http://www.apache.org/licenses/LICENSE-2.0 *
|
||||
* *
|
||||
* Unless required by applicable law or agreed to in writing, software *
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, *
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
|
||||
* See the License for the specific language governing permissions and *
|
||||
* limitations under the License. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/*============================ INCLUDES ======================================*/
|
||||
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "perf_counter.h"
|
||||
#include "cmsis_compiler.h"
|
||||
|
||||
/*============================ MACROS ========================================*/
|
||||
|
||||
#undef __WRAP_FUNC
|
||||
#undef WRAP_FUNC
|
||||
#if defined(__IS_COMPILER_ARM_COMPILER__) && __IS_COMPILER_ARM_COMPILER__
|
||||
|
||||
# define __WRAP_FUNC(__NAME) $Sub$$##__NAME
|
||||
# define __ORIG_FUNC(__NAME) $Super$$##__NAME
|
||||
|
||||
#elif (defined(__IS_COMPILER_LLVM__) && __IS_COMPILER_LLVM__) \
|
||||
|| (defined(__IS_COMPILER_GCC__) && __IS_COMPILER_GCC__)
|
||||
|
||||
# define __WRAP_FUNC(__NAME) __wrap_##__NAME
|
||||
# define __ORIG_FUNC(__NAME) __real_##__NAME
|
||||
|
||||
#endif
|
||||
#define WRAP_FUNC(__NAME) __WRAP_FUNC(__NAME)
|
||||
#define ORIG_FUNC(__NAME) __ORIG_FUNC(__NAME)
|
||||
|
||||
struct __task_cycle_info_t {
|
||||
uint64_t dwLastTimeStamp;
|
||||
task_cycle_info_t tInfo;
|
||||
} ;
|
||||
|
||||
|
||||
#ifndef RT_USING_HOOK
|
||||
#error In order to use perf_counter:RT-Thread-Patch, please define RT_USING_HOOK\
|
||||
rtconfig.h. If you don't want to use this patch, please un-select it in RTE.
|
||||
#endif
|
||||
|
||||
/*============================ TYPES =========================================*/
|
||||
/*============================ GLOBAL VARIABLES ==============================*/
|
||||
/*============================ LOCAL VARIABLES ===============================*/
|
||||
/*============================ PROTOTYPES ====================================*/
|
||||
extern void __on_context_switch_in(uint32_t *pwStack);
|
||||
extern void __on_context_switch_out(uint32_t *pwStack);
|
||||
extern struct rt_thread *rt_current_thread;
|
||||
/*============================ IMPLEMENTATION ================================*/
|
||||
|
||||
void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread *to)
|
||||
{
|
||||
if (NULL != from) {
|
||||
__on_context_switch_out(from->stack_addr);
|
||||
}
|
||||
|
||||
__on_context_switch_in(to->stack_addr);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
void __perf_os_patch_init(void)
|
||||
{
|
||||
rt_scheduler_sethook(&__rt_thread_scheduler_hook);
|
||||
}
|
||||
#endif
|
||||
|
||||
task_cycle_info_t * get_rtos_task_cycle_info(void)
|
||||
{
|
||||
return &(((struct __task_cycle_info_t *)rt_current_thread->stack_addr)->tInfo);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user