source: rtems/c/src/lib/libbsp/powerpc/eth_comm/irq/irq_init.c @ 4055e6f8

4.104.114.84.95
Last change on this file since 4055e6f8 was 4055e6f8, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 16, 2001 at 8:18:03 PM

2001-04-11 Eric Valette <valette@…>

  • clock/.cvsignore, clock/Makefile.am, clock/p_clock.c, include/8xx_immap.h, include/commproc.h, irq/.cvsignore, irq/Makefile.am, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c, vectors/.cvsignore, vectors/Makefile.am, vectors/vectors.S, vectors/vectors.h, vectors/vectors_init.c: New file.
  • Switch the eth_comm BSP to use the "new exception processing model."
  • Property mode set to 100644
File size: 4.7 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) 2001 valette@crf.canon.fr
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14#include <bsp/irq.h>
15#include <bsp.h>
16#include <libcpu/raw_exception.h>
17#include <bsp/8xx_immap.h>
18#include <bsp/commproc.h>
19
20extern unsigned int external_exception_vector_prolog_code_size;
21extern void external_exception_vector_prolog_code();
22extern unsigned int decrementer_exception_vector_prolog_code_size;
23extern void decrementer_exception_vector_prolog_code();
24
25volatile unsigned int ppc_cached_irq_mask;
26
27/*
28 * default on/off function
29 */
30static void nop_func(){}
31/*
32 * default isOn function
33 */
34static int not_connected() {return 0;}
35/*
36 * default possible isOn function
37 */
38static int connected() {return 1;}
39
40static rtems_irq_connect_data           rtemsIrq[BSP_IRQ_NUMBER];
41static rtems_irq_global_settings        initial_config;
42static rtems_irq_connect_data           defaultIrq = {
43  /* vectorIdex,         hdl            , on            , off           , isOn */
44  0,                     nop_func       , nop_func      , nop_func      , not_connected
45};
46static rtems_irq_prio irqPrioTable[BSP_IRQ_NUMBER]={
47  /*
48   * actual rpiorities for interrupt :
49   *    0   means that only current interrupt is masked
50   *    255 means all other interrupts are masked
51   */
52  /*
53   * SIU interrupts.
54   */
55  7,7, 6,6, 5,5, 4,4, 3,3, 2,2, 1,1, 0,0,
56  /*
57   * CPM Interrupts
58   */
59  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,
60  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
61  /*
62   * Processor exceptions handled as interrupts
63   */
64  0
65};
66
67void BSP_SIU_irq_init()
68{
69  /*
70   * In theory we should initialize two registers at least :
71   * SIMASK, SIEL. SIMASK is reset at 0 value meaning no interrupt. But
72   * we should take care that a monitor may have restoreed to another value.
73   * If someone find a reasonnable value for SIEL, AND THE NEED TO CHANGE IT
74   * please feel free to add it here.
75   */
76  ((volatile immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask = 0;
77  ((volatile immap_t *)IMAP_ADDR)->im_siu_conf.sc_sipend = 0xffff0000;
78  ppc_cached_irq_mask = 0;
79  ((volatile immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel = ((volatile immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel;
80}
81
82/*
83 * Initialize CPM interrupt management
84 */
85void
86BSP_CPM_irq_init(void)
87{
88  /*
89   * Initialize the CPM interrupt controller.
90   */
91  ((volatile immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr =
92#ifdef mpc860
93    (CICR_SCD_SCC4 | CICR_SCC_SCC3 | CICR_SCB_SCC2 | CICR_SCA_SCC1) |
94#else
95    (CICR_SCB_SCC2 | CICR_SCA_SCC1) |
96#endif   
97    ((BSP_CPM_INTERRUPT/2) << 13) | CICR_HP_MASK;
98  ((volatile immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr = 0;
99
100  ((volatile immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr |= CICR_IEN;
101}
102
103void BSP_rtems_irq_mng_init(unsigned cpuId)
104{
105  rtems_raw_except_connect_data vectorDesc;
106  int i;
107 
108  BSP_SIU_irq_init();
109  BSP_CPM_irq_init();
110  /*
111   * Initialize Rtems management interrupt table
112   */
113    /*
114     * re-init the rtemsIrq table
115     */
116    for (i = 0; i < BSP_IRQ_NUMBER; i++) {
117      rtemsIrq[i]      = defaultIrq;
118      rtemsIrq[i].name = i;
119    }
120    /*
121     * Init initial Interrupt management config
122     */
123    initial_config.irqNb        = BSP_IRQ_NUMBER;
124    initial_config.defaultEntry = defaultIrq;
125    initial_config.irqHdlTbl    = rtemsIrq;
126    initial_config.irqBase      = BSP_ASM_IRQ_VECTOR_BASE;
127    initial_config.irqPrioTbl   = irqPrioTable;
128
129    if (!BSP_rtems_irq_mngt_set(&initial_config)) {
130      /*
131       * put something here that will show the failure...
132       */
133      BSP_panic("Unable to initialize RTEMS interrupt Management!!! System locked\n");
134    }
135 
136  /*
137   * We must connect the raw irq handler for the two
138   * expected interrupt sources : decrementer and external interrupts.
139   */
140    vectorDesc.exceptIndex      =       ASM_DEC_VECTOR;
141    vectorDesc.hdl.vector       =       ASM_DEC_VECTOR;
142    vectorDesc.hdl.raw_hdl      =       decrementer_exception_vector_prolog_code;
143    vectorDesc.hdl.raw_hdl_size =       (unsigned) &decrementer_exception_vector_prolog_code_size;
144    vectorDesc.on               =       nop_func;
145    vectorDesc.off              =       nop_func;
146    vectorDesc.isOn             =       connected;
147    if (!mpc8xx_set_exception (&vectorDesc)) {
148      BSP_panic("Unable to initialize RTEMS decrementer raw exception\n");
149    }
150    vectorDesc.exceptIndex      =       ASM_EXT_VECTOR;
151    vectorDesc.hdl.vector       =       ASM_EXT_VECTOR;
152    vectorDesc.hdl.raw_hdl      =       external_exception_vector_prolog_code;
153    vectorDesc.hdl.raw_hdl_size =       (unsigned) &external_exception_vector_prolog_code_size;
154    if (!mpc8xx_set_exception (&vectorDesc)) {
155      BSP_panic("Unable to initialize RTEMS external raw exception\n");
156    }
157#ifdef TRACE_IRQ_INIT 
158    printk("RTEMS IRQ management is now operationnal\n");
159#endif
160}
161
Note: See TracBrowser for help on using the repository browser.