source: rtems/cpukit/include/rtems/rtems/clock.h @ 675e879

Last change on this file since 675e879 was 675e879, checked in by Sebastian Huber <sebastian.huber@…>, on 11/23/21 at 14:15:27

rtems: Replace "precision" with "resolution"

Resolution is the right term for the documented property.

  • Property mode set to 100644
File size: 38.2 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassicClock
7 *
8 * @brief This header file defines the Clock Manager API.
9 */
10
11/*
12 * Copyright (C) 2014, 2021 embedded brains GmbH (http://www.embedded-brains.de)
13 * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37/*
38 * This file is part of the RTEMS quality process and was automatically
39 * generated.  If you find something that needs to be fixed or
40 * worded better please post a report or patch to an RTEMS mailing list
41 * or raise a bug report:
42 *
43 * https://www.rtems.org/bugs.html
44 *
45 * For information on updating and regenerating please refer to the How-To
46 * section in the Software Requirements Engineering chapter of the
47 * RTEMS Software Engineering manual.  The manual is provided as a part of
48 * a release.  For development sources please refer to the online
49 * documentation at:
50 *
51 * https://docs.rtems.org
52 */
53
54/* Generated from spec:/rtems/clock/if/header */
55
56#ifndef _RTEMS_RTEMS_CLOCK_H
57#define _RTEMS_RTEMS_CLOCK_H
58
59#include <stdbool.h>
60#include <stdint.h>
61#include <time.h>
62#include <rtems/config.h>
63#include <sys/_timespec.h>
64#include <sys/_timeval.h>
65#include <rtems/rtems/status.h>
66#include <rtems/rtems/types.h>
67#include <rtems/score/watchdogticks.h>
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73/* Generated from spec:/rtems/clock/if/group */
74
75/**
76 * @defgroup RTEMSAPIClassicClock Clock Manager
77 *
78 * @ingroup RTEMSAPIClassic
79 *
80 * @brief The Clock Manager provides support for time of day and other time
81 *   related capabilities.
82 */
83
84/* Generated from spec:/rtems/clock/if/bintime */
85
86/* Forward declaration */
87struct bintime;
88
89/* Generated from spec:/rtems/clock/if/set */
90
91/**
92 * @ingroup RTEMSAPIClassicClock
93 *
94 * @brief Sets the CLOCK_REALTIME to the time of day.
95 *
96 * @param time_of_day is the time of day to set the clock.
97 *
98 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
99 *
100 * @retval ::RTEMS_INVALID_ADDRESS The ``time_of_day`` parameter was NULL.
101 *
102 * @retval ::RTEMS_INVALID_CLOCK The time of day specified by ``time_of_day``
103 *   was invalid.
104 *
105 * @par Notes
106 * @parblock
107 * The date, time, and ticks specified by ``time_of_day`` are all
108 * range-checked, and an error is returned if any one is out of its valid
109 * range.
110 *
111 * RTEMS can represent time points of the CLOCK_REALTIME clock in nanoseconds
112 * ranging from 1988-01-01T00:00:00.000000000Z to
113 * 2514-05-31T01:53:03.999999999Z.  The future uptime of the system shall be in
114 * this range, otherwise the system behaviour is undefined.  Due to
115 * implementation constraints, the time of day set by the directive shall be
116 * before 2100-01-01:00:00.000000000Z.  The latest valid time of day accepted
117 * by the POSIX clock_settime() is 2400-01-01T00:00:00.999999999Z.
118 *
119 * The specified time is based on the configured clock tick rate, see the
120 * #CONFIGURE_MICROSECONDS_PER_TICK application configuration option.
121 *
122 * Setting the time forward will fire all CLOCK_REALTIME timers which are
123 * scheduled at a time point before or at the time set by the directive.  This
124 * may unblock tasks, which may preempt the calling task. User-provided timer
125 * routines will execute in the context of the caller.
126 *
127 * It is allowed to call this directive from within interrupt context, however,
128 * this is not recommended since an arbitrary number of timers may fire.
129 *
130 * The directive shall be called at least once to enable the service of
131 * CLOCK_REALTIME related directives.  If the clock is not set at least once,
132 * they may return an error status.
133 * @endparblock
134 *
135 * @par Constraints
136 * @parblock
137 * The following constraints apply to this directive:
138 *
139 * * The directive may be called from within any runtime context.
140 *
141 * * The directive may change the priority of a task.  This may cause the
142 *   calling task to be preempted.
143 *
144 * * The directive may unblock a task.  This may cause the calling task to be
145 *   preempted.
146 *
147 * * The time of day set by the directive shall be
148 *   1988-01-01T00:00:00.000000000Z or later.
149 *
150 * * The time of day set by the directive shall be before
151 *   2100-01-01T00:00:00.000000000Z.
152 * @endparblock
153 */
154rtems_status_code rtems_clock_set( const rtems_time_of_day *time_of_day );
155
156/* Generated from spec:/rtems/clock/if/get-tod */
157
158/**
159 * @ingroup RTEMSAPIClassicClock
160 *
161 * @brief Gets the time of day associated with the current CLOCK_REALTIME.
162 *
163 * @param time_of_day is the pointer to an rtems_time_of_day object.  When the
164 *   directive call is successful, the time of day associated with the
165 *   CLOCK_REALTIME at some point during the directive call will be stored in
166 *   this object.
167 *
168 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
169 *
170 * @retval ::RTEMS_INVALID_ADDRESS The ``time_of_day`` parameter was NULL.
171 *
172 * @retval ::RTEMS_NOT_DEFINED The CLOCK_REALTIME was not set.  It can be set
173 *   with rtems_clock_set().
174 *
175 * @par Constraints
176 * @parblock
177 * The following constraints apply to this directive:
178 *
179 * * The directive may be called from within any runtime context.
180 *
181 * * The directive will not cause the calling task to be preempted.
182 *
183 * * The directive requires a Clock Driver.
184 * @endparblock
185 */
186rtems_status_code rtems_clock_get_tod( rtems_time_of_day *time_of_day );
187
188/* Generated from spec:/rtems/clock/if/get-tod-timeval */
189
190/**
191 * @ingroup RTEMSAPIClassicClock
192 *
193 * @brief Gets the seconds and microseconds elapsed since the Unix epoch and
194 *   the current CLOCK_REALTIME.
195 *
196 * @param[out] time_of_day is the pointer to a struct timeval object.  When the
197 *   directive call is successful, the seconds and microseconds elapsed since
198 *   the Unix epoch and the CLOCK_REALTIME at some point during the directive
199 *   call will be stored in this object.
200 *
201 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
202 *
203 * @retval ::RTEMS_INVALID_ADDRESS The ``time_of_day`` parameter was NULL.
204 *
205 * @retval ::RTEMS_NOT_DEFINED The CLOCK_REALTIME was not set.  It can be set
206 *   with rtems_clock_set().
207 *
208 * @par Constraints
209 * @parblock
210 * The following constraints apply to this directive:
211 *
212 * * The directive may be called from within any runtime context.
213 *
214 * * The directive will not cause the calling task to be preempted.
215 *
216 * * The directive requires a Clock Driver.
217 * @endparblock
218 */
219rtems_status_code rtems_clock_get_tod_timeval( struct timeval *time_of_day );
220
221/* Generated from spec:/rtems/clock/if/get-realtime */
222
223/**
224 * @ingroup RTEMSAPIClassicClock
225 *
226 * @brief Gets the time elapsed since the Unix epoch measured using
227 *   CLOCK_REALTIME in seconds and nanoseconds format.
228 *
229 * @param[out] time_snapshot is the pointer to a struct timespec object.  The
230 *   time elapsed since the Unix epoch measured using the CLOCK_REALTIME at
231 *   some time point during the directive call will be stored in this object.
232 *   Calling the directive with a pointer equal to NULL is undefined behaviour.
233 *
234 * @par Notes
235 * @parblock
236 * The directive accesses a device provided by the Clock Driver to get the time
237 * in the highest resolution available to the system.  Alternatively, the
238 * rtems_clock_get_realtime_coarse() directive may be used to get the time in a
239 * lower resolution and with less runtime overhead.
240 *
241 * See rtems_clock_get_realtime_bintime() and
242 * rtems_clock_get_realtime_timeval() to get the time in alternative formats.
243 * @endparblock
244 *
245 * @par Constraints
246 * @parblock
247 * The following constraints apply to this directive:
248 *
249 * * The directive may be called from within any runtime context.
250 *
251 * * The directive will not cause the calling task to be preempted.
252 *
253 * * The directive requires a Clock Driver.
254 * @endparblock
255 */
256void rtems_clock_get_realtime( struct timespec *time_snapshot );
257
258/* Generated from spec:/rtems/clock/if/get-realtime-bintime */
259
260/**
261 * @ingroup RTEMSAPIClassicClock
262 *
263 * @brief Gets the time elapsed since the Unix epoch measured using
264 *   CLOCK_REALTIME in binary time format.
265 *
266 * @param[out] time_snapshot is the pointer to a bintime object.  The time
267 *   elapsed since the Unix epoch measured using the CLOCK_REALTIME at some
268 *   time point during the directive call will be stored in this object.
269 *   Calling the directive with a pointer equal to NULL is undefined behaviour.
270 *
271 * @par Notes
272 * @parblock
273 * The directive accesses a device provided by the Clock Driver to get the time
274 * in the highest resolution available to the system.  Alternatively, the
275 * rtems_clock_get_realtime_coarse_bintime() directive may be used to get the
276 * time in a lower resolution and with less runtime overhead.
277 *
278 * See rtems_clock_get_realtime() and rtems_clock_get_realtime_timeval() to get
279 * the time in alternative formats.
280 * @endparblock
281 *
282 * @par Constraints
283 * @parblock
284 * The following constraints apply to this directive:
285 *
286 * * The directive may be called from within any runtime context.
287 *
288 * * The directive will not cause the calling task to be preempted.
289 *
290 * * The directive requires a Clock Driver.
291 * @endparblock
292 */
293void rtems_clock_get_realtime_bintime( struct bintime *time_snapshot );
294
295/* Generated from spec:/rtems/clock/if/get-realtime-timeval */
296
297/**
298 * @ingroup RTEMSAPIClassicClock
299 *
300 * @brief Gets the time elapsed since the Unix epoch measured using
301 *   CLOCK_REALTIME in seconds and microseconds format.
302 *
303 * @param[out] time_snapshot is the pointer to a struct timeval object.  The
304 *   time elapsed since the Unix epoch measured using the CLOCK_REALTIME at
305 *   some time point during the directive call will be stored in this object.
306 *   Calling the directive with a pointer equal to NULL is undefined behaviour.
307 *
308 * @par Notes
309 * @parblock
310 * The directive accesses a device provided by the Clock Driver to get the time
311 * in the highest resolution available to the system.  Alternatively, the
312 * rtems_clock_get_realtime_coarse_timeval() directive may be used to get the
313 * time in a lower resolution and with less runtime overhead.
314 *
315 * See rtems_clock_get_realtime() and rtems_clock_get_realtime_bintime() to get
316 * the time in alternative formats.
317 * @endparblock
318 *
319 * @par Constraints
320 * @parblock
321 * The following constraints apply to this directive:
322 *
323 * * The directive may be called from within any runtime context.
324 *
325 * * The directive will not cause the calling task to be preempted.
326 *
327 * * The directive requires a Clock Driver.
328 * @endparblock
329 */
330void rtems_clock_get_realtime_timeval( struct timeval *time_snapshot );
331
332/* Generated from spec:/rtems/clock/if/get-realtime-coarse */
333
334/**
335 * @ingroup RTEMSAPIClassicClock
336 *
337 * @brief Gets the time elapsed since the Unix epoch measured using
338 *   CLOCK_REALTIME in coarse resolution in seconds and nanoseconds format.
339 *
340 * @param[out] time_snapshot is the pointer to a struct timespec object.  The
341 *   time elapsed since the Unix epoch measured using the CLOCK_REALTIME at
342 *   some time point close to the directive call will be stored in this object.
343 *   Calling the directive with a pointer equal to NULL is undefined behaviour.
344 *
345 * @par Notes
346 * @parblock
347 * The directive does not access a device to get the time.  It uses a recent
348 * snapshot provided by the Clock Driver.  Alternatively, the
349 * rtems_clock_get_realtime() directive may be used to get the time in a higher
350 * resolution and with a higher runtime overhead.
351 *
352 * See rtems_clock_get_realtime_coarse_bintime() and
353 * rtems_clock_get_realtime_coarse_timeval() to get the time in alternative
354 * formats.
355 * @endparblock
356 *
357 * @par Constraints
358 * @parblock
359 * The following constraints apply to this directive:
360 *
361 * * The directive may be called from within any runtime context.
362 *
363 * * The directive will not cause the calling task to be preempted.
364 *
365 * * The directive requires a Clock Driver.
366 * @endparblock
367 */
368void rtems_clock_get_realtime_coarse( struct timespec *time_snapshot );
369
370/* Generated from spec:/rtems/clock/if/get-realtime-coarse-bintime */
371
372/**
373 * @ingroup RTEMSAPIClassicClock
374 *
375 * @brief Gets the time elapsed since the Unix epoch measured using
376 *   CLOCK_REALTIME in coarse resolution in binary time format.
377 *
378 * @param[out] time_snapshot is the pointer to a bintime object.  The time
379 *   elapsed since the Unix epoch measured using the CLOCK_REALTIME at some
380 *   time point close to the directive call will be stored in this object.
381 *   Calling the directive with a pointer equal to NULL is undefined behaviour.
382 *
383 * @par Notes
384 * @parblock
385 * The directive does not access a device to get the time.  It uses a recent
386 * snapshot provided by the Clock Driver.  Alternatively, the
387 * rtems_clock_get_realtime_bintime() directive may be used to get the time in
388 * a higher resolution and with a higher runtime overhead.
389 *
390 * See rtems_clock_get_realtime_coarse() and
391 * rtems_clock_get_realtime_coarse_timeval() to get the time in alternative
392 * formats.
393 * @endparblock
394 *
395 * @par Constraints
396 * @parblock
397 * The following constraints apply to this directive:
398 *
399 * * The directive may be called from within any runtime context.
400 *
401 * * The directive will not cause the calling task to be preempted.
402 *
403 * * The directive requires a Clock Driver.
404 * @endparblock
405 */
406void rtems_clock_get_realtime_coarse_bintime( struct bintime *time_snapshot );
407
408/* Generated from spec:/rtems/clock/if/get-realtime-coarse-timeval */
409
410/**
411 * @ingroup RTEMSAPIClassicClock
412 *
413 * @brief Gets the time elapsed since the Unix epoch measured using
414 *   CLOCK_REALTIME in coarse resolution in seconds and microseconds format.
415 *
416 * @param[out] time_snapshot is the pointer to a struct timeval object.  The
417 *   time elapsed since the Unix epoch measured using the CLOCK_REALTIME at
418 *   some time point close to the directive call will be stored in this object.
419 *   Calling the directive with a pointer equal to NULL is undefined behaviour.
420 *
421 * @par Notes
422 * @parblock
423 * The directive does not access a device to get the time.  It uses a recent
424 * snapshot provided by the Clock Driver.  Alternatively, the
425 * rtems_clock_get_realtime_timeval() directive may be used to get the time in
426 * a higher resolution and with a higher runtime overhead.
427 *
428 * See rtems_clock_get_realtime_coarse() and
429 * rtems_clock_get_realtime_coarse_timeval() to get the time in alternative
430 * formats.
431 * @endparblock
432 *
433 * @par Constraints
434 * @parblock
435 * The following constraints apply to this directive:
436 *
437 * * The directive may be called from within any runtime context.
438 *
439 * * The directive will not cause the calling task to be preempted.
440 *
441 * * The directive requires a Clock Driver.
442 * @endparblock
443 */
444void rtems_clock_get_realtime_coarse_timeval( struct timeval *time_snapshot );
445
446/* Generated from spec:/rtems/clock/if/get-monotonic */
447
448/**
449 * @ingroup RTEMSAPIClassicClock
450 *
451 * @brief Gets the time elapsed since some fixed time point in the past
452 *   measured using the CLOCK_MONOTONIC in seconds and nanoseconds format.
453 *
454 * @param[out] time_snapshot is the pointer to a bintime object.  The time
455 *   elapsed since some fixed time point in the past measured using the
456 *   CLOCK_MONOTONIC at some time point during the directive call will be
457 *   stored in this object.  Calling the directive with a pointer equal to NULL
458 *   is undefined behaviour.
459 *
460 * @par Notes
461 * @parblock
462 * The directive accesses a device provided by the Clock Driver to get the time
463 * in the highest resolution available to the system.  Alternatively, the
464 * rtems_clock_get_monotonic_coarse() directive may be used to get the time
465 * with in a lower resolution and with less runtime overhead.
466 *
467 * See rtems_clock_get_monotonic_bintime(),
468 * rtems_clock_get_monotonic_sbintime(), and
469 * rtems_clock_get_monotonic_timeval() to get the time in alternative formats.
470 * @endparblock
471 *
472 * @par Constraints
473 * @parblock
474 * The following constraints apply to this directive:
475 *
476 * * The directive may be called from within any runtime context.
477 *
478 * * The directive will not cause the calling task to be preempted.
479 *
480 * * The directive requires a Clock Driver.
481 * @endparblock
482 */
483void rtems_clock_get_monotonic( struct timespec *time_snapshot );
484
485/* Generated from spec:/rtems/clock/if/get-monotonic-bintime */
486
487/**
488 * @ingroup RTEMSAPIClassicClock
489 *
490 * @brief Gets the time elapsed since some fixed time point in the past
491 *   measured using the CLOCK_MONOTONIC in binary time format.
492 *
493 * @param[out] time_snapshot is the pointer to a bintime object.  The time
494 *   elapsed since some fixed time point in the past measured using the
495 *   CLOCK_MONOTONIC at some time point during the directive call will be
496 *   stored in this object.  Calling the directive with a pointer equal to NULL
497 *   is undefined behaviour.
498 *
499 * @par Notes
500 * @parblock
501 * The directive accesses a device provided by the Clock Driver to get the time
502 * in the highest resolution available to the system.  Alternatively, the
503 * rtems_clock_get_monotonic_coarse_bintime() directive may be used to get the
504 * time in a lower resolution and with less runtime overhead.
505 *
506 * See rtems_clock_get_monotonic(), rtems_clock_get_monotonic_sbintime(), and
507 * rtems_clock_get_monotonic_timeval() to get the time in alternative formats.
508 * @endparblock
509 *
510 * @par Constraints
511 * @parblock
512 * The following constraints apply to this directive:
513 *
514 * * The directive may be called from within any runtime context.
515 *
516 * * The directive will not cause the calling task to be preempted.
517 *
518 * * The directive requires a Clock Driver.
519 * @endparblock
520 */
521void rtems_clock_get_monotonic_bintime( struct bintime *time_snapshot );
522
523/* Generated from spec:/rtems/clock/if/get-monotonic-sbintime */
524
525/**
526 * @ingroup RTEMSAPIClassicClock
527 *
528 * @brief Gets the time elapsed since some fixed time point in the past
529 *   measured using the CLOCK_MONOTONIC in signed binary time format.
530 *
531 * @return Returns the time elapsed since some fixed time point in the past
532 *   measured using the CLOCK_MONOTONIC at some time point during the directive
533 *   call.
534 *
535 * @par Notes
536 * @parblock
537 * The directive accesses a device provided by the Clock Driver to get the time
538 * in the highest resolution available to the system.
539 *
540 * See rtems_clock_get_monotonic(), rtems_clock_get_monotonic_bintime(), and
541 * rtems_clock_get_monotonic_timeval() to get the time in alternative formats.
542 * @endparblock
543 *
544 * @par Constraints
545 * @parblock
546 * The following constraints apply to this directive:
547 *
548 * * The directive may be called from within any runtime context.
549 *
550 * * The directive will not cause the calling task to be preempted.
551 *
552 * * The directive requires a Clock Driver.
553 * @endparblock
554 */
555int64_t rtems_clock_get_monotonic_sbintime( void );
556
557/* Generated from spec:/rtems/clock/if/get-monotonic-timeval */
558
559/**
560 * @ingroup RTEMSAPIClassicClock
561 *
562 * @brief Gets the time elapsed since some fixed time point in the past
563 *   measured using the CLOCK_MONOTONIC in seconds and microseconds format.
564 *
565 * @param[out] time_snapshot is the pointer to a bintime object.  The time
566 *   elapsed since some fixed time point in the past measured using the
567 *   CLOCK_MONOTONIC at some time point during the directive call will be
568 *   stored in this object.  Calling the directive with a pointer equal to NULL
569 *   is undefined behaviour.
570 *
571 * @par Notes
572 * @parblock
573 * The directive accesses a device provided by the Clock Driver to get the time
574 * in the highest resolution available to the system.  Alternatively, the
575 * rtems_clock_get_monotonic_coarse_timeval() directive may be used to get the
576 * time in a lower resolution and with less runtime overhead.
577 *
578 * See rtems_clock_get_monotonic(), rtems_clock_get_monotonic_bintime(), and
579 * rtems_clock_get_monotonic_sbintime() to get the time in alternative formats.
580 * @endparblock
581 *
582 * @par Constraints
583 * @parblock
584 * The following constraints apply to this directive:
585 *
586 * * The directive may be called from within any runtime context.
587 *
588 * * The directive will not cause the calling task to be preempted.
589 *
590 * * The directive requires a Clock Driver.
591 * @endparblock
592 */
593void rtems_clock_get_monotonic_timeval( struct timeval *time_snapshot );
594
595/* Generated from spec:/rtems/clock/if/get-monotonic-coarse */
596
597/**
598 * @ingroup RTEMSAPIClassicClock
599 *
600 * @brief Gets the time elapsed since some fixed time point in the past
601 *   measured using the CLOCK_MONOTONIC in coarse resolution in seconds and
602 *   nanoseconds format.
603 *
604 * @param[out] time_snapshot is the pointer to a bintime object.  The time
605 *   elapsed since some fixed time point in the past measured using the
606 *   CLOCK_MONOTONIC at some time point close to the directive call will be
607 *   stored in this object.  Calling the directive with a pointer equal to NULL
608 *   is undefined behaviour.
609 *
610 * @par Notes
611 * @parblock
612 * The directive does not access a device to get the time.  It uses a recent
613 * snapshot provided by the Clock Driver.  Alternatively, the
614 * rtems_clock_get_monotonic() directive may be used to get the time in a
615 * higher resolution and with a higher runtime overhead.
616 *
617 * See rtems_clock_get_monotonic_coarse_bintime() and
618 * rtems_clock_get_monotonic_coarse_timeval() to get the time in alternative
619 * formats.
620 * @endparblock
621 *
622 * @par Constraints
623 * @parblock
624 * The following constraints apply to this directive:
625 *
626 * * The directive may be called from within any runtime context.
627 *
628 * * The directive will not cause the calling task to be preempted.
629 *
630 * * The directive requires a Clock Driver.
631 * @endparblock
632 */
633void rtems_clock_get_monotonic_coarse( struct timespec *time_snapshot );
634
635/* Generated from spec:/rtems/clock/if/get-monotonic-coarse-bintime */
636
637/**
638 * @ingroup RTEMSAPIClassicClock
639 *
640 * @brief Gets the time elapsed since some fixed time point in the past
641 *   measured using the CLOCK_MONOTONIC in coarse resolution in binary time
642 *   format.
643 *
644 * @param[out] time_snapshot is the pointer to a bintime object.  The time
645 *   elapsed since some fixed time point in the past measured using the
646 *   CLOCK_MONOTONIC at some time point close to the directive call will be
647 *   stored in this object.  Calling the directive with a pointer equal to NULL
648 *   is undefined behaviour.
649 *
650 * @par Notes
651 * @parblock
652 * The directive does not access a device to get the time.  It uses a recent
653 * snapshot provided by the Clock Driver.  Alternatively, the
654 * rtems_clock_get_monotonic_bintime() directive may be used to get the time in
655 * a higher resolution and with a higher runtime overhead.
656 *
657 * See rtems_clock_get_monotonic_coarse() and
658 * rtems_clock_get_monotonic_coarse_timeval() to get the time in alternative
659 * formats.
660 * @endparblock
661 *
662 * @par Constraints
663 * @parblock
664 * The following constraints apply to this directive:
665 *
666 * * The directive may be called from within any runtime context.
667 *
668 * * The directive will not cause the calling task to be preempted.
669 *
670 * * The directive requires a Clock Driver.
671 * @endparblock
672 */
673void rtems_clock_get_monotonic_coarse_bintime( struct bintime *time_snapshot );
674
675/* Generated from spec:/rtems/clock/if/get-monotonic-coarse-timeval */
676
677/**
678 * @ingroup RTEMSAPIClassicClock
679 *
680 * @brief Gets the time elapsed since some fixed time point in the past
681 *   measured using the CLOCK_MONOTONIC in coarse resolution in seconds and
682 *   microseconds format.
683 *
684 * @param[out] time_snapshot is the pointer to a bintime object.  The time
685 *   elapsed since some fixed time point in the past measured using the
686 *   CLOCK_MONOTONIC at some time point close to the directive call will be
687 *   stored in this object.  Calling the directive with a pointer equal to NULL
688 *   is undefined behaviour.
689 *
690 * @par Notes
691 * @parblock
692 * The directive does not access a device to get the time.  It uses a recent
693 * snapshot provided by the Clock Driver.  Alternatively, the
694 * rtems_clock_get_monotonic_timeval() directive may be used to get the time in
695 * a higher resolution and with a higher runtime overhead.
696 *
697 * See rtems_clock_get_monotonic_coarse() and
698 * rtems_clock_get_monotonic_coarse_bintime() to get the time in alternative
699 * formats.
700 * @endparblock
701 *
702 * @par Constraints
703 * @parblock
704 * The following constraints apply to this directive:
705 *
706 * * The directive may be called from within any runtime context.
707 *
708 * * The directive will not cause the calling task to be preempted.
709 *
710 * * The directive requires a Clock Driver.
711 * @endparblock
712 */
713void rtems_clock_get_monotonic_coarse_timeval( struct timeval *time_snapshot );
714
715/* Generated from spec:/rtems/clock/if/get-boot-time */
716
717/**
718 * @ingroup RTEMSAPIClassicClock
719 *
720 * @brief Gets the time elapsed since the Unix epoch at some time point during
721 *   system initialization in seconds and nanoseconds format.
722 *
723 * @param[out] boot_time is the pointer to a struct timespec object.  The time
724 *   elapsed since the Unix epoch at some time point during system
725 *   initialization call will be stored in this object.  Calling the directive
726 *   with a pointer equal to NULL is undefined behaviour.
727 *
728 * @par Notes
729 * See rtems_clock_get_boot_time_bintime() and
730 * rtems_clock_get_boot_time_timeval() to get the boot time in alternative
731 * formats.  Setting the CLOCK_REALTIME will also set the boot time.
732 *
733 * @par Constraints
734 * @parblock
735 * The following constraints apply to this directive:
736 *
737 * * The directive may be called from within any runtime context.
738 *
739 * * The directive will not cause the calling task to be preempted.
740 *
741 * * The directive requires a Clock Driver.
742 * @endparblock
743 */
744void rtems_clock_get_boot_time( struct timespec *boot_time );
745
746/* Generated from spec:/rtems/clock/if/get-boot-time-bintime */
747
748/**
749 * @ingroup RTEMSAPIClassicClock
750 *
751 * @brief Gets the time elapsed since the Unix epoch at some time point during
752 *   system initialization in binary time format.
753 *
754 * @param[out] boot_time is the pointer to a bintime object.  The time elapsed
755 *   since the Unix epoch at some time point during system initialization call
756 *   will be stored in this object.  Calling the directive with a pointer equal
757 *   to NULL is undefined behaviour.
758 *
759 * @par Notes
760 * See rtems_clock_get_boot_time() and rtems_clock_get_boot_time_timeval() to
761 * get the boot time in alternative formats.  Setting the CLOCK_REALTIME will
762 * also set the boot time.
763 *
764 * @par Constraints
765 * @parblock
766 * The following constraints apply to this directive:
767 *
768 * * The directive may be called from within any runtime context.
769 *
770 * * The directive will not cause the calling task to be preempted.
771 *
772 * * The directive requires a Clock Driver.
773 * @endparblock
774 */
775void rtems_clock_get_boot_time_bintime( struct bintime *boot_time );
776
777/* Generated from spec:/rtems/clock/if/get-boot-time-timeval */
778
779/**
780 * @ingroup RTEMSAPIClassicClock
781 *
782 * @brief Gets the time elapsed since the Unix epoch at some time point during
783 *   system initialization in seconds and microseconds format.
784 *
785 * @param[out] boot_time is the pointer to a struct timeval object.  The time
786 *   elapsed since the Unix epoch at some time point during system
787 *   initialization call will be stored in this object.  Calling the directive
788 *   with a pointer equal to NULL is undefined behaviour.
789 *
790 * @par Notes
791 * See rtems_clock_get_boot_time() and rtems_clock_get_boot_time_bintime() to
792 * get the boot time in alternative formats.  Setting the CLOCK_REALTIME will
793 * also set the boot time.
794 *
795 * @par Constraints
796 * @parblock
797 * The following constraints apply to this directive:
798 *
799 * * The directive may be called from within any runtime context.
800 *
801 * * The directive will not cause the calling task to be preempted.
802 *
803 * * The directive requires a Clock Driver.
804 * @endparblock
805 */
806void rtems_clock_get_boot_time_timeval( struct timeval *boot_time );
807
808/* Generated from spec:/rtems/clock/if/get-seconds-since-epoch */
809
810/**
811 * @ingroup RTEMSAPIClassicClock
812 *
813 * @brief Gets the seconds elapsed since the RTEMS epoch and the current
814 *   CLOCK_REALTIME.
815 *
816 * @param[out] seconds_since_rtems_epoch is the pointer to an ::rtems_interval
817 *   object.  When the directive call is successful, the seconds elapsed since
818 *   the RTEMS epoch and the CLOCK_REALTIME at some point during the directive
819 *   call will be stored in this object.
820 *
821 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
822 *
823 * @retval ::RTEMS_INVALID_ADDRESS The ``seconds_since_rtems_epoch`` parameter
824 *   was NULL.
825 *
826 * @retval ::RTEMS_NOT_DEFINED The CLOCK_REALTIME was not set.  It can be set
827 *   with rtems_clock_set().
828 *
829 * @par Constraints
830 * @parblock
831 * The following constraints apply to this directive:
832 *
833 * * The directive may be called from within any runtime context.
834 *
835 * * The directive will not cause the calling task to be preempted.
836 *
837 * * The directive requires a Clock Driver.
838 * @endparblock
839 */
840rtems_status_code rtems_clock_get_seconds_since_epoch(
841  rtems_interval *seconds_since_rtems_epoch
842);
843
844/* Generated from spec:/rtems/clock/if/get-ticks-per-second */
845
846/**
847 * @ingroup RTEMSAPIClassicClock
848 *
849 * @brief Gets the number of clock ticks per second configured for the
850 *   application.
851 *
852 * @return Returns the number of clock ticks per second configured for this
853 *   application.
854 *
855 * @par Notes
856 * The number of clock ticks per second is defined indirectly by the
857 * #CONFIGURE_MICROSECONDS_PER_TICK configuration option.
858 *
859 * @par Constraints
860 * @parblock
861 * The following constraints apply to this directive:
862 *
863 * * The directive may be called from within any runtime context.
864 *
865 * * The directive will not cause the calling task to be preempted.
866 * @endparblock
867 */
868rtems_interval rtems_clock_get_ticks_per_second( void );
869
870/* Generated from spec:/rtems/clock/if/get-ticks-per-second-macro */
871#define rtems_clock_get_ticks_per_second() _Watchdog_Ticks_per_second
872
873/* Generated from spec:/rtems/clock/if/get-ticks-since-boot */
874
875/**
876 * @ingroup RTEMSAPIClassicClock
877 *
878 * @brief Gets the number of clock ticks since some time point during the
879 *   system initialization or the last overflow of the clock tick counter.
880 *
881 * @return Returns the number of clock ticks since some time point during the
882 *   system initialization or the last overflow of the clock tick counter.
883 *
884 * @par Notes
885 * With a 1ms clock tick, this counter overflows after 50 days since boot.
886 * This is the historical measure of uptime in an RTEMS system.  The newer
887 * service rtems_clock_get_uptime() is another and potentially more accurate
888 * way of obtaining similar information.
889 *
890 * @par Constraints
891 * @parblock
892 * The following constraints apply to this directive:
893 *
894 * * The directive may be called from within any runtime context.
895 *
896 * * The directive will not cause the calling task to be preempted.
897 * @endparblock
898 */
899rtems_interval rtems_clock_get_ticks_since_boot( void );
900
901/* Generated from spec:/rtems/clock/if/get-ticks-since-boot-macro */
902#define rtems_clock_get_ticks_since_boot() _Watchdog_Ticks_since_boot
903
904/* Generated from spec:/rtems/clock/if/get-uptime */
905
906/**
907 * @ingroup RTEMSAPIClassicClock
908 *
909 * @brief Gets the seconds and nanoseconds elapsed since some time point during
910 *   the system initialization using CLOCK_MONOTONIC.
911 *
912 * @param[out] uptime is the pointer to a struct timeval object.  When the
913 *   directive call is successful, the seconds and nanoseconds elapsed since
914 *   some time point during the system initialization and some point during the
915 *   directive call using CLOCK_MONOTONIC will be stored in this object.
916 *
917 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
918 *
919 * @retval ::RTEMS_INVALID_ADDRESS The ``uptime`` parameter was NULL.
920 *
921 * @par Constraints
922 * @parblock
923 * The following constraints apply to this directive:
924 *
925 * * The directive may be called from within any runtime context.
926 *
927 * * The directive will not cause the calling task to be preempted.
928 *
929 * * The directive requires a Clock Driver.
930 * @endparblock
931 */
932rtems_status_code rtems_clock_get_uptime( struct timespec *uptime );
933
934/* Generated from spec:/rtems/clock/if/get-uptime-timeval */
935
936/**
937 * @ingroup RTEMSAPIClassicClock
938 *
939 * @brief Gets the seconds and microseconds elapsed since some time point
940 *   during the system initialization using CLOCK_MONOTONIC.
941 *
942 * @param[out] uptime is the pointer to a struct timeval object.  The seconds
943 *   and microseconds elapsed since some time point during the system
944 *   initialization and some point during the directive call using
945 *   CLOCK_MONOTONIC will be stored in this object.  The pointer shall be
946 *   valid, otherwise the behaviour is undefined.
947 *
948 * @par Constraints
949 * @parblock
950 * The following constraints apply to this directive:
951 *
952 * * The directive may be called from within any runtime context.
953 *
954 * * The directive will not cause the calling task to be preempted.
955 *
956 * * The directive requires a Clock Driver.
957 * @endparblock
958 */
959void rtems_clock_get_uptime_timeval( struct timeval *uptime );
960
961/* Generated from spec:/rtems/clock/if/get-uptime-seconds */
962
963/**
964 * @ingroup RTEMSAPIClassicClock
965 *
966 * @brief Gets the seconds elapsed since some time point during the system
967 *   initialization using CLOCK_MONOTONIC.
968 *
969 * @return Returns the seconds elapsed since some time point during the system
970 *   initialization and some point during the directive call using
971 *   CLOCK_MONOTONIC.
972 *
973 * @par Constraints
974 * @parblock
975 * The following constraints apply to this directive:
976 *
977 * * The directive may be called from within any runtime context.
978 *
979 * * The directive will not cause the calling task to be preempted.
980 *
981 * * The directive requires a Clock Driver.
982 * @endparblock
983 */
984time_t rtems_clock_get_uptime_seconds( void );
985
986/* Generated from spec:/rtems/clock/if/get-uptime-nanoseconds */
987
988/**
989 * @ingroup RTEMSAPIClassicClock
990 *
991 * @brief Gets the nanoseconds elapsed since some time point during the system
992 *   initialization using CLOCK_MONOTONIC.
993 *
994 * @return Returns the nanoseconds elapsed since some time point during the
995 *   system initialization and some point during the directive call using
996 *   CLOCK_MONOTONIC.
997 *
998 * @par Constraints
999 * @parblock
1000 * The following constraints apply to this directive:
1001 *
1002 * * The directive may be called from within any runtime context.
1003 *
1004 * * The directive will not cause the calling task to be preempted.
1005 *
1006 * * The directive requires a Clock Driver.
1007 * @endparblock
1008 */
1009uint64_t rtems_clock_get_uptime_nanoseconds( void );
1010
1011/* Generated from spec:/rtems/clock/if/tick-later */
1012
1013/**
1014 * @ingroup RTEMSAPIClassicClock
1015 *
1016 * @brief Gets a clock tick value which is at least delta clock ticks in the
1017 *   future.
1018 *
1019 * @param delta is the delta value in clock ticks.
1020 *
1021 * @return Returns a clock tick counter value which is at least ``delta`` clock
1022 *   ticks in the future.
1023 *
1024 * @par Constraints
1025 * @parblock
1026 * The following constraints apply to this directive:
1027 *
1028 * * The directive may be called from within any runtime context.
1029 *
1030 * * The directive will not cause the calling task to be preempted.
1031 *
1032 * * The directive requires a Clock Driver.
1033 * @endparblock
1034 */
1035static inline rtems_interval rtems_clock_tick_later( rtems_interval delta )
1036{
1037  return _Watchdog_Ticks_since_boot + delta;
1038}
1039
1040/* Generated from spec:/rtems/clock/if/tick-later-usec */
1041
1042/**
1043 * @ingroup RTEMSAPIClassicClock
1044 *
1045 * @brief Gets a clock tick value which is at least delta microseconds in the
1046 *   future.
1047 *
1048 * @param delta_in_usec is the delta value in microseconds.
1049 *
1050 * @return Returns a clock tick counter value which is at least
1051 *   ``delta_in_usec`` microseconds in the future.
1052 *
1053 * @par Constraints
1054 * @parblock
1055 * The following constraints apply to this directive:
1056 *
1057 * * The directive may be called from within any runtime context.
1058 *
1059 * * The directive will not cause the calling task to be preempted.
1060 *
1061 * * The directive requires a Clock Driver.
1062 * @endparblock
1063 */
1064static inline rtems_interval rtems_clock_tick_later_usec(
1065  rtems_interval delta_in_usec
1066)
1067{
1068  rtems_interval us_per_tick;
1069
1070  us_per_tick = rtems_configuration_get_microseconds_per_tick();
1071
1072  /*
1073   * Add one additional tick, since we do not know the time to the clock
1074   * next tick.
1075   */
1076  return _Watchdog_Ticks_since_boot + 1
1077    + ( delta_in_usec + us_per_tick - 1 ) / us_per_tick;
1078}
1079
1080/* Generated from spec:/rtems/clock/if/tick-before */
1081
1082/**
1083 * @ingroup RTEMSAPIClassicClock
1084 *
1085 * @brief Indicates if the current clock tick counter is before the ticks.
1086 *
1087 * @param ticks is the ticks value to check.
1088 *
1089 * @return Returns true, if current clock tick counter indicates a time before
1090 *   the time in ticks, otherwise returns false.
1091 *
1092 * @par Notes
1093 * @parblock
1094 * This directive can be used to write busy loops with a timeout.
1095 *
1096 * @code
1097 * status busy( void )
1098 * {
1099 *   rtems_interval timeout;
1100 *
1101 *   timeout = rtems_clock_tick_later_usec( 10000 );
1102 *
1103 *   do {
1104 *     if ( ok() ) {
1105 *       return success;
1106 *     }
1107 *   } while ( rtems_clock_tick_before( timeout ) );
1108 *
1109 *   return timeout;
1110 * }
1111 * @endcode
1112 * @endparblock
1113 *
1114 * @par Constraints
1115 * @parblock
1116 * The following constraints apply to this directive:
1117 *
1118 * * The directive may be called from within any runtime context.
1119 *
1120 * * The directive will not cause the calling task to be preempted.
1121 *
1122 * * The directive requires a Clock Driver.
1123 * @endparblock
1124 */
1125static inline bool rtems_clock_tick_before( rtems_interval ticks )
1126{
1127  return (int32_t) ( ticks - _Watchdog_Ticks_since_boot ) > 0;
1128}
1129
1130/* Generated from spec:/rtems/clock/if/tick */
1131
1132/**
1133 * @brief Announces a clock tick.
1134 *
1135 * @par Notes
1136 * The directive is a legacy interface.  It should not be called by
1137 * applications directly.  A Clock Driver may call this directive.
1138 */
1139rtems_status_code rtems_clock_tick( void );
1140
1141#ifdef __cplusplus
1142}
1143#endif
1144
1145#endif /* _RTEMS_RTEMS_CLOCK_H */
Note: See TracBrowser for help on using the repository browser.