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>
<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.
- Enhance RTOS support
- Add macro __PERF_COUNTER__ in RTE_Components.h for compile-time detection.
@ -143,7 +143,7 @@
-->
<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>
<doc></doc>
<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>
<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.
- Enhance RTOS support
- Add macro __PERF_COUNTER__ in RTE_Components.h for compile-time detection.
@ -143,7 +143,7 @@
-->
<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>
<doc></doc>
<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"
/* 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__
/* Keil.ARM Compiler::Compiler:I/O:STDOUT:User:1.2.0 */
#define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */

View File

@ -16,7 +16,7 @@
*/
#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__

View File

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

File diff suppressed because one or more lines are too long

View File

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

Binary file not shown.

View File

@ -30,7 +30,7 @@
#define __PERF_COUNTER_VER_MAJOR__ 1
#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 \
+__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
*! \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
*!
*! \param ptInfo the address of target task_cycle_info_t object
*! \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
*!
@ -424,7 +424,7 @@ extern bool disable_task_cycle_info(task_cycle_info_t *ptInfo)
*! \param bEnabledStatus the previous status
*/
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
*!
@ -444,8 +444,10 @@ task_cycle_info_agent_t *
unregister_task_cycle_agent(task_cycle_info_agent_t *ptAgent);
/*! \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
*! start point
@ -453,17 +455,33 @@ extern void start_task_cycle_counter(void);
*! \note you can call stop_cycle_counter() multiple times following one
*! 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.
*/
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)
# define start_task_cycle_counter start_cycle_counter
# define stop_task_cycle_counter stop_cycle_counter
# define start_task_cycle_counter(...) start_cycle_counter()
# define stop_task_cycle_counter(...) stop_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
/*----------------------------------------------------------------------------*

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 *)get_rtos_task_cycle_info();
@ -604,10 +604,16 @@ void start_task_cycle_counter(void)
__IRQ_SAFE {
ptRootAgent->lLastTimeStamp = get_system_ticks();
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 *)get_rtos_task_cycle_info();
@ -616,10 +622,20 @@ int64_t stop_task_cycle_counter(void)
}
int64_t lCycles = 0;
int64_t lCycleUsed;
__IRQ_SAFE {
lCycles = ptRootAgent->tInfo.lUsedTotal
+ (get_system_ticks() - ptRootAgent->lLastTimeStamp);
lCycleUsed = 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;

View File

@ -30,7 +30,7 @@
#define __PERF_COUNTER_VER_MAJOR__ 1
#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 \
+__PERF_COUNTER_VER_MINOR__ * 100ul \
@ -444,8 +444,10 @@ task_cycle_info_agent_t *
unregister_task_cycle_agent(task_cycle_info_agent_t *ptAgent);
/*! \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
*! start point
@ -453,17 +455,33 @@ extern void start_task_cycle_counter(void);
*! \note you can call stop_cycle_counter() multiple times following one
*! 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.
*/
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)
# define start_task_cycle_counter start_cycle_counter
# define stop_task_cycle_counter stop_cycle_counter
# define start_task_cycle_counter(...) start_cycle_counter()
# define stop_task_cycle_counter(...) stop_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
/*----------------------------------------------------------------------------*