[comp.os.msdos.programmer] I/O and Intel 8259A

jgb@prism.gatech.EDU (James G. Baker) (04/08/91)

In article <16410@chaph.usc.edu> syau@aludra.usc.edu (Shu-Jye Syau) writes:
>Hi :
>    My problem is how can I get the interrupt number ?
>    I use TC 2.0 , setvect(intno,int_vect) .
>    
>    The data inport address is 0x0394 .
>    Please help !!!!!

The INTERRUPT NUMBER refered to is really the software interrupt level.  The
8259 is programmed by the BIOS initialization routines to place the external
hardware interrupt table to start at location 0020 hex.  Each table entry
has the IP and CS for your interrupt service routine, so it is 4 bytes
each.  

You need to determine what interrupt line your device is using.  For example,
a serial port might use IRQ4 which is level 12 (add 8 to irq#); the vector
is located at location 30hex (12*4).  On a XT, IRQ2 is unused, but on an AT, 
this line is used by the cascade 8259 to allow for 8 more IRQ lines, so 
things get tricky.  The setvect() makes life much easier. 

If you use level 2, then 
   setvect( 2, my_isr() );
would change the 8086 NMI vector, which would not be a good thing, instead:
   setvect( 10, my_isr() );

Also, its not a bad idea to disable() and enable() around this critical section
of messing with the interrupt table.  And, you might want to save the old
entry and restore the table after you finish.

As you write your my_isr(), be sure to handle the very important issues
such as the End-Of-Interrupt (EOI) command that must be sent to the
8259 to allow more interrupts to be processed.  It is here, within my_isr()
that you would read from 0x0394.

As mentioned, the AT redirects IRQ2 to IRQ9 without you knowing it, but
you have to deal with two EOI's for both the 8259s.  Similar story with
a PS/2.

Good luck...



-- 
BAKER,JAMES G - Undergraduate Lab Instructor, School of Electrical Engineering
____  _    _    Georgia Institute of Technology, Atlanta Georgia, 30332
  |  | _  |_)   uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!jgb 
(_|. |_). |_).  Internet: jgb@prism.gatech.edu

nengle@copper.ucs.indiana.edu (nathan engle) (04/08/91)

In article <16410@chaph.usc.edu> syau@aludra.usc.edu (Shu-Jye Syau) writes:
>Hi :
>    I install a voice card in PC , when voice input , the ADC will interrupt
>8259A , and execute a interrupt handler to read in digital data from ADC .
>(hardware interrupt).
>
>    My problem is how can I get the interrupt number ?
>    I use TC 2.0 , setvect(intno,int_vect) .
>    
  You need to do a little reading and research. Somewhere in your manual
(or maybe even silkscreened on the voice card itself) there should be a
jumper block or setup option that says what IRQ level the voice card
generates for its ADC End-of-Conversion interrupt. My guess is that the
board defaults to either IRQ2 (for XTs), IRQ5 (for ATs), or IRQ3 (which
would work in either but would conflict with COM2 if it's installed.

  As hardware IRQ's come in through the 8259, it has been set up (and
this is standard for all IBM compatibles) so that the actual interrupt
generated is equal to the IRQ level + 8. Therefore IRQ2 comes in on
interrupt vector 0x0A (8 + 2), IRQ3 comes in as 0x0B, etc.

  So you need to find out what interrupt the voice card is using in
order to find out which interrupt vector to use.

>    The data inport address is 0x0394 .
>    Please help !!!!!

  The I/O address of a card like this almost never tells you which
interrupt it'll use. Standard cards like disk controllers and serial
ports have standard assignments that can clue you in on what IRQ they
should use, but voice cards just aren't common enough for this sort of
identification method.

>scott
>USC
>syau@aludra.usc.edu

Nathan Engle             Software Evangelist
Indiana University       Dept of Psychology
nengle@copper.ucs.indiana.edu