Compaq AA-RNG2A-TE Network Card User Manual


 
5.1.14 Registering the shutdown Routine
The following code shows how the el_probe( ) routine registers its
shutdown( ) routine. The kernel calls this routine when the system shuts
down. The driver can specify an argument for the kernel to pass to the
routine at that time.
if (!sc->reprobe)
drvr_register_shutdown(el_shutdown, (void*)sc, DRVR_REGISTER);
1
return(~0);
}
1 Registers the shutdown( ) routine and directs the kernel to pass
a pointer to the drivers softc data structure to the routine. The
shutdown( ) routine is important for those devices that perform
DMA-related operations.
5.2 Implementing the el_shutdown Routine
The drivers shutdown( ) routine shuts down the controller. The kernel
calls all registered shutdown( ) routines when the system shuts down.
The el_probe( ) routine registers a shutdown( ) routine called
el_shutdown( ). The if_el device driver implements the routine as
follows:
static void el_shutdown(struct el_softc *sc)
1
{
WRITE_CMD(sc, CMD_RESET);
2
DELAY(1000); 3
}
1 Specifies the argument that the kernel passes to the routine, which is a
pointer to the drivers el_softc data structure. The driver specifies
this argument when it registers the shutdown( ) routine in its probe
interface.
2 Calls the WRITE_CMD macro to write data to the command port register.
In this call, the el_softc data structure for this 3Com 3C5x9 device
contains the I/O handle to reference the devices command register. The
data to be written is the CMD_RESET bit, which resets the device.
3 Calls the DELAY macro to delay the execution of el_shutdown( ) for 1
millisecond before continuing execution. This gives the reset command
time to complete.
5.3 Implementing the el_autosense_thread Routine
The if_el device driver implements a driver-specific routine called
el_autosense_thread( ) to determine the mode of the network interface.
The el_probe( ) routine calls el_autosense_thread( ) during device
autoconfiguration.
Implementing the Autoconfiguration Support Section (probe) 517