#ifndef _TOPO_MODULE_H
#define _TOPO_MODULE_H
#include <fm/topo_mod.h>
#include <topo_list.h>
#include <topo_tree.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct topo_imodops {
int (*mop_init)(struct topo_mod *, topo_version_t version);
int (*mop_fini)(struct topo_mod *);
} topo_imodops_t;
#define TOPO_HASH_BUCKETS 3
struct topo_modhash {
pthread_mutex_t mh_lock;
struct topo_mod **mh_hash;
uint_t mh_hashlen;
uint_t mh_nelems;
};
typedef struct topo_imod_info {
char *tmi_desc;
char *tmi_scheme;
topo_version_t tmi_version;
topo_modops_t *tmi_ops;
} topo_imodinfo_t;
struct topo_mod {
pthread_mutex_t tm_lock;
pthread_cond_t tm_cv;
uint_t tm_busy;
struct topo_mod *tm_next;
topo_hdl_t *tm_hdl;
topo_alloc_t *tm_alloc;
char *tm_name;
char *tm_path;
char *tm_rootdir;
void *tm_priv;
uint_t tm_refs;
uint_t tm_flags;
uint_t tm_debug;
void *tm_data;
topo_imodops_t *tm_mops;
topo_imodinfo_t *tm_info;
int tm_errno;
};
#define TOPO_MOD_INIT 0x001
#define TOPO_MOD_FINI 0x002
#define TOPO_MOD_REG 0x004
#define TOPO_MOD_UNREG 0x008
extern const topo_imodops_t topo_rtld_ops;
extern void topo_mod_enter(topo_mod_t *);
extern void topo_mod_exit(topo_mod_t *);
extern void topo_mod_hold(topo_mod_t *);
extern void topo_mod_rele(topo_mod_t *);
extern topo_modhash_t *topo_modhash_create(topo_hdl_t *);
extern void topo_modhash_destroy(topo_hdl_t *);
extern topo_mod_t *topo_modhash_lookup(topo_modhash_t *, const char *);
extern topo_mod_t *topo_modhash_load(topo_hdl_t *, const char *, const char *,
const topo_imodops_t *, topo_version_t);
extern void topo_modhash_unload(topo_mod_t *);
extern void topo_modhash_unload_all(topo_hdl_t *);
extern void topo_mod_release(topo_mod_t *, tnode_t *);
extern topo_mod_t *topo_mod_lookup(topo_hdl_t *, const char *, int);
#ifdef __cplusplus
}
#endif
#endif