• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ devclass_find函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: usb_attach_sub

/*------------------------------------------------------------------------*
 *	usb_attach_sub
 *
 * This function creates a thread which runs the USB attach code.
 *------------------------------------------------------------------------*/
static void
usb_attach_sub(device_t dev, struct usb_bus *bus)
{
	const char *pname = device_get_nameunit(dev);

	mtx_lock(&Giant);
	if (usb_devclass_ptr == NULL)
		usb_devclass_ptr = devclass_find("usbus");
	mtx_unlock(&Giant);

#if USB_HAVE_PF
	usbpf_attach(bus);
#endif
	/* Initialise USB process messages */
	bus->explore_msg[0].hdr.pm_callback = &usb_bus_explore;
	bus->explore_msg[0].bus = bus;
	bus->explore_msg[1].hdr.pm_callback = &usb_bus_explore;
	bus->explore_msg[1].bus = bus;

	bus->detach_msg[0].hdr.pm_callback = &usb_bus_detach;
	bus->detach_msg[0].bus = bus;
	bus->detach_msg[1].hdr.pm_callback = &usb_bus_detach;
	bus->detach_msg[1].bus = bus;

	bus->attach_msg[0].hdr.pm_callback = &usb_bus_attach;
	bus->attach_msg[0].bus = bus;
	bus->attach_msg[1].hdr.pm_callback = &usb_bus_attach;
	bus->attach_msg[1].bus = bus;

	/* Create USB explore and callback processes */

	if (usb_proc_create(&bus->giant_callback_proc,
	    &bus->bus_mtx, pname, USB_PRI_MED)) {
		device_printf(dev, "WARNING: Creation of USB Giant "
		    "callback process failed.\n");
	} else if (usb_proc_create(&bus->non_giant_callback_proc,
	    &bus->bus_mtx, pname, USB_PRI_HIGH)) {
		device_printf(dev, "WARNING: Creation of USB non-Giant "
		    "callback process failed.\n");
	} else if (usb_proc_create(&bus->explore_proc,
	    &bus->bus_mtx, pname, USB_PRI_MED)) {
		device_printf(dev, "WARNING: Creation of USB explore "
		    "process failed.\n");
	} else if (usb_proc_create(&bus->control_xfer_proc,
	    &bus->bus_mtx, pname, USB_PRI_MED)) {
		device_printf(dev, "WARNING: Creation of USB control transfer "
		    "process failed.\n");
	} else {
		/* Get final attach going */
		USB_BUS_LOCK(bus);
		if (usb_proc_msignal(&bus->explore_proc,
		    &bus->attach_msg[0], &bus->attach_msg[1])) {
			/* ignore */
		}
		USB_BUS_UNLOCK(bus);

		/* Do initial explore */
		usb_needs_explore(bus, 1);
	}
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:65,代码来源:usb_controller.c


示例2: tsc_levels_changed

/*
 * When cpufreq levels change, find out about the (new) max frequency.  We
 * use this to update CPU accounting in case it got a lower estimate at boot.
 */
static void
tsc_levels_changed(void *arg, int unit)
{
    device_t cf_dev;
    struct cf_level *levels;
    int count, error;
    uint64_t max_freq;

    /* Only use values from the first CPU, assuming all are equal. */
    if (unit != 0)
        return;

    /* Find the appropriate cpufreq device instance. */
    cf_dev = devclass_get_device(devclass_find("cpufreq"), unit);
    if (cf_dev == NULL) {
        printf("tsc_levels_changed() called but no cpufreq device?\n");
        return;
    }

    /* Get settings from the device and find the max frequency. */
    count = 64;
    levels = malloc(count * sizeof(*levels), M_TEMP, M_NOWAIT);
    if (levels == NULL)
        return;
    error = CPUFREQ_LEVELS(cf_dev, levels, &count);
    if (error == 0 && count != 0) {
        max_freq = (uint64_t)levels[0].total_set.freq * 1000000;
        set_cputicker(rdtsc, max_freq, 1);
    } else
        printf("tsc_levels_changed: no max freq found\n");
    free(levels, M_TEMP);
}
开发者ID:oza,项目名称:FreeBSD-7.3-dyntick,代码行数:36,代码来源:tsc.c


示例3: acpi_pci_update_device

static void
acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child)
{
	ACPI_STATUS status;
	device_t child;

	/*
	 * Occasionally a PCI device may show up as an ACPI device
	 * with a _HID.  (For example, the TabletPC TC1000 has a
	 * second PCI-ISA bridge that has a _HID for an
	 * acpi_sysresource device.)  In that case, leave ACPI-CA's
	 * device data pointing at the ACPI-enumerated device.
	 */
	child = acpi_get_device(handle);
	if (child != NULL) {
		KASSERT(device_get_parent(child) ==
		    devclass_get_device(devclass_find("acpi"), 0),
		    ("%s: child (%s)'s parent is not acpi0", __func__,
		    acpi_name(handle)));
		return;
	}

	/*
	 * Update ACPI-CA to use the PCI enumerated device_t for this handle.
	 */
	status = AcpiAttachData(handle, acpi_fake_objhandler, pci_child);
	if (ACPI_FAILURE(status))
		printf("WARNING: Unable to attach object data to %s - %s\n",
		    acpi_name(handle), AcpiFormatException(status));
}
开发者ID:MattDooner,项目名称:freebsd-west,代码行数:30,代码来源:acpi_pci.c


示例4: acpi_smbat_attach

static int
acpi_smbat_attach(device_t dev)
{
	struct acpi_smbat_softc *sc;
	uint32_t base;

	sc = device_get_softc(dev);
	if (ACPI_FAILURE(acpi_GetInteger(acpi_get_handle(dev), "_EC", &base))) {
		device_printf(dev, "cannot get EC base address\n");
		return (ENXIO);
	}
	sc->sb_base_addr = (base >> 8) & 0xff;

	/* XXX Only works with one EC, but nearly all systems only have one. */
	sc->ec_dev = devclass_get_device(devclass_find("acpi_ec"), 0);
	if (sc->ec_dev == NULL) {
		device_printf(dev, "cannot find EC device\n");
		return (ENXIO);
	}

	timespecclear(&sc->bif_lastupdated);
	timespecclear(&sc->bst_lastupdated);

	if (acpi_battery_register(dev) != 0) {
		device_printf(dev, "cannot register battery\n");
		return (ENXIO);
	}
	return (0);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:29,代码来源:acpi_smbat.c


示例5: aac_printstate0

/*
 * Print the command queue states for controller 0 (callable from DDB)
 */
void
aac_printstate0(void)
{
	struct aac_softc *sc;

	sc = devclass_get_softc(devclass_find("aac"), 0);

	aac_print_queues(sc);
	switch (sc->aac_hwif) {
	case AAC_HWIF_I960RX:
	case AAC_HWIF_NARK:
		device_printf(sc->aac_dev, "IDBR 0x%08x  IIMR 0x%08x  "
		    "IISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_IDBR),
		    AAC_MEM0_GETREG4(sc, AAC_RX_IIMR), AAC_MEM0_GETREG4(sc, AAC_RX_IISR));
		device_printf(sc->aac_dev, "ODBR 0x%08x  OIMR 0x%08x  "
		    "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR),
		    AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR));
		AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY |
			    AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/);
		device_printf(sc->aac_dev, "ODBR 0x%08x  OIMR 0x%08x  "
		    "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR),
		    AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR));
		break;
	case AAC_HWIF_STRONGARM:
		/* XXX implement */
		break;
	}
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:31,代码来源:aac_debug.c


示例6: nandsim_stop_ctrl

static int
nandsim_stop_ctrl(int num)
{
	device_t nexus;
	devclass_t nexus_devclass;
	int ret = 0;

	nand_debug(NDBG_SIM,"stop controller num:%d", num);

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

	if (!ctrls[num].created || !ctrls[num].running) {
		return (ENODEV);
	}

	/* 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 (ENODEV);
	}

	mtx_lock(&Giant);
	if (ctrls[num].sim_ctrl_dev) {
		ret = device_delete_child(nexus, ctrls[num].sim_ctrl_dev);
		ctrls[num].sim_ctrl_dev = NULL;
	}
	mtx_unlock(&Giant);

	ctrls[num].running = 0;

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


示例7: reset_hsic_hub

static int
reset_hsic_hub(struct exynos_ehci_softc *esc, phandle_t hub)
{
	device_t gpio_dev;
	pcell_t pin;

	/* TODO: check that hub is compatible with "smsc,usb3503" */
	if (!OF_hasprop(hub, "freebsd,reset-gpio")) {
		return (1);
	}

	if (OF_getencprop(hub, "freebsd,reset-gpio", &pin, sizeof(pin)) < 0) {
		device_printf(esc->dev,
		    "failed to decode reset GPIO pin number for HSIC hub\n");
		return (1);
	}

	/* Get the GPIO device, we need this to give power to USB */
	gpio_dev = devclass_get_device(devclass_find("gpio"), 0);
	if (gpio_dev == NULL) {
		device_printf(esc->dev, "Cant find gpio device\n");
		return (1);
	}

	GPIO_PIN_SET(gpio_dev, pin, GPIO_PIN_LOW);
	DELAY(100);
	GPIO_PIN_SET(gpio_dev, pin, GPIO_PIN_HIGH);

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


示例8: usbpf_uninit

static void
usbpf_uninit(void *arg)
{
	int devlcnt;
	device_t *devlp;
	devclass_t dc;
	struct usb_bus *ubus;
	int error;
	int i;
	
	if_clone_detach(usbpf_cloner);

	dc = devclass_find(usbusname);
	if (dc == NULL)
		return;
	error = devclass_get_devices(dc, &devlp, &devlcnt);
	if (error)
		return;
	for (i = 0; i < devlcnt; i++) {
		ubus = device_get_softc(devlp[i]);
		if (ubus != NULL && ubus->ifp != NULL)
			usbpf_clone_destroy(usbpf_cloner, ubus->ifp);
	}
	free(devlp, M_TEMP);
}
开发者ID:JabirTech,项目名称:Source,代码行数:25,代码来源:usb_pf.c


示例9: bhndb_pci_probe

/** 
 * Default bhndb_pci implementation of device_probe().
 * 
 * Verifies that the parent is a PCI/PCIe device.
 */
static int
bhndb_pci_probe(device_t dev)
{
	struct bhndb_pci_probe	*probe;
	struct bhndb_pci_core	*entry;
	bhnd_devclass_t		 hostb_devclass;
	device_t		 parent, parent_bus;
	devclass_t		 pci, bus_devclass;
	int			 error;

	probe = NULL;

	/* Our parent must be a PCI/PCIe device. */
	pci = devclass_find("pci");
	parent = device_get_parent(dev);
	parent_bus = device_get_parent(parent);
	if (parent_bus == NULL)
		return (ENXIO);

	/* The bus device class may inherit from 'pci' */
	for (bus_devclass = device_get_devclass(parent_bus);
	    bus_devclass != NULL;
	    bus_devclass = devclass_get_parent(bus_devclass))
	{
		if (bus_devclass == pci)
			break;
	}

	if (bus_devclass != pci)
		return (ENXIO);

	/* Enable clocks */
	if ((error = bhndb_enable_pci_clocks(dev)))
		return (error);

	/* Identify the chip and enumerate the bridged cores */
	hostb_devclass = bhndb_expected_pci_devclass(dev);
	if ((error = bhndb_pci_probe_alloc(&probe, dev, hostb_devclass)))
		goto cleanup;

	/* Look for a matching core table entry */
	if ((entry = bhndb_pci_find_core(&probe->hostb_core)) == NULL) {
		error = ENXIO;
		goto cleanup;
	}

	device_set_desc(dev, "PCI-BHND bridge");

	/* fall-through */
	error = BUS_PROBE_DEFAULT;

cleanup:
	if (probe != NULL)
		bhndb_pci_probe_free(probe);

	bhndb_disable_pci_clocks(dev);

	return (error);
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:64,代码来源:bhndb_pci.c


示例10: acpi_pcib_power_for_sleep

int
acpi_pcib_power_for_sleep(device_t pcib, device_t dev, int *pstate)
{
    device_t acpi_dev;

    acpi_dev = devclass_get_device(devclass_find("acpi"), 0);
    acpi_device_pwr_for_sleep(acpi_dev, dev, pstate);
    return (0);
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:9,代码来源:acpi_pcib.c


示例11: AcpiOsInstallInterruptHandler

ACPI_STATUS
AcpiOsInstallInterruptHandler(UINT32 InterruptNumber,
    ACPI_OSD_HANDLER ServiceRoutine, void *Context)
{
    struct acpi_softc	*sc;

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

    if ((sc = devclass_get_softc(devclass_find("acpi"), 0)) == NULL)
	panic("can't find ACPI device to register interrupt");
    if (sc->acpi_dev == NULL)
	panic("acpi softc has invalid device");

    if (InterruptNumber < 0 || InterruptNumber > 255)
	return_ACPI_STATUS (AE_BAD_PARAMETER);
    if (ServiceRoutine == NULL)
	return_ACPI_STATUS (AE_BAD_PARAMETER);

    /*
     * If the MADT contained an interrupt override directive for the SCI,
     * we use that value instead of the one from the FADT.
     */
    if (InterruptOverride != 0) {
	    device_printf(sc->acpi_dev,
		"Overriding SCI Interrupt from IRQ %u to IRQ %u\n",
		InterruptNumber, InterruptOverride);
	    InterruptNumber = InterruptOverride;
    }

    /* Set up the interrupt resource. */
    sc->acpi_irq_rid = 0;
    bus_set_resource(sc->acpi_dev, SYS_RES_IRQ, 0, InterruptNumber, 1);
    sc->acpi_irq = bus_alloc_resource_any(sc->acpi_dev, SYS_RES_IRQ,
	&sc->acpi_irq_rid, RF_SHAREABLE | RF_ACTIVE);
    if (sc->acpi_irq == NULL) {
	device_printf(sc->acpi_dev, "could not allocate interrupt\n");
	goto error;
    }
    if (bus_setup_intr(sc->acpi_dev, sc->acpi_irq, INTR_TYPE_MISC|INTR_MPSAFE,
	NULL, (driver_intr_t *)ServiceRoutine, Context, &sc->acpi_irq_handle)) {
	device_printf(sc->acpi_dev, "could not set up interrupt\n");
	goto error;
    }

    return_ACPI_STATUS (AE_OK);

error:
    if (sc->acpi_irq_handle)
	bus_teardown_intr(sc->acpi_dev, sc->acpi_irq, sc->acpi_irq_handle);
    sc->acpi_irq_handle = NULL;
    if (sc->acpi_irq)
	bus_release_resource(sc->acpi_dev, SYS_RES_IRQ, 0, sc->acpi_irq);
    sc->acpi_irq = NULL;
    bus_delete_resource(sc->acpi_dev, SYS_RES_IRQ, 0);

    return_ACPI_STATUS (AE_ALREADY_EXISTS);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:57,代码来源:OsdInterrupt.c


示例12: phy_init

static int
phy_init(struct vybrid_ehci_softc *esc)
{
	device_t sc_gpio_dev;
	int reg;

	/* Reset phy */
	reg = PHY_READ4(esc, USBPHY_CTRL);
	reg |= (USBPHY_CTRL_SFTRST);
	PHY_WRITE4(esc, USBPHY_CTRL, reg);

	/* Minimum reset time */
	DELAY(10000);

	reg &= ~(USBPHY_CTRL_SFTRST | USBPHY_CTRL_CLKGATE);
	PHY_WRITE4(esc, USBPHY_CTRL, reg);

	reg = (ENUTMILEVEL2 | ENUTMILEVEL3);
	PHY_WRITE4(esc, USBPHY_CTRL_SET, reg);

	/* Get the GPIO device, we need this to give power to USB */
	sc_gpio_dev = devclass_get_device(devclass_find("gpio"), 0);
	if (sc_gpio_dev == NULL) {
		device_printf(esc->dev, "Error: failed to get the GPIO dev\n");
		return (1);
	}

	/* Give power to USB */
	GPIO_PIN_SETFLAGS(sc_gpio_dev, GPIO_USB_PWR, GPIO_PIN_OUTPUT);
	GPIO_PIN_SET(sc_gpio_dev, GPIO_USB_PWR, GPIO_PIN_HIGH);

	/* Power up PHY */
	PHY_WRITE4(esc, USBPHY_PWD, 0x00);

	/* Ungate clocks */
	reg = PHY_READ4(esc, USBPHY_DEBUG);
	reg &= ~(USBPHY_DEBUG_CLKGATE);
	PHY_WRITE4(esc, USBPHY_DEBUG, reg);

#if 0
	printf("USBPHY_CTRL == 0x%08x\n",
	    PHY_READ4(esc, USBPHY_CTRL));
	printf("USBPHY_IP == 0x%08x\n",
	    PHY_READ4(esc, USBPHY_IP));
	printf("USBPHY_STATUS == 0x%08x\n",
	    PHY_READ4(esc, USBPHY_STATUS));
	printf("USBPHY_DEBUG == 0x%08x\n",
	    PHY_READ4(esc, USBPHY_DEBUG));
	printf("USBPHY_DEBUG0_STATUS == 0x%08x\n",
	    PHY_READ4(esc, USBPHY_DEBUG0_STATUS));
	printf("USBPHY_DEBUG1 == 0x%08x\n",
	    PHY_READ4(esc, USBPHY_DEBUG1));
#endif

	return (0);
}
开发者ID:MattDooner,项目名称:freebsd-west,代码行数:56,代码来源:vf_ehci.c


示例13: vga_pci_is_boot_display

int
vga_pci_is_boot_display(device_t dev)
{
	int unit;
	device_t pcib;
	uint16_t config;

	/* Check that the given device is a video card */
	if ((pci_get_class(dev) != PCIC_DISPLAY &&
	    (pci_get_class(dev) != PCIC_OLD ||
	     pci_get_subclass(dev) != PCIS_OLD_VGA)))
		return (0);

	unit = device_get_unit(dev);

	if (vga_pci_default_unit >= 0) {
		/*
		 * The boot display device was determined by a previous
		 * call to this function, or the user forced it using
		 * the hw.pci.default_vgapci_unit tunable.
		 */
		return (vga_pci_default_unit == unit);
	}

	/*
	 * The primary video card used as a boot display must have the
	 * "I/O" and "Memory Address Space Decoding" bits set in its
	 * Command register.
	 *
	 * Furthermore, if the card is attached to a bridge, instead of
	 * the root PCI bus, the bridge must have the "VGA Enable" bit
	 * set in its Control register.
	 */

	pcib = device_get_parent(device_get_parent(dev));
	if (device_get_devclass(device_get_parent(pcib)) ==
	    devclass_find("pci")) {
		/*
		 * The parent bridge is a PCI-to-PCI bridge: check the
		 * value of the "VGA Enable" bit.
		 */
		config = pci_read_config(pcib, PCIR_BRIDGECTL_1, 2);
		if ((config & PCIB_BCR_VGA_ENABLE) == 0)
			return (0);
	}

	config = pci_read_config(dev, PCIR_COMMAND, 2);
	if ((config & (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN)) == 0)
		return (0);

	/* This video card is the boot display: record its unit number. */
	vga_pci_default_unit = unit;
	device_set_flags(dev, 1);

	return (1);
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:56,代码来源:vga_pci.c


示例14: bcm_mbox_write

void
bcm_mbox_write(int channel, uint32_t data)
{
	device_t mbox;

        mbox = devclass_get_device(devclass_find("mbox"), 0);

        if (mbox)
                MBOX_WRITE(mbox, channel, data);
}
开发者ID:brd,项目名称:vchiq-freebsd,代码行数:10,代码来源:vchi_bsd.c


示例15: acpi_battery_get_units

int
acpi_battery_get_units(void)
{
    devclass_t batt_dc;

    batt_dc = devclass_find("battery");
    if (batt_dc == NULL)
	return (0);
    return (devclass_get_count(batt_dc));
}
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:10,代码来源:acpi_battery.c


示例16: eisab_attach

static int
eisab_attach(device_t dev)
{
    /*
     * Attach an EISA bus.  Note that we can only have one EISA bus.
     */
    if (!devclass_get_device(devclass_find("eisa"), 0))
	device_add_child(dev, "eisa", -1);

    /*
     * Attach an ISA bus as well, since the EISA bus may have ISA
     * cards installed, and we may have no EISA support in the system.
     */
    if (!devclass_get_device(devclass_find("isa"), 0))
	device_add_child(dev, "isa", -1);

    bus_generic_attach(dev);

    return(0);
}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:20,代码来源:eisa_pci.c


示例17: ntb_setup_interface

static int
ntb_setup_interface(void)
{
	struct ifnet *ifp;
	struct ntb_queue_handlers handlers = { ntb_net_rx_handler,
	    ntb_net_tx_handler, ntb_net_event_handler };
	int rc;

	net_softc.ntb = devclass_get_softc(devclass_find("ntb_hw"), 0);
	if (net_softc.ntb == NULL) {
		printf("ntb: Cannot find devclass\n");
		return (ENXIO);
	}

	ifp = net_softc.ifp = if_alloc(IFT_ETHER);
	if (ifp == NULL) {
		ntb_transport_free(&net_softc);
		printf("ntb: Cannot allocate ifnet structure\n");
		return (ENOMEM);
	}
	if_initname(ifp, "ntb", 0);

	rc = ntb_transport_probe(net_softc.ntb);
	if (rc != 0) {
		printf("ntb: Cannot init transport: %d\n", rc);
		if_free(net_softc.ifp);
		return (rc);
	}

	net_softc.qp = ntb_transport_create_queue(ifp, net_softc.ntb,
	    &handlers);
	ifp->if_init = ntb_net_init;
	ifp->if_softc = &net_softc;
	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
	ifp->if_ioctl = ntb_ioctl;
	ifp->if_start = ntb_start;
	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
	IFQ_SET_READY(&ifp->if_snd);
	create_random_local_eui48(net_softc.eaddr);
	ether_ifattach(ifp, net_softc.eaddr);
	ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_JUMBO_MTU;
	ifp->if_capenable = ifp->if_capabilities;
	ifp->if_mtu = ntb_transport_max_size(net_softc.qp) - ETHER_HDR_LEN -
	    ETHER_CRC_LEN;

	ntb_transport_link_up(net_softc.qp);
	net_softc.bufsize = ntb_transport_max_size(net_softc.qp) +
	    sizeof(struct ether_header);
	return (0);
}
开发者ID:Digital-Chaos,项目名称:freebsd,代码行数:51,代码来源:if_ntb.c


示例18: acpi_pci_suspend

int
acpi_pci_suspend(device_t dev)
{
    int dstate, error, i, numdevs;
    device_t acpi_dev, child, *devlist;
    struct pci_devinfo *dinfo;

    acpi_dev = devclass_get_device(devclass_find("acpi"), 0);
    device_get_children(dev, &devlist, &numdevs);

    /*
     * Save the PCI configuration space for each child and set the
     * device in the appropriate power state for this sleep state.
     */
    for (i = 0; i < numdevs; i++) {
        child = devlist[i];
        dinfo = (struct pci_devinfo *)device_get_ivars(child);
        pci_cfg_save(child, dinfo, 0);
    }

    /*
     * Suspend devices before potentially powering them down.
     */
    error = bus_generic_suspend(dev);
    if (error) {
        kfree(devlist, M_TEMP);
        return (error);
    }

    /*
     * Always set the device to D3.  If ACPI suggests a different
     * power state, use it instead.  If ACPI is not present, the
     * firmware is responsible for managing device power.  Skip
     * children who aren't attached since they are powered down
     * separately.  Only manage type 0 devices for now.
     */
    for (i = 0; acpi_dev && i < numdevs; i++) {
        child = devlist[i];
        dinfo = (struct pci_devinfo *)device_get_ivars(child);
        if (device_is_attached(child) && dinfo->cfg.hdrtype == 0) {
            dstate = PCI_POWERSTATE_D3;
            ACPI_PWR_FOR_SLEEP(acpi_dev, child, &dstate);
            pci_set_powerstate(child, dstate);
        }
    }

    kfree(devlist, M_TEMP);
    return (0);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:49,代码来源:acpi_pci.c


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ devclass_get_device函数代码示例发布时间:2022-05-30
下一篇:
C++ devattach函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap