Beispiel #1
0
static int
ndis_probe_pccard(device_t dev)
{
	struct drvdb_ent *db;
	struct driver_object *drv;

	drv = windrv_lookup(0, "PCCARD Bus");
	if (drv == NULL)
		return (ENXIO);

	db = windrv_match((matchfuncptr)ndis_devcompare_pccard, dev);
	if (db == NULL)
		return (ENXIO);
	return (windrv_create_pdo(drv, dev));
}
Beispiel #2
0
static int
ndisusb_match(device_t self)
{
	struct drvdb_ent *db;
	struct usb_attach_arg *uaa = device_get_ivars(self);

	if (windrv_lookup(0, "USB Bus") == NULL)
		return (UMATCH_NONE);

	if (uaa->iface != NULL)
		return (UMATCH_NONE);

	db = windrv_match((matchfuncptr)ndisusb_devcompare, self);
	if (db == NULL)
		return (UMATCH_NONE);

	return (UMATCH_VENDOR_PRODUCT);
}
Beispiel #3
0
static int
ndis_probe_usb(device_t dev)
{
	struct usb_attach_arg *uaa;
	struct drvdb_ent *db;

	uaa = device_get_ivars(dev);
	if (uaa->usb_mode != USB_MODE_HOST ||
	    uaa->info.bConfigIndex != NDISUSB_CONFIG_NO ||
	    uaa->info.bIfaceIndex != NDISUSB_IFACE_INDEX ||
	    windrv_lookup(0, "USB Bus") == NULL)
		return (ENXIO);

	db = windrv_match((matchfuncptr)ndis_devcompare_usb, dev);
	if (db == NULL)
		return (ENXIO);
	uaa->driver_ivar = db;

	return (0);
}
Beispiel #4
0
/*
 * Probe for an NDIS device. Check the PCI vendor and device
 * IDs against our list and return a device name if we find a match.
 */
static int
ndis_probe_pccard(device_t dev)
{
	driver_object		*drv;
	struct drvdb_ent	*db;

	drv = windrv_lookup(0, "PCCARD Bus");
	if (drv == NULL)
		return(ENXIO);

	db = windrv_match((matchfuncptr)ndis_devcompare, dev);

	if (db != NULL) {
		/* Create PDO for this device instance */
		windrv_create_pdo(drv, dev);
		return(0);
	}

	return(ENXIO);
}
Beispiel #5
0
static int
ndis_attach_pccard(device_t dev)
{
	struct ndis_softc *sc;
	struct ndis_device_type *t;
	struct drvdb_ent *db;
	uint32_t product, vendor;
	int devidx = 0, error = 0, rid = 0;

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

	db = windrv_match((matchfuncptr)ndis_devcompare_pccard, dev);
	if (db == NULL)
		return (ENXIO);
	sc->ndis_dobj = db->windrv_object;
	sc->ndis_regvals = db->windrv_regvals;
	resource_list_init(&sc->ndis_rl);

	sc->ndis_io_rid = 0;
	sc->ndis_res_io = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
	    &sc->ndis_io_rid, RF_ACTIVE);
	if (sc->ndis_res_io == NULL) {
		device_printf(dev, "couldn't map iospace\n");
		return (ENXIO);
	}
	sc->ndis_rescnt++;
	resource_list_add(&sc->ndis_rl, SYS_RES_IOPORT, sc->ndis_io_rid,
	    rman_get_start(sc->ndis_res_io), rman_get_end(sc->ndis_res_io),
	    rman_get_size(sc->ndis_res_io));

	sc->ndis_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
	    RF_SHAREABLE | RF_ACTIVE);
	if (sc->ndis_irq == NULL) {
		device_printf(dev, "couldn't map interrupt\n");
		return (ENXIO);
	}
	sc->ndis_rescnt++;
	resource_list_add(&sc->ndis_rl, SYS_RES_IRQ, rid,
	    rman_get_start(sc->ndis_irq), rman_get_start(sc->ndis_irq), 1);
	sc->ndis_bus_type = NDIS_PCMCIABUS;

	error = pccard_get_product(dev, &product);
	if (error)
		return (error);
	error = pccard_get_vendor(dev, &vendor);
	if (error)
		return (error);
	/* Figure out exactly which device we matched. */
	for (t = db->windrv_devlist; t->name != NULL; t++, devidx++) {
		if ((vendor == t->vendor) &&
		    (product == t->device))
			break;
	}
	sc->ndis_devidx = devidx;

	error = ndis_alloc_amem(sc);
	if (error) {
		ndis_free_amem(sc);
		return (error);
	}
	return (ndis_attach(dev));
}
Beispiel #6
0
/*
 * Attach the interface. Allocate softc structures, do ifmedia
 * setup and ethernet/BPF attach.
 */
static int
ndis_attach_pccard(device_t dev)
{
	struct ndis_softc	*sc;
	int			unit, error = 0, rid;
	struct ndis_pccard_type	*t;
	int			devidx = 0;
	const char		*prodstr, *vendstr;
	struct drvdb_ent	*db;

	wlan_serialize_enter();
	sc = device_get_softc(dev);
	unit = device_get_unit(dev);
	sc->ndis_dev = dev;

	db = windrv_match((matchfuncptr)ndis_devcompare, dev);
	if (db == NULL) {
		wlan_serialize_exit();
		return (ENXIO);
	}
	sc->ndis_dobj = db->windrv_object;
	sc->ndis_regvals = db->windrv_regvals;
	resource_list_init(&sc->ndis_rl);

	sc->ndis_io_rid = 0;
	sc->ndis_res_io = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
	    &sc->ndis_io_rid, RF_ACTIVE);
	if (sc->ndis_res_io == NULL) {
		device_printf(dev,
		    "couldn't map iospace\n");
		error = ENXIO;
		goto fail;
	}
	sc->ndis_rescnt++;
	resource_list_add(&sc->ndis_rl, SYS_RES_IOPORT, rid,
	    rman_get_start(sc->ndis_res_io), rman_get_end(sc->ndis_res_io),
	    rman_get_size(sc->ndis_res_io), -1);

	rid = 0;
	sc->ndis_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
	    RF_SHAREABLE | RF_ACTIVE);
	if (sc->ndis_irq == NULL) {
		device_printf(dev,
		    "couldn't map interrupt\n");
		error = ENXIO;
		goto fail;
	}
	sc->ndis_rescnt++;
	resource_list_add(&sc->ndis_rl, SYS_RES_IRQ, rid,
	    rman_get_start(sc->ndis_irq), rman_get_start(sc->ndis_irq), 1,
	    rman_get_cpuid(sc->ndis_irq));

	sc->ndis_iftype = PCMCIABus;

	/* Figure out exactly which device we matched. */

	t = db->windrv_devlist;

	prodstr = pccard_get_product_str(dev);
	vendstr = pccard_get_vendor_str(dev);

	while(t->ndis_name != NULL) {
		if (strcasecmp(vendstr, t->ndis_vid) == 0 &&
		    strcasecmp(prodstr, t->ndis_did) == 0)
			break;
		t++;
		devidx++;
	}

	sc->ndis_devidx = devidx;

	error = ndis_attach(dev);

fail:
	wlan_serialize_exit();
	return(error);
}
Beispiel #7
0
static int
ndisusb_attach(device_t self)
{
	struct drvdb_ent	*db;
	struct ndisusb_softc *dummy = device_get_softc(self);
	struct usb_attach_arg *uaa = device_get_ivars(self);
	struct ndis_softc	*sc;
	struct ndis_usb_type	*t;
	driver_object		*drv;
	int			devidx = 0;
	usbd_status		status;

	wlan_serialize_enter();
	sc = (struct ndis_softc *)dummy;

	if (uaa->device == NULL) {
		wlan_serialize_exit();
		return ENXIO;
	}

	db = windrv_match((matchfuncptr)ndisusb_devcompare, self);
	if (db == NULL) {
		wlan_serialize_exit();
		return (ENXIO);
	}

	sc->ndis_dev = self;
	sc->ndis_dobj = db->windrv_object;
	sc->ndis_regvals = db->windrv_regvals;
	sc->ndis_iftype = PNPBus;

	/* Create PDO for this device instance */

	drv = windrv_lookup(0, "USB Bus");
	windrv_create_pdo(drv, self);

	status = usbd_set_config_no(uaa->device, NDISUSB_CONFIG_NO, 0);
	if (status != USBD_NORMAL_COMPLETION) {
		device_printf(self, "setting config no failed\n");
		wlan_serialize_exit();
		return (ENXIO);
	}

	/* Figure out exactly which device we matched. */

	t = db->windrv_devlist;

	while (t->ndis_name != NULL) {
		if ((uaa->vendor == t->ndis_vid) &&
		    (uaa->product == t->ndis_did)) {
			sc->ndis_devidx = devidx;
			break;
		}
		t++;
		devidx++;
	}

	if (ndis_attach(self) != 0) {
		wlan_serialize_exit();
		return ENXIO;
	}

	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, uaa->device, self);

	wlan_serialize_exit();
	return 0;
}