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


C++ device_unit函数代码示例

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


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

示例1: mtattach

static void
mtattach(device_t parent, device_t self, void *aux)
{
	struct mt_softc *sc = device_private(self);
	struct hpibbus_attach_args *ha = aux;
	int unit, hpibno, slave;

	sc->sc_dev = self;
	if (mtident(sc, ha) == 0) {
		aprint_error(": impossible!\n");
		return;
	}

	unit = device_unit(self);
	hpibno = device_unit(parent);
	slave = ha->ha_slave;

	bufq_alloc(&sc->sc_tab, "fcfs", 0);
	callout_init(&sc->sc_start_ch, 0);
	callout_init(&sc->sc_intr_ch, 0);

	sc->sc_hpibno = hpibno;
	sc->sc_slave = slave;
	sc->sc_flags = MTF_EXISTS;

	/* Initialize hpib job queue entry. */
	sc->sc_hq.hq_softc = sc;
	sc->sc_hq.hq_slave = sc->sc_slave;
	sc->sc_hq.hq_start = mtstart;
	sc->sc_hq.hq_go = mtgo;
	sc->sc_hq.hq_intr = mtintr;
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:32,代码来源:mt.c

示例2: ahc_isa_probe

/*
 * Check the slots looking for a board we recognise
 * If we find one, note its address (slot) and call
 * the actual probe routine to check it out.
 */
int
ahc_isa_probe(device_t parent, cfdata_t match, void *aux)
{
	struct isa_attach_args *ia = aux;
	struct ahc_isa_slot *as;

	if (ahc_isa_slot_initialized == 0) {
		LIST_INIT(&ahc_isa_all_slots);
		ahc_isa_slot_initialized = 1;
	}

	if (ia->ia_nio < 1)
		return (0);
	if (ia->ia_nirq < 1)
		return (0);

	if (ISA_DIRECT_CONFIG(ia))
		return (0);

	if (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT)
		return (ahc_isa_match(ia, ia->ia_io[0].ir_addr));

	/*
	 * Find this bus's state.  If we don't yet have a slot
	 * marker, allocate and initialize one.
	 */
	for (as = ahc_isa_all_slots.lh_first; as != NULL;
	    as = as->link.le_next)
		if (as->bus == device_unit(parent))
			goto found_slot_marker;

	/*
	 * Don't have one, so make one.
	 */
	as = (struct ahc_isa_slot *)
	    malloc(sizeof(struct ahc_isa_slot), M_DEVBUF, M_NOWAIT);
	if (as == NULL)
		panic("ahc_isa_probe: can't allocate slot marker");

	as->bus = device_unit(parent);
	as->slot = AHC_ISA_MIN_SLOT;
	LIST_INSERT_HEAD(&ahc_isa_all_slots, as, link);

 found_slot_marker:

	for (; as->slot <= AHC_ISA_MAX_SLOT; as->slot++) {
		if (ahc_isa_match(ia, EISA_SLOT_ADDR(as->slot) +
		    AHC_ISA_SLOT_OFFSET)) {
			as->slot++; /* next slot to search */
			return (1);
		}
	}

	/* No matching cards were found. */
	return (0);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:61,代码来源:ahc_isa.c

示例3: device_register

/*
 * Attempt to find the device from which we were booted.
 */
void
device_register(struct device *dev, void *aux)
{
	struct bootdev_data *b = bootdev_data;
	struct device *parent = device_parent(dev);

	static int found = 0, initted = 0, scsiboot = 0;
	static struct device *scsibusdev = NULL;

	if (b == NULL)
		return;	/* There is no hope. */
	if (found)
		return;

	if (!initted) {
		if (strcmp(b->dev_type, "sd") == 0)
			scsiboot = 1;
		initted = 1;
	}

	if (scsiboot && device_is_a(dev, "scsibus")) {
		/* XXX device_unit() abuse */
		if (device_unit(dev) == b->bus) {
			scsibusdev = dev;
#if 0
			printf("\nscsibus = %s\n", dev->dv_xname);
#endif
		}
		return;
	}

	if (!device_is_a(dev, b->dev_type))
		return;

	if (device_is_a(dev, "sd")) {
		struct scsipibus_attach_args *sa = aux;

		if (scsiboot && scsibusdev && parent == scsibusdev &&
		    sa->sa_periph->periph_target == b->unit) {
			booted_device = dev;
#if 0
			printf("\nbooted_device = %s\n", dev->dv_xname);
#endif
			found = 1;
		}
		return;
	}
	/* XXX device_unit() abuse */
	if (device_unit(dev) == b->unit) {
		booted_device = dev;
#if 0
		printf("\nbooted_device = %s\n", dev->dv_xname);
#endif
		found = 1;
	}
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:59,代码来源:autoconf.c

示例4: ssdetach

static int
ssdetach(device_t self, int flags)
{
	struct ss_softc *ss = device_private(self);
	int s, cmaj, mn;

	/* locate the major number */
	cmaj = cdevsw_lookup_major(&ss_cdevsw);

	/* kill any pending restart */
	callout_stop(&ss->sc_callout);

	s = splbio();

	/* Kill off any queued buffers. */
	bufq_drain(ss->buf_queue);

	bufq_free(ss->buf_queue);

	/* Kill off any pending commands. */
	scsipi_kill_pending(ss->sc_periph);

	splx(s);

	/* Nuke the vnodes for any open instances */
	mn = SSUNIT(device_unit(self));
	vdevgone(cmaj, mn, mn+SSNMINOR-1, VCHR);

	return 0;
}
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:30,代码来源:ss.c

示例5: vme_attach

static void 
vme_attach(device_t parent, device_t self, void *args)
{
	struct confargs *ca = aux;
	struct vme_softc *sc = device_private(self);
	struct confargs vmea;
	int unit;

	sc->sc_dev = self;

	unit = device_unit(self);
	aprint_normal(": (%s)\n", vme_info[unit].name);

	sc->sc_bustag = ca->ca_bustag;
	sc->sc_dmatag = ca->ca_dmatag;
	sc->sc_bustype = unit;

	vme_space_tag.cookie = sc;
	vme_space_tag.parent = sc->sc_bustag;

	vme_dma_tag = *sc->sc_dmatag;
	vme_dma_tag._cookie = sc;
	vme_dma_tag._dmamap_load = vme_dmamap_load;

	vmea = *ca;
	vmea.ca_bustag = &vme_space_tag;
	vmea.ca_dmatag = &vme_dma_tag;

	/* We know ca_bustype == BUS_VMExx */
	config_search_ia(bus_scan, self, "vme", args);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:31,代码来源:vme.c

示例6: md_attach

static void
md_attach(device_t parent, device_t self,
          void *aux)
{
    struct md_softc *sc = device_private(self);

    bufq_alloc(&sc->sc_buflist, "fcfs", 0);

    /* XXX - Could accept aux info here to set the config. */
#ifdef	MEMORY_DISK_HOOKS
    /*
     * This external function might setup a pre-loaded disk.
     * All it would need to do is setup the md_conf struct.
     * See sys/dev/md_root.c for an example.
     */
    md_attach_hook(device_unit(self), &sc->sc_md);
#endif

    /*
     * Initialize and attach the disk structure.
     */
    disk_init(&sc->sc_dkdev, device_xname(self), &mddkdriver);
    disk_attach(&sc->sc_dkdev);

    if (!pmf_device_register(self, NULL, NULL))
        aprint_error_dev(self, "couldn't establish power handler\n");
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:27,代码来源:md.c

示例7: sacom_detach

/* This is necessary when dynamically changing SAIP configuration. */
int
sacom_detach(struct device *self, int flags)
{
    struct sacom_softc *sc = (struct sacom_softc *)self;
    int maj, mn;

    /* locate the major number */
    maj = cdevsw_lookup_major(&sacom_cdevsw);

    /* Nuke the vnodes for any open instances. */
    mn = device_unit(self);
    vdevgone(maj, mn, mn, VCHR);

    mn |= COMDIALOUT_MASK;
    vdevgone(maj, mn, mn, VCHR);

    /* Free the receive buffer. */
    free(sc->sc_rbuf, M_DEVBUF);

    /* Detach and free the tty. */
    tty_detach(sc->sc_tty);
    ttyfree(sc->sc_tty);

    /* Unhook the soft interrupt handler. */
    softint_disestablish(sc->sc_si);

#if NRND > 0 && defined(RND_COM)
    /* Unhook the entropy source. */
    rnd_detach_source(&sc->rnd_source);
#endif

    return 0;
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:34,代码来源:sa11x0_com.c

示例8: rdmatch

static int
rdmatch(device_t parent, cfdata_t cf, void *aux)
{
	struct hpibbus_attach_args *ha = aux;

	/*
	 * Set punit if operator specified one in the kernel
	 * configuration file.
	 */
	if (cf->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT &&
	    cf->hpibbuscf_punit < HPIB_NPUNITS)
		ha->ha_punit = cf->hpibbuscf_punit;

	if (rdident(parent, NULL, ha) == 0) {
		/*
		 * XXX Some aging HP-IB drives are slow to
		 * XXX respond; give them a chance to catch
		 * XXX up and probe them again.
		 */
		delay(10000);
		ha->ha_id = hpibid(device_unit(parent), ha->ha_slave);
		return rdident(parent, NULL, ha);
	}
	return 1;
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:25,代码来源:rd.c

示例9: bcm2835gpio_gpio_pin_ctl

static void
bcm2835gpio_gpio_pin_ctl(void *arg, int pin, int flags)
{
	struct bcmgpio_softc *sc = arg;
	uint32_t cmd;
	int epin = pin + device_unit(sc->sc_dev) * 32;
	
	if (device_unit(sc->sc_dev) > 1) {
		return;
	}
	
	DPRINTF(2, ("%s: gpio_ctl pin %d flags 0x%x\n", device_xname(sc->sc_dev), epin, flags));

	if (flags & (GPIO_PIN_OUTPUT|GPIO_PIN_INPUT)) {
		if ((flags & GPIO_PIN_INPUT) || !(flags & GPIO_PIN_OUTPUT)) {
			/* for safety INPUT will overide output */
	                bcm2835gpio_function_select(epin, BCM2835_GPIO_IN);
                } else {
	                bcm2835gpio_function_select(epin, BCM2835_GPIO_OUT);
		}
	}

	if (flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) {
		cmd = (flags & GPIO_PIN_PULLUP) ?
			BCM2835_GPIO_GPPUD_PULLUP : BCM2835_GPIO_GPPUD_PULLDOWN;
	} else {
		cmd = BCM2835_GPIO_GPPUD_PULLOFF;
	}

	/* set up control signal */
	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
		BCM2835_GPIO_GPPUD, cmd);
	delay(1); /* wait 150 cycles */
	/* set clock signal */
	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
		BCM2835_GPIO_GPPUDCLK(device_unit(sc->sc_dev)),
		1 << (epin % BCM2835_GPIO_GPPUD_PINS_PER_REGISTER));
	delay(1); /* wait 150 cycles */
	/* reset control signal and clock */
	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
		BCM2835_GPIO_GPPUD, BCM2835_GPIO_GPPUD_PULLOFF);	
	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
		BCM2835_GPIO_GPPUDCLK(device_unit(sc->sc_dev)),
		0);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:45,代码来源:bcm2835_gpio.c

示例10: rlopen

int
rlopen(dev_t dev, int flag, int fmt, struct lwp *l)
{
	struct rl_softc * const rc = device_lookup_private(&rl_cd, DISKUNIT(dev));
	struct rlc_softc *sc;
	int error, part, mask;
	struct disklabel *dl;
	const char *msg;

	/*
	 * Make sure this is a reasonable open request.
	 */
	if (rc == NULL)
		return ENXIO;

	sc = rc->rc_rlc;
	part = DISKPART(dev);

	mutex_enter(&rc->rc_disk.dk_openlock);

	/*
	 * If there are wedges, and this is not RAW_PART, then we
	 * need to fail.
	 */
	if (rc->rc_disk.dk_nwedges != 0 && part != RAW_PART) {
		error = EBUSY;
		goto bad1;
	}

	/* Check that the disk actually is useable */
	msg = rlstate(sc, rc->rc_hwid);
	if (msg == NULL || msg == rlstates[RLMP_UNLOAD] ||
	    msg == rlstates[RLMP_SPUNDOWN]) {
		error = ENXIO;
		goto bad1;
	}
	/*
	 * If this is the first open; read in where on the disk we are.
	 */
	dl = rc->rc_disk.dk_label;
	if (rc->rc_state == DK_CLOSED) {
		u_int16_t mp;
		int maj;
		RL_WREG(RL_CS, RLCS_RHDR|(rc->rc_hwid << RLCS_USHFT));
		waitcrdy(sc);
		mp = RL_RREG(RL_MP);
		rc->rc_head = ((mp & RLMP_HS) == RLMP_HS);
		rc->rc_cyl = (mp >> 7) & 0777;
		rc->rc_state = DK_OPEN;
		/* Get disk label */
		maj = cdevsw_lookup_major(&rl_cdevsw);
		if ((msg = readdisklabel(MAKEDISKDEV(maj,
		    device_unit(rc->rc_dev), RAW_PART), rlstrategy, dl, NULL)))
			aprint_normal_dev(rc->rc_dev, "%s", msg);
		aprint_normal_dev(rc->rc_dev, "size %d sectors\n",
		    dl->d_secperunit);
	}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:57,代码来源:rl.c

示例11: parstart

void
parstart(void *arg)
{
	struct par_softc *sc = arg;
#ifdef DEBUG
	if (pardebug & PDB_FOLLOW)
		printf("parstart(%x)\n", device_unit(sc->sc_dev));
#endif
	sc->sc_flags &= ~PARF_DELAY;
	wakeup(sc);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:11,代码来源:par.c

示例12: partimo

void
partimo(void *arg)
{
	struct par_softc *sc = arg;
#ifdef DEBUG
	if (pardebug & PDB_FOLLOW)
		printf("partimo(%x)\n", device_unit(sc->sc_dev));
#endif
	sc->sc_flags &= ~(PARF_UIO|PARF_TIMO);
	wakeup(sc);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:11,代码来源:par.c

示例13: bcm2835gpio_gpio_pin_write

static void
bcm2835gpio_gpio_pin_write(void *arg, int pin, int value)
{
	struct bcmgpio_softc *sc = arg;
	int epin = pin + device_unit(sc->sc_dev) * 32;
	bus_size_t reg;
	
	if (device_unit(sc->sc_dev) > 1) {
		return;
	}
	
	if (value == GPIO_PIN_HIGH) {
		reg = BCM2835_GPIO_GPSET(epin / BCM2835_GPIO_GPSET_PINS_PER_REGISTER);
	} else {
		reg = BCM2835_GPIO_GPCLR(epin / BCM2835_GPIO_GPCLR_PINS_PER_REGISTER);
	}
	
	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
		reg, 1 << (epin % BCM2835_GPIO_GPSET_PINS_PER_REGISTER));
	DPRINTF(2, ("%s: gpio_write pin %d<-%d\n", device_xname(sc->sc_dev), epin, (value == GPIO_PIN_HIGH)));
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:21,代码来源:bcm2835_gpio.c

示例14: target_to_unit

static int
target_to_unit(u_long bus, u_long target, u_long lun)
{
    struct scsibus_softc	*scsi;
    struct scsipi_periph	*periph;
    extern	struct cfdriver		scsibus_cd;

    if (target < 0 || target > 7 || lun < 0 || lun > 7) {
        printf("scsi target to unit, target (%ld) or lun (%ld)"
               " out of range.\n", target, lun);
        return -1;
    }

    if (bus == -1) {
        for (bus = 0 ; bus < scsibus_cd.cd_ndevs ; bus++) {
            scsi = device_lookup_private(&scsibus_cd, bus);
            if (!scsi)
                continue;
            periph = scsipi_lookup_periph(scsi->sc_channel,
                                          target, lun);
            if (!periph)
                continue;
            return device_unit(periph->periph_dev);
        }
        return -1;
    }
    if (bus < 0 || bus >= scsibus_cd.cd_ndevs) {
        printf("scsi target to unit, bus (%ld) out of range.\n", bus);
        return -1;
    }
    scsi = device_lookup_private(&scsibus_cd, bus);
    if (!scsi)
        return -1;

    periph = scsipi_lookup_periph(scsi->sc_channel,
                                  target, lun);
    if (!periph)
        return -1;
    return device_unit(periph->periph_dev);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:40,代码来源:autoconf.c

示例15: bcm2835gpio_gpio_pin_read

/* GPIO support functions */
static int
bcm2835gpio_gpio_pin_read(void *arg, int pin)
{
	struct bcmgpio_softc *sc = arg;
	int epin = pin + device_unit(sc->sc_dev) * 32;
	uint32_t val;
	int res;

	if (device_unit(sc->sc_dev) > 1) {
		return 0;
	}
	
	val = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
		BCM2835_GPIO_GPLEV(epin / BCM2835_GPIO_GPLEV_PINS_PER_REGISTER));

	res = val & (1 << (epin % BCM2835_GPIO_GPLEV_PINS_PER_REGISTER)) ?
		GPIO_PIN_HIGH : GPIO_PIN_LOW;

	DPRINTF(2, ("%s: gpio_read pin %d->%d\n", device_xname(sc->sc_dev), epin, (res == GPIO_PIN_HIGH)));
	
	return res;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:23,代码来源:bcm2835_gpio.c


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