
13.1.1 Setting the IPL and Obtaining the Simple Lock
The following code shows how the el_intr( ) routine sets the CPU’s IPL and obtains the simple lock:
static int el_intr(int unit)
{
1
register u_int s; volatile u_int status;
register struct el_softc *sc = el_softc[unit]; register struct ifnet *ifp =
if (el_card_out(sc)) return (INTR_NOT_SERVICED);
2
s = splimp(); 3
4
1
2
3
4
Declares an argument that specifies the unit number of the network interface that generated the interrupt.
Determines whether the card is still in the socket. If the card is no longer in the socket, then returns the constant INTR_NOT_SERVICED to the kernel interrupt dispatcher.
Calls the splimp( ) routine to mask all Ethernet hardware interrupts.
Calls the simple_lock( ) routine to assert a lock with exclusive access for the resource that is associated with el_softc_lock.
13.1.2 Rearming the Next Timeout
The following code shows how the el_intr( ) routine rearms the next timeout:
if
timeout((void *)el_intr, (void *)unit, (1*hz)/el_pollint); 2
1
2
Determines whether polling was started by testing the polling_flag flag member in the el_softc data structure for this device.
If the polling process was started, calls the timeout( ) routine to rearm the next timeout. The timeout( ) routine is called with the following arguments:
•A pointer to the el_intr( ) routine, the if_el device driver’s interrupt handler.
•The unit variable, which contains the controller number for this device. This argument is passed to the el_intr( ) routine.
•The el_pollint variable, which specifies the amount of time to delay before calling the el_intr( ) routine.