pic8259.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Basic support for controlling the 8259 Programmable Interrupt Controllers.
*
* Initially written by Michael Brown (mcb30).
*/
#ifndef PIC8259_H
#define PIC8259_H
/* For segoff_t */
#include <segoff.h>
#define IRQ_PIC_CUTOFF (8)
/* 8259 register locations */
#define PIC1_ICW1 (0x20)
#define PIC1_OCW2 (0x20)
#define PIC1_OCW3 (0x20)
#define PIC1_ICR (0x20)
#define PIC1_IRR (0x20)
#define PIC1_ISR (0x20)
#define PIC1_ICW2 (0x21)
#define PIC1_ICW3 (0x21)
#define PIC1_ICW4 (0x21)
#define PIC1_IMR (0x21)
#define PIC2_ICW1 (0xa0)
#define PIC2_OCW2 (0xa0)
#define PIC2_OCW3 (0xa0)
#define PIC2_ICR (0xa0)
#define PIC2_IRR (0xa0)
#define PIC2_ISR (0xa0)
#define PIC2_ICW2 (0xa1)
#define PIC2_ICW3 (0xa1)
#define PIC2_ICW4 (0xa1)
#define PIC2_IMR (0xa1)
/* Register command values */
#define OCW3_ID (0x08)
#define OCW3_READ_IRR (0x03)
#define OCW3_READ_ISR (0x02)
#define ICR_EOI_NON_SPECIFIC (0x20)
#define ICR_EOI_NOP (0x40)
#define ICR_EOI_SPECIFIC (0x60)
#define ICR_EOI_SET_PRIORITY (0xc0)
/* Macros for acknowledging IRQs */
#define ICR_VALUE(x) ( (x) % IRQ_PIC_CUTOFF )
#define CHAINED_IRQ 2
/* Utility macros to convert IRQ numbers to INT numbers and INT vectors */
/* Other constants */
#define IRQ_MAX (15)
#define IRQ_NONE (0xff)
/* Labels in assembly code (asm.S)
*/
extern void _undi_irq_handler_start;
extern void _undi_irq_handler ( void );
extern volatile uint16_t _undi_irq_trigger_count;
extern volatile uint16_t _undi_irq_fail_count;
extern volatile uint16_t _undi_irq_not_ours_count;
extern segoff_t _undi_irq_chain_to;
extern uint8_t _undi_irq_chain;
extern uint8_t _pxenv_undi_irq;
extern segoff_t _pxenv_undi_entrypointsp;
/* Function prototypes
*/
#ifdef DEBUG_IRQ
void dump_irq_status ( void );
#else
#define dump_irq_status()
#endif
#endif /* PIC8259_H */