source: rtems/c/src/lib/libbsp/powerpc/dmv177/startup/genpvec.c @ a4199003

Last change on this file since a4199003 was a4199003, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:44:59

2003-09-04 Joel Sherrill <joel@…>

  • clock/clock.c, console/debugio.c, include/dmv170.h, startup/bspclean.c, startup/genpvec.c, startup/setvec.c, startup/vmeintr.c, timer/timer.c: URL for license changed.
  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*  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.rtems.com/license/LICENSE.
18 *
19 *  $Id$
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 */
33typedef 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 */
44EE_ISR_Type       ISR_Nodes [NUM_LIRQ_HANDLERS];
45rtems_unsigned16  Nodes_Used;
46Chain_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
62rtems_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  Chain_Node           *node;
70  EE_ISR_Type          *ee_isr;
71 
72
73  /*
74   * Get all active interrupts.
75   */
76  scv64_status = SCV64_Get_Interrupt();
77  scv64_status &= SCV64_Get_Interrupt_Enable();
78
79  /*
80   * Process any set interrupts.
81   */
82  for (index = 0; index <= 5; index++) {
83    switch(index) {
84      case 0:
85        is_active = SCV64_Is_IRQ0( scv64_status );
86        break;
87      case 1:
88        is_active = SCV64_Is_IRQ1( scv64_status );
89        break;
90      case 2:
91        is_active = SCV64_Is_IRQ2( scv64_status );
92        break;
93      case 3:
94        is_active = SCV64_Is_IRQ3( scv64_status );
95        break;
96      case 4:
97        is_active = SCV64_Is_IRQ4( scv64_status );
98        break;
99      case 5:
100        is_active = SCV64_Is_IRQ5( scv64_status );
101        break;
102    }
103
104    if (is_active) {
105      /*
106       * Read vector.
107       */
108      node = ISR_Array[ index ].first;
109      while ( !_Chain_Is_tail( &ISR_Array[ index ], node ) ) {
110        ee_isr = (EE_ISR_Type *) node;
111        (*ee_isr->handler)( ee_isr->vector );
112        node = node->next;
113      }
114    }
115  }
116}
117
118
119/*PAGE
120 *
121 *  initialize_external_exception_vector
122 *
123 *  This routine initializes the external exception vector
124 *
125 *  Input parameters: NONE
126 *
127 *  Output parameters:  NONE
128 *
129 *  Return values: NONE
130 */
131
132void initialize_external_exception_vector ()
133{
134  int i;
135  rtems_isr_entry previous_isr;
136  rtems_status_code status;
137  extern void SCV64_Initialize( void );
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
175rtems_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
Note: See TracBrowser for help on using the repository browser.