summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/tod.h
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-04-02 18:23:59 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-04-02 18:23:59 +0000
commit812da546889eea0b6dea7eb2954f46a4c43d1314 (patch)
tree22fc95d921c3544de770454a2f9c604d5d0a27a2 /cpukit/score/include/rtems/score/tod.h
parent2007-04-02 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-812da546889eea0b6dea7eb2954f46a4c43d1314.tar.bz2
2007-04-02 Joel Sherrill <joel@OARcorp.com>
* itron/src/itrontime.c, libcsupport/src/__gettod.c, posix/include/rtems/posix/time.h, posix/include/rtems/posix/timer.h, posix/src/clockgettime.c, posix/src/clocksettime.c, posix/src/nanosleep.c, posix/src/posixtimespecsubtract.c, posix/src/posixtimespectointerval.c, posix/src/ptimer1.c, posix/src/sleep.c, rtems/Makefile.am, rtems/include/rtems/rtems/clock.h, rtems/include/rtems/rtems/timer.h, rtems/include/rtems/rtems/types.h, rtems/src/clockget.c, rtems/src/clockset.c, rtems/src/clocktodtoseconds.c, rtems/src/clocktodvalidate.c, rtems/src/taskwakewhen.c, score/Makefile.am, score/include/rtems/score/tod.h, score/inline/rtems/score/tod.inl, score/src/coretod.c, score/src/coretodset.c: Convert from Classic API style TOD_Control as fundamental time structure to POSIX struct timespec. Add clock_get_uptime(). * rtems/src/clockgetuptime.c, score/src/coretodget.c, score/src/coretodgetuptime.c: New files. * score/src/coretodtickle.c, score/src/coretodtoseconds.c, score/src/coretodvalidate.c: Removed.
Diffstat (limited to 'cpukit/score/include/rtems/score/tod.h')
-rw-r--r--cpukit/score/include/rtems/score/tod.h144
1 files changed, 33 insertions, 111 deletions
diff --git a/cpukit/score/include/rtems/score/tod.h b/cpukit/score/include/rtems/score/tod.h
index 8f5256e245..8de4bb9304 100644
--- a/cpukit/score/include/rtems/score/tod.h
+++ b/cpukit/score/include/rtems/score/tod.h
@@ -6,7 +6,7 @@
*/
/*
- * COPYRIGHT (c) 1989-2006.
+ * COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -32,6 +32,7 @@ extern "C" {
#include <rtems/score/object.h>
#include <rtems/score/watchdog.h>
+#include <time.h>
/** @defgroup ScoreTODConstants TOD Constants
* The following constants are related to the time of day.
@@ -96,6 +97,15 @@ extern "C" {
*/
#define TOD_NANOSECONDS_PER_MICROSECOND (uint32_t)1000
+/*
+ * Seconds from January 1, 1970 to January 1, 1988. Used to account for
+ * differences between POSIX API and RTEMS core. The timespec format time
+ * is kept in POSIX compliant form.
+ */
+#define TOD_SECONDS_1970_THROUGH_1988 \
+ (((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
+ (4 * TOD_SECONDS_PER_DAY))
+
/**@}*/
/** @brief RTEMS Epoch Year
@@ -106,29 +116,6 @@ extern "C" {
*/
#define TOD_BASE_YEAR 1988
-/**
- * The following record defines the time of control block. This
- * control block is used to maintain the current time of day.
- *
- * @note This is an RTEID style time/date.
- */
-typedef struct {
- /** This field is the year, A.D. */
- uint32_t year;
- /** This field is the month, 1 -> 12 */
- uint32_t month;
- /** This field is the day, 1 -> 31 */
- uint32_t day;
- /** This field is the hour, 0 -> 23 */
- uint32_t hour;
- /** This field is the minute, 0 -> 59 */
- uint32_t minute;
- /** This field is the second, 0 -> 59 */
- uint32_t second;
- /** This field is the elapsed ticks between secs */
- uint32_t ticks;
-} TOD_Control;
-
/** @brief Is the Time Of Day Set
*
* This is TRUE if the application has set the current
@@ -136,10 +123,15 @@ typedef struct {
*/
SCORE_EXTERN boolean _TOD_Is_set;
-/** @brief Current Time of Day
+/** @brief Current Time of Day (Timespec)
* The following contains the current time of day.
*/
-SCORE_EXTERN TOD_Control _TOD_Current;
+SCORE_EXTERN struct timespec _TOD_Now;
+
+/** @brief Current Time of Day (Timespec)
+ * The following contains the running uptime.
+ */
+SCORE_EXTERN struct timespec _TOD_Uptime;
/** @brief Seconds Since RTEMS Epoch
* The following contains the number of seconds from 00:00:00
@@ -164,69 +156,6 @@ SCORE_EXTERN uint32_t _TOD_Microseconds_per_tick;
*/
SCORE_EXTERN uint32_t _TOD_Ticks_per_second;
-/** @brief Watchdog Set Managed by Seconds
- *
- * This is the control structure for the watchdog timer which
- * fires to service the seconds chain.
- */
-SCORE_EXTERN Watchdog_Control _TOD_Seconds_watchdog;
-
-#ifdef SCORE_INIT
-
-/*
- * The following array contains the number of days in all months.
- * The first dimension should be 1 for leap years, and 0 otherwise.
- * The second dimension should range from 1 to 12 for January to
- * February, respectively.
- */
-const uint32_t _TOD_Days_per_month[ 2 ][ 13 ] = {
- { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-};
-
-/*
- * The following array contains the number of days in all months
- * up to the month indicated by the index of the second dimension.
- * The first dimension should be 1 for leap years, and 0 otherwise.
- */
-const uint16_t _TOD_Days_to_date[2][13] = {
- { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
- { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
-};
-
-/*
- * The following array contains the number of days in the years
- * since the last leap year. The index should be 0 for leap
- * years, and the number of years since the beginning of a leap
- * year otherwise.
- */
-const uint16_t _TOD_Days_since_last_leap_year[4] = { 0, 366, 731, 1096 };
-
-#else
-
-/** @brief Convert Month to Julian Days
- *
- * This is a prototype for a table which assists in converting the
- * current day into the Julian days since the first of the year.
- */
-extern const uint16_t _TOD_Days_to_date[2][13]; /* Julian days */
-
-/** @brief Days since Beginning of Last Leap Year
- *
- * This is a prototype for a table which assists in calculating the
- * number of days since the beginning of the last leap year.
- */
-extern const uint16_t _TOD_Days_since_last_leap_year[4];
-
-/** @brief Days Per Month Table
- *
- * This is a prototype for a table which holds the number of days
- * per month for a leap year and non-leap year.
- */
-extern const uint32_t _TOD_Days_per_month[2][13];
-
-#endif
-
/** @brief _TOD_Handler_initialization
*
* This routine performs the initialization necessary for this handler.
@@ -237,40 +166,33 @@ void _TOD_Handler_initialization(
/** @brief _TOD_Set
*
- * This routine sets the current time of day to THE_TOD and
+ * This routine sets the current time of day to @a time and
* the equivalent SECONDS_SINCE_EPOCH.
*/
void _TOD_Set(
- TOD_Control *the_tod,
- Watchdog_Interval seconds_since_epoch
+ const struct timespec *time
);
-/** @brief _TOD_Validate
+/** @brief _TOD_Get
*
- * This function returns TRUE if THE_TOD contains
- * a valid time of day, and FALSE otherwise.
- */
-boolean _TOD_Validate(
- TOD_Control *the_tod
-);
-
-/** @brief _TOD_To_seconds
+ * This routine returns the current time of day with potential accuracy
+ * to the nanosecond.
*
- * This function returns the number seconds between the epoch and THE_TOD.
+ * @param[in] time is a pointer to the time to be returned
*/
-Watchdog_Interval _TOD_To_seconds(
- TOD_Control *the_tod
+void _TOD_Get(
+ struct timespec *time
);
-/** @brief _TOD_Tickle
+/** @brief _TOD_Get_uptime
+ *
+ * This routine returns the system uptime with potential accuracy
+ * to the nanosecond.
*
- * This routine is scheduled as a watchdog function and is invoked at
- * each second boundary. It updates the current time of day to indicate
- * that a second has passed and processes the seconds watchdog chain.
+ * @param[in] time is a pointer to the uptime to be returned
*/
-void _TOD_Tickle(
- Objects_Id id,
- void *ignored
+void _TOD_Get_uptime(
+ struct timespec *time
);
/** @brief TOD_MILLISECONDS_TO_MICROSECONDS