[comp.sys.ibm.pc.misc] PC Interrupt resolution

teg@cci632.UUCP (Thomas Gauger) (01/04/91)

Well I found the answer to my interrupt problem. First the solution
and then a response to a few of the responses that I got from
various individuals. Thank you for your quick responses, a contract
I am working on dependent on a quick resolution. Thank you again
I hope I can help you sometime.

Resolution: The problem turned out to be a 'faux pas' on my part.
It's what you get for tring to program in a hurry at 11 o'clock at
night.

Here is a piece of MS 'C' code that I had placed in my IRQ5 initialization
routine (sans comments):

bd_irq5init()
{
  unsigned char	mask;

  _disable();
  inp(OCW1, mask);
  mask &= ~IRQ5_MASK;
  outp(OCW1, mask);
  _enable();
}

This looks simple enough, the attempt is to enable the IRQ5 interrupt
in the 8259A interrupt controller chip. Looks like it should work, and
indeed it does enable IRQ5. But, those who know the 'inp()' library
routine will tell you that 'inp()' only accepts one parameter, a port 
address. It is supposed to return the value at that port address. Oops,
it should have been:

  mask = inp(OCW1);

Ode to have lint on a PC! The result was that whatever garbage was on the
stack at the location that 'mask' occupied become the new interrupt mask.
Thus IRQ6, floppy disk interrupt, was disabled. As was occasionally the
keyboard, the hard disk, .... well you get the idea.


Reply to responses:

There was some great debate by the IRQ usage on the PC AT. Here is the list
according to 'Interfacing to the PC' by Peter Sams.

IRQ0	Timer 0
IRQ1	Keyboard interrupt
IRQ2	Tied to second 8259A interrupt controller for IRQ8 - IRQ15
IRQ3	COM2
IRQ4	COM1
IRQ5	LPT2 if installed
IRQ6	Floppy DIsk controller
IRQ7	LPT1

IRQ5 indeed was used as the as the hard disk controller in the PC XT. In the
AT, it was moved to the IRQ8 - IRQ15 range. I don't remeber which one, as
I don't have the book in front of me.

The interrupt vector for IRQ0 (Timer) is 0x8. The first 8 interrupt vectors
are used by the 80286 processor for exceptions, NMI's, etc.


Thanks once again for your help.

-----------------------------------------
Thomas E. Gauger
The TEGGER
Rochester's self proclaimed #1 Bill's fan

Buffalo: 38
Opponents: 14

God, I hate the opponents!