summaryrefslogtreecommitdiffstats
path: root/c/src/librtems++/src/rtemsInterrupt.cc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-07-31 22:13:29 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-07-31 22:13:29 +0000
commit0074691a67f857c9b3f880fb581e0af1d5673337 (patch)
treef80fd23129ad62236ee4f64eeaf537f53bbaa0b8 /c/src/librtems++/src/rtemsInterrupt.cc
parentMerged very large and much appreciated patch from Chris Johns (diff)
downloadrtems-0074691a67f857c9b3f880fb581e0af1d5673337.tar.bz2
Merged very large and much appreciated patch from Chris Johns
<cjohns@plessey.com.au>. This patch includes the ods68302 bsp, the RTEMS++ class library, and the rtems++ test.
Diffstat (limited to 'c/src/librtems++/src/rtemsInterrupt.cc')
-rw-r--r--c/src/librtems++/src/rtemsInterrupt.cc110
1 files changed, 110 insertions, 0 deletions
diff --git a/c/src/librtems++/src/rtemsInterrupt.cc b/c/src/librtems++/src/rtemsInterrupt.cc
new file mode 100644
index 0000000000..c445807c35
--- /dev/null
+++ b/c/src/librtems++/src/rtemsInterrupt.cc
@@ -0,0 +1,110 @@
+/*
+ ------------------------------------------------------------------------
+ $Id$
+ ------------------------------------------------------------------------
+
+ COPYRIGHT (c) 1997
+ Objective Design Systems Ltd Pty (ODS)
+ All rights reserved (R) Objective Design Systems Ltd Pty
+
+ The license and distribution terms for this file may be found in the
+ file LICENSE in this distribution or at
+ http://www.OARcorp.com/rtems/license.html.
+
+ ------------------------------------------------------------------------
+
+ See header file.
+
+ ------------------------------------------------------------------------
+*/
+
+#include <rtems++/rtemsInterrupt.h>
+
+/* ----
+ Interrupt Table
+
+ This table is used to re-direct the call from RTEMS to a user
+ object
+*/
+
+static rtemsInterrupt *interrupt_table[CPU_INTERRUPT_NUMBER_OF_VECTORS];
+
+// has the table been initialised
+static bool initialised = false;
+
+/* ----
+ rtemsInterrupt
+*/
+
+rtemsInterrupt::rtemsInterrupt()
+ : vector(0),
+ caught(false),
+ old_handler(0),
+ old_interrupt(0)
+{
+ if (!initialised)
+ {
+ for (rtems_vector_number vec = 0;
+ vec < CPU_INTERRUPT_NUMBER_OF_VECTORS;
+ vec++)
+ {
+ interrupt_table[vector] = 0;
+ }
+ initialised = true;
+ }
+}
+
+const rtems_status_code rtemsInterrupt::isr_catch(const rtems_vector_number vec)
+{
+ if (vec >= CPU_INTERRUPT_NUMBER_OF_VECTORS)
+ return set_status_code(RTEMS_INVALID_NUMBER);
+
+ if (caught)
+ return set_status_code(RTEMS_RESOURCE_IN_USE);
+
+ old_interrupt = interrupt_table[vector];
+ interrupt_table[vector] = this;
+ vector = vec;
+
+ set_status_code(rtems_interrupt_catch(redirector,
+ vector,
+ &old_handler));
+
+ if (successful())
+ caught = true;
+ else
+ {
+ interrupt_table[vector] = old_interrupt;
+ old_interrupt = 0;
+ old_handler = 0;
+ vector = 0;
+ }
+
+ return last_status_code();
+}
+
+const rtems_status_code rtemsInterrupt::release(void)
+{
+ if (caught)
+ {
+ set_status_code(rtems_interrupt_catch(old_handler,
+ vector,
+ &old_handler));
+
+ interrupt_table[vector] = old_interrupt;
+ old_interrupt = 0;
+ old_handler = 0;
+ vector = 0;
+ caught = false;
+ }
+ else
+ set_status_code(RTEMS_SUCCESSFUL);
+
+ return last_status_code();
+}
+
+void rtemsInterrupt::redirector(rtems_vector_number vector)
+{
+ if (interrupt_table[vector])
+ interrupt_table[vector]->handler();
+}