#ifndef _SYS_DEVOPS_H
#define _SYS_DEVOPS_H
#include <sys/types.h>
#include <sys/cred.h>
#include <sys/uio.h>
#include <sys/buf.h>
#include <sys/poll.h>
#include <vm/as.h>
#include <sys/dditypes.h>
#include <sys/ddidmareq.h>
#include <sys/ddimapreq.h>
#include <sys/ddipropdefs.h>
#include <sys/ddidevmap.h>
#include <sys/ddifm.h>
#include <sys/nexusdefs.h>
#include <sys/ddi_intr.h>
#include <sys/ddi_hp.h>
#include <sys/ddi_hp_impl.h>
#include <sys/aio_req.h>
#include <vm/page.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
struct cb_ops {
int (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
int (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
int (*cb_strategy)(struct buf *bp);
int (*cb_print)(dev_t dev, char *str);
int (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
int (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
int (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
int (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
cred_t *credp, int *rvalp);
int (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
size_t len, size_t *maplen, uint_t model);
int (*cb_mmap)(dev_t dev, off_t off, int prot);
int (*cb_segmap)(dev_t dev, off_t off, struct as *asp,
caddr_t *addrp, off_t len, unsigned int prot,
unsigned int maxprot, unsigned int flags, cred_t *credp);
int (*cb_chpoll)(dev_t dev, short events, int anyyet,
short *reventsp, struct pollhead **phpp);
int (*cb_prop_op)(dev_t dev, dev_info_t *dip,
ddi_prop_op_t prop_op, int mod_flags,
char *name, caddr_t valuep, int *length);
struct streamtab *cb_str;
int cb_flag;
int cb_rev;
int (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
int (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
};
#define BUSO_REV_3 3
#define BUSO_REV_4 4
#define BUSO_REV_5 5
#define BUSO_REV_6 6
#define BUSO_REV_7 7
#define BUSO_REV_8 8
#define BUSO_REV_9 9
#define BUSO_REV_10 10
#define BUSO_REV BUSO_REV_10
struct bus_ops {
int busops_rev;
int (*bus_map)(dev_info_t *dip, dev_info_t *rdip,
ddi_map_req_t *mp, off_t offset, off_t len,
caddr_t *vaddrp);
ddi_intrspec_t (*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
uint_t inumber);
int (*bus_add_intrspec)(dev_info_t *dip,
dev_info_t *rdip, ddi_intrspec_t intrspec,
ddi_iblock_cookie_t *ibcp,
ddi_idevice_cookie_t *idcp,
uint_t (*int_handler)(caddr_t intr_handler_arg),
caddr_t intr_handler_arg, int kind);
void (*bus_remove_intrspec)(dev_info_t *dip,
dev_info_t *rdip, ddi_intrspec_t intrspec,
ddi_iblock_cookie_t iblock_cookie);
int (*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
struct hat *hat, struct seg *seg, caddr_t addr,
struct devpage *dp, pfn_t pfn, uint_t prot,
uint_t lock);
int (*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
struct ddi_dma_req *dmareq,
ddi_dma_handle_t *handlep);
int (*bus_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_attr_t *attr, int (*waitfp)(caddr_t),
caddr_t arg, ddi_dma_handle_t *handlep);
int (*bus_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle);
int (*bus_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
ddi_dma_cookie_t *, uint_t *);
int (*bus_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle);
int (*bus_dma_flush)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, off_t off,
size_t len, uint_t cache_flags);
int (*bus_dma_win)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, uint_t win, off_t *offp,
size_t *lenp, ddi_dma_cookie_t *cookiep,
uint_t *ccountp);
int (*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle,
enum ddi_dma_ctlops request, off_t *offp,
size_t *lenp, caddr_t *objp, uint_t flags);
int (*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
ddi_ctl_enum_t ctlop, void *arg, void *result);
int (*bus_prop_op)(dev_t dev, dev_info_t *dip,
dev_info_t *child_dip, ddi_prop_op_t prop_op,
int mod_flags, char *name, caddr_t valuep,
int *length);
int (*bus_get_eventcookie)(dev_info_t *dip,
dev_info_t *rdip, char *eventname,
ddi_eventcookie_t *cookiep);
int (*bus_add_eventcall)(dev_info_t *dip, dev_info_t *rdip,
ddi_eventcookie_t eventid,
void (*event_hdlr)(dev_info_t *dip,
ddi_eventcookie_t event, void *arg,
void *bus_impldata), void *arg,
ddi_callback_id_t *cb_id);
int (*bus_remove_eventcall)(dev_info_t *devi,
ddi_callback_id_t cb_id);
int (*bus_post_event)(dev_info_t *dip, dev_info_t *rdip,
ddi_eventcookie_t event, void *impl_data);
int (*bus_intr_ctl)(dev_info_t *dip, dev_info_t *rdip,
ddi_intr_ctlop_t ctlop, void * arg, void * result);
int (*bus_config)(dev_info_t *parent, uint_t flags,
ddi_bus_config_op_t op, void *arg,
dev_info_t **childp);
int (*bus_unconfig)(dev_info_t *parent, uint_t flags,
ddi_bus_config_op_t op, void *arg);
int (*bus_fm_init)(dev_info_t *dip, dev_info_t *tdip,
int cap, ddi_iblock_cookie_t *ibc);
void (*bus_fm_fini)(dev_info_t *dip, dev_info_t *tdip);
void (*bus_fm_access_enter)(dev_info_t *dip,
ddi_acc_handle_t handle);
void (*bus_fm_access_exit)(dev_info_t *dip,
ddi_acc_handle_t handle);
int (*bus_power)(dev_info_t *dip, void *impl_arg,
pm_bus_power_op_t op, void *arg, void *result);
int (*bus_intr_op)(dev_info_t *dip, dev_info_t *rdip,
ddi_intr_op_t op, ddi_intr_handle_impl_t *hdlp,
void *result);
int (*bus_hp_op)(dev_info_t *dip, char *cn_name,
ddi_hp_op_t op, void *arg, void *result);
};
struct bus_ops_rev1 {
int (*bus_map)(dev_info_t *dip, dev_info_t *rdip,
ddi_map_req_t *mp, off_t offset, off_t len,
caddr_t *vaddrp);
ddi_intrspec_t (*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
uint_t inumber);
int (*bus_add_intrspec)(dev_info_t *dip,
dev_info_t *rdip, ddi_intrspec_t intrspec,
ddi_iblock_cookie_t *ibcp,
ddi_idevice_cookie_t *idcp,
uint_t (*int_handler)(caddr_t intr_handler_arg),
caddr_t intr_handler_arg, int kind);
void (*bus_remove_intrspec)(dev_info_t *dip,
dev_info_t *rdip, ddi_intrspec_t intrspec,
ddi_iblock_cookie_t iblock_cookie);
int (*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
struct hat *hat, struct seg *seg, caddr_t addr,
struct devpage *dp, pfn_t pfn, uint_t prot,
uint_t lock);
int (*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
struct ddi_dma_req *dmareq,
ddi_dma_handle_t *handlep);
int (*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle,
enum ddi_dma_ctlops request, off_t *offp,
uint_t *lenp, caddr_t *objp, uint_t flags);
int (*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
ddi_ctl_enum_t ctlop, void *arg, void *result);
int (*bus_prop_op)(dev_t dev, dev_info_t *dip,
dev_info_t *child_dip, ddi_prop_op_t prop_op,
int mod_flags, char *name, caddr_t valuep,
int *length);
};
#define DEVO_REV 4
#define CB_REV 1
#define DDI_PROBE_FAILURE ENXIO
#define DDI_PROBE_DONTCARE 0
#define DDI_PROBE_PARTIAL 1
#define DDI_PROBE_SUCCESS 2
typedef enum {
DDI_INFO_DEVT2DEVINFO = 0,
DDI_INFO_DEVT2INSTANCE = 1
} ddi_info_cmd_t;
typedef enum {
DDI_ATTACH = 0,
DDI_RESUME = 1,
DDI_PM_RESUME = 2
} ddi_attach_cmd_t;
typedef enum {
DDI_DETACH = 0,
DDI_SUSPEND = 1,
DDI_PM_SUSPEND = 2,
DDI_HOTPLUG_DETACH = 3
} ddi_detach_cmd_t;
typedef enum {
DDI_RESET_FORCE = 0
} ddi_reset_cmd_t;
struct dev_ops {
int devo_rev;
int devo_refcnt;
int (*devo_getinfo)(dev_info_t *dip,
ddi_info_cmd_t infocmd, void *arg, void **result);
int (*devo_identify)(dev_info_t *dip);
int (*devo_probe)(dev_info_t *dip);
int (*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd);
int (*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd);
int (*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd);
struct cb_ops *devo_cb_ops;
struct bus_ops *devo_bus_ops;
int (*devo_power)(dev_info_t *dip, int component,
int level);
int (*devo_quiesce)(dev_info_t *dip);
};
#define DDI_DEFINE_STREAM_OPS(XXname, XXidentify, XXprobe, XXattach, XXdetach, XXreset, XXgetinfo, XXflag, XXstream_tab, XXquiesce) \
static struct cb_ops cb_##XXname = { \
nulldev, \
nulldev, \
nodev, \
nodev, \
nodev, \
nodev, \
nodev, \
nodev, \
nodev, \
nodev, \
nodev, \
nochpoll, \
ddi_prop_op, \
(XXstream_tab), \
(int)(XXflag), \
CB_REV, \
nodev, \
nodev, \
}; \
\
static struct dev_ops XXname = { \
DEVO_REV, \
0, \
(XXgetinfo), \
(XXidentify), \
(XXprobe), \
(XXattach), \
(XXdetach), \
(XXreset), \
&(cb_##XXname), \
(struct bus_ops *)NULL, \
NULL, \
(XXquiesce) \
}
#endif
#ifdef __cplusplus
}
#endif
#endif