Setting A Timer For The Current Kernel Thread; Testing For Loss Of Carrier - Compaq Tru64 UNIX Installation Manual

Writing network device drivers
Table of Contents

Advertisement

5.3.12 Setting a Timer for the Current Kernel Thread

The following code shows how the el_autosense_thread( ) routine sets a
timer for the current kernel thread:
wait = 0;
while ((prev_tint == sc->tint) &&
(prev_tmo
(wait++ < 4)) {
assert_wait((vm_offset_t)&wait_flag, TRUE);
thread_set_timeout(1*hz);
thread_block();
}
Waits until the transmit makes it out, a timeout occurs, or 4 seconds
1
pass.
Sets the timer and puts the current thread to sleep. To use a timer,
2
thread_set_timeout( ) must be called between an assert_wait( )
and a thread_block( ).

5.3.13 Testing for Loss of Carrier

The following code shows how the el_autosense_thread( ) routine tests
for loss of carrier:
link_beat = 0;
switch (sc->lm_media) {
case LAN_MEDIA_UTP:
s = splimp();
simple_lock(&sc->el_softc_lock);
WRITE_CMD(sc, CMD_WINDOW4);
i = READ_MD(sc);
if ((i & MD_VLB) != 0)
link_beat=1;
WRITE_CMD(sc, CMD_WINDOW1);
simple_unlock(&sc->el_softc_lock);
splx(s);
case LAN_MEDIA_BNC:
case LAN_MEDIA_AUI:
s = splimp();
simple_lock(&sc->el_softc_lock);
WRITE_CMD(sc, CMD_WINDOW6);
WRITE_CMD(sc, CMD_STATSDIS);
i = READ_BUS_D8(sc->basereg);
if (i != 0) {
wait = 100;
if (sc->debug)
printf("el%d: autosense: %s carrier loss\n",
}
WRITE_CMD(sc, CMD_STATSENA);
1
== sc->xmit_tmo) &&
2
1
ifp->if_unit,
lan_media_strings_10[sc->lm_media]);
Implementing the Autoconfiguration Support Section (probe) 5–23

Advertisement

Table of Contents
loading

Table of Contents