sys/dev/netif/ar/if_ar_isa.c
static int
ar_isa_attach(device_t device)
{
	u_int tmp;
	u_long irq, junk;
	struct ar_hardc *hc;

	hc = (struct ar_hardc *)device_get_softc(device);
	if(ar_allocate_ioport(device, 0, ARC_IO_SIZ))
		return (ENXIO);

	tmp = ar_inb(hc, AR_BMI);
	hc->bustype = tmp & AR_BUS_MSK;
	hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
	hc->memsize = 1 << hc->memsize;
	hc->memsize <<= 16;
	hc->interface[0] = (tmp & AR_IFACE_MSK);
	hc->interface[1] = hc->interface[0];
	hc->interface[2] = hc->interface[0];
	hc->interface[3] = hc->interface[0];
	tmp = ar_inb(hc, AR_REV);
	hc->revision = tmp & AR_REV_MSK;
	hc->winsize = 1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT);
	hc->winsize *= ARC_WIN_SIZ;
	hc->winmsk = hc->winsize - 1;
	hc->numports = ar_inb(hc, AR_PNUM);
	hc->handshake = ar_inb(hc, AR_HNDSH);

	if(ar_allocate_memory(device, 0, hc->winsize))
		return (ENXIO);

	hc->mem_start = rman_get_virtual(hc->res_memory);
	hc->mem_end = hc->mem_start + hc->winsize;
	hc->cunit = device_get_unit(device);

	switch(hc->interface[0]) {
	case AR_IFACE_EIA_232:
		kprintf("ar%d: The EIA 232 interface is not supported.\n",
			hc->cunit);
		ar_deallocate_resources(device);
		return (ENXIO);
	case AR_IFACE_V_35:
		break;
	case AR_IFACE_EIA_530:
		kprintf("ar%d: WARNING: The EIA 530 interface is untested.\n",
			hc->cunit);
		break;
	case AR_IFACE_X_21:
		break;
	case AR_IFACE_COMBO:
		kprintf("ar%d: WARNING: The COMBO interface is untested.\n",
			hc->cunit);
		break;
	}

	/*
	 * Do a little sanity check.
	 */
	if((hc->numports > NPORT) || (hc->memsize > (512*1024))) {
		ar_deallocate_resources(device);
		return (ENXIO);
	}

	if(ar_allocate_irq(device, 0, 1))
		return (ENXIO);

	if(bus_get_resource(device, SYS_RES_IRQ, 0, &irq, &junk)) {
		ar_deallocate_resources(device);
		return (ENXIO);
	}
	hc->isa_irq = irq;

	if(ar_attach(device)) {
		ar_deallocate_resources(device);
		return (ENXIO);
	}

	return (0);
}
/*
 * Malloc memory for the softc structures.
 * Reset the card to put it in a known state.
 * Register the ports on the adapter.
 * Fill in the info for each port.
 * Attach each port to sppp and bpf.
 */
Malloc memory for the softc structures.
Reset the card to put it in a known state.
Register the ports on the adapter.
Fill in the info for each port.
Attach each port to sppp and bpf.
Malloc memory for the softc structures . Reset the card to put it in a known state . Register the ports on the adapter . Fill in the info for each port . Attach each port to sppp and bpf .
static int
ar_isa_attach(device_t device)
{
	u_int tmp;
	u_long irq, junk;
	struct ar_hardc *hc;
	hc = (struct ar_hardc *)device_get_softc(device);
	if(ar_allocate_ioport(device, 0, ARC_IO_SIZ))
		return (ENXIO);
	tmp = ar_inb(hc, AR_BMI);
	hc->bustype = tmp & AR_BUS_MSK;
	hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
	hc->memsize = 1 << hc->memsize;
	hc->memsize <<= 16;
	hc->interface[0] = (tmp & AR_IFACE_MSK);
	hc->interface[1] = hc->interface[0];
	hc->interface[2] = hc->interface[0];
	hc->interface[3] = hc->interface[0];
	tmp = ar_inb(hc, AR_REV);
	hc->revision = tmp & AR_REV_MSK;
	hc->winsize = 1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT);
	hc->winsize *= ARC_WIN_SIZ;
	hc->winmsk = hc->winsize - 1;
	hc->numports = ar_inb(hc, AR_PNUM);
	hc->handshake = ar_inb(hc, AR_HNDSH);
	if(ar_allocate_memory(device, 0, hc->winsize))
		return (ENXIO);
	hc->mem_start = rman_get_virtual(hc->res_memory);
	hc->mem_end = hc->mem_start + hc->winsize;
	hc->cunit = device_get_unit(device);
	switch(hc->interface[0]) {
	case AR_IFACE_EIA_232:
		kprintf("ar%d: The EIA 232 interface is not supported.\n",
			hc->cunit);
		ar_deallocate_resources(device);
		return (ENXIO);
	case AR_IFACE_V_35:
		break;
	case AR_IFACE_EIA_530:
		kprintf("ar%d: WARNING: The EIA 530 interface is untested.\n",
			hc->cunit);
		break;
	case AR_IFACE_X_21:
		break;
	case AR_IFACE_COMBO:
		kprintf("ar%d: WARNING: The COMBO interface is untested.\n",
			hc->cunit);
		break;
	}
	if((hc->numports > NPORT) || (hc->memsize > (512*1024))) {
		ar_deallocate_resources(device);
		return (ENXIO);
	}
	if(ar_allocate_irq(device, 0, 1))
		return (ENXIO);
	if(bus_get_resource(device, SYS_RES_IRQ, 0, &irq, &junk)) {
		ar_deallocate_resources(device);
		return (ENXIO);
	}
	hc->isa_irq = irq;
	if(ar_attach(device)) {
		ar_deallocate_resources(device);
		return (ENXIO);
	}
	return (0);
}
static int ar_isa_attach ( device_t device ) { u_int tmp ; u_long irq , junk ; struct ar_hardc * hc ; hc = ( struct ar_hardc * ) device_get_softc ( device ) ; if ( ar_allocate_ioport ( device , 0 , ARC_IO_SIZ ) ) return ( ENXIO ) ; tmp = ar_inb ( hc , AR_BMI ) ; hc -> bustype = tmp & AR_BUS_MSK ; hc -> memsize = ( tmp & AR_MEM_MSK ) >> AR_MEM_SHFT ; hc -> memsize = 1 << hc -> memsize ; hc -> memsize <<= 16 ; hc -> interface [ 0 ] = ( tmp & AR_IFACE_MSK ) ; hc -> interface [ 1 ] = hc -> interface [ 0 ] ; hc -> interface [ 2 ] = hc -> interface [ 0 ] ; hc -> interface [ 3 ] = hc -> interface [ 0 ] ; tmp = ar_inb ( hc , AR_REV ) ; hc -> revision = tmp & AR_REV_MSK ; hc -> winsize = 1 << ( ( tmp & AR_WSIZ_MSK ) >> AR_WSIZ_SHFT ) ; hc -> winsize *= ARC_WIN_SIZ ; hc -> winmsk = hc -> winsize - 1 ; hc -> numports = ar_inb ( hc , AR_PNUM ) ; hc -> handshake = ar_inb ( hc , AR_HNDSH ) ; if ( ar_allocate_memory ( device , 0 , hc -> winsize ) ) return ( ENXIO ) ; hc -> mem_start = rman_get_virtual ( hc -> res_memory ) ; hc -> mem_end = hc -> mem_start + hc -> winsize ; hc -> cunit = device_get_unit ( device ) ; switch ( hc -> interface [ 0 ] ) { case AR_IFACE_EIA_232 : kprintf ( " \n " , hc -> cunit ) ; ar_deallocate_resources ( device ) ; return ( ENXIO ) ; case AR_IFACE_V_35 : break ; case AR_IFACE_EIA_530 : kprintf ( " \n " , hc -> cunit ) ; break ; case AR_IFACE_X_21 : break ; case AR_IFACE_COMBO : kprintf ( " \n " , hc -> cunit ) ; break ; } if ( ( hc -> numports > NPORT ) || ( hc -> memsize > ( 512 * 1024 ) ) ) { ar_deallocate_resources ( device ) ; return ( ENXIO ) ; } if ( ar_allocate_irq ( device , 0 , 1 ) ) return ( ENXIO ) ; if ( bus_get_resource ( device , SYS_RES_IRQ , 0 , & irq , & junk ) ) { ar_deallocate_resources ( device ) ; return ( ENXIO ) ; } hc -> isa_irq = irq ; if ( ar_attach ( device ) ) { ar_deallocate_resources ( device ) ; return ( ENXIO ) ; } return ( 0 ) ; }
Malloc memory for the softc structures.
Malloc memory for the softc structures .
/*
	 * Do a little sanity check.
	 */