Skip to content

Commit

Permalink
add PMU
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Jan 22, 2024
1 parent de7e506 commit f1b948a
Show file tree
Hide file tree
Showing 6 changed files with 1,038 additions and 12 deletions.
35 changes: 33 additions & 2 deletions GorgonMeducer.perf_counter.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,18 @@
<description>Require Perf_Counter Core</description>
<require Cclass="Utilities" Cgroup="perf_counter" Csub="Core"/>
</condition>


<condition id="PMU Devices">
<description>Require Perf_Counter Core</description>
<require condition="perf_counter" />
<accept Dcore="ARMV8MML"/>
<accept Dcore="ARMV81MML"/>
<accept Dcore="Cortex-M33"/>
<accept Dcore="Cortex-M35P"/>
<accept Dcore="Cortex-M55"/>
<accept Dcore="Cortex-M85"/>
</condition>

<condition id="Cortex-M Arm GCC">
<description>Compile Cortex-M Processors with GNU Tools for Arm Embedded Processors.</description>
<require condition="Arm GCC"/>
Expand Down Expand Up @@ -291,7 +302,7 @@
</RTE_Components_h>
</component>

<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="Porting" Cvariant="User Defined" isDefaultVariant="true" condition="perf_counter">
<component Cclass="Utilities" Cversion="1.0.2" Cgroup="perf_counter" Csub="Porting" Cvariant="User Defined" isDefaultVariant="false" condition="perf_counter">
<description>A user define system timer</description>
<files>
<file category="sourceC" name="template/perfc_port_user.c" attr="config" version="1.0.2"/>
Expand All @@ -311,6 +322,26 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="1.0.0" Cgroup="perf_counter" Csub="Porting" Cvariant="PMU" isDefaultVariant="true" condition="PMU Devices">
<description>Using the Performande Monitor Unit</description>
<files>
<file category="sourceC" name="perfc_port_pmu.c"/>
<file category="header" name="perfc_port_pmu.h"/>
</files>
<RTE_Components_h>

#define __RTE_PERFC_PORTING_PMU__ 1
</RTE_Components_h>

<Pre_Include_Global_h>

#define __PERFC_USE_PMU_PORTING__ 1
#define __PERFC_CFG_DISABLE_DEFAULT_SYSTICK_PORTING__ 1
#define __PERFC_CFG_PORTING_INCLUDE__ "perfc_port_pmu.h"

</Pre_Include_Global_h>
</component>


<component Cclass="Utilities" Cgroup="perf_counter" Csub="Benchmark" Cvariant="Coremark" Cversion="1.1.2" condition="perf_counter">
<description>Coremark</description>
Expand Down
19 changes: 12 additions & 7 deletions perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ volatile static uint32_t s_wMSResidule = 0;
volatile static uint32_t s_wUSResidule = 0;
volatile static int64_t s_lSystemMS = 0;
volatile static int64_t s_lSystemUS = 0;
volatile static int64_t s_lEventRecorderOffset = 0;

volatile static int64_t s_lSystemClockCounts = 0;

Expand Down Expand Up @@ -239,22 +240,25 @@ void delay_us(uint32_t wUs)
while(get_system_ticks() < lUs);
}


volatile int64_t observer;
void delay_ms(uint32_t wMs)
{
int64_t lUs = (int64_t)wMs * (int64_t)s_wMSUnit;
int64_t lMs = (int64_t)wMs * (int64_t)s_wMSUnit;
int32_t iCompensate = g_nOffset > PERF_CNT_DELAY_US_COMPENSATION
? g_nOffset
: PERF_CNT_DELAY_US_COMPENSATION;

if (lUs <= iCompensate) {
if (lMs <= iCompensate) {
return ;
}

lUs -= iCompensate;
lMs -= iCompensate;

lUs += get_system_ticks();
while(get_system_ticks() < lUs);
lMs += get_system_ticks();
do {
observer = get_system_ticks();
} while(observer < lMs);
//while(get_system_ticks() < lUs);
}

__attribute__((noinline))
Expand Down Expand Up @@ -391,6 +395,7 @@ bool __perfc_is_time_out(int64_t lPeriod, int64_t *plTimestamp, bool bAutoReload
uint32_t EventRecorderTimerSetup (void)
{
/* doing nothing at all */
s_lEventRecorderOffset = get_system_ticks();
return 1;
}

Expand All @@ -405,7 +410,7 @@ uint32_t EventRecorderTimerGetFreq (void)
/// \return timer count (32-bit)
uint32_t EventRecorderTimerGetCount (void)
{
return get_system_ticks();
return get_system_ticks() - s_lEventRecorderOffset;
}


Expand Down
4 changes: 2 additions & 2 deletions perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ __asm(".global __ensure_systick_wrapper\n\t");
__perf_counter_printf__( \
"--------------------------------------------\r\n"); \
__perf_counter_printf__( \
__STR " total cycle count: %ld [%016lx]\r\n", \
(long)_, (long)_); \
__STR " total cycle count: %lld [%016llx]\r\n", \
_, _); \
} else { \
__VA_ARGS__ \
}; \
Expand Down
Loading

0 comments on commit f1b948a

Please sign in to comment.