cpu.c revision 7bebe46c240b554f47faeed19186123896281967
/*
* 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"
#include <sys/processor.h>
#include <fm/fmd_fmri.h>
#include <strings.h>
#include <errno.h>
#include <kstat.h>
/*
* The scheme plugin for cpu FMRIs.
*/
{
int err;
return (fmd_fmri_set_errno(EINVAL));
if (version == CPU_SCHEME_VERSION0) {
!= 0)
return (fmd_fmri_set_errno(EINVAL));
(u_longlong_t)serint));
} else if (version == CPU_SCHEME_VERSION1) {
return (fmd_fmri_set_errno(EINVAL));
/*
* Serial number is an optional element
*/
&serstr)) != 0)
return (fmd_fmri_set_errno(EINVAL));
/*
* Cache index, way and type are optional elements
* But if we have one of them, we must have them all.
*/
&index);
/* Insure there were no errors accessing the nvl */
return (fmd_fmri_set_errno(EINVAL));
/* If we have a serial string and no cache info */
FM_FMRI_CPU_ID, cpuid));
else {
"cpu:///%s=%u/%s=%u/%s=%u/%s=%d",
}
} else {
"cpu:///%s=%u/%s=%s",
} else {
"cpu:///%s=%u/%s=%s/%s=%u/%s=%u/%s=%d",
}
}
} else
return (fmd_fmri_set_errno(EINVAL));
}
/*
* Determine if a cpuid is present.
*/
/*ARGSUSED*/
static int
{
#ifdef sparc
/*
* For SPARC, use kstats to see if the cpuid is present.
* Note that this may need to change for sun4v.
*/
return (-1); /* errno is set for us */
(void) kstat_close(kc);
#else /* sparc */
/*
* For x64, just return true.
*/
return (1);
#endif /* sparc */
}
static int
{
int i;
return (-1); /* errno is set for us */
(void) kstat_close(kc);
return (fmd_fmri_set_errno(ENOENT));
}
(void) kstat_close(kc);
return (fmd_fmri_set_errno(oserr));
}
(void) kstat_close(kc);
return (0);
}
}
(void) kstat_close(kc);
return (fmd_fmri_set_errno(ENOENT));
}
static int
{
int err;
return (err);
}
static int
{
}
int
{
return (fmd_fmri_set_errno(EINVAL));
/*
* If the cpu-scheme topology exports this method expand(), invoke it.
*/
return (fmd_fmri_set_errno(EINVAL));
if (err != ETOPO_METHOD_NOTSUP)
return (rc);
if (version == CPU_SCHEME_VERSION0) {
&serialid)) != 0) {
return (fmd_fmri_set_errno(rc));
return (-1); /* errno is set for us */
serialid)) != 0)
return (fmd_fmri_set_errno(rc));
}
} else if (version == CPU_SCHEME_VERSION1) {
&serstr)) != 0) {
return (fmd_fmri_set_errno(rc));
return (0); /* Serial number is optional */
serbuf)) != 0)
return (fmd_fmri_set_errno(rc));
}
} else {
return (fmd_fmri_set_errno(EINVAL));
}
return (0);
}
int
{
return (fmd_fmri_set_errno(EINVAL));
/*
* If the cpu-scheme topology exports this method present(), invoke it.
*/
return (fmd_fmri_set_errno(EINVAL));
if (err != ETOPO_METHOD_NOTSUP)
return (rc);
if (version == CPU_SCHEME_VERSION0) {
&nvlserid) != 0)
return (fmd_fmri_set_errno(EINVAL));
} else if (version == CPU_SCHEME_VERSION1) {
&nvlserstr)) != 0)
return (fmd_fmri_set_errno(EINVAL));
/*
* If serial id is not available, just check if the cpuid
* is present.
*/
return (cpu_cpuid_present(cpuid));
} else {
return (fmd_fmri_set_errno(EINVAL));
}
}
int
{
return (fmd_fmri_set_errno(EINVAL));
/*
* If the cpu-scheme topology exports this method unusable(), invoke it.
*/
return (fmd_fmri_set_errno(EINVAL));
if (err != ETOPO_METHOD_NOTSUP)
return (rc);
}
int
{
int err;
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
if (erversion == CPU_SCHEME_VERSION0) {
&erserint) != 0)
return (0);
&eeserint) != 0)
return (0);
return (0);
} else if (erversion == CPU_SCHEME_VERSION1) {
/* Serial ID is an optional element */
&erserstr)) != 0)
return (0);
&eeserstr)) != 0)
return (0);
return (0);
}
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
return (1);
}