summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-16 20:53:34 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-16 20:53:34 +0000
commit26fb4aadcd2c3159ecca7493c1f3d02cc02149ba (patch)
treee352a00acf541d65590f7c250b9fd9cd61f4e70d
parent2008-12-16 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-26fb4aadcd2c3159ecca7493c1f3d02cc02149ba.tar.bz2
2008-12-16 Joel Sherrill <joel.sherrill@oarcorp.com>
* libblock/src/bdbuf.c, libmisc/capture/capture-cli.c, libmisc/capture/capture.c, libmisc/mw-fb/mw_uid.c, rtems/include/rtems/rtems/support.h, score/Makefile.am, score/include/rtems/score/tod.h, score/src/coretod.c, score/src/coretodtickle.c: Eliminate all public use of TOD conversion routines. Eliminate _TOD_Microseconds_per_tick and let every place use the field directly from the Configuration Table. This required moving some methods from macros to bodies. * score/src/coretodmsecstoticks.c, score/src/coretodtickspersec.c, score/src/coretodusectoticks.c: New files.
-rw-r--r--cpukit/ChangeLog13
-rw-r--r--cpukit/libblock/src/bdbuf.c2
-rw-r--r--cpukit/libmisc/capture/capture-cli.c4
-rw-r--r--cpukit/libmisc/capture/capture.c2
-rw-r--r--cpukit/libmisc/mw-fb/mw_uid.c2
-rw-r--r--cpukit/rtems/include/rtems/rtems/support.h5
-rw-r--r--cpukit/score/Makefile.am3
-rw-r--r--cpukit/score/include/rtems/score/tod.h40
-rw-r--r--cpukit/score/src/coretod.c2
-rw-r--r--cpukit/score/src/coretodmsecstoticks.c25
-rw-r--r--cpukit/score/src/coretodtickle.c3
-rw-r--r--cpukit/score/src/coretodtickspersec.c24
-rw-r--r--cpukit/score/src/coretodusectoticks.c25
13 files changed, 116 insertions, 34 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 65f931e362..10ef1e7fc7 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,5 +1,18 @@
2008-12-16 Joel Sherrill <joel.sherrill@oarcorp.com>
+ * libblock/src/bdbuf.c, libmisc/capture/capture-cli.c,
+ libmisc/capture/capture.c, libmisc/mw-fb/mw_uid.c,
+ rtems/include/rtems/rtems/support.h, score/Makefile.am,
+ score/include/rtems/score/tod.h, score/src/coretod.c,
+ score/src/coretodtickle.c: Eliminate all public use of TOD conversion
+ routines. Eliminate _TOD_Microseconds_per_tick and let every place
+ use the field directly from the Configuration Table. This required
+ moving some methods from macros to bodies.
+ * score/src/coretodmsecstoticks.c, score/src/coretodtickspersec.c,
+ score/src/coretodusectoticks.c: New files.
+
+2008-12-16 Joel Sherrill <joel.sherrill@oarcorp.com>
+
* libcsupport/src/__times.c, posix/src/adjtime.c,
posix/src/clockgetres.c, posix/src/sysconf.c,
rtems/src/clockgettickspersecond.c, rtems/src/clockgettod.c,
diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c
index da7d6f8e9c..48751b34f9 100644
--- a/cpukit/libblock/src/bdbuf.c
+++ b/cpukit/libblock/src/bdbuf.c
@@ -2353,7 +2353,7 @@ rtems_bdbuf_swapout_task (rtems_task_argument arg)
write_req->done_arg = write_req;
write_req->io_task = rtems_task_self ();
- period_in_ticks = TOD_MICROSECONDS_TO_TICKS (period_in_msecs * 1000);
+ period_in_ticks = RTEMS_MICROSECONDS_TO_TICKS (period_in_msecs * 1000);
/*
* This is temporary. Needs to be changed to use the real time clock.
diff --git a/cpukit/libmisc/capture/capture-cli.c b/cpukit/libmisc/capture/capture-cli.c
index bd659f283f..cf288f9b26 100644
--- a/cpukit/libmisc/capture/capture-cli.c
+++ b/cpukit/libmisc/capture/capture-cli.c
@@ -443,7 +443,7 @@ rtems_capture_cli_task_load_thread (rtems_task_argument arg)
cli_load_thread_active = 0;
- rtems_task_wake_after (TOD_MICROSECONDS_TO_TICKS (5000000));
+ rtems_task_wake_after (RTEMS_MICROSECONDS_TO_TICKS (5000000));
}
}
@@ -509,7 +509,7 @@ rtems_capture_cli_task_load (int argc,
int loops = 20;
while (loops && cli_load_thread_active)
- rtems_task_wake_after (TOD_MICROSECONDS_TO_TICKS (100000));
+ rtems_task_wake_after (RTEMS_MICROSECONDS_TO_TICKS (100000));
rtems_task_delete (id);
diff --git a/cpukit/libmisc/capture/capture.c b/cpukit/libmisc/capture/capture.c
index 00b71f7480..727e461727 100644
--- a/cpukit/libmisc/capture/capture.c
+++ b/cpukit/libmisc/capture/capture.c
@@ -1772,7 +1772,7 @@ rtems_capture_read (uint32_t threshold,
sc = rtems_event_receive (RTEMS_EVENT_0,
RTEMS_WAIT | RTEMS_EVENT_ANY,
- TOD_MICROSECONDS_TO_TICKS (timeout),
+ RTEMS_MICROSECONDS_TO_TICKS (timeout),
&event_out);
/*
diff --git a/cpukit/libmisc/mw-fb/mw_uid.c b/cpukit/libmisc/mw-fb/mw_uid.c
index 06a7d713f0..41b0583ada 100644
--- a/cpukit/libmisc/mw-fb/mw_uid.c
+++ b/cpukit/libmisc/mw-fb/mw_uid.c
@@ -93,7 +93,7 @@ int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout )
(void*)m,
&size,
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
- TOD_MICROSECONDS_TO_TICKS(micro_secs ) );
+ RTEMS_MICROSECONDS_TO_TICKS(micro_secs));
if( status == RTEMS_SUCCESSFUL )
{
diff --git a/cpukit/rtems/include/rtems/rtems/support.h b/cpukit/rtems/include/rtems/rtems/support.h
index 25f6ebf08d..b7282e33d6 100644
--- a/cpukit/rtems/include/rtems/rtems/support.h
+++ b/cpukit/rtems/include/rtems/rtems/support.h
@@ -43,7 +43,8 @@ extern "C" {
* This is the public milliseconds to ticks conversion.
*/
#define RTEMS_MILLISECONDS_TO_TICKS(_ms) \
- TOD_MILLISECONDS_TO_TICKS(_ms)
+ (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / \
+ rtems_configuration_get_microseconds_per_tick())
/**
* @brief microseconds to ticks
@@ -51,7 +52,7 @@ extern "C" {
* This is the public microseconds to tick conversion.
*/
#define RTEMS_MICROSECONDS_TO_TICKS(_ms) \
- TOD_MICROSECONDS_TO_TICKS(_ms)
+ ((_ms) / rtems_configuration_get_microseconds_per_tick())
/**
* @brief get workspace information
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 82ebc5e20d..81e2e525f7 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -178,7 +178,8 @@ libscore_a_SOURCES += src/ts64addto.c src/ts64dividebyinteger.c \
## TOD_C_FILES
libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
- src/coretodgetuptime.c src/coretodgetuptimetimespec.c src/coretodtickle.c
+ src/coretodgetuptime.c src/coretodgetuptimetimespec.c src/coretodtickle.c \
+ src/coretodmsecstoticks.c src/coretodtickspersec.c src/coretodusectoticks.c
## WATCHDOG_C_FILES
libscore_a_SOURCES += src/watchdog.c src/watchdogadjust.c \
diff --git a/cpukit/score/include/rtems/score/tod.h b/cpukit/score/include/rtems/score/tod.h
index 44d4df862e..fb3ac98140 100644
--- a/cpukit/score/include/rtems/score/tod.h
+++ b/cpukit/score/include/rtems/score/tod.h
@@ -101,14 +101,6 @@ extern "C" {
(((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
(4 * TOD_SECONDS_PER_DAY))
-/** @brief Ticks per Second
- *
- * This macro calculates the number of ticks per second.
- */
-
-#define TOD_TICKS_PER_SECOND \
- (TOD_MICROSECONDS_PER_SECOND / _TOD_Microseconds_per_tick)
-
/** @brief RTEMS Epoch Year
*
* The following constant define the earliest year to which an
@@ -148,12 +140,6 @@ SCORE_EXTERN Timestamp_Control _TOD_Uptime;
#define _TOD_Seconds_since_epoch() \
_Timestamp_Get_seconds(&_TOD_Now)
-/** @brief Microseconds per Clock Tick
- *
- * The following contains the number of microseconds per tick.
- */
-SCORE_EXTERN uint32_t _TOD_Microseconds_per_tick;
-
/** @brief _TOD_Handler_initialization
*
* This routine performs the initialization necessary for this handler.
@@ -224,8 +210,9 @@ void _TOD_Tickle_ticks( void );
*
* @note This must be a macro so it can be used in "static" tables.
*/
-#define TOD_MICROSECONDS_TO_TICKS(_us) \
- ((_us) / _TOD_Microseconds_per_tick)
+uint32_t TOD_MICROSECONDS_TO_TICKS(
+ uint32_t microseconds
+);
/** @brief TOD_MILLISECONDS_TO_TICKS
*
@@ -233,20 +220,27 @@ void _TOD_Tickle_ticks( void );
*
* @note This must be a macro so it can be used in "static" tables.
*/
-
-#define TOD_MILLISECONDS_TO_TICKS(_ms) \
- (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick)
-
+uint32_t TOD_MILLISECONDS_TO_TICKS(
+ uint32_t microseconds
+);
/** @brief How many ticks in a second?
*
- * This macro returns the number of ticks in a second.
+ * This method returns the number of ticks in a second.
*
* @note If the clock tick value does not multiply evenly into a second
* then this number of ticks will be slightly shorter than a second.
*/
-#define TOD_TICKS_PER_SECOND \
- (TOD_MICROSECONDS_PER_SECOND / _TOD_Microseconds_per_tick)
+uint32_t TOD_TICKS_PER_SECOND_method(void);
+
+/** @brief Method to return number of ticks in a second
+ *
+ * This method exists to hide the fact that TOD_TICKS_PER_SECOND can no
+ * be implemented as a macro in a .h file due to visibility issues.
+ * The Configuration Table is not available to SuperCore .h files but
+ * is available to their .c files.
+ */
+#define TOD_TICKS_PER_SECOND TOD_TICKS_PER_SECOND_method()
#ifndef __RTEMS_APPLICATION__
#include <rtems/score/tod.inl>
diff --git a/cpukit/score/src/coretod.c b/cpukit/score/src/coretod.c
index cf4ec8e334..6d0fc11b5a 100644
--- a/cpukit/score/src/coretod.c
+++ b/cpukit/score/src/coretod.c
@@ -38,8 +38,6 @@ void _TOD_Handler_initialization(
uint32_t microseconds_per_tick
)
{
- _TOD_Microseconds_per_tick = microseconds_per_tick;
-
/* POSIX format TOD (timespec) */
_Timestamp_Set( &_TOD_Now, TOD_SECONDS_1970_THROUGH_1988, 0 );
diff --git a/cpukit/score/src/coretodmsecstoticks.c b/cpukit/score/src/coretodmsecstoticks.c
new file mode 100644
index 0000000000..cddd3d646d
--- /dev/null
+++ b/cpukit/score/src/coretodmsecstoticks.c
@@ -0,0 +1,25 @@
+/* COPYRIGHT (c) 1989-2008.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/tod.h>
+
+uint32_t TOD_MILLISECONDS_TO_TICKS(
+ uint32_t milliseconds
+)
+{
+ return (milliseconds / rtems_configuration_get_milliseconds_per_tick());
+}
diff --git a/cpukit/score/src/coretodtickle.c b/cpukit/score/src/coretodtickle.c
index f4e5a4f69c..ddc8e4aac0 100644
--- a/cpukit/score/src/coretodtickle.c
+++ b/cpukit/score/src/coretodtickle.c
@@ -22,6 +22,7 @@
#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
+#include <rtems/config.h>
/*PAGE
*
@@ -40,7 +41,7 @@ void _TOD_Tickle_ticks( void )
uint32_t seconds;
/* Convert the tick quantum to a timestamp */
- _Timestamp_Set( &tick, 0, _TOD_Microseconds_per_tick * 1000 );
+ _Timestamp_Set( &tick, 0, rtems_configuration_get_nanoseconds_per_tick() );
/* Update the counter of ticks since boot */
_Watchdog_Ticks_since_boot += 1;
diff --git a/cpukit/score/src/coretodtickspersec.c b/cpukit/score/src/coretodtickspersec.c
new file mode 100644
index 0000000000..ac6316ba7b
--- /dev/null
+++ b/cpukit/score/src/coretodtickspersec.c
@@ -0,0 +1,24 @@
+/* COPYRIGHT (c) 1989-2008.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/tod.h>
+
+uint32_t TOD_TICKS_PER_SECOND_method(void)
+{
+ return (TOD_MICROSECONDS_PER_SECOND /
+ rtems_configuration_get_microseconds_per_tick());
+}
diff --git a/cpukit/score/src/coretodusectoticks.c b/cpukit/score/src/coretodusectoticks.c
new file mode 100644
index 0000000000..be2cbd7024
--- /dev/null
+++ b/cpukit/score/src/coretodusectoticks.c
@@ -0,0 +1,25 @@
+/* COPYRIGHT (c) 1989-2008.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/config.h>
+#include <rtems/score/tod.h>
+
+uint32_t TOD_MICROSECONDS_TO_TICKS(
+ uint32_t microseconds
+)
+{
+ return (microseconds / rtems_configuration_get_microseconds_per_tick());
+}