[rtems commit] or1ksim: Implement cpu counter functions.
Joel Sherrill
joel at rtems.org
Tue Sep 16 14:45:21 UTC 2014
Module: rtems
Branch: master
Commit: d2c76160578076e6d64156e7fd6820aae16b0294
Changeset: http://git.rtems.org/rtems/commit/?id=d2c76160578076e6d64156e7fd6820aae16b0294
Author: Hesham ALMatary <heshamelmatary at gmail.com>
Date: Mon Sep 15 17:33:31 2014 -0500
or1ksim: Implement cpu counter functions.
---
c/src/lib/libbsp/or1k/or1ksim/clock/clockdrv.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/c/src/lib/libbsp/or1k/or1ksim/clock/clockdrv.c b/c/src/lib/libbsp/or1k/or1ksim/clock/clockdrv.c
index 7358bf5..ad49d07 100644
--- a/c/src/lib/libbsp/or1k/or1ksim/clock/clockdrv.c
+++ b/c/src/lib/libbsp/or1k/or1ksim/clock/clockdrv.c
@@ -27,6 +27,9 @@
#define TTMR_NUM_OF_CLOCK_TICKS_INTERRUPT 0x09ED9
#define OR1KSIM_CLOCK_CYCLE_TIME_NANOSECONDS 10
+/* CPU counter */
+static CPU_Counter_ticks cpu_counter_ticks;
+
/* This prototype is added here to Avoid warnings */
void Clock_isr(void *arg);
@@ -46,6 +49,8 @@ static void or1ksim_clock_at_tick(void)
_OR1K_mtspr(CPU_OR1K_SPR_TTMR, TTMR);
_OR1K_mtspr(CPU_OR1K_SPR_TTCR, 0);
+
+ cpu_counter_ticks += TTMR_NUM_OF_CLOCK_TICKS_INTERRUPT;
}
static void or1ksim_clock_handler_install(proc_ptr new_isr, proc_ptr old_isr)
@@ -81,6 +86,9 @@ static void or1ksim_clock_initialize(void)
_OR1K_mtspr(CPU_OR1K_SPR_TTMR, TTMR);
_OR1K_mtspr(CPU_OR1K_SPR_TTCR, 0);
+
+ /* Initialize CPU Counter */
+ cpu_counter_ticks = 0;
}
static void or1ksim_clock_cleanup(void)
@@ -107,6 +115,22 @@ static uint32_t or1ksim_clock_nanoseconds_since_last_tick(void)
TTMR_NUM_OF_CLOCK_TICKS_INTERRUPT * OR1KSIM_CLOCK_CYCLE_TIME_NANOSECONDS;
}
+CPU_Counter_ticks _CPU_Counter_read(void)
+{
+ uint32_t ticks_since_last_timer_interrupt;
+
+ ticks_since_last_timer_interrupt = _OR1K_mfspr(CPU_OR1K_SPR_TTCR);
+
+ return cpu_counter_ticks + ticks_since_last_timer_interrupt;
+}
+
+CPU_Counter_ticks _CPU_Counter_difference(
+ CPU_Counter_ticks second,
+ CPU_Counter_ticks first
+)
+{
+ return second - first;
+}
#define Clock_driver_support_at_tick() or1ksim_clock_at_tick()
#define Clock_driver_support_initialize_hardware() or1ksim_clock_initialize()
More information about the vc
mailing list