Compaq AA-RNG2A-TE manual Implementing the Initialization Section, Implementing the elinit Routine

Models: AA-RNG2A-TE

1 159
Download 159 pages 42.56 Kb
Page 101
Image 101

8

Implementing the Initialization Section

The initialization section prepares the network interface to transmit and receive data packets. It can also allocate mbuf data structures for the receive ring.

The if_el device driver implements the following routines in its initialization section:

el_init (Section 8.1)

el_init_locked (Section 8.2)

8.1Implementing the el_init Routine

The el_init( ) routine is a jacket routine that performs the following tasks:

Determines whether the PCMCIA card is in the slot (Section 8.1.2)

Sets the IPL and obtains the simple lock (Section 8.1.3)

Calls the el_init_locked( ) routine to perform the initialization (Section 8.1.4)

Releases the simple lock and resets the IPL (Section 8.1.5)

Returns the status from el_init_locked( ) (Section 8.1.6)

8.1.1Setting Up the el_init Routine

The following code shows how to set up the el_init( ) routine:

static int el_init(int unit) 1

{

register struct el_softc *sc = el_softc[unit]; register struct ifnet *ifp = &sc->is_if; 3 int i, s; 4

2

1

2

Specifies the unit number of the network interface as the only argument to el_init( ).

Declares a pointer to the el_softc data structure called sc and initializes it to the el_softc data structure for this device. The controller number (which is stored in the unit variable) is used as an index into the array of el_softc data structures to determine which el_softc data structure is for this device.

Implementing the Initialization Section 8–1

Page 101
Image 101
Compaq AA-RNG2A-TE Implementing the Initialization Section, Implementing the elinit Routine, Setting Up the elinit Routine