chip.c revision 64d1d4ab72834b7483c7962efc738b568ca8792e
/*
* 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.
*/
#include <unistd.h>
#include <fcntl.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/fmd_agent.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 core_pgroup =
static const topo_pgroup_info_t strand_pgroup =
static const topo_method_t chip_methods[] = {
{ SIMPLE_CHIP_LBL, "Property method", 0,
{ G4_CHIP_LBL, "Property method", 0,
{ A4FPLUS_CHIP_LBL, "Property method", 0,
{ FSB2_CHIP_LBL, "Property method", 0,
{ NULL }
};
static const topo_method_t strands_retire_methods[] = {
{ NULL }
};
int
{
if (getenv("TOPOCHIPDBG"))
return (-1); /* mod errno set */
}
return (0);
}
void
{
}
is_xpv(void)
{
static int r = -1;
char platform[MAXNAMELEN];
if (r != -1)
return (r == 0);
return (r == 0);
}
static tnode_t *
{
return (NULL);
}
return (cnode);
}
static int
{
&strandid)) != 0) {
return (-1);
}
!= NULL) {
return (-1);
}
return (-1);
/*
* Inherit FRU from core node, in native use cpu scheme ASRU,
* in xpv, use hc scheme ASRU.
*/
if (is_xpv()) {
"topo_node_resource failed\n");
} else {
}
} else {
"failed\n");
} else {
!= NULL) {
0, &err);
} else {
"cpu_fmri_create() failed\n");
}
}
}
"topo_method_register failed\n");
}
static int
{
!= 0) {
return (-1);
}
return (-1);
/*
* Inherit FRU from the chip node, for native, we use hc
* scheme ASRU for the core node.
*/
if (is_xpv()) {
"topo_node_resource failed\n");
} else {
}
}
"topo_method_register failed\n");
CORE_CHIP_ID, NULL);
0, 255) != 0)
return (-1);
}
if (! is_xpv()) {
/*
* In native mode, we're in favor of cpu scheme ASRU for
* printing reason. More work needs to be done to support
* multi-strand cpu: the ASRU will be a list of cpuid then.
*/
"failed\n");
} else {
!= NULL) {
} else {
"cpu_fmri_create() failed\n");
}
}
}
}
static int
int mc_offchip)
{
!= 0) {
return (-1);
}
return (-1);
return (-1);
"topo_method_register failed\n");
"topo_node_resource failed\n");
} else {
}
CHIP_VENDOR_ID, &vendor);
"topo_method_register failed\n");
0, 255) != 0)
return (-1);
}
/*
* Create memory-controller node under a chip for architectures
* that may have on-chip memory-controller(s).
*/
else if (!mc_offchip)
}
/*ARGSUSED*/
static int
int mc_offchip)
{
int nerr = 0;
return (0);
return (-1);
return (-1);
}
for (i = 0; i < ncpu; i++) {
nvlist_free(cpus[i]);
}
if (nerr == 0) {
return (0);
} else {
return (-1);
}
}
/*ARGSUSED*/
static int
{
int rv = 0;
int offchip_mc;
const char *dom0 = "control_d";
/*
* Create nothing if we're running in domU.
*/
return (-1);
return (0);
if (fd != -1) {
return (0);
}
}
}
if (offchip_mc)
return (rv);
}