libtopo.h revision 4557a2a1868181b517f5dfe61ba6eeba58edf4c0
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
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 *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * or http://www.opensolaris.org/os/licensing.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
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 *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER END
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
dd566498928f08e7c9a79797a40db893c6a4b9fbvn * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#ifndef _LIBTOPO_H
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define _LIBTOPO_H
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident "%Z%%M% %I% %E% SMI"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/nvpair.h>
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#include <stdio.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#ifdef __cplusplus
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern "C" {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#endif
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_VERSION 1 /* Library ABI Interface Version */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef struct topo_hdl topo_hdl_t;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef struct topo_node tnode_t;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef struct topo_walk topo_walk_t;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef int32_t topo_instance_t;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef uint32_t topo_version_t;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * The following functions, error codes and data structures are private
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * to libtopo snapshot consumers and enumerator modules.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern topo_hdl_t *topo_open(int, const char *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void topo_close(topo_hdl_t *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern char *topo_snap_hold(topo_hdl_t *, const char *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void topo_snap_release(topo_hdl_t *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/*
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Snapshot walker support
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi */
0eb822a1c0c2bea495647510b75f77f0e57633ebcinditypedef int (*topo_walk_cb_t)(topo_hdl_t *, tnode_t *, void *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern topo_walk_t *topo_walk_init(topo_hdl_t *, const char *, topo_walk_cb_t,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi void *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_walk_step(topo_walk_t *, int);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void topo_walk_fini(topo_walk_t *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Walk status returned from walker
c40d7343efa60b18ad1ceb316eb337caeea79046cindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_WALK_ERR -1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_WALK_NEXT 0
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_WALK_TERMINATE 1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Types of walks: depth-first (child) or breadth-first (sibling)
c40d7343efa60b18ad1ceb316eb337caeea79046cindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_WALK_CHILD 0x0001
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_WALK_SIBLING 0x0002
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/*
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * FMRI helper routines
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_present(topo_hdl_t *, nvlist_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_fmri_contains(topo_hdl_t *, nvlist_t *, nvlist_t *, int *);
dd566498928f08e7c9a79797a40db893c6a4b9fbvnextern int topo_fmri_expand(topo_hdl_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 **,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int *);
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 *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Topo node utilities: callable from topo_walk_step() callback or module
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * enumeration, topo_mod_enumerate()
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern char *topo_node_name(tnode_t *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern topo_instance_t topo_node_instance(tnode_t *);
4557a2a1868181b517f5dfe61ba6eeba58edf4c0robjextern tnode_t *topo_node_parent(tnode_t *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void *topo_node_private(tnode_t *);
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_node_label(tnode_t *, char **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_method_invoke(tnode_t *node, const char *, topo_version_t,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_t *, nvlist_t **, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_int32(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int32_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_uint32(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint32_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_int64(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int64_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int topo_prop_get_uint64(tnode_t *, const char *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint64_t *, int *);
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 *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_t **, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_int32_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi int32_t **, uint_t *, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_uint32_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi uint32_t **, uint_t *, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_int64_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi int64_t **, uint_t *, int *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int topo_prop_get_uint64_array(tnode_t *, const char *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi uint64_t **, uint_t *, int *);
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 *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi nvlist_t ***, uint_t *, int *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#define TOPO_PROP_IMMUTABLE 0
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#define TOPO_PROP_MUTABLE 1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
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_ASRU "ASRU" /* ASRU FMRI */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_FRU "FRU" /* FRU FMRI */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_MOD "module" /* software module FMRI */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_PKG "package" /* software package FMRI */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_LABEL "label" /* property LABEL */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * System property group
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PGROUP_SYSTEM "system"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_ISA "isa"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define TOPO_PROP_MACHINE "machine"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * These enum definitions are used to define a set of error tags associated with
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * libtopo error conditions occuring during the adminstration of
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * properties, invocation of methods and fmri-based queries. The shell script
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * mkerror.sh is used to parse this file and create a corresponding topo_error.c
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * source file.
c40d7343efa60b18ad1ceb316eb337caeea79046cindi *
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.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi */
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_TYPE, /* invalid property type */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_PROP_NAME, /* invalid property name */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_NOINHERIT, /* can not inherit property */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_NVL, /* malformed property nvlist */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_PROP_METHOD, /* get property method failed */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ETOPO_PROP_END /* end of prop errno list (to ease auto-merge) */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi} topo_prop_errno_t;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
dd566498928f08e7c9a79797a40db893c6a4b9fbvntypedef enum topo_method_errno {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_UNKNOWN = 3100, /* unknown topo method error */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_INVAL, /* invalid method registration */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_NOTSUP, /* method not supported */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_FAIL, /* method failed */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_VEROLD, /* app is compiled to use obsolete method */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_VERNEW, /* app is compiled to use obsolete method */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_NOMEM, /* memory limit exceeded during method op */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_DEFD, /* method op already defined */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_METHOD_END /* end of method errno list */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn} topo_method_errno_t;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
c40d7343efa60b18ad1ceb316eb337caeea79046cinditypedef enum topo_fmri_errno {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_FMRI_UNKNOWN = 3200, /* unknown topo fmri error */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_FMRI_NVL, /* nvlist allocation failure for FMRI */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_FMRI_VERSION, /* invalid FMRI scheme version */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_FMRI_MALFORM, /* malformed FMRI */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_FMRI_NOMEM, /* memory limit exceeded */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_FMRI_END /* end of fmri errno list */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi} topo_fmri_errno_t;
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cinditypedef enum topo_hdl_errno {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_HDL_UNKNOWN = 3300, /* unknown topo handle error */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_HDL_ABIVER, /* handle opened with invalid ABI version */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_HDL_SNAP, /* snapshot already taken */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_HDL_INVAL, /* invalid argument specified */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_HDL_UUID, /* uuid already set */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_HDL_NOMEM, /* memory limit exceeded */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi ETOPO_HDL_END /* end of handle errno list */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi} topo_hdl_errno_t;
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern const char *topo_strerror(int);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern void topo_hdl_strfree(topo_hdl_t *, char *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern void topo_debug_set(topo_hdl_t *, const char *, const char *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * The following functions and data structures to support property
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * observability are private to the fmtopo command.
c40d7343efa60b18ad1ceb316eb337caeea79046cindi */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Each topology node advertises the name and data stability of each of its
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * modules and properties. (see attributes(5)).
c40d7343efa60b18ad1ceb316eb337caeea79046cindi */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Topo stability attributes
c40d7343efa60b18ad1ceb316eb337caeea79046cindi */
c40d7343efa60b18ad1ceb316eb337caeea79046cinditypedef enum topo_stability {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_UNKNOWN = 0, /* private to libtopo */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_INTERNAL, /* private to libtopo */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_PRIVATE, /* private to Sun */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_OBSOLETE, /* scheduled for removal */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_EXTERNAL, /* not controlled by Sun */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_UNSTABLE, /* new or rapidly changing */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_EVOLVING, /* less rapidly changing */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_STABLE, /* mature interface from Sun */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_STABILITY_STANDARD /* industry standard */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi} topo_stability_t;
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_STABILITY_MAX TOPO_STABILITY_STANDARD /* max valid stab */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cinditypedef struct topo_pgroup_info {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi const char *tpi_name; /* property group name */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi topo_stability_t tpi_namestab; /* stability of group name */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi topo_stability_t tpi_datastab; /* stability of all property values */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi topo_version_t tpi_version; /* version of pgroup definition */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi} topo_pgroup_info_t;
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern topo_stability_t topo_name2stability(const char *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern const char *topo_stability2name(topo_stability_t);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern void topo_pgroup_destroy(tnode_t *, const char *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern topo_pgroup_info_t *topo_pgroup_info(tnode_t *, const char *, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cinditypedef enum {
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_INVALID = 0,
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_BOOLEAN, /* boolean */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_INT32, /* int32_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_UINT32, /* uint32_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_INT64, /* int64_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_UINT64, /* uint64_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_STRING, /* const char* */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_TIME, /* uint64_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_SIZE, /* uint64_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_FMRI, /* nvlist_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_INT32_ARRAY, /* array of int32_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_UINT32_ARRAY, /* array of uint32_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_INT64_ARRAY, /* array of int64_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_UINT64_ARRAY, /* array of uint64_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_STRING_ARRAY, /* array of const char* */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi TOPO_TYPE_FMRI_ARRAY /* array of nvlist_t */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi} topo_type_t;
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern nvlist_t *topo_prop_getprops(tnode_t *, int *err);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int topo_prop_getprop(tnode_t *, const char *, const char *,
c40d7343efa60b18ad1ceb316eb337caeea79046cindi nvlist_t *, nvlist_t **, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int topo_prop_getpgrp(tnode_t *, const char *, nvlist_t **, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int topo_prop_setprop(tnode_t *, const char *, nvlist_t *,
c40d7343efa60b18ad1ceb316eb337caeea79046cindi int, nvlist_t *, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int topo_fmri_getprop(topo_hdl_t *, nvlist_t *, const char *,
c40d7343efa60b18ad1ceb316eb337caeea79046cindi const char *, nvlist_t *, nvlist_t **, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int topo_fmri_getpgrp(topo_hdl_t *, nvlist_t *, const char *,
c40d7343efa60b18ad1ceb316eb337caeea79046cindi nvlist_t **, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int topo_fmri_setprop(topo_hdl_t *, nvlist_t *, const char *,
c40d7343efa60b18ad1ceb316eb337caeea79046cindi nvlist_t *, int, nvlist_t *, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi/* Property node NVL names used in topo_prop_getprops */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_GROUP "property-group"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_GROUP_NAME "property-group-name"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_GROUP_DSTAB "property-group-data-stability"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_GROUP_NSTAB "property-group-name-stability"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_GROUP_VERSION "property-group-version"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_VAL "property"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_VAL_NAME "property-name"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_VAL_VAL "property-value"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_VAL_TYPE "property-type"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_FLAG "property-flag"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindi/*
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * ARGS list used in topo property methods
c40d7343efa60b18ad1ceb316eb337caeea79046cindi */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_ARGS "args"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi#define TOPO_PROP_PARGS "private-args"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int topo_xml_print(topo_hdl_t *, FILE *, const char *scheme, int *);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void *topo_hdl_alloc(topo_hdl_t *, size_t);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void *topo_hdl_zalloc(topo_hdl_t *, size_t);
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
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#ifdef __cplusplus
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#endif
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#endif /* _LIBTOPO_H */