source: rtems/cpukit/include/rtems/score/watchdog.h @ 9480815a

Last change on this file since 9480815a was 9480815a, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 21, 2017 at 1:36:52 PM

score: Introduce new monotonic clock

Rename PER_CPU_WATCHDOG_MONOTONIC to PER_CPU_WATCHDOG_TICKS. Add new
PER_CPU_WATCHDOG_MONOTONIC which is based on the system uptime (measured
by timecounter).

Close #3264.

  • Property mode set to 100644
File size: 3.8 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 Special watchdog ticks value to indicate an infinite wait.
57 */
58#define WATCHDOG_NO_TIMEOUT 0
59
60/**
61 *  @brief Return type from a Watchdog Service Routine.
62 *
63 *  This type defines the return type from a Watchdog Service Routine.
64 */
65typedef void Watchdog_Service_routine;
66
67/**
68 *  @brief Pointer to a watchdog service routine.
69 *
70 *  This type define a pointer to a watchdog service routine.
71 */
72typedef Watchdog_Service_routine
73  ( *Watchdog_Service_routine_entry )( Watchdog_Control * );
74
75/**
76 * @brief The watchdog header to manage scheduled watchdogs.
77 */
78typedef struct {
79  /**
80   * @brief Red-black tree of scheduled watchdogs sorted by expiration time.
81   */
82  RBTree_Control Watchdogs;
83
84  /**
85   * @brief The scheduled watchdog with the earliest expiration time or NULL in
86   * case no watchdog is scheduled.
87   */
88  RBTree_Node *first;
89} Watchdog_Header;
90
91/**
92 *  @brief The control block used to manage each watchdog timer.
93 *
94 *  The following record defines the control block used
95 *  to manage each watchdog timer.
96 */
97struct Watchdog_Control {
98  /**
99   * @brief Nodes for the watchdog.
100   */
101  union {
102    /**
103     * @brief this field is a red-black tree node structure and allows this to
104     * be placed on a red-black tree used to manage the scheduled watchdogs.
105     */
106    RBTree_Node RBTree;
107
108    /**
109     * @brief this field is a chain node structure and allows this to be placed
110     * on a chain used to manage pending watchdogs by the timer server.
111     */
112    Chain_Node Chain;
113  } Node;
114
115#if defined(RTEMS_SMP)
116  /** @brief This field references the processor of this watchdog control. */
117  struct Per_CPU_Control *cpu;
118#endif
119
120  /** @brief This field is the function to invoke. */
121  Watchdog_Service_routine_entry routine;
122
123  /** @brief This field is the expiration time point. */
124  uint64_t expire;
125};
126
127/**
128 * @brief The watchdog ticks counter.
129 *
130 * With a 1ms watchdog tick, this counter overflows after 50 days since boot.
131 */
132extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot;
133
134/**
135 * @brief The watchdog nanoseconds per tick.
136 *
137 * This constant is defined by the application configuration via
138 * <rtems/confdefs.h>.
139 */
140extern const uint32_t _Watchdog_Nanoseconds_per_tick;
141
142/**
143 * @brief The watchdog ticks per second.
144 *
145 * This constant is defined by the application configuration via
146 * <rtems/confdefs.h>.
147 */
148extern const uint32_t _Watchdog_Ticks_per_second;
149
150/**@}*/
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif
157/* end of include file */
Note: See TracBrowser for help on using the repository browser.