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