/*
* 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
*/
/*
*/
#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 <topo_fmri.h>
#include <sys/processor.h>
#include <fm/fmd_fmri.h>
#include <cpu.h>
/*
* platform specific cpu module
*/
topo_instance_t, void *, void *);
nvlist_t **);
nvlist_t **);
nvlist_t **);
{ NULL }
};
{ cpu_enum, cpu_release };
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;
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;
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)
return (0);
/*
* 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 (0);
/* 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/%s=%d",
}
} else {
"cpu:///%s=%u/%s=%s",
} else {
"cpu:///%s=%u/%s=%s/%s=%u/%s=%u/%s=%d/%s=%d",
}
}
} else
return (0);
}
/*ARGSUSED*/
static int
{
char *name;
if (version > TOPO_METH_NVL2STR_VERSION)
}
}
return (0);
}
/*ARGSUSED*/
static int
{
int err;
int index_present = 0;
if (version > TOPO_METH_STR2NVL_VERSION)
/* We're expecting a string version of a cpu scheme FMRI */
if (s == NULL)
++s;
/* If there is a serial #, then there might also be cache data */
if (*(s = end) == '/') {
s = strchr(s, '=');
++s;
serial = s;
/* If there is cache data, all must be present */
if (serial_end != NULL) {
/* Now terminate the serial string */
*serial_end = '\0';
index_present = 1;
s = serial_end + 1;
s = strchr(s, '=');
++s;
if (*(s = end) != '/') {
return (topo_mod_seterrno(mod,
}
s = strchr(s, '=');
if (s == NULL) {
return (topo_mod_seterrno(mod,
}
++s;
if (*(s = end) != '/') {
return (topo_mod_seterrno(mod,
}
s = strchr(s, '=');
if (s == NULL) {
return (topo_mod_seterrno(mod,
}
++s;
if (*(s = end) != '/') {
return (topo_mod_seterrno(mod,
}
s = strchr(s, '=');
if (s == NULL) {
return (topo_mod_seterrno(mod,
}
++s;
}
}
serial);
if (index_present) {
index);
way);
bit);
type);
}
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);
}
/*ARGSUSED*/
static int
{
int rc;
if (version > TOPO_METH_FMRI_VERSION) {
}
if (rc != 0) {
/*
* This routine requires arguments to be packed in the
* format used in topo_fmri_create()
*/
}
}
return (-1);
}
return (0);
}
/*ARGSUSED*/
static int
{
int state;
state) != 0) {
nvlist_free(*out);
}
return (0);
}
/*ARGSUSED*/
static int
{
uint64_t h = 0;
int len;
sizeof (FM_FMRI_CPU_SERIAL_ID) - 1) == 0)
f++;
if (f != NULL)
h += topo_fmri_strhash_one(f, strlen(f));
*rval = h;
return (0);
}
/*ARGSUSED*/
static int
{
/*
* just skip the next char ("/") as there is no auth for cpu
*/
a++;
b++;
/*
* First compare the cpuid bit (first element)
*/
return (B_FALSE);
return (B_FALSE);
/*
* If next element is FM_FMRI_CPU_SERIAL_ID then skip it
* and compare what's left.
*/
sizeof (FM_FMRI_CPU_SERIAL_ID) - 1) == 0)
fa++;
sizeof (FM_FMRI_CPU_SERIAL_ID) - 1) == 0)
fb++;
return (B_TRUE);
return (B_FALSE);
else
}
/*ARGSUSED*/
static int
{
a = strstr(a, FM_FMRI_CPU_SERIAL_ID);
b = strstr(b, FM_FMRI_CPU_SERIAL_ID);
return (B_TRUE);
return (B_FALSE);
return (B_FALSE);
}