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

4.104.114.84.95
Last change on this file since 8bf6095 was 8bf6095, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 16, 1998 at 7:05:50 PM

Added initialization of css routines.

  • Property mode set to 100644
File size: 4.4 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-1998.
13 *  On-Line Applications Research Corporation (OAR).
14 *  Copyright assigned to U.S. Government, 1994.
15 *
16 *  The license and distribution terms for this file may in
17 *  the file LICENSE in this distribution or at
18 *  http://www.OARcorp.com/rtems/license.html.
19 *
20 *  $Id:
21 */
22
23#include <bsp.h>
24#include "chain.h"
25#include <assert.h>
26
27#define   NUM_LIRQ_HANDLERS   20
28#define   NUM_LIRQ            ( MAX_BOARD_IRQS - PPC_IRQ_LAST )
29
30/*
31 * Structure to for one of possible multiple interrupt handlers for
32 * a given interrupt.
33 */
34typedef struct
35{
36  Chain_Node          Node;
37  rtems_isr_entry     handler;                  /* isr routine        */
38  rtems_vector_number vector;                   /* vector number      */
39} EE_ISR_Type;
40
41/*
42 * Note:  The following will not work if we add a method to remove
43 *        handlers at a later time.
44 */
45EE_ISR_Type       ISR_Nodes [NUM_LIRQ_HANDLERS];
46rtems_unsigned16  Nodes_Used; 
47Chain_Control     ISR_Array  [NUM_LIRQ];
48
49/*PAGE
50 *
51 * external_exception_ISR
52 *
53 * This interrupt service routine is called for an External Exception.
54 *
55 *  Input parameters:
56 *    vector - vector number representing the external exception vector.
57 *
58 *  Output parameters:  NONE
59 *
60 *  Return values:
61 */
62
63rtems_isr external_exception_ISR (
64  rtems_vector_number   vector             /* IN  */
65)
66{ 
67 rtems_unsigned16      index;
68 rtems_vector_number   chained_vector;
69 Chain_Node           *node;
70 EE_ISR_Type          *ee_isr;
71 
72 /*
73  * Read vector.
74  */
75 chained_vector = Get_interrupt();
76 index = chained_vector - DMV170_IRQ_FIRST;
77 node = ISR_Array[ index ].first;
78 while ( !_Chain_Is_tail( &ISR_Array[ index ], node ) ) {
79   ee_isr = (EE_ISR_Type *) node;
80   (*ee_isr->handler)( ee_isr->vector );
81   node = node->next;
82 }
83
84 /*
85  * Clear the interrupt.
86  */
87 Clear_interrupt( chained_vector );
88
89}
90
91
92/*PAGE
93 *
94 *  initialize_external_exception_vector
95 *
96 *  This routine initializes the external exception vector
97 *
98 *  Input parameters: NONE
99 *
100 *  Output parameters:  NONE
101 *
102 *  Return values: NONE
103 */
104
105void initialize_external_exception_vector ()
106{
107  int i;
108  rtems_isr_entry previous_isr;
109  rtems_status_code status;
110
111  Nodes_Used = 0;
112
113  for (i=0; i <NUM_LIRQ; i++)
114    Chain_Initialize_empty( &ISR_Array[i] );
115
116  /* 
117   * Install external_exception_ISR () as the handler for
118   *  the General Purpose Interrupt.
119   */
120
121  status = rtems_interrupt_catch( external_exception_ISR, 
122           PPC_IRQ_EXTERNAL , (rtems_isr_entry *) &previous_isr );
123
124  Init_Css();
125}
126
127/*PAGE
128 *
129 *  set_EE_vector
130 *
131 *  This routine installs one of multiple ISRs for the general purpose
132 *  inerrupt.
133 *
134 *  Input parameters:
135 *    handler - handler to call at exception
136 *    vector  - vector number associated with this handler.
137 *
138 *  Output parameters:  NONE
139 *
140 *  Return values:
141 */
142
143rtems_isr_entry  set_EE_vector(
144  rtems_isr_entry     handler,      /* isr routine        */
145  rtems_vector_number vector        /* vector number      */
146)
147{
148  rtems_unsigned16 vec_idx  = vector - DMV170_IRQ_FIRST;
149  rtems_unsigned32 index;
150 
151  /*
152   *  Verify that all of the nodes have not been used.
153   */
154  assert  (Nodes_Used < NUM_LIRQ_HANDLERS);
155   
156  /*
157   *  If we have already installed this handler for this vector, then
158   *  just reset it.
159   */
160
161  for ( index=0 ; index <= Nodes_Used ; index++ ) {
162    if ( ISR_Nodes[index].vector == vector &&
163         ISR_Nodes[index].handler == handler )
164      return 0;
165  }
166
167  /*
168   * Increment the number of nedes used and set the index for the node
169   * array.
170   */
171 
172  Nodes_Used++; 
173  index = Nodes_Used - 1;
174
175  /*
176   * Write the values of the handler and the vector to this node.
177   */
178  ISR_Nodes[index].handler = handler;
179  ISR_Nodes[index].vector  = vector;
180
181  /*
182   * Connect this node to the chain at the location of the
183   * vector index. 
184   */
185  Chain_Append( &ISR_Array[vec_idx], &ISR_Nodes[index].Node );
186
187  /*
188   * Enable the interrupt.
189   */
190   enable_card_interrupt( vector );
191
192  /*
193   * No interrupt service routine was removed so return 0
194   */
195  return 0;
196}
197
198
199
Note: See TracBrowser for help on using the repository browser.