Beispiel #1
0
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);
}
Beispiel #2
0
/*
 * Finds the device node with device_type "rtc" and opens it to
 * execute the get-time method
 */
static int
todds1307_setup_prom()
{
    pnode_t todnode;
    char tod1307_devpath[MAXNAMELEN];

    if ((todnode = prom_findnode_bydevtype(prom_rootnode(),
                                           DS1307_DEVICE_TYPE)) == OBP_NONODE)
        return (DDI_FAILURE);

    /*
     * We now have the phandle of the rtc node, we need to open the
     * node and get the ihandle
     */
    if (prom_phandle_to_path(todnode, tod1307_devpath,
                             sizeof (tod1307_devpath)) < 0) {
        cmn_err(CE_WARN, "prom_phandle_to_path failed");
        return (DDI_FAILURE);
    }

    /*
     * Now open the node and store it's ihandle
     */
    if ((todds1307_ihandle = prom_open(tod1307_devpath)) == NULL) {
        cmn_err(CE_WARN, "prom_open failed");
        return (DDI_FAILURE);
    }

    return (DDI_SUCCESS);
}
void
kmdb_prom_walk_cpus(int (*cb)(pnode_t, void *, void *), void *arg, void *result)
{
	walk_cpu_data_t wcd;

	wcd.wcd_cb = cb;
	wcd.wcd_arg = arg;

	prom_walk_devs(prom_rootnode(), walk_cpus_cb, &wcd, result);
}
Beispiel #4
0
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();
	}
}
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);
}
Beispiel #6
0
char *
prom_bootpath(void)
{
	static char bootpath[OBP_MAXPATHLEN];
	int length;
	pnode_t node;
	static char *name = "bootpath";

	if (bootpath[0] != (char)0)
		return (bootpath);

	node = prom_chosennode();
	if ((node == OBP_NONODE) || (node == OBP_BADNODE))
		node = prom_rootnode();
	length = prom_getproplen(node, name);
	if ((length == -1) || (length == 0))
		return (NULL);
	if (length > OBP_MAXPATHLEN)
		length = OBP_MAXPATHLEN - 1;	/* Null terminator */
	(void) prom_bounded_getprop(node, name, bootpath, length);
	return (bootpath);
}
Beispiel #7
0
ddi_prop_t *
get_proplist(char *name)
{
    ddi_prop_t *plist, *npp, *plast;
    char *curprop, *newprop;
    unsigned char *propval;
    unsigned long id;

    plist = NULL;
    plast = NULL;
    id = prom_findnode_byname(prom_rootnode(), name);
    if (id == 0)
        return (plist);
    curprop = "";
    while (newprop = (char *)prom_nextprop(curprop)) {
        curprop = strdup(newprop);
        npp = (ddi_prop_t *)malloc(sizeof (ddi_prop_t));
        if (npp == 0)
            exit(_error(PERROR, mfail));
        propval = prom_getprop(curprop, &npp->prop_len);
        npp->prop_name = curprop;
        if (propval != NULL) {
            npp->prop_val = (char *)malloc(npp->prop_len);
            if (npp->prop_val == 0)
                exit(_error(PERROR, mfail));
            memcpy(npp->prop_val, propval, npp->prop_len);
        } else
            npp->prop_val = NULL;
        npp->prop_next = NULL;
        if (plast == NULL) {
            plist = npp;
        } else {
            plast->prop_next = npp;
        }
        plast = npp;
    }
    return (plist);
}
Beispiel #8
0
/*
 * find cpu node for the boot processor
 *
 * sets globals:
 * 	cb_mid
 */
static pnode_t
get_cpu_node(void)
{
	static char *props[] = { "upa-portid", "portid", NULL };
	pnode_t node;
	char *str, *name, **propp;
	uint_t cpu_id;
	int err;

	str = "get_cpu_node";
	name = "cpu";

	cb_mid = getmid();
	for (node = prom_rootnode(); ; node = prom_nextnode(node)) {
		node = prom_findnode_bydevtype(node, name);
		if (node == OBP_NONODE) {
			prom_printf("\n%s: cant find node for devtype \"%s\"\n",
			    str, name);
			break;
		}

		cpu_id = (uint_t)-1;
		for (propp = props; *propp; propp++) {
			err = get_intprop(node, *propp, &cpu_id);
			CB_VPRINTF(("    cpu node 0x%x, "
			    "prop \"%s\", cpu_id %d\n",
			    node, *propp, (int)cpu_id));
			if (err == 0)
				break;
		}

		if (cpu_id == cb_mid)
			return (node);
	}

	return (OBP_NONODE);
}
/*
 * Platform specific lgroup initialization
 */
void
plat_lgrp_init(void)
{
	pnode_t		curnode;
	char		tmp_name[MAXSYSNAME];
	int		portid;
	int		cpucnt = 0;
	int		max_portid = -1;
	extern uint32_t lgrp_expand_proc_thresh;
	extern uint32_t lgrp_expand_proc_diff;
	extern pgcnt_t	lgrp_mem_free_thresh;
	extern uint32_t lgrp_loadavg_tolerance;
	extern uint32_t lgrp_loadavg_max_effect;
	extern uint32_t lgrp_load_thresh;
	extern lgrp_mem_policy_t  lgrp_mem_policy_root;

	/*
	 * Count the number of CPUs installed to determine if
	 * NUMA optimization should be enabled or not.
	 *
	 * All CPU nodes reside in the root node and have a
	 * device type "cpu".
	 */
	curnode = prom_rootnode();
	for (curnode = prom_childnode(curnode); curnode;
	    curnode = prom_nextnode(curnode)) {
		bzero(tmp_name, MAXSYSNAME);
		if (prom_getprop(curnode, OBP_NAME, (caddr_t)tmp_name) == -1 ||
		    prom_getprop(curnode, OBP_DEVICETYPE, tmp_name) == -1 ||
		    strcmp(tmp_name, "cpu") != 0)
			continue;

		cpucnt++;
		if (prom_getprop(curnode, "portid", (caddr_t)&portid) != -1 &&
		    portid > max_portid)
			max_portid = portid;
	}
	if (cpucnt <= 1)
		max_mem_nodes = 1;
	else if (max_portid >= 0 && max_portid < MAX_MEM_NODES)
		max_mem_nodes = max_portid + 1;

	/*
	 * Set tuneables for fiesta architecture
	 *
	 * lgrp_expand_proc_thresh is the minimum load on the lgroups
	 * this process is currently running on before considering
	 * expanding threads to another lgroup.
	 *
	 * lgrp_expand_proc_diff determines how much less the remote lgroup
	 * must be loaded before expanding to it.
	 *
	 * Optimize for memory bandwidth by spreading multi-threaded
	 * program to different lgroups.
	 */
	lgrp_expand_proc_thresh = lgrp_loadavg_max_effect - 1;
	lgrp_expand_proc_diff = lgrp_loadavg_max_effect / 2;
	lgrp_loadavg_tolerance = lgrp_loadavg_max_effect / 2;
	lgrp_mem_free_thresh = 1;	/* home lgrp must have some memory */
	lgrp_expand_proc_thresh = lgrp_loadavg_max_effect - 1;
	lgrp_mem_policy_root = LGRP_MEM_POLICY_NEXT;
	lgrp_load_thresh = 0;

	mem_node_pfn_shift = ENCHILADA_MC_SHIFT - MMU_PAGESHIFT;
}