cpu.c revision 14ea4bb737263733ad80a36b4f73f681c30a6b45
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#include <limits.h>
#include <strings.h>
#include <unistd.h>
#include <topo_error.h>
#include <fm/topo_mod.h>
#include <topo_method.h>
#include <cpu.h>
/*
* platform specific cpu module
*/
#define PLATFORM_CPU_VERSION CPU_VERSION
#define PLATFORM_CPU_NAME "platform-cpu"
topo_instance_t, void *, void *);
nvlist_t **);
nvlist_t **);
nvlist_t **);
static const topo_method_t cpu_methods[] = {
{ NULL }
};
static const topo_modops_t cpu_ops =
{ cpu_enum, cpu_release };
static const topo_modinfo_t cpu_info =
int
{
if (getenv("TOPOCPUDEBUG"))
if (version != CPU_VERSION)
return (-1);
}
return (-1);
}
return (-1);
}
return (0);
}
void
{
}
static int
{
return (-1);
} else {
}
return (ksp->ks_instance);
}
/*ARGSUSED*/
static int
{
int i;
char *s, sbuf[21];
for (i = 0; i <= cpuip->cn_ncpustats; i++) {
continue;
"device_ID")) != NULL) {
s = sbuf;
} else {
s = NULL;
}
continue;
}
return (0);
}
/*ARGSUSED*/
static int
{
PLATFORM_CPU_VERSION)) == NULL) {
/*
* There is no platform specific cpu module, so use
* the default enumeration with kstats of this builtin
* cpu module.
*/
"cpu enumeration failed to create "
"cpu range [0-%d]: %s\n",
return (-1); /* mod_errno set */
}
} else {
/* Fail to load the module */
"Failed to load module %s: %s",
return (-1);
}
}
"%s failed to enumerate: %s",
return (-1);
}
return (0);
}
static void
{
}
{
int rc;
char *serstr;
if (version == CPU_SCHEME_VERSION0) {
!= 0)
return (0);
(u_longlong_t)serint));
} else if (version == CPU_SCHEME_VERSION1) {
return (0);
/*
* Serial number is an optional element
*/
&serstr)) != 0)
FM_FMRI_CPU_ID, cpuid));
else
return (0);
else
serstr));
} else {
return (0);
}
}
/*ARGSUSED*/
static int
{
char *name;
if (version > TOPO_METH_NVL2STR_VERSION)
}
}
return (0);
}
/*ARGSUSED*/
static int
{
int err;
if (version > TOPO_METH_STR2NVL_VERSION)
/* We're expecting a string version of a cpu scheme FMRI */
if (s == NULL)
++s;
if (*(s = end) == '/') {
s = strchr(s, '=');
++s;
serial = s;
}
serial);
if (err != 0) {
}
return (0);
}
static nvlist_t *
{
int err;
return (NULL);
}
if (s != NULL)
if (err != 0) {
return (NULL);
}
return (fmri);
}
/*ARGSUSED*/
static int
{
int rc;
else
}
return (0);
}