Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / seabios / src / hw / pic.h
1 // Helpers for working with i8259 interrupt controller.
2 //
3 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
4 // Copyright (C) 2002  MandrakeSoft S.A.
5 //
6 // This file may be distributed under the terms of the GNU LGPLv3 license.
7 #ifndef __PIC_H
8 #define __PIC_H
9
10 #include "x86.h" // outb
11
12 #define PORT_PIC1_CMD          0x0020
13 #define PORT_PIC1_DATA         0x0021
14 #define PORT_PIC2_CMD          0x00a0
15 #define PORT_PIC2_DATA         0x00a1
16
17 // PORT_PIC1 bitdefs
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)
23 // PORT_PIC2 bitdefs
24 #define PIC2_IRQ8  (1<<8)
25 #define PIC2_IRQ12 (1<<12)
26 #define PIC2_IRQ13 (1<<13)
27 #define PIC2_IRQ14 (1<<14)
28
29 #define PIC_IRQMASK_DEFAULT ((u16)~PIC1_IRQ2)
30
31 #define BIOS_HWIRQ0_VECTOR 0x08
32 #define BIOS_HWIRQ8_VECTOR 0x70
33
34 static inline void
35 pic_eoi1(void)
36 {
37     // Send eoi (select OCW2 + eoi)
38     outb(0x20, PORT_PIC1_CMD);
39 }
40
41 static inline void
42 pic_eoi2(void)
43 {
44     // Send eoi (select OCW2 + eoi)
45     outb(0x20, PORT_PIC2_CMD);
46     pic_eoi1();
47 }
48
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);
53 void pic_setup(void);
54 void enable_hwirq(int hwirq, struct segoff_s func);
55
56 #endif // pic.h