You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pic8259.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Basic support for controlling the 8259 Programmable Interrupt Controllers.
  3. *
  4. * Initially written by Michael Brown (mcb30).
  5. */
  6. FILE_LICENCE ( GPL2_OR_LATER );
  7. #ifndef PIC8259_H
  8. #define PIC8259_H
  9. /* For segoff_t */
  10. #include "realmode.h"
  11. #define IRQ_PIC_CUTOFF 8
  12. /* 8259 register locations */
  13. #define PIC1_ICW1 0x20
  14. #define PIC1_OCW2 0x20
  15. #define PIC1_OCW3 0x20
  16. #define PIC1_ICR 0x20
  17. #define PIC1_IRR 0x20
  18. #define PIC1_ISR 0x20
  19. #define PIC1_ICW2 0x21
  20. #define PIC1_ICW3 0x21
  21. #define PIC1_ICW4 0x21
  22. #define PIC1_IMR 0x21
  23. #define PIC2_ICW1 0xa0
  24. #define PIC2_OCW2 0xa0
  25. #define PIC2_OCW3 0xa0
  26. #define PIC2_ICR 0xa0
  27. #define PIC2_IRR 0xa0
  28. #define PIC2_ISR 0xa0
  29. #define PIC2_ICW2 0xa1
  30. #define PIC2_ICW3 0xa1
  31. #define PIC2_ICW4 0xa1
  32. #define PIC2_IMR 0xa1
  33. /* Register command values */
  34. #define OCW3_ID 0x08
  35. #define OCW3_READ_IRR 0x03
  36. #define OCW3_READ_ISR 0x02
  37. #define ICR_EOI_NON_SPECIFIC 0x20
  38. #define ICR_EOI_NOP 0x40
  39. #define ICR_EOI_SPECIFIC 0x60
  40. #define ICR_EOI_SET_PRIORITY 0xc0
  41. /* Macros to enable/disable IRQs */
  42. #define IMR_REG(x) ( (x) < IRQ_PIC_CUTOFF ? PIC1_IMR : PIC2_IMR )
  43. #define IMR_BIT(x) ( 1 << ( (x) % IRQ_PIC_CUTOFF ) )
  44. #define irq_enabled(x) ( ( inb ( IMR_REG(x) ) & IMR_BIT(x) ) == 0 )
  45. #define enable_irq(x) outb ( inb( IMR_REG(x) ) & ~IMR_BIT(x), IMR_REG(x) )
  46. #define disable_irq(x) outb ( inb( IMR_REG(x) ) | IMR_BIT(x), IMR_REG(x) )
  47. /* Macros for acknowledging IRQs */
  48. #define ICR_REG( irq ) ( (irq) < IRQ_PIC_CUTOFF ? PIC1_ICR : PIC2_ICR )
  49. #define ICR_VALUE( irq ) ( (irq) % IRQ_PIC_CUTOFF )
  50. #define CHAINED_IRQ 2
  51. /* Utility macros to convert IRQ numbers to INT numbers and INT vectors */
  52. #define IRQ_INT( irq ) ( ( ( (irq) - IRQ_PIC_CUTOFF ) ^ 0x70 ) & 0x7f )
  53. /* Other constants */
  54. #define IRQ_MAX 15
  55. #define IRQ_NONE -1U
  56. /* Function prototypes
  57. */
  58. void send_eoi ( unsigned int irq );
  59. #endif /* PIC8259_H */