Xref: utzoo comp.sys.ibm.pc:15992 comp.lang.c:10475 Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!umd5!purdue!decwrl!hplabs!hp-sdd!ucsdhub!ucrmath!hope!baumann From: baumann@hope.UUCP (Michael Baumann) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: The 8259 interrupt controller (HELP!) Keywords: interrupt, C Message-ID: <280@ucrmath.UUCP> Date: 28 May 88 02:32:57 GMT References: <531@wsccs.UUCP> Sender: news@ucrmath.UUCP Reply-To: baumann@hope.UUCP (Michael Baumann) Organization: University of California, Riverside Lines: 38 In article <531@wsccs.UUCP> rargyle@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 , 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