if (sc->lm_media_mode == LAN_MODE_AUTOSENSE)
sc->lm_media = LAN_MEDIA_UTP;
break;
case LAN_MEDIA_BNC:
if (sc->lm_media_mode == LAN_MODE_AUTOSENSE)
sc->lm_media = LAN_MEDIA_AUI;
break;
case LAN_MEDIA_UTP:
default:
if (sc->lm_media_mode == LAN_MODE_AUTOSENSE)
sc->lm_media = LAN_MEDIA_BNC;
break;
}
el_reset(ifp->if_unit);
2
}
}
1 Selects new media.
2 Calls the el_reset( ) routine to reset the hardware. This reset will
establish the next media to try.
5.3.17 Establishing the Media
The following code shows how the el_autosense_thread( ) routine
establishes the new media:
}
if (sc->debug) {
if ((sc->lm_media == LAN_MEDIA_UTP) && !link_beat &&
(passes <= EL_AUTOSENSE_PASSES))
printf("el%d: No Link Beat signal\n", ifp->if_unit);
}
sc->lm_media_state = LAN_MEDIA_STATE_DETERMINED;
1
printf("el%d: Autosense selected %s media\n", ifp->if_unit,
lan_media_strings_10[sc->lm_media]);
s = splimp();
2
simple_lock(&sc->el_softc_lock); 3
WRITE_CMD(sc, CMD_STATSDIS); 4
simple_unlock(&sc->el_softc_lock); 5
splx(s); 6
}
}
1 Sets the lm_media_state member of the softc data structure to
LAN_MEDIA_STATE_DETERMINED. This indicates that the driver has
successfully selected a media mode.
2 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( ).
3 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.
Implementing the Autoconfiguration Support Section (probe) 5–25