1 /*
2  * Copyright (c) 2012 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #include <lk/debug.h>
9 #include <lk/compiler.h>
10 #include <arch/arm/cm.h>
11 #include <platform/stm32.h>
12 #include <target/debugconfig.h>
13 #include <lib/cbuf.h>
14 
15 /* un-overridden irq handler */
stm32_dummy_irq(void)16 void stm32_dummy_irq(void) {
17     arm_cm_irq_entry();
18 
19     panic("unhandled irq\n");
20 }
21 
22 /* a list of default handlers that are simply aliases to the dummy handler */
23 #define DEFAULT_HANDLER(x) \
24 void stm32_##x(void) __WEAK_ALIAS("stm32_dummy_irq");
25 
26 DEFAULT_HANDLER(WWDG_IRQ);
27 DEFAULT_HANDLER(PVD_IRQ);
28 DEFAULT_HANDLER(TAMP_STAMP_IRQ);
29 DEFAULT_HANDLER(RTC_WKUP_IRQ);
30 DEFAULT_HANDLER(FLASH_IRQ);
31 DEFAULT_HANDLER(RCC_IRQ);
32 DEFAULT_HANDLER(EXTI0_IRQ);
33 DEFAULT_HANDLER(EXTI1_IRQ);
34 DEFAULT_HANDLER(EXTI2_IRQ);
35 DEFAULT_HANDLER(EXTI3_IRQ);
36 DEFAULT_HANDLER(EXTI4_IRQ);
37 
38 DEFAULT_HANDLER(DMA1_Stream0_IRQ);
39 DEFAULT_HANDLER(DMA1_Stream1_IRQ);
40 DEFAULT_HANDLER(DMA1_Stream2_IRQ);
41 DEFAULT_HANDLER(DMA1_Stream3_IRQ);
42 DEFAULT_HANDLER(DMA1_Stream4_IRQ);
43 DEFAULT_HANDLER(DMA1_Stream5_IRQ);
44 DEFAULT_HANDLER(DMA1_Stream6_IRQ);
45 
46 DEFAULT_HANDLER(ADC_IRQ);
47 DEFAULT_HANDLER(CAN1_TX_IRQ);
48 DEFAULT_HANDLER(CAN1_RX0_IRQ);
49 DEFAULT_HANDLER(CAN1_RX1_IRQ);
50 DEFAULT_HANDLER(CAN1_SCE_IRQ);
51 DEFAULT_HANDLER(EXTI9_5_IRQ);
52 
53 DEFAULT_HANDLER(TIM1_BRK_TIM9_IRQ);
54 DEFAULT_HANDLER(TIM1_UP_TIM10_IRQ);
55 DEFAULT_HANDLER(TIM1_TRG_COM_TIM11_IRQ);
56 DEFAULT_HANDLER(TIM1_CC_IRQ);
57 DEFAULT_HANDLER(TIM2_IRQ);
58 DEFAULT_HANDLER(TIM3_IRQ);
59 DEFAULT_HANDLER(TIM4_IRQ);
60 
61 DEFAULT_HANDLER(I2C1_EV_IRQ);
62 DEFAULT_HANDLER(I2C1_ER_IRQ);
63 DEFAULT_HANDLER(I2C2_EV_IRQ);
64 DEFAULT_HANDLER(I2C2_ER_IRQ);
65 
66 DEFAULT_HANDLER(SPI1_IRQ);
67 DEFAULT_HANDLER(SPI2_IRQ);
68 
69 DEFAULT_HANDLER(USART1_IRQ);
70 DEFAULT_HANDLER(USART2_IRQ);
71 DEFAULT_HANDLER(USART3_IRQ);
72 
73 DEFAULT_HANDLER(EXTI15_10_IRQ);
74 DEFAULT_HANDLER(RTC_Alarm_IRQ);
75 DEFAULT_HANDLER(OTG_FS_WKUP_IRQ);
76 DEFAULT_HANDLER(TIM8_BRK_TIM12_IRQ);
77 DEFAULT_HANDLER(TIM8_UP_TIM13_IRQ);
78 DEFAULT_HANDLER(TIM8_TRG_COM_TIM14_IRQ);
79 DEFAULT_HANDLER(TIM8_CC_IRQ);
80 DEFAULT_HANDLER(DMA1_Stream7_IRQ);
81 DEFAULT_HANDLER(FSMC_IRQ);
82 DEFAULT_HANDLER(SDIO_IRQ);
83 DEFAULT_HANDLER(TIM5_IRQ);
84 DEFAULT_HANDLER(SPI3_IRQ);
85 DEFAULT_HANDLER(UART4_IRQ);
86 DEFAULT_HANDLER(UART5_IRQ);
87 DEFAULT_HANDLER(TIM6_DAC_IRQ);
88 DEFAULT_HANDLER(TIM7_IRQ);
89 
90 DEFAULT_HANDLER(DMA2_Stream0_IRQ);
91 DEFAULT_HANDLER(DMA2_Stream1_IRQ);
92 DEFAULT_HANDLER(DMA2_Stream2_IRQ);
93 DEFAULT_HANDLER(DMA2_Stream3_IRQ);
94 DEFAULT_HANDLER(DMA2_Stream4_IRQ);
95 
96 DEFAULT_HANDLER(ETH_IRQ);
97 DEFAULT_HANDLER(ETH_WKUP_IRQ);
98 DEFAULT_HANDLER(CAN2_TX_IRQ);
99 DEFAULT_HANDLER(CAN2_RX0_IRQ);
100 DEFAULT_HANDLER(CAN2_RX1_IRQ);
101 DEFAULT_HANDLER(CAN2_SCE_IRQ);
102 DEFAULT_HANDLER(OTG_FS_IRQ);
103 DEFAULT_HANDLER(DMA2_Stream5_IRQ);
104 DEFAULT_HANDLER(DMA2_Stream6_IRQ);
105 DEFAULT_HANDLER(DMA2_Stream7_IRQ);
106 DEFAULT_HANDLER(USART6_IRQ);
107 DEFAULT_HANDLER(I2C3_EV_IRQ);
108 DEFAULT_HANDLER(I2C3_ER_IRQ);
109 DEFAULT_HANDLER(OTG_HS_EP1_OUT_IRQ);
110 DEFAULT_HANDLER(OTG_HS_EP1_IN_IRQ);
111 DEFAULT_HANDLER(OTG_HS_WKUP_IRQ);
112 DEFAULT_HANDLER(OTG_HS_IRQ);
113 DEFAULT_HANDLER(DCMI_IRQ);
114 DEFAULT_HANDLER(CRYP_IRQ);
115 DEFAULT_HANDLER(HASH_RNG_IRQ);
116 
117 DEFAULT_HANDLER(FMC_IRQ);
118 DEFAULT_HANDLER(SDMMC1_IRQ);
119 DEFAULT_HANDLER(RNG_IRQ);
120 DEFAULT_HANDLER(FPU_IRQ);
121 DEFAULT_HANDLER(UART7_IRQ);
122 DEFAULT_HANDLER(UART8_IRQ);
123 DEFAULT_HANDLER(SPI4_IRQ);
124 DEFAULT_HANDLER(SPI5_IRQ);
125 DEFAULT_HANDLER(SPI6_IRQ);
126 DEFAULT_HANDLER(SAI1_IRQ);
127 DEFAULT_HANDLER(LTDC_IRQ);
128 DEFAULT_HANDLER(LTDC_ER_IRQ);
129 DEFAULT_HANDLER(DMA2D_IRQ);
130 DEFAULT_HANDLER(SAI2_IRQ);
131 DEFAULT_HANDLER(QUADSPI_IRQ);
132 DEFAULT_HANDLER(LPTIM1_IRQ);
133 DEFAULT_HANDLER(CEC_IRQ);
134 DEFAULT_HANDLER(I2C4_EV_IRQ);
135 DEFAULT_HANDLER(I2C4_ER_IRQ);
136 DEFAULT_HANDLER(SPDIF_RX_IRQ);
137 
138 #define VECTAB_ENTRY(x) [x##n] = stm32_##x
139 
140 /* appended to the end of the main vector table */
141 const void *const __SECTION(".text.boot.vectab2") vectab2[] = {
142     VECTAB_ENTRY(WWDG_IRQ),      /*!< Window WatchDog Interrupt                                         */
143     VECTAB_ENTRY(PVD_IRQ),      /*!< PVD through EXTI Line detection Interrupt                         */
144     VECTAB_ENTRY(TAMP_STAMP_IRQ),      /*!< Tamper and TimeStamp interrupts through the EXTI line             */
145     VECTAB_ENTRY(RTC_WKUP_IRQ),      /*!< RTC Wakeup interrupt through the EXTI line                        */
146     VECTAB_ENTRY(FLASH_IRQ),      /*!< FLASH global Interrupt                                            */
147     VECTAB_ENTRY(RCC_IRQ),      /*!< RCC global Interrupt                                              */
148     VECTAB_ENTRY(EXTI0_IRQ),      /*!< EXTI Line0 Interrupt                                              */
149     VECTAB_ENTRY(EXTI1_IRQ),      /*!< EXTI Line1 Interrupt                                              */
150     VECTAB_ENTRY(EXTI2_IRQ),      /*!< EXTI Line2 Interrupt                                              */
151     VECTAB_ENTRY(EXTI3_IRQ),      /*!< EXTI Line3 Interrupt                                              */
152     VECTAB_ENTRY(EXTI4_IRQ),     /*!< EXTI Line4 Interrupt                                              */
153     VECTAB_ENTRY(DMA1_Stream0_IRQ),     /*!< DMA1 Stream 0 global Interrupt                                    */
154     VECTAB_ENTRY(DMA1_Stream1_IRQ),     /*!< DMA1 Stream 1 global Interrupt                                    */
155     VECTAB_ENTRY(DMA1_Stream2_IRQ),     /*!< DMA1 Stream 2 global Interrupt                                    */
156     VECTAB_ENTRY(DMA1_Stream3_IRQ),     /*!< DMA1 Stream 3 global Interrupt                                    */
157     VECTAB_ENTRY(DMA1_Stream4_IRQ),     /*!< DMA1 Stream 4 global Interrupt                                    */
158     VECTAB_ENTRY(DMA1_Stream5_IRQ),     /*!< DMA1 Stream 5 global Interrupt                                    */
159     VECTAB_ENTRY(DMA1_Stream6_IRQ),     /*!< DMA1 Stream 6 global Interrupt                                    */
160     VECTAB_ENTRY(ADC_IRQ),     /*!< ADC1, ADC2 and ADC3 global Interrupts                             */
161     VECTAB_ENTRY(CAN1_TX_IRQ),     /*!< CAN1 TX Interrupt                                                 */
162     VECTAB_ENTRY(CAN1_RX0_IRQ),     /*!< CAN1 RX0 Interrupt                                                */
163     VECTAB_ENTRY(CAN1_RX1_IRQ),     /*!< CAN1 RX1 Interrupt                                                */
164     VECTAB_ENTRY(CAN1_SCE_IRQ),     /*!< CAN1 SCE Interrupt                                                */
165     VECTAB_ENTRY(EXTI9_5_IRQ),     /*!< External Line[9:5] Interrupts                                     */
166     VECTAB_ENTRY(TIM1_BRK_TIM9_IRQ),     /*!< TIM1 Break interrupt and TIM9 global interrupt                    */
167     VECTAB_ENTRY(TIM1_UP_TIM10_IRQ),     /*!< TIM1 Update Interrupt and TIM10 global interrupt                  */
168     VECTAB_ENTRY(TIM1_TRG_COM_TIM11_IRQ),     /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */
169     VECTAB_ENTRY(TIM1_CC_IRQ),     /*!< TIM1 Capture Compare Interrupt                                    */
170     VECTAB_ENTRY(TIM2_IRQ),     /*!< TIM2 global Interrupt                                             */
171     VECTAB_ENTRY(TIM3_IRQ),     /*!< TIM3 global Interrupt                                             */
172     VECTAB_ENTRY(TIM4_IRQ),     /*!< TIM4 global Interrupt                                             */
173     VECTAB_ENTRY(I2C1_EV_IRQ),     /*!< I2C1 Event Interrupt                                              */
174     VECTAB_ENTRY(I2C1_ER_IRQ),     /*!< I2C1 Error Interrupt                                              */
175     VECTAB_ENTRY(I2C2_EV_IRQ),     /*!< I2C2 Event Interrupt                                              */
176     VECTAB_ENTRY(I2C2_ER_IRQ),     /*!< I2C2 Error Interrupt                                              */
177     VECTAB_ENTRY(SPI1_IRQ),     /*!< SPI1 global Interrupt                                             */
178     VECTAB_ENTRY(SPI2_IRQ),     /*!< SPI2 global Interrupt                                             */
179     VECTAB_ENTRY(USART1_IRQ),     /*!< USART1 global Interrupt                                           */
180     VECTAB_ENTRY(USART2_IRQ),     /*!< USART2 global Interrupt                                           */
181     VECTAB_ENTRY(USART3_IRQ),     /*!< USART3 global Interrupt                                           */
182     VECTAB_ENTRY(EXTI15_10_IRQ),     /*!< External Line[15:10] Interrupts                                   */
183     VECTAB_ENTRY(RTC_Alarm_IRQ),     /*!< RTC Alarm (A and B) through EXTI Line Interrupt                   */
184     VECTAB_ENTRY(OTG_FS_WKUP_IRQ),     /*!< USB OTG FS Wakeup through EXTI line interrupt                     */
185     VECTAB_ENTRY(TIM8_BRK_TIM12_IRQ),     /*!< TIM8 Break Interrupt and TIM12 global interrupt                   */
186     VECTAB_ENTRY(TIM8_UP_TIM13_IRQ),     /*!< TIM8 Update Interrupt and TIM13 global interrupt                  */
187     VECTAB_ENTRY(TIM8_TRG_COM_TIM14_IRQ),     /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */
188     VECTAB_ENTRY(TIM8_CC_IRQ),     /*!< TIM8 Capture Compare Interrupt                                    */
189     VECTAB_ENTRY(DMA1_Stream7_IRQ),     /*!< DMA1 Stream7 Interrupt                                            */
190     VECTAB_ENTRY(FMC_IRQ),     /*!< FMC global Interrupt                                              */
191     VECTAB_ENTRY(SDMMC1_IRQ),     /*!< SDMMC1 global Interrupt                                             */
192     VECTAB_ENTRY(TIM5_IRQ),     /*!< TIM5 global Interrupt                                             */
193     VECTAB_ENTRY(SPI3_IRQ),     /*!< SPI3 global Interrupt                                             */
194     VECTAB_ENTRY(UART4_IRQ),     /*!< UART4 global Interrupt                                            */
195     VECTAB_ENTRY(UART5_IRQ),     /*!< UART5 global Interrupt                                            */
196     VECTAB_ENTRY(TIM6_DAC_IRQ),     /*!< TIM6 global and DAC1&2 underrun error  interrupts                 */
197     VECTAB_ENTRY(TIM7_IRQ),     /*!< TIM7 global interrupt                                             */
198     VECTAB_ENTRY(DMA2_Stream0_IRQ),     /*!< DMA2 Stream 0 global Interrupt                                    */
199     VECTAB_ENTRY(DMA2_Stream1_IRQ),     /*!< DMA2 Stream 1 global Interrupt                                    */
200     VECTAB_ENTRY(DMA2_Stream2_IRQ),     /*!< DMA2 Stream 2 global Interrupt                                    */
201     VECTAB_ENTRY(DMA2_Stream3_IRQ),     /*!< DMA2 Stream 3 global Interrupt                                    */
202     VECTAB_ENTRY(DMA2_Stream4_IRQ),     /*!< DMA2 Stream 4 global Interrupt                                    */
203     VECTAB_ENTRY(ETH_IRQ),     /*!< Ethernet global Interrupt                                         */
204     VECTAB_ENTRY(ETH_WKUP_IRQ),     /*!< Ethernet Wakeup through EXTI line Interrupt                       */
205     VECTAB_ENTRY(CAN2_TX_IRQ),     /*!< CAN2 TX Interrupt                                                 */
206     VECTAB_ENTRY(CAN2_RX0_IRQ),     /*!< CAN2 RX0 Interrupt                                                */
207     VECTAB_ENTRY(CAN2_RX1_IRQ),     /*!< CAN2 RX1 Interrupt                                                */
208     VECTAB_ENTRY(CAN2_SCE_IRQ),     /*!< CAN2 SCE Interrupt                                                */
209     VECTAB_ENTRY(OTG_FS_IRQ),     /*!< USB OTG FS global Interrupt                                       */
210     VECTAB_ENTRY(DMA2_Stream5_IRQ),     /*!< DMA2 Stream 5 global interrupt                                    */
211     VECTAB_ENTRY(DMA2_Stream6_IRQ),     /*!< DMA2 Stream 6 global interrupt                                    */
212     VECTAB_ENTRY(DMA2_Stream7_IRQ),     /*!< DMA2 Stream 7 global interrupt                                    */
213     VECTAB_ENTRY(USART6_IRQ),     /*!< USART6 global interrupt                                           */
214     VECTAB_ENTRY(I2C3_EV_IRQ),     /*!< I2C3 event interrupt                                              */
215     VECTAB_ENTRY(I2C3_ER_IRQ),     /*!< I2C3 error interrupt                                              */
216     VECTAB_ENTRY(OTG_HS_EP1_OUT_IRQ),     /*!< USB OTG HS End Point 1 Out global interrupt                       */
217     VECTAB_ENTRY(OTG_HS_EP1_IN_IRQ),     /*!< USB OTG HS End Point 1 In global interrupt                        */
218     VECTAB_ENTRY(OTG_HS_WKUP_IRQ),     /*!< USB OTG HS Wakeup through EXTI interrupt                          */
219     VECTAB_ENTRY(OTG_HS_IRQ),     /*!< USB OTG HS global interrupt                                       */
220     VECTAB_ENTRY(DCMI_IRQ),     /*!< DCMI global interrupt                                             */
221     VECTAB_ENTRY(RNG_IRQ),     /*!< RNG global interrupt                                              */
222     VECTAB_ENTRY(FPU_IRQ),     /*!< FPU global interrupt                                              */
223     VECTAB_ENTRY(UART7_IRQ),     /*!< UART7 global interrupt                                            */
224     VECTAB_ENTRY(UART8_IRQ),     /*!< UART8 global interrupt                                            */
225     VECTAB_ENTRY(SPI4_IRQ),     /*!< SPI4 global Interrupt                                             */
226     VECTAB_ENTRY(SPI5_IRQ),     /*!< SPI5 global Interrupt                                             */
227     VECTAB_ENTRY(SPI6_IRQ),     /*!< SPI6 global Interrupt                                             */
228     VECTAB_ENTRY(SAI1_IRQ),     /*!< SAI1 global Interrupt                                             */
229     VECTAB_ENTRY(LTDC_IRQ),     /*!< LTDC global Interrupt                                             */
230     VECTAB_ENTRY(LTDC_ER_IRQ),     /*!< LTDC Error global Interrupt                                       */
231     VECTAB_ENTRY(DMA2D_IRQ),     /*!< DMA2D global Interrupt                                            */
232     VECTAB_ENTRY(SAI2_IRQ),     /*!< SAI2 global Interrupt                                             */
233     VECTAB_ENTRY(QUADSPI_IRQ),     /*!< Quad SPI global interrupt                                         */
234     VECTAB_ENTRY(LPTIM1_IRQ),     /*!< LP TIM1 interrupt                                                 */
235     VECTAB_ENTRY(CEC_IRQ),     /*!< HDMI-CEC global Interrupt                                         */
236     VECTAB_ENTRY(I2C4_EV_IRQ),     /*!< I2C4 Event Interrupt                                              */
237     VECTAB_ENTRY(I2C4_ER_IRQ),     /*!< I2C4 Error Interrupt                                              */
238     VECTAB_ENTRY(SPDIF_RX_IRQ)     /*!< SPDIF-RX global Interrupt                                         */
239 };
240 
241