1 |
27 |
unneback |
#ifndef CYGONCE_DEVS_WATCHDOG_HXX
|
2 |
|
|
#define CYGONCE_DEVS_WATCHDOG_HXX
|
3 |
|
|
|
4 |
|
|
//==========================================================================
|
5 |
|
|
//
|
6 |
|
|
// watchdog.hxx
|
7 |
|
|
//
|
8 |
|
|
// Watchdog interface declaration
|
9 |
|
|
//
|
10 |
|
|
//==========================================================================
|
11 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
21 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License along
|
26 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
30 |
|
|
// or inline functions from this file, or you compile this file and link it
|
31 |
|
|
// with other works to produce a work based on this file, this file does not
|
32 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
33 |
|
|
// License. However the source code for this file must still be made available
|
34 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
37 |
|
|
// this file might be covered by the GNU General Public License.
|
38 |
|
|
//
|
39 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
40 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
43 |
|
|
//==========================================================================
|
44 |
|
|
//#####DESCRIPTIONBEGIN####
|
45 |
|
|
//
|
46 |
|
|
// Author(s): nickg
|
47 |
|
|
// Contributors: nickg
|
48 |
|
|
// Date: 1998-07-14
|
49 |
|
|
// Purpose: Watchdog declarations
|
50 |
|
|
// Description: This file defines the interface to the watchdog device
|
51 |
|
|
// that provides timer based recovery from software and
|
52 |
|
|
// hardware faults.
|
53 |
|
|
// Usage: #include
|
54 |
|
|
//
|
55 |
|
|
//####DESCRIPTIONEND####
|
56 |
|
|
//
|
57 |
|
|
//==========================================================================
|
58 |
|
|
|
59 |
|
|
#include
|
60 |
|
|
#include // assertion macros
|
61 |
|
|
|
62 |
|
|
class Cyg_Watchdog_Action;
|
63 |
|
|
|
64 |
|
|
// -------------------------------------------------------------------------
|
65 |
|
|
// Watchdog class
|
66 |
|
|
|
67 |
|
|
class Cyg_Watchdog
|
68 |
|
|
{
|
69 |
|
|
|
70 |
|
|
Cyg_Watchdog_Action *action_list;
|
71 |
|
|
|
72 |
|
|
cyg_uint64 resolution;
|
73 |
|
|
|
74 |
|
|
public:
|
75 |
|
|
|
76 |
|
|
Cyg_Watchdog();
|
77 |
|
|
|
78 |
|
|
// Return time interval allowed between resets before watchdog
|
79 |
|
|
// triggers, in nanoseconds.
|
80 |
|
|
cyg_uint64 get_resolution( void );
|
81 |
|
|
|
82 |
|
|
// Start the watchdog running.
|
83 |
|
|
void start( void );
|
84 |
|
|
|
85 |
|
|
// Reset watchdog timer. This needs to be called regularly to prevent
|
86 |
|
|
// the watchdog firing.
|
87 |
|
|
void reset( void );
|
88 |
|
|
|
89 |
|
|
#ifndef CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT
|
90 |
|
|
// Trigger the watchdog as if the timer had expired.
|
91 |
|
|
void trigger( void );
|
92 |
|
|
|
93 |
|
|
// Register an action routine that will be called when the timer
|
94 |
|
|
// triggers.
|
95 |
|
|
void install_action( Cyg_Watchdog_Action *wdaction );
|
96 |
|
|
|
97 |
|
|
// Deregister a previously registered action routine.
|
98 |
|
|
void uninstall_action( Cyg_Watchdog_Action *wdaction );
|
99 |
|
|
#endif
|
100 |
|
|
|
101 |
|
|
// A static instance of the single system defined watchdog device.
|
102 |
|
|
static Cyg_Watchdog watchdog;
|
103 |
|
|
|
104 |
|
|
private:
|
105 |
|
|
void init_hw( void );
|
106 |
|
|
};
|
107 |
|
|
|
108 |
|
|
#ifndef CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT
|
109 |
|
|
// -------------------------------------------------------------------------
|
110 |
|
|
// Watchdog action class
|
111 |
|
|
|
112 |
|
|
class Cyg_Watchdog_Action
|
113 |
|
|
{
|
114 |
|
|
friend class Cyg_Watchdog;
|
115 |
|
|
|
116 |
|
|
Cyg_Watchdog_Action *next; // link in chain
|
117 |
|
|
|
118 |
|
|
void (*action)( CYG_ADDRWORD data ); // action function
|
119 |
|
|
|
120 |
|
|
CYG_ADDRWORD data; // data argument
|
121 |
|
|
|
122 |
|
|
public:
|
123 |
|
|
|
124 |
|
|
Cyg_Watchdog_Action(
|
125 |
|
|
void (*action)( CYG_ADDRWORD data ),
|
126 |
|
|
CYG_ADDRWORD data
|
127 |
|
|
);
|
128 |
|
|
|
129 |
|
|
~Cyg_Watchdog_Action();
|
130 |
|
|
|
131 |
|
|
void install();
|
132 |
|
|
|
133 |
|
|
void uninstall();
|
134 |
|
|
};
|
135 |
|
|
|
136 |
|
|
// -------------------------------------------------------------------------
|
137 |
|
|
// Cyg_Watchdog_Action inlines
|
138 |
|
|
|
139 |
|
|
inline Cyg_Watchdog_Action::Cyg_Watchdog_Action(
|
140 |
|
|
void (*action_arg)( CYG_ADDRWORD data ),
|
141 |
|
|
CYG_ADDRWORD data_arg
|
142 |
|
|
)
|
143 |
|
|
{
|
144 |
|
|
next = NULL;
|
145 |
|
|
action = action_arg;
|
146 |
|
|
data = data_arg;
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
inline Cyg_Watchdog_Action::~Cyg_Watchdog_Action()
|
150 |
|
|
{
|
151 |
|
|
Cyg_Watchdog::watchdog.uninstall_action( this );
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
inline void Cyg_Watchdog_Action::install()
|
155 |
|
|
{
|
156 |
|
|
Cyg_Watchdog::watchdog.install_action( this );
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
inline void Cyg_Watchdog_Action::uninstall()
|
160 |
|
|
{
|
161 |
|
|
Cyg_Watchdog::watchdog.uninstall_action( this );
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
#endif // CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT
|
165 |
|
|
|
166 |
|
|
// -------------------------------------------------------------------------
|
167 |
|
|
#endif // ifndef CYGONCE_DEVS_WATCHDOG_HXX
|
168 |
|
|
// EOF watchdog.hxx
|