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