Texas Instruments TNETE100A Network Card User Manual


 
Loading and Unloading an Interrupt Service Routine (ISR)
4-2
4.1 Loading and Unloading an Interrupt Service Routine (ISR)
Before the ThunderLAN controller can be allowed to generate an interrupt to
the host, it is necessary to install code for the host to handle the interrupt. The
driver also relies on other host services that are interrupt-driven, like getting
notice of timer ticks for deadman timers. The driver calculates the pattern to
write to the interrupt controller to acknowledge the interrupt from the controller,
based on the actual hardware interrupt line assigned to the NIC’s slot.
This sample program hooks into the software vector table. The host PC timer
interrupt comes first, so that the program can time out operations that can hang
the PC and can also provide time stamp information for operations.
nic.OldTimer = HwSetIntVector((BYTE)0x1C, TimerIsr);
The driver points to the next code to execute when the timer interrupt goes off
and saves the value for program restart. nic.OldTimer is a storage place for this
information reserved in a routine called NICEVN, which is allocated for each
NIC; this instance is called nic. HwSetIntVector is a function that inserts the
address of a function into the interrupt table at a particular location:
// HwSetIntVector() – Set PC interrupt vector and return
previous one
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Parameters:
// bIRQ BYTE Irq to set
// lpFunc void (ISR *)() interrupt function
//
// Return val:
// void (ISR *)() Returns previous contents of vector
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––
static void (ISR *HwSetIntVector( BYTE bIRQ, void (ISR
*lpFunc)() ))()
{
BYTE bINT;
void (ISR *lpOld)();
if( bIRQ < 8 )
bINT = 8 + bIRQ ;
else if (bIRQ < 15)
bINT = (0x70–8) + bIRQ;
else
bINT = bIRQ;
lpOld = _dos_getvect( bINT );
_dos_setvect( bINT,lpFunc);
return( lpOld );
}