当前位置: 首页>>代码示例>>C++>>正文


C++ device_probe_and_attach函数代码示例

本文整理汇总了C++中device_probe_and_attach函数的典型用法代码示例。如果您正苦于以下问题:C++ device_probe_and_attach函数的具体用法?C++ device_probe_and_attach怎么用?C++ device_probe_and_attach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了device_probe_and_attach函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ixpiic_attach

static int
ixpiic_attach(device_t dev)
{
	struct ixpiic_softc *sc = device_get_softc(dev);
	struct ixp425_softc *sa = device_get_softc(device_get_parent(dev));

	ixpiic_sc = sc;

	sc->sc_dev = dev;
	sc->sc_iot = sa->sc_iot;
	sc->sc_gpio_ioh = sa->sc_gpio_ioh;

	GPIO_CONF_SET(sc, IXP425_GPIO_GPOER,
		GPIO_I2C_SCL_BIT | GPIO_I2C_SDA_BIT);
	GPIO_CONF_CLR(sc, IXP425_GPIO_GPOUTR,
		GPIO_I2C_SCL_BIT | GPIO_I2C_SDA_BIT);

	/* add generic bit-banging code */	
	if ((sc->iicbb = device_add_child(dev, "iicbb", -1)) == NULL)
		device_printf(dev, "could not add iicbb\n");

	/* probe and attach the bit-banging code */
	device_probe_and_attach(sc->iicbb);

	return (0);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:26,代码来源:ixp425_iic.c

示例2: ehci_oxu_attach

int
ehci_oxu_attach(device_t self)
{
  ehci_softc_t *sc = device_get_softc(self);
  int err;

#if EHCI_OXU_DEBUG_LEDS
  dbg_port_set_mode (dbg_port_uh_mon);
#endif
  
  /* initialise some bus fields */
  sc->sc_bus.parent = self;
  sc->sc_bus.devices = sc->sc_devices;
  sc->sc_bus.devices_max = EHCI_MAX_DEVICES;
  sc->sc_io_tag = 0U;
  sc->sc_io_hdl = OXU210_USB_EHCI_OFST;
  sc->sc_io_size = 0x00020000;

  sc->sc_flags |= (EHCI_SCFLG_SETMODE |
                   EHCI_SCFLG_TT | EHCI_SCFLG_FORCESPEED |
                   EHCI_SCFLG_NORESTERM |
                   EHCI_SCFLG_SETFRSZ);

  /* get all DMA memory */
  if (usb_bus_mem_alloc_all(&sc->sc_bus,
                            USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) {
    return (ENOMEM);
  }

  sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
  if (!sc->sc_bus.bdev) {
    device_printf(self, "Could not add USB device\n");
    goto error;
  }

  device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
  device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR);

  err = oxu210_intr_attach (oxu210_intr_shc,
                            (oxu210_intr_handler) ehci_interrupt,
                            sc);
  if (err) {
    device_printf(self, "USB EHCI intr attach error\n");
    goto error;
  }

  err = ehci_init(sc);
  if (!err) {
    err = device_probe_and_attach(sc->sc_bus.bdev);
  }
  if (err) {
    device_printf(self, "USB init failed err=%d\n", err);
    goto error;
  }
  return (0);

error:
  ehci_oxu_detach(self);
  return (ENXIO);
}
开发者ID:wsoltys,项目名称:pacedev,代码行数:60,代码来源:ehci_oxu210.c

示例3: twe_attach_drive

/********************************************************************************
 * Given a detected drive, attach it to the bio interface.
 *
 * This is called from twe_add_unit.
 */
int
twe_attach_drive(struct twe_softc *sc, struct twe_drive *dr)
{
    char	buf[80];
    int		error;

    mtx_lock(&Giant);
    dr->td_disk =  device_add_child(sc->twe_dev, NULL, -1);
    if (dr->td_disk == NULL) {
	mtx_unlock(&Giant);
	twe_printf(sc, "Cannot add unit\n");
	return (EIO);
    }
    device_set_ivars(dr->td_disk, dr);

    /* 
     * XXX It would make sense to test the online/initialising bits, but they seem to be
     * always set...
     */
    sprintf(buf, "Unit %d, %s, %s",
	    dr->td_twe_unit,
	    twe_describe_code(twe_table_unittype, dr->td_type),
	    twe_describe_code(twe_table_unitstate, dr->td_state & TWE_PARAM_UNITSTATUS_MASK));
    device_set_desc_copy(dr->td_disk, buf);

    error = device_probe_and_attach(dr->td_disk);
    mtx_unlock(&Giant);
    if (error != 0) {
	twe_printf(sc, "Cannot attach unit to controller. error = %d\n", error);
	return (EIO);
    }
    return (0);
}
开发者ID:JabirTech,项目名称:Source,代码行数:38,代码来源:twe_freebsd.c

示例4: acpi_perf_identify

static void
acpi_perf_identify(driver_t *driver, device_t parent)
{
	ACPI_HANDLE handle;
	device_t dev;

	/* Make sure we're not being doubly invoked. */
	if (device_find_child(parent, "acpi_perf", -1) != NULL)
		return;

	/* Get the handle for the Processor object and check for perf states. */
	handle = acpi_get_handle(parent);
	if (handle == NULL)
		return;
	if (ACPI_FAILURE(AcpiEvaluateObject(handle, "_PSS", NULL, NULL)))
		return;

	/*
	 * Add a child to every CPU that has the right methods.  In future
	 * versions of the ACPI spec, CPUs can have different settings.
	 * We probe this child now so that other devices that depend
	 * on it (i.e., for info about supported states) will see it.
	 */
	if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_perf", -1)) != NULL)
		device_probe_and_attach(dev);
	else
		device_printf(parent, "add acpi_perf child failed\n");
}
开发者ID:MattDooner,项目名称:freebsd-west,代码行数:28,代码来源:acpi_perf.c

示例5: bcm_fb_setup_fbd

static int
bcm_fb_setup_fbd(struct bcmsc_softc *sc)
{
	struct bcm2835_fb_config fb;
	device_t fbd;
	int err;

	err = bcm_fb_init(sc, &fb);
	if (err)
		return (err);

	memset(&sc->info, 0, sizeof(sc->info));
	sc->info.fb_name = device_get_nameunit(sc->dev);

	sc->info.fb_vbase = (intptr_t)pmap_mapdev(fb.base, fb.size);
	sc->info.fb_pbase = fb.base;
	sc->info.fb_size = fb.size;
	sc->info.fb_bpp = sc->info.fb_depth = fb.bpp;
	sc->info.fb_stride = fb.pitch;
	sc->info.fb_width = fb.xres;
	sc->info.fb_height = fb.yres;
	sc->info.fb_flags = FB_FLAG_MEMATTR;
	sc->info.fb_memattr = VM_MEMATTR_WRITE_COMBINING;

	if (sc->fbswap) {
		switch (sc->info.fb_bpp) {
		case 24:
			vt_generate_cons_palette(sc->info.fb_cmap,
			    COLOR_FORMAT_RGB, 0xff, 0, 0xff, 8, 0xff, 16);
			sc->info.fb_cmsize = 16;
			break;
		case 32:
			vt_generate_cons_palette(sc->info.fb_cmap,
			    COLOR_FORMAT_RGB, 0xff, 16, 0xff, 8, 0xff, 0);
			sc->info.fb_cmsize = 16;
			break;
		}
	}

	fbd = device_add_child(sc->dev, "fbd", device_get_unit(sc->dev));
	if (fbd == NULL) {
		device_printf(sc->dev, "Failed to add fbd child\n");
		pmap_unmapdev(sc->info.fb_vbase, sc->info.fb_size);
		return (ENXIO);
	} else if (device_probe_and_attach(fbd) != 0) {
		device_printf(sc->dev, "Failed to attach fbd device\n");
		device_delete_child(sc->dev, fbd);
		pmap_unmapdev(sc->info.fb_vbase, sc->info.fb_size);
		return (ENXIO);
	}

	device_printf(sc->dev, "%dx%d(%dx%[email protected]%d,%d) %dbpp\n", fb.xres, fb.yres,
	    fb.vxres, fb.vyres, fb.xoffset, fb.yoffset, fb.bpp);
	device_printf(sc->dev,
	    "fbswap: %d, pitch %d, base 0x%08x, screen_size %d\n",
	    sc->fbswap, fb.pitch, fb.base, fb.size);

	return (0);
}
开发者ID:KingD512,项目名称:freebsd,代码行数:59,代码来源:bcm2835_fbd.c

示例6: acpi_ec_ecdt_probe

/*
 * Look for an ECDT and if we find one, set up default GPE and
 * space handlers to catch attempts to access EC space before
 * we have a real driver instance in place.
 *
 * TODO: Some old Gateway laptops need us to fake up an ECDT or
 * otherwise attach early so that _REG methods can run.
 */
void
acpi_ec_ecdt_probe(device_t parent)
{
    ACPI_TABLE_ECDT *ecdt;
    ACPI_STATUS	     status;
    device_t	     child;
    ACPI_HANDLE	     h;
    struct acpi_ec_params *params;

    ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);

    /* Find and validate the ECDT. */
    status = AcpiGetTable(ACPI_SIG_ECDT, 1, (ACPI_TABLE_HEADER **)&ecdt);
    if (ACPI_FAILURE(status) ||
	ecdt->Control.BitWidth != 8 ||
	ecdt->Data.BitWidth != 8) {
	return;
    }

    /* Create the child device with the given unit number. */
    child = BUS_ADD_CHILD(parent, parent, 0, "acpi_ec", ecdt->Uid);
    if (child == NULL) {
	kprintf("%s: can't add child\n", __func__);
	return;
    }

    /* Find and save the ACPI handle for this device. */
    status = AcpiGetHandle(NULL, ecdt->Id, &h);
    if (ACPI_FAILURE(status)) {
	device_delete_child(parent, child);
	kprintf("%s: can't get handle\n", __func__);
	return;
    }
    acpi_set_handle(child, h);

    /* Set the data and CSR register addresses. */
    bus_set_resource(child, SYS_RES_IOPORT, 0, ecdt->Data.Address,
	/*count*/1, -1);
    bus_set_resource(child, SYS_RES_IOPORT, 1, ecdt->Control.Address,
	/*count*/1, -1);

    /*
     * Store values for the probe/attach routines to use.  Store the
     * ECDT GPE bit and set the global lock flag according to _GLK.
     * Note that it is not perfectly correct to be evaluating a method
     * before initializing devices, but in practice this function
     * should be safe to call at this point.
     */
    params = kmalloc(sizeof(struct acpi_ec_params), M_TEMP, M_WAITOK | M_ZERO);
    params->gpe_handle = NULL;
    params->gpe_bit = ecdt->Gpe;
    params->uid = ecdt->Uid;
    acpi_GetInteger(h, "_GLK", &params->glk);
    acpi_set_private(child, params);

    /* Finish the attach process. */
    if (device_probe_and_attach(child) != 0)
	device_delete_child(parent, child);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:67,代码来源:acpi_ec.c

示例7: tcasic_attach

static int
tcasic_attach(device_t dev)
{
	tcasic0 = dev;

/*	chipset = tcasic_chipset;*/
	device_probe_and_attach(tc0);
	return 0;
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:9,代码来源:tcasic.c

示例8: octusb_octeon_attach

static int
octusb_octeon_attach(device_t dev)
{
	struct octusb_octeon_softc *sc = device_get_softc(dev);
	int err;
	int rid;

	/* setup controller interface softc */

	/* initialise some bus fields */
	sc->sc_dci.sc_bus.parent = dev;
	sc->sc_dci.sc_bus.devices = sc->sc_dci.sc_devices;
	sc->sc_dci.sc_bus.devices_max = OCTUSB_MAX_DEVICES;

	/* get all DMA memory */
	if (usb_bus_mem_alloc_all(&sc->sc_dci.sc_bus,
	    USB_GET_DMA_TAG(dev), NULL)) {
		return (ENOMEM);
	}
	rid = 0;
	sc->sc_dci.sc_irq_res =
	    bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
			       CVMX_IRQ_USB, CVMX_IRQ_USB, 1, RF_ACTIVE);
	if (!(sc->sc_dci.sc_irq_res)) {
		goto error;
	}

	sc->sc_dci.sc_bus.bdev = device_add_child(dev, "usbus", -1);
	if (!(sc->sc_dci.sc_bus.bdev)) {
		goto error;
	}
	device_set_ivars(sc->sc_dci.sc_bus.bdev, &sc->sc_dci.sc_bus);

#if (__FreeBSD_version >= 700031)
	err = bus_setup_intr(dev, sc->sc_dci.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
	    NULL, (driver_intr_t *)octusb_interrupt, sc, &sc->sc_dci.sc_intr_hdl);
#else
	err = bus_setup_intr(dev, sc->sc_dci.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
	    (driver_intr_t *)octusb_interrupt, sc, &sc->sc_dci.sc_intr_hdl);
#endif
	if (err) {
		sc->sc_dci.sc_intr_hdl = NULL;
		goto error;
	}
	err = octusb_init(&sc->sc_dci);
	if (!err) {
		err = device_probe_and_attach(sc->sc_dci.sc_bus.bdev);
	}
	if (err) {
		goto error;
	}
	return (0);

error:
	octusb_octeon_detach(dev);
	return (ENXIO);
}
开发者ID:ppaeps,项目名称:freebsd-head,代码行数:57,代码来源:octusb_octeon.c

示例9: cardbus_attach_card

static int
cardbus_attach_card(device_t cbdev)
{
	device_t brdev = device_get_parent(cbdev);
	device_t child;
	int bus, domain, slot, func;
	int cardattached = 0;
	int cardbusfunchigh = 0;
	struct cardbus_softc *sc;

	sc = device_get_softc(cbdev);
	cardbus_detach_card(cbdev); /* detach existing cards */
	POWER_ENABLE_SOCKET(brdev, cbdev);
	domain = pcib_get_domain(cbdev);
	bus = pcib_get_bus(cbdev);
	slot = 0;
	/* For each function, set it up and try to attach a driver to it */
	for (func = 0; func <= cardbusfunchigh; func++) {
		struct cardbus_devinfo *dinfo;

		dinfo = (struct cardbus_devinfo *)
		    pci_read_device(brdev, domain, bus, slot, func,
			sizeof(struct cardbus_devinfo));
		if (dinfo == NULL)
			continue;
		if (dinfo->pci.cfg.mfdev)
			cardbusfunchigh = PCI_FUNCMAX;

		child = device_add_child(cbdev, NULL, -1);
		if (child == NULL) {
			DEVPRINTF((cbdev, "Cannot add child!\n"));
			pci_freecfg((struct pci_devinfo *)dinfo);
			continue;
		}
		dinfo->pci.cfg.dev = child;
		resource_list_init(&dinfo->pci.resources);
		device_set_ivars(child, dinfo);
		cardbus_device_create(sc, dinfo, cbdev, child);
		if (cardbus_do_cis(cbdev, child) != 0)
			DEVPRINTF((cbdev, "Warning: Bogus CIS ignored\n"));
		pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 0);
		pci_cfg_restore(dinfo->pci.cfg.dev, &dinfo->pci);
		cardbus_device_setup_regs(&dinfo->pci.cfg);
		pci_add_resources(cbdev, child, 1, dinfo->mprefetchable);
		pci_print_verbose(&dinfo->pci);
		if (device_probe_and_attach(child) == 0)
			cardattached++;
		else
			pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 1);
	}
	if (cardattached > 0)
		return (0);
/*	POWER_DISABLE_SOCKET(brdev, cbdev); */
	return (ENOENT);
}
开发者ID:MattDooner,项目名称:freebsd-west,代码行数:55,代码来源:cardbus.c

示例10: lpbb_attach

static int
lpbb_attach(device_t dev)
{
	device_t bitbang;

	/* add generic bit-banging code */
	bitbang = device_add_child(dev, "iicbb", -1);
	device_probe_and_attach(bitbang);

	return (0);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:11,代码来源:lpbb.c

示例11: tcasic_attach

static int
tcasic_attach(device_t dev)
{
	struct tcasic_softc* sc = TCASIC_SOFTC(dev);
	device_t parent = device_get_parent(dev);
	vm_offset_t regs;
	tcasic0 = dev;

/*	chipset = tcasic_chipset;*/
	chipset.intrdev = dev;
	device_probe_and_attach(tc0);
	return 0;
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:13,代码来源:tcasic.c

示例12: card_detect_task

static void
card_detect_task(void *arg, int pending)
{
	struct fsl_sdhc_softc *sc = (struct fsl_sdhc_softc *)arg;
	int err;
	int insert;

	insert = read4(sc, SDHC_PRSSTAT) & PRSSTAT_CINS;

	mtx_lock(&sc->mtx);

	if (insert) {
		if (sc->child != NULL) {
			mtx_unlock(&sc->mtx);
			return;
		}

		sc->child = device_add_child(sc->self, "mmc", -1);
		if (sc->child == NULL) {
			device_printf(sc->self, "Couldn't add MMC bus!\n");
			mtx_unlock(&sc->mtx);
			return;
		}

		/* Initialize MMC bus host structure. */
		init_mmc_host_struct(sc);
		device_set_ivars(sc->child, &sc->mmc_host);

	} else {
		if (sc->child == NULL) {
			mtx_unlock(&sc->mtx);
			return;
		}
	}

	mtx_unlock(&sc->mtx);

	if (insert) {
		if ((err = device_probe_and_attach(sc->child)) != 0) {
			device_printf(sc->self, "MMC bus failed on probe "
			    "and attach! error %d\n", err);
			device_delete_child(sc->self, sc->child);
			sc->child = NULL;
		}
	} else {
		if (device_delete_child(sc->self, sc->child) != 0)
			device_printf(sc->self, "Could not delete MMC bus!\n");
		sc->child = NULL;
	}
}
开发者ID:ngkaho1234,项目名称:freebsd,代码行数:50,代码来源:fsl_sdhc.c

示例13: acpi_dock_attach_later

static void
acpi_dock_attach_later(void *context)
{
	device_t	dev;

	dev = (device_t)context;

	if (!device_is_enabled(dev))
		device_enable(dev);

	mtx_lock(&Giant);
	device_probe_and_attach(dev);
	mtx_unlock(&Giant);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:14,代码来源:acpi_dock.c

示例14: nexus_attach

static int
nexus_attach(device_t dev)
{
	device_t	child;

	/*
	 * First, deal with the children we know about already
	 */
	bus_generic_attach(dev);
	/*
	 * And if we didn't see EISA or ISA on a pci bridge, create some
	 * connection points now so they show up "on motherboard".
	 */
	if (!devclass_get_device(devclass_find("eisa"), 0)) {
		child = device_add_child(dev, "eisa", 0);
		if (child == NULL)
			panic("nexus_attach eisa");
		device_probe_and_attach(child);
	}
#if NMCA > 0
	if (!devclass_get_device(devclass_find("mca"), 0)) {
        	child = device_add_child(dev, "mca", 0);
        	if (child == 0)
                	panic("nexus_probe mca");
		device_probe_and_attach(child);
	}
#endif
	if (!devclass_get_device(devclass_find("isa"), 0)) {
		child = device_add_child(dev, "isa", 0);
		if (child == NULL)
			panic("nexus_attach isa");
		device_probe_and_attach(child);
	}

	return 0;
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:36,代码来源:nexus.c

示例15: nandsim_start_ctrl

static int
nandsim_start_ctrl(int num)
{
	device_t nexus, ndev;
	devclass_t nexus_devclass;
	int ret = 0;

	nand_debug(NDBG_SIM,"start ctlr num:%d", num);

	if (num >= MAX_SIM_DEV)
		return (EINVAL);

	if (!ctrls[num].created)
		return (ENODEV);

	if (ctrls[num].running)
		return (EBUSY);

	/* We will add our device as a child of the nexus0 device */
	if (!(nexus_devclass = devclass_find("nexus")) ||
	    !(nexus = devclass_get_device(nexus_devclass, 0)))
		return (EFAULT);

	/*
	 * Create a newbus device representing this frontend instance
	 *
	 * XXX powerpc nexus doesn't implement bus_add_child, so child
	 * must be added by device_add_child().
	 */
#if defined(__powerpc__)
	ndev = device_add_child(nexus, "nandsim", num);
#else
	ndev = BUS_ADD_CHILD(nexus, 0, "nandsim", num);
#endif
	if (!ndev)
		return (EFAULT);

	mtx_lock(&Giant);
	ret = device_probe_and_attach(ndev);
	mtx_unlock(&Giant);

	if (ret == 0) {
		ctrls[num].sim_ctrl_dev = ndev;
		ctrls[num].running = 1;
	}

	return (ret);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:48,代码来源:nandsim.c


注:本文中的device_probe_and_attach函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。