27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
51939740Sherry Moore * Common Development and Distribution License (the "License").
61939740Sherry Moore * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
222694730Evan Yan * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bdstevel@tonic-gate * Use is subject to license terms.
247c478bdstevel@tonic-gate */
25cd21e7cGarrett D'Amore/*
26cd21e7cGarrett D'Amore * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
27cd21e7cGarrett D'Amore */
297c478bdstevel@tonic-gate#ifndef	_SYS_DEVOPS_H
307c478bdstevel@tonic-gate#define	_SYS_DEVOPS_H
327c478bdstevel@tonic-gate#include <sys/types.h>
337c478bdstevel@tonic-gate#include <sys/cred.h>
347c478bdstevel@tonic-gate#include <sys/uio.h>
357c478bdstevel@tonic-gate#include <sys/buf.h>
367c478bdstevel@tonic-gate#include <sys/poll.h>
377c478bdstevel@tonic-gate#include <vm/as.h>
397c478bdstevel@tonic-gate#include <sys/dditypes.h>
407c478bdstevel@tonic-gate#include <sys/ddidmareq.h>
417c478bdstevel@tonic-gate#include <sys/ddimapreq.h>
427c478bdstevel@tonic-gate#include <sys/ddipropdefs.h>
437c478bdstevel@tonic-gate#include <sys/ddidevmap.h>
447c478bdstevel@tonic-gate#include <sys/ddifm.h>
457c478bdstevel@tonic-gate#include <sys/nexusdefs.h>
467c478bdstevel@tonic-gate#include <sys/ddi_intr.h>
472694730Evan Yan#include <sys/ddi_hp.h>
482694730Evan Yan#include <sys/ddi_hp_impl.h>
497c478bdstevel@tonic-gate#include <sys/aio_req.h>
507c478bdstevel@tonic-gate#include <vm/page.h>
527c478bdstevel@tonic-gate#ifdef	__cplusplus
537c478bdstevel@tonic-gateextern "C" {
567c478bdstevel@tonic-gate#ifdef	_KERNEL
597c478bdstevel@tonic-gate * cb_ops:	Leaf device drivers or bus nexus drivers supporting
607c478bdstevel@tonic-gate *		direct user process access (open/close/etc).
617c478bdstevel@tonic-gate *
627c478bdstevel@tonic-gate * This is an OR of cdevsw and bdevsw fields for drivers that
637c478bdstevel@tonic-gate * support both character and block entry points.
647c478bdstevel@tonic-gate *
657c478bdstevel@tonic-gate * For streams stuff, see also sys/stream.h.
667c478bdstevel@tonic-gate *
677c478bdstevel@tonic-gate * The following DDI/DKI or DKI only or DDI only functions are
687c478bdstevel@tonic-gate * provided in the character/block driver operations structure.
697c478bdstevel@tonic-gate *
707c478bdstevel@tonic-gate *	block/char	Function	description
717c478bdstevel@tonic-gate *	b/c		XXopen		DDI/DKI
727c478bdstevel@tonic-gate *	b/c		XXclose		DDI/DKI
737c478bdstevel@tonic-gate *	b		XXstrategy	DDI/DKI
747c478bdstevel@tonic-gate *	b  		XXprint		DDI/DKI
757c478bdstevel@tonic-gate *	b  		XXdump		DDI(Sun)
767c478bdstevel@tonic-gate *	  c		XXread		DDI/DKI
777c478bdstevel@tonic-gate *	  c		XXwrite		DDI/DKI
787c478bdstevel@tonic-gate *	  c		XXioctl		DDI/DKI
797c478bdstevel@tonic-gate *	  c		XXdevmap	DDI(Sun)
80cd21e7cGarrett D'Amore *	  c		XXmmap		DKI(Obsolete)
817c478bdstevel@tonic-gate *	  c		XXsegmap	DKI
827c478bdstevel@tonic-gate *	  c		XXchpoll	DDI/DKI
837c478bdstevel@tonic-gate *	  c		XXprop_op	DDI(Sun)
84cd21e7cGarrett D'Amore *	  c		XXaread		DDI(Sun)
85cd21e7cGarrett D'Amore *	  c		XXawrite	DDI(Sun)
867c478bdstevel@tonic-gate */
887c478bdstevel@tonic-gatestruct cb_ops  {
897c478bdstevel@tonic-gate	int	(*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
907c478bdstevel@tonic-gate	int	(*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
917c478bdstevel@tonic-gate	int	(*cb_strategy)(struct buf *bp);
927c478bdstevel@tonic-gate	int	(*cb_print)(dev_t dev, char *str);
937c478bdstevel@tonic-gate	int	(*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
947c478bdstevel@tonic-gate	int	(*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
957c478bdstevel@tonic-gate	int	(*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
967c478bdstevel@tonic-gate	int	(*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
977c478bdstevel@tonic-gate		    cred_t *credp, int *rvalp);
987c478bdstevel@tonic-gate	int	(*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
997c478bdstevel@tonic-gate			size_t len, size_t *maplen, uint_t model);
1007c478bdstevel@tonic-gate	int	(*cb_mmap)(dev_t dev, off_t off, int prot);
1017c478bdstevel@tonic-gate	int	(*cb_segmap)(dev_t dev, off_t off, struct as *asp,
1027c478bdstevel@tonic-gate		    caddr_t *addrp, off_t len, unsigned int prot,
1037c478bdstevel@tonic-gate		    unsigned int maxprot, unsigned int flags, cred_t *credp);
1047c478bdstevel@tonic-gate	int	(*cb_chpoll)(dev_t dev, short events, int anyyet,
1057c478bdstevel@tonic-gate		    short *reventsp, struct pollhead **phpp);
1067c478bdstevel@tonic-gate	int	(*cb_prop_op)(dev_t dev, dev_info_t *dip,
1077c478bdstevel@tonic-gate		    ddi_prop_op_t prop_op, int mod_flags,
1087c478bdstevel@tonic-gate		    char *name, caddr_t valuep, int *length);
1107c478bdstevel@tonic-gate	struct streamtab *cb_str;	/* streams information */
1127c478bdstevel@tonic-gate	/*
1137c478bdstevel@tonic-gate	 * The cb_flag fields are here to tell the system a
1147c478bdstevel@tonic-gate	 * bit about the device. The bit definitions are
1157c478bdstevel@tonic-gate	 * in <sys/conf.h>.
1167c478bdstevel@tonic-gate	 */
1177c478bdstevel@tonic-gate	int	cb_flag;		/* driver compatibility flag */
1187c478bdstevel@tonic-gate	int	cb_rev;			/* cb_ops version number */
1197c478bdstevel@tonic-gate	int	(*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
1207c478bdstevel@tonic-gate	int	(*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
1247c478bdstevel@tonic-gate * bus_ops:	bus nexus drivers only.
1257c478bdstevel@tonic-gate *
1267c478bdstevel@tonic-gate * These functions are used to implement the Sun DDI functions
1277c478bdstevel@tonic-gate * described elsewhere.
1287c478bdstevel@tonic-gate *
1297c478bdstevel@tonic-gate * Only nexus drivers support these entry points.
1307c478bdstevel@tonic-gate *
1317c478bdstevel@tonic-gate * The following bus nexus functions are provided in the bus nexus
1327c478bdstevel@tonic-gate * driver operations structure.  Note that all functions take both
1337c478bdstevel@tonic-gate * their dip and the requesters dip except for the child functions since
1347c478bdstevel@tonic-gate * they will be called from outside the ddi.
1357c478bdstevel@tonic-gate *
1367c478bdstevel@tonic-gate *	bus_map			-  Map/unmap/control IU -> device mappings.
137cd21e7cGarrett D'Amore *	bus_get_intrspec	-  obsolete, not called
138cd21e7cGarrett D'Amore *	bus_add_intrspec	-  obsolete, not called
139cd21e7cGarrett D'Amore *	bus_remove_intrspec	-  obsolete, not called
1407c478bdstevel@tonic-gate *	bus_map_fault		-  bus fault handler
141cd21e7cGarrett D'Amore *	bus_dma_map		-  obsolete, not called
142cd21e7cGarrett D'Amore *	bus_dma_allochdl	-  allocate a DMA handle
143cd21e7cGarrett D'Amore *	bus_dma_freehdl		-  free a DMA handle
144cd21e7cGarrett D'Amore *	bus_dma_bindhdl		-  bind a DMA handle to physical mapping
145cd21e7cGarrett D'Amore *	bus_dma_unbindhdl	-  unbind a DMA handle to physical mapping
146cd21e7cGarrett D'Amore *	bus_dma_flush		-  flush DMA caches
147cd21e7cGarrett D'Amore *	bus_dma_win		-  access DMA windows
148cd21e7cGarrett D'Amore *	bus_dma_ctl		-  control dma mapping (legacy use only)
1497c478bdstevel@tonic-gate *	bus_ctl			-  generic control operations
150cd21e7cGarrett D'Amore *	bus_prop_op		-  request for property
151cd21e7cGarrett D'Amore *	bus_get_eventcookie	-  get an event cookie
152cd21e7cGarrett D'Amore *	bus_add_eventcall	-  event call management
153cd21e7cGarrett D'Amore *	bus_remove_eventcall	-  event call management
154cd21e7cGarrett D'Amore *	bus_post_event		-  post an event
155cd21e7cGarrett D'Amore *	bus_config		-  child node configuration
156cd21e7cGarrett D'Amore *	bus_unconfig		-  child node unconfiguration
157cd21e7cGarrett D'Amore *	bus_fm_init		-  FMA support
158cd21e7cGarrett D'Amore *	bus_fm_fini		-  FMA support
159cd21e7cGarrett D'Amore *	bus_fm_access_enter	-  FMA support
160cd21e7cGarrett D'Amore *	bus_fm_access_exit	-  FMA support
161cd21e7cGarrett D'Amore *	bus_power		-  power management
162cd21e7cGarrett D'Amore *	bus_intr_op		-  control interrupt mappings
163cd21e7cGarrett D'Amore *	bus_hp_op		-  hotplug support
1647c478bdstevel@tonic-gate */
1667c478bdstevel@tonic-gate#define	BUSO_REV_3	3
1677c478bdstevel@tonic-gate#define	BUSO_REV_4	4
1687c478bdstevel@tonic-gate#define	BUSO_REV_5	5
1697c478bdstevel@tonic-gate#define	BUSO_REV_6	6
1707c478bdstevel@tonic-gate#define	BUSO_REV_7	7
1717c478bdstevel@tonic-gate#define	BUSO_REV_8	8
1727c478bdstevel@tonic-gate#define	BUSO_REV_9	9
1732694730Evan Yan#define	BUSO_REV_10	10
1742694730Evan Yan#define	BUSO_REV	BUSO_REV_10
1777c478bdstevel@tonic-gatestruct bus_ops  {
1787c478bdstevel@tonic-gate	int		busops_rev;	/* rev of this structure */
1797c478bdstevel@tonic-gate	int		(*bus_map)(dev_info_t *dip, dev_info_t *rdip,
1807c478bdstevel@tonic-gate			    ddi_map_req_t *mp, off_t offset, off_t len,
1817c478bdstevel@tonic-gate			    caddr_t *vaddrp);
1837c478bdstevel@tonic-gate	/*
1847c478bdstevel@tonic-gate	 * NOTE: the following 3 busops entrypoints are obsoleted with
1857c478bdstevel@tonic-gate	 * version 9 or greater. Use bus_intr_op interface in place of
1867c478bdstevel@tonic-gate	 * these obsolete interfaces.
1877c478bdstevel@tonic-gate	 */
1887c478bdstevel@tonic-gate	ddi_intrspec_t	(*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
1897c478bdstevel@tonic-gate			    uint_t inumber);
1907c478bdstevel@tonic-gate	int		(*bus_add_intrspec)(dev_info_t *dip,
1917c478bdstevel@tonic-gate			    dev_info_t *rdip, ddi_intrspec_t intrspec,
1927c478bdstevel@tonic-gate			    ddi_iblock_cookie_t *ibcp,
1937c478bdstevel@tonic-gate			    ddi_idevice_cookie_t *idcp,
1947c478bdstevel@tonic-gate			    uint_t (*int_handler)(caddr_t intr_handler_arg),
1957c478bdstevel@tonic-gate			    caddr_t intr_handler_arg, int kind);
1967c478bdstevel@tonic-gate	void		(*bus_remove_intrspec)(dev_info_t *dip,
1977c478bdstevel@tonic-gate			    dev_info_t *rdip, ddi_intrspec_t intrspec,
1987c478bdstevel@tonic-gate			    ddi_iblock_cookie_t iblock_cookie);
2007c478bdstevel@tonic-gate	int		(*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
2017c478bdstevel@tonic-gate			    struct hat *hat, struct seg *seg, caddr_t addr,
2027c478bdstevel@tonic-gate			    struct devpage *dp, pfn_t pfn, uint_t prot,
2037c478bdstevel@tonic-gate			    uint_t lock);
2047c478bdstevel@tonic-gate	int		(*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
2057c478bdstevel@tonic-gate			    struct ddi_dma_req *dmareq,
2067c478bdstevel@tonic-gate			    ddi_dma_handle_t *handlep);
2077c478bdstevel@tonic-gate	int		(*bus_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip,
2087c478bdstevel@tonic-gate			    ddi_dma_attr_t *attr, int (*waitfp)(caddr_t),
2097c478bdstevel@tonic-gate			    caddr_t arg, ddi_dma_handle_t *handlep);
2107c478bdstevel@tonic-gate	int		(*bus_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip,
2117c478bdstevel@tonic-gate			    ddi_dma_handle_t handle);
2127c478bdstevel@tonic-gate	int		(*bus_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip,
2137c478bdstevel@tonic-gate			    ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
2147c478bdstevel@tonic-gate			    ddi_dma_cookie_t *, uint_t *);
2157c478bdstevel@tonic-gate	int		(*bus_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip,
2167c478bdstevel@tonic-gate			    ddi_dma_handle_t handle);
2177c478bdstevel@tonic-gate	int		(*bus_dma_flush)(dev_info_t *dip, dev_info_t *rdip,
2187c478bdstevel@tonic-gate			    ddi_dma_handle_t handle, off_t off,
2197c478bdstevel@tonic-gate			    size_t len, uint_t cache_flags);
2207c478bdstevel@tonic-gate	int		(*bus_dma_win)(dev_info_t *dip, dev_info_t *rdip,
2217c478bdstevel@tonic-gate			    ddi_dma_handle_t handle, uint_t win, off_t *offp,
2227c478bdstevel@tonic-gate			    size_t *lenp, ddi_dma_cookie_t *cookiep,
2237c478bdstevel@tonic-gate			    uint_t *ccountp);
2247c478bdstevel@tonic-gate	int		(*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
2257c478bdstevel@tonic-gate			    ddi_dma_handle_t handle,
2267c478bdstevel@tonic-gate			    enum ddi_dma_ctlops request, off_t *offp,
2277c478bdstevel@tonic-gate			    size_t *lenp, caddr_t *objp, uint_t flags);
2287c478bdstevel@tonic-gate	int		(*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
2297c478bdstevel@tonic-gate			    ddi_ctl_enum_t ctlop, void *arg, void *result);
2307c478bdstevel@tonic-gate	int		(*bus_prop_op)(dev_t dev, dev_info_t *dip,
2317c478bdstevel@tonic-gate			    dev_info_t *child_dip, ddi_prop_op_t prop_op,
2327c478bdstevel@tonic-gate			    int mod_flags, char *name, caddr_t valuep,
2337c478bdstevel@tonic-gate			    int *length);
2347c478bdstevel@tonic-gate	/*
2357c478bdstevel@tonic-gate	 * NOTE: the following 4 busops entrypoints are only available
2367c478bdstevel@tonic-gate	 * with version 3 or greater.  Due to interface modifications, these
2377c478bdstevel@tonic-gate	 * entrypoints can only be used with version 6 or greater.
2387c478bdstevel@tonic-gate	 */
2407c478bdstevel@tonic-gate	int		(*bus_get_eventcookie)(dev_info_t *dip,
2417c478bdstevel@tonic-gate			    dev_info_t *rdip, char *eventname,
2427c478bdstevel@tonic-gate			    ddi_eventcookie_t *cookiep);
2437c478bdstevel@tonic-gate	int		(*bus_add_eventcall)(dev_info_t *dip, dev_info_t *rdip,
2447c478bdstevel@tonic-gate			    ddi_eventcookie_t eventid,
2457c478bdstevel@tonic-gate			    void (*event_hdlr)(dev_info_t *dip,
2467c478bdstevel@tonic-gate			    ddi_eventcookie_t event, void *arg,
2477c478bdstevel@tonic-gate			    void *bus_impldata), void *arg,
2487c478bdstevel@tonic-gate			    ddi_callback_id_t *cb_id);
2497c478bdstevel@tonic-gate	int		(*bus_remove_eventcall)(dev_info_t *devi,
2507c478bdstevel@tonic-gate			    ddi_callback_id_t cb_id);
2517c478bdstevel@tonic-gate	int		(*bus_post_event)(dev_info_t *dip, dev_info_t *rdip,
2527c478bdstevel@tonic-gate			    ddi_eventcookie_t event, void *impl_data);
2547c478bdstevel@tonic-gate	/*
2557c478bdstevel@tonic-gate	 * NOTE: the following bus_intr_ctl entrypoint is obsoleted with
2567c478bdstevel@tonic-gate	 * version 9 or greater. Use bus_intr_op interface in place of
2577c478bdstevel@tonic-gate	 * this obsolete interface.
2587c478bdstevel@tonic-gate	 */
2597c478bdstevel@tonic-gate	int		(*bus_intr_ctl)(dev_info_t *dip, dev_info_t *rdip,
2607c478bdstevel@tonic-gate			    ddi_intr_ctlop_t ctlop, void * arg, void * result);
2617c478bdstevel@tonic-gate	/*
2627c478bdstevel@tonic-gate	 * NOTE: the following busop entrypoints are available with version
2637c478bdstevel@tonic-gate	 * 5 or greater.
2647c478bdstevel@tonic-gate	 */
2657c478bdstevel@tonic-gate	int		(*bus_config)(dev_info_t *parent, uint_t flags,
2667c478bdstevel@tonic-gate			    ddi_bus_config_op_t op, void *arg,
2677c478bdstevel@tonic-gate			    dev_info_t **childp);
2687c478bdstevel@tonic-gate	int		(*bus_unconfig)(dev_info_t *parent, uint_t flags,
2697c478bdstevel@tonic-gate			    ddi_bus_config_op_t op, void *arg);
2717c478bdstevel@tonic-gate	/*
2727c478bdstevel@tonic-gate	 * NOTE: the following busop entrypoints are available with version
2737c478bdstevel@tonic-gate	 * 6 or greater.
2747c478bdstevel@tonic-gate	 */
2757c478bdstevel@tonic-gate	int		(*bus_fm_init)(dev_info_t *dip, dev_info_t *tdip,
2767c478bdstevel@tonic-gate			    int cap, ddi_iblock_cookie_t *ibc);
2777c478bdstevel@tonic-gate	void		(*bus_fm_fini)(dev_info_t *dip, dev_info_t *tdip);
2787c478bdstevel@tonic-gate	void		(*bus_fm_access_enter)(dev_info_t *dip,
2797c478bdstevel@tonic-gate			    ddi_acc_handle_t handle);
2807c478bdstevel@tonic-gate	void		(*bus_fm_access_exit)(dev_info_t *dip,
2817c478bdstevel@tonic-gate			    ddi_acc_handle_t handle);
2837c478bdstevel@tonic-gate	/*
2847c478bdstevel@tonic-gate	 * NOTE: the following busop entrypoint is available with version
2857c478bdstevel@tonic-gate	 * 7 or greater.
2867c478bdstevel@tonic-gate	 */
2877c478bdstevel@tonic-gate	int		(*bus_power)(dev_info_t *dip, void *impl_arg,
2887c478bdstevel@tonic-gate			    pm_bus_power_op_t op, void *arg, void *result);
2907c478bdstevel@tonic-gate	/*
2917c478bdstevel@tonic-gate	 * NOTE: the following busop entrypoint is available with version
2927c478bdstevel@tonic-gate	 * 9 or greater.
2937c478bdstevel@tonic-gate	 */
2947c478bdstevel@tonic-gate	int		(*bus_intr_op)(dev_info_t *dip, dev_info_t *rdip,
2957c478bdstevel@tonic-gate			    ddi_intr_op_t op, ddi_intr_handle_impl_t *hdlp,
2967c478bdstevel@tonic-gate			    void *result);
2972694730Evan Yan
2982694730Evan Yan	/*
2992694730Evan Yan	 * NOTE: the following busop entrypoint is available with version
3002694730Evan Yan	 * 10 or greater.
3012694730Evan Yan	 */
3022694730Evan Yan	int		(*bus_hp_op)(dev_info_t *dip, char *cn_name,
3032694730Evan Yan			    ddi_hp_op_t op, void *arg, void *result);
3077c478bdstevel@tonic-gate * REV 1 bus ops structure
3087c478bdstevel@tonic-gate */
3107c478bdstevel@tonic-gatestruct bus_ops_rev1 {
3117c478bdstevel@tonic-gate	int		(*bus_map)(dev_info_t *dip, dev_info_t *rdip,
3127c478bdstevel@tonic-gate			    ddi_map_req_t *mp, off_t offset, off_t len,
3137c478bdstevel@tonic-gate			    caddr_t *vaddrp);
3147c478bdstevel@tonic-gate	ddi_intrspec_t	(*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
3157c478bdstevel@tonic-gate			    uint_t inumber);
3167c478bdstevel@tonic-gate	int		(*bus_add_intrspec)(dev_info_t *dip,
3177c478bdstevel@tonic-gate			    dev_info_t *rdip, ddi_intrspec_t intrspec,
3187c478bdstevel@tonic-gate			    ddi_iblock_cookie_t *ibcp,
3197c478bdstevel@tonic-gate			    ddi_idevice_cookie_t *idcp,
3207c478bdstevel@tonic-gate			    uint_t (*int_handler)(caddr_t intr_handler_arg),
3217c478bdstevel@tonic-gate			    caddr_t intr_handler_arg, int kind);
3227c478bdstevel@tonic-gate	void		(*bus_remove_intrspec)(dev_info_t *dip,
3237c478bdstevel@tonic-gate			    dev_info_t *rdip, ddi_intrspec_t intrspec,
3247c478bdstevel@tonic-gate			    ddi_iblock_cookie_t iblock_cookie);
3257c478bdstevel@tonic-gate	int		(*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
3267c478bdstevel@tonic-gate			    struct hat *hat, struct seg *seg, caddr_t addr,
3277c478bdstevel@tonic-gate			    struct devpage *dp, pfn_t pfn, uint_t prot,
3287c478bdstevel@tonic-gate			    uint_t lock);
3297c478bdstevel@tonic-gate	int		(*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
3307c478bdstevel@tonic-gate			    struct ddi_dma_req *dmareq,
3317c478bdstevel@tonic-gate			    ddi_dma_handle_t *handlep);
3327c478bdstevel@tonic-gate	int		(*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
3337c478bdstevel@tonic-gate			    ddi_dma_handle_t handle,
3347c478bdstevel@tonic-gate			    enum ddi_dma_ctlops request, off_t *offp,
3357c478bdstevel@tonic-gate			    uint_t *lenp, caddr_t *objp, uint_t flags);
3367c478bdstevel@tonic-gate	int		(*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
3377c478bdstevel@tonic-gate			    ddi_ctl_enum_t ctlop, void *arg, void *result);
3387c478bdstevel@tonic-gate	int		(*bus_prop_op)(dev_t dev, dev_info_t *dip,
3397c478bdstevel@tonic-gate			    dev_info_t *child_dip, ddi_prop_op_t prop_op,
3407c478bdstevel@tonic-gate			    int mod_flags, char *name, caddr_t valuep,
3417c478bdstevel@tonic-gate			    int *length);
3457c478bdstevel@tonic-gate * dev_ops:	Contains driver common fields and pointers
3467c478bdstevel@tonic-gate *		to the bus_ops and/or cb_ops parts.
3477c478bdstevel@tonic-gate *
3487c478bdstevel@tonic-gate * Drivers should set devo_rev to DEVO_REV at compile time.
3497c478bdstevel@tonic-gate * All drivers should support these entry points.
3507c478bdstevel@tonic-gate *
3517c478bdstevel@tonic-gate * the following device functions are provided in the device operations
3527c478bdstevel@tonic-gate * structure.
3537c478bdstevel@tonic-gate *
3547c478bdstevel@tonic-gate *	devo_getinfo		-  Device handle conversion
3557c478bdstevel@tonic-gate *	devo_identify		-  Obsolete, set to nulldev
3567c478bdstevel@tonic-gate *	devo_probe		-  Probe for device's existence
3577c478bdstevel@tonic-gate *	devo_attach		-  Attach driver to dev_info
3587c478bdstevel@tonic-gate *	devo_detach		-  Detach/prepare driver to unload
3597c478bdstevel@tonic-gate *	devo_reset		-  Reset device
3601939740Sherry Moore *	devo_quiesce		-  Quiesce device
3617c478bdstevel@tonic-gate */
3631939740Sherry Moore#define		DEVO_REV		4
3647c478bdstevel@tonic-gate#define		CB_REV			1
3677c478bdstevel@tonic-gate * Return from driver's devo_probe function:
3687c478bdstevel@tonic-gate */
3707c478bdstevel@tonic-gate#define	DDI_PROBE_FAILURE	ENXIO	/* matches nodev return */
3717c478bdstevel@tonic-gate#define	DDI_PROBE_DONTCARE	0	/* matches nulldev return */
3727c478bdstevel@tonic-gate#define	DDI_PROBE_PARTIAL	1
3737c478bdstevel@tonic-gate#define	DDI_PROBE_SUCCESS	2
3767c478bdstevel@tonic-gate * Typedefs for the info, attach, detach and reset routines.
3777c478bdstevel@tonic-gate * These are mostly placeholders for now.
3787c478bdstevel@tonic-gate *
3797c478bdstevel@tonic-gate * NOTE: DDI_INFO_DEVT2DEVINFO is deprecated
3807c478bdstevel@tonic-gate */
3817c478bdstevel@tonic-gatetypedef enum {
3827c478bdstevel@tonic-gate	DDI_INFO_DEVT2DEVINFO = 0,	/* Convert a dev_t to a dev_info_t */
3837c478bdstevel@tonic-gate	DDI_INFO_DEVT2INSTANCE = 1	/* Convert a dev_t to an instance # */
3847c478bdstevel@tonic-gate} ddi_info_cmd_t;
3867c478bdstevel@tonic-gatetypedef enum {
3877c478bdstevel@tonic-gate	DDI_ATTACH = 0,
3887c478bdstevel@tonic-gate	DDI_RESUME = 1,
3897c478bdstevel@tonic-gate	DDI_PM_RESUME = 2
3907c478bdstevel@tonic-gate} ddi_attach_cmd_t;
3927c478bdstevel@tonic-gatetypedef enum {
3937c478bdstevel@tonic-gate	DDI_DETACH = 0,
3947c478bdstevel@tonic-gate	DDI_SUSPEND = 1,
3957c478bdstevel@tonic-gate	DDI_PM_SUSPEND = 2,
3967c478bdstevel@tonic-gate	DDI_HOTPLUG_DETACH = 3		/* detach, don't try to auto-unconfig */
3977c478bdstevel@tonic-gate} ddi_detach_cmd_t;
3997c478bdstevel@tonic-gatetypedef enum {
4007c478bdstevel@tonic-gate	DDI_RESET_FORCE = 0
4017c478bdstevel@tonic-gate} ddi_reset_cmd_t;
4037c478bdstevel@tonic-gatestruct dev_ops  {
4047c478bdstevel@tonic-gate	int		devo_rev;	/* Driver build version		*/
4057c478bdstevel@tonic-gate	int		devo_refcnt;	/* device reference count	*/
4077c478bdstevel@tonic-gate	int		(*devo_getinfo)(dev_info_t *dip,
4087c478bdstevel@tonic-gate			    ddi_info_cmd_t infocmd, void *arg, void **result);
4097c478bdstevel@tonic-gate	int		(*devo_identify)(dev_info_t *dip);
4107c478bdstevel@tonic-gate	int		(*devo_probe)(dev_info_t *dip);
4117c478bdstevel@tonic-gate	int		(*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd);
4127c478bdstevel@tonic-gate	int		(*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd);
4137c478bdstevel@tonic-gate	int		(*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd);
4157c478bdstevel@tonic-gate	struct cb_ops	*devo_cb_ops;	/* cb_ops pointer for leaf drivers   */
4167c478bdstevel@tonic-gate	struct bus_ops	*devo_bus_ops;	/* bus_ops pointer for nexus drivers */
4177c478bdstevel@tonic-gate	int		(*devo_power)(dev_info_t *dip, int component,
4187c478bdstevel@tonic-gate			    int level);
4191939740Sherry Moore	int		(*devo_quiesce)(dev_info_t *dip);
4237c478bdstevel@tonic-gate * Create a dev_ops suitable for a streams driver:
4247c478bdstevel@tonic-gate *
4257c478bdstevel@tonic-gate * XXX: Note:  Since this is a macro, it is NOT supported as
4267c478bdstevel@tonic-gate * XXX: part of the Sun DDI.  It is not a documented Sun DDI interface.
4277c478bdstevel@tonic-gate *
4287c478bdstevel@tonic-gate * STR_OPS(name, identify, probe, attach, detach, reset,
4297c478bdstevel@tonic-gate *	info, flag, stream_tab);
4307c478bdstevel@tonic-gate *
4317c478bdstevel@tonic-gate *	XXname is the name of the dev_ops structure.
4327c478bdstevel@tonic-gate *	XXidentify must be set to nulldev
4337c478bdstevel@tonic-gate *	XXprobe is the name of the probe routine, or nulldev
4347c478bdstevel@tonic-gate *	XXattach is the name of the attach routine
4357c478bdstevel@tonic-gate *	XXdetach is the name of the detach routine, or nodev
4367c478bdstevel@tonic-gate *	XXreset is the name of the reset routine, or nodev
4377c478bdstevel@tonic-gate *	XXinfo is the name of the info routine
4387c478bdstevel@tonic-gate *	XXflag is driver flag (cb_flag) in cb_ops,
4397c478bdstevel@tonic-gate *	XXstream_tab is the obvious.
4401939740Sherry Moore *	XXquiesce is the name of the quiesce routine. It must be implemented
4411939740Sherry Moore *		for fast reboot to succeed.
4427c478bdstevel@tonic-gate *	cb_##XXname is the name of the internally defined cb_ops struct.
4437c478bdstevel@tonic-gate *
4447c478bdstevel@tonic-gate * uses cb_XXname as name of static cb_ops structure.
4457c478bdstevel@tonic-gate */
4487c478bdstevel@tonic-gate * This file is included by genassym.c now and I couldn't get it to take the
4497c478bdstevel@tonic-gate * next line if it was broken into two lines joined by a '\'.  So, don't try
4507c478bdstevel@tonic-gate * to reformat it to satisfy Cstyle because genassym.c won't compile.
4517c478bdstevel@tonic-gate */
4527c478bdstevel@tonic-gate/* CSTYLED */
4531939740Sherry Moore#define	DDI_DEFINE_STREAM_OPS(XXname, XXidentify, XXprobe, XXattach, XXdetach, XXreset, XXgetinfo, XXflag, XXstream_tab, XXquiesce) \
4547c478bdstevel@tonic-gatestatic struct cb_ops cb_##XXname = {					\
4557c478bdstevel@tonic-gate	nulldev,		/* cb_open */				\
4567c478bdstevel@tonic-gate	nulldev,		/* cb_close */				\
4577c478bdstevel@tonic-gate	nodev,			/* cb_strategy */			\
4587c478bdstevel@tonic-gate	nodev,			/* cb_print */				\
4597c478bdstevel@tonic-gate	nodev,			/* cb_dump */				\
4607c478bdstevel@tonic-gate	nodev,			/* cb_read */				\
4617c478bdstevel@tonic-gate	nodev,			/* cb_write */				\
4627c478bdstevel@tonic-gate	nodev,			/* cb_ioctl */				\
4637c478bdstevel@tonic-gate	nodev,			/* cb_devmap */				\
4647c478bdstevel@tonic-gate	nodev,			/* cb_mmap */				\
4657c478bdstevel@tonic-gate	nodev,			/* cb_segmap */				\
4667c478bdstevel@tonic-gate	nochpoll,		/* cb_chpoll */				\
4677c478bdstevel@tonic-gate	ddi_prop_op,		/* cb_prop_op */			\
4687c478bdstevel@tonic-gate	(XXstream_tab),		/* cb_stream */				\
4697c478bdstevel@tonic-gate	(int)(XXflag),		/* cb_flag */				\
4707c478bdstevel@tonic-gate	CB_REV,			/* cb_rev */				\
4717c478bdstevel@tonic-gate	nodev,			/* cb_aread */				\
4727c478bdstevel@tonic-gate	nodev,			/* cb_awrite */				\
4737c478bdstevel@tonic-gate};									\
4747c478bdstevel@tonic-gate									\
4757c478bdstevel@tonic-gatestatic struct dev_ops XXname = {					\
4767c478bdstevel@tonic-gate	DEVO_REV,		/* devo_rev */				\
4777c478bdstevel@tonic-gate	0,			/* devo_refcnt */			\
4787c478bdstevel@tonic-gate	(XXgetinfo),		/* devo_getinfo */			\
4797c478bdstevel@tonic-gate	(XXidentify),		/* devo_identify */			\
4807c478bdstevel@tonic-gate	(XXprobe),		/* devo_probe */			\
4817c478bdstevel@tonic-gate	(XXattach),		/* devo_attach */			\
4827c478bdstevel@tonic-gate	(XXdetach),		/* devo_detach */			\
4837c478bdstevel@tonic-gate	(XXreset),		/* devo_reset */			\
4847c478bdstevel@tonic-gate	&(cb_##XXname),		/* devo_cb_ops */			\
4857c478bdstevel@tonic-gate	(struct bus_ops *)NULL,	/* devo_bus_ops */			\
4861939740Sherry Moore	NULL,			/* devo_power */			\
4871939740Sherry Moore	(XXquiesce)		/* devo_quiesce */			\
4907c478bdstevel@tonic-gate#endif	/* _KERNEL */
4927c478bdstevel@tonic-gate#ifdef	__cplusplus
4967c478bdstevel@tonic-gate#endif	/* _SYS_DEVOPS_H */