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

4.115
Last change on this file since c424bb5 was c424bb5, checked in by Joel Sherrill <joel.sherrill@…>, on 05/09/12 at 15:07:23

librtems++ - Disable Interrupt Class When Not Simple Vectored

This class only works on Simple Vectored Architectures. Even worse,
it is not guaranteed to compile on a Programmable Interrupt Vector
architecture.

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