cpu.c revision 9ef59e775c4e5bf58e38adbfd9897b45caeda106
/*
* 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 2007 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>
#ifdef sparc
#include <cpu_mdesc.h>
#endif
/*
* The scheme plugin for cpu FMRIs.
*/
#ifdef sparc
static ldom_hdl_t *cpu_scheme_lhp;
#endif /* sparc */
{
int err;
char *serstr;
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)
FM_FMRI_CPU_ID, cpuid));
else
return (fmd_fmri_set_errno(EINVAL));
else
serstr));
} 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;
#ifdef sparc
else
#endif /* sparc */
return (err);
}
static int
{
#ifdef sparc
else
#endif /* sparc */
}
int
{
int rc;
return (fmd_fmri_set_errno(EINVAL));
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));
}
#ifdef sparc
(void) nvlist_add_string(nvl,
} else {
(void) nvlist_add_string(nvl,
}
(void) nvlist_add_string(nvl,
}
}
#endif /* sparc */
} 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
{
int rc;
return (fmd_fmri_set_errno(EINVAL));
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));
#ifdef sparc
{
}
#else
#endif
}
#ifdef sparc
int
fmd_fmri_init(void)
{
return (cpu_mdesc_init(cpu_scheme_lhp));
}
void
fmd_fmri_fini(void)
{
}
#endif /* sparc */