[ae68ff0] | 1 | @c |
---|
[bf6d03d] | 2 | @c COPYRIGHT (c) 1988-2008 |
---|
[ae68ff0] | 3 | @c On-Line Applications Research Corporation (OAR). |
---|
| 4 | @c All rights reserved. |
---|
| 5 | |
---|
| 6 | @chapter Clock Manager |
---|
[20515fc] | 7 | |
---|
[169502e] | 8 | @cindex clock |
---|
| 9 | |
---|
[ae68ff0] | 10 | @section Introduction |
---|
| 11 | |
---|
| 12 | The clock manager provides support for time of day |
---|
| 13 | and other time related capabilities. The directives provided by |
---|
| 14 | the clock manager are: |
---|
| 15 | |
---|
| 16 | @itemize @bullet |
---|
[bf6d03d] | 17 | @item @code{@value{DIRPREFIX}clock_set} - Set date and time |
---|
| 18 | @item @code{@value{DIRPREFIX}clock_get} - Get date and time information |
---|
| 19 | @item @code{@value{DIRPREFIX}clock_get_tod} - Get date and time in TOD format |
---|
| 20 | @item @code{@value{DIRPREFIX}clock_get_tod_timeval} - Get date and time in timeval format |
---|
[2d1bdc8] | 21 | @item @code{@value{DIRPREFIX}clock_get_seconds_since_epoch} - Get seconds since epoch |
---|
[bf6d03d] | 22 | @item @code{@value{DIRPREFIX}clock_get_ticks_per_second} - Get ticks per second |
---|
| 23 | @item @code{@value{DIRPREFIX}clock_get_ticks_since_boot} - Get ticks since boot |
---|
[bf4d016] | 24 | @item @code{@value{DIRPREFIX}clock_get_uptime} - Get time since boot |
---|
[bfddb047] | 25 | @item @code{@value{DIRPREFIX}clock_get_uptime_timeval} - Get time since boot in timeval format |
---|
[90733a86] | 26 | @item @code{@value{DIRPREFIX}clock_get_uptime_seconds} - Get seconds since boot |
---|
[2d1bdc8] | 27 | @item @code{@value{DIRPREFIX}clock_get_uptime_nanoseconds} - Get nanoseconds since boot |
---|
[a91cc06] | 28 | @item @code{@value{DIRPREFIX}clock_set_nanoseconds_extension} - Install the nanoseconds since last tick handler |
---|
[4fa4ea65] | 29 | @item @code{@value{DIRPREFIX}clock_tick} - Announce a clock tick |
---|
[ae68ff0] | 30 | @end itemize |
---|
| 31 | |
---|
| 32 | @section Background |
---|
[20515fc] | 33 | |
---|
[ae68ff0] | 34 | @subsection Required Support |
---|
| 35 | |
---|
| 36 | For the features provided by the clock manager to be |
---|
| 37 | utilized, periodic timer interrupts are required. Therefore, a |
---|
| 38 | real-time clock or hardware timer is necessary to create the |
---|
[75e22db] | 39 | timer interrupts. The @code{@value{DIRPREFIX}clock_tick} |
---|
| 40 | directive is normally called |
---|
[ae68ff0] | 41 | by the timer ISR to announce to RTEMS that a system clock tick |
---|
| 42 | has occurred. Elapsed time is measured in ticks. A tick is |
---|
| 43 | defined to be an integral number of microseconds which is |
---|
| 44 | specified by the user in the Configuration Table. |
---|
| 45 | |
---|
| 46 | @subsection Time and Date Data Structures |
---|
| 47 | |
---|
| 48 | The clock facilities of the clock manager operate |
---|
| 49 | upon calendar time. These directives utilize the following date |
---|
[7e8a1fc] | 50 | and time @value{STRUCTURE} for the native time and date format: |
---|
[ae68ff0] | 51 | |
---|
[adee5979] | 52 | |
---|
[61389eac] | 53 | @ifset is-C |
---|
[adee5979] | 54 | @findex rtems_time_of_day |
---|
[ae68ff0] | 55 | @example |
---|
| 56 | struct rtems_tod_control @{ |
---|
[ae10dbd] | 57 | uint32_t year; /* greater than 1987 */ |
---|
| 58 | uint32_t month; /* 1 - 12 */ |
---|
| 59 | uint32_t day; /* 1 - 31 */ |
---|
| 60 | uint32_t hour; /* 0 - 23 */ |
---|
| 61 | uint32_t minute; /* 0 - 59 */ |
---|
| 62 | uint32_t second; /* 0 - 59 */ |
---|
| 63 | uint32_t ticks; /* elapsed between seconds */ |
---|
[ae68ff0] | 64 | @}; |
---|
| 65 | |
---|
| 66 | typedef struct rtems_tod_control rtems_time_of_day; |
---|
| 67 | @end example |
---|
[61389eac] | 68 | @end ifset |
---|
| 69 | |
---|
| 70 | @ifset is-Ada |
---|
| 71 | @example |
---|
| 72 | type Time_Of_Day is |
---|
| 73 | record |
---|
| 74 | Year : RTEMS.Unsigned32; -- year, A.D. |
---|
| 75 | Month : RTEMS.Unsigned32; -- month, 1 .. 12 |
---|
| 76 | Day : RTEMS.Unsigned32; -- day, 1 .. 31 |
---|
| 77 | Hour : RTEMS.Unsigned32; -- hour, 0 .. 23 |
---|
| 78 | Minute : RTEMS.Unsigned32; -- minute, 0 .. 59 |
---|
| 79 | Second : RTEMS.Unsigned32; -- second, 0 .. 59 |
---|
| 80 | Ticks : RTEMS.Unsigned32; -- elapsed ticks between seconds |
---|
| 81 | end record; |
---|
| 82 | @end example |
---|
| 83 | @end ifset |
---|
[ae68ff0] | 84 | |
---|
| 85 | |
---|
| 86 | The native date and time format is the only format |
---|
| 87 | supported when setting the system date and time using the |
---|
[3372dc8] | 88 | @code{@value{DIRPREFIX}clock_set} directive. Some applications |
---|
[2d1bdc8] | 89 | expect to operate on a "UNIX-style" date and time data structure. The |
---|
[3372dc8] | 90 | @code{@value{DIRPREFIX}clock_get_tod_timeval} always returns |
---|
[2d1bdc8] | 91 | the date and time in @code{struct timeval} format. The |
---|
[75e22db] | 92 | @code{@value{DIRPREFIX}clock_get} directive can optionally return |
---|
[2d1bdc8] | 93 | the current date and time in this format. |
---|
[ae68ff0] | 94 | |
---|
[3372dc8] | 95 | The @code{struct timeval} data structure has two fields: @code{tv_sec} |
---|
| 96 | and @code{tv_usec} which are seconds and microseconds, respectively. |
---|
| 97 | The @code{tv_sec} field in this data structure is the number of seconds |
---|
[638a9195] | 98 | since the POSIX epoch of January 1, 1970 but will never be prior to |
---|
| 99 | the RTEMS epoch of January 1, 1988. |
---|
[ae68ff0] | 100 | |
---|
| 101 | @subsection Clock Tick and Timeslicing |
---|
| 102 | |
---|
[adee5979] | 103 | @cindex timeslicing |
---|
| 104 | |
---|
[ae68ff0] | 105 | Timeslicing is a task scheduling discipline in which |
---|
| 106 | tasks of equal priority are executed for a specific period of |
---|
| 107 | time before control of the CPU is passed to another task. It is |
---|
| 108 | also sometimes referred to as the automatic round-robin |
---|
| 109 | scheduling algorithm. The length of time allocated to each task |
---|
| 110 | is known as the quantum or timeslice. |
---|
| 111 | |
---|
| 112 | The system's timeslice is defined as an integral |
---|
| 113 | number of ticks, and is specified in the Configuration Table. |
---|
| 114 | The timeslice is defined for the entire system of tasks, but |
---|
| 115 | timeslicing is enabled and disabled on a per task basis. |
---|
| 116 | |
---|
[75e22db] | 117 | The @code{@value{DIRPREFIX}clock_tick} |
---|
| 118 | directive implements timeslicing by |
---|
[ae68ff0] | 119 | decrementing the running task's time-remaining counter when both |
---|
| 120 | timeslicing and preemption are enabled. If the task's timeslice |
---|
| 121 | has expired, then that task will be preempted if there exists a |
---|
| 122 | ready task of equal priority. |
---|
| 123 | |
---|
| 124 | @subsection Delays |
---|
| 125 | |
---|
[adee5979] | 126 | @cindex delays |
---|
| 127 | |
---|
[ae68ff0] | 128 | A sleep timer allows a task to delay for a given |
---|
| 129 | interval or up until a given time, and then wake and continue |
---|
| 130 | execution. This type of timer is created automatically by the |
---|
[75e22db] | 131 | @code{@value{DIRPREFIX}task_wake_after} |
---|
| 132 | and @code{@value{DIRPREFIX}task_wake_when} directives and, as a result, |
---|
[ae68ff0] | 133 | does not have an RTEMS ID. Once activated, a sleep timer cannot |
---|
| 134 | be explicitly deleted. Each task may activate one and only one |
---|
| 135 | sleep timer at a time. |
---|
| 136 | |
---|
| 137 | @subsection Timeouts |
---|
| 138 | |
---|
[adee5979] | 139 | @cindex timeouts |
---|
| 140 | |
---|
[ae68ff0] | 141 | Timeouts are a special type of timer automatically |
---|
| 142 | created when the timeout option is used on the |
---|
[75e22db] | 143 | @code{@value{DIRPREFIX}message_queue_receive}, |
---|
| 144 | @code{@value{DIRPREFIX}event_receive}, |
---|
| 145 | @code{@value{DIRPREFIX}semaphore_obtain} and |
---|
[2d1bdc8] | 146 | @code{@value{DIRPREFIX}region_get_segment} directives. |
---|
| 147 | Each task may have one and only one timeout active at a time. |
---|
[75e22db] | 148 | When a timeout expires, it unblocks the task with a timeout status code. |
---|
[ae68ff0] | 149 | |
---|
| 150 | @section Operations |
---|
[20515fc] | 151 | |
---|
[ae68ff0] | 152 | @subsection Announcing a Tick |
---|
| 153 | |
---|
[75e22db] | 154 | RTEMS provides the @code{@value{DIRPREFIX}clock_tick} directive which is |
---|
[ae68ff0] | 155 | called from the user's real-time clock ISR to inform RTEMS that |
---|
| 156 | a tick has elapsed. The tick frequency value, defined in |
---|
| 157 | microseconds, is a configuration parameter found in the |
---|
| 158 | Configuration Table. RTEMS divides one million microseconds |
---|
| 159 | (one second) by the number of microseconds per tick to determine |
---|
[75e22db] | 160 | the number of calls to the |
---|
| 161 | @code{@value{DIRPREFIX}clock_tick} directive per second. The |
---|
| 162 | frequency of @code{@value{DIRPREFIX}clock_tick} |
---|
| 163 | calls determines the resolution |
---|
[ae68ff0] | 164 | (granularity) for all time dependent RTEMS actions. For |
---|
[75e22db] | 165 | example, calling @code{@value{DIRPREFIX}clock_tick} |
---|
| 166 | ten times per second yields a higher |
---|
| 167 | resolution than calling @code{@value{DIRPREFIX}clock_tick} |
---|
| 168 | two times per second. The @code{@value{DIRPREFIX}clock_tick} |
---|
| 169 | directive is responsible for maintaining both |
---|
[ae68ff0] | 170 | calendar time and the dynamic set of timers. |
---|
| 171 | |
---|
| 172 | @subsection Setting the Time |
---|
| 173 | |
---|
[75e22db] | 174 | The @code{@value{DIRPREFIX}clock_set} directive allows a task or an ISR to |
---|
[ae68ff0] | 175 | set the date and time maintained by RTEMS. If setting the date |
---|
| 176 | and time causes any outstanding timers to pass their deadline, |
---|
| 177 | then the expired timers will be fired during the invocation of |
---|
[75e22db] | 178 | the @code{@value{DIRPREFIX}clock_set} directive. |
---|
[ae68ff0] | 179 | |
---|
| 180 | @subsection Obtaining the Time |
---|
| 181 | |
---|
[75e22db] | 182 | The @code{@value{DIRPREFIX}clock_get} directive allows a task or an ISR to |
---|
[ae68ff0] | 183 | obtain the current date and time or date and time related |
---|
| 184 | information. The current date and time can be returned in |
---|
| 185 | either native or UNIX-style format. Additionally, the |
---|
| 186 | application can obtain date and time related information such as |
---|
| 187 | the number of seconds since the RTEMS epoch, the number of ticks |
---|
| 188 | since the executive was initialized, and the number of ticks per |
---|
[75e22db] | 189 | second. The information returned by the |
---|
| 190 | @code{@value{DIRPREFIX}clock_get} directive is |
---|
[adee5979] | 191 | dependent on the option selected by the caller. This |
---|
| 192 | is specified using one of the following constants |
---|
| 193 | associated with the enumerated type |
---|
| 194 | @code{@value{DIRPREFIX}clock_get_options}: |
---|
| 195 | |
---|
[2d1bdc8] | 196 | @findex rtems_clock_get_options |
---|
[ae68ff0] | 197 | |
---|
| 198 | @itemize @bullet |
---|
[4fa4ea65] | 199 | @item @code{@value{RPREFIX}CLOCK_GET_TOD} - obtain native style date and time |
---|
[a94c5a5d] | 200 | |
---|
[75e22db] | 201 | @item @code{@value{RPREFIX}CLOCK_GET_TIME_VALUE} - obtain UNIX-style |
---|
| 202 | date and time |
---|
[a94c5a5d] | 203 | |
---|
[4fa4ea65] | 204 | @item @code{@value{RPREFIX}CLOCK_GET_TICKS_SINCE_BOOT} - obtain number of ticks |
---|
[a94c5a5d] | 205 | since RTEMS was initialized |
---|
| 206 | |
---|
[75e22db] | 207 | @item @code{@value{RPREFIX}CLOCK_GET_SECONDS_SINCE_EPOCH} - obtain number |
---|
| 208 | of seconds since RTEMS epoch |
---|
[a94c5a5d] | 209 | |
---|
[75e22db] | 210 | @item @code{@value{RPREFIX}CLOCK_GET_TICKS_PER_SECOND} - obtain number of clock |
---|
| 211 | ticks per second |
---|
[a94c5a5d] | 212 | |
---|
[ae68ff0] | 213 | @end itemize |
---|
| 214 | |
---|
| 215 | Calendar time operations will return an error code if |
---|
| 216 | invoked before the date and time have been set. |
---|
| 217 | |
---|
| 218 | @section Directives |
---|
| 219 | |
---|
| 220 | This section details the clock manager's directives. |
---|
| 221 | A subsection is dedicated to each of this manager's directives |
---|
| 222 | and describes the calling sequence, related constants, usage, |
---|
| 223 | and status codes. |
---|
| 224 | |
---|
[169502e] | 225 | @c |
---|
| 226 | @c |
---|
| 227 | @c |
---|
[ae68ff0] | 228 | @page |
---|
[bf6d03d] | 229 | @subsection CLOCK_SET - Set date and time |
---|
[ae68ff0] | 230 | |
---|
| 231 | @subheading CALLING SEQUENCE: |
---|
| 232 | |
---|
[169502e] | 233 | @cindex set the time of day |
---|
| 234 | |
---|
[61389eac] | 235 | @ifset is-C |
---|
[169502e] | 236 | @findex rtems_clock_set |
---|
[ae68ff0] | 237 | @example |
---|
| 238 | rtems_status_code rtems_clock_set( |
---|
| 239 | rtems_time_of_day *time_buffer |
---|
| 240 | ); |
---|
| 241 | @end example |
---|
[61389eac] | 242 | @end ifset |
---|
| 243 | |
---|
| 244 | @ifset is-Ada |
---|
| 245 | @example |
---|
| 246 | procedure Clock_Set ( |
---|
| 247 | Time_Buffer : in RTEMS.Time_Of_Day; |
---|
| 248 | Result : out RTEMS.Status_Codes |
---|
| 249 | ); |
---|
| 250 | @end example |
---|
| 251 | @end ifset |
---|
[ae68ff0] | 252 | |
---|
| 253 | @subheading DIRECTIVE STATUS CODES: |
---|
[4fa4ea65] | 254 | @code{@value{RPREFIX}SUCCESSFUL} - date and time set successfully@* |
---|
[f8892c9] | 255 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{time_buffer} is NULL@* |
---|
[4dc6a46] | 256 | @code{@value{RPREFIX}INVALID_CLOCK} - invalid time of day |
---|
[ae68ff0] | 257 | |
---|
| 258 | @subheading DESCRIPTION: |
---|
| 259 | |
---|
| 260 | This directive sets the system date and time. The |
---|
[7e8a1fc] | 261 | date, time, and ticks in the time_buffer @value{STRUCTURE} are all |
---|
[ae68ff0] | 262 | range-checked, and an error is returned if any one is out of its |
---|
| 263 | valid range. |
---|
| 264 | |
---|
| 265 | @subheading NOTES: |
---|
| 266 | |
---|
| 267 | Years before 1988 are invalid. |
---|
| 268 | |
---|
| 269 | The system date and time are based on the configured |
---|
| 270 | tick rate (number of microseconds in a tick). |
---|
| 271 | |
---|
| 272 | Setting the time forward may cause a higher priority |
---|
| 273 | task, blocked waiting on a specific time, to be made ready. In |
---|
| 274 | this case, the calling task will be preempted after the next |
---|
| 275 | clock tick. |
---|
| 276 | |
---|
| 277 | Re-initializing RTEMS causes the system date and time |
---|
| 278 | to be reset to an uninitialized state. Another call to |
---|
[75e22db] | 279 | @code{@value{DIRPREFIX}clock_set} is required to re-initialize |
---|
| 280 | the system date and time to application specific specifications. |
---|
[ae68ff0] | 281 | |
---|
[169502e] | 282 | @c |
---|
| 283 | @c |
---|
| 284 | @c |
---|
[ae68ff0] | 285 | @page |
---|
[bf6d03d] | 286 | @subsection CLOCK_GET - Get date and time information |
---|
[ae68ff0] | 287 | |
---|
[169502e] | 288 | @cindex obtain the time of day |
---|
| 289 | |
---|
[ae68ff0] | 290 | @subheading CALLING SEQUENCE: |
---|
| 291 | |
---|
[61389eac] | 292 | @ifset is-C |
---|
[169502e] | 293 | @findex rtems_clock_get |
---|
[ae68ff0] | 294 | @example |
---|
| 295 | rtems_status_code rtems_clock_get( |
---|
| 296 | rtems_clock_get_options option, |
---|
| 297 | void *time_buffer |
---|
| 298 | ); |
---|
| 299 | @end example |
---|
[61389eac] | 300 | @end ifset |
---|
| 301 | |
---|
| 302 | @ifset is-Ada |
---|
| 303 | @example |
---|
| 304 | procedure Clock_Get ( |
---|
| 305 | Option : in RTEMS.Clock_Get_Options; |
---|
| 306 | Time_Buffer : in RTEMS.Address; |
---|
| 307 | Result : out RTEMS.Status_Codes |
---|
| 308 | ); |
---|
| 309 | @end example |
---|
| 310 | @end ifset |
---|
[ae68ff0] | 311 | |
---|
| 312 | @subheading DIRECTIVE STATUS CODES: |
---|
[4fa4ea65] | 313 | @code{@value{RPREFIX}SUCCESSFUL} - current time obtained successfully@* |
---|
[f8892c9] | 314 | @code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set@* |
---|
| 315 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{time_buffer} is NULL |
---|
[ae68ff0] | 316 | |
---|
| 317 | @subheading DESCRIPTION: |
---|
| 318 | |
---|
| 319 | This directive obtains the system date and time. If |
---|
| 320 | the caller is attempting to obtain the date and time (i.e. |
---|
[4fa4ea65] | 321 | option is set to either @code{@value{RPREFIX}CLOCK_GET_SECONDS_SINCE_EPOCH}, |
---|
[75e22db] | 322 | @code{@value{RPREFIX}CLOCK_GET_TOD}, or |
---|
| 323 | @code{@value{RPREFIX}CLOCK_GET_TIME_VALUE}) and the date and time |
---|
| 324 | has not been set with a previous call to |
---|
| 325 | @code{@value{DIRPREFIX}clock_set}, then the |
---|
[2d1bdc8] | 326 | @code{@value{RPREFIX}NOT_DEFINED} status code is returned. |
---|
[75e22db] | 327 | The caller can always obtain the number of ticks per second (option is |
---|
| 328 | @code{@value{RPREFIX}CLOCK_GET_TICKS_PER_SECOND}) and the number of |
---|
| 329 | ticks since the executive was initialized option is |
---|
| 330 | @code{@value{RPREFIX}CLOCK_GET_TICKS_SINCE_BOOT}). |
---|
[ae68ff0] | 331 | |
---|
[adee5979] | 332 | The @code{option} argument may taken on any value of the enumerated |
---|
| 333 | type @code{rtems_clock_get_options}. The data type expected for |
---|
| 334 | @code{time_buffer} is based on the value of @code{option} as |
---|
| 335 | indicated below: |
---|
[c3fec1c] | 336 | |
---|
[2d1bdc8] | 337 | @findex rtems_clock_get_options |
---|
[c3fec1c] | 338 | @ifset is-C |
---|
| 339 | @itemize @bullet |
---|
[4fa4ea65] | 340 | @item @code{@value{RPREFIX}CLOCK_GET_TOD} - (rtems_time_of_day *) |
---|
[c3fec1c] | 341 | |
---|
[4ffbc49] | 342 | @item @code{@value{RPREFIX}CLOCK_GET_SECONDS_SINCE_EPOCH} - (rtems_interval *) |
---|
[c3fec1c] | 343 | |
---|
[4fa4ea65] | 344 | @item @code{@value{RPREFIX}CLOCK_GET_TICKS_SINCE_BOOT} - (rtems_interval *) |
---|
[c3fec1c] | 345 | |
---|
[4fa4ea65] | 346 | @item @code{@value{RPREFIX}CLOCK_GET_TICKS_PER_SECOND} - (rtems_interval *) |
---|
[c3fec1c] | 347 | |
---|
[c0640a2] | 348 | @item @code{@value{RPREFIX}CLOCK_GET_TIME_VALUE} - (struct timeval *) |
---|
[4ffbc49] | 349 | |
---|
[c3fec1c] | 350 | @end itemize |
---|
| 351 | @end ifset |
---|
| 352 | |
---|
| 353 | @ifset is-Ada |
---|
| 354 | @itemize @bullet |
---|
[4ffbc49] | 355 | @item @code{@value{RPREFIX}Clock_Get_TOD} - Address of an variable of |
---|
[75e22db] | 356 | type RTEMS.Time_Of_Day |
---|
[c3fec1c] | 357 | |
---|
[4ffbc49] | 358 | @item @code{@value{RPREFIX}Clock_Get_Seconds_Since_Epoch} - Address of an |
---|
[75e22db] | 359 | variable of type RTEMS.Interval |
---|
[c3fec1c] | 360 | |
---|
[4ffbc49] | 361 | @item @code{@value{RPREFIX}Clock_Get_Ticks_Since_Boot} - Address of an |
---|
[75e22db] | 362 | variable of type RTEMS.Interval |
---|
[c3fec1c] | 363 | |
---|
[4ffbc49] | 364 | @item @code{@value{RPREFIX}Clock_Get_Ticks_Per_Second} - Address of an |
---|
[75e22db] | 365 | variable of type RTEMS.Interval |
---|
[c3fec1c] | 366 | |
---|
[4ffbc49] | 367 | @item @code{@value{RPREFIX}Clock_Get_Time_Value} - Address of an variable of |
---|
| 368 | type RTEMS.Clock_Time_Value |
---|
| 369 | |
---|
[c3fec1c] | 370 | @end itemize |
---|
| 371 | @end ifset |
---|
| 372 | |
---|
[ae68ff0] | 373 | @subheading NOTES: |
---|
| 374 | |
---|
| 375 | This directive is callable from an ISR. |
---|
| 376 | |
---|
| 377 | This directive will not cause the running task to be |
---|
| 378 | preempted. Re-initializing RTEMS causes the system date and |
---|
| 379 | time to be reset to an uninitialized state. Another call to |
---|
[75e22db] | 380 | @code{@value{DIRPREFIX}clock_set} is required to re-initialize the |
---|
| 381 | system date and time to application specific specifications. |
---|
[ae68ff0] | 382 | |
---|
[a91cc06] | 383 | @c |
---|
| 384 | @c |
---|
| 385 | @c |
---|
| 386 | @page |
---|
[bf6d03d] | 387 | @subsection CLOCK_GET_TOD - Get date and time in TOD format |
---|
[a91cc06] | 388 | |
---|
[bf6d03d] | 389 | @cindex obtain the time of day |
---|
[a91cc06] | 390 | |
---|
| 391 | @subheading CALLING SEQUENCE: |
---|
| 392 | |
---|
| 393 | @ifset is-C |
---|
[bf6d03d] | 394 | @findex rtems_clock_get_tod |
---|
[a91cc06] | 395 | @example |
---|
[bf6d03d] | 396 | rtems_status_code rtems_clock_get_tod( |
---|
| 397 | rtems_time_of_day *time_buffer |
---|
[a91cc06] | 398 | ); |
---|
| 399 | @end example |
---|
| 400 | @end ifset |
---|
| 401 | |
---|
| 402 | @ifset is-Ada |
---|
| 403 | @example |
---|
[bf6d03d] | 404 | procedure Clock_Get_TOD ( |
---|
| 405 | Time_Buffer : in RTEMS.Time_Of_Day; |
---|
| 406 | Result : out RTEMS.Status_Codes |
---|
| 407 | ); |
---|
[a91cc06] | 408 | @end example |
---|
| 409 | @end ifset |
---|
| 410 | |
---|
| 411 | @subheading DIRECTIVE STATUS CODES: |
---|
[bf6d03d] | 412 | @code{@value{RPREFIX}SUCCESSFUL} - current time obtained successfully@* |
---|
| 413 | @code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set@* |
---|
[a91cc06] | 414 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{time_buffer} is NULL |
---|
| 415 | |
---|
| 416 | @subheading DESCRIPTION: |
---|
| 417 | |
---|
[bf6d03d] | 418 | This directive obtains the system date and time. If the date and time |
---|
| 419 | has not been set with a previous call to |
---|
| 420 | @code{@value{DIRPREFIX}clock_set}, then the |
---|
[2d1bdc8] | 421 | @code{@value{RPREFIX}NOT_DEFINED} status code is returned. |
---|
[a91cc06] | 422 | |
---|
[bf6d03d] | 423 | @subheading NOTES: |
---|
| 424 | |
---|
| 425 | This directive is callable from an ISR. |
---|
| 426 | |
---|
| 427 | This directive will not cause the running task to be |
---|
| 428 | preempted. Re-initializing RTEMS causes the system date and |
---|
| 429 | time to be reset to an uninitialized state. Another call to |
---|
| 430 | @code{@value{DIRPREFIX}clock_set} is required to re-initialize the |
---|
| 431 | system date and time to application specific specifications. |
---|
| 432 | |
---|
| 433 | @c |
---|
| 434 | @c |
---|
| 435 | @c |
---|
| 436 | @page |
---|
| 437 | @subsection CLOCK_GET_TOD_TIMEVAL - Get date and time in timeval format |
---|
| 438 | |
---|
| 439 | @cindex obtain the time of day |
---|
| 440 | |
---|
| 441 | @subheading CALLING SEQUENCE: |
---|
| 442 | |
---|
| 443 | @ifset is-C |
---|
| 444 | @findex rtems_clock_get_tod_timeval |
---|
| 445 | @example |
---|
| 446 | rtems_status_code rtems_clock_get_tod( |
---|
| 447 | struct timeval *time |
---|
| 448 | ); |
---|
| 449 | @end example |
---|
| 450 | @end ifset |
---|
| 451 | |
---|
| 452 | @ifset is-Ada |
---|
| 453 | @example |
---|
| 454 | procedure Clock_Get_TOD_Timeval ( |
---|
| 455 | Time : in RTEMS.Timeval; |
---|
| 456 | Result : out RTEMS.Status_Codes |
---|
| 457 | ); |
---|
| 458 | @end example |
---|
| 459 | @end ifset |
---|
| 460 | |
---|
| 461 | @subheading DIRECTIVE STATUS CODES: |
---|
| 462 | @code{@value{RPREFIX}SUCCESSFUL} - current time obtained successfully@* |
---|
| 463 | @code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set@* |
---|
| 464 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{time} is NULL |
---|
| 465 | |
---|
| 466 | @subheading DESCRIPTION: |
---|
| 467 | |
---|
| 468 | This directive obtains the system date and time in POSIX |
---|
| 469 | @code{struct timeval} format. If the date and time |
---|
| 470 | has not been set with a previous call to |
---|
| 471 | @code{@value{DIRPREFIX}clock_set}, then the |
---|
[2d1bdc8] | 472 | @code{@value{RPREFIX}NOT_DEFINED} status code is returned. |
---|
[a91cc06] | 473 | |
---|
| 474 | @subheading NOTES: |
---|
| 475 | |
---|
[bf6d03d] | 476 | This directive is callable from an ISR. |
---|
[a91cc06] | 477 | |
---|
[bf6d03d] | 478 | This directive will not cause the running task to be |
---|
| 479 | preempted. Re-initializing RTEMS causes the system date and |
---|
| 480 | time to be reset to an uninitialized state. Another call to |
---|
| 481 | @code{@value{DIRPREFIX}clock_set} is required to re-initialize the |
---|
| 482 | system date and time to application specific specifications. |
---|
| 483 | |
---|
| 484 | @c |
---|
| 485 | @c |
---|
| 486 | @c |
---|
| 487 | @page |
---|
| 488 | @subsection CLOCK_GET_SECONDS_SINCE_EPOCH - Get seconds since epoch |
---|
| 489 | |
---|
| 490 | @cindex obtain seconds since epoch |
---|
| 491 | |
---|
| 492 | @subheading CALLING SEQUENCE: |
---|
| 493 | |
---|
| 494 | @ifset is-C |
---|
| 495 | @findex rtems_clock_get_seconds_since_epoch |
---|
| 496 | @example |
---|
| 497 | rtems_status_code rtems_clock_get_seconds_since_epoch( |
---|
| 498 | rtems_interval *the_interval |
---|
| 499 | ); |
---|
| 500 | @end example |
---|
| 501 | @end ifset |
---|
| 502 | |
---|
| 503 | @ifset is-Ada |
---|
| 504 | @example |
---|
| 505 | procedure Clock_Get_Seconds_Since_Epoch( |
---|
| 506 | The_Interval : out RTEMS.Interval; |
---|
| 507 | Result : out RTEMS.Status_Codes |
---|
| 508 | ); |
---|
| 509 | @end example |
---|
| 510 | @end ifset |
---|
| 511 | |
---|
| 512 | @subheading DIRECTIVE STATUS CODES: |
---|
| 513 | @code{@value{RPREFIX}SUCCESSFUL} - current time obtained successfully@* |
---|
| 514 | @code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set@* |
---|
| 515 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{the_interval} is NULL |
---|
| 516 | |
---|
| 517 | @subheading DESCRIPTION: |
---|
| 518 | |
---|
| 519 | This directive returns the number of seconds since the RTEMS |
---|
| 520 | epoch and the current system date and time. If the date and time |
---|
| 521 | has not been set with a previous call to |
---|
| 522 | @code{@value{DIRPREFIX}clock_set}, then the |
---|
[2d1bdc8] | 523 | @code{@value{RPREFIX}NOT_DEFINED} status code is returned. |
---|
[bf6d03d] | 524 | |
---|
| 525 | @subheading NOTES: |
---|
| 526 | |
---|
| 527 | This directive is callable from an ISR. |
---|
| 528 | |
---|
| 529 | This directive will not cause the running task to be |
---|
| 530 | preempted. Re-initializing RTEMS causes the system date and |
---|
| 531 | time to be reset to an uninitialized state. Another call to |
---|
| 532 | @code{@value{DIRPREFIX}clock_set} is required to re-initialize the |
---|
| 533 | system date and time to application specific specifications. |
---|
| 534 | |
---|
| 535 | @c |
---|
| 536 | @c |
---|
| 537 | @c |
---|
| 538 | @page |
---|
| 539 | @subsection CLOCK_GET_TICKS_PER_SECOND - Get ticks per second |
---|
| 540 | |
---|
| 541 | @cindex obtain seconds since epoch |
---|
| 542 | |
---|
| 543 | @subheading CALLING SEQUENCE: |
---|
| 544 | |
---|
| 545 | @ifset is-C |
---|
| 546 | @findex rtems_clock_get_ticks_per_second |
---|
| 547 | @example |
---|
[29a3d72c] | 548 | rtems_interval rtems_clock_get_ticks_per_second(void); |
---|
[bf6d03d] | 549 | @end example |
---|
| 550 | @end ifset |
---|
| 551 | |
---|
| 552 | @ifset is-Ada |
---|
| 553 | @example |
---|
| 554 | function Clock_Get_Ticks_Per_Seconds |
---|
| 555 | return RTEMS.Interval; |
---|
| 556 | @end example |
---|
| 557 | @end ifset |
---|
| 558 | |
---|
| 559 | @subheading DIRECTIVE STATUS CODES: |
---|
| 560 | NONE |
---|
| 561 | |
---|
| 562 | @subheading DESCRIPTION: |
---|
| 563 | |
---|
| 564 | This directive returns the number of clock ticks per second. This |
---|
| 565 | is strictly based upon the microseconds per clock tick that the |
---|
| 566 | application has configured. |
---|
| 567 | |
---|
| 568 | @subheading NOTES: |
---|
| 569 | |
---|
| 570 | This directive is callable from an ISR. |
---|
| 571 | |
---|
| 572 | This directive will not cause the running task to be |
---|
| 573 | preempted. Re-initializing RTEMS causes the system date and |
---|
| 574 | time to be reset to an uninitialized state. Another call to |
---|
| 575 | @code{@value{DIRPREFIX}clock_set} is required to re-initialize the |
---|
| 576 | system date and time to application specific specifications. |
---|
| 577 | |
---|
| 578 | @c |
---|
| 579 | @c |
---|
| 580 | @c |
---|
| 581 | @page |
---|
| 582 | @subsection CLOCK_GET_TICKS_SINCE_BOOT - Get ticks since boot |
---|
| 583 | |
---|
| 584 | @cindex obtain ticks since boot |
---|
| 585 | |
---|
| 586 | @subheading CALLING SEQUENCE: |
---|
| 587 | |
---|
| 588 | @ifset is-C |
---|
| 589 | @findex rtems_clock_get_ticks_since_boot |
---|
| 590 | @example |
---|
| 591 | rtems_interval rtems_clock_get_ticks_since_boot(void); |
---|
| 592 | @end example |
---|
| 593 | @end ifset |
---|
| 594 | |
---|
| 595 | @ifset is-Ada |
---|
| 596 | @example |
---|
| 597 | function Clock_Get_Ticks_Since_Boot |
---|
| 598 | return RTEMS.Interval; |
---|
| 599 | @end example |
---|
| 600 | @end ifset |
---|
| 601 | |
---|
| 602 | @subheading DIRECTIVE STATUS CODES: |
---|
| 603 | NONE |
---|
| 604 | |
---|
| 605 | @subheading DESCRIPTION: |
---|
| 606 | |
---|
| 607 | This directive returns the number of clock ticks that have elapsed |
---|
| 608 | since the system was booted. This is the historical measure of uptime |
---|
| 609 | in an RTEMS system. The newer service |
---|
| 610 | @code{@value{DIRPREFIX}clock_get_uptime} is another and potentially |
---|
| 611 | more accurate way of obtaining similar information. |
---|
| 612 | |
---|
| 613 | @subheading NOTES: |
---|
| 614 | |
---|
| 615 | This directive is callable from an ISR. |
---|
| 616 | |
---|
| 617 | This directive will not cause the running task to be |
---|
| 618 | preempted. Re-initializing RTEMS causes the system date and |
---|
| 619 | time to be reset to an uninitialized state. Another call to |
---|
| 620 | @code{@value{DIRPREFIX}clock_set} is required to re-initialize the |
---|
| 621 | system date and time to application specific specifications. |
---|
| 622 | |
---|
| 623 | This directive simply returns the number of times the dirivective |
---|
[2d1bdc8] | 624 | @code{@value{DIRPREFIX}clock_tick} has been invoked since the |
---|
[bf6d03d] | 625 | system was booted. |
---|
[a91cc06] | 626 | |
---|
[bf4d016] | 627 | @c |
---|
| 628 | @c |
---|
| 629 | @c |
---|
| 630 | @page |
---|
[4ffbc49] | 631 | @subsection CLOCK_GET_UPTIME - Get the time since boot |
---|
[bf4d016] | 632 | |
---|
| 633 | @cindex clock get uptime |
---|
| 634 | @cindex uptime |
---|
| 635 | |
---|
| 636 | @subheading CALLING SEQUENCE: |
---|
| 637 | |
---|
| 638 | @ifset is-C |
---|
| 639 | @findex rtems_clock_get_uptime |
---|
| 640 | @example |
---|
| 641 | rtems_status_code rtems_clock_get_uptime( |
---|
| 642 | struct timespec *uptime |
---|
| 643 | ); |
---|
| 644 | @end example |
---|
| 645 | @end ifset |
---|
| 646 | |
---|
| 647 | @ifset is-Ada |
---|
| 648 | @example |
---|
[4ffbc49] | 649 | procedure Clock_Get_Uptime ( |
---|
| 650 | Uptime : out RTEMS.Timespec; |
---|
| 651 | Result : out RTEMS.Status_Codes |
---|
| 652 | ); |
---|
[bf4d016] | 653 | @end example |
---|
| 654 | @end ifset |
---|
| 655 | |
---|
| 656 | @subheading DIRECTIVE STATUS CODES: |
---|
| 657 | @code{@value{RPREFIX}SUCCESSFUL} - clock tick processed successfully@* |
---|
| 658 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{time_buffer} is NULL |
---|
| 659 | |
---|
| 660 | @subheading DESCRIPTION: |
---|
| 661 | |
---|
| 662 | This directive returns the seconds and nanoseconds since the |
---|
| 663 | system was booted. If the BSP supports nanosecond clock |
---|
| 664 | accuracy, the time reported will probably be different on every |
---|
| 665 | call. |
---|
| 666 | |
---|
| 667 | @subheading NOTES: |
---|
| 668 | |
---|
| 669 | This directive may be called from an ISR. |
---|
| 670 | |
---|
[bfddb047] | 671 | @c |
---|
| 672 | @c |
---|
| 673 | @c |
---|
| 674 | @page |
---|
| 675 | @subsection CLOCK_GET_UPTIME_TIMEVAL - Get the time since boot in timeval format |
---|
| 676 | |
---|
| 677 | @cindex clock get uptime |
---|
| 678 | @cindex uptime |
---|
| 679 | |
---|
| 680 | @subheading CALLING SEQUENCE: |
---|
| 681 | |
---|
| 682 | @ifset is-C |
---|
| 683 | @findex rtems_clock_get_uptime_timeval |
---|
| 684 | @example |
---|
| 685 | void rtems_clock_get_uptime_timeval( |
---|
| 686 | struct timeval *uptime |
---|
| 687 | ); |
---|
| 688 | @end example |
---|
| 689 | @end ifset |
---|
| 690 | |
---|
| 691 | @subheading DIRECTIVE STATUS CODES: |
---|
| 692 | |
---|
| 693 | NONE |
---|
| 694 | |
---|
| 695 | @subheading DESCRIPTION: |
---|
| 696 | |
---|
| 697 | This directive returns the seconds and microseconds since the |
---|
| 698 | system was booted. If the BSP supports nanosecond clock |
---|
| 699 | accuracy, the time reported will probably be different on every |
---|
| 700 | call. |
---|
| 701 | |
---|
| 702 | @subheading NOTES: |
---|
| 703 | |
---|
| 704 | This directive may be called from an ISR. |
---|
[bf6d03d] | 705 | |
---|
[90733a86] | 706 | @c |
---|
| 707 | @c |
---|
| 708 | @c |
---|
| 709 | @page |
---|
| 710 | @subsection CLOCK_GET_UPTIME_SECONDS - Get the seconds since boot |
---|
| 711 | |
---|
| 712 | @cindex clock get uptime |
---|
| 713 | @cindex uptime |
---|
| 714 | |
---|
| 715 | @subheading CALLING SEQUENCE: |
---|
| 716 | |
---|
| 717 | @ifset is-C |
---|
| 718 | @findex rtems_clock_get_uptime_seconds |
---|
| 719 | @example |
---|
| 720 | time_t rtems_clock_get_uptime_seconds(void); |
---|
| 721 | @end example |
---|
| 722 | @end ifset |
---|
| 723 | |
---|
| 724 | @subheading DIRECTIVE STATUS CODES: |
---|
| 725 | |
---|
| 726 | The system uptime in seconds. |
---|
| 727 | |
---|
| 728 | @subheading DESCRIPTION: |
---|
| 729 | |
---|
| 730 | This directive returns the seconds since the system was booted. |
---|
| 731 | |
---|
| 732 | @subheading NOTES: |
---|
| 733 | |
---|
| 734 | This directive may be called from an ISR. |
---|
| 735 | |
---|
[2d1bdc8] | 736 | @c |
---|
| 737 | @c |
---|
| 738 | @c |
---|
| 739 | @page |
---|
| 740 | @subsection CLOCK_GET_UPTIME_NANOSECONDS - Get the nanoseconds since boot |
---|
| 741 | |
---|
| 742 | @cindex clock get nanoseconds uptime |
---|
| 743 | @cindex uptime |
---|
| 744 | |
---|
| 745 | @subheading CALLING SEQUENCE: |
---|
| 746 | |
---|
| 747 | @ifset is-C |
---|
| 748 | @findex rtems_clock_get_uptime_nanoseconds |
---|
| 749 | @example |
---|
| 750 | uint64_t rtems_clock_get_uptime_nanoseconds(void); |
---|
| 751 | @end example |
---|
| 752 | @end ifset |
---|
| 753 | |
---|
| 754 | @subheading DIRECTIVE STATUS CODES: |
---|
| 755 | |
---|
| 756 | The system uptime in nanoseconds. |
---|
| 757 | |
---|
| 758 | @subheading DESCRIPTION: |
---|
| 759 | |
---|
| 760 | This directive returns the nanoseconds since the system was booted. |
---|
| 761 | |
---|
| 762 | @subheading NOTES: |
---|
| 763 | |
---|
| 764 | This directive may be called from an ISR. |
---|
| 765 | |
---|
[bf6d03d] | 766 | @c |
---|
| 767 | @c |
---|
| 768 | @c |
---|
| 769 | @page |
---|
| 770 | @subsection CLOCK_SET_NANOSECONDS_EXTENSION - Install the nanoseconds since last tick handler |
---|
| 771 | |
---|
| 772 | @cindex clock set nanoseconds extension |
---|
| 773 | @cindex nanoseconds extension |
---|
| 774 | @cindex nanoseconds time accuracy |
---|
| 775 | |
---|
| 776 | @subheading CALLING SEQUENCE: |
---|
| 777 | |
---|
| 778 | @ifset is-C |
---|
| 779 | @findex rtems_clock_set_nanoseconds_extension |
---|
| 780 | @example |
---|
| 781 | rtems_status_code rtems_clock_set_nanoseconds_extension( |
---|
| 782 | rtems_nanoseconds_extension_routine routine |
---|
| 783 | ); |
---|
| 784 | @end example |
---|
| 785 | @end ifset |
---|
| 786 | |
---|
| 787 | @ifset is-Ada |
---|
| 788 | @example |
---|
| 789 | NOT SUPPORTED FROM Ada BINDING |
---|
| 790 | @end example |
---|
| 791 | @end ifset |
---|
| 792 | |
---|
| 793 | @subheading DIRECTIVE STATUS CODES: |
---|
| 794 | @code{@value{RPREFIX}SUCCESSFUL} - clock tick processed successfully@* |
---|
| 795 | @code{@value{RPREFIX}INVALID_ADDRESS} - @code{time_buffer} is NULL |
---|
| 796 | |
---|
| 797 | @subheading DESCRIPTION: |
---|
| 798 | |
---|
[2d1bdc8] | 799 | This directive is used by the Clock device driver to install the |
---|
[bf6d03d] | 800 | @code{routine} which will be invoked by the internal RTEMS method used to |
---|
| 801 | obtain a highly accurate time of day. It is usually called during |
---|
| 802 | the initialization of the driver. |
---|
| 803 | |
---|
| 804 | When the @code{routine} is invoked, it will determine the number of |
---|
| 805 | nanoseconds which have elapsed since the last invocation of |
---|
| 806 | the @code{@value{DIRPREFIX}clock_tick} directive. It should do |
---|
| 807 | this as quickly as possible with as little impact as possible |
---|
| 808 | on the device used as a clock source. |
---|
| 809 | |
---|
| 810 | @subheading NOTES: |
---|
| 811 | |
---|
| 812 | This directive may be called from an ISR. |
---|
| 813 | |
---|
[2d1bdc8] | 814 | This directive is called as part of every service to obtain the |
---|
[bf6d03d] | 815 | current date and time as well as timestamps. |
---|
| 816 | |
---|
[169502e] | 817 | @c |
---|
| 818 | @c |
---|
| 819 | @c |
---|
[ae68ff0] | 820 | @page |
---|
| 821 | @subsection CLOCK_TICK - Announce a clock tick |
---|
| 822 | |
---|
[169502e] | 823 | @cindex clock tick |
---|
| 824 | |
---|
[ae68ff0] | 825 | @subheading CALLING SEQUENCE: |
---|
| 826 | |
---|
[61389eac] | 827 | @ifset is-C |
---|
[169502e] | 828 | @findex rtems_clock_tick |
---|
[ae68ff0] | 829 | @example |
---|
| 830 | rtems_status_code rtems_clock_tick( void ); |
---|
| 831 | @end example |
---|
[61389eac] | 832 | @end ifset |
---|
| 833 | |
---|
| 834 | @ifset is-Ada |
---|
| 835 | @example |
---|
[4ffbc49] | 836 | procedure Clock_Tick ( |
---|
| 837 | Result : out RTEMS.Status_Codes |
---|
| 838 | ); |
---|
[61389eac] | 839 | @end example |
---|
| 840 | @end ifset |
---|
[ae68ff0] | 841 | |
---|
| 842 | @subheading DIRECTIVE STATUS CODES: |
---|
[f8892c9] | 843 | @code{@value{RPREFIX}SUCCESSFUL} - clock tick processed successfully |
---|
[ae68ff0] | 844 | |
---|
| 845 | @subheading DESCRIPTION: |
---|
| 846 | |
---|
| 847 | This directive announces to RTEMS that a system clock |
---|
| 848 | tick has occurred. The directive is usually called from the |
---|
| 849 | timer interrupt ISR of the local processor. This directive |
---|
| 850 | maintains the system date and time, decrements timers for |
---|
| 851 | delayed tasks, timeouts, rate monotonic periods, and implements |
---|
| 852 | timeslicing. |
---|
| 853 | |
---|
| 854 | @subheading NOTES: |
---|
| 855 | |
---|
| 856 | This directive is typically called from an ISR. |
---|
| 857 | |
---|
[a91cc06] | 858 | The @code{microseconds_per_tick} and @code{ticks_per_timeslice} |
---|
[ae68ff0] | 859 | parameters in the Configuration Table contain the number of |
---|
| 860 | microseconds per tick and number of ticks per timeslice, |
---|
| 861 | respectively. |
---|