dr.c revision 1ae0874509b6811fdde1dfd46f0d93fd09867a3f
/*
* 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 "mdescplugin.h"
typedef struct cpu_lookup {
int result;
} cpu_lookup_t;
extern md_t *mdesc_devinit(void);
/*
* This function is identical to the one in the picldevtree plugin.
* Unfortunately we can't just reuse that code.
*/
static int
unsigned int nrows)
{
int err;
unsigned int i;
unsigned int j;
int len;
#define NCOLS_IN_STRING_TABLE 1
if (err != PICL_SUCCESS)
return (err);
if (err != PICL_SUCCESS)
return (err);
if (err != PICL_SUCCESS)
return (err);
(void) ptree_destroy_prop(proph);
return (PICL_FAILURE);
}
for (j = 0; j < nrows; ++j) {
if (err != PICL_SUCCESS)
break;
if (err != PICL_SUCCESS)
break;
&proprow[j]);
if (err != PICL_SUCCESS)
break;
}
if (err != PICL_SUCCESS) {
for (i = 0; i < j; ++i)
(void) ptree_destroy_prop(proprow[i]);
(void) ptree_delete_prop(proph);
(void) ptree_destroy_prop(proph);
return (err);
}
return (PICL_SUCCESS);
}
/*
* This function is identical to the one in the picldevtree plugin.
* Unfortunately we can't just reuse that code.
*/
static void
{
int instance;
char *di_val;
int di_ptype;
if (di_val) {
NULL);
}
if (di_val) {
NULL);
}
if (di_val) {
NULL);
}
if (di_val) {
NULL);
}
di_prop != DI_PROP_NIL;
switch (di_ptype) {
case DI_PROP_TYPE_BOOLEAN:
(void) ptree_init_propinfo(&propinfo,
break;
case DI_PROP_TYPE_INT: {
int *idata;
int len;
if (len < 0)
/* Recieved error, so ignore prop */
break;
if (len == 1)
(void) ptree_init_propinfo(&propinfo,
else
(void) ptree_init_propinfo(&propinfo,
}
break;
case DI_PROP_TYPE_STRING: {
char *sdata;
int len;
if (len < 0)
break;
if (len == 1) {
(void) ptree_init_propinfo(&propinfo,
(void) ptree_create_and_add_prop(nodeh,
} else {
}
}
break;
case DI_PROP_TYPE_BYTE: {
int len;
unsigned char *bdata;
if (len < 0)
break;
(void) ptree_init_propinfo(&propinfo,
}
break;
case DI_PROP_TYPE_UNKNOWN:
break;
case DI_PROP_TYPE_UNDEF_IT:
break;
default:
break;
}
}
}
/*
* Create a picl node of type cpu and fill it.
* properties are filled from both the device tree and the
* Machine description.
*/
static int
{
int err;
char *nodename;
&anodeh);
if (err != PICL_SUCCESS)
return (err);
return (err);
}
/*
* Given a devinfo node find its reg property.
*/
static int
{
int dret = 0;
if (dret > 0)
return (dret);
if (!ph)
return (0);
}
/*
* Given a devinfo cpu node find its cpuid property.
*/
int
{
int len;
int *idata;
int dcpuid = -1;
if (len != SUN4V_CPU_REGSIZE)
return (dcpuid);
if (len == SUN4V_CPU_REGSIZE)
return (dcpuid);
}
int
{
int dcpuid;
char *nodename;
continue;
return (1);
}
}
}
return (0);
}
/*
* Callback to the ptree walk function during remove_cpus.
* As a part of the args receives a picl nodeh, searches
* the device tree for a cpu whose cpuid matches the picl cpu node.
* Sets arg struct's result to 1 if it failed to match and terminates
* the walk.
*/
static int
{
int err;
int pcpuid;
int reg_prop[SUN4V_CPU_REGSIZE];
return (PICL_INVALIDARG);
sizeof (reg_prop));
if (err != PICL_SUCCESS) {
return (PICL_WALK_CONTINUE);
}
return (PICL_WALK_TERMINATE);
}
return (PICL_WALK_CONTINUE);
}
/*
* Given the start node of the device tree.
* find all cpus in the picl tree that don't have
* device tree counterparts and remove them.
*/
static void
{
int err;
if (err != PICL_SUCCESS)
return;
do {
!= PICL_SUCCESS)
return;
if (err == PICL_SUCCESS)
}
}
/*
* Callback to the ptree walk function during add_cpus.
* As a part of the args receives a cpu di_node, compares
* each picl cpu node's cpuid to the device tree node's cpuid.
* Sets arg struct's result to 1 on a match.
*/
static int
{
int err;
int reg_prop[4];
return (PICL_INVALIDARG);
sizeof (reg_prop));
if (err != PICL_SUCCESS)
return (PICL_WALK_CONTINUE);
return (PICL_WALK_TERMINATE);
}
return (PICL_WALK_CONTINUE);
}
/*
* Given the root node of the device tree.
* compare it to the picl tree and add to it cpus
* that are new.
*/
static void
{
int err;
char *nodename;
if (err != PICL_SUCCESS)
return;
continue;
!= PICL_SUCCESS)
return;
/*
* Didn't find a matching cpu, add it.
*/
(void) construct_cpu_node(plath,
cnode);
}
}
}
/*
* Handle DR events. Only supports cpu add and remove.
*/
int
{
return (PICL_FAILURE);
return (PICL_FAILURE);
}
if (op == DEV_REMOVE) {
}
return (PICL_SUCCESS);
}