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

C++ prom_getproplen函数代码示例

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

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



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

示例1: i_cpr_is_supported

int
i_cpr_is_supported(int sleeptype)
{
	char es_prop[] = "energystar-v2";
	pnode_t node;
	int last;
	extern int cpr_supported_override;
	extern int cpr_platform_enable;

	if (sleeptype != CPR_TODISK)
		return (0);

	/*
	 * The next statement tests if a specific platform has turned off
	 * cpr support.
	 */
	if (cpr_supported_override)
		return (0);

	/*
	 * Do not inspect energystar-v* property if a platform has
	 * specifically turned on cpr support
	 */
	if (cpr_platform_enable)
		return (1);

	node = prom_rootnode();
	if (prom_getproplen(node, es_prop) != -1)
		return (1);
	last = strlen(es_prop) - 1;
	es_prop[last] = '3';
	return (prom_getproplen(node, es_prop) != -1);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:33,代码来源:cpr_impl.c


示例2: getlongprop_buf

/*
 * Note that this routine does not take into account the endianness
 * of the host or the device (or PROM) when retrieving properties.
 */
static int
getlongprop_buf(int id, char *name, char *buf, int maxlen)
{
	int size;

	size = prom_getproplen((pnode_t)id, name);
	if (size <= 0 || (size > maxlen - 1))
		return (-1);

	if (-1 == prom_getprop((pnode_t)id, name, buf))
		return (-1);

	/*
	 * Workaround for bugid 1085575 - OBP may return a "name" property
	 * without null terminating the string with '\0'.  When this occurs,
	 * append a '\0' and return (size + 1).
	 */
	if (strcmp("name", name) == 0) {
		if (buf[size - 1] != '\0') {
			buf[size] = '\0';
			size += 1;
		}
	}

	return (size);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:30,代码来源:mach_ddi_impl.c


示例3: mc_get_dimm_size

int
mc_get_dimm_size(pnode_t nodeid)
{
	uint64_t	psi_addr;
	uint_t		dimmtype;
	int		i, rlen;
	struct sf_memunit_regspec	reg;

	rlen = prom_getproplen(nodeid, "reg");
	if (rlen != sizeof (struct sf_memunit_regspec))
		return (-1);

	if (prom_getprop(nodeid, "reg", (caddr_t)&reg) < 0)
		return (-1);

	psi_addr = ((uint64_t)reg.regspec_addr_hi) << 32;
	psi_addr |= (uint64_t)reg.regspec_addr_lo;
	psi_addr = STARFIRE_MC_DIMMTYPE_ADDR(psi_addr);

	if (psi_addr == (uint64_t)-1)
		return (-1);

	dimmtype = ldphysio(psi_addr);
	dimmtype &= STARFIRE_MC_DIMMSIZE_MASK;

	for (i = 0; dimmsize_table[i].mc_type != 0; i++)
		if (dimmsize_table[i].mc_type == dimmtype)
			break;

	return (dimmsize_table[i].mc_module_size);
}
开发者ID:andreiw,项目名称:polaris,代码行数:31,代码来源:memctrl.c


示例4: read_obp_memory

static void __init read_obp_memory(const char *property,
				   struct linux_prom64_registers *regs,
				   int *num_ents)
{
	int node = prom_finddevice("/memory");
	int prop_size = prom_getproplen(node, property);
	int ents, ret, i;

	ents = prop_size / sizeof(struct linux_prom64_registers);
	if (ents > MAX_BANKS) {
		prom_printf("The machine has more %s property entries than "
			    "this kernel can support (%d).\n",
			    property, MAX_BANKS);
		prom_halt();
	}

	ret = prom_getproperty(node, property, (char *) regs, prop_size);
	if (ret == -1) {
		prom_printf("Couldn't get %s property from /memory.\n");
		prom_halt();
	}

	/* Sanitize what we got from the firmware, by page aligning
	 * everything.
	 */
	for (i = 0; i < ents; i++) {
		unsigned long base, size;

		base = regs[i].phys_addr;
		size = regs[i].reg_size;

		size &= PAGE_MASK;
		if (base & ~PAGE_MASK) {
			unsigned long new_base = PAGE_ALIGN(base);

			size -= new_base - base;
			if ((long) size < 0L)
				size = 0UL;
			base = new_base;
		}
		if (size == 0UL) {
			/* If it is empty, simply get rid of it.
			 * This simplifies the logic of the other
			 * functions that process these arrays.
			 */
			memmove(&regs[i], &regs[i + 1],
				(ents - i - 1) * sizeof(regs[0]));
			i--;
			ents--;
			continue;
		}
		regs[i].phys_addr = base;
		regs[i].reg_size = size;
	}

	*num_ents = ents;

	sort(regs, ents, sizeof(struct linux_prom64_registers),
	     cmp_p64, NULL);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:60,代码来源:init.c


示例5: prom_getprop

int
prom_getprop(pnode_t nodeid, caddr_t name, caddr_t value)
{
	int len, rv;
	cell_t ci[8];

	/*
	 * This function assumes the buffer is large enough to
	 * hold the result, so in 1275 mode, we pass in the length
	 * of the property as the length of the buffer, since we
	 * have no way of knowing the size of the buffer. Pre-1275
	 * OpenBoot(tm) PROMs did not have a bounded getprop.
	 *
	 * Note that we ignore the "length" result of the service.
	 */

	if ((len = prom_getproplen(nodeid, name)) <= 0)
		return (len);

	ci[0] = p1275_ptr2cell("getprop");	/* Service name */
	ci[1] = (cell_t)4;			/* #argument cells */
	ci[2] = (cell_t)0;			/* #result cells */
	ci[3] = p1275_phandle2cell((phandle_t)nodeid);	/* Arg1: package */
	ci[4] = p1275_ptr2cell(name);		/* Arg2: property name */
	ci[5] = p1275_ptr2cell(value);		/* Arg3: buffer address */
	ci[6] = len;				/* Arg4: buf len (assumed) */

	promif_preprom();
	rv = p1275_cif_handler(&ci);
	promif_postprom();

	if (rv != 0)
		return (-1);
	return (len);				/* Return known length */
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:35,代码来源:prom_prop.c


示例6: cpr_update_nvram

/*
 * write new or original values to nvram
 */
int
cpr_update_nvram(cprop_t *props)
{
	cprop_t *tail;
	pnode_t node;
	int len, rc;

	if (rc = cpr_get_options_node(&node))
		return (rc);

	if (cpr_show_props)
		prom_printf("\ncpr_show_props:\n");
	for (tail = props + CPR_MAXPROP; props < tail; props++) {
		if (cpr_show_props) {
			prom_printf("mod=%c, name \"%s\",\tvalue \"%s\"\n",
			    props->mod, props->name, props->value);
		}
		if (props->mod == PROP_NOMOD)
			continue;
		/*
		 * Note: When doing a prom_setprop you must include the
		 * trailing NULL in the length argument, but when calling
		 * prom_getproplen() the NULL is excluded from the count!
		 */
		len = strlen(props->value);
		rc = prom_setprop(node, props->name, props->value, len + 1);
		if (rc < 0 || prom_getproplen(node, props->name) != len) {
			cpr_err(CE_WARN, "cannot set nvram \"%s\" to \"%s\"",
			    props->name, props->value);
			return (ENXIO);
		}
	}

	return (0);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:38,代码来源:cpr_sparc.c


示例7: prom_getbool

/* Acquire a boolean property, 1=TRUE 0=FALSE. */
int prom_getbool(int node, char *prop)
{
	int retval;

	retval = prom_getproplen(node, prop);
	if(retval == -1) return 0;
	return 1;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:9,代码来源:tree.c


示例8: ibd_init

void
ibd_init(void)
{
	pnode_t	chosen;
	char	*mtuprop = "ipib-frame-size";
	char	*bcastprop = "ipib-broadcast";
	char	*addrprop = "ipib-address";
	char	*cidprop = "client-id";
	int	cidlen;
	uint8_t	dhcpcid[DHCP_MAX_CID_LEN];

	mac_state.mac_addr_len = IPOIB_ADDRL;
	mac_state.mac_addr_buf = bkmem_alloc(mac_state.mac_addr_len);
	if (mac_state.mac_addr_buf == NULL)
		prom_panic("ibd_init: Cannot allocate memory.");

	chosen = prom_finddevice("/chosen");
	if (chosen == OBP_NONODE || chosen == OBP_BADNODE)
		prom_panic("ibd_init: Cannot find /chosen.");

	if (prom_getprop(chosen, addrprop, (caddr_t)mac_state.mac_addr_buf) !=
	    IPOIB_ADDRL)
		prom_panic("ibd_init: Cannot find /chosen:ipib-address\n.");

	if (prom_getprop(chosen, bcastprop, (caddr_t)&ibdbroadcastaddr) !=
	    IPOIB_ADDRL)
		prom_panic("ibd_init: Cannot find /chosen:ipib-broadcast\n.");

	if (((cidlen = prom_getproplen(chosen, cidprop)) <= 0) ||
	    (cidlen > DHCP_MAX_CID_LEN) || (prom_getprop(chosen, cidprop,
	    (caddr_t)&dhcpcid) != cidlen))
		prom_panic("ibd_init: Invalid /chosen:client-id\n.");
	dhcp_set_client_id(dhcpcid, cidlen);

	/*
	 * Note that prom reports mtu including 20 bytes of
	 * addressing information.
	 */
	if (prom_getprop(chosen, mtuprop,
	    (caddr_t)&mac_state.mac_mtu) <= 0)
		mac_state.mac_mtu = IBDSIZE + IPOIB_ADDRL;

	/*
	 * Tell upper layers that we can support a little
	 * more. We will be taking off these 20 bytes at
	 * the start before we invoke prom_write() to send
	 * over the wire.
	 */
	mac_state.mac_arp_timeout = IBD_ARP_TIMEOUT;
	mac_state.mac_in_timeout = IBD_IN_TIMEOUT;

	mac_state.mac_arp = ibd_arp;
	mac_state.mac_rarp = ibd_revarp;
	mac_state.mac_header_len = ibd_header_len;
	mac_state.mac_input = ibd_input;
	mac_state.mac_output = ibd_output;
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:57,代码来源:ibd.c


示例9: prom_getbool

/* Acquire a boolean property, 1=TRUE 0=FALSE. */
int prom_getbool(phandle node, const char *prop)
{
	int retval;

	retval = prom_getproplen(node, prop);
	if (retval == -1)
		return 0;
	return 1;
}
开发者ID:0-T-0,项目名称:ps4-linux,代码行数:10,代码来源:tree_64.c


示例10: system_check

void
system_check(void)
{
	char buf[PROM_VERS_MAX_LEN];
	pnode_t	n;
	char	arch[128];
	size_t	len;
	bootplat_defaults_t *plat_defaults;

	/*
	 * This is a sun4v machine iff the device_type property
	 * exists on the root node and has the value "sun4v".
	 * Some older sunfire proms do not have such a property.
	 */
	is_sun4v = 0;
	n = prom_rootnode();
	len = prom_getproplen(n, "device_type");
	if (len > 0 && len < sizeof (arch)) {
		(void) prom_getprop(n, "device_type", arch);
		arch[len] = '\0';
		dprintf("device_type=%s\n", arch);
		if (strcmp(arch, "sun4v") == 0) {
			is_sun4v = 1;
		}
	} else {
		dprintf("device_type: no such property, len=%d\n", (int)len);
	}

	if (!is_sun4v && cpu_is_ultrasparc_1()) {
		printf("UltraSPARC I processors are not supported by this "
		    "release of Solaris.\n");
		prom_exit_to_mon();
	}

	/*
	 * Set up defaults per platform
	 */
	plat_defaults = (is_sun4v) ?
	    &sun4v_plat_defaults : &sun4u_plat_defaults;

	default_name = plat_defaults->plat_defaults_name;
	default_path = plat_defaults->plat_defaults_path;
	vac = plat_defaults->plat_defaults_vac;

	dprintf("default_name: %s\n", default_name);
	dprintf("default_path: %s\n", default_path);
	dprintf("vac: %d\n", vac);

	if (prom_version_check(buf, PROM_VERS_MAX_LEN, NULL) != PROM_VER64_OK) {
		printf("The firmware on this system does not support the 64-bit"
		    " OS.\n\tPlease upgrade to at least the following version:"
		    "\n\n\t%s\n", buf);
		prom_exit_to_mon();
	}
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:55,代码来源:boot_plat.c


示例11: build_one_prop

static struct property * __init build_one_prop(phandle node, char *prev,
					       char *special_name,
					       void *special_val,
					       int special_len)
{
	static struct property *tmp = NULL;
	struct property *p;
	const char *name;

	if (tmp) {
		p = tmp;
		memset(p, 0, sizeof(*p) + 32);
		tmp = NULL;
	} else {
		p = prom_early_alloc(sizeof(struct property) + 32);
		p->unique_id = prom_unique_id++;
	}

	p->name = (char *) (p + 1);
	if (special_name) {
		strcpy(p->name, special_name);
		p->length = special_len;
		p->value = prom_early_alloc(special_len);
		memcpy(p->value, special_val, special_len);
	} else {
		if (prev == NULL) {
			name = prom_firstprop(node, p->name);
		} else {
			name = prom_nextprop(node, prev, p->name);
		}

		if (!name || strlen(name) == 0) {
			tmp = p;
			return NULL;
		}
#ifdef CONFIG_SPARC32
		strcpy(p->name, name);
#endif
		p->length = prom_getproplen(node, p->name);
		if (p->length <= 0) {
			p->length = 0;
		} else {
			int len;

			p->value = prom_early_alloc(p->length + 1);
			len = prom_getproperty(node, p->name, p->value,
					       p->length);
			if (len <= 0)
				p->length = 0;
			((unsigned char *)p->value)[p->length] = '\0';
		}
	}
	return p;
}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:54,代码来源:prom_common.c


示例12: prom_get_idprom

/* Get the idprom and stuff it into buffer 'idbuf'.  Returns the
 * format type.  'num_bytes' is the number of bytes that your idbuf
 * has space for.  Returns 0xff on error.
 */
unsigned char
prom_get_idprom(char *idbuf, int num_bytes)
{
	int len;

	len = prom_getproplen(prom_root_node, "idprom");
	if((len>num_bytes) || (len==-1)) return 0xff;
	if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
		return idbuf[0];

	return 0xff;
}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:16,代码来源:misc_32.c


示例13: prom_getbool

/* Acquire a boolean property, 1=TRUE 0=FALSE. */
int
prom_getbool(int node, char *prop)
{
	int retval;

#if CONFIG_AP1000
        printk("prom_getbool(%s) -> 0\n",prop);
        return 0;
#endif
	retval = prom_getproplen(node, prop);
	if(retval == -1) return 0;
	return 1;
}
开发者ID:andreiw,项目名称:mkunity,代码行数:14,代码来源:tree.c


示例14: get_one_property

static char * __init get_one_property(phandle node, const char *name)
{
	char *buf = "<NULL>";
	int len;

	len = prom_getproplen(node, name);
	if (len > 0) {
		buf = prom_early_alloc(len);
		len = prom_getproperty(node, name, buf, len);
	}

	return buf;
}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:13,代码来源:prom_common.c


示例15: impl_name

static int
impl_name(char *buf, size_t bufsz)
{
	pnode_t n = prom_rootnode();
	size_t len = prom_getproplen(n, "name");

	if (len == 0 || len >= bufsz)
		return (-1);

	(void) prom_getprop(n, "name", buf);
	buf[len] = '\0';

	return (0);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:14,代码来源:sun4x_standalloc.c


示例16: prom_get_tem_size

/*
 * Here we use the "screen-#columns" and "screen-#rows" settings of
 * PROM to help us decide the console size and cursor position. The
 * actual sizes of PROM's TEM and the console might be different with
 * those "screen-#.." settings, in cases that they are too big to
 * accommodate.
 */
void
prom_get_tem_size(size_t *height, size_t *width)
{
	char buf[MAXPATHLEN];
	char name[16];
	pnode_t node;
	int len;

	if ((node = prom_optionsnode()) == OBP_BADNODE)
		return;

	(void) prom_strcpy(name, "screen-#rows");
	if ((len = prom_getproplen(node, (caddr_t)name)) > 0) {
		(void) prom_getprop(node, (caddr_t)name, (caddr_t)buf);
		*height = prom_atol(buf, len);
	}

	(void) prom_strcpy(name, "screen-#columns");
	if ((len = prom_getproplen(node, (caddr_t)name)) > 0) {
		(void) prom_getprop(node, (caddr_t)name, (caddr_t)buf);
		*width = prom_atol(buf, len);
	}
}
开发者ID:andreiw,项目名称:polaris,代码行数:30,代码来源:prom_fb.c


示例17: prom_memory_ihandle

ihandle_t
prom_memory_ihandle(void)
{
	static ihandle_t imemory;

	if (imemory != (ihandle_t)0)
		return (imemory);

	if (prom_getproplen(prom_chosennode(), "memory") != sizeof (ihandle_t))
		return (imemory = (ihandle_t)-1);

	(void) prom_getprop(prom_chosennode(), "memory", (caddr_t)(&imemory));
	return (imemory);
}
开发者ID:andreiw,项目名称:polaris,代码行数:14,代码来源:prom_mem.c


示例18: prom_getproperty

/* Acquire a property 'prop' at node 'node' and place it in
 * 'buffer' which has a size of 'bufsize'.  If the acquisition
 * was successful the length will be returned, else -1 is returned.
 */
int prom_getproperty(phandle node, const char *prop, char *buffer, int bufsize)
{
	int plen, ret;
	unsigned long flags;

	plen = prom_getproplen(node, prop);
	if((plen > bufsize) || (plen == 0) || (plen == -1))
		return -1;
	/* Ok, things seem all right. */
	spin_lock_irqsave(&prom_lock, flags);
	ret = prom_nodeops->no_getprop(node, prop, buffer);
	restore_current();
	spin_unlock_irqrestore(&prom_lock, flags);
	return ret;
}
开发者ID:0-T-0,项目名称:ps4-linux,代码行数:19,代码来源:tree_32.c


示例19: prom_getproperty

/* Acquire a property 'prop' at node 'node' and place it in
 * 'buffer' which has a size of 'bufsize'.  If the acquisition
 * was successful the length will be returned, else -1 is returned.
 */
int
prom_getproperty(int node, char *prop, char *buffer, int bufsize)
{
	int plen;

#if CONFIG_AP1000
        printk("prom_getproperty(%s) -> -1\n",prop);
        return -1;
#endif
	plen = prom_getproplen(node, prop);
	if((plen > bufsize) || (plen == 0) || (plen == -1)) return -1;

	/* Ok, things seem all right. */
	return prom_nodeops->no_getprop(node, prop, buffer);
}
开发者ID:andreiw,项目名称:mkunity,代码行数:19,代码来源:tree.c


示例20: prom_getproperty

/* Acquire a property 'prop' at node 'node' and place it in
 * 'buffer' which has a size of 'bufsize'.  If the acquisition
 * was successful the length will be returned, else -1 is returned.
 */
int prom_getproperty(int node, char *prop, char *buffer, int bufsize)
{
	int plen, ret;
	unsigned long flags;

	plen = prom_getproplen(node, prop);
	if((plen > bufsize) || (plen == 0) || (plen == -1))
		return -1;
	/* Ok, things seem all right. */
	save_flags(flags); cli();
	ret = prom_nodeops->no_getprop(node, prop, buffer);
	restore_current();
	restore_flags(flags);
	return ret;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:19,代码来源:tree.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ prom_printf函数代码示例发布时间:2022-05-30
下一篇:
C++ prom_getproperty函数代码示例发布时间: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