•
Determines whether packets were transmitted successfully
(Section 5.3.14)
•
Prints debug information (Section 5.3.15)
•
Sets up new media to try if transmit was unsuccessful (Section 5.3.16)
•
Establishes media if transmit was successful (Section 5.3.17)
5.3.1 Setting Up the el_autosense_thread Routine
The following code shows how to set up the
el_autosense_thread( )
routine:
unsigned char el_junk_msg[] = {
1
0xaa, 0x00, 0x04, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x60, 0x06,
’t’, ’h’, ’i’, ’s’, ’ ’, ’i’, ’s’, ’ ’, ’a’, ’ ’, ’j’, ’u’, ’n’, ’k’,
’ ’, ’a’, ’u’, ’t’, ’o’, ’s’, ’e’, ’n’, ’s’, ’e’, ’ ’, ’m’,
’e’, ’s’, ’s’, ’a’, ’g’, ’e’, ’.’
};
#define EL_JUNK_SIZE 46
#define EL_AUTOSENSE_PASSES 3*10
static void el_autosense_thread(struct el_softc *sc)
2
{
struct ifnet *ifp = &sc->is_if;
3
unsigned long prev_tint, prev_tmo, prev_err;
struct mbuf *m;
int good_xmits, wait, s, i, link_beat, passes;
unsigned long wait_flag=0;
1
Defines the message to transmit when trying to determine the mode of
the device.
2
Declares a pointer to the
el_softc
data structure and calls it
sc
.
3
Declares a pointer to an
ifnet
data structure and calls it
ifp
. This line
also initializes
ifp
to the address of the
ifnet
data structure for this
3Com 3C5x9 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 and is actually the instance of the
ifnet
data structure for
this 3Com 3C5x9 device.
5.3.2 Blocking Until Awakened
The following code shows how the
el_autosense_thread( )
routine blocks
until awakened:
while(1) {
assert_wait((vm_offset_t)&sc->autosense_flag, TRUE);
1
thread_block();
1
Waits for some process to indicate when to proceed with the autosense
test.
Implementing the Autoconfiguration Support Section (probe) 5–19