[comp.sys.amiga.tech] Parallel port interrupt server

phil@eos.UUCP (Phil Stone) (04/30/88)

Restatememt of original question:
	I have built a UART interface for the parallel port so as to be
	able to run RS232 *and* MIDI concurrently.  The UART will send
	interrupts on the FLAG input of the 8520 when it needs
	data or has received data.  How do I distinguish a FLAG interrupt
	from all the other interrupts (timers, PC handshaking, etc.) that
	come from the parallel port?

[ I didn't state this very clearly the first time, sorry ]

I know the kernal must have some way of distinguishing between the different
irq sources, unless the *entire* irq server chain is looking at *every* (timer
event, PC, FLAG, etc.) possible source of irq on the 8520.  This doesn't seem
very efficient to me.  So my original question, once I have added an
interrupt server to the PORTS chain, how do I tell if the FLAG bit was the
cause of the interrupt? (The interrupt register cannot be read directly, as
this action automatically clears it).

[ Thanks for trying to wade through my first garbled attempt at expressing
this problem, Matt. ]

dillon@CORY.BERKELEY.EDU (Matt Dillon) (04/30/88)

>interrupt server to the PORTS chain, how do I tell if the FLAG bit was the
>cause of the interrupt? (The interrupt register cannot be read directly, as
>this action automatically clears it).

	Ahh, now I understand.  I'm not by my Amiga (or manuals) at the
moment, but the proper way to catch CIA(A or B) interrupts is to open the
appropriate resource, which contains function vectors to add and remove
specific CIA interrupts.  You do *not* manually add your server to the
68000 interrupt chain as I said earlier (my mistake).

				-Matt

dillon@CORY.BERKELEY.EDU (Matt Dillon) (04/30/88)

	Ok, found my manuals.  Here is an overview (read the manual pages
for more info):

	(1) OpenResource() the "misc.resource" 
	(2) Call AllocMiscResource() for the MR_PARALLELPORT and 
	    MR_PARALLELBITS to ensure nobody else is using them.
	(3) OpenResource() the "ciaa.resource" to get access to the interrupt
	    bits.
	(4) AddICRVector() the FLAG interrupt to your interrupt server

		(stuff)

	(5) RemICRVector() the FLAG interrupt
	(6) FreeMiscResource() MR_PARALLELPORT and MR_PARALLELBITS



	AddICRVector()	offset -6  from cia?.resource base
	RemICRVector()  offset -12 from cia?.resource base
	AbleICR()	offset -18 from cia?.resource base
	SetICR()	offset -24 from cia?.resource base

	AllocMiscResource()	offset -6  from misc.resource base
	FreeMiscResource()	offset -12 from misc.resource base

	See <resources/misc.h>, AUTODOCS: misc.doc, cia.doc

	The interrupt is automatically enabled on AddICRVector() and disabled 
	on RemICRVector().  And, of course, AddICRVector() fails if the
	interrupt is already allocated.

					-Matt