#ifndef _SYS_SUNNDI_H
#define _SYS_SUNNDI_H
#include <sys/esunddi.h>
#include <sys/sunddi.h>
#include <sys/obpdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
#define NDI_SUCCESS DDI_SUCCESS
#define NDI_FAILURE DDI_FAILURE
#define NDI_NOMEM -2
#define NDI_BADHANDLE -3
#define NDI_FAULT -4
#define NDI_BUSY -5
#define NDI_UNBOUND -6
#define NDI_EINVAL -7
#define NDI_ENOTSUP -8
#define NDI_CLAIMED NDI_SUCCESS
#define NDI_UNCLAIMED -9
int
ndi_prop_create_boolean(dev_t match_dev, dev_info_t *dip, char *name);
int
ndi_prop_update_int(dev_t match_dev, dev_info_t *dip, char *name, int data);
int
ndi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, char *name,
int *data, uint_t nelements);
int
ndi_prop_update_int64(dev_t match_dev, dev_info_t *dip, char *name,
int64_t data);
int
ndi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, char *name,
int64_t *data, uint_t nelements);
int
ndi_prop_update_string(dev_t match_dev, dev_info_t *dip, char *name,
char *data);
int
ndi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
char *name, char **data, uint_t nelements);
int
ndi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
char *name, uchar_t *data, uint_t nelements);
int
ndi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
void
ndi_prop_remove_all(dev_info_t *dip);
int
ndi_devi_alloc(dev_info_t *parent, const char *node_name, pnode_t nodeid,
dev_info_t **ret_dip);
void
ndi_devi_alloc_sleep(dev_info_t *parent, const char *node_name, pnode_t nodeid,
dev_info_t **ret_dip);
int
ndi_devi_free(dev_info_t *dip);
void ndi_devi_enter(dev_info_t *dip);
void ndi_devi_exit(dev_info_t *dip);
int ndi_devi_tryenter(dev_info_t *dip);
void ndi_hold_devi(dev_info_t *dip);
void ndi_rele_devi(dev_info_t *dip);
struct dev_ops *ndi_hold_driver(dev_info_t *dip);
void ndi_rele_driver(dev_info_t *dip);
int
ndi_devi_set_nodename(dev_info_t *dip, char *name, int flags);
int
ndi_devi_bind_driver(dev_info_t *dip, uint_t flags);
int
ndi_devi_bind_driver_async(dev_info_t *dip, uint_t flags);
int
ndi_devctl_device_getstate(dev_info_t *parent, struct devctl_iocdata *dcp,
uint_t *state);
int
ndi_devctl_device_online(dev_info_t *dip, struct devctl_iocdata *dcp,
uint_t flags);
int
ndi_devctl_device_offline(dev_info_t *dip, struct devctl_iocdata *dcp,
uint_t flags);
int
ndi_devctl_device_remove(dev_info_t *dip, struct devctl_iocdata *dcp,
uint_t flags);
int
ndi_devctl_bus_getstate(dev_info_t *dip, struct devctl_iocdata *dcp,
uint_t *state);
int
ndi_devi_online(dev_info_t *dip, uint_t flags);
int
ndi_devctl_ioctl(dev_info_t *dip, int cmd, intptr_t arg, int mode,
uint_t flags);
int
ndi_devi_online_async(dev_info_t *dip, uint_t flags);
int
ndi_devi_config(dev_info_t *dip, int flags);
int
ndi_devi_config_driver(dev_info_t *dip, int flags, major_t major);
int
ndi_devi_config_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, int flags);
int
ndi_devi_unconfig(dev_info_t *dip, int flags);
int
e_ddi_devi_unconfig(dev_info_t *dip, dev_info_t **dipp, int flags);
int
ndi_devi_unconfig_one(dev_info_t *dip, char *devnm, dev_info_t **dipp,
int flags);
int
ndi_devi_unconfig_driver(dev_info_t *dip, int flags, major_t major);
void
ndi_set_bus_private(dev_info_t *dip, boolean_t up, uint32_t port_type,
void *data);
void *
ndi_get_bus_private(dev_info_t *dip, boolean_t up);
boolean_t
ndi_port_type(dev_info_t *dip, boolean_t up, uint32_t port_type);
int
ndi_irm_create(dev_info_t *dip, ddi_irm_params_t *paramsp,
ddi_irm_pool_t **pool_retp);
int
ndi_irm_destroy(ddi_irm_pool_t *poolp);
int
ndi_irm_resize_pool(ddi_irm_pool_t *poolp, uint_t newsize);
#define NDI_DEVI_REMOVE 0x00000001
#define NDI_ONLINE_ATTACH 0x00000002
#define NDI_MDI_FALLBACK 0x00000004
#define NDI_CONFIG 0x00000008
#define NDI_UNCONFIG 0x00000010
#define NDI_DEVI_BIND 0x00000020
#define NDI_DEVI_PERSIST 0x00000040
#define NDI_PROMNAME 0x00000080
#define NDI_DEVFS_CLEAN 0x00001000
#define NDI_AUTODETACH 0x00002000
#define NDI_NO_EVENT 0x00004000
#define NDI_DEVI_DEBUG 0x00008000
#define NDI_CONFIG_REPROBE 0x00010000
#define NDI_DEVI_ONLINE 0x00020000
#define NDI_DEVI_OFFLINE 0x00040000
#define NDI_POST_EVENT 0x00080000
#define NDI_BRANCH_EVENT_OP 0x01000000
#define NDI_NO_EVENT_STATE_CHNG 0x02000000
#define NDI_DRV_CONF_REPROBE 0x04000000
#define NDI_DETACH_DRIVER 0x08000000
#define NDI_MTC_OFF 0x10000000
#define NDI_USER_REQ 0x20000000
#define NDI_SLEEP 0x000000
#define NDI_NOSLEEP 0x100000
#define NDI_EVENT_NOPASS 0x200000
int
ndi_devi_offline(dev_info_t *dip, uint_t flags);
dev_info_t *
ndi_devi_find(dev_info_t *p, char *cname, char *caddr);
dev_info_t *
ndi_devi_findchild(dev_info_t *p, char *devname);
dev_info_t *
ndi_devi_findchild_by_callback(dev_info_t *p, char *dname, char *ua,
int (*make_ua)(dev_info_t *, char *, int));
int
ndi_devi_device_isremoved(dev_info_t *dip);
int
ndi_devi_device_remove(dev_info_t *dip);
int
ndi_devi_device_insert(dev_info_t *dip);
#define NDI_DEBUG(flags, args) \
if (flags & NDI_DEVI_DEBUG) cmn_err args
int
ndi_dc_allochdl(void *iocarg, struct devctl_iocdata **rdcp);
void
ndi_dc_freehdl(struct devctl_iocdata *dcp);
char *
ndi_dc_getpath(struct devctl_iocdata *dcp);
char *
ndi_dc_getname(struct devctl_iocdata *dcp);
char *
ndi_dc_getaddr(struct devctl_iocdata *dcp);
nvlist_t *
ndi_dc_get_ap_data(struct devctl_iocdata *dcp);
char *
ndi_dc_getminorname(struct devctl_iocdata *dcp);
int
ndi_dc_return_dev_state(dev_info_t *dip, struct devctl_iocdata *dcp);
int
ndi_dc_return_ap_state(devctl_ap_state_t *ap, struct devctl_iocdata *dcp);
int
ndi_dc_return_bus_state(dev_info_t *dip, struct devctl_iocdata *dcp);
int
ndi_dc_devi_create(struct devctl_iocdata *dcp, dev_info_t *pdip, int flags,
dev_info_t **rdip);
int
ndi_get_bus_state(dev_info_t *dip, uint_t *rstate);
int
ndi_set_bus_state(dev_info_t *dip, uint_t state);
int
ndi_post_event(dev_info_t *dip, dev_info_t *rdip, ddi_eventcookie_t eventhdl,
void *impl_data);
int
ndi_busop_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
ddi_eventcookie_t eventhdl, void (*callback)(), void *arg,
ddi_callback_id_t *cb_id);
int
ndi_busop_remove_eventcall(dev_info_t *ddip, ddi_callback_id_t id);
int
ndi_busop_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, char *name,
ddi_eventcookie_t *event_cookiep);
typedef struct ndi_event_hdl *ndi_event_hdl_t;
typedef struct ndi_event_callbacks {
struct ndi_event_callbacks *ndi_evtcb_next;
struct ndi_event_callbacks *ndi_evtcb_prev;
dev_info_t *ndi_evtcb_dip;
char *devname;
void (*ndi_evtcb_callback)();
void *ndi_evtcb_arg;
ddi_eventcookie_t ndi_evtcb_cookie;
} ndi_event_callbacks_t;
typedef struct ndi_event_definition {
int ndi_event_tag;
char *ndi_event_name;
ddi_plevel_t ndi_event_plevel;
uint_t ndi_event_attributes;
} ndi_event_definition_t;
typedef struct ndi_event_cookie {
ndi_event_definition_t *definition;
dev_info_t *ddip;
ndi_event_callbacks_t *callback_list;
struct ndi_event_cookie *next_cookie;
} ndi_event_cookie_t;
#define NDI_EVENT(cookie) ((struct ndi_event_cookie *)(void *)(cookie))
#define NDI_EVENT_NAME(cookie) (NDI_EVENT(cookie)->definition->ndi_event_name)
#define NDI_EVENT_TAG(cookie) (NDI_EVENT(cookie)->definition->ndi_event_tag)
#define NDI_EVENT_ATTRIBUTES(cookie) \
(NDI_EVENT(cookie)->definition->ndi_event_attributes)
#define NDI_EVENT_PLEVEL(cookie) \
(NDI_EVENT(cookie)->definition->ndi_event_plevel)
#define NDI_EVENT_DDIP(cookie) (NDI_EVENT(cookie)->ddip)
#define NDI_EVENT_POST_TO_ALL 0x0
#define NDI_EVENT_POST_TO_TGT 0x1
typedef struct ndi_event_set {
ushort_t ndi_events_version;
ushort_t ndi_n_events;
ndi_event_definition_t *ndi_event_defs;
} ndi_event_set_t;
#define NDI_EVENTS_REV0 0
#define NDI_EVENTS_REV1 1
int
ndi_event_alloc_hdl(dev_info_t *dip, ddi_iblock_cookie_t cookie,
ndi_event_hdl_t *ndi_event_hdl, uint_t flag);
int
ndi_event_free_hdl(ndi_event_hdl_t handle);
int
ndi_event_bind_set(ndi_event_hdl_t handle, ndi_event_set_t *ndi_event_set,
uint_t flag);
int
ndi_event_unbind_set(ndi_event_hdl_t handle, ndi_event_set_t *ndi_event_set,
uint_t flag);
int
ndi_event_retrieve_cookie(ndi_event_hdl_t handle, dev_info_t *child_dip,
char *eventname, ddi_eventcookie_t *cookiep, uint_t flag);
int
ndi_event_add_callback(ndi_event_hdl_t handle, dev_info_t *child_dip,
ddi_eventcookie_t cookie, ddi_event_cb_f event_callback, void *arg,
uint_t flag, ddi_callback_id_t *cb_id);
int
ndi_event_remove_callback(ndi_event_hdl_t handle, ddi_callback_id_t id);
int
ndi_event_run_callbacks(ndi_event_hdl_t handle, dev_info_t *child_dip,
ddi_eventcookie_t cookie, void *bus_impldata);
int ndi_event_do_callback(ndi_event_hdl_t handle, dev_info_t *child_dip,
ddi_eventcookie_t cookie, void *bus_impldata);
ddi_eventcookie_t
ndi_event_tag_to_cookie(ndi_event_hdl_t handle, int event_tag);
int
ndi_event_cookie_to_tag(ndi_event_hdl_t handle,
ddi_eventcookie_t cookie);
char *
ndi_event_cookie_to_name(ndi_event_hdl_t handle,
ddi_eventcookie_t cookie);
char *
ndi_event_tag_to_name(ndi_event_hdl_t handle, int event_tag);
dev_info_t *
ndi_devi_config_vhci(char *, int);
#ifdef DEBUG
void
ndi_event_dump_hdl(struct ndi_event_hdl *hdl, char *location);
#endif
int
ndi_busop_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op,
void *arg, dev_info_t **child, clock_t reset_delay);
int
ndi_busop_bus_unconfig(dev_info_t *dip, uint_t flags, ddi_bus_config_op_t op,
void *arg);
int
ndi_hp_register(dev_info_t *dip, ddi_hp_cn_info_t *info_p);
int
ndi_hp_unregister(dev_info_t *dip, char *cn_name);
int
ndi_hp_state_change_req(dev_info_t *dip, char *cn_name,
ddi_hp_cn_state_t state, uint_t flag);
void
ndi_hp_walk_cn(dev_info_t *dip, int (*f)(ddi_hp_cn_info_t *, void *),
void *arg);
typedef struct ndi_ra_request {
uint_t ra_flags;
uint64_t ra_len;
uint64_t ra_addr;
uint64_t ra_boundbase;
uint64_t ra_boundlen;
uint64_t ra_align_mask;
} ndi_ra_request_t;
#define NDI_RA_ALIGN_SIZE 0x0001
#define NDI_RA_ALLOC_BOUNDED 0x0002
#define NDI_RA_ALLOC_SPECIFIED 0x0004
#define NDI_RA_ALLOC_PARTIAL_OK 0x0008
#define NDI_RA_PARTIAL_REQ -7
#define NDI_RA_TYPE_MEM "memory"
#define NDI_RA_TYPE_IO "io"
#define NDI_RA_TYPE_PCI_BUSNUM "pci_bus_number"
#define NDI_RA_TYPE_PCI_PREFETCH_MEM "pci_prefetchable_memory"
#define NDI_RA_TYPE_INTR "interrupt"
#define NDI_RA_PASS 0x0001
int
ndi_ra_map_setup(dev_info_t *dip, char *type);
int
ndi_ra_map_destroy(dev_info_t *dip, char *type);
int
ndi_ra_alloc(dev_info_t *dip, ndi_ra_request_t *req, uint64_t *basep,
uint64_t *lenp, char *type, uint_t flag);
int
ndi_ra_free(dev_info_t *dip, uint64_t base, uint64_t len, char *type,
uint_t flag);
int ndi_dev_is_prom_node(dev_info_t *);
int ndi_dev_is_pseudo_node(dev_info_t *);
int ndi_dev_is_persistent_node(dev_info_t *);
int ndi_dev_is_hotplug_node(dev_info_t *);
int ndi_dev_is_hidden_node(dev_info_t *);
void ndi_devi_set_hidden(dev_info_t *);
void ndi_devi_clr_hidden(dev_info_t *);
#define DDI_DEVI_FAULT_EVENT "DDI:DEVI_FAULT"
struct ddi_fault_event_data {
dev_info_t *f_dip;
ddi_fault_impact_t f_impact;
ddi_fault_location_t f_location;
const char *f_message;
ddi_devstate_t f_oldstate;
};
void ndi_set_acc_fault(ddi_acc_handle_t ah);
void ndi_clr_acc_fault(ddi_acc_handle_t ah);
void ndi_set_dma_fault(ddi_dma_handle_t dh);
void ndi_clr_dma_fault(ddi_dma_handle_t dh);
int ndi_merge_node(dev_info_t *, int (*)(dev_info_t *, char *, int));
void ndi_merge_wildcard_node(dev_info_t *);
#define NDI_FLAVOR_VANILLA 0
void ndi_flavorv_alloc(dev_info_t *self, int nflavors);
void ndi_flavorv_set(dev_info_t *self, ndi_flavor_t child_flavor, void *);
void *ndi_flavorv_get(dev_info_t *self, ndi_flavor_t child_flavor);
void ndi_flavor_set(dev_info_t *child, ndi_flavor_t child_flavor);
ndi_flavor_t ndi_flavor_get(dev_info_t *child);
#endif
#ifdef __cplusplus
}
#endif
#endif