The 8259 interrupt controller (HELP!)

Michael Baumann baumann at hope.UUCP
Sat May 28 12:32:57 AEST 1988


In article <531 at wsccs.UUCP> rargyle at wsccs.UUCP (Bob Argyle) writes:
>
>
>Using Microsoft C, for a PCclone, I want to program the 8259
>interrupt controller (ports 0x20 and 0x21) so that COM1
>generates an interrupt (Int 0x0C) when the receive buffer is
>full.  When setting up the interrupt mask, I want to read
>the previous mask so I can leave it in the same state when
>the application is done. ...
>...Any pointers on this?  How do I put in a
>return-from-interrupt in C?  

You asked for information on how to program an 8259a for masks etc.. here is
your answer. I have written some stuff for the pc's com port so I hope this
helps. First, I assume that you have no problem with programming the 8250.
Second, I assume that MSC has a way to write/read I/O ports, in Turbo C 1.5
the commands I use are   void outportb(int portid,char data) and 
char inportb(int portid).

To read the Interrupt Mask Register (IMR) do a read from port 0x21. (one
byte only!). As the Com port (for com 1) interrupts on IRQ4 you want to
clear bit 4 of the IMR, a bit-wise and with 0xef works just fine. write
the results back out to 0x21. To signal EOI write 0x20 to port 0x20. This
is the Nonspecific EOI, if you want to do a specific send 0x64 (for IRQ4).
That's all there is to it. I got this information from the Intel lit.

As for the return-from-interrupt, I don't know how MSC handles the writing
of interrupt routines, but Turbo C provides the following mech.:
interrupt <Function declaration>, this provides for saving of all registers,
restoreing them afterword, and issuing an IRET. If worst comes to worst you
could have the ISR entry be in assembly, save the registers there, call
your C routine to do the work, return to assembly, restore registers and 
issue IRET. Hope this helps.


-----------------------------------------------------------------------------
"Life is full of little suprises." -- Pandora  (as quoted by Robert Asprin)
UUCP:   {ucbvax!ucdavis,ucsd,ucivax}!ucrmath!hope!baumann
				or !ucrmath!jinx!baumann



More information about the Comp.lang.c mailing list