source: rtems/cpukit/score/include/rtems/score/watchdog.h @ 7ed377b

5
Last change on this file since 7ed377b was 7ed377b, checked in by Sebastian Huber <sebastian.huber@…>, on 10/20/17 at 06:43:15

score: _Watchdog_Is_far_future_monotonic_timespec

Update #3117.
Update #3182.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/**
2 *  @file  rtems/score/watchdog.h
3 *
4 *  @brief Constants and Structures Associated with Watchdog Timers
5 *
6 *  This include file contains all the constants and structures associated
7 *  with watchdog timers.   This Handler provides mechanisms which can be
8 *  used to initialize and manipulate watchdog timers.
9 */
10
11/*
12 *  COPYRIGHT (c) 1989-2009.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#ifndef _RTEMS_SCORE_WATCHDOG_H
21#define _RTEMS_SCORE_WATCHDOG_H
22
23#include <rtems/score/basedefs.h>
24#include <rtems/score/chain.h>
25#include <rtems/score/rbtree.h>
26
27struct Per_CPU_Control;
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 *  @defgroup ScoreWatchdog Watchdog Handler
35 *
36 *  @ingroup Score
37 *
38 *  This handler encapsulates functionality related to the scheduling of
39 *  watchdog functions to be called at specific times in the future.
40 *
41 *  @note This handler does not have anything to do with hardware watchdog
42 *        timers.
43 */
44/**@{*/
45
46typedef struct Watchdog_Control Watchdog_Control;
47
48/**
49 *  @brief Type is used to specify the length of intervals.
50 *
51 *  This type is used to specify the length of intervals.
52 */
53typedef uint32_t   Watchdog_Interval;
54
55/**
56 *  @brief The clock discipline to use for the Watchdog timeout interval.
57 */
58typedef enum {
59
60  /**
61   * @brief Indefinite wait.
62   *
63   * This is to indicate there is no timeout and not to use a watchdog. It
64   * must be equal to 0, which is an illegal relative clock interval, so that
65   * it may be used as a Watchdog_Interval value with WATCHDOG_RELATIVE to
66   * express an indefinite wait.
67   */
68  WATCHDOG_NO_TIMEOUT = 0,
69
70  /**
71   * @brief Relative clock.
72   *
73   * The reference time point for the watchdog is current ticks value
74   * during insert.  Time is measured in clock ticks.
75   */
76  WATCHDOG_RELATIVE,
77
78  /**
79   * @brief Absolute clock.
80   *
81   * The reference time point for this header is the POSIX Epoch.  Time is
82   * measured in nanoseconds since POSIX Epoch.
83   */
84  WATCHDOG_ABSOLUTE
85} Watchdog_Discipline;
86
87/**
88 *  @brief Return type from a Watchdog Service Routine.
89 *
90 *  This type defines the return type from a Watchdog Service Routine.
91 */
92typedef void Watchdog_Service_routine;
93
94/**
95 *  @brief Pointer to a watchdog service routine.
96 *
97 *  This type define a pointer to a watchdog service routine.
98 */
99typedef Watchdog_Service_routine
100  ( *Watchdog_Service_routine_entry )( Watchdog_Control * );
101
102/**
103 * @brief The watchdog header to manage scheduled watchdogs.
104 */
105typedef struct {
106  /**
107   * @brief Red-black tree of scheduled watchdogs sorted by expiration time.
108   */
109  RBTree_Control Watchdogs;
110
111  /**
112   * @brief The scheduled watchdog with the earliest expiration time or NULL in
113   * case no watchdog is scheduled.
114   */
115  RBTree_Node *first;
116} Watchdog_Header;
117
118/**
119 *  @brief The control block used to manage each watchdog timer.
120 *
121 *  The following record defines the control block used
122 *  to manage each watchdog timer.
123 */
124struct Watchdog_Control {
125  /**
126   * @brief Nodes for the watchdog.
127   */
128  union {
129    /**
130     * @brief this field is a red-black tree node structure and allows this to
131     * be placed on a red-black tree used to manage the scheduled watchdogs.
132     */
133    RBTree_Node RBTree;
134
135    /**
136     * @brief this field is a chain node structure and allows this to be placed
137     * on a chain used to manage pending watchdogs by the timer server.
138     */
139    Chain_Node Chain;
140  } Node;
141
142#if defined(RTEMS_SMP)
143  /** @brief This field references the processor of this watchdog control. */
144  struct Per_CPU_Control *cpu;
145#endif
146
147  /** @brief This field is the function to invoke. */
148  Watchdog_Service_routine_entry routine;
149
150  /** @brief This field is the expiration time point. */
151  uint64_t expire;
152};
153
154/**
155 * @brief The watchdog ticks counter.
156 *
157 * With a 1ms watchdog tick, this counter overflows after 50 days since boot.
158 */
159extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot;
160
161/**
162 * @brief The watchdog ticks per second.
163 *
164 * This constant is defined by the application configuration via
165 * <rtems/confdefs.h>.
166 */
167extern const uint32_t _Watchdog_Ticks_per_second;
168
169/**
170 * @brief The maximum number of seconds representable in the monotonic watchdog
171 * format.
172 *
173 * This constant is defined by the application configuration via
174 * <rtems/confdefs.h>.
175 */
176extern const uint64_t _Watchdog_Monotonic_max_seconds;
177
178/**@}*/
179
180#ifdef __cplusplus
181}
182#endif
183
184#endif
185/* end of include file */
Note: See TracBrowser for help on using the repository browser.