#ifndef _TOPO_TREE_H
#define _TOPO_TREE_H
#include <fm/topo_mod.h>
#include <libipmi.h>
#include <topo_list.h>
#include <topo_prop.h>
#include <topo_method.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct topo_modhash topo_modhash_t;
typedef struct topo_range {
topo_instance_t tr_min;
topo_instance_t tr_max;
} topo_range_t;
typedef struct topo_nodehash {
topo_list_t th_list;
tnode_t **th_nodearr;
uint_t th_arrlen;
char *th_name;
topo_mod_t *th_enum;
topo_range_t th_range;
} topo_nodehash_t;
struct topo_node {
pthread_mutex_t tn_lock;
char *tn_name;
topo_instance_t tn_instance;
int tn_state;
int tn_fflags;
struct topo_node *tn_parent;
topo_nodehash_t *tn_phash;
topo_hdl_t *tn_hdl;
topo_mod_t *tn_enum;
topo_list_t tn_children;
topo_list_t tn_pgroups;
topo_list_t tn_methods;
void *tn_priv;
int tn_refs;
topo_vertex_t *tn_vtx;
};
#define TOPO_NODE_INIT 0x0001
#define TOPO_NODE_ROOT 0x0002
#define TOPO_NODE_BOUND 0x0004
#define TOPO_NODE_LINKED 0x0008
typedef struct topo_tree {
topo_list_t tt_list;
char *tt_scheme;
topo_mod_t *tt_mod;
struct topo_node *tt_root;
topo_walk_t *tt_walk;
} ttree_t;
struct topo_walk {
struct topo_hdl *tw_thp;
struct topo_node *tw_root;
struct topo_node *tw_node;
int (*tw_cb)();
void *tw_pdata;
topo_mod_t *tw_mod;
};
typedef struct topo_alloc {
int ta_flags;
nv_alloc_t ta_nva;
nv_alloc_ops_t ta_nvops;
void *(*ta_alloc)(size_t, int);
void *(*ta_zalloc)(size_t, int);
void (*ta_free)(void *, size_t);
} topo_alloc_t;
struct topo_hdl {
pthread_mutex_t th_lock;
char *th_uuid;
char *th_rootdir;
char *th_platform;
char *th_isa;
char *th_machine;
char *th_product;
di_node_t th_di;
di_prom_handle_t th_pi;
topo_modhash_t *th_modhash;
topo_list_t th_trees;
topo_list_t th_digraphs;
topo_alloc_t *th_alloc;
int th_errno;
int th_debug;
int th_dbout;
ipmi_handle_t *th_ipmi;
pthread_mutex_t th_ipmi_lock;
smbios_hdl_t *th_smbios;
pcidb_hdl_t *th_pcidb;
};
#define TOPO_UUID_SIZE 37
extern ttree_t *topo_tree_create(topo_hdl_t *, topo_mod_t *, const char *);
extern void topo_tree_destroy(ttree_t *);
extern int topo_tree_enum_all(topo_hdl_t *);
extern void topo_node_lock(tnode_t *);
extern void topo_node_unlock(tnode_t *);
extern void topo_node_hold(tnode_t *);
extern void topo_node_rele(tnode_t *);
extern tnode_t *topo_node_lookup(tnode_t *, const char *, topo_instance_t);
extern int topo_node_hash(topo_nodehash_t *, topo_instance_t);
extern int topo_walk_bottomup(topo_walk_t *, int);
extern topo_walk_t *topo_node_walk_init(topo_hdl_t *, topo_mod_t *, tnode_t *,
topo_walk_cb_t, void *, int *);
#ifdef __cplusplus
}
#endif
#endif