blob: f722eb768395b4251f054dbf25170d75bd48077b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsInterrupt class.
This class catches an interrupt and passes control to the user's
derived class throught the handler method.
The interrupt is released back to the previous handler when this
object destructs.
The old handler can be chained to after the interrupt is
caught. Watch the stack usage!
More than one instance of this class can catch the same vector. The
application will have to chain to the other objects if required. If
the old handler is not an instance of this class the chain is passed
as "void (*)(void)". If it is an instance of this class, the handler
method is directly called.
The isr catch extends the documented return codes with :
RTEMS_RESOURCE_IN_USE = interrupt already caught
------------------------------------------------------------------------ */
#if !defined(_rtemsInterrupt_h_)
#define _rtemsInterrupt_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsInterrupt
*/
class rtemsInterrupt
: public rtemsStatusCode
{
public:
rtemsInterrupt();
virtual ~rtemsInterrupt();
// catch the interrupt
virtual const rtems_status_code isr_catch(const rtems_vector_number vector);
// release the interrupt back to the previous handle
virtual const rtems_status_code release();
// the old handler
const rtems_isr_entry old_isr_handler() const { return old_handler; }
protected:
// called after the interrupt is caught and it goes off
virtual void handler() = 0;
// chain to the previous handler,
inline void chain() const;
private:
const rtemsInterrupt& operator=(const rtemsInterrupt& );
rtemsInterrupt(const rtemsInterrupt& );
// the vector caught
rtems_vector_number vector;
// true when the interrupt is caught
bool caught;
// returned when catching the interrupt
rtems_isr_entry old_handler;
// old interrupt table entry
rtemsInterrupt *old_interrupt;
// common handler to redirect the interrupts
static void redirector(rtems_vector_number vector);
};
void rtemsInterrupt::chain() const
{
if (old_interrupt)
old_interrupt->handler();
else if (old_handler)
((void(*)()) old_handler)();
}
#endif // _rtemsInterrupt_h_
|