2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _TOPO_MODULE_H
2N/A#define _TOPO_MODULE_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include <fm/topo_mod.h>
2N/A
2N/A#include <topo_list.h>
2N/A#include <topo_tree.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/Atypedef struct topo_imodops {
2N/A int (*mop_init)(struct topo_mod *, topo_version_t version);
2N/A int (*mop_fini)(struct topo_mod *);
2N/A} topo_imodops_t;
2N/A
2N/A#define TOPO_HASH_BUCKETS 3
2N/A
2N/Astruct topo_modhash {
2N/A pthread_mutex_t mh_lock; /* hash lock */
2N/A struct topo_mod **mh_hash; /* hash bucket array */
2N/A uint_t mh_hashlen; /* size of hash bucket array */
2N/A uint_t mh_nelems; /* number of modules in hash */
2N/A};
2N/A
2N/Atypedef struct topo_imod_info {
2N/A char *tmi_desc; /* module description */
2N/A char *tmi_scheme; /* enumeration scheme-type */
2N/A topo_version_t tmi_version; /* module version */
2N/A topo_modops_t *tmi_ops; /* module ops vector */
2N/A} topo_imodinfo_t;
2N/A
2N/Astruct topo_mod {
2N/A pthread_mutex_t tm_lock; /* Lock for tm_cv/owner/flags/refs */
2N/A pthread_cond_t tm_cv; /* Module condition variable */
2N/A uint_t tm_busy; /* Busy indicator */
2N/A struct topo_mod *tm_next; /* Next module in hash chain */
2N/A topo_hdl_t *tm_hdl; /* Topo handle for this module */
2N/A topo_alloc_t *tm_alloc; /* Allocators */
2N/A char *tm_name; /* Basename of module */
2N/A char *tm_path; /* Full pathname of module file */
2N/A char *tm_rootdir; /* Relative root directory of module */
2N/A void *tm_priv; /* Module private data */
2N/A uint_t tm_refs; /* Module reference count */
2N/A uint_t tm_flags; /* Miscellaneous flags (see below) */
2N/A uint_t tm_debug; /* Debug printf mask */
2N/A void *tm_data; /* Private rtld/builtin data */
2N/A topo_imodops_t *tm_mops; /* Module class ops vector */
2N/A topo_imodinfo_t *tm_info; /* Module info registered with handle */
2N/A int tm_errno; /* Module error */
2N/A};
2N/A
2N/A#define TOPO_MOD_INIT 0x001 /* Module init completed */
2N/A#define TOPO_MOD_FINI 0x002 /* Module fini completed */
2N/A#define TOPO_MOD_REG 0x004 /* topo_modinfo_t registered */
2N/A#define TOPO_MOD_UNREG 0x008 /* Module unregistered */
2N/A
2N/Aextern const topo_imodops_t topo_rtld_ops;
2N/A
2N/Aextern void topo_mod_enter(topo_mod_t *);
2N/Aextern void topo_mod_exit(topo_mod_t *);
2N/Aextern void topo_mod_hold(topo_mod_t *);
2N/Aextern void topo_mod_rele(topo_mod_t *);
2N/A
2N/Aextern topo_modhash_t *topo_modhash_create(topo_hdl_t *);
2N/Aextern void topo_modhash_destroy(topo_hdl_t *);
2N/Aextern topo_mod_t *topo_modhash_lookup(topo_modhash_t *, const char *);
2N/Aextern topo_mod_t *topo_modhash_load(topo_hdl_t *, const char *, const char *,
2N/A const topo_imodops_t *, topo_version_t);
2N/Aextern void topo_modhash_unload(topo_mod_t *);
2N/Aextern void topo_modhash_unload_all(topo_hdl_t *);
2N/A
2N/Aextern void topo_mod_release(topo_mod_t *, tnode_t *);
2N/Aextern topo_mod_t *topo_mod_lookup(topo_hdl_t *, const char *, int);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _TOPO_MODULE_H */