source: rtems/c/src/librtems++/include/rtems++/rtemsInterrupt.h @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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