source: rtems/c/src/lib/libbsp/powerpc/score603e/startup/genpvec.c @ 9345c7d

4.104.115
Last change on this file since 9345c7d was 9345c7d, checked in by Joel Sherrill <joel.sherrill@…>, on 08/07/09 at 15:49:23

2009-08-07 Joel Sherrill <joel.sherrill@…>

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