1 // Helpers for working with i8259 interrupt controller.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4 // Copyright (C) 2002 MandrakeSoft S.A.
6 // This file may be distributed under the terms of the GNU LGPLv3 license.
10 #include "x86.h" // outb
12 #define PORT_PIC1_CMD 0x0020
13 #define PORT_PIC1_DATA 0x0021
14 #define PORT_PIC2_CMD 0x00a0
15 #define PORT_PIC2_DATA 0x00a1
18 #define PIC1_IRQ0 (1<<0)
19 #define PIC1_IRQ1 (1<<1)
20 #define PIC1_IRQ2 (1<<2)
21 #define PIC1_IRQ5 (1<<5)
22 #define PIC1_IRQ6 (1<<6)
24 #define PIC2_IRQ8 (1<<8)
25 #define PIC2_IRQ12 (1<<12)
26 #define PIC2_IRQ13 (1<<13)
27 #define PIC2_IRQ14 (1<<14)
29 #define PIC_IRQMASK_DEFAULT ((u16)~PIC1_IRQ2)
31 #define BIOS_HWIRQ0_VECTOR 0x08
32 #define BIOS_HWIRQ8_VECTOR 0x70
37 // Send eoi (select OCW2 + eoi)
38 outb(0x20, PORT_PIC1_CMD);
44 // Send eoi (select OCW2 + eoi)
45 outb(0x20, PORT_PIC2_CMD);
49 u16 pic_irqmask_read(void);
50 void pic_irqmask_write(u16 mask);
51 void pic_irqmask_mask(u16 off, u16 on);
52 void pic_reset(u8 irq0, u8 irq8);
54 void enable_hwirq(int hwirq, struct segoff_s func);