Compaq AA-RNG2A-TE Setting a Timer for the Current Kernel Thread, Testing for Loss of Carrier

Models: AA-RNG2A-TE

1 159
Download 159 pages 42.56 Kb
Page 81
Image 81

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) && 1 (prev_tmo == sc->xmit_tmo) && (wait++ < 4)) {

assert_wait((vm_offset_t)&wait_flag, TRUE); thread_set_timeout(1*hz); 2 thread_block();

}

1

2

Waits until the transmit makes it out, a timeout occurs, or 4 seconds pass.

Sets the timer and puts the current thread to sleep. To use a timer, 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; 1 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", ifp->if_unit, lan_media_strings_10[sc->lm_media]);

}

WRITE_CMD(sc, CMD_STATSENA);

Implementing the Autoconfiguration Support Section (probe) 5–23

Page 81
Image 81
Compaq AA-RNG2A-TE manual Setting a Timer for the Current Kernel Thread, Testing for Loss of Carrier