3 * Graeme Russ, graeme.russ@gmail.com
6 * Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * This file provides the interrupt handling functionality for systems
29 * based on the standard PC/AT architecture using two cascaded i8259
30 * Programmable Interrupt Controllers.
35 #include <asm/i8259.h>
36 #include <asm/ibmpc.h>
37 #include <asm/interrupt.h>
39 #if CONFIG_SYS_NUM_IRQS != 16
40 #error "CONFIG_SYS_NUM_IRQS must equal 16 if CONFIG_SYS_NUM_IRQS is defined"
52 DECLARE_INTERRUPT(10);
53 DECLARE_INTERRUPT(11);
54 DECLARE_INTERRUPT(12);
55 DECLARE_INTERRUPT(13);
56 DECLARE_INTERRUPT(14);
57 DECLARE_INTERRUPT(15);
59 int interrupt_init(void)
65 /* Setup interrupts */
66 set_vector(0x20, irq_0);
67 set_vector(0x21, irq_1);
68 set_vector(0x23, irq_3);
69 set_vector(0x24, irq_4);
70 set_vector(0x25, irq_5);
71 set_vector(0x26, irq_6);
72 set_vector(0x27, irq_7);
73 set_vector(0x28, irq_8);
74 set_vector(0x29, irq_9);
75 set_vector(0x2a, irq_10);
76 set_vector(0x2b, irq_11);
77 set_vector(0x2c, irq_12);
78 set_vector(0x2d, irq_13);
79 set_vector(0x2e, irq_14);
80 set_vector(0x2f, irq_15);
82 /* Mask all interrupts */
83 outb(0xff, MASTER_PIC + IMR);
84 outb(0xff, SLAVE_PIC + IMR);
87 /* Place master PIC interrupts at INT20 */
88 /* ICW3, One slave PIC is present */
89 outb(ICW1_SEL|ICW1_EICW4, MASTER_PIC + ICW1);
90 outb(0x20, MASTER_PIC + ICW2);
91 outb(IR2, MASTER_PIC + ICW3);
92 outb(ICW4_PM, MASTER_PIC + ICW4);
94 for (i = 0; i < 8; i++)
95 outb(OCW2_SEOI | i, MASTER_PIC + OCW2);
98 /* Place slave PIC interrupts at INT28 */
100 outb(ICW1_SEL|ICW1_EICW4, SLAVE_PIC + ICW1);
101 outb(0x28, SLAVE_PIC + ICW2);
102 outb(0x02, SLAVE_PIC + ICW3);
103 outb(ICW4_PM, SLAVE_PIC + ICW4);
105 for (i = 0; i < 8; i++)
106 outb(OCW2_SEOI | i, SLAVE_PIC + OCW2);
109 * Enable cascaded interrupts by unmasking the cascade IRQ pin of
119 void mask_irq(int irq)
123 if (irq >= CONFIG_SYS_NUM_IRQS)
127 imr_port = SLAVE_PIC + IMR;
129 imr_port = MASTER_PIC + IMR;
131 outb(inb(imr_port) | (1 << (irq & 7)), imr_port);
134 void unmask_irq(int irq)
138 if (irq >= CONFIG_SYS_NUM_IRQS)
142 imr_port = SLAVE_PIC + IMR;
144 imr_port = MASTER_PIC + IMR;
146 outb(inb(imr_port) & ~(1 << (irq & 7)), imr_port);
149 void specific_eoi(int irq)
151 if (irq >= CONFIG_SYS_NUM_IRQS)
156 * IRQ is on the slave - Issue a corresponding EOI to the
157 * slave PIC and an EOI for IRQ2 (the cascade interrupt)
160 outb(OCW2_SEOI | (irq & 7), SLAVE_PIC + OCW2);
164 outb(OCW2_SEOI | irq, MASTER_PIC + OCW2);