pic8259.h

Go to the documentation of this file.
00001 /*
00002  * Basic support for controlling the 8259 Programmable Interrupt Controllers.
00003  *
00004  * Initially written by Michael Brown (mcb30).
00005  */
00006 
00007 FILE_LICENCE ( GPL2_OR_LATER );
00008 
00009 #ifndef PIC8259_H
00010 #define PIC8259_H
00011 
00012 /* For segoff_t */
00013 #include "realmode.h"
00014 
00015 #define IRQ_PIC_CUTOFF 8
00016 
00017 /* 8259 register locations */
00018 #define PIC1_ICW1 0x20
00019 #define PIC1_OCW2 0x20
00020 #define PIC1_OCW3 0x20
00021 #define PIC1_ICR 0x20
00022 #define PIC1_IRR 0x20
00023 #define PIC1_ISR 0x20
00024 #define PIC1_ICW2 0x21
00025 #define PIC1_ICW3 0x21
00026 #define PIC1_ICW4 0x21
00027 #define PIC1_IMR 0x21
00028 #define PIC2_ICW1 0xa0
00029 #define PIC2_OCW2 0xa0
00030 #define PIC2_OCW3 0xa0
00031 #define PIC2_ICR 0xa0
00032 #define PIC2_IRR 0xa0
00033 #define PIC2_ISR 0xa0
00034 #define PIC2_ICW2 0xa1
00035 #define PIC2_ICW3 0xa1
00036 #define PIC2_ICW4 0xa1
00037 #define PIC2_IMR 0xa1
00038 
00039 /* Register command values */
00040 #define OCW3_ID 0x08
00041 #define OCW3_READ_IRR 0x03
00042 #define OCW3_READ_ISR 0x02
00043 #define ICR_EOI_NON_SPECIFIC 0x20
00044 #define ICR_EOI_NOP 0x40
00045 #define ICR_EOI_SPECIFIC 0x60
00046 #define ICR_EOI_SET_PRIORITY 0xc0
00047 
00048 /* Macros to enable/disable IRQs */
00049 #define IMR_REG(x) ( (x) < IRQ_PIC_CUTOFF ? PIC1_IMR : PIC2_IMR )
00050 #define IMR_BIT(x) ( 1 << ( (x) % IRQ_PIC_CUTOFF ) )
00051 #define irq_enabled(x) ( ( inb ( IMR_REG(x) ) & IMR_BIT(x) ) == 0 )
00052 #define enable_irq(x) outb ( inb( IMR_REG(x) ) & ~IMR_BIT(x), IMR_REG(x) )
00053 #define disable_irq(x) outb ( inb( IMR_REG(x) ) | IMR_BIT(x), IMR_REG(x) )
00054 
00055 /* Macros for acknowledging IRQs */
00056 #define ICR_REG( irq ) ( (irq) < IRQ_PIC_CUTOFF ? PIC1_ICR : PIC2_ICR )
00057 #define ICR_VALUE( irq ) ( (irq) % IRQ_PIC_CUTOFF )
00058 #define CHAINED_IRQ 2
00059 
00060 /* Utility macros to convert IRQ numbers to INT numbers and INT vectors  */
00061 #define IRQ_INT( irq ) ( ( ( (irq) - IRQ_PIC_CUTOFF ) ^ 0x70 ) & 0x7f )
00062 
00063 /* Other constants */
00064 #define IRQ_MAX 15
00065 #define IRQ_NONE -1U
00066 
00067 /* Function prototypes
00068  */
00069 void send_eoi ( unsigned int irq );
00070 
00071 #endif /* PIC8259_H */

Generated on Tue Apr 6 20:00:50 2010 for gPXE by  doxygen 1.5.7.1