示例#1
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_finddevice(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 1) {
		if (nrets == 1) {
			sval *ap = DRELA(&ofh_active_package, b);
			const char *devspec = (const char *)argp[0];
			sval *ph = &retp[0];
			void *mem = ofd_mem(b);

			/* good enuff */
			if (devspec[0] == '\0') {
				if (*ap == -1) {
					return OF_FAILURE;
				}
				*ph = *ap;
			} else {
				*ph = ofd_node_find(mem, devspec);
				if (*ph <= 0) {
					return OF_FAILURE;
				}
			}
			*ap = *ph;
			return OF_SUCCESS;
		}
	}
	return OF_FAILURE;
}
示例#2
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_parent(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 1) {
		if (nrets == 1) {
			ofdn_t ph = argp[0];
			uval *parent_ph = &retp[0];
			void *mem = ofd_mem(b);

			*parent_ph = ofd_node_parent(mem, ph);
			return OF_SUCCESS;
		}	
	}
	return OF_FAILURE;
}	
示例#3
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_nextprop(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 3) {
		if (nrets == 1) {
			ofdn_t ph = argp[0];
			const char *prev = (const char *)argp[1];
			char *name = (char *)argp[2];
			sval *flag = &retp[0];
			void *mem = ofd_mem(b);

			*flag = ofd_nextprop(mem, ph, prev, name);
			return OF_SUCCESS;
		}
	}
	return OF_FAILURE;
}
示例#4
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_getproplen(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 2) {
		if (nrets == 1) {
			ofdn_t ph = argp[0];
			const char *name = (const char *)argp[1];
			sval *size = &retp[0];
			void *mem = ofd_mem(b);

			*size = ofd_getproplen(mem, ph, name);
			if (*size >= 0) {
				return OF_SUCCESS;
			}
		}
	}
	return OF_FAILURE;
}
示例#5
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_package_to_path(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 3) {
		if (nrets == 1) {
			ofdn_t ph = argp[0];
			char *buf = (char *)argp[1];
			uval sz = argp[2];
			sval *len = &retp[0];
			void *mem = ofd_mem(b);

			*len = ofd_node_to_path(mem, ph, buf, sz);

			return OF_SUCCESS;
		}
	}
	return OF_FAILURE;
}
示例#6
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_setprop(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 4) {
		if (nrets == 1) {
			ofdn_t ph = argp[0];
			const char *name = (const char *)argp[1];
			const void *buf = (void *)argp[2];
			uval buflen = argp[3];
			sval *size = &retp[0];
			void *mem = ofd_mem(b);

			*size = ofd_setprop(mem, ph, name, buf, buflen);
			return OF_SUCCESS;
		}
	}
	return OF_FAILURE;
}
示例#7
0
void ofh_rtas_init(ulong b)
{
    static const char path[] = "/rtas";
    ofdn_t n;
    void *m = ofd_mem(b);
    u32 sz;

    n = ofd_node_find(m, DRELA(&path[0], b));
    if (n <= 0)
        return;

    sz = (_rtas_image_end - _rtas_image_start);
    /* Round size up to a multiple of 0x1000 */
    sz = ALIGN_UP(sz, PAGE_SIZE);

    ofd_prop_add(m, n, DRELA((const char *)"rtas-size", b),
                 &sz, sizeof(sz));

    /* create an IO node */
    ofd_io_create(m, n, (ulong)rtas_open);
}
示例#8
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_instance_to_path(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 3) {
		if (nrets == 1) {
			struct ofh_ihandle_s *ih =
				(struct ofh_ihandle_s *)argp[0];
			char *buf = (char *)argp[1];
			uval sz = argp[2];
			uval *len = &retp[0];
			ofdn_t ph;
			void *mem = ofd_mem(b);

			ph = ih->ofi_node;
			*len = ofd_node_to_path(mem, ph, buf, sz);

			return OF_SUCCESS;
		}
	}
	return OF_FAILURE;
}
示例#9
0
文件: devtree.c 项目: jiamacs/rhype
sval
ofh_canon(uval nargs, uval nrets, sval argp[], sval retp[], uval b)
{
	if (nargs == 3) {
		if (nrets == 1) {
			const char *dev_spec = (const char *)argp[0];
			char *buf = (char *)argp[1];
			uval sz = argp[2];
			uval *len = &retp[0];
			void *mem = ofd_mem(b);
			ofdn_t ph;

			ph = ofd_node_find(mem, dev_spec);
			if (ph > 0) {
				*len = ofd_node_to_path(mem, ph, buf, sz);
				return OF_SUCCESS;
			}
		}
	}
	return OF_FAILURE;
}