improve RTOS support

This commit is contained in:
Gabriel Wang 2022-02-13 20:04:40 +00:00
parent 5adb0af76e
commit 1f4bf7fcab
14 changed files with 103 additions and 49 deletions

View File

@ -16,7 +16,7 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository> <repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
<releases> <releases>
<release date="2022-01-29" version="1.9.0" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.0.pack"> <release date="2022-01-29" version="1.9.1" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.1.pack">
- Add preprocessing in perf_counter.h to detect whether GNU extension is enabled or not. - Add preprocessing in perf_counter.h to detect whether GNU extension is enabled or not.
- Enhance RTOS support - Enhance RTOS support
- Add macro __PERF_COUNTER__ in RTE_Components.h for compile-time detection. - Add macro __PERF_COUNTER__ in RTE_Components.h for compile-time detection.
@ -143,7 +143,7 @@
--> -->
<components> <components>
<bundle Cbundle="Performance Counter" Cclass="Utilities" Cversion="1.9.0"> <bundle Cbundle="Performance Counter" Cclass="Utilities" Cversion="1.9.1">
<description>A dedicated performance counter for Cortex-M systick.</description> <description>A dedicated performance counter for Cortex-M systick.</description>
<doc></doc> <doc></doc>
<component Cgroup="perf_counter" Csub="Core" Cvariant="Library" isDefaultVariant="true" condition="CMSIS-CORE"> <component Cgroup="perf_counter" Csub="Core" Cvariant="Library" isDefaultVariant="true" condition="CMSIS-CORE">

Binary file not shown.

View File

@ -16,7 +16,7 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository> <repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
<releases> <releases>
<release date="2022-01-29" version="1.9.0" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.0.pack"> <release date="2022-01-29" version="1.9.1" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.1.pack">
- Add preprocessing in perf_counter.h to detect whether GNU extension is enabled or not. - Add preprocessing in perf_counter.h to detect whether GNU extension is enabled or not.
- Enhance RTOS support - Enhance RTOS support
- Add macro __PERF_COUNTER__ in RTE_Components.h for compile-time detection. - Add macro __PERF_COUNTER__ in RTE_Components.h for compile-time detection.
@ -143,7 +143,7 @@
--> -->
<components> <components>
<bundle Cbundle="Performance Counter" Cclass="Utilities" Cversion="1.9.0"> <bundle Cbundle="Performance Counter" Cclass="Utilities" Cversion="1.9.1">
<description>A dedicated performance counter for Cortex-M systick.</description> <description>A dedicated performance counter for Cortex-M systick.</description>
<doc></doc> <doc></doc>
<component Cgroup="perf_counter" Csub="Core" Cvariant="Library" isDefaultVariant="true" condition="CMSIS-CORE"> <component Cgroup="perf_counter" Csub="Core" Cvariant="Library" isDefaultVariant="true" condition="CMSIS-CORE">

View File

@ -16,7 +16,7 @@
*/ */
#define CMSIS_device_header "ARMCM0.h" #define CMSIS_device_header "ARMCM0.h"
/* GorgonMeducer.Performance Counter::Utilities:perf_counter:Core:Library:1.9.0 */ /* GorgonMeducer.Performance Counter::Utilities:perf_counter:Core:Library:1.9.1 */
#define __PERF_COUNTER__ #define __PERF_COUNTER__
/* Keil.ARM Compiler::Compiler:I/O:STDOUT:User:1.2.0 */ /* Keil.ARM Compiler::Compiler:I/O:STDOUT:User:1.2.0 */
#define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */ #define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */

View File

@ -16,7 +16,7 @@
*/ */
#define CMSIS_device_header "ARMCM0.h" #define CMSIS_device_header "ARMCM0.h"
/* GorgonMeducer.Performance Counter::Utilities:perf_counter:Core:Library:1.9.0 */ /* GorgonMeducer.Performance Counter::Utilities:perf_counter:Core:Library:1.9.1 */
#define __PERF_COUNTER__ #define __PERF_COUNTER__

View File

@ -16,6 +16,8 @@
*/ */
#define CMSIS_device_header "ARMCM0.h" #define CMSIS_device_header "ARMCM0.h"
/* GorgonMeducer.Performance Counter::Utilities:perf_counter:Core:Library:1.9.1 */
#define __PERF_COUNTER__
#endif /* RTE_COMPONENTS_H */ #endif /* RTE_COMPONENTS_H */

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@
<View> <View>
<WinId>38003</WinId> <WinId>38003</WinId>
<ViewName>Registers</ViewName> <ViewName>Registers</ViewName>
<TableColWidths>188 122</TableColWidths> <TableColWidths>238 72</TableColWidths>
</View> </View>
<View> <View>
<WinId>346</WinId> <WinId>346</WinId>
@ -101,17 +101,17 @@
<yPos>-1</yPos> <yPos>-1</yPos>
</MaxPosition> </MaxPosition>
<NormalPosition> <NormalPosition>
<Top>0</Top> <Top>193</Top>
<Left>624</Left> <Left>1234</Left>
<Right>1671</Right> <Right>2281</Right>
<Bottom>859</Bottom> <Bottom>1052</Bottom>
</NormalPosition> </NormalPosition>
</WindowPosition> </WindowPosition>
<MDIClientArea> <MDIClientArea>
<RegID>0</RegID> <RegID>0</RegID>
<MDITabState> <MDITabState>
<Len>346</Len> <Len>346</Len>
<Data>01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000002000000000000000100000037453A5C53564E5C70726F6A656374735C4D43555C706572665F636F756E7465725F6C6962726172795C706572665F636F756E7465722E63000000000E706572665F636F756E7465722E6300000000C5D4F200FFFFFFFF37453A5C53564E5C70726F6A656374735C4D43555C706572665F636F756E7465725F6C6962726172795C706572665F636F756E7465722E68000000000E706572665F636F756E7465722E6800000000FFDC7800FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000000000000020000004401000066000000000A000098040000</Data> <Data>01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000002000000010000000100000037453A5C53564E5C70726F6A656374735C4D43555C706572665F636F756E7465725F6C6962726172795C706572665F636F756E7465722E63000000000E706572665F636F756E7465722E6300000000C5D4F200FFFFFFFF37453A5C53564E5C70726F6A656374735C4D43555C706572665F636F756E7465725F6C6962726172795C706572665F636F756E7465722E68000000000E706572665F636F756E7465722E6800000000FFDC7800FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000000000000020000004401000066000000000A000098040000</Data>
</MDITabState> </MDITabState>
</MDIClientArea> </MDIClientArea>
<ViewEx> <ViewEx>

Binary file not shown.

View File

@ -30,7 +30,7 @@
#define __PERF_COUNTER_VER_MAJOR__ 1 #define __PERF_COUNTER_VER_MAJOR__ 1
#define __PERF_COUNTER_VER_MINOR__ 9 #define __PERF_COUNTER_VER_MINOR__ 9
#define __PERF_COUNTER_VER_REVISE__ 0 #define __PERF_COUNTER_VER_REVISE__ 1
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \ #define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
+__PERF_COUNTER_VER_MINOR__ * 100ul \ +__PERF_COUNTER_VER_MINOR__ * 100ul \
@ -409,14 +409,14 @@ extern task_cycle_info_t *init_task_cycle_info(task_cycle_info_t *ptInfo);
*! \param ptInfo the address of target task_cycle_info_t object *! \param ptInfo the address of target task_cycle_info_t object
*! \return previous status *! \return previous status
*/ */
extern bool enable_task_cycle_info(task_cycle_info_t *ptInfo) extern bool enable_task_cycle_info(task_cycle_info_t *ptInfo);
/*! \brief disable a given task_cycle_info_t object /*! \brief disable a given task_cycle_info_t object
*! *!
*! \param ptInfo the address of target task_cycle_info_t object *! \param ptInfo the address of target task_cycle_info_t object
*! \return previous status *! \return previous status
*/ */
extern bool disable_task_cycle_info(task_cycle_info_t *ptInfo) extern bool disable_task_cycle_info(task_cycle_info_t *ptInfo);
/*! \brief resume the enabled status of a given task_cycle_info_t object /*! \brief resume the enabled status of a given task_cycle_info_t object
*! *!
@ -424,7 +424,7 @@ extern bool disable_task_cycle_info(task_cycle_info_t *ptInfo)
*! \param bEnabledStatus the previous status *! \param bEnabledStatus the previous status
*/ */
extern extern
void resume_task_cycle_info(task_cycle_info_t *ptInfo, bool bEnabledStatus) void resume_task_cycle_info(task_cycle_info_t *ptInfo, bool bEnabledStatus);
/*! \brief register a global virtual cycle counter agent to the current task /*! \brief register a global virtual cycle counter agent to the current task
*! *!
@ -444,8 +444,10 @@ task_cycle_info_agent_t *
unregister_task_cycle_agent(task_cycle_info_agent_t *ptAgent); unregister_task_cycle_agent(task_cycle_info_agent_t *ptAgent);
/*! \brief reset and start the virtual cycle counter for the current task /*! \brief reset and start the virtual cycle counter for the current task
*!
*! \param ptInfo the target task_cycle_info_t object
*/ */
extern void start_task_cycle_counter(void); extern void __start_task_cycle_counter(task_cycle_info_t *ptInfo);
/*! \brief calculate the elapsed cycle count for current task since the last /*! \brief calculate the elapsed cycle count for current task since the last
*! start point *! start point
@ -453,17 +455,33 @@ extern void start_task_cycle_counter(void);
*! \note you can call stop_cycle_counter() multiple times following one *! \note you can call stop_cycle_counter() multiple times following one
*! start_task_cycle_counter() *! start_task_cycle_counter()
*! *!
*! \param ptInfo the target task_cycle_info_t object
*!
*! \note When ptInfo is NULL, it returns current task cycle info, when ptInfo
*! is non-NULL, it returns the total used cycles of the specified
*! task_cycle_info_t object.
*!
*! \return the elapsed cycle count. *! \return the elapsed cycle count.
*/ */
extern int64_t stop_task_cycle_counter(void); extern int64_t __stop_task_cycle_counter(task_cycle_info_t *ptInfo);
#define start_task_cycle_counter(...) \
__start_task_cycle_counter((NULL,##__VA_ARGS__))
#define stop_task_cycle_counter(...) \
__stop_task_cycle_counter((NULL,##__VA_ARGS__))
#elif !defined(__IMPLEMENT_PERF_COUNTER) #elif !defined(__IMPLEMENT_PERF_COUNTER)
# define start_task_cycle_counter(...) start_cycle_counter()
# define start_task_cycle_counter start_cycle_counter # define stop_task_cycle_counter(...) stop_cycle_counter()
# define stop_task_cycle_counter stop_cycle_counter
# define init_task_cycle_counter() # define init_task_cycle_counter()
# define register_task_cycle_agent(...)
# define unregister_task_cycle_agent(...)
# define init_task_cycle_info(...) (NULL)
# define enable_task_cycle_info(...) (false)
# define disable_task_cycle_info(...) (false)
# define resume_task_cycle_info(...)
#endif #endif
/*----------------------------------------------------------------------------* /*----------------------------------------------------------------------------*

Binary file not shown.

View File

@ -593,7 +593,7 @@ void __on_context_switch_out(uint32_t *pwStack)
} }
} }
void start_task_cycle_counter(void) void __start_task_cycle_counter(task_cycle_info_t *ptInfo)
{ {
struct __task_cycle_info_t * ptRootAgent = struct __task_cycle_info_t * ptRootAgent =
(struct __task_cycle_info_t *)get_rtos_task_cycle_info(); (struct __task_cycle_info_t *)get_rtos_task_cycle_info();
@ -604,10 +604,16 @@ void start_task_cycle_counter(void)
__IRQ_SAFE { __IRQ_SAFE {
ptRootAgent->lLastTimeStamp = get_system_ticks(); ptRootAgent->lLastTimeStamp = get_system_ticks();
ptRootAgent->tInfo.lUsedTotal = 0; ptRootAgent->tInfo.lUsedTotal = 0;
if (NULL != ptInfo) {
ptInfo->lUsedTotal = 0;
ptInfo->bEnabled = true;
}
} }
} }
int64_t stop_task_cycle_counter(void)
int64_t __stop_task_cycle_counter(task_cycle_info_t *ptInfo)
{ {
struct __task_cycle_info_t * ptRootAgent = struct __task_cycle_info_t * ptRootAgent =
(struct __task_cycle_info_t *)get_rtos_task_cycle_info(); (struct __task_cycle_info_t *)get_rtos_task_cycle_info();
@ -616,10 +622,20 @@ int64_t stop_task_cycle_counter(void)
} }
int64_t lCycles = 0; int64_t lCycles = 0;
int64_t lCycleUsed;
__IRQ_SAFE { __IRQ_SAFE {
lCycles = ptRootAgent->tInfo.lUsedTotal lCycleUsed = get_system_ticks() - ptRootAgent->lLastTimeStamp;
+ (get_system_ticks() - ptRootAgent->lLastTimeStamp); lCycles = ptRootAgent->tInfo.lUsedTotal + lCycleUsed;
}
if (NULL != ptInfo) {
if (ptInfo->bEnabled) {
ptInfo->nUsedRecent = lCycleUsed;
ptInfo->lUsedTotal += lCycleUsed;
ptInfo->bEnabled = false;
}
return ptInfo->lUsedTotal;
} }
return lCycles; return lCycles;

View File

@ -30,7 +30,7 @@
#define __PERF_COUNTER_VER_MAJOR__ 1 #define __PERF_COUNTER_VER_MAJOR__ 1
#define __PERF_COUNTER_VER_MINOR__ 9 #define __PERF_COUNTER_VER_MINOR__ 9
#define __PERF_COUNTER_VER_REVISE__ 0 #define __PERF_COUNTER_VER_REVISE__ 1
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \ #define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
+__PERF_COUNTER_VER_MINOR__ * 100ul \ +__PERF_COUNTER_VER_MINOR__ * 100ul \
@ -444,8 +444,10 @@ task_cycle_info_agent_t *
unregister_task_cycle_agent(task_cycle_info_agent_t *ptAgent); unregister_task_cycle_agent(task_cycle_info_agent_t *ptAgent);
/*! \brief reset and start the virtual cycle counter for the current task /*! \brief reset and start the virtual cycle counter for the current task
*!
*! \param ptInfo the target task_cycle_info_t object
*/ */
extern void start_task_cycle_counter(void); extern void __start_task_cycle_counter(task_cycle_info_t *ptInfo);
/*! \brief calculate the elapsed cycle count for current task since the last /*! \brief calculate the elapsed cycle count for current task since the last
*! start point *! start point
@ -453,17 +455,33 @@ extern void start_task_cycle_counter(void);
*! \note you can call stop_cycle_counter() multiple times following one *! \note you can call stop_cycle_counter() multiple times following one
*! start_task_cycle_counter() *! start_task_cycle_counter()
*! *!
*! \param ptInfo the target task_cycle_info_t object
*!
*! \note When ptInfo is NULL, it returns current task cycle info, when ptInfo
*! is non-NULL, it returns the total used cycles of the specified
*! task_cycle_info_t object.
*!
*! \return the elapsed cycle count. *! \return the elapsed cycle count.
*/ */
extern int64_t stop_task_cycle_counter(void); extern int64_t __stop_task_cycle_counter(task_cycle_info_t *ptInfo);
#define start_task_cycle_counter(...) \
__start_task_cycle_counter((NULL,##__VA_ARGS__))
#define stop_task_cycle_counter(...) \
__stop_task_cycle_counter((NULL,##__VA_ARGS__))
#elif !defined(__IMPLEMENT_PERF_COUNTER) #elif !defined(__IMPLEMENT_PERF_COUNTER)
# define start_task_cycle_counter(...) start_cycle_counter()
# define start_task_cycle_counter start_cycle_counter # define stop_task_cycle_counter(...) stop_cycle_counter()
# define stop_task_cycle_counter stop_cycle_counter
# define init_task_cycle_counter() # define init_task_cycle_counter()
# define register_task_cycle_agent(...)
# define unregister_task_cycle_agent(...)
# define init_task_cycle_info(...) (NULL)
# define enable_task_cycle_info(...) (false)
# define disable_task_cycle_info(...) (false)
# define resume_task_cycle_info(...)
#endif #endif
/*----------------------------------------------------------------------------* /*----------------------------------------------------------------------------*