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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [dmv177/] [startup/] [genpvec.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  genpvec.c
2
 *
3
 *  These routines handle the external exception.  Multiple ISRs occur off
4
 *  of this one interrupt.  This method will allow multiple ISRs to be
5
 *  called using the same IRQ index.  However, removing the ISR routines is
6
 *  presently not supported.
7
 *
8
 *  The external exception vector numbers begin with DMV170_IRQ_FIRST.
9
 *  DMV170_IRQ_FIRST is defined to be one greater than the last processor
10
 *  interrupt.
11
 *
12
 *  COPYRIGHT (c) 1989-1999.
13
 *  On-Line Applications Research Corporation (OAR).
14
 *
15
 *  The license and distribution terms for this file may in
16
 *  the file LICENSE in this distribution or at
17
 *  http://www.OARcorp.com/rtems/license.html.
18
 *
19
 *  $Id: genpvec.c,v 1.2 2001-09-27 12:00:35 chris Exp $
20
 */
21
 
22
#include <bsp.h>
23
#include "chain.h"
24
#include <assert.h>
25
 
26
#define   NUM_LIRQ_HANDLERS   20
27
#define   NUM_LIRQ            ( MAX_BOARD_IRQS - PPC_IRQ_LAST )
28
 
29
/*
30
 * Structure to for one of possible multiple interrupt handlers for
31
 * a given interrupt.
32
 */
33
typedef struct
34
{
35
  Chain_Node          Node;
36
  rtems_isr_entry     handler;                  /* isr routine        */
37
  rtems_vector_number vector;                   /* vector number      */
38
} EE_ISR_Type;
39
 
40
/*
41
 * Note:  The following will not work if we add a method to remove
42
 *        handlers at a later time.
43
 */
44
EE_ISR_Type       ISR_Nodes [NUM_LIRQ_HANDLERS];
45
rtems_unsigned16  Nodes_Used;
46
Chain_Control     ISR_Array  [NUM_LIRQ];
47
 
48
/*PAGE
49
 *
50
 * external_exception_ISR
51
 *
52
 * This interrupt service routine is called for an External Exception.
53
 *
54
 *  Input parameters:
55
 *    vector - vector number representing the external exception vector.
56
 *
57
 *  Output parameters:  NONE
58
 *
59
 *  Return values:
60
 */
61
 
62
rtems_isr external_exception_ISR (
63
  rtems_vector_number   vector             /* IN  */
64
)
65
{
66
  rtems_unsigned16      index;
67
  rtems_boolean         is_active=FALSE;
68
  rtems_unsigned32      scv64_status;
69
  rtems_vector_number   chained_vector;
70
  Chain_Node           *node;
71
  EE_ISR_Type          *ee_isr;
72
 
73
 
74
  /*
75
   * Get all active interrupts.
76
   */
77
  scv64_status = SCV64_Get_Interrupt();
78
  scv64_status &= SCV64_Get_Interrupt_Enable();
79
 
80
  /*
81
   * Process any set interrupts.
82
   */
83
  for (index = 0; index <= 5; index++) {
84
    switch(index) {
85
      case 0:
86
        is_active = SCV64_Is_IRQ0( scv64_status );
87
        break;
88
      case 1:
89
        is_active = SCV64_Is_IRQ1( scv64_status );
90
        break;
91
      case 2:
92
        is_active = SCV64_Is_IRQ2( scv64_status );
93
        break;
94
      case 3:
95
        is_active = SCV64_Is_IRQ3( scv64_status );
96
        break;
97
      case 4:
98
        is_active = SCV64_Is_IRQ4( scv64_status );
99
        break;
100
      case 5:
101
        is_active = SCV64_Is_IRQ5( scv64_status );
102
        break;
103
    }
104
 
105
    if (is_active) {
106
      /*
107
       * Read vector.
108
       */
109
      node = ISR_Array[ index ].first;
110
      while ( !_Chain_Is_tail( &ISR_Array[ index ], node ) ) {
111
        ee_isr = (EE_ISR_Type *) node;
112
        (*ee_isr->handler)( ee_isr->vector );
113
        node = node->next;
114
      }
115
    }
116
  }
117
}
118
 
119
 
120
/*PAGE
121
 *
122
 *  initialize_external_exception_vector
123
 *
124
 *  This routine initializes the external exception vector
125
 *
126
 *  Input parameters: NONE
127
 *
128
 *  Output parameters:  NONE
129
 *
130
 *  Return values: NONE
131
 */
132
 
133
void initialize_external_exception_vector ()
134
{
135
  int i;
136
  rtems_isr_entry previous_isr;
137
  rtems_status_code status;
138
 
139
  Nodes_Used = 0;
140
 
141
  /*
142
   * Initialize the SCV64 chip
143
   */
144
  SCV64_Initialize();
145
 
146
  for (i=0; i <NUM_LIRQ; i++)
147
    Chain_Initialize_empty( &ISR_Array[i] );
148
 
149
  /*
150
   * Install external_exception_ISR () as the handler for
151
   *  the General Purpose Interrupt.
152
   */
153
 
154
  status = rtems_interrupt_catch( external_exception_ISR,
155
           PPC_IRQ_EXTERNAL , (rtems_isr_entry *) &previous_isr );
156
 
157
}
158
 
159
/*PAGE
160
 *
161
 *  set_EE_vector
162
 *
163
 *  This routine installs one of multiple ISRs for the general purpose
164
 *  inerrupt.
165
 *
166
 *  Input parameters:
167
 *    handler - handler to call at exception
168
 *    vector  - vector number associated with this handler.
169
 *
170
 *  Output parameters:  NONE
171
 *
172
 *  Return values:
173
 */
174
 
175
rtems_isr_entry  set_EE_vector(
176
  rtems_isr_entry     handler,      /* isr routine        */
177
  rtems_vector_number vector        /* vector number      */
178
)
179
{
180
  rtems_unsigned16 vec_idx  = vector - DMV170_IRQ_FIRST;
181
  rtems_unsigned32 index;
182
 
183
  /*
184
   *  Verify that all of the nodes have not been used.
185
   */
186
  assert  (Nodes_Used < NUM_LIRQ_HANDLERS);
187
 
188
  /*
189
   *  If we have already installed this handler for this vector, then
190
   *  just reset it.
191
   */
192
 
193
  for ( index=0 ; index <= Nodes_Used ; index++ ) {
194
    if ( ISR_Nodes[index].vector == vector &&
195
         ISR_Nodes[index].handler == handler )
196
      return 0;
197
  }
198
 
199
  /*
200
   * Increment the number of nedes used and set the index for the node
201
   * array.
202
   */
203
 
204
  Nodes_Used++;
205
  index = Nodes_Used - 1;
206
 
207
  /*
208
   * Write the values of the handler and the vector to this node.
209
   */
210
  ISR_Nodes[index].handler = handler;
211
  ISR_Nodes[index].vector  = vector;
212
 
213
  /*
214
   * Connect this node to the chain at the location of the
215
   * vector index.
216
   */
217
  Chain_Append( &ISR_Array[vec_idx], &ISR_Nodes[index].Node );
218
 
219
  /*
220
   * Enable the LIRQ interrupt.
221
   */
222
  SCV64_Generate_DUART_Interrupts();
223
 
224
  /*
225
   * No interrupt service routine was removed so return 0
226
   */
227
  return 0;
228
}
229
 
230
 
231
 
232
 
233
 
234
 
235
 
236
 
237
 
238
 

powered by: WebSVN 2.1.0

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