source: rtems/c/src/librtems++/src/rtemsInterrupt.cc @ 9ee5b97

4.115
Last change on this file since 9ee5b97 was 9ee5b97, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/12 at 13:33:36

librtems++ - Remove junk line accidentally committed

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