[rtems commit] riscv: Implement CPU counter
Sebastian Huber
sebh at rtems.org
Fri Jul 6 12:28:27 UTC 2018
Module: rtems
Branch: master
Commit: dd32e2b2d009de525c1a4ad488899fab355d8fed
Changeset: http://git.rtems.org/rtems/commit/?id=dd32e2b2d009de525c1a4ad488899fab355d8fed
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Jul 6 08:12:40 2018 +0200
riscv: Implement CPU counter
Update #3433.
---
bsps/riscv/riscv/clock/clockdrv.c | 12 ++----------
cpukit/score/cpu/riscv/Makefile.am | 1 -
cpukit/score/cpu/riscv/include/rtems/score/cpu.h | 17 ++++++++++++++++-
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/bsps/riscv/riscv/clock/clockdrv.c b/bsps/riscv/riscv/clock/clockdrv.c
index 6a5d2db..d2d7a40 100644
--- a/bsps/riscv/riscv/clock/clockdrv.c
+++ b/bsps/riscv/riscv/clock/clockdrv.c
@@ -87,11 +87,6 @@ static uint32_t riscv_clock_get_timecount(struct timecounter *tc)
return clint->mtime.val_32[0];
}
-CPU_Counter_ticks _CPU_Counter_read(void)
-{
- return riscv_clock_get_timecount(NULL);
-}
-
static uint32_t riscv_clock_get_timebase_frequency(const void *fdt)
{
int node;
@@ -131,12 +126,9 @@ static void riscv_clock_initialize(void)
rtems_timecounter_install(&riscv_clock_tc);
}
-CPU_Counter_ticks _CPU_Counter_difference(
- CPU_Counter_ticks second,
- CPU_Counter_ticks first
-)
+uint32_t _CPU_Counter_frequency( void )
{
- return second - first;
+ return riscv_clock_get_timebase_frequency(bsp_fdt_get());
}
#define Clock_driver_support_at_tick() riscv_clock_at_tick()
diff --git a/cpukit/score/cpu/riscv/Makefile.am b/cpukit/score/cpu/riscv/Makefile.am
index e771468..3630c03 100644
--- a/cpukit/score/cpu/riscv/Makefile.am
+++ b/cpukit/score/cpu/riscv/Makefile.am
@@ -2,7 +2,6 @@ include $(top_srcdir)/automake/compile.am
noinst_LIBRARIES = libscorecpu.a
libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
libscorecpu_a_SOURCES = cpu.c
-libscorecpu_a_SOURCES += ../no_cpu/cpucounterfrequency.c
libscorecpu_a_SOURCES += riscv-exception-handler.S
libscorecpu_a_SOURCES += riscv-exception-default.c
libscorecpu_a_SOURCES += riscv-exception-frame-print.c
diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
index e79ce25..f84395c 100644
--- a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
@@ -370,7 +370,22 @@ typedef uint32_t CPU_Counter_ticks;
uint32_t _CPU_Counter_frequency( void );
-CPU_Counter_ticks _CPU_Counter_read( void );
+static inline CPU_Counter_ticks _CPU_Counter_read( void )
+{
+ unsigned long ticks;
+
+ __asm__ volatile ( "rdtime %0" : "=&r" ( ticks ) );
+
+ return (uint32_t) ticks;
+}
+
+static inline CPU_Counter_ticks _CPU_Counter_difference(
+ CPU_Counter_ticks second,
+ CPU_Counter_ticks first
+)
+{
+ return second - first;
+}
#ifdef RTEMS_SMP
More information about the vc
mailing list