/*
* 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
*/
/*
*/
/*
* Topology Trees
*
* Toplogy trees are instantiated for each builtin (FMRI) scheme specified
* in topo_builtin.c. Each ttree_t data structure contains the
* skeleton of the topology tree (scheme, root node, and file information).
* The root node of a topology does not represent any FMRI but rather serves
* as the entry point for topology access interfaces. The file information
* provides a handle to access static .xml files that seed scheme-specifc
* topologies
*
* Topology trees will remain unpopulated until topo_snap_hold() is called.
* At that time, a ttree_t structure is allocated and added to the list
* trees maintained in topo_hdl_t. Builtin scheme-specific enumerators are
* called upon to create nodes that represent FMRIs for resources present in the
* system. If a <scheme>-topology.xml file exists in a standard file
* location, the file is used to seed the topology while the rest is
* dynamically created by the builtin or helper enumerator modules.
* For example, the 'hc' tree is enumerated by the hc enumerator (hc.c)
* is created with a properly formatted hc FMRI resource.
*
* Toplogy trees are released and deallocated when topo_snap_hold is called.
* Upon return from topo_snap_rele(), all node resources are deallocated
* and all that remains is the ttree_t structure containing the root node.
*/
#include <pthread.h>
#include <limits.h>
#include <assert.h>
#include <sys/systeminfo.h>
#include <topo_alloc.h>
#include <topo_error.h>
#include <topo_file.h>
#include <topo_module.h>
#include <topo_string.h>
#include <topo_subr.h>
#include <topo_tree.h>
static ttree_t *
{
if (err != 0)
return (NULL);
}
ttree_t *
{
/*
* Initialize a private walker for internal use
*/
/*
* Create the root of this tree: LINKED but never BOUND
*/
rp->tn_instance = 0;
return (tp);
}
void
{
return;
}
/*
* Deallocate this last, because a pointer alias for tt_scheme
* (stored in the root node's name field) may be used in
* topo_node_rele().
*/
}
static int
{
int rv = 0;
char *pp;
if (load_snapshot == B_TRUE) {
/*
* Enumerate by loading in a saved topology snapshot.
*/
} else {
/*
* Attempt to enumerate the tree from a topology map in the
* following order:
* <product-name>-<scheme>-topology
* <platform-name>-<scheme>-topology (uname -i)
* <machine-name>-<scheme>-topology (uname -m)
* <scheme>-topology
*
* Trim any SUNW, from the product or platform name
* before loading file
*/
else
pp++;
else
pp++;
rv = topo_file_load(
}
}
}
}
if (rv != 0) {
"map for %s FMRI scheme, errmsg=%s\n", __func__,
return (topo_hdl_seterrno(thp,
}
return (0);
}
int
{
int err = 0;
err++;
break;
}
}
if (err != 0)
return (-1);
else
return (0);
}