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


C++ devclass_get_device函数代码示例

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


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

示例1: wds_print

/* for debugging, print out all the data about the status of devices */
void
wds_print(void)
{
	int	unit;
	int	i;
	struct	wds_req *r;
	struct	wds     *wp;

	for (unit = 0; unit < devclass_get_maxunit(wds_devclass); unit++) {
		wp = (struct wds *) devclass_get_device(wds_devclass, unit);
		if (wp == NULL)
			continue;
		printf("wds%d: want_wdsr=0x%x stat=0x%x irq=%s irqstat=0x%x\n",
		       unit, wp->want_wdsr, inb(wp->addr + WDS_STAT) & 0xff,
		       (inb(wp->addr + WDS_STAT) & WDS_IRQ) ? "ready" : "no",
		       inb(wp->addr + WDS_IRQSTAT) & 0xff);
		for (i = 0; i < MAXSIMUL; i++) {
			r = &wp->dx->req[i];
			if( wp->wdsr_free & (1 << r->id) ) {
				printf("req=%d flg=0x%x ombn=%d ombstat=%d "
				       "mask=0x%x targ=%d lun=%d cmd=0x%x\n",
				       i, r->flags, r->ombn,
				       wp->dx->ombs[r->ombn].stat,
				       r->mask, r->cmd.targ >> 5,
				       r->cmd.targ & 7, r->cmd.scb[0]);
			}
		}
	}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:29,代码来源:wd7000.c

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

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

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

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

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

示例7: acpi_cmbat_ioctl

static int
acpi_cmbat_ioctl(u_long cmd, caddr_t addr, void *arg)
{
	device_t	dev;
	union acpi_battery_ioctl_arg *ioctl_arg;
	struct acpi_cmbat_softc *sc;
	struct acpi_bif	*bifp;
	struct acpi_bst	*bstp;

	ioctl_arg = (union acpi_battery_ioctl_arg *)addr;
	if ((dev = devclass_get_device(acpi_cmbat_devclass,
			ioctl_arg->unit)) == NULL) {
		return (ENXIO);
	}

	if ((sc = device_get_softc(dev)) == NULL) {
		return (ENXIO);
	}

        /*
         * No security check required: information retrieval only.  If
         * new functions are added here, a check might be required.
         */
	
	switch (cmd) {
	case ACPIIO_CMBAT_GET_BIF:
		acpi_cmbat_get_bif(dev);
		bifp = &ioctl_arg->bif;
		bifp->unit = sc->bif.unit;
		bifp->dcap = sc->bif.dcap;
		bifp->lfcap = sc->bif.lfcap;
		bifp->btech = sc->bif.btech;
		bifp->dvol = sc->bif.dvol;
		bifp->wcap = sc->bif.wcap;
		bifp->lcap = sc->bif.lcap;
		bifp->gra1 = sc->bif.gra1;
		bifp->gra2 = sc->bif.gra2;
		strncpy(bifp->model, sc->bif.model, sizeof(sc->bif.model));
		strncpy(bifp->serial, sc->bif.serial, sizeof(sc->bif.serial));
		strncpy(bifp->type, sc->bif.type, sizeof(sc->bif.type));
		strncpy(bifp->oeminfo, sc->bif.oeminfo, sizeof(sc->bif.oeminfo));
		break;

	case ACPIIO_CMBAT_GET_BST:
		bstp = &ioctl_arg->bst;
		if (acpi_BatteryIsPresent(dev)) {
			acpi_cmbat_get_bst(dev);
			bstp->state = sc->bst.state;
			bstp->rate = sc->bst.rate;
			bstp->cap = sc->bst.cap;
			bstp->volt = sc->bst.volt;
		} else
			bstp->state = ACPI_BATT_STAT_NOT_PRESENT;
		break;
	}

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

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

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

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

示例11: acpi_hpet_identify

/*
 * Locate the ACPI timer using the FADT, set up and allocate the I/O resources
 * we will be using.
 */
static int
acpi_hpet_identify(driver_t *driver, device_t parent)
{
	ACPI_TABLE_HPET *hpet;
	ACPI_TABLE_HEADER *hdr;
	ACPI_STATUS status;
	device_t child;

	/*
	 * Just try once, do nothing if the 'acpi' bus is rescanned.
	 */
	if (device_get_state(parent) == DS_ATTACHED)
		return 0;

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

	/* Only one HPET device can be added. */
	if (devclass_get_device(acpi_hpet_devclass, 0))
		return ENXIO;

	/* Currently, ID and minimum clock tick info is unused. */

	status = AcpiGetTable(ACPI_SIG_HPET, 1, &hdr);
	if (ACPI_FAILURE(status))
		return ENXIO;

	/*
	 * The unit number could be derived from hdr->Sequence but we only
	 * support one HPET device.
	 */
	hpet = (ACPI_TABLE_HPET *)hdr;
	if (hpet->Sequence != 0) {
		kprintf("ACPI HPET table warning: Sequence is non-zero (%d)\n",
			hpet->Sequence);
	}

	child = BUS_ADD_CHILD(parent, parent, 0, "acpi_hpet", 0);
	if (child == NULL) {
		device_printf(parent, "%s: can't add acpi_hpet0\n", __func__);
		return ENXIO;
	}

	/* Record a magic value so we can detect this device later. */
	acpi_set_magic(child, (uintptr_t)&acpi_hpet_devclass);

	acpi_hpet_res_start = hpet->Address.Address;
	if (bus_set_resource(child, SYS_RES_MEMORY, 0,
			     hpet->Address.Address, HPET_MEM_WIDTH, -1)) {
		device_printf(child, "could not set iomem resources: "
			      "0x%jx, %d\n", (uintmax_t)hpet->Address.Address,
			      HPET_MEM_WIDTH);
		return ENOMEM;
	}
	return 0;
}
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:59,代码来源:acpi_hpet.c

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

示例13: ata_pci_attach

int
ata_pci_attach(device_t dev)
{
    struct ata_pci_controller *ctlr = device_get_softc(dev);
    u_int32_t cmd;
    int unit;

    /* do chipset specific setups only needed once */
    ctlr->legacy = ata_legacy(dev);
    if (ctlr->legacy || pci_read_config(dev, PCIR_BAR(2), 4) & IOMASK)
	ctlr->channels = 2;
    else
	ctlr->channels = 1;
    ctlr->allocate = ata_pci_allocate;
    ctlr->dev = dev;

    /* if needed try to enable busmastering */
    cmd = pci_read_config(dev, PCIR_COMMAND, 2);
    if (!(cmd & PCIM_CMD_BUSMASTEREN)) {
	pci_write_config(dev, PCIR_COMMAND, cmd | PCIM_CMD_BUSMASTEREN, 2);
	cmd = pci_read_config(dev, PCIR_COMMAND, 2);
    }

    /* if busmastering mode "stuck" use it */
    if ((cmd & PCIM_CMD_BUSMASTEREN) == PCIM_CMD_BUSMASTEREN) {
	ctlr->r_type1 = SYS_RES_IOPORT;
	ctlr->r_rid1 = ATA_BMADDR_RID;
	ctlr->r_res1 = bus_alloc_resource_any(dev, ctlr->r_type1, &ctlr->r_rid1,
					      RF_ACTIVE);
	/* Only set a dma init function if the device actually supports it. */
        ctlr->dmainit = ata_pci_dmainit;
    }

    if (ctlr->chipinit(dev))
	return ENXIO;

    /* attach all channels on this controller */
    for (unit = 0; unit < ctlr->channels; unit++) {
	int freeunit = 2;
	if ((unit == 0 || unit == 1) && ctlr->legacy) {
	    device_add_child(dev, "ata", unit);
	    continue;
	}
	/* XXX TGEN devclass_find_free_unit() implementation */
	if (ata_devclass) {
		while (freeunit < devclass_get_maxunit(ata_devclass) &&
		    devclass_get_device(ata_devclass, freeunit) != NULL)
			freeunit++;
	}
	device_add_child(dev, "ata", freeunit);
    }
    bus_generic_attach(dev);
    return 0;
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:54,代码来源:ata-pci.c

示例14: xenpci_alloc_space

/*
 * Allocate a physical address range from our mmio region.
 */
int
xenpci_alloc_space(size_t sz, vm_paddr_t *pa)
{
	device_t dev = devclass_get_device(xenpci_devclass, 0);

	if (dev) {
		return (xenpci_alloc_space_int(device_get_softc(dev),
			sz, pa));
	} else {
		return (ENOMEM);
	}
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:15,代码来源:xenpci.c

示例15: acpi_isab_probe

static int
acpi_isab_probe(device_t dev)
{
	static char *isa_ids[] = { "PNP0A05", "PNP0A06", NULL };

	if (acpi_disabled("isab") ||
	    ACPI_ID_PROBE(device_get_parent(dev), dev, isa_ids) == NULL ||
	    devclass_get_device(isab_devclass, 0) != dev)
		return (ENXIO);

	device_set_desc(dev, "ACPI Generic ISA bridge");
	return (0);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:13,代码来源:acpi_isab.c


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