annotate packages/devs/watchdog/current/include/watchdog.hxx @ 32:5af43b635655 ecos-sw-1999-08-18

Merge from eCos master repository on 1999-08-18-15:20:01-BST
author jlarmour
date Wed, 18 Aug 1999 15:33:44 +0000
parents 443894e2e912
children c38311975d4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 #ifndef CYGONCE_DEVS_WATCHDOG_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 #define CYGONCE_DEVS_WATCHDOG_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
3
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
5 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
6 // watchdog.hxx
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
8 // Watchdog interface declaration
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
9 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
10 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
11 //####COPYRIGHTBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
12 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
13 // -------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
14 // The contents of this file are subject to the Cygnus eCos Public License
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
15 // Version 1.0 (the "License"); you may not use this file except in
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
16 // compliance with the License. You may obtain a copy of the License at
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
17 // http://sourceware.cygnus.com/ecos
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
18 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
19 // Software distributed under the License is distributed on an "AS IS"
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
21 // License for the specific language governing rights and limitations under
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
22 // the License.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
23 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
24 // The Original Code is eCos - Embedded Cygnus Operating System, released
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
25 // September 30, 1998.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
26 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
27 // The Initial Developer of the Original Code is Cygnus. Portions created
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
28 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
29 // -------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
30 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
31 //####COPYRIGHTEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
32 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
33 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
34 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
35 // Author(s): nickg
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
36 // Contributors: nickg
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
37 // Date: 1998-07-14
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
38 // Purpose: Watchdog declarations
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
39 // Description: This file defines the interface to the watchdog device
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 // that provides timer based recovery from software and
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 // hardware faults.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42 // Usage: #include <cyg/devs/watchdog.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
45 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
46 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
47
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
48 #include <cyg/kernel/ktypes.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
49 #include <cyg/infra/cyg_ass.h> // assertion macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 class Cyg_Watchdog_Action;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54 // Watchdog class
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56 class Cyg_Watchdog
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59 Cyg_Watchdog_Action *action_list;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60
32
5af43b635655 Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents: 2
diff changeset
61 cyg_uint64 resolution;
5af43b635655 Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents: 2
diff changeset
62
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63 public:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 Cyg_Watchdog();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66
32
5af43b635655 Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents: 2
diff changeset
67 // Return time interval allowed between resets before watchdog
5af43b635655 Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents: 2
diff changeset
68 // triggers, in nanoseconds.
5af43b635655 Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents: 2
diff changeset
69 cyg_uint64 get_resolution();
5af43b635655 Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents: 2
diff changeset
70
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71 // Start the watchdog running.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 void start();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74 // Reset watchdog timer. This needs to be called regularly to prevent
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75 // the watchdog firing.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
76 void reset();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78 // Trigger the watchdog as if the timer had expired.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79 void trigger();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 // Register an action routine that will be called when the timer
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 // triggers.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83 void install_action( Cyg_Watchdog_Action *wdaction );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85 // Deregister a previously registered action routine.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86 void uninstall_action( Cyg_Watchdog_Action *wdaction );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88 // A static instance of the single system defined watchdog device.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 static Cyg_Watchdog watchdog;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91 };
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
94 // Watchdog action class
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96 class Cyg_Watchdog_Action
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98 friend class Cyg_Watchdog;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100 Cyg_Watchdog_Action *next; // link in chain
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 void (*action)( CYG_ADDRWORD data ); // action function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104 CYG_ADDRWORD data; // data argument
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
106 public:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108 Cyg_Watchdog_Action(
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109 void (*action)( CYG_ADDRWORD data ),
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110 CYG_ADDRWORD data
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111 );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 ~Cyg_Watchdog_Action();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 void install();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117 void uninstall();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 };
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
121 // Cyg_Watchdog_Action inlines
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
123 inline Cyg_Watchdog_Action::Cyg_Watchdog_Action(
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 void (*action_arg)( CYG_ADDRWORD data ),
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125 CYG_ADDRWORD data_arg
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
126 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
128 next = NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129 action = action_arg;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 data = data_arg;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
133 inline Cyg_Watchdog_Action::~Cyg_Watchdog_Action()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135 Cyg_Watchdog::watchdog.uninstall_action( this );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
136 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
137
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
138 inline void Cyg_Watchdog_Action::install()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
139 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
140 Cyg_Watchdog::watchdog.install_action( this );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
143 inline void Cyg_Watchdog_Action::uninstall()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 Cyg_Watchdog::watchdog.uninstall_action( this );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149 #endif // ifndef CYGONCE_DEVS_WATCHDOG_HXX
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150 // EOF watchdog.hxx