; vi:filetype=nasm ts=8 sts=8 sw=8: PIC1_CMD equ 020h PIC2_CMD equ 0a0h OCW2_EOI equ 020h OCW3_ISR equ 00bh IRQ_OFFSET equ 32 %define IRQ_TO_INTR(x) ((x) + IRQ_OFFSET) %define INTR_TO_IRQ(x) ((x) - IRQ_OFFSET) %macro set_irq_vector 2 push dword IRQ_TO_INTR(%1) push dword %2 call set_intr %endmacro %macro mask_irq 1 %if %1 < 8 %assign port PIC1_DATA %assign mask (1 << %1) %else %assign port PIC2_DATA %assign mask (1 << (%1 - 8)) %endif in al, port or al, mask out port, al %endmacro %macro unmask_irq 1 %if %1 < 8 %assign port PIC1_DATA %assign mask ~(1 << %1) %else %assign port PIC2_DATA %assign mask ~(1 << (%1 - 8)) %endif in al, port and al, mask out port, al %endmacro %macro end_of_irq 1 mov al, OCW2_EOI %if %1 >= 8 out PIC2_CMD, al %endif out PIC1_CMD, al %endmacro extern idt %ifndef INTR_ASM_ extern set_intr %endif