X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dos_sbtest;a=blobdiff_plain;f=src%2Fintr.h;fp=src%2Fintr.h;h=3345324d476e8de2942a381615d30067af9fd671;hp=0000000000000000000000000000000000000000;hb=07c19444f4f2a55abf97d181ab62aeaa51033c62;hpb=01a545fde6dc446fe626382f8bba50b9b7c1a35b diff --git a/src/intr.h b/src/intr.h new file mode 100644 index 0000000..3345324 --- /dev/null +++ b/src/intr.h @@ -0,0 +1,60 @@ +#ifndef INTR_H_ +#define INTR_H_ + +#define INTERRUPT __interrupt __far + +#define IRQ_TO_INTR(x) ((x) + 8) + +/* PIC command and data ports */ +#define PIC1_CMD 0x20 +#define PIC1_DATA 0x21 +#define PIC2_CMD 0xa0 +#define PIC2_DATA 0xa1 +/* PIC operation command word 2 bits */ +#define OCW2_EOI (1 << 5) + +unsigned char get_irq_mask(int pic); +#pragma aux get_irq_mask = \ + "cmp bx, 0" \ + "jnz getpic2" \ + "in al, 0x21" \ + "jmp getend" \ + "getpic2:" \ + "in al, 0xa1" \ + "getend:" \ + value[al] parm[ebx]; + +void mask_irq(int irq); +#pragma aux mask_irq = \ + "mov dx, 0x21" \ + "cmp ax, 8" \ + "jb skip_mask_pic2" \ + "mov dx, 0xa1" \ + "sub ax, 8" \ + "skip_mask_pic2:" \ + "mov cl, al" \ + "mov ah, 1" \ + "shl ah, cl" \ + "in al, dx" \ + "or al, ah" \ + "out dx, al" \ + parm[eax] modify[cl dx]; + +void unmask_irq(int irq); +#pragma aux unmask_irq = \ + "mov dx, 0x21" \ + "cmp ax, 8" \ + "jb skip_unmask_pic2" \ + "mov dx, 0xa1" \ + "sub ax, 8" \ + "skip_unmask_pic2:" \ + "mov cl, al" \ + "mov ah, 1" \ + "shl ah, cl" \ + "not ah" \ + "in al, dx" \ + "and al, ah" \ + "out dx, al" \ + parm[eax] modify[cl dx]; + +#endif /* INTR_H_ */