chip_subr.c revision 25c6ff4b77fcddf4097ce78a8277275ca603b46c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Support function for the i86pc chip enumerator
*/
#include <stdarg.h>
#include <strings.h>
#include <fm/fmd_fmri.h>
#include "chip.h"
/*
* Whinge a debug message via topo_mod_dprintf and increment the
* given error counter.
*/
void
{
char buf[160];
++*nerr;
}
/*
* Given an nvpair of a limited number of data types, extract the property
* name and value and add that combination to the given node in the
* specified property group using the corresponding topo_prop_set_* function
* for the data type. Return 1 on success, otherwise 0.
*/
int
{
int success = 0;
int err;
switch (nvpair_type(nvp)) {
case DATA_TYPE_BOOLEAN_VALUE: {
success = 1;
break;
}
case DATA_TYPE_UINT32: {
success = 1;
break;
}
case DATA_TYPE_UINT64: {
success = 1;
break;
}
case DATA_TYPE_UINT32_ARRAY: {
success = 1;
break;
}
case DATA_TYPE_STRING: {
char *str;
success = 1;
break;
}
default:
"'%s' in property group %s of %s node\n",
break;
}
return (success ? 0 : 1);
}
/*
* Lookup string data named pname in the given kstat_t and add that
* as property named pname in the given property group pgname on the indicated
* topo node. Fill pvalp with a pointer to the string value, valid until
* kstat_close is called (or the given kstat_t is otherwise invalidated).
*/
int
{
const char *pval;
kstat_named_t *k;
int err = 0;
return (-1);
if (pvalp)
return (0);
} else {
pname);
return (-1);
}
}
/*
* Lookup an int32 item named pname in the given kstat_t and add that
* as property named pname in the given property group pgname on the indicated
* topo node. Fill pvalp with the property value.
*/
int
{
kstat_named_t *k;
int err;
return (-1);
if (pvalp)
return (0);
} else {
pname);
return (-1);
}
}
/*
* In a given kstat_t lookup a variable number of int32 properties named in
* const char * varargs and each each in the given property group on the
* node. Fill an array of the retrieved values.
*/
int
{
const char *pname;
int nerr = 0;
pvalap) != 0)
nerr++; /* have whinged elsewhere */
++pvalap;
}
return (nerr == 0 ? 0 : -1);
}
/*
* Construct an hc scheme resource FMRI for a node named name with
* instance number inst, parented by the given parent node pnode.
*/
int
{
}
/*
* Construct a cpu scheme FMRI with the given data; the caller must free
* the allocated nvlist with nvlist_free().
*/
nvlist_t *
{
int err;
return (NULL);
if (s != NULL)
if (err != 0) {
return (NULL);
}
return (asru);
}
/*
* Construct a mem scheme FMRI for the given unum string; the caller must
* free the allocated nvlist with nvlist_free().
*/
nvlist_t *
{
return (NULL);
return (NULL);
}
return (asru);
}
/*
* Registered method for asru computation for rank nodes. The 'node'
* argument identifies the node for which we seek an asru. The 'in'
* argument is used to select which asru we will return, as follows:
*
* - the node name must be "dimm" or "rank"
* - if 'in' is NULL then return any statically defined asru for this node
* - if 'in' is an "hc" scheme fmri then we construct a "mem" scheme asru
* with unum being the hc path to the dimm or rank (this method is called
* as part of dynamic asru computation for rank nodes only, but
* it is also called directly to construct a "mem" scheme asru for a dimm
* node)
* - if 'in' in addition includes an hc-specific member which specifies
* asru-physaddr or asru-offset then these are includes in the "mem" scheme
* asru as additional members physaddr and offset
*/
int
{
int incl_pa = 0, incl_offset = 0;
int err = 0;
&pa) == 0)
incl_pa = 1;
&offset) == 0)
incl_offset = 1;
}
/* use 'fmri' to obtain resource path; could use node resource */
return (-1); /* mod errno set */
if (incl_pa)
if (incl_offset)
if (err != 0) {
}
return (0);
}
/*ARGSUSED*/
int
{
int err;
} else {
}
return (-1); /* mod errno already set */
}
}
if (err != 0) {
nvlist_free(*out);
}
return (0);
}
/*
* If we're getting called then the question of whether this dimm is plugged
* in has already been answered. What we don't know for sure is whether it's
* the same dimm or a different one plugged in the same slot. To check, we
* try and compare the serial numbers on the dimm in the current topology with
* the serial num from the unum fmri that got passed into this function as the
* argument.
*
* In the event we encounter problems comparing serials or if a comparison isn't
* possible, we err on the side of caution and set is_present to TRUE.
*/
/* ARGSUSED */
int
{
/*
* If a serial number for the dimm was available at the time of the
* fault, it will have been added as a string to the unum nvlist
*/
goto done;
/*
* If the current serial number is available for the DIMM that this rank
* belongs to, it will be accessible as a property on the parent (dimm)
* node.
*/
if (err != ETOPO_PROP_NOENT) {
"retrieving serial from node");
} else
goto done;
}
is_present = 0;
done:
"rank_fmri_present: failed to allocate nvlist!");
}
nvlist_free(*out);
}
return (0);
}
/*
* If we're getting called then the question of whether this dimm is plugged
* in has already been answered. What we don't know for sure is whether it's
* the same dimm or a different one plugged in the same slot. To check, we
* try and compare the serial numbers on the dimm in the current topology with
* the serial num from the unum fmri that got passed into this function as the
* argument.
*
* In the event we encounter problems comparing serials or if a comparison isn't
* possible, we err on the side of caution and set is_present to TRUE.
*/
/* ARGSUSED */
int
{
/*
* If a serial number for the dimm was available at the time of the
* fault, it will have been added as a string to the unum nvlist
*/
goto done;
/*
* If the current serial number is available for the DIMM that this rank
* belongs to, it will be accessible as a property on the parent (dimm)
* node.
*/
if (err != ETOPO_PROP_NOENT) {
"retrieving serial from node");
} else
goto done;
}
else
done:
"rank_fmri_present: failed to allocate nvlist!");
}
nvlist_free(*out);
}
return (0);
}