OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librtems++/] [src/] [rtemsInterrupt.cc] - Blame information for rev 228

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
  ------------------------------------------------------------------------
3
  $Id: rtemsInterrupt.cc,v 1.2 2001-09-27 12:02:05 chris Exp $
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
 
30
static rtemsInterrupt *interrupt_table[CPU_INTERRUPT_NUMBER_OF_VECTORS];
31
 
32
// has the table been initialised
33
static bool initialised = false;
34
 
35
/* ----
36
   rtemsInterrupt
37
*/
38
 
39
rtemsInterrupt::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
 
57
rtemsInterrupt::~rtemsInterrupt()
58
{
59
  release();
60
}
61
 
62
const rtems_status_code rtemsInterrupt::isr_catch(const rtems_vector_number vec)
63
{
64
  if (vec >= CPU_INTERRUPT_NUMBER_OF_VECTORS)
65
    return set_status_code(RTEMS_INVALID_NUMBER);
66
 
67
  if (caught)
68
    return set_status_code(RTEMS_RESOURCE_IN_USE);
69
 
70
  old_interrupt = interrupt_table[vector];
71
  interrupt_table[vector] = this;
72
  vector = vec;
73
 
74
  set_status_code(rtems_interrupt_catch(redirector,
75
                                        vector,
76
                                        &old_handler));
77
 
78
  if (successful())
79
    caught = true;
80
  else
81
  {
82
    interrupt_table[vector] = old_interrupt;
83
    old_interrupt = 0;
84
    old_handler = 0;
85
    vector = 0;
86
  }
87
 
88
  return last_status_code();
89
}
90
 
91
const rtems_status_code rtemsInterrupt::release(void)
92
{
93
  if (caught)
94
  {
95
    set_status_code(rtems_interrupt_catch(old_handler,
96
                                          vector,
97
                                          &old_handler));
98
 
99
    interrupt_table[vector] = old_interrupt;
100
    old_interrupt = 0;
101
    old_handler = 0;
102
    vector = 0;
103
    caught = false;
104
  }
105
  else
106
    set_status_code(RTEMS_SUCCESSFUL);
107
 
108
  return last_status_code();
109
}
110
 
111
void rtemsInterrupt::redirector(rtems_vector_number vector)
112
{
113
  if (interrupt_table[vector])
114
    interrupt_table[vector]->handler();
115
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.