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

4.104.114.84.95
Last change on this file since 510524c6 was dc104a4, checked in by Joel Sherrill <joel.sherrill@…>, on 05/30/98 at 11:46:21

Updated to current source and removed warnings.

  • Property mode set to 100644
File size: 4.2 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 Chain_Node          *node;
69 EE_ISR_Type         *ee_isr;
70 
71 /*
72  * Read vector.
73  */
74 index = 0;
75
76 node = ISR_Array[ index ].first;
77 while ( !_Chain_Is_tail( &ISR_Array[ index ], node ) ) {
78   ee_isr = (EE_ISR_Type *) node;
79   (*ee_isr->handler)( ee_isr->vector );
80   node = node->next;
81 }
82
83 /*
84  * Clear the interrupt.
85  */
86}
87
88
89/*PAGE
90 *
91 *  initialize_external_exception_vector
92 *
93 *  This routine initializes the external exception vector
94 *
95 *  Input parameters: NONE
96 *
97 *  Output parameters:  NONE
98 *
99 *  Return values: NONE
100 */
101
102void initialize_external_exception_vector ()
103{
104  int i;
105  rtems_isr_entry previous_isr;
106  rtems_status_code status;
107
108  Nodes_Used = 0;
109
110  for (i=0; i <NUM_LIRQ; i++)
111    Chain_Initialize_empty( &ISR_Array[i] );
112
113  /* 
114   * Install external_exception_ISR () as the handler for
115   *  the General Purpose Interrupt.
116   */
117
118  status = rtems_interrupt_catch( external_exception_ISR,
119           PPC_IRQ_EXTERNAL , (rtems_isr_entry *) &previous_isr );
120}
121
122/*PAGE
123 *
124 *  set_EE_vector
125 *
126 *  This routine installs one of multiple ISRs for the general purpose
127 *  inerrupt.
128 *
129 *  Input parameters:
130 *    handler - handler to call at exception
131 *    vector  - vector number associated with this handler.
132 *
133 *  Output parameters:  NONE
134 *
135 *  Return values:
136 */
137
138rtems_isr_entry  set_EE_vector(
139  rtems_isr_entry     handler,      /* isr routine        */
140  rtems_vector_number vector        /* vector number      */
141)
142{
143  rtems_unsigned16 vec_idx  = vector - DMV170_IRQ_FIRST;
144  rtems_unsigned32 index;
145 
146  /*
147   *  Verify that all of the nodes have not been used.
148   */
149  assert  (Nodes_Used < NUM_LIRQ_HANDLERS);
150   
151  /*
152   *  If we have already installed this handler for this vector, then
153   *  just reset it.
154   */
155
156  for ( index=0 ; index <= Nodes_Used ; index++ ) {
157    if ( ISR_Nodes[index].vector == vector &&
158         ISR_Nodes[index].handler == handler )
159      return 0;
160  }
161
162  /*
163   * Increment the number of nedes used and set the index for the node
164   * array.
165   */
166 
167  Nodes_Used++;
168  index = Nodes_Used - 1;
169
170  /*
171   * Write the values of the handler and the vector to this node.
172   */
173  ISR_Nodes[index].handler = handler;
174  ISR_Nodes[index].vector  = vector;
175
176  /*
177   * Connect this node to the chain at the location of the
178   * vector index. 
179   */
180  Chain_Append( &ISR_Array[vec_idx], &ISR_Nodes[index].Node );
181
182  /*
183   * No interrupt service routine was removed so return 0
184   */
185  return 0;
186}
187
Note: See TracBrowser for help on using the repository browser.