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

4.104.114.84.95
Last change on this file since 2936b425 was 2936b425, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 23, 1998 at 5:45:05 PM

Solaris port updates from Chris Johns

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