Interrupt Service Procedures
K
A
DAK
53
Conforming ISP Construction
The construction of an Interrupt Service Procedure (ISP) to service an external interrupt
is a simple process.
The conforming ISP consists of two parts: the ISP root and your Interrupt Handler. The
ISP root is a code fragment most easily created using procedure ajispm.
The Interrupt Handler can be written in as a Large or Medium model C function
without formal parameters. If the C function makes any calls to AMX, restrictions for
ISPs must be obeyed. The following example of a device Interrupt Handler illustrates
how little application code must be programmed to satisfy AMX.
If the processor Interrupt Vector Table (IVT) is in RAM and AMX was launched with
vector access allowed, you can install the pointer to the ISP root into the IVT using AMX
function ajivtw. Otherwise, you must initialize the device's entry in the IVT as
described in Chapter 4.8 before launching AMX. The following example assumes that
the device interrupts through vector number 32.
#include "amx831cf.h" /* AMX C Interface Header */
static struct amxisps isproot; /* ISP root */
void cdecl dvcisp(void)
{local variables, if required
:
Perform all device service.
Interrupts may be enabled using ajei() if nested interrupts
are supported by your design.
:
/* If necessary, disable interrupts and clear the request in */
/* one or more interrupt controllers (such as the Intel 8259). */
ajdi(); /* Disable interrupts */
ajoutb(0x20, 0x20); /* Non-specific EOI */
}
void cdecl rrproc(void) /* Restart Procedure */
{ajispm(dvcisp, &isproot); /* Make ISP root */
ajivtw(32, (void (*)())&isproot); /* Install ISP in IVT */
}
The ISP root created by AMX in static variable isproot is an ISP coded as follows:
ISPROOT LABEL FAR
CALL AAINT ;begin interrupt service
CALL DVCISP ;ISP
CALL AAINX ;end interrupt service
IRET ;end of interrupt