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