FreeBSD/sys/dev/wl/if_wl.c
/*
 * wlprobe:
 *
 *	This function "probes" or checks for the WaveLAN board on the bus to
 *	see if it is there.  As far as I can tell, the best break between this
 *	routine and the attach code is to simply determine whether the board
 *	is configured in properly.  Currently my approach to this is to write
 *	and read a word from the SRAM on the board being probed.  If the word
 *	comes back properly then we assume the board is there.  The config
 *	code expects to see a successful return from the probe routine before
 *	attach will be called.
 *
 * input	: address device is mapped to, and unit # being checked
 * output	: a '1' is returned if the board exists, and a 0 otherwise
 *
 */
This function "probes" or checks for the WaveLAN board on the bus to
see if it is there.  As far as I can tell, the best break between this
routine and the attach code is to simply determine whether the board
is configured in properly.  Currently my approach to this is to write
and read a word from the SRAM on the board being probed.  If the word
comes back properly then we assume the board is there.  The config
code expects to see a successful return from the probe routine before
attach will be called.

input        : address device is mapped to, and unit # being checked
output       : a '1' is returned if the board exists, and a 0 otherwise
This function " probes " or checks for the WaveLAN board on the bus to see if it is there . As far as I can tell the best break between this routine and the attach code is to simply determine whether the board is configured in properly . Currently my approach to this is to write and read a word from the SRAM on the board being probed . If the word comes back properly then we assume the board is there . The config code expects to see a successful return from the probe routine before attach will be called . input : address device is mapped to and unit # being checked output : a ' 1 ' is returned if the board exists and a 0 otherwise
static int
wlprobe(device_t device)
{
    struct wl_softc	*sc;
    char		*str = "wl%d: board out of range [0..%d]\n";
    u_char		inbuf[100];
    rman_res_t		junk, sirq;
    int			error, irq;
    error = ISA_PNP_PROBE(device_get_parent(device), device, wl_ids);
    if (error == ENXIO || error == 0)
	return (error);
    sc = device_get_softc(device);
    error = wl_allocate_resources(device);
    if (error)
	goto errexit;
#define PCMD(sc, hacr) WL_WRITE_2((sc), HACR, (hacr))
    PCMD(sc, HACR_RESET);			
    DELAY(DELAYCONST);				
    PCMD(sc, HACR_RESET);			
    DELAY(DELAYCONST);	                	
    PCMD(sc, HACR_DEFAULT);
    PCMD(sc, HACR_DEFAULT);
    WL_WRITE_2(sc, PIOR1, 0);			
    WL_WRITE_MULTI_2(sc, PIOP1, str, strlen(str)/2+1);	
    WL_WRITE_2(sc, PIOR1, 0);			
    WL_READ_MULTI_2(sc, PIOP1, inbuf, strlen(str)/2+1);	
    if (bcmp(str, inbuf, strlen(str))) {
	error = ENXIO;
	goto errexit;
    }
    sc->chan24 = 0;                             
    sc->freq24 = 0;                             
    wlgetpsa(sc, inbuf);
    for (irq = 15; irq >= 0; irq--)
	if (irqvals[irq] == inbuf[WLPSA_IRQNO])
	    break;
    if ((irq == 0) || (irqvals[irq] == 0)){
	device_printf(device, "PSA corrupt (invalid IRQ value)\n");
    } else {
	if (bus_get_resource(device, SYS_RES_IRQ, 0, &sirq, &junk))
	    goto errexit;
	if (irq != (int)sirq)
	    device_printf(device, "board is configured for interrupt %d\n",
		irq);
    }
    wl_deallocate_resources(device);
    return (0);
errexit:
    wl_deallocate_resources(device);
    return (error);
}
static int wlprobe ( device_t device ) { struct wl_softc * sc ; char * str = " \n " ; u_char inbuf [ 100 ] ; rman_res_t junk , sirq ; int error , irq ; error = ISA_PNP_PROBE ( device_get_parent ( device ) , device , wl_ids ) ; if ( error == ENXIO || error == 0 ) return ( error ) ; sc = device_get_softc ( device ) ; error = wl_allocate_resources ( device ) ; if ( error ) goto errexit ; #define PCMD ( sc , hacr )  WL_WRITE_2((sc), HACR, (hacr)) PCMD ( sc , HACR_RESET ) ; DELAY ( DELAYCONST ) ; PCMD ( sc , HACR_RESET ) ; DELAY ( DELAYCONST ) ; PCMD ( sc , HACR_DEFAULT ) ; PCMD ( sc , HACR_DEFAULT ) ; WL_WRITE_2 ( sc , PIOR1 , 0 ) ; WL_WRITE_MULTI_2 ( sc , PIOP1 , str , strlen ( str ) / 2 + 1 ) ; WL_WRITE_2 ( sc , PIOR1 , 0 ) ; WL_READ_MULTI_2 ( sc , PIOP1 , inbuf , strlen ( str ) / 2 + 1 ) ; if ( bcmp ( str , inbuf , strlen ( str ) ) ) { error = ENXIO ; goto errexit ; } sc -> chan24 = 0 ; sc -> freq24 = 0 ; wlgetpsa ( sc , inbuf ) ; for ( irq = 15 ; irq >= 0 ; irq -- ) if ( irqvals [ irq ] == inbuf [ WLPSA_IRQNO ] ) break ; if ( ( irq == 0 ) || ( irqvals [ irq ] == 0 ) ) { device_printf ( device , " \n " ) ; } else { if ( bus_get_resource ( device , SYS_RES_IRQ , 0 , & sirq , & junk ) ) goto errexit ; if ( irq != ( int ) sirq ) device_printf ( device , " \n " , irq ) ; } wl_deallocate_resources ( device ) ; return ( 0 ) ; errexit : wl_deallocate_resources ( device ) ; return ( error ) ; }
wlprobe:
      This function "probes" or checks for the WaveLAN board on the bus to
      see if it is there.
wlprobe : This function " probes " or checks for the WaveLAN board on the bus to see if it is there .
/* TBD. not true.
     * regular CMD() will not work, since no softc yet 
     */ /* reset the board */ /* >> 4 clocks at 6MHz */ /* reset the board */ /* >> 4 clocks at 6MHz */ /* clear reset command and set PIO#1 in autoincrement mode */ /* go to beginning of RAM */ /* write string */ /* rewind */ /* read result */ /* 2.4 Gz: config channel */ /* 2.4 Gz: frequency    */ /* read the PSA from the board into temporary storage */ /* We read the IRQ value from the PSA on the board. */ /*
	 * If the IRQ requested by the PSA is already claimed by another
	 * device, the board won't work, but the user can still access the
	 * driver to change the IRQ.
	 */