chip.c revision 20c794b39650d115e17a15983b6b82e46238cf45
/*
* 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 <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <limits.h>
#include <alloca.h>
#include <kstat.h>
#include <errno.h>
#include <libnvpair.h>
#include <sys/processor.h>
#include <sys/systeminfo.h>
#include <sys/mc_intel.h>
#include <fm/topo_mod.h>
#include "chip.h"
#define MAX_DIMMNUM 7
#define MAX_CSNUM 7
/*
* Enumerates the processing chips, or sockets, (as distinct from cores) in a
* system. For each chip found, the necessary nodes (one or more cores, and
* possibly a memory controller) are constructed underneath.
*/
topo_instance_t, topo_instance_t, void *, void *);
static const topo_modops_t chip_ops =
static const topo_modinfo_t chip_info =
static const topo_pgroup_info_t chip_pgroup =
static const topo_pgroup_info_t cpu_pgroup =
static const topo_method_t chip_methods[] = {
{ SIMPLE_CHIP_LBL, "Property method", 0,
{ G4_CHIP_LBL, "Property method", 0,
{ NULL }
};
int
{
if (getenv("TOPOCHIPDBG"))
}
}
return (-1); /* mod errno set */
}
return (0);
}
void
{
}
static int
{
kstat_named_t *k;
chip->chip_ncpustats) < 0)
return (-1);
continue;
/*
* The chip_id in the cpu_info kstat numbers the individual
* chips from 0 to #chips - 1.
*/
"chip_id")) == NULL) {
"kstats failed\n");
continue;
}
continue; /* not an error */
/*
* The clog_id in the cpu_info kstat numbers the virtual
* processors of a single chip; these may be separate
* of individual cores.
*
* The core_id in the cpu_info kstat tells us which cpus
* share the same core - i.e., are hardware strands of the
* same core. The core ids do not reset to zero for each
* distinct chip - they number across all cores of all chips.
* This enumerator does not distinguish stranded
* cores so core_id is unused.
*/
"clog_id")) == NULL) {
"kstats failed\n");
continue;
}
continue;
}
== NULL) {
continue;
}
} else {
"failed\n");
}
NULL) != 0)
nerr++; /* have whinged elsewhere */
}
return (nerr == 0 ? 0 : -1);
}
static int
{
int i, nerr = 0;
/*
* Read in all cpu_info kstats, for all chip ids. The ks_instance
* argument to kstat_lookup is the logical cpu_id - we will use this
* in cpu_create.
*/
for (i = 0; i <= chip->chip_ncpustats; i++) {
continue;
}
for (i = 0; i <= chip->chip_ncpustats; i++) {
const char *vendor;
kstat_named_t *k;
continue;
"via kstats failed\n");
continue;
}
continue;
continue;
continue;
}
== NULL) {
"failed for chipid %d\n", chipid);
continue;
}
"topo_method_register failed");
CHIP_VENDOR_ID, &vendor) != 0)
nerr++; /* have whinged elsewhere */
nerr++; /* have whinged elsewhere */
!= 0)
nerr++; /* have whinged elsewhere */
/*
* Create memory-controller node under a chip for architectures
* that may have on-chip memory-controller(s).
*/
}
if (nerr == 0) {
return (0);
} else {
return (-1);
}
}
/*ARGSUSED*/
static int
{
int rv = 0;
int intel_mc;
intel_mc = mc_offchip_open();
if (intel_mc)
return (rv);
}