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


C++ OF_finddevice函数代码示例

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


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

示例1: ofw_cnprobe

static void
ofw_cnprobe(struct consdev *cp)
{
	int chosen;

	if ((chosen = OF_finddevice("/chosen")) == -1) {
		cp->cn_pri = CN_DEAD;
		return;
	}

	if (OF_getencprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) {
		cp->cn_pri = CN_DEAD;
		return;
	}

	if (OF_getencprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) {
		cp->cn_pri = CN_DEAD;
		return;
	}

	cp->cn_pri = CN_LOW;
}
开发者ID:OpenKod,项目名称:src,代码行数:22,代码来源:ofw_console.c

示例2: fsl_ocotp_devmap

static void
fsl_ocotp_devmap(void)
{
	phandle_t child, root;
	u_long base, size;

	if ((root = OF_finddevice("/")) == 0)
		goto fatal;
	if ((child = fdt_depth_search_compatible(root, "fsl,imx6q-ocotp", 0)) == 0)
		goto fatal;
	if (fdt_regsize(child, &base, &size) != 0)
		goto fatal;

	ocotp_size = (vm_size_t)size;

	if ((ocotp_regs = pmap_mapdev((vm_offset_t)base, ocotp_size)) == NULL)
		goto fatal;

	return;
fatal:
	panic("cannot find/map the ocotp registers");
}
开发者ID:MattDooner,项目名称:freebsd-west,代码行数:22,代码来源:fsl_ocotp.c

示例3: OF_getetheraddr

void
OF_getetheraddr(device_t dev, u_char *addr)
{
	char buf[sizeof("true")];
	phandle_t node;
	struct idprom idp;

	if ((node = OF_finddevice("/options")) > 0 &&
	    OF_getprop(node, "local-mac-address?", buf, sizeof(buf)) > 0) {
		buf[sizeof(buf) - 1] = '\0';
		if (strcmp(buf, "true") == 0 &&
		    (node = ofw_bus_get_node(dev)) > 0 &&
		    OF_getprop(node, "local-mac-address", addr,
		    ETHER_ADDR_LEN) == ETHER_ADDR_LEN)
			return;
	}

	node = OF_peer(0);
	if (node <= 0 || OF_getprop(node, "idprom", &idp, sizeof(idp)) == -1)
		panic("Could not determine the machine Ethernet address");
	bcopy(&idp.id_ether, addr, ETHER_ADDR_LEN);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:22,代码来源:ofw_machdep.c

示例4: openpic_ofw_probe

static int
openpic_ofw_probe(device_t dev)
{
	const char *type = ofw_bus_get_type(dev);

	if (type == NULL)
                return (ENXIO);

	if (!ofw_bus_is_compatible(dev, "chrp,open-pic") &&
	    strcmp(type, "open-pic") != 0)
                return (ENXIO);

	/*
	 * On some U4 systems, there is a phantom MPIC in the mac-io cell.
	 * The uninorth driver will pick up the real PIC, so ignore it here.
	 */
	if (OF_finddevice("/u4") != (phandle_t)-1)
		return (ENXIO);

	device_set_desc(dev, OPENPIC_DEVSTR);
	return (0);
}
开发者ID:OpenKod,项目名称:src,代码行数:22,代码来源:openpic_ofw.c

示例5: powermac_smp_first_cpu

static int
powermac_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
{
	char buf[8];
	phandle_t cpu, dev, root;
	int res;

	root = OF_peer(0);

	dev = OF_child(root);
	while (dev != 0) {
		res = OF_getprop(dev, "name", buf, sizeof(buf));
		if (res > 0 && strcmp(buf, "cpus") == 0)
			break;
		dev = OF_peer(dev);
	}
	if (dev == 0) {
		/*
		 * psim doesn't have a name property on the /cpus node,
		 * but it can be found directly
		 */
		dev = OF_finddevice("/cpus");
		if (dev == -1)
			return (ENOENT);
	}

	cpu = OF_child(dev);

	while (cpu != 0) {
		res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
		if (res > 0 && strcmp(buf, "cpu") == 0)
			break;
		cpu = OF_peer(cpu);
	}
	if (cpu == 0)
		return (ENOENT);

	return (powermac_smp_fill_cpuref(cpuref, cpu));
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:39,代码来源:platform_powermac.c

示例6: copy_rom_font

static int
copy_rom_font()
{
    u_char *romfont;
    int char_width, char_height;
    int chosen, mmu, m, e;

    /* Get ROM FONT address. */
    OF_interpret("font-adr", 0, 1, &romfont);
    if (romfont == NULL)
        return -1;

    chosen = OF_finddevice("/chosen");
    OF_getprop(chosen, "mmu", &mmu, 4);

    /*
     * Convert to physcal address.  We cannot access to Open Firmware's
     * virtual address space.
     */
    OF_call_method("translate", mmu, 1, 3, romfont, &romfont, &m, &e);

    /* Get character size */
    OF_interpret("char-width", 0, 1, &char_width);
    OF_interpret("char-height", 0, 1, &char_height);

    openfirm6x11.name = "Open Firmware";
    openfirm6x11.firstchar = 32;
    openfirm6x11.numchars = 96;
    openfirm6x11.encoding = WSDISPLAY_FONTENC_ISO;
    openfirm6x11.fontwidth = char_width;
    openfirm6x11.fontheight = char_height;
    openfirm6x11.stride = 1;
    openfirm6x11.bitorder = WSDISPLAY_FONTORDER_L2R;
    openfirm6x11.byteorder = WSDISPLAY_FONTORDER_L2R;
    openfirm6x11.data = romfont;

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

示例7: uart_phyp_cnprobe

static void
uart_phyp_cnprobe(struct consdev *cp)
{
	char buf[64];
	ihandle_t stdout;
	phandle_t input, chosen;
	static struct uart_phyp_softc sc;

	if ((chosen = OF_finddevice("/chosen")) == -1)
		goto fail;

	/* Check if OF has an active stdin/stdout */
	input = -1;
	if (OF_getprop(chosen, "stdout", &stdout,
	    sizeof(stdout)) == sizeof(stdout) && stdout != 0)
		input = OF_instance_to_package(stdout);
	if (input == -1)
		goto fail;

	if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1)
		goto fail;
	if (strcmp(buf, "serial") != 0)
		goto fail;

	sc.node = input;
	if (uart_phyp_probe_node(&sc) != 0)
		goto fail;
	mtx_init(&sc.sc_mtx, "uart_phyp", NULL, MTX_SPIN | MTX_QUIET |
	    MTX_NOWITNESS);

	cp->cn_pri = CN_NORMAL;
	console_sc = &sc;
	return;
	
fail:
	cp->cn_pri = CN_DEAD;
	return;
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:38,代码来源:phyp_console.c

示例8: aml8726_fixup_busfreq

static void
aml8726_fixup_busfreq(void)
{
	phandle_t node;
	pcell_t freq, prop;
	ssize_t len;

	/*
	 * Set the bus-frequency for the SoC simple-bus if it
	 * needs updating (meaning the current frequency is zero).
	 */

	if ((freq = aml8726_clkmsr_bus_frequency()) == 0 ||
	    (node = OF_finddevice("/soc")) == 0 ||
	    fdt_is_compatible_strict(node, "simple-bus") == 0)
		while (1);

	freq = cpu_to_fdt32(freq);

	len = OF_getencprop(node, "bus-frequency", &prop, sizeof(prop));
	if ((len / sizeof(prop)) == 1 && prop == 0)
		OF_setprop(node, "bus-frequency", (void *)&freq, sizeof(freq));
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:23,代码来源:aml8726_machdep.c

示例9: ofw_alloc_heap

void *
ofw_alloc_heap(unsigned int size)
{
	phandle_t	memoryp, root;
	cell_t		available[4];
	cell_t		acells;

	root = OF_finddevice("/");
	acells = 1;
	OF_getprop(root, "#address-cells", &acells, sizeof(acells));

	memoryp = OF_instance_to_package(memory);
	OF_getprop(memoryp, "available", available, sizeof(available));

	heap_base = OF_claim((void *)available[acells-1], size,
	    sizeof(register_t));

	if (heap_base != (void *)-1) {
		heap_size = size;
	}

	return (heap_base);
}
开发者ID:ele7enxxh,项目名称:dtrace-pf,代码行数:23,代码来源:ofw_memory.c

示例10: ofw_cons_probe

static void
ofw_cons_probe(struct consdev *cp)
{
	int chosen;

	if ((chosen = OF_finddevice("/chosen")) == -1) {
		cp->cn_pri = CN_DEAD;
		return;
	}

	if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) {
		cp->cn_pri = CN_DEAD;
		return;
	}

	if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) {
		cp->cn_pri = CN_DEAD;
		return;
	}

	cp->cn_dev = NULL;
	cp->cn_pri = CN_INTERNAL;
}
开发者ID:MarginC,项目名称:kame,代码行数:23,代码来源:ofw_console.c

示例11: main

int
main()
{
	int chosen;

	/*
	 * Get the boot arguments from Openfirmware
	 */
	if ((chosen = OF_finddevice("/chosen")) == -1 ||
	    OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 ||
	    OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) {
		printf("Invalid Openfirmware environment\n");
		exit();
	}
	prom2boot(bootdev);
	get_alt_bootdev(bootdev, sizeof(bootdev), bootline, sizeof(bootline));
	if (bootline[0] != '\0')
		kernelfile = bootline;

	OF_claim((void *)0x00100000, CLAIM_LIMIT, 0); /* XXX */
	boot(0);
	return 0;
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:23,代码来源:main.c

示例12: cn_drvinit

static void
cn_drvinit(void *unused)
{
    phandle_t options;
    char output[32];
    struct tty *tp;

    if (ofw_consdev.cn_pri != CN_DEAD &&
            ofw_consdev.cn_name[0] != '\0') {
        tp = tty_alloc(&ofw_ttydevsw, NULL);
        tty_makedev(tp, NULL, "%s", "ofwcons");

        /*
         * XXX: This is a hack and it may result in two /dev/ttya
         * XXX: devices on platforms where the sab driver works.
         */
        if ((options = OF_finddevice("/options")) == -1 ||
                OF_getprop(options, "output-device", output,
                           sizeof(output)) == -1)
            return;
        if (strlen(output) > 0)
            tty_makealias(tp, output);
    }
}
开发者ID:coyizumi,项目名称:cs111,代码行数:24,代码来源:ofw_console.c

示例13: l3remap

static int
l3remap(struct rstmgr_softc *sc, int remap, int enable)
{
	uint32_t addr, paddr;
	bus_addr_t vaddr;
	phandle_t node;
	int reg;

	/*
	 * Control whether bridge is visible to L3 masters or not.
	 * Register is write-only.
	 */

	reg = REMAP_MPUZERO;
	if (enable)
		reg |= (remap);
	else
		reg &= ~(remap);

	node = OF_finddevice("l3regs");
	if (node == -1) {
		device_printf(sc->dev, "Can't find l3regs node\n");
		return (1);
	}

	if ((OF_getprop(node, "reg", &paddr, sizeof(paddr))) > 0) {
		addr = fdt32_to_cpu(paddr);
		if (bus_space_map(fdtbus_bs_tag, addr, 0x4, 0, &vaddr) == 0) {
			bus_space_write_4(fdtbus_bs_tag, vaddr,
			    L3REGS_REMAP, reg);
			return (0);
		}
	}

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

示例14: cpu_reset

void
cpu_reset(void)
{
	uint32_t paddr;
	bus_addr_t vaddr;
	phandle_t node;

	if (rstmgr_warmreset() == 0)
		goto end;

	node = OF_finddevice("rstmgr");
	if (node == -1)
		goto end;

	if ((OF_getencprop(node, "reg", &paddr, sizeof(paddr))) > 0) {
		if (bus_space_map(fdtbus_bs_tag, paddr, 0x8, 0, &vaddr) == 0) {
			bus_space_write_4(fdtbus_bs_tag, vaddr,
			    RSTMGR_CTRL, CTRL_SWWARMRSTREQ);
		}
	}

end:
	while (1);
}
开发者ID:kwitaszczyk,项目名称:freebsd,代码行数:24,代码来源:socfpga_common.c

示例15: pmu_attach

static void
pmu_attach(device_t parent, device_t self, void *aux)
{
	struct confargs *ca = aux;
	struct pmu_softc *sc = device_private(self);
#if notyet
	struct i2cbus_attach_args iba;
#endif
	uint32_t regs[16];
	int irq = ca->ca_intr[0];
	int node, extint_node, root_node;
	int nbat = 1, i, pmnode;
	int type = IST_EDGE;
	uint8_t cmd[2] = {2, 0};
	uint8_t resp[16];
	char name[256];

	extint_node = of_getnode_byname(OF_parent(ca->ca_node), "extint-gpio1");
	if (extint_node) {

		OF_getprop(extint_node, "interrupts", &irq, 4);
		type = IST_LEVEL;
	}

	aprint_normal(" irq %d: ", irq);

	sc->sc_dev = self;
	sc->sc_node = ca->ca_node;
	sc->sc_memt = ca->ca_tag;

	root_node = OF_finddevice("/");

	sc->sc_error = 0;
	sc->sc_autopoll = 0;
	sc->sc_pending_eject = 0;
	sc->sc_brightness = sc->sc_brightness_wanted = 0x80;
	sc->sc_volume = sc->sc_volume_wanted = 0x80;
	sc->sc_flags = 0;
	sc->sc_callback = NULL;
	sc->sc_lid_closed = 0;

	if (bus_space_map(sc->sc_memt, ca->ca_reg[0] + ca->ca_baseaddr,
	    ca->ca_reg[1], 0, &sc->sc_memh) != 0) {
		aprint_error_dev(self, "unable to map registers\n");
		return;
	}
	sc->sc_ih = intr_establish(irq, type, IPL_TTY, pmu_intr, sc);

	pmu_init(sc);

	sc->sc_pmu_ops.cookie = sc;
	sc->sc_pmu_ops.do_command = pmu_send;
	sc->sc_pmu_ops.register_callback = pmu_register_callback;

	if (pmu0 == NULL)
		pmu0 = sc;

	pmu_send(sc, PMU_SYSTEM_READY, 1, cmd, 16, resp);

	/* check what kind of PMU we're talking to */
	if (pmu_send(sc, PMU_GET_VERSION, 0, cmd, 16, resp) > 1)
		aprint_normal(" rev. %d", resp[1]);
	aprint_normal("\n");

	node = OF_child(sc->sc_node);

	while (node != 0) {

		if (OF_getprop(node, "name", name, 256) == 0)
			goto next;

		if (strncmp(name, "pmu-i2c", 8) == 0) {
			aprint_normal_dev(self, "initializing IIC bus\n");
			goto next;
		}
		if (strncmp(name, "adb", 4) == 0) {
			aprint_normal_dev(self, "initializing ADB\n");
			sc->sc_adbops.cookie = sc;
			sc->sc_adbops.send = pmu_adb_send;
			sc->sc_adbops.poll = pmu_adb_poll;
			sc->sc_adbops.autopoll = pmu_autopoll;
			sc->sc_adbops.set_handler = pmu_adb_set_handler;
#if NNADB > 0
			config_found_ia(self, "adb_bus", &sc->sc_adbops,
			    nadb_print);
#endif
			goto next;
		}
		if (strncmp(name, "rtc", 4) == 0) {

			aprint_normal_dev(self, "initializing RTC\n");
			sc->sc_todr.todr_gettime = pmu_todr_get;
			sc->sc_todr.todr_settime = pmu_todr_set;
			sc->sc_todr.cookie = sc;
			todr_attach(&sc->sc_todr);
			goto next;
		}
		if (strncmp(name, "battery", 8) == 0)
			goto next;

//.........这里部分代码省略.........
开发者ID:ycui1984,项目名称:netbsd-src,代码行数:101,代码来源:pmu.c


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