3 * Copyright 2007 Free Software Foundation, Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "memory_map.h"
27 * Our secondary interrupt vector.
29 irq_handler_t pic_vector[NVECTORS] = {
44 // uP is level triggered
46 pic_regs->mask = ~0; // mask all interrupts
47 pic_regs->edge_enable = PIC_TIMER_INT | PIC_PHY_INT;
48 pic_regs->polarity = ~0 & ~PIC_PHY_INT; // rising edge
49 pic_regs->pending = ~0; // clear all pending ints
53 * This magic gets pic_interrupt_handler wired into the
54 * system interrupt handler with the appropriate prologue and
57 void pic_interrupt_handler() __attribute__ ((interrupt_handler));
59 void pic_interrupt_handler()
61 // pending and not masked interrupts
62 int live = pic_regs->pending & ~pic_regs->mask;
64 // FIXME loop while there are interrupts to service.
65 // That will reduce our overhead.
67 // handle the first one set
70 for (i=0, mask=1; i < NVECTORS; i++, mask <<= 1){
71 if (mask & live){ // handle this one
74 pic_regs->pending = mask; // clear pending interrupt
81 pic_register_handler(unsigned irq, irq_handler_t handler)
85 pic_vector[irq] = handler;
87 pic_regs->mask &= ~IRQ_TO_MASK(irq);
91 nop_handler(unsigned irq)