Beispiel #1
0
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);
}
Beispiel #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);
}
Beispiel #3
0
static int
ex_pccard_detach(device_t dev)
{
	struct ex_softc		*sc = device_get_softc(dev);
	struct ifnet		*ifp = &sc->arpcom.ac_if;

	ex_stop(sc);
	ifp->if_flags &= ~IFF_RUNNING;
	if_detach(ifp);
	ex_release_resources(dev);
	return (0);
}
Beispiel #4
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);
}
Beispiel #5
0
static int
ex_pccard_detach(device_t dev)
{
	struct ex_softc		*sc = device_get_softc(dev);
	struct ifnet		*ifp = &sc->arpcom.ac_if;

	lwkt_serialize_enter(ifp->if_serializer);
	ex_stop(sc);
	ifp->if_flags &= ~IFF_RUNNING;
	lwkt_serialize_exit(ifp->if_serializer);

	ether_ifdetach(ifp);
	ex_release_resources(dev);
	return (0);
}
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);
}
Beispiel #7
0
int
ex_detach(device_t dev)
{
	struct ex_softc	*sc;
	struct ifnet	*ifp;

	sc = device_get_softc(dev);
	ifp = sc->ifp;

	EX_LOCK(sc);
        ex_stop(sc);
	EX_UNLOCK(sc);

	ether_ifdetach(ifp);
	callout_drain(&sc->timer);

	ex_release_resources(dev);
	mtx_destroy(&sc->lock);

	return (0);
}
Beispiel #8
0
static int
ex_isa_probe(device_t dev)
{
	bus_addr_t	iobase;
	u_int		irq;
	char *		irq2ee;
	u_char *	ee2irq;
	u_char 		enaddr[6];
	int		tmp;
	int		error;
	struct ex_softc *sc = device_get_softc(dev);

	/* Check isapnp ids */
	error = ISA_PNP_PROBE(device_get_parent(dev), dev, ex_ids);

	/* If the card had a PnP ID that didn't match any we know about */
	if (error == ENXIO)
		return(error);

	/* If we had some other problem. */
	if (!(error == 0 || error == ENOENT))
		return(error);

	error = ex_alloc_resources(dev);
	if (error != 0)
		goto bad;
	iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
	if (!ex_look_for_card(sc)) {
		if (bootverbose)
			printf("ex: no card found at 0x%03lx.\n", (unsigned long)iobase);
		error = ENXIO;
		goto bad;
	}
	if (bootverbose)
		printf("ex: ex_isa_probe() found card at 0x%03lx\n", (unsigned long)iobase);

	/*
	 * Reset the card.
	 */
	CSR_WRITE_1(sc, CMD_REG, Reset_CMD);
	DELAY(800);

	ex_get_address(sc, enaddr);

	/* work out which set of irq <-> internal tables to use */
	if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
		irq2ee = plus_irq2eemap;
		ee2irq = plus_ee2irqmap;
	} else {
		irq2ee = irq2eemap;
		ee2irq = ee2irqmap;
	}

	tmp = ex_eeprom_read(sc, EE_W1) & EE_W1_INT_SEL;
	irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0);
	if (irq > 0) {
		/* This will happen if board is in PnP mode. */
		if (ee2irq[tmp] != irq) {
			device_printf(dev,
			    "WARNING: IRQ mismatch: EEPROM %d, using %d\n",
				ee2irq[tmp], irq);
		}
	} else {
		irq = ee2irq[tmp];
		bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
	}

	if (irq == 0) {
		printf("ex: invalid IRQ.\n");
		error = ENXIO;
	}

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