diff options
author | mb158278 <none@none> | 2008-06-18 11:59:22 -0700 |
---|---|---|
committer | mb158278 <none@none> | 2008-06-18 11:59:22 -0700 |
commit | 535c87f8e3fe2736e61b245839d511aa33554911 (patch) | |
tree | bf59f69c0745df404b79d37aac48e0ac771fb926 | |
parent | 808757cd437463271effd366563677b296be490d (diff) | |
download | illumos-joyent-535c87f8e3fe2736e61b245839d511aa33554911.tar.gz |
6694939 LDoms cpu DR leaves picl tree out of sync.
-rw-r--r-- | usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c | 76 | ||||
-rw-r--r-- | usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c | 37 | ||||
-rw-r--r-- | usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c | 9 |
3 files changed, 117 insertions, 5 deletions
diff --git a/usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c b/usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c index e45aab4969..08d1453697 100644 --- a/usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c +++ b/usr/src/cmd/picl/plugins/sun4v/mdesc/cpu_prop_update.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -204,6 +204,74 @@ add_cache_props(picl_nodehdl_t node, mde_cookie_t *cachelistp, int ncaches) } } +static void +add_clock_frequency(picl_nodehdl_t pnode, mde_cookie_t mnode) +{ + uint64_t uint64_value; + uint32_t uint32_value; + + if (md_get_prop_val(mdp, mnode, "clock-frequency", + &uint64_value)) { + return; + } + uint32_value = (uint32_t)(uint64_value & UINT32_MAX); + add_md_prop(pnode, sizeof (uint32_value), "clock-frequency", + &uint32_value, PICL_PTYPE_UNSIGNED_INT); +} + +/* + * Return the number of strings in the buffer + */ +static int +get_string_count(char *strdat, int length) +{ + int count; + char *lastnull; + char *nullptr; + + count = 1; + for (lastnull = &strdat[length - 1], nullptr = strchr(strdat, '\0'); + nullptr != lastnull; nullptr = strchr(nullptr + 1, '\0')) + count++; + + return (count); +} + +static void +add_compatible(picl_nodehdl_t pnode, mde_cookie_t mnode) +{ + char *compat; + int len; + int count; + void add_string_list_prop(picl_nodehdl_t, char *, char *, + unsigned int); + + if (prop_exists(pnode, "compatible")) + return; + if (md_get_prop_data(mdp, mnode, "compatible", (uint8_t **)&compat, + &len)) { + return; + } + if (compat[0] == '\0' || compat[len - 1] != '\0') + return; + count = get_string_count(compat, len); + if (count == 1) { + add_md_prop(pnode, len, "compatible", compat, + PICL_PTYPE_CHARSTRING); + return; + } + (void) add_string_list_prop(pnode, "compatible", compat, count); +} + +static void +add_device_type(picl_nodehdl_t pnode) +{ + char *device_type = "cpu"; + + add_md_prop(pnode, strlen(device_type) + 1, "device_type", device_type, + PICL_PTYPE_CHARSTRING); +} + int add_cpu_prop(picl_nodehdl_t node, void *args) { @@ -278,6 +346,12 @@ add_cpu_prop(picl_nodehdl_t node, void *args) add_md_prop(node, sizeof (int_value), OBP_PROP_PORTID, &int_value, PICL_PTYPE_INT); + add_clock_frequency(node, cpulistp[x]); + + add_compatible(node, cpulistp[x]); + + add_device_type(node); + /* get caches for CPU */ ncaches = md_scan_dag(mdp, cpulistp[x], md_find_name(mdp, "cache"), diff --git a/usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c b/usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c index 5323a23264..6b491d24a6 100644 --- a/usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c +++ b/usr/src/cmd/picl/plugins/sun4v/mdesc/dr.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -43,7 +43,7 @@ extern md_t *mdesc_devinit(void); * This function is identical to the one in the picldevtree plugin. * Unfortunately we can't just reuse that code. */ -static int +int add_string_list_prop(picl_nodehdl_t nodeh, char *name, char *strlist, unsigned int nrows) { @@ -164,7 +164,7 @@ add_devinfo_props(picl_nodehdl_t nodeh, di_node_t di_node) for (di_prop = di_prop_next(di_node, DI_PROP_NIL); di_prop != DI_PROP_NIL; - di_prop = di_prop_next(di_node, di_prop)) { + di_prop = di_prop_next(di_node, di_prop)) { di_val = di_prop_name(di_prop); di_ptype = di_prop_type(di_prop); @@ -248,6 +248,36 @@ add_devinfo_props(picl_nodehdl_t nodeh, di_node_t di_node) } /* + * add OBP_REG property to picl cpu node if it's not already there. + */ +static void +add_reg_prop(picl_nodehdl_t pn, di_node_t dn) +{ + int reg_prop[SUN4V_CPU_REGSIZE]; + int status; + int dlen; + int *pdata; + ptree_propinfo_t propinfo; + + status = ptree_get_propval_by_name(pn, OBP_REG, reg_prop, + sizeof (reg_prop)); + if (status == PICL_SUCCESS) { + return; + } + dlen = di_prom_prop_lookup_ints(ph, dn, OBP_REG, &pdata); + if (dlen < 0) { + return; + } + status = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION, + PICL_PTYPE_BYTEARRAY, PICL_READ, dlen * sizeof (int), OBP_REG, + NULL, NULL); + if (status != PICL_SUCCESS) { + return; + } + (void) ptree_create_and_add_prop(pn, &propinfo, pdata, NULL); +} + +/* * Create a picl node of type cpu and fill it. * properties are filled from both the device tree and the * Machine description. @@ -267,6 +297,7 @@ construct_cpu_node(picl_nodehdl_t plath, di_node_t dn) return (err); add_devinfo_props(anodeh, dn); + add_reg_prop(anodeh, dn); (void) add_cpu_prop(anodeh, NULL); return (err); diff --git a/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c b/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c index 0caff9baad..912b2b0406 100644 --- a/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c +++ b/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -271,6 +271,13 @@ mdescplugin_init(void) if (mdp == NULL) return; + /* + * update the cpu configuration in case the snapshot cache used by the + * devtree plugin is out of date. + */ + (void) update_devices(OBP_CPU, DEV_ADD); + (void) update_devices(OBP_CPU, DEV_REMOVE); + rootnode = md_root_node(mdp); /* |