source: rtems/c/src/lib/libbsp/powerpc/psim/irq/irq_init.c @ 1611e8ca

4.104.114.84.95
Last change on this file since 1611e8ca was 78f96ab, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/05/07 at 20:32:43

fixed some problems with shared PPC exception handling code

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/* irq_init.c
2 *
3 *  This file contains the implementation of rtems initialization
4 *  related to interrupt handling.
5 *
6 *  CopyRight (C) 1999 valette@crf.canon.fr
7 *
8 * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com>
9 * to make it valid for MVME2300 Motorola boards.
10 *
11 * Till Straumann <strauman@slac.stanford.edu>, 12/20/2001:
12 * Use the new interface to openpic_init
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  irq_init.c,v 1.6.2.5 2003/09/04 18:45:20 joel Exp
19 */
20
21#include <libcpu/io.h>
22#include <libcpu/spr.h>
23#include <bsp/irq.h>
24#include <bsp.h>
25#include <libcpu/raw_exception.h>
26#include <rtems/bspIo.h>
27#if 0
28#include <bsp/pci.h>
29#include <bsp/residual.h>
30#include <bsp/openpic.h>
31#include <bsp/motorola.h>
32#endif
33
34
35/*
36#define SHOW_ISA_PCI_BRIDGE_SETTINGS
37*/
38
39typedef struct {
40  unsigned char bus;    /* few chance the PCI/ISA bridge is not on first bus but ... */
41  unsigned char device;
42  unsigned char function;
43} pci_isa_bridge_device;
44
45pci_isa_bridge_device* via_82c586 = 0;
46
47extern unsigned int external_exception_vector_prolog_code_size[];
48extern void external_exception_vector_prolog_code();
49extern unsigned int decrementer_exception_vector_prolog_code_size[];
50extern void decrementer_exception_vector_prolog_code();
51
52/*
53 * default on/off function
54 */
55static void nop_func(){}
56/*
57 * default isOn function
58 */
59static int not_connected() {return 0;}
60/*
61 * default possible isOn function
62 */
63static int connected() {return 1;}
64
65static rtems_irq_connect_data           rtemsIrq[BSP_IRQ_NUMBER];
66static rtems_irq_global_settings        initial_config;
67static rtems_irq_connect_data           defaultIrq = {
68  /* vectorIdex,         hdl            , handle        , on            , off           , isOn */
69  0,                     nop_func       , NULL          , nop_func      , nop_func      , not_connected
70};
71static rtems_irq_prio irqPrioTable[BSP_IRQ_NUMBER]={
72  /*
73   * actual rpiorities for interrupt :
74   *    0   means that only current interrupt is masked
75   *    255 means all other interrupts are masked
76   */
77  /*
78   * ISA interrupts.
79   * The second entry has a priority of 255 because
80   * it is the slave pic entry and is should always remain
81   * unmasked.
82   */
83  0,0,
84  255,
85  0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
86  /*
87   * PCI Interrupts
88   */
89  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* for raven prio 0 means unactive... */
90  /*
91   * Processor exceptions handled as interrupts
92   */
93  0
94};
95
96void VIA_isa_bridge_interrupts_setup(void)
97{
98  printk("VIA_isa_bridge_interrupts_setup - Shouldn't get here!\n");
99  return;
100}
101
102  /*
103   * This code assumes the exceptions management setup has already
104   * been done. We just need to replace the exceptions that will
105   * be handled like interrupt. On mcp750/mpc750 and many PPC processors
106   * this means the decrementer exception and the external exception.
107   */
108void BSP_rtems_irq_mng_init(unsigned cpuId)
109{
110  rtems_raw_except_connect_data vectorDesc;
111  int i;
112 
113  /*
114   * First initialize the Interrupt management hardware
115   */
116
117  /*
118   * Initialize Rtems management interrupt table
119   */
120    /*
121     * re-init the rtemsIrq table
122     */
123    for (i = 0; i < BSP_IRQ_NUMBER; i++) {
124      rtemsIrq[i]      = defaultIrq;
125      rtemsIrq[i].name = i;
126    }
127    /*
128     * Init initial Interrupt management config
129     */
130    initial_config.irqNb        = BSP_IRQ_NUMBER;
131    initial_config.defaultEntry = defaultIrq;
132    initial_config.irqHdlTbl    = rtemsIrq;
133    initial_config.irqBase      = BSP_ASM_IRQ_VECTOR_BASE;
134    initial_config.irqPrioTbl   = irqPrioTable;
135
136    if (!BSP_rtems_irq_mngt_set(&initial_config)) {
137      /*
138       * put something here that will show the failure...
139       */
140      BSP_panic("Unable to initialize RTEMS interrupt Management!!! System locked\n");
141    }
142 
143  /*
144   * We must connect the raw irq handler for the two
145   * expected interrupt sources : decrementer and external interrupts.
146   */
147    vectorDesc.exceptIndex      =       ASM_DEC_VECTOR;
148    vectorDesc.hdl.vector       =       ASM_DEC_VECTOR;
149    vectorDesc.hdl.raw_hdl      =       decrementer_exception_vector_prolog_code;
150    vectorDesc.hdl.raw_hdl_size =       (unsigned) decrementer_exception_vector_prolog_code_size;
151    vectorDesc.on               =       nop_func;
152    vectorDesc.off              =       nop_func;
153    vectorDesc.isOn             =       connected;
154    if (!ppc_set_exception (&vectorDesc)) {
155      BSP_panic("Unable to initialize RTEMS decrementer raw exception\n");
156    }
157    vectorDesc.exceptIndex      =       ASM_EXT_VECTOR;
158    vectorDesc.hdl.vector       =       ASM_EXT_VECTOR;
159    vectorDesc.hdl.raw_hdl      =       external_exception_vector_prolog_code;
160    vectorDesc.hdl.raw_hdl_size =       (unsigned) external_exception_vector_prolog_code_size;
161    if (!ppc_set_exception (&vectorDesc)) {
162      BSP_panic("Unable to initialize RTEMS external raw exception\n");
163    }
164#ifdef TRACE_IRQ_INIT 
165    printk("RTEMS IRQ management is now operationnal\n");
166#endif
167}
168
Note: See TracBrowser for help on using the repository browser.