Ejemplo n.º 1
0
static int
snc_pccard_attach(device_t dev)
{
	struct snc_softc *sc = device_get_softc(dev);
	int error;
	
	/*
	 * Not sure that this belongs here or in snc_pccard_attach
	 */
	if ((error = snc_alloc_port(dev, 0)) != 0)
		goto err;
	if ((error = snc_alloc_memory(dev, 0)) != 0)
		goto err;
	if ((error = snc_alloc_irq(dev, 0, 0)) != 0)
		goto err;
	if ((error = snc_probe(dev, SNEC_TYPE_PNP)) != 0)
		goto err;
	/* This interface is always enabled. */
	sc->sc_enabled = 1;
	/* pccard_get_ether(dev, ether_addr); */
	if ((error = snc_attach(dev)) != 0)
		goto err;
	return 0;
err:;
	snc_release_resources(dev);
	return error;
} 
Ejemplo n.º 2
0
static int
snc_pccard_attach(device_t dev)
{
	struct snc_softc *sc = device_get_softc(dev);
	int error;
	
	bzero(sc, sizeof(struct snc_softc));

	snc_alloc_port(dev, 0);
	snc_alloc_memory(dev, 0);
	snc_alloc_irq(dev, 0, 0);
		
	error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
			       sncintr, sc, &sc->irq_handle);
	if (error) {
		printf("snc_isa_attach: bus_setup_intr() failed\n");
		snc_release_resources(dev);
		return (error);
	}	       

	/* This interface is always enabled. */
	sc->sc_enabled = 1;

	/* pccard_get_ether(dev, ether_addr); */

	return snc_attach(dev);
} 
Ejemplo n.º 3
0
/* 
 * Probe framework for pccards.  Replicates the standard framework,
 * minus the pccard driver registration and ignores the ether address
 * supplied (from the CIS), relying on the probe to find it instead.
 */
static int
snc_pccard_probe(device_t dev)
{
	int     error;

	error = snc_alloc_port(dev, 0);
	error = max(error, snc_alloc_memory(dev, 0));
	error = max(error, snc_alloc_irq(dev, 0, 0));

	if (!error && !snc_probe(dev, SNEC_TYPE_PNP))
		error = ENOENT;

	snc_release_resources(dev);
	return (error);
}
Ejemplo n.º 4
0
static int
snc_isa_attach(device_t dev)
{
	struct snc_softc *sc = device_get_softc(dev);
	
	bzero(sc, sizeof(struct snc_softc));

	snc_alloc_port(dev, 0);
	snc_alloc_memory(dev, 0);
	snc_alloc_irq(dev, 0, 0);
		
	/* This interface is always enabled. */
	sc->sc_enabled = 1;

	return snc_attach(dev);
} 
Ejemplo n.º 5
0
static int
snc_isa_probe(device_t dev)
{
	struct snc_softc *sc = device_get_softc(dev);
	int type;
 	int error = 0;

	bzero(sc, sizeof(struct snc_softc));

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

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

	switch (error) {
	case 0:		/* Matched PnP */
		type = SNEC_TYPE_PNP;
		break;

	case ENOENT:	/* Legacy ISA */
		type = SNEC_TYPE_LEGACY;
		break;

	default:	/* If we had some other problem. */
		return(error);
	}

	if (type == SNEC_TYPE_PNP && isa_get_portsize(dev) == 0) {
		int port;
		int rid = 0;
		struct resource *res = NULL;

		for (port = 0x0888; port <= 0x3888; port += 0x1000) {
			bus_set_resource(dev, SYS_RES_IOPORT, rid,
					 port, SNEC_NREGS);
			res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
						 0ul, ~0ul, SNEC_NREGS,
						 0 /* !RF_ACTIVE */);
			if (res) break;
		}

		printf("snc_isa_probe: broken PnP resource, ");
		if (res) {
			printf("use port 0x%x\n", port);
			bus_release_resource(dev, SYS_RES_IOPORT, rid, res);
			snc_isapnp_reconfig(dev);
		} else {
			printf("and can't find port\n");
		}
	}

	error = snc_alloc_port(dev, 0);
	error = max(error, snc_alloc_memory(dev, 0));
	error = max(error, snc_alloc_irq(dev, 0, 0));

	if (!error && !snc_probe(dev, type))
		error = ENOENT;

	snc_release_resources(dev);
	return (error);
}