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


C++ FDT_CHECK_HEADER函数代码示例

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


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

示例1: fdt_node_offset_by_prop_value

int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
				  const char *propname,
				  const void *propval, int proplen)
{
	int offset;
	const void *val;
	int len;

	FDT_CHECK_HEADER(fdt);

	/* FIXME: The algorithm here is pretty horrible: we scan each
	 * property of a node in fdt_getprop(), then if that didn't
	 * find what we want, we scan over them again making our way
	 * to the next node.  Still it's the easiest to implement
	 * approach; performance can come later. */
	for (offset = fdt_next_node(fdt, startoffset, NULL);
	     offset >= 0;
	     offset = fdt_next_node(fdt, offset, NULL)) {
		val = fdt_getprop(fdt, offset, propname, &len);
		if (val && (len == proplen)
		    && (memcmp(val, propval, len) == 0))
			return offset;
	}

	return offset; /* error from fdt_next_node() */
}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:26,代码来源:fdt_ro.c

示例2: fdt_get_mem_rsv

int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
{
	FDT_CHECK_HEADER(fdt);
	*address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);
	*size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);
	return 0;
}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:7,代码来源:fdt_ro.c

示例3: fdt_path_offset

int fdt_path_offset(const void *fdt, const char *path)
{
	const char *end = path + strlen(path);
	const char *p = path;
	int offset = 0;

	FDT_CHECK_HEADER(fdt);

	if (*path != '/')
		return -FDT_ERR_BADPATH;

	while (*p) {
		const char *q;

		while (*p == '/')
			p++;
		if (! *p)
			return offset;
		q = strchr(p, '/');
		if (! q)
			q = end;

		offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
		if (offset < 0)
			return offset;

		p = q;
	}

	return offset;
}
开发者ID:bandwidthcrunch,项目名称:xvisor,代码行数:31,代码来源:fdt_ro.c

示例4: fdt_supernode_atdepth_offset

int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
				 int supernodedepth, int *nodedepth)
{
	int offset, depth;
	int supernodeoffset = -FDT_ERR_INTERNAL;

	FDT_CHECK_HEADER(fdt);

	if (supernodedepth < 0)
		return -FDT_ERR_NOTFOUND;

	for (offset = 0, depth = 0;
	     (offset >= 0) && (offset <= nodeoffset);
	     offset = fdt_next_node(fdt, offset, &depth)) {
		if (depth == supernodedepth)
			supernodeoffset = offset;

		if (offset == nodeoffset) {
			if (nodedepth)
				*nodedepth = depth;

			if (supernodedepth > depth)
				return -FDT_ERR_NOTFOUND;
			else
				return supernodeoffset;
		}
	}

	if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))
		return -FDT_ERR_BADOFFSET;
	else if (offset == -FDT_ERR_BADOFFSET)
		return -FDT_ERR_BADSTRUCTURE;

	return offset; /* error from fdt_next_node() */
}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:35,代码来源:fdt_ro.c

示例5: fdt_subnode_offset_namelen

/*
 * fdt에서 offset를 기준으로 하위 노드를 탐색
 * (참고로 꼭 root가 아닐수 있음 즉, offset는 상대적인 위치임)

 * 참고: http://iamroot.org/wiki/lib/exe/fetch.php?media=%EC%8A%A4%ED%84%B0%EB%94%94:dtb_structure.png
 * +------+-------------------------+
 * | Node | FDT_BEGIN_NODE          |
 * |      +-------------------------+
 * |      | Node Name               |
 * |      +----------+--------------+
 * |      | Property | FDT_PROP     |
 * |      |          +--------------+
 * |      |          | Value Length |
 * |      |          +--------------+
 * |      |          | Name Offset  |
 * |      |          +--------------+
 * |      |          | Value        |
 * +------+----------+--------------+
*/
int fdt_subnode_offset_namelen(const void *fdt, int offset,
			       const char *name, int namelen)
{
	int depth;

	FDT_CHECK_HEADER(fdt);

	/*
	 * root부터 시작해서(depth=0) node를 탐색
	 * 현재 탐색중인 node의 depth를 받아와서
	*/
	for (depth = 0;
	     (offset >= 0) && (depth >= 0);
	     offset = fdt_next_node(fdt, offset, &depth))
		/*
		 * root 입장으로 봤을때 depth가 1인 node들 중에서
		 * 찾고자 하는 node가 맞다면 node offset을 리턴
		*/
		if ((depth == 1)
		    && _fdt_nodename_eq(fdt, offset, name, namelen))
			return offset;

	// 탐색했더니 찾고자 하는 node가 없는 상황
	if (depth < 0)
		return -FDT_ERR_NOTFOUND;
	return offset; /* error */
}
开发者ID:fehead,项目名称:linux_m,代码行数:46,代码来源:fdt_ro.c

示例6: fdt_get_path

int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
{
	int pdepth = 0, p = 0;
	int offset, depth, namelen;
	const char *name;

	FDT_CHECK_HEADER(fdt);

	if (buflen < 2)
		return -FDT_ERR_NOSPACE;

	for (offset = 0, depth = 0;
	     (offset >= 0) && (offset <= nodeoffset);
	     offset = fdt_next_node(fdt, offset, &depth)) {
		if (pdepth < depth)
			continue; /* overflowed buffer */

		while (pdepth > depth) {
			do {
				p--;
			} while (buf[p-1] != '/');
			pdepth--;
		}

		name = fdt_get_name(fdt, offset, &namelen);
		if (!name)
			return namelen;
		if ((p + namelen + 1) <= buflen) {
			memcpy(buf + p, name, namelen);
			p += namelen;
			buf[p++] = '/';
			pdepth++;
		}

		if (offset == nodeoffset) {
			if (pdepth < (depth + 1))
				return -FDT_ERR_NOSPACE;

			if (p > 1) /* special case so that root path is "/", not "" */
				p--;
			buf[p] = '\0';
			return p;
		}
	}

	if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))
		return -FDT_ERR_BADOFFSET;
	else if (offset == -FDT_ERR_BADOFFSET)
		return -FDT_ERR_BADSTRUCTURE;

	return offset; /* error from fdt_next_node() */
}
开发者ID:bandwidthcrunch,项目名称:xvisor,代码行数:52,代码来源:fdt_ro.c

示例7: fdt_path_offset

int fdt_path_offset(const void *fdt, const char *path)
{
	const char *end = path + strlen(path);
	const char *p = path;
	int offset = 0;

	FDT_CHECK_HEADER(fdt);

	/* see if we have an alias */
	if (*path != '/') {
		const char *q;
		int aliasoffset = fdt_path_offset(fdt, "/aliases");

		if (aliasoffset < 0)
			return -FDT_ERR_BADPATH;

		q = strchr(path, '/');
		if (!q)
			q = end;

		p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
		if (!p)
			return -FDT_ERR_BADPATH;
		offset = fdt_path_offset(fdt, p);

		p = q;
	}

	while (*p) {
		const char *q;

		while (*p == '/')
			p++;
		if (! *p)
			return offset;
		q = strchr(p, '/');
		if (! q)
			q = end;

		offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
		if (offset < 0)
			return offset;

		p = q;
	}

	return offset;
}
开发者ID:Februar0218,项目名称:u-boot-omap-pandora,代码行数:48,代码来源:fdt_ro.c

示例8: fdt_path_offset_namelen

int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
{
	const char *end = path + namelen;
	const char *p = path;
	int offset = 0;

	FDT_CHECK_HEADER(fdt);

	/* see if we have an alias */
	if (*path != '/') {
		const char *q = fdt_path_next_separator(path, namelen);

		if (!q)
			q = end;

		p = fdt_get_alias_namelen(fdt, p, q - p);
		if (!p)
			return -FDT_ERR_BADPATH;
		offset = fdt_path_offset(fdt, p);

		p = q;
	}

	while (*p && (p < end)) {
		const char *q;

		while (*p == '/')
			p++;

		if (*p == '\0' || *p == ':')
			return offset;

		q = fdt_path_next_separator(p, end - p);
		if (!q)
			q = end;

		offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
		if (offset < 0)
			return offset;

		p = q;
	}

	return offset;
}
开发者ID:Noltari,项目名称:u-boot,代码行数:45,代码来源:fdt_ro.c

示例9: fdt_subnode_offset_namelen

int fdt_subnode_offset_namelen(const void *fdt, int offset,
			       const char *name, int namelen)
{
	int depth;

	FDT_CHECK_HEADER(fdt);

	for (depth = 0;
	     (offset >= 0) && (depth >= 0);
	     offset = fdt_next_node(fdt, offset, &depth))
		if ((depth == 1)
		    && _fdt_nodename_eq(fdt, offset, name, namelen))
			return offset;

	if (depth < 0)
		return -FDT_ERR_NOTFOUND;
	return offset; /* error */
}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:18,代码来源:fdt_ro.c

示例10: fdt_node_offset_by_compatible

int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
				  const char *compatible)
{
	int offset, err;

	FDT_CHECK_HEADER(fdt);

	/* FIXME: The algorithm here is pretty horrible: we scan each
	 * property of a node in fdt_node_check_compatible(), then if
	 * that didn't find what we want, we scan over them again
	 * making our way to the next node.  Still it's the easiest to
	 * implement approach; performance can come later. */
	for (offset = fdt_next_node(fdt, startoffset, NULL);
	     offset >= 0; offset = fdt_next_node(fdt, offset, NULL)) {
		err = fdt_node_check_compatible(fdt, offset, compatible);
		if ((err < 0) && (err != -FDT_ERR_NOTFOUND))
			return err;
		else if (err == 0)
			return offset;
	}

	return offset;		/* error from fdt_next_node() */
}
开发者ID:BadrElh,项目名称:open-amp,代码行数:23,代码来源:fdt_ro.c

示例11: fdt_node_offset_by_phandle

int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
{
	int offset;

	if ((phandle == 0) || (phandle == -1))
		return -FDT_ERR_BADPHANDLE;

	FDT_CHECK_HEADER(fdt);

	/* FIXME: The algorithm here is pretty horrible: we
	 * potentially scan each property of a node in
	 * fdt_get_phandle(), then if that didn't find what
	 * we want, we scan over them again making our way to the next
	 * node.  Still it's the easiest to implement approach;
	 * performance can come later. */
	for (offset = fdt_next_node(fdt, -1, NULL);
	     offset >= 0; offset = fdt_next_node(fdt, offset, NULL)) {
		if (fdt_get_phandle(fdt, offset) == phandle)
			return offset;
	}

	return offset;		/* error from fdt_next_node() */
}
开发者ID:BadrElh,项目名称:open-amp,代码行数:23,代码来源:fdt_ro.c

示例12: fdt_path_offset

/*
 * chosen {
 * bootargs = "console=ttyS0,115200 ubi.mtd=4 root=ubi0:rootfs rootfstype=ubifs";
 * };

 * 호출: int offset = fdt_path_offset(fdt, "/chosen");
*/
int fdt_path_offset(const void *fdt, const char *path)
{
	/*
	 * p : "chosen"의 시작 주소
	 * end : "chosen"의 끝 주소
	*/
	const char *end = path + strlen(path);
	const char *p = path;
	int offset = 0;

	FDT_CHECK_HEADER(fdt);

	/* see if we have an alias */
	if (*path != '/') {
		// path가 '/'로 시작하지 않으면 path내에서 '/' 위치 찾음
		const char *q = strchr(path, '/');

		// path내에 '/'가 없으면 끝 주소로 지정
		if (!q)
			q = end;

		/*
		 * '/'로 시작하지 않았다면 alias라고 가정하고 원래 node명 탐색
		 * p: alias명
		 * q-p: alias 길이
		*/ 
		p = fdt_get_alias_namelen(fdt, p, q - p);
		// alias도 아닌경우 에러 리턴
		if (!p)
			return -FDT_ERR_BADPATH;
		offset = fdt_path_offset(fdt, p);

		p = q;
	}

	/*
	 * "chosen"의 alias가 없으면 여기서 탐색
	 * 여기서는 node의 이름이 "chosen"인지 아닌지 탐색
	*/
	while (*p) {
		const char *q;

		// path내에서 '/'가 아닌곳까지 이동
		while (*p == '/')
			p++;
		// path 끝까지 이동한 경우
		if (! *p)
			return offset;
		// p를 기준으로 다음 '/' 위치까지 찾아서
		q = strchr(p, '/');
		// 다음 '/'가 없다면 path의 끝으로 지정
		if (! q)
			q = end;
	
		// path에서 '/'로 split 해보면서
		// 하위 node들중 해당 이름의 node가 있는지 탐색
		offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
		if (offset < 0)
			return offset;

		p = q;
	}

	return offset;
}
开发者ID:fehead,项目名称:linux_m,代码行数:72,代码来源:fdt_ro.c


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