1 /* 2 * Interrupt handling. 3 * 4 * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include "board-defs.h" 21 22 #include "init.h" 23 #include "board.h" 24 #include "cpu.h" 25 #include "cpu_op.h" 26 #include "irq.h" 27 #include "tasks.h" 28 29 /* Initialisation and handling. */ 30 31 void irq_init() 32 { 33 handle_error_level(); 34 timer_init_irq(); 35 init_interrupts(); 36 } 37 38 void irq_handle() 39 { 40 unsigned short i; 41 42 /* Check interrupt identity. */ 43 44 if (REG_INTC_IPR & (1 << TIMER_CHAN_IRQ)) { 45 46 /* Switch task. */ 47 48 switch_task(); 49 50 /* Clear interrupt status. */ 51 52 timer_clear(); 53 54 /* Handle other interrupts, anyway. */ 55 56 } else { 57 for (i = 0; i < 32; i++) { 58 if (REG_INTC_IPR & (1 << i)) 59 __intc_ack_irq(i); 60 } 61 } 62 }