source: rtems/c/src/lib/librtems++/rtemsInterrupt.cc @ 6f9c75c3

4.104.114.84.95
Last change on this file since 6f9c75c3 was 0074691a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/31/97 at 22:13:29

Merged very large and much appreciated patch from Chris Johns
<cjohns@…>. This patch includes the ods68302 bsp,
the RTEMS++ class library, and the rtems++ test.

  • Property mode set to 100644
File size: 2.5 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  See header file.
17
18  ------------------------------------------------------------------------
19*/
20
21#include <rtems++/rtemsInterrupt.h>
22
23/* ----
24   Interrupt Table
25
26   This table is used to re-direct the call from RTEMS to a user
27   object
28*/
29
30static rtemsInterrupt *interrupt_table[CPU_INTERRUPT_NUMBER_OF_VECTORS];
31
32// has the table been initialised
33static bool initialised = false;
34
35/* ----
36   rtemsInterrupt
37*/
38
39rtemsInterrupt::rtemsInterrupt()
40  : vector(0),
41    caught(false),
42    old_handler(0),
43    old_interrupt(0)
44{
45  if (!initialised)
46  {
47    for (rtems_vector_number vec = 0;
48         vec < CPU_INTERRUPT_NUMBER_OF_VECTORS;
49         vec++)
50    {
51      interrupt_table[vector] = 0;
52    }
53    initialised = true;
54  }
55}
56
57const rtems_status_code rtemsInterrupt::isr_catch(const rtems_vector_number vec)
58{
59  if (vec >= CPU_INTERRUPT_NUMBER_OF_VECTORS)
60    return set_status_code(RTEMS_INVALID_NUMBER);
61 
62  if (caught)
63    return set_status_code(RTEMS_RESOURCE_IN_USE);
64
65  old_interrupt = interrupt_table[vector];
66  interrupt_table[vector] = this;
67  vector = vec;
68 
69  set_status_code(rtems_interrupt_catch(redirector,
70                                        vector,
71                                        &old_handler));
72
73  if (successful())
74    caught = true;
75  else
76  {
77    interrupt_table[vector] = old_interrupt;
78    old_interrupt = 0;
79    old_handler = 0;
80    vector = 0;
81  }
82 
83  return last_status_code();
84}
85
86const rtems_status_code rtemsInterrupt::release(void)
87{
88  if (caught)
89  {
90    set_status_code(rtems_interrupt_catch(old_handler,
91                                          vector,
92                                          &old_handler));
93
94    interrupt_table[vector] = old_interrupt;
95    old_interrupt = 0;
96    old_handler = 0;
97    vector = 0;
98    caught = false;
99  }
100  else
101    set_status_code(RTEMS_SUCCESSFUL);
102 
103  return last_status_code();
104}
105
106void rtemsInterrupt::redirector(rtems_vector_number vector)
107{
108  if (interrupt_table[vector])
109    interrupt_table[vector]->handler();
110}
Note: See TracBrowser for help on using the repository browser.