Esempio n. 1
0
static ofdn_t ofd_cpus_props(void *m, struct domain *d)
{
    static const char path[] = "/cpus";
    static const char cpu[] = "cpu";
    u32 val = 1;
    ofdn_t n;
    ofdn_t c;
    static u32 ibm_pft_size[] = { 0x0, 0x0 };

    n = ofd_node_find(m, path);
    if (n == 0) {
        n = ofd_node_add(m, OFD_ROOT, path, sizeof (path));
        ofd_prop_add(m, n, "name",
                     &path[1], sizeof (path) - 1);
    }
    ofd_prop_add(m, n, "#address-cells", &val, sizeof(val));
    ofd_prop_add(m, n, "#size-cells", &val, sizeof(val));
    ofd_prop_add(m, n, "smp-enabled", NULL, 0);

#ifdef HV_EXPOSE_PERFORMANCE_MONITOR
    ofd_prop_add(m, n, "performance-monitor", NULL, 0);
#endif

    c = ofd_node_find_by_prop(m, n, "device_type", cpu, sizeof (cpu));
    if (ofd_boot_cpu == -1)
        ofd_boot_cpu = c;
    while (c > 0) {
        /* We do not use the OF tree to identify secondary processors
         * so we must prune them from the tree */
        if (c == ofd_boot_cpu) {
            ofdn_t p;

            ibm_pft_size[1] = d->arch.htab.log_num_ptes + LOG_PTE_SIZE;
            ofd_prop_add(m, c, "ibm,pft-size",
                         ibm_pft_size, sizeof (ibm_pft_size));

            /* get rid of non-standard properties */
            p = ofd_prop_find(m, c, "cpu#");
            if (p > 0) {
                ofd_prop_remove(m, c, p);
            }

            /* FIXME: Check the the "l2-cache" property who's
             * contents is an orphaned phandle? */
        } else
            ofd_node_prune(m, c);

        c = ofd_node_find_next(m, c);
    }

    return n;
}
Esempio n. 2
0
File: ofd.c Progetto: jiamacs/rhype
static ofdn_t
ofd_memory_props(void *m, uval mem_size)
{
	ofdn_t n = 0;
	char fmt[] = "/memory@%lx";
	char name[] = "memory";
	uval32 v;
	uval start = 0;


	ofdn_t old;
	/* Remove all old memory props */
	do {
		old = ofd_node_find_by_prop(m, OFD_ROOT, "device_type",
					    name, sizeof(name));
		if (old <= 0) break;

		ofd_node_prune(m, old);
	} while (1);

	while (start < mem_size) {
		/* FIXME: these two properties need to be set during parition
		 * contruction */
		struct reg {
			uval64 addr;
			uval64 sz;
		};
		char path[64];
		uval l = snprintf(path, 64, fmt, start);
		n = ofd_node_add(m, OFD_ROOT, path, l+1);
		ofd_prop_add(m, n, "name", name, sizeof (name));

		v = 1;
		ofd_prop_add(m, n, "#address-cells", &v, sizeof (v));
		v = 0;
		ofd_prop_add(m, n, "#size-cells", &v, sizeof (v));

		ofd_prop_add(m, n, "device_type", name, sizeof (name));


			/* physical addresses usable without regard to OF */
		struct reg reg;
		reg.addr = start;
		reg.sz = mem_size - start;
		if (reg.sz > CHUNK_SIZE) {
			reg.sz = CHUNK_SIZE;
		}
		/* free list of physical addresses available after OF and
		 * client program have been accounted for */
		/* FIXME: obviously making this up */
		if (start == 0) {
			struct reg avail = {
				.addr = 0,
				.sz = CHUNK_SIZE - (1024 * 1024),
			};
			ofd_prop_add(m, n, "available", &avail,
				     sizeof (avail));
		}

		ofd_prop_add(m, n, "reg", &reg, sizeof (reg));

		start += reg.sz;
	}

	return n;
}


static ofdn_t
ofd_prune(void *m, const char *devspec)
{
	ofdn_t n;
	int rc = -1;
	while ((n = ofd_node_find(m, devspec)) > 0) {
		rc = ofd_node_prune(m, n);
	}

	return rc;
}
Esempio n. 3
0
File: ofd.c Progetto: jiamacs/rhype
static ofdn_t
ofd_cpus_props(void *m, struct partition_status *ps)
{
	static const char path[] = "/cpus";
	static const char cpu[] = "cpu";
	uval32 val = 1;
	ofdn_t n;
	ofdn_t c;
	static uval32 ibm_pft_size[] = { 0x0, 0x0 };

	n = ofd_node_find(m, path);
	if (n == 0) {
		n = ofd_node_add(m, OFD_ROOT, path, sizeof (path));
		ofd_prop_add(m, n, "name",
				&path[1], sizeof (path) - 1);
	}
	ofd_prop_add(m, n, "#address-cells", &val, sizeof(val));
	ofd_prop_add(m, n, "#size-cells", &val, sizeof(val));
	ofd_prop_add(m, n, "smp-enabled", NULL, 0);

#ifdef HV_EXPOSE_PERFORMANCE_MONITOR
	ofd_prop_add(m, n, "performance-monitor", NULL, 0);
#endif

	c = ofd_node_find_by_prop(m, n, "device_type", cpu, sizeof (cpu));
	//assert(c > 0, "can't get first processor\n");
	while (c > 0) {
		ibm_pft_size[1] = ps->log_htab_bytes;
		ofd_prop_add(m, c, "ibm,pft-size",
			     ibm_pft_size, sizeof (ibm_pft_size));

		/* FIXME: we don't sleep to good yet so if on simulator lie
		 * about the clock speed */
		if (onsim()) {
			val = 100000000;
			ofd_prop_add(m, c,
				     "clock-frequency", &val, sizeof(val));
			ofd_prop_add(m, c,
				     "timebase-frequency", &val, sizeof(val));
		}

		/* FIXME: Check the the "l2-cache" property who's
		 * contents is an orphaned phandle? */

		ofd_per_proc_props(m, c, ps->lpid);
		c = ofd_node_find_next(m, c);

		/* Since we are not MP yet we can prune the rest of the CPUs */
		while (c > 0) {
			ofdn_t nc;

			nc = ofd_node_find_next(m, c);
			ofd_node_prune(m, c);

			c = nc;
		}
	}

	ofd_proc_props(m, ps->lpid);
	return n;
}