[rtems commit] sapi: Add nanoseconds_per_tick to configuration

Sebastian Huber sebh at rtems.org
Thu Jun 14 12:17:33 UTC 2012


Module:    rtems
Branch:    master
Commit:    50fc8f65a6a7a602720af82af58b453dc663f082
Changeset: http://git.rtems.org/rtems/commit/?id=50fc8f65a6a7a602720af82af58b453dc663f082

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jun 13 09:44:32 2012 +0200

sapi: Add nanoseconds_per_tick to configuration

Add nanoseconds_per_tick to rtems_configuration_table.  This value will
be derived from the microseconds_per_tick value.  This avoids some
calculations at run-time.

---

 c/src/lib/libbsp/arm/nds/startup/bspstart.c |    2 +-
 cpukit/sapi/include/confdefs.h              |    1 +
 cpukit/sapi/include/rtems/config.h          |   15 ++++++++++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/c/src/lib/libbsp/arm/nds/startup/bspstart.c b/c/src/lib/libbsp/arm/nds/startup/bspstart.c
index 0fc67d3..59c074e 100644
--- a/c/src/lib/libbsp/arm/nds/startup/bspstart.c
+++ b/c/src/lib/libbsp/arm/nds/startup/bspstart.c
@@ -43,7 +43,7 @@ void bsp_start (void)
   arm_cpu_mode = 0x1f;
 
   /* configure clock period */
-  Configuration.microseconds_per_tick = 10000;  /* us */
+  rtems_configuration_set_microseconds_per_tick (10000);
 
   defaultExceptionHandler ();
 }
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 0f804ee..d4f21ca 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -2323,6 +2323,7 @@ rtems_fs_init_functions_t    rtems_fs_init_helper =
     CONFIGURE_STACK_SPACE_SIZE,               /* required stack space */
     CONFIGURE_MAXIMUM_USER_EXTENSIONS,        /* maximum dynamic extensions */
     CONFIGURE_MICROSECONDS_PER_TICK,          /* microseconds per clock tick */
+    1000 * CONFIGURE_MICROSECONDS_PER_TICK,   /* nanoseconds per clock tick */
     CONFIGURE_TICKS_PER_TIMESLICE,            /* ticks per timeslice quantum */
     CONFIGURE_IDLE_TASK_BODY,                 /* user's IDLE task */
     CONFIGURE_IDLE_TASK_STACK_SIZE,           /* IDLE task stack size */
diff --git a/cpukit/sapi/include/rtems/config.h b/cpukit/sapi/include/rtems/config.h
index 8bc5aea..58b350d 100644
--- a/cpukit/sapi/include/rtems/config.h
+++ b/cpukit/sapi/include/rtems/config.h
@@ -146,6 +146,13 @@ typedef struct {
    */
   uint32_t                       microseconds_per_tick;
 
+  /** This field specifies the number of nanoseconds which elapse
+   *  between clock ticks.  This value is derived from the
+   *  microseconds_per_tick field and provided to avoid calculation at
+   *  run-time.
+   */
+  uint32_t                       nanoseconds_per_tick;
+
   /** This field specifies the number of ticks in each task's timeslice.
    */
   uint32_t                       ticks_per_timeslice;
@@ -281,7 +288,13 @@ extern rtems_configuration_table  Configuration;
 #define rtems_configuration_get_milliseconds_per_tick() \
         (Configuration.microseconds_per_tick / 1000)
 #define rtems_configuration_get_nanoseconds_per_tick() \
-      (Configuration.microseconds_per_tick * 1000)
+        (Configuration.nanoseconds_per_tick)
+#define rtems_configuration_set_microseconds_per_tick( _us ) \
+        do { \
+          Configuration.microseconds_per_tick = (_us); \
+          Configuration.nanoseconds_per_tick = \
+            1000 * Configuration.microseconds_per_tick; \
+        } while (0)
 
 #define rtems_configuration_get_ticks_per_timeslice() \
         (Configuration.ticks_per_timeslice)




More information about the vc mailing list