[comp.os.msdos.programmer] Programming interrupts on an AT

lawson@suphys.physics.su.OZ.AU (Peter Lawson) (06/19/91)

I have been writing code for DMA data acquisition based on an article
which appeared in Jan. 1990's "Dr. Dobb's Journal".  The MS C example that
he gives shows how to program an interrupt service routine for a PC,
which only has one 8259A Programmable Interrupt Controller and therefore
only supports interrupts 0 through 7.  

I would like to know how to program interrupts on an AT, and I would be
very grateful for good references.  The AT has two 8259A chips, which are
set up in a master-slave configuration; the slave chip appears as only
one other interrupt line to the master chip (usually interrupt line 2).
I would like to use interrupt level 11, but don't know how to approach it.
The programming of the two chips is a bit more complicated.  I have all the
addresses for the chips, from my cryptic computer manual, but I'm not
sure how the masks are to be set up.  I assume that "Dr. Dobb's" has had
articles on the subject, but this university doesn't subscribe to it.
Any help would be greatly appreciated.

Peter.

Astronomy Department.  Sydney University
NSW 2006    Australia.

msmith%peruvian.utah.edu@cs.utah.edu (Matthew Smith) (06/20/91)

In article <1991Jun18.235514.9294@metro.ucc.su.OZ.AU> lawson@suphys.physics.su.OZ.AU (Peter Lawson) writes:
>I have been writing code for DMA data acquisition based on an article
>which appeared in Jan. 1990's "Dr. Dobb's Journal".  The MS C example that
>he gives shows how to program an interrupt service routine for a PC,
>which only has one 8259A Programmable Interrupt Controller and therefore
>only supports interrupts 0 through 7.  
>
>I would like to know how to program interrupts on an AT, and I would be
>very grateful for good references.  The AT has two 8259A chips, which are
>set up in a master-slave configuration; the slave chip appears as only
>one other interrupt line to the master chip (usually interrupt line 2).
>I would like to use interrupt level 11, but don't know how to approach it.
>The programming of the two chips is a bit more complicated.  I have all the
>addresses for the chips, from my cryptic computer manual, but I'm not
>sure how the masks are to be set up.  I assume that "Dr. Dobb's" has had
>articles on the subject, but this university doesn't subscribe to it.
>Any help would be greatly appreciated.
>
>Peter.
>
>Astronomy Department.  Sydney University
>NSW 2006    Australia.

Hi there.  Actually, it's not too difficult to set up the chips for whatever
interrupt programming you want to do.  The mask is very simple, bits 0 through
7 on the first 8259 correspond to IRQ's 0-7 (interrupts 8-15), and the same
bits on the second 8952 correspond to IRQ's 8-15 (interrupts 16-23).  If a 0
is in the n-th bit, then the n-th IRQ is enabled, if a 1 is in the spot, then
the IRQ is disabled.  

To write a particular mask to the chip, you use the addresses you found, and
do an outport(addr,mask), where addr is the address of the chip you want to
change, and the mask is the bitmask to place in the chip.  

I remember that the address of the first chip is 0x20, but I don't recall the
second address.  What is it??

After that, writing programs for a particular interrupt use the functions
getvector() and setvector() to modify the interrupt table to point to
your function when an interrupt occurs.

I hope this helps...

Matt Smith
msmith@peruvian.utah.edu

jim@visix.com (Jim Edwards-Hewitt) (06/20/91)

lawson@suphys.physics.su.OZ.AU (Peter Lawson) writes:
>I would like to know how to program interrupts on an AT, and I would be
>very grateful for good references.  ...

msmith%peruvian.utah.edu@cs.utah.edu (Matthew Smith) writes:
>       Actually, it's not too difficult to set up the chips for whatever
> interrupt programming you want to do.  ...

The other information that's useful to have (which I unfortunately
don't have a reference for at the moment) is what devices use what
interrupts.  That way you don't change your hard disk or keyboard
interrupt accidentally.  I never found enough information on this in
the various PC hardware books I checked.  Unfortunately, the only
really good reference I ever found on the subject was the manual for
the AMX-86 real-time operating system.  They had to muck with a lot of
the hardware to make the system work well, and they told you in the
manual how they did it all, with source code.

       -- Jim

__

Jim Edwards-Hewitt                                       jim@visix.com
Visix Software Inc.                                ...!uunet!visix!jim
__

In the future, men will be women, and women will be men.    -- David Byrne
--
__

Jim Edwards-Hewitt                                       jim@visix.com
Visix Software Inc.                                ...!uunet!visix!jim
__

In the future, men will be women, and women will be men.    -- David Byrne

lawson@suphys.physics.su.OZ.AU (Peter Lawson) (06/21/91)

> lawson@suphys.physics.su.OZ.AU (Peter Lawson) writes:
>>I would like to know how to program interrupts on an AT, and I would be
>>very grateful for good references.  ...
> 
 Jim Edwards-Hewitt writes 
> 
> The other information that's useful to have (which I unfortunately
> don't have a reference for at the moment) is what devices use what
> interrupts.  That way you don't change your hard disk or keyboard
> interrupt accidentally. 
> 

I'm using a National Instruments AT-DIO-32F interface card. The manual
that comes with it has the following to say:

Do NOT use interrupt line 6 or interrupt line 14. Interrupt 6 is
used by the diskette drive controller, and interrupt line 14 is used
by the hard disk controller on most IBM PC AT's and compatibles.

My NEC APC IV System Reference Guide is somewhat more explicit, but I'm
not sure how general it is. For what it's worth it has the following
table:

IRQ00	Timer counter #0 output
IRQ01	Keyboard (output buffer full)
IRQ02	INT output from the slave 8259A [interrupt controller]
IRQ08	Realtime clock
IRQ09	Software INT0AH
IRQ10	Reserved
IRQ11	Reserved
IRQ12	Reserved
IRQ13	80287
IRQ14	Fixed disk controler
IRQ15	Reserved
IRQ03	Serial port 2
IRQ04	Serial port 1
IRQ05	Parallel port 2
IRQ06	Floppy disk controller
IRQ07	Parallel port 1

The ones marked "Reserved" are the ones you can use.  IRQ00-IRQ07 are
on the Master 8259A, and IRQ08-IRQ15 are through the Slave 8259A.

Peter.

Astronomy Department, Sydney University
NSW 2006 Australia.