source: rtems/c/src/lib/libbsp/powerpc/score603e/startup/genpvec.c @ 2a832d8

4.104.114.84.95
Last change on this file since 2a832d8 was dac4208, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/31/04 at 03:47:07

2004-03-31 Ralf Corsepius <ralf_corsepius@…>

  • PCI_bus/PCI.c, PCI_bus/PCI.h, PCI_bus/flash.c, PCI_bus/universe.c, clock/clock.c, console/85c30.c, console/console.c, console/consolebsp.h, include/bsp.h, include/gen2.h, startup/FPGA.c, startup/Hwr_init.c, startup/bspstart.c, startup/genpvec.c, startup/spurious.c, startup/vmeintr.c, timer/timer.c, tod/tod.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*  genpvec.c
2 *
3 *  These routines handle the external exception.  Multiple ISRs occur off
4 *  of this one interrupt.
5 *
6 *  COPYRIGHT (c) 1989-1997.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may in
10 *  the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <bsp.h>
17#include <chain.h>
18#include <assert.h>
19
20#include <stdio.h> /* for sprintf */
21
22
23/*
24 * Proto types for this file                                         
25 */
26
27rtems_isr external_exception_ISR (
28  rtems_vector_number   vector                                  /* IN  */
29);
30
31#define   NUM_LIRQ_HANDLERS   20
32#define   NUM_LIRQ            ( MAX_BOARD_IRQS - PPC_IRQ_LAST )
33
34/*
35 * Structure to for one of possible multiple interrupt handlers for
36 * a given interrupt.
37 */
38typedef struct
39{
40  Chain_Node          Node;
41  rtems_isr_entry     handler;                  /* isr routine        */
42  rtems_vector_number vector;                   /* vector number      */
43} EE_ISR_Type;
44
45
46/* Note:  The following will not work if we add a method to remove
47 *        handlers at a later time.
48 */
49  EE_ISR_Type       ISR_Nodes [NUM_LIRQ_HANDLERS];
50  uint16_t          Nodes_Used;
51  Chain_Control     ISR_Array  [NUM_LIRQ];
52
53/* XXX */
54void init_irq_data_register();
55
56void initialize_external_exception_vector ()
57{
58  int i;
59  rtems_isr_entry previous_isr;
60  rtems_status_code status;
61
62  Nodes_Used = 0;
63
64  /*
65   * Mask out all interupts until they have a handler installed.
66   */
67
68  for (i=0; i <NUM_LIRQ; i++)
69    Chain_Initialize_empty( &ISR_Array[i] );
70 
71  init_irq_data_register();
72   
73  /* 
74   * Install external_exception_ISR () as the handler for
75   *  the General Purpose Interrupt.
76   */
77  status = rtems_interrupt_catch( external_exception_ISR,
78           PPC_IRQ_EXTERNAL, (rtems_isr_entry *) &previous_isr );
79}
80
81void Init_EE_mask_init() {
82;
83}
84
85/*
86 *  This routine installs one of multiple ISRs for the general purpose
87 *  inerrupt.
88 */
89rtems_isr_entry  set_EE_vector(
90  rtems_isr_entry     handler,      /* isr routine        */
91  rtems_vector_number vector        /* vector number      */
92)
93{
94  uint16_t         vec_idx  = vector - Score_IRQ_First;
95  uint32_t         index;
96 
97  assert  (Nodes_Used < NUM_LIRQ_HANDLERS);
98   
99  /*
100   *  If we have already installed this handler for this vector, then
101   *  just reset it.
102   */
103
104  for ( index=0 ; index <= Nodes_Used ; index++ ) {
105    if ( ISR_Nodes[index].vector == vector &&
106         ISR_Nodes[index].handler == handler )
107      return NULL;
108  }
109
110  /*
111   *  Doing things in this order makes them more atomic
112   */
113 
114  Nodes_Used++;
115
116  index = Nodes_Used - 1;
117
118  ISR_Nodes[index].handler = handler;
119  ISR_Nodes[index].vector  = vector;
120
121  /* printf( "Vector Index: %04x, Vector: %d (%x)\n",
122          vec_idx, vector, vector); */
123
124  Chain_Append( &ISR_Array[vec_idx], &ISR_Nodes[index].Node );
125
126  /*
127   * Unmask the interrupt.
128   */
129  unmask_irq( vec_idx );
130
131  return NULL;
132}
133
134/*
135 * This interrupt service routine is called for an External Exception.
136 */
137rtems_isr external_exception_ISR (
138  rtems_vector_number   vector             /* IN  */
139)
140{
141 uint16_t            index;
142 EE_ISR_Type         *node;
143 uint16_t            value;
144 char                err_msg[100];
145#if (HAS_PMC_PSC8)
146 uint16_t            PMC_irq;
147 uint16_t            check_irq;
148 uint16_t            status_word;
149#endif
150
151 index = read_and_clear_irq();
152 if ( index >= NUM_LIRQ ) {
153   sprintf( err_msg, "ERROR:: Invalid interrupt number (%02x)\n", index );
154   DEBUG_puts( err_msg );
155   return;
156 }
157
158#if (HAS_PMC_PSC8)
159  PMC_irq = SCORE603E_PCI_IRQ_0 - SCORE603E_IRQ00;
160
161  if (index ==  PMC_irq) {
162    status_word = read_and_clear_PMC_irq( index );
163
164    for (check_irq=SCORE603E_IRQ16; check_irq<=SCORE603E_IRQ19; check_irq++) {
165      if ( Is_PMC_IRQ( check_irq, status_word )) {
166        index = check_irq - SCORE603E_IRQ00;
167        node = (EE_ISR_Type *)(ISR_Array[ index ].first);
168
169        if ( _Chain_Is_tail( &ISR_Array[ index ], (void *)node ) ) {
170          sprintf(err_msg,"ERROR:: check %d interrupt %02d has no isr\n",
171                  check_irq, index);
172          DEBUG_puts( err_msg);
173          value = get_irq_mask();
174          sprintf(err_msg,"        Mask = %02x\n", value);
175          DEBUG_puts( err_msg);
176        }
177        while ( !_Chain_Is_tail( &ISR_Array[ index ], (void *)node ) ) {
178          (*node->handler)( node->vector );
179          node = (EE_ISR_Type *) node->Node.next;
180        }
181      }
182    }
183  }
184  else
185#endif
186  {
187    node = (EE_ISR_Type *)(ISR_Array[ index ].first);
188    if ( _Chain_Is_tail( &ISR_Array[ index ], (void *)node ) ) {
189      sprintf(err_msg,"ERROR:: interrupt %02x has no isr\n", index);
190      DEBUG_puts( err_msg);
191      value = get_irq_mask();
192      sprintf(err_msg,"        Mask = %02x\n", value);
193      DEBUG_puts( err_msg);
194      return;
195    }
196    while ( !_Chain_Is_tail( &ISR_Array[ index ], (void *)node ) ) {
197     (*node->handler)( node->vector );
198     node = (EE_ISR_Type *) node->Node.next;
199    }
200  }
201
202}
203
204
205
Note: See TracBrowser for help on using the repository browser.