6
Implementing the Autoconfiguration
Support Section (attach)
The autoconfiguration support section implements a network device driver’s
attach
interface. A network device driver’s
attach
interface establishes
communication with the device. The interface initializes the pointer to the
ifnet
data structure and attaches the network interface to the packet filter.
The bus configuration code calls the driver’s
attach
interface.
The
if_el
device driver implements an
attach( )
routine called
el_attach( )
. The
el_attach( )
routine performs the following tasks:
•
Initializes the media address and media header lengths (Section 6.2)
•
Sets up the media (Section 6.3)
•
Initializes simple lock information (Section 6.4)
•
Prints a success message (Section 6.5)
•
Specifies the network driver interfaces (Section 6.6)
•
Sets the baud rate (Section 6.7)
•
Attaches to the packet filter and the network layer (Section 6.8)
•
Sets network attributes and registers the adapter (Section 6.9)
•
Handles reinsertion operations (Section 6.10)
•
Enables the interrupt handler (Section 6.11)
•
Starts the polling process (Section 6.12)
6.1 Setting Up the el_attach Routine
The following code shows how to set up the
el_attach( )
routine:
static int el_attach(struct controller *ctlr)
1
{
register int unit = ctlr->ctlr_num;
2
register struct el_softc *sc = el_softc[unit];
3
register struct ifnet *ifp = &sc->is_if;
4
register struct sockaddr_in *sin;
5
1
Declares as an argument a pointer to a
controller
data structure
for this controller. This data structure contains such information
as the controller type, the controller name, and the current status
Implementing the Autoconfiguration Support Section (attach) 6–1