source: rtems/c/src/lib/libbsp/powerpc/gen5200/irq/irq_init.c @ f8506230

4.104.114.95
Last change on this file since f8506230 was f8506230, checked in by Ralf Corsepius <ralf.corsepius@…>, on 08/20/08 at 04:28:02

Add missing prototypes.

  • Property mode set to 100644
File size: 12.3 KB
Line 
1/*===============================================================*\
2| Project: RTEMS generic MPC5200 BSP                              |
3+-----------------------------------------------------------------+
4| Partially based on the code references which are named below.   |
5| Adaptions, modifications, enhancements and any recent parts of  |
6| the code are:                                                   |
7|                    Copyright (c) 2005                           |
8|                    Embedded Brains GmbH                         |
9|                    Obere Lagerstr. 30                           |
10|                    D-82178 Puchheim                             |
11|                    Germany                                      |
12|                    rtems@embedded-brains.de                     |
13+-----------------------------------------------------------------+
14| The license and distribution terms for this file may be         |
15| found in the file LICENSE in this distribution or at            |
16|                                                                 |
17| http://www.rtems.com/license/LICENSE.                           |
18|                                                                 |
19+-----------------------------------------------------------------+
20| this file contains the IRQ controller/system initialization     |
21\*===============================================================*/
22/***********************************************************************/
23/*                                                                     */
24/*   Module:       irq_init.c                                          */
25/*   Date:         07/17/2003                                          */
26/*   Purpose:      RTEMS MPC5x00 CPU interrupt initialization          */
27/*                                                                     */
28/*---------------------------------------------------------------------*/
29/*                                                                     */
30/*   Description:  This file contains the implementation of rtems      */
31/*                 initialization related to interrupt handling.       */
32/*                                                                     */
33/*---------------------------------------------------------------------*/
34/*                                                                     */
35/*   Code                                                              */
36/*   References:   MBX8xx CPU interrupt initialization                 */
37/*   Module:       irq_init.c                                          */
38/*   Project:      RTEMS 4.6.0pre1 / MBX8xx BSP                        */
39/*   Version       1.1                                                 */
40/*   Date:         04/06/2001                                          */
41/*                                                                     */
42/*   Author(s) / Copyright(s):                                         */
43/*                                                                     */
44/*   CopyRight (C) 2001 valette@crf.canon.fr                           */
45/*                                                                     */
46/*   The license and distribution terms for this file may be           */
47/*   found in found in the file LICENSE in this distribution or at     */
48/*   http://www.rtems.com/license/LICENSE.                        */
49/*                                                                     */
50/*---------------------------------------------------------------------*/
51/*                                                                     */
52/*   Partially based on the code references which are named above.     */
53/*   Adaptions, modifications, enhancements and any recent parts of    */
54/*   the code are under the right of                                   */
55/*                                                                     */
56/*         IPR Engineering, Dachauer Straße 38, D-80335 MÃŒnchen        */
57/*                        Copyright(C) 2003                            */
58/*                                                                     */
59/*---------------------------------------------------------------------*/
60/*                                                                     */
61/*   IPR Engineering makes no representation or warranties with        */
62/*   respect to the performance of this computer program, and          */
63/*   specifically disclaims any responsibility for any damages,        */
64/*   special or consequential, connected with the use of this program. */
65/*                                                                     */
66/*---------------------------------------------------------------------*/
67/*                                                                     */
68/*   Version history:  1.0                                             */
69/*                                                                     */
70/***********************************************************************/
71
72#include <bsp.h>
73#include <rtems.h>
74#include "../irq/irq.h"
75#include <rtems/bspIo.h>
76#include <libcpu/raw_exception.h>
77#include "../include/mpc5200.h"
78
79extern unsigned int external_exception_vector_prolog_code_size;
80extern void external_exception_vector_prolog_code(void);
81extern unsigned int decrementer_exception_vector_prolog_code_size;
82extern void decrementer_exception_vector_prolog_code(void);
83extern unsigned int system_management_exception_vector_prolog_code_size;
84extern void system_management_exception_vector_prolog_code(void);
85
86extern void BSP_panic(char *s);
87extern void _BSP_Fatal_error(unsigned int v);
88/*
89volatile unsigned int ppc_cached_irq_mask;
90*/
91
92/*
93 * default on/off function
94 */
95static void nop_func(void){}
96/*
97 * default isOn function
98 */
99static int not_connected(void) {return 0;}
100/*
101 * default possible isOn function
102 */
103static int connected(void) {return 1;}
104
105static rtems_irq_connect_data     rtemsIrq[BSP_IRQ_NUMBER];
106static rtems_irq_global_settings  initial_config;
107
108static rtems_irq_connect_data     defaultIrq =
109  {
110  /* vectorIdex, hdl     , param, on      , off     , isOn */
111  0,             nop_func, NULL , nop_func, nop_func, not_connected };
112
113static rtems_irq_prio irqPrioTable[BSP_SIU_IRQ_NUMBER] =
114  {
115/* per. int. priorities (0-7) / 4bit coding / msb is HI/LO selection               */
116/* msb = 0 -> non-critical per. int. is routed to main int. (LO_int)               */
117/* msb = 1 -> critical per. int. is routed to critical int. (HI_int)               */
118  0xF, 0,   0,   0,   /* smart_comm (do not change!), psc1, psc2, psc3             */
119  0,   0,   0,   0,   /* irda, eth, usb, ata                                       */
120  0,   0,   0,   0,   /* pci_ctrl, pci_sc_rx, pci_sc_tx, res                       */
121  0,   0,   0,   0,   /* res, spi_modf, spi_spif, i2c1                             */
122  0,   0,   0,   0,   /* i2c, can1, can2, ir_rx                                    */
123  0,   0,             /* ir_rx, xlb_arb                                            */
124/* main interrupt priorities (0-7) / 4bit coding / msb is INT/SMI selection        */
125/* msb = 0 -> main int. is routed to processor INT (low vector base 0x500 )        */
126/* msb = 1 -> main int. is routed to processor SMI (low vector base 0x1400 )       */
127            0,   0,   /* slice_tim2, irq1                                          */
128  0,   0,   0,   0,   /* irq2, irq3, lo_int, rtc_pint                              */
129  0,   0,   0,   0,   /* rtc_sint, gpio_std, gpio_wkup, tmr0                       */
130  0,   0,   0,   0,   /* tmr1, tmr2, tmr3, tmr4                                    */
131  0,   0,   0,        /* tmr5, tmr6, tmr7                                          */
132  /* critical interrupt priorities (0-3) / 2bit coding / no special purpose of msb */
133                 0,   /* irq0                                                      */
134  0,   0,   0         /* slice_tim1, hi_int, ccs_wkup                              */
135  };
136
137uint32_t irqMaskTable[BSP_PER_IRQ_NUMBER + BSP_MAIN_IRQ_NUMBER];
138
139
140/*
141 * setup irqMaskTable to support a priorized/nested interrupt environment
142 */
143void setup_irqMaskTable(void)
144  {
145  rtems_irq_prio prio = 0;
146  uint32_t i = 0, j = 0, mask = 0;
147
148  /* set up the priority dependent masks for peripheral interrupts */
149  for(i = BSP_PER_IRQ_LOWEST_OFFSET; i <= BSP_PER_IRQ_MAX_OFFSET; i++)
150    {
151
152    prio = irqPrioTable[i];
153    mask = 0;
154
155    for(j = BSP_PER_IRQ_LOWEST_OFFSET; j <= BSP_PER_IRQ_MAX_OFFSET; j++)
156      {
157
158      if(prio > irqPrioTable[j])
159            mask |= (1 << (31 - j + BSP_PER_IRQ_LOWEST_OFFSET));
160
161      if((prio == irqPrioTable[j]) && (j >= i))
162        mask |= (1 << (31 - j + BSP_PER_IRQ_LOWEST_OFFSET));
163
164      }
165
166    irqMaskTable[i] = mask;
167
168    }
169
170
171  /* set up the priority dependent masks for main interrupts */
172  for(i = BSP_MAIN_IRQ_LOWEST_OFFSET; i <= BSP_MAIN_IRQ_MAX_OFFSET; i++)
173    {
174
175    prio = irqPrioTable[i];
176    mask = 0;
177
178    for(j = BSP_MAIN_IRQ_LOWEST_OFFSET; j <= BSP_MAIN_IRQ_MAX_OFFSET; j++)
179      {
180
181      if(prio > irqPrioTable[j])
182        mask |= (1 << (16 - j + BSP_MAIN_IRQ_LOWEST_OFFSET));
183
184      if((prio == irqPrioTable[j]) && (j >= i))
185        mask |= (1 << (16 - j + BSP_MAIN_IRQ_LOWEST_OFFSET));
186
187      }
188
189    irqMaskTable[i] = mask;
190
191    }
192
193  }
194
195
196/*
197 * Initialize MPC5x00 SIU interrupt management
198 */
199void BSP_SIU_irq_init(void)
200  {
201
202  /* disable all peripheral interrupts */
203  mpc5200.per_mask = 0xFFFFFC00;
204
205  /* peripheral interrupt priorities according to reset value */
206  mpc5200.per_pri_1 = 0xF0000000;
207  mpc5200.per_pri_2 = 0x00000000;
208  mpc5200.per_pri_3 = 0x00000000;
209
210  /* disable external interrupts IRQ0-4 / critical interrupts are routed to core_int */
211  mpc5200.ext_en_type = 0x0F000001;
212
213  /* disable main interrupts / crit. int. priorities according to reset values */
214  mpc5200.crit_pri_main_mask = 0x0001FFFF;
215
216  /* main priorities according to reset value */
217  mpc5200.main_pri_1 = 0;
218  mpc5200.main_pri_2 = 0;
219
220  /* reset all status indicators */
221  mpc5200.csa    = 0x0001FFFF;
222  mpc5200.msa    = 0x0001FFFF;
223  mpc5200.psa    = 0x003FFFFF;
224  mpc5200.psa_be = 0x03000000;
225
226  setup_irqMaskTable();
227
228  }
229
230void BSP_rtems_irq_mng_init(unsigned cpuId)
231  {
232  rtems_raw_except_connect_data vectorDesc;
233  int i;
234  #if (BENCHMARK_IRQ_PROCESSING == 1)
235    extern void BSP_initialize_IRQ_Timing(void);
236
237    void BSP_initialize_IRQ_Timing(void);
238  #endif
239
240  BSP_SIU_irq_init();
241
242  /*
243   * Initialize Rtems management interrupt table
244   */
245
246  /*
247   * re-init the rtemsIrq table
248   */
249  for (i = 0; i < BSP_IRQ_NUMBER; i++) {
250    rtemsIrq[i]      = defaultIrq;
251    rtemsIrq[i].name = i;
252  }
253  /*
254   * Init initial Interrupt management config
255   */
256  initial_config.irqNb        = BSP_IRQ_NUMBER;
257  initial_config.defaultEntry = defaultIrq;
258  initial_config.irqHdlTbl    = rtemsIrq;
259  initial_config.irqBase      = BSP_LOWEST_OFFSET;
260  initial_config.irqPrioTbl   = irqPrioTable;
261 
262  if (!BSP_rtems_irq_mngt_set(&initial_config)) {
263    /*
264     * put something here that will show the failure...
265     */
266    BSP_panic(
267      "Unable to initialize RTEMS interrupt Management!!! System locked\n"
268    );
269  }
270
271  /*
272   * We must connect the raw irq handler for the two
273   * expected interrupt sources : decrementer and external interrupts.
274   */
275  vectorDesc.exceptIndex       = ASM_DEC_VECTOR;
276  vectorDesc.hdl.vector        = ASM_DEC_VECTOR;
277  vectorDesc.hdl.raw_hdl           = decrementer_exception_vector_prolog_code;
278  vectorDesc.hdl.raw_hdl_size  = (unsigned) &decrementer_exception_vector_prolog_code_size;
279  vectorDesc.on                = nop_func;
280  vectorDesc.off               = nop_func;
281  vectorDesc.isOn              = connected;
282
283  if (!ppc_set_exception (&vectorDesc)) {
284   BSP_panic("Unable to initialize RTEMS decrementer raw exception\n");
285  }
286
287  vectorDesc.exceptIndex           = ASM_EXT_VECTOR;
288  vectorDesc.hdl.vector        = ASM_EXT_VECTOR;
289  vectorDesc.hdl.raw_hdl       = external_exception_vector_prolog_code;
290  vectorDesc.hdl.raw_hdl_size  = (unsigned) &external_exception_vector_prolog_code_size;
291
292  if (!ppc_set_exception (&vectorDesc)) {
293    BSP_panic("Unable to initialize RTEMS external raw exception\n");
294  }
295
296  vectorDesc.exceptIndex           = ASM_60X_SYSMGMT_VECTOR;
297  vectorDesc.hdl.vector        = ASM_60X_SYSMGMT_VECTOR;
298  vectorDesc.hdl.raw_hdl       = system_management_exception_vector_prolog_code;
299  vectorDesc.hdl.raw_hdl_size  = (unsigned) &system_management_exception_vector_prolog_code_size;
300
301  if (!ppc_set_exception (&vectorDesc)) {
302    BSP_panic("Unable to initialize RTEMS system management raw exception\n");
303  }
304}
305
Note: See TracBrowser for help on using the repository browser.