7 Some general purpose IRQ routines
11 MSDOS: BC(y) Watcom(y) DJGPP(y)
17 (n) - no (not possible or not useful)
18 (?) - may be possible, but not tested
25 #define OCR1 0x20 /* 8259-1 Operation control register */
26 #define IMR1 0x21 /* 8259-1 Mask register */
28 #define OCR2 0xA0 /* 8259-2 Operation control register */
29 #define IMR2 0xA1 /* 8259-2 Mask register */
32 BOOL MIrq_IsEnabled(UBYTE irqno)
34 Returns true if the specified hardware irq is enabled.
37 UBYTE imr=(irqno>7) ? IMR2 : IMR1; /* interrupt mask register */
38 UBYTE msk=1<<(irqno&7); /* interrupt mask */
39 return((inportb(imr) & msk) == 0);
43 BOOL MIrq_OnOff(UBYTE irqno,UBYTE onoff)
45 Use to enable or disable the specified irq.
48 UBYTE imr=(irqno>7) ? IMR2 : IMR1; /* interrupt mask register */
49 UBYTE ocr=(irqno>7) ? OCR2 : OCR1; /* ocr */
50 UBYTE msk=1<<(irqno&7); /* interrupt mask */
51 UBYTE eoi=0x60|(irqno&7); /* specific end-of-interrupt */
54 /* save current setting of this irq */
55 oldstate=((inportb(imr) & msk) == 0);
58 outportb(imr,inportb(imr) & ~msk);
60 if(irqno>7) MIrq_OnOff(2,1);
63 outportb(imr,inportb(imr) | msk);
70 void MIrq_EOI(UBYTE irqno)
72 Clears the specified interrupt request at the interrupt controller.
75 UBYTE ocr=(irqno>7) ? OCR2 : OCR1; /* ocr */
76 UBYTE eoi=0x60|(irqno&7); /* specific end-of-interrupt */
79 if(irqno>7) outportb(OCR1,0x20);
83 PVI MIrq_SetHandler(UBYTE irqno,PVI handler)
86 _go32_dpmi_seginfo seginfo;
89 int vecno=(irqno>7) ? irqno+0x68 : irqno+0x8;
91 _go32_dpmi_get_protected_mode_interrupt_vector(vecno, &seginfo);
92 oldvect = (PVI)seginfo.pm_offset;
93 seginfo.pm_offset = (int)handler;
94 seginfo.pm_selector = _go32_my_cs();
95 _go32_dpmi_allocate_iret_wrapper(&seginfo);
96 _go32_dpmi_set_protected_mode_interrupt_vector(vecno, &seginfo);
98 oldvect=_dos_getvect(vecno);
99 _dos_setvect(vecno,handler);