Compaq AA-RNG2A-TE Network Card User Manual


 
3 Declares a pointer to an ifnet data structure called ifp and initializes
it to the address of the ifnet data structure for this device. The
ifnet data structure is referenced through the is_if member of the
el_softc data structure pointer. The is_if name is an alternate
name for the ac_if member of the arpcom data structure. The ac_if
member is referred to as the network-visible interface.
4 Declares the i and s variables. The i variable stores the value that
el_init_locked( ) returns. The s variable stores the value that
splimp( ) returns.
8.1.2 Determining Whether the PCMCIA Card Is Present
The following code shows how the el_init( ) routine determines whether
the PCMCIA card is still present in the system.
if (sc->cardout) return(EIO); 1
1 If the user has removed the PCMCIA card from the slot, returns the
error code EIO to the el_attach( ) routine. The el_card_remove( )
routine sets the cardout member.
8.1.3 Setting the IPL and Obtaining the Simple Lock
All network device drivers must set the interrupt priority level (IPL) to
mask all LAN hardware interrupts. Raising the IPL protects the driver from
interrupts on the same CPU. Only network device drivers that operate on
multiple CPUs need to obtain a simple lock. The simple lock mechanism
protects resources in a symmetric multiprocessing environment.
The following code shows how the el_init( ) routine sets the IPL and
obtains the simple lock:
s = splimp();
1
simple_lock(&sc->el_softc_lock); 2
1 Calls the splimp( ) routine to mask all LAN hardware interrupts.
Upon successful completion, splimp( ) stores an integer value in the
s variable. This value represents the CPU priority level that existed
before the call to splimp( ).
2 Calls the simple_lock( ) routine to assert a lock with exclusive
access for the resource that is associated with the el_softc_lock
data structure. This means that no other kernel thread can gain access
to the locked resource until you call simple_unlock( ) to release it.
Because simple locks are spin locks, simple_lock( ) does not return
until the lock has been obtained.
82 Implementing the Initialization Section