OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [watchdog/] [current/] [include/] [watchdog.hxx] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.