topo_mod.h revision 738c43b514a3570e657652233a5a19291a328a28
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _TOPO_MOD_H
#define _TOPO_MOD_H
#include <libipmi.h>
#include <libnvpair.h>
#include <libdevinfo.h>
#include <smbios.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Enumerator and method supplier module API
*/
typedef struct topo_mod topo_mod_t;
nvlist_t **);
topo_instance_t, void *, void *);
typedef struct topo_method {
const char *tm_name; /* Method name */
const char *tm_desc; /* Method description */
typedef struct topo_modops {
typedef struct topo_mod_info {
const char *tmi_desc; /* module description */
const char *tmi_scheme; /* enumeration scheme type */
extern void topo_mod_unload(topo_mod_t *);
extern void topo_mod_unregister(topo_mod_t *);
const char *, topo_instance_t, topo_instance_t, void *);
const char *);
extern void topo_mod_setspecific(topo_mod_t *, void *);
extern void *topo_mod_getspecific(topo_mod_t *);
const char *);
const char *);
const char *);
const char *, int);
/*
* Snapshot walker support
*/
topo_mod_walk_cb_t, void *, int *);
/*
* Flags for topo_mod_memfmri
*/
extern void topo_mod_ipmi_rele(topo_mod_t *);
/*
* FMRI methods
*/
#define TOPO_METH_LABEL "topo_label"
#define TOPO_METH_LABEL_DESC "label constructor"
#define TOPO_METH_LABEL_VERSION0 0
#define TOPO_METH_LABEL_ARG_NVL "label-specific"
#define TOPO_METH_LABEL_RET_STR "label-string"
#define TOPO_METH_PRESENT "topo_present"
#define TOPO_METH_PRESENT_DESC "presence indicator"
#define TOPO_METH_PRESENT_VERSION0 0
#define TOPO_METH_PRESENT_RET "present-ret"
#define TOPO_METH_REPLACED "topo_replaced"
#define TOPO_METH_REPLACED_DESC "replaced indicator"
#define TOPO_METH_REPLACED_VERSION0 0
#define TOPO_METH_REPLACED_RET "replaced-ret"
#define TOPO_METH_UNUSABLE "topo_unusable"
#define TOPO_METH_UNUSABLE_DESC "unusable indicator"
#define TOPO_METH_UNUSABLE_VERSION0 0
#define TOPO_METH_UNUSABLE_RET "unusable-ret"
#define TOPO_METH_SERVICE_STATE "topo_service_state"
#define TOPO_METH_SERVICE_STATE_DESC "service_state indicator"
#define TOPO_METH_SERVICE_STATE_VERSION0 0
#define TOPO_METH_SERVICE_STATE_RET "service_state-ret"
#define TOPO_METH_RETIRE "topo_retire"
#define TOPO_METH_RETIRE_DESC "retire action"
#define TOPO_METH_RETIRE_VERSION0 0
#define TOPO_METH_RETIRE_RET "retire-ret"
#define TOPO_METH_UNRETIRE "topo_unretire"
#define TOPO_METH_UNRETIRE_DESC "unretire action"
#define TOPO_METH_UNRETIRE_VERSION0 0
#define TOPO_METH_UNRETIRE_RET "unretire-ret"
#define TOPO_METH_EXPAND "topo_expand"
#define TOPO_METH_EXPAND_DESC "expand FMRI"
#define TOPO_METH_EXPAND_VERSION0 0
#define TOPO_METH_CONTAINS "topo_contains"
#define TOPO_METH_CONTAINS_DESC "FMRI contains sub-FMRI"
#define TOPO_METH_CONTAINS_VERSION0 0
#define TOPO_METH_CONTAINS_RET "contains-return"
#define TOPO_METH_FMRI_ARG_FMRI "fmri"
#define TOPO_METH_FMRI_ARG_SUBFMRI "sub-fmri"
#define TOPO_METH_ASRU_COMPUTE "topo_asru_compute"
#define TOPO_METH_ASRU_COMPUTE_VERSION 0
#define TOPO_METH_ASRU_COMPUTE_DESC "Dynamic ASRU constructor"
#define TOPO_METH_FRU_COMPUTE "topo_fru_compute"
#define TOPO_METH_FRU_COMPUTE_VERSION 0
#define TOPO_METH_FRU_COMPUTE_DESC "Dynamic FRU constructor"
#define TOPO_METH_DISK_STATUS "topo_disk_status"
#define TOPO_METH_DISK_STATUS_VERSION 0
#define TOPO_METH_DISK_STATUS_DESC "Disk status"
#define TOPO_METH_SENSOR_FAILURE "topo_sensor_failure"
#define TOPO_METH_SENSOR_FAILURE_VERSION 0
#define TOPO_METH_SENSOR_FAILURE_DESC "Sensor failure state"
#define TOPO_PROP_METH_DESC "Dynamic Property method"
#define TOPO_METH_IPMI_ENTITY "ipmi_entity"
#define TOPO_METH_FAC_ENUM_DESC "Facility Enumerator"
extern char *topo_mod_strdup(topo_mod_t *, const char *);
extern void topo_mod_strfree(topo_mod_t *, char *);
extern void topo_mod_clrdebug(topo_mod_t *);
extern void topo_mod_setdebug(topo_mod_t *);
extern void topo_mod_dprintf(topo_mod_t *, const char *, ...);
extern const char *topo_mod_errmsg(topo_mod_t *);
extern int topo_mod_errno(topo_mod_t *);
/*
* Topo node utilities: callable from module enumeration, topo_mod_enumerate()
*/
extern void topo_node_range_destroy(tnode_t *, const char *);
topo_instance_t, nvlist_t *);
const char *);
extern void topo_node_unbind(tnode_t *);
extern void topo_node_setspecific(tnode_t *, void *);
extern void *topo_node_getspecific(tnode_t *);
extern int topo_prop_inherit(tnode_t *, const char *, const char *, int *);
/*
* Topo property method registration
*/
extern int topo_prop_method_register(tnode_t *, const char *, const char *,
topo_type_t, const char *, const nvlist_t *, int *);
extern void topo_prop_method_unregister(tnode_t *, const char *, const char *);
/*
* This enum definition is used to define a set of error tags associated with
* the module api error conditions. The shell script mkerror.sh is
* used to parse this file and create a corresponding topo_error.c source file.
* If you do something other than add a new error tag here, you may need to
* update the mkerror shell script as it is based upon simple regexps.
*/
typedef enum topo_mod_errno {
EMOD_NOMEM, /* module memory limit exceeded */
EMOD_PARTIAL_ENUM, /* module completed partial enumeration */
EMOD_METHOD_INVAL, /* method arguments invalid */
EMOD_METHOD_NOTSUP, /* method not supported */
EMOD_FMRI_NVL, /* nvlist allocation failure for FMRI */
EMOD_FMRI_VERSION, /* invalid FMRI scheme version */
EMOD_FMRI_MALFORM, /* malformed FMRI */
EMOD_NODE_BOUND, /* node already bound */
EMOD_NODE_DUP, /* duplicate node */
EMOD_NODE_NOENT, /* node not found */
EMOD_NODE_RANGE, /* invalid node range */
EMOD_VER_ABI, /* registered with invalid ABI version */
EMOD_VER_OLD, /* attempt to load obsolete module */
EMOD_VER_NEW, /* attempt to load a newer module */
EMOD_NVL_INVAL, /* invalid nvlist */
EMOD_NONCANON, /* non-canonical component name requested */
EMOD_MOD_NOENT, /* module lookup failed */
EMOD_UKNOWN_ENUM, /* unknown enumeration error */
EMOD_END /* end of mod errno list (to ease auto-merge) */
extern int topo_mod_seterrno(topo_mod_t *, int);
#ifdef __cplusplus
}
#endif
#endif /* _TOPO_MOD_H */