/*
* 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 "priplugin.h"
static int
static int
const char *pval);
/*
* Gather IO device nodes from the PRI and use the info to
* find the corresponding nodes in PICL's device tree, insert
* a Label into the devtree containing the "nac" from the PRI,
* and add a reference property to the corresponding fru tree node.
*/
void
{
return;
/*
* Find and remember the roots of the /frutree and /platform trees.
*/
PICL_SUCCESS) {
"io_dev_label: can't find platform node: %s\n",
return;
}
if (node_count == 0) {
"process\n");
return;
}
sizeof (mde_cookie_t));
if (components == NULL) {
"io_dev_addlabel: can't get memory for IO nodes\n");
return;
}
for (i = 0; i < component_count; ++i) {
/*
* Try to fetch the "type" as a string or as "data" until we
* can agree on what its tag type should be.
*/
-1) {
"can't get type for component %d\n", i);
continue;
}
}
/*
* Isolate components of type "io".
*/
"io_add_devlabel: skipping component %d with "
"type %s\n", i, type);
continue;
}
/*
* Now get the nac and raw path from the PRI.
*/
"io_add_devlabel: can't get nac value for device "
"<%s>\n", type);
continue;
} else
-1) {
"io_add_devlabel: can't get path value for "
"device <%s>\n", type);
continue;
}
path);
/*
* This loop visits each path component where those
* components are delimited with '/' and '@' characters.
* Each path component is a search key into the /platform
* tree; we're looking to match the bus-addr field of
* a node if that field is defined. If each path component
* matches up then we now have the corresponding device
* path for that IO device. Add a Label property to the
* leaf node.
*/
/*
* Isolate the bus address for this node by skipping
* over the first delimiter if present and writing
* a NUL character over the next '/'.
*/
if (*p == '/')
++p;
if (*p == '@')
++p;
*q = '\0';
/*
* See if there's a match, at this level only, in the
* device tree. We cannot skip generations in the
* device tree, which is why we're not doing a
* recursive search for bus-addr. bus-addr must
* be found at each node along the way. By doing
* this we'll stay in sync with the path components
* in the PRI.
*/
PICL_PROP_BUS_ADDR, (const char *)p, &tpn)) !=
PICL_SUCCESS) {
"can't find %s property of <%s> "
"for nac %s: %s\n",
PICL_PROP_BUS_ADDR, p, nac,
busaddr_match = 0;
break;
}
/*
* Note path component for the leaf so we can use
* it below.
*/
saved_path = p;
}
/*
* We could not drill down through the bus-addrs, so skip this
* device and move on to the next.
*/
if (busaddr_match == 0) {
"bus-addr path for this nac - skipping\n");
continue;
}
/*
* This loop adds a Label property to all the functions
* on the device we matched from the PRI path.
*/
/*
* Add Labels to peers that have the same bus-addr
* value (ignoring the function numbers.)
*/
"io_add_device: can't get %s "
"property from picl devtree: %s\n",
} else {
PICL_PROPNAMELEN_MAX) == 0) {
}
}
}
}
}
/*
* These two functions shamelessly stolen from picldevtree.c
*/
/*
* Return 1 if this node has this property with the given value.
*/
static int
const char *pval)
{
char *pvalbuf;
int err;
int len;
return (0);
return (0); /* not string prop */
return (0);
return (1); /* prop match */
return (0);
}
/*
* Search this node's children for the given property.
*/
static int
{
int err;
&childh, sizeof (picl_nodehdl_t))) {
if (err != PICL_SUCCESS)
return (err);
return (PICL_SUCCESS);
}
}
return (PICL_ENDOFLIST);
}