source: rtems/c/src/lib/libbsp/powerpc/score603e/startup/genpvec.c @ 1666253f

4.104.115
Last change on this file since 1666253f was 8000c52, checked in by Joel Sherrill <joel.sherrill@…>, on 10/01/08 at 17:03:45

2008-10-01 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, PCI_bus/PCI.c, PCI_bus/universe.c, startup/genpvec.c: Fix warnings.
  • Property mode set to 100644
File size: 4.7 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-2008.
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 <rtems/chain.h>
18#include <rtems/bspIo.h>
19#include <assert.h>
20
21#include <stdio.h> /* for sprintf */
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  rtems_chain_node    Node;
41  rtems_isr_entry     handler;                  /* isr routine        */
42  rtems_vector_number vector;                   /* vector number      */
43} EE_ISR_Type;
44
45/* Note:  The following will not work if we add a method to remove
46 *        handlers at a later time.
47 */
48  EE_ISR_Type         ISR_Nodes [NUM_LIRQ_HANDLERS];
49  uint16_t            Nodes_Used;
50  rtems_chain_control ISR_Array  [NUM_LIRQ];
51
52/* XXX */
53void init_irq_data_register(void);
54
55#if 0
56void initialize_external_exception_vector (void)
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    rtems_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#endif
81
82void Init_EE_mask_init(void)
83{
84}
85
86/*
87 *  This routine installs one of multiple ISRs for the general purpose
88 *  inerrupt.
89 */
90rtems_isr_entry  set_EE_vector(
91  rtems_isr_entry     handler,      /* isr routine        */
92  rtems_vector_number vector        /* vector number      */
93)
94{
95  uint16_t         vec_idx  = vector - Score_IRQ_First;
96  uint32_t         index;
97
98  assert  (Nodes_Used < NUM_LIRQ_HANDLERS);
99
100  /*
101   *  If we have already installed this handler for this vector, then
102   *  just reset it.
103   */
104
105  for ( index=0 ; index <= Nodes_Used ; index++ ) {
106    if ( ISR_Nodes[index].vector == vector &&
107         ISR_Nodes[index].handler == handler )
108      return NULL;
109  }
110
111  /*
112   *  Doing things in this order makes them more atomic
113   */
114
115  Nodes_Used++;
116
117  index = Nodes_Used - 1;
118
119  ISR_Nodes[index].handler = handler;
120  ISR_Nodes[index].vector  = vector;
121
122  /* printf( "Vector Index: %04x, Vector: %d (%x)\n",
123          vec_idx, vector, vector); */
124
125  rtems_chain_append( &ISR_Array[vec_idx], &ISR_Nodes[index].Node );
126
127  /*
128   * Unmask the interrupt.
129   */
130  unmask_irq( vec_idx );
131
132  return NULL;
133}
134
135/*
136 * This interrupt service routine is called for an External Exception.
137 */
138rtems_isr external_exception_ISR (
139  rtems_vector_number   vector             /* IN  */
140)
141{
142 uint16_t            index;
143 EE_ISR_Type         *node;
144 uint16_t            value;
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   printk( "ERROR:: Invalid interrupt number (%02x)\n", index );
154   return;
155 }
156
157#if (HAS_PMC_PSC8)
158  PMC_irq = SCORE603E_PCI_IRQ_0 - SCORE603E_IRQ00;
159
160  if (index ==  PMC_irq) {
161    status_word = read_and_clear_PMC_irq( index );
162
163    for (check_irq=SCORE603E_IRQ16; check_irq<=SCORE603E_IRQ19; check_irq++) {
164      if ( Is_PMC_IRQ( check_irq, status_word )) {
165        index = check_irq - SCORE603E_IRQ00;
166        node = (EE_ISR_Type *)(ISR_Array[ index ].first);
167
168        if ( rtems_chain_is_tail( &ISR_Array[ index ], (void *)node ) ) {
169          printk ("ERROR:: check %d interrupt %02d has no isr\n", check_irq, index);
170          value = get_irq_mask();
171          printk("        Mask = %02x\n", value);
172        }
173        while ( !rtems_chain_is_tail( &ISR_Array[ index ], (void *)node ) ) {
174          (*node->handler)( node->vector );
175          node = (EE_ISR_Type *) node->Node.next;
176        }
177      }
178    }
179  }
180  else
181#endif
182  {
183    node = (EE_ISR_Type *)(ISR_Array[ index ].first);
184    if ( rtems_chain_is_tail( &ISR_Array[ index ], (void *)node ) ) {
185      printk( "ERROR:: interrupt %02x has no isr\n", index);
186      value = get_irq_mask();
187      printk("        Mask = %02x\n", value);
188      return;
189    }
190    while ( !rtems_chain_is_tail( &ISR_Array[ index ], (void *)node ) ) {
191     (*node->handler)( node->vector );
192     node = (EE_ISR_Type *) node->Node.next;
193    }
194  }
195
196}
Note: See TracBrowser for help on using the repository browser.