libtopo.h revision 9dd0f810214fdc8e1af881a9a5c4b6927629ff9e
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file are subject to the terms of the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Common Development and Distribution License (the "License").
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You may not use this file except in compliance with the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * When distributing Covered Code, include this CDDL HEADER in each
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If applicable, add the following below this CDDL HEADER, with the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * fields enclosed by brackets "[]" replaced with your own identifying
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * information: Portions Copyright [yyyy] [name of copyright owner]
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER END
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident "%Z%%M% %I% %E% SMI"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern "C" {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_VERSION 1 /* Library ABI Interface Version */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Topo stability attributes
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Each topology node advertises the name and data stability of each of its
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * modules and properties. (see attributes(5))
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef enum topo_stability {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi TOPO_STABILITY_UNSTABLE, /* new or rapidly changing */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi TOPO_STABILITY_STABLE, /* mature interface from Sun */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#define TOPO_STABILITY_MAX TOPO_STABILITY_STANDARD /* max valid stab */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef enum {
0eb822a1c0c2bea495647510b75f77f0e57633ebcinditypedef struct topo_pgroup_info {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_stability_t tpi_namestab; /* stability of group name */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_stability_t tpi_datastab; /* stability of all property values */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_version_t tpi_version; /* version of pgroup definition */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern topo_stability_t topo_name2stability(const char *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern const char *topo_stability2name(topo_stability_t);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern topo_hdl_t *topo_open(int, const char *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern char *topo_snap_hold(topo_hdl_t *, const char *, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_xml_print(topo_hdl_t *, FILE *, const char *scheme, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Snapshot walker support
0eb822a1c0c2bea495647510b75f77f0e57633ebcinditypedef int (*topo_walk_cb_t)(topo_hdl_t *, tnode_t *, void *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern topo_walk_t *topo_walk_init(topo_hdl_t *, const char *, topo_walk_cb_t,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi void *, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * FMRI helper routines
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_present(topo_hdl_t *, nvlist_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_contains(topo_hdl_t *, nvlist_t *, nvlist_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_unusable(topo_hdl_t *, nvlist_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_nvl2str(topo_hdl_t *, nvlist_t *, char **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_str2nvl(topo_hdl_t *, const char *, nvlist_t **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_asru(topo_hdl_t *, nvlist_t *, nvlist_t **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_fru(topo_hdl_t *, nvlist_t *, nvlist_t **,
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindiextern int topo_fmri_label(topo_hdl_t *, nvlist_t *, char **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_compare(topo_hdl_t *, nvlist_t *, nvlist_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_invoke(topo_hdl_t *, nvlist_t *, topo_walk_cb_t, void *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Topo node utilities: callable from topo_walk_step() callback or module
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * enumeration, topo_mod_enumerate()
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_node_asru(tnode_t *, nvlist_t **, nvlist_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_node_fru(tnode_t *, nvlist_t **, nvlist_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_node_resource(tnode_t *, nvlist_t **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_method_invoke(tnode_t *node, const char *, topo_version_t,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_pgroup_create(tnode_t *, const topo_pgroup_info_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void topo_pgroup_destroy(tnode_t *, const char *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern topo_pgroup_info_t *topo_pgroup_info(tnode_t *, const char *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_int32(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_uint32(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_int64(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_uint64(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_string(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi char **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_fmri(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_int32_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_uint32_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_int64_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_uint64_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_string_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi char ***, uint_t *, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_fmri_array(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_set_int32(tnode_t *, const char *, const char *, int,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_set_uint32(tnode_t *, const char *, const char *, int,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_set_int64(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int, int64_t, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_set_uint64(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int, uint64_t, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_set_string(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int, const char *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_set_fmri(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int, const nvlist_t *, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_set_int32_array(tnode_t *, const char *, const char *, int,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_set_uint32_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_set_int64_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_set_uint64_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_set_string_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi int, const char **, uint_t, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_set_fmri_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern nvlist_t *topo_prop_getprops(tnode_t *, int *err);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_inherit(tnode_t *, const char *, const char *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/* Protocol property group and property names */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PGROUP_PROTOCOL "protocol" /* Required property group */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_RESOURCE "resource" /* resource FMRI */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_MOD "module" /* software module FMRI */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_PKG "package" /* software package FMRI */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * System property group
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/* Property node NVL names used in topo_prop_getprops */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#define TOPO_PROP_GROUP_DSTAB "property-group-data-stability"
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#define TOPO_PROP_GROUP_NSTAB "property-group-name-stability"
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#define TOPO_PROP_GROUP_VERSION "property-group-version"
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * This enum definition is used to define a set of error tags associated with
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * the libtopo various error conditions occuring during the adminstration of
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * properties. The shell script mkerror.sh is
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * used to parse this file and create a corresponding topo_error.c source file.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * If you do something other than add a new error tag here, you may need to
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * update the mkerror shell script as it is based upon simple regexps.
0eb822a1c0c2bea495647510b75f77f0e57633ebcinditypedef enum topo_prop_errno {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_UNKNOWN = 3000, /* unknown topo prop error */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_NOENT, /* undefined property or property group */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_DEFD, /* static property already defined */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_NOMEM, /* memory limit exceeded during property allocation */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_END /* end of prop errno list (to ease auto-merge) */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern const char *topo_strerror(int);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern void topo_debug_set(topo_hdl_t *, const char *, const char *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void topo_hdl_free(topo_hdl_t *, void *, size_t);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_hdl_nvalloc(topo_hdl_t *, nvlist_t **, uint_t);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_hdl_nvdup(topo_hdl_t *, nvlist_t *, nvlist_t **);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern char *topo_hdl_strdup(topo_hdl_t *, const char *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#endif /* _LIBTOPO_H */