예제 #1
0
파일: if_ex_isa.c 프로젝트: MarginC/kame
static int
ex_isa_attach(device_t dev)
{
    struct ex_softc *	sc = device_get_softc(dev);
    int			error = 0;
    u_int16_t		temp;

    sc->dev = dev;
    sc->ioport_rid = 0;
    sc->irq_rid = 0;

    if ((error = ex_alloc_resources(dev)) != 0) {
        device_printf(dev, "ex_alloc_resources() failed!\n");
        goto bad;
    }

    /*
     * Fill in several fields of the softc structure:
     *	- I/O base address.
     *	- Hardware Ethernet address.
     *	- IRQ number (if not supplied in config file, read it from EEPROM).
     *	- Connector type.
     */
    sc->iobase = rman_get_start(sc->ioport);
    sc->irq_no = rman_get_start(sc->irq);

    ex_get_address(sc->iobase, sc->arpcom.ac_enaddr);

    temp = eeprom_read(sc->iobase, EE_W0);
    device_printf(sc->dev, "%s config, %s bus, ",
                  (temp & EE_W0_PNP) ? "PnP" : "Manual",
                  (temp & EE_W0_BUS16) ? "16-bit" : "8-bit");

    temp = eeprom_read(sc->iobase, EE_W6);
    printf("board id 0x%03x, stepping 0x%01x\n",
           (temp & EE_W6_BOARD_MASK) >> EE_W6_BOARD_SHIFT,
           temp & EE_W6_STEP_MASK);

    if ((error = ex_attach(dev)) != 0) {
        device_printf(dev, "ex_attach() failed!\n");
        goto bad;
    }

    error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
                           ex_intr, (void *)sc, &sc->ih);
    if (error) {
        device_printf(dev, "bus_setup_intr() failed!\n");
        goto bad;
    }

    return(0);
bad:
    ex_release_resources(dev);
    return (error);
}
예제 #2
0
static int
ex_pccard_attach(device_t dev)
{
	struct ex_softc *	sc = device_get_softc(dev);
	struct ifnet *		ifp = &sc->arpcom.ac_if;
	int			error = 0;
	int			i;
	uint8_t			sum;
	const uint8_t	*	ether_addr;

	sc->dev = dev;
	sc->ioport_rid = 0;
	sc->irq_rid = 0;

	if ((error = ex_alloc_resources(dev)) != 0) {
		device_printf(dev, "ex_alloc_resources() failed!\n");
		goto bad;
	}

	/*
	 * Fill in several fields of the softc structure:
	 *	- I/O base address.
	 *	- Hardware Ethernet address.
	 *	- IRQ number.
	 */
	sc->iobase = rman_get_start(sc->ioport);
	sc->irq_no = rman_get_start(sc->irq);

	ether_addr = pccard_get_ether(dev);
	for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
		sum |= ether_addr[i];
	if (sum)
		bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);

	if ((error = ex_attach(dev)) != 0) {
		device_printf(dev, "ex_attach() failed!\n");
		goto bad;
	}

	error = bus_setup_intr(dev, sc->irq, INTR_MPSAFE,
				ex_intr, (void *)sc, &sc->ih, 
				ifp->if_serializer);
	if (error) {
		device_printf(dev, "bus_setup_intr() failed!\n");
		goto bad;
	}

	ifq_set_cpuid(&ifp->if_snd, rman_get_cpuid(sc->irq));

	return(0);
bad:
	ex_release_resources(dev);
	return (error);
}
예제 #3
0
static int
ex_pccard_attach(device_t dev)
{
	struct ex_softc *	sc = device_get_softc(dev);
	int			error = 0;
	int			i;
	u_char			sum;
	u_char			ether_addr[ETHER_ADDR_LEN];

	sc->dev = dev;
	sc->ioport_rid = 0;
	sc->irq_rid = 0;

	if ((error = ex_alloc_resources(dev)) != 0) {
		device_printf(dev, "ex_alloc_resources() failed!\n");
		goto bad;
	}

	/*
	 * Fill in several fields of the softc structure:
	 *	- I/O base address.
	 *	- Hardware Ethernet address.
	 *	- IRQ number.
	 */
	sc->iobase = rman_get_start(sc->ioport);
	sc->irq_no = rman_get_start(sc->irq);

	pccard_get_ether(dev, ether_addr);
	for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
		sum |= ether_addr[i];
	if (sum)
		bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);

	if ((error = ex_attach(dev)) != 0) {
		device_printf(dev, "ex_attach() failed!\n");
		goto bad;
	}

	error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
				ex_intr, (void *)sc, &sc->ih);
	if (error) {
		device_printf(dev, "bus_setup_intr() failed!\n");
		goto bad;
	}

	return(0);
bad:
	ex_release_resources(dev);
	return (error);
}
static int
ex_pccard_attach(device_t dev)
{
	struct ex_softc *	sc = device_get_softc(dev);
	int			error = 0;
	u_char			ether_addr[ETHER_ADDR_LEN];

	sc->dev = dev;
	sc->ioport_rid = 0;
	sc->irq_rid = 0;

	if ((error = ex_alloc_resources(dev)) != 0) {
		device_printf(dev, "ex_alloc_resources() failed!\n");
		goto bad;
	}

	/*
	 * Fill in several fields of the softc structure:
	 *	- Hardware Ethernet address.
	 *	- IRQ number.
	 */
	sc->irq_no = rman_get_start(sc->irq);

	/* Try to get the ethernet address from the chip, then the CIS */
	ex_get_address(sc, ether_addr);
	if (!ex_pccard_enet_ok(ether_addr))
		pccard_get_ether(dev, ether_addr);
	if (!ex_pccard_enet_ok(ether_addr))
		ex_pccard_get_silicom_mac(dev, ether_addr);
	if (!ex_pccard_enet_ok(ether_addr)) {
		device_printf(dev, "No NIC address found.\n");
		error = ENXIO;
		goto bad;
	}
	bcopy(ether_addr, sc->enaddr, ETHER_ADDR_LEN);

	if ((error = ex_attach(dev)) != 0) {
		device_printf(dev, "ex_attach() failed!\n");
		goto bad;
	}

	return(0);
bad:
	ex_release_resources(dev);
	return (error);
}