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