xref: /illumos-gate/usr/src/uts/common/sys/devops.h (revision 193974072f41a843678abf5f61979c748687e66b)
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
5*19397407SSherry Moore  * Common Development and Distribution License (the "License").
6*19397407SSherry 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 /*
22*19397407SSherry Moore  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_DEVOPS_H
277c478bd9Sstevel@tonic-gate #define	_SYS_DEVOPS_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <sys/types.h>
317c478bd9Sstevel@tonic-gate #include <sys/cred.h>
327c478bd9Sstevel@tonic-gate #include <sys/uio.h>
337c478bd9Sstevel@tonic-gate #include <sys/buf.h>
347c478bd9Sstevel@tonic-gate #include <sys/poll.h>
357c478bd9Sstevel@tonic-gate #include <vm/as.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
387c478bd9Sstevel@tonic-gate #include <sys/ddidmareq.h>
397c478bd9Sstevel@tonic-gate #include <sys/ddimapreq.h>
407c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h>
417c478bd9Sstevel@tonic-gate #include <sys/ddidevmap.h>
427c478bd9Sstevel@tonic-gate #include <sys/ddifm.h>
437c478bd9Sstevel@tonic-gate #include <sys/nexusdefs.h>
447c478bd9Sstevel@tonic-gate #include <sys/ddi_intr.h>
457c478bd9Sstevel@tonic-gate #include <sys/aio_req.h>
467c478bd9Sstevel@tonic-gate #include <vm/page.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * cb_ops:	Leaf device drivers or bus nexus drivers supporting
567c478bd9Sstevel@tonic-gate  *		direct user process access (open/close/etc).
577c478bd9Sstevel@tonic-gate  *
587c478bd9Sstevel@tonic-gate  * This is an OR of cdevsw and bdevsw fields for drivers that
597c478bd9Sstevel@tonic-gate  * support both character and block entry points.
607c478bd9Sstevel@tonic-gate  *
617c478bd9Sstevel@tonic-gate  * For streams stuff, see also sys/stream.h.
627c478bd9Sstevel@tonic-gate  *
637c478bd9Sstevel@tonic-gate  * The following DDI/DKI or DKI only or DDI only functions are
647c478bd9Sstevel@tonic-gate  * provided in the character/block driver operations structure.
657c478bd9Sstevel@tonic-gate  *
667c478bd9Sstevel@tonic-gate  *	block/char	Function	description
677c478bd9Sstevel@tonic-gate  *	b/c		XXopen		DDI/DKI
687c478bd9Sstevel@tonic-gate  *	b/c		XXclose		DDI/DKI
697c478bd9Sstevel@tonic-gate  *	b		XXstrategy	DDI/DKI
707c478bd9Sstevel@tonic-gate  *	b  		XXprint		DDI/DKI
717c478bd9Sstevel@tonic-gate  *	b  		XXdump		DDI(Sun)
727c478bd9Sstevel@tonic-gate  *	  c		XXread		DDI/DKI
737c478bd9Sstevel@tonic-gate  *	  c		XXwrite		DDI/DKI
747c478bd9Sstevel@tonic-gate  *	  c		XXioctl		DDI/DKI
757c478bd9Sstevel@tonic-gate  *	  c		XXdevmap	DDI(Sun)
767c478bd9Sstevel@tonic-gate  *	  c		XXmmap		DKI
777c478bd9Sstevel@tonic-gate  *	  c		XXsegmap	DKI
787c478bd9Sstevel@tonic-gate  *	  c		XXchpoll	DDI/DKI
797c478bd9Sstevel@tonic-gate  *	  c		XXprop_op	DDI(Sun)
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate struct cb_ops  {
837c478bd9Sstevel@tonic-gate 	int	(*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
847c478bd9Sstevel@tonic-gate 	int	(*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
857c478bd9Sstevel@tonic-gate 	int	(*cb_strategy)(struct buf *bp);
867c478bd9Sstevel@tonic-gate 	int	(*cb_print)(dev_t dev, char *str);
877c478bd9Sstevel@tonic-gate 	int	(*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
887c478bd9Sstevel@tonic-gate 	int	(*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
897c478bd9Sstevel@tonic-gate 	int	(*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
907c478bd9Sstevel@tonic-gate 	int	(*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
917c478bd9Sstevel@tonic-gate 		    cred_t *credp, int *rvalp);
927c478bd9Sstevel@tonic-gate 	int	(*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
937c478bd9Sstevel@tonic-gate 			size_t len, size_t *maplen, uint_t model);
947c478bd9Sstevel@tonic-gate 	int	(*cb_mmap)(dev_t dev, off_t off, int prot);
957c478bd9Sstevel@tonic-gate 	int	(*cb_segmap)(dev_t dev, off_t off, struct as *asp,
967c478bd9Sstevel@tonic-gate 		    caddr_t *addrp, off_t len, unsigned int prot,
977c478bd9Sstevel@tonic-gate 		    unsigned int maxprot, unsigned int flags, cred_t *credp);
987c478bd9Sstevel@tonic-gate 	int	(*cb_chpoll)(dev_t dev, short events, int anyyet,
997c478bd9Sstevel@tonic-gate 		    short *reventsp, struct pollhead **phpp);
1007c478bd9Sstevel@tonic-gate 	int	(*cb_prop_op)(dev_t dev, dev_info_t *dip,
1017c478bd9Sstevel@tonic-gate 		    ddi_prop_op_t prop_op, int mod_flags,
1027c478bd9Sstevel@tonic-gate 		    char *name, caddr_t valuep, int *length);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	struct streamtab *cb_str;	/* streams information */
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate 	/*
1077c478bd9Sstevel@tonic-gate 	 * The cb_flag fields are here to tell the system a
1087c478bd9Sstevel@tonic-gate 	 * bit about the device. The bit definitions are
1097c478bd9Sstevel@tonic-gate 	 * in <sys/conf.h>.
1107c478bd9Sstevel@tonic-gate 	 */
1117c478bd9Sstevel@tonic-gate 	int	cb_flag;		/* driver compatibility flag */
1127c478bd9Sstevel@tonic-gate 	int	cb_rev;			/* cb_ops version number */
1137c478bd9Sstevel@tonic-gate 	int	(*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
1147c478bd9Sstevel@tonic-gate 	int	(*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
1157c478bd9Sstevel@tonic-gate };
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate /*
1187c478bd9Sstevel@tonic-gate  * bus_ops:	bus nexus drivers only.
1197c478bd9Sstevel@tonic-gate  *
1207c478bd9Sstevel@tonic-gate  * These functions are used to implement the Sun DDI functions
1217c478bd9Sstevel@tonic-gate  * described elsewhere.
1227c478bd9Sstevel@tonic-gate  *
1237c478bd9Sstevel@tonic-gate  * Only nexus drivers support these entry points.
1247c478bd9Sstevel@tonic-gate  *
1257c478bd9Sstevel@tonic-gate  * The following bus nexus functions are provided in the bus nexus
1267c478bd9Sstevel@tonic-gate  * driver operations structure.  Note that all functions take both
1277c478bd9Sstevel@tonic-gate  * their dip and the requesters dip except for the child functions since
1287c478bd9Sstevel@tonic-gate  * they will be called from outside the ddi.
1297c478bd9Sstevel@tonic-gate  *
1307c478bd9Sstevel@tonic-gate  *	bus_map			-  Map/unmap/control IU -> device mappings.
1317c478bd9Sstevel@tonic-gate  *	bus_get_intrspec	-  get interrupt specification by number
1327c478bd9Sstevel@tonic-gate  *	bus_add_intrspec	-  add interrupt specification, return cookie
1337c478bd9Sstevel@tonic-gate  *	bus_remove_intrspec	-  remove interrupt specification
1347c478bd9Sstevel@tonic-gate  *	bus_map_fault		-  bus fault handler
1357c478bd9Sstevel@tonic-gate  *	bus_dma_map		-  setup dma mapping
1367c478bd9Sstevel@tonic-gate  *	bus_dma_mapctl		-  control (and free) dma mapping
1377c478bd9Sstevel@tonic-gate  *	bus_ctl			-  generic control operations
1387c478bd9Sstevel@tonic-gate  *	bus_prop_op		_  request for property
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #define	BUSO_REV_3	3
1427c478bd9Sstevel@tonic-gate #define	BUSO_REV_4	4
1437c478bd9Sstevel@tonic-gate #define	BUSO_REV_5	5
1447c478bd9Sstevel@tonic-gate #define	BUSO_REV_6	6
1457c478bd9Sstevel@tonic-gate #define	BUSO_REV_7	7
1467c478bd9Sstevel@tonic-gate #define	BUSO_REV_8	8
1477c478bd9Sstevel@tonic-gate #define	BUSO_REV_9	9
1487c478bd9Sstevel@tonic-gate #define	BUSO_REV	BUSO_REV_9
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate struct bus_ops  {
1527c478bd9Sstevel@tonic-gate 	int		busops_rev;	/* rev of this structure */
1537c478bd9Sstevel@tonic-gate 	int		(*bus_map)(dev_info_t *dip, dev_info_t *rdip,
1547c478bd9Sstevel@tonic-gate 			    ddi_map_req_t *mp, off_t offset, off_t len,
1557c478bd9Sstevel@tonic-gate 			    caddr_t *vaddrp);
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate 	/*
1587c478bd9Sstevel@tonic-gate 	 * NOTE: the following 3 busops entrypoints are obsoleted with
1597c478bd9Sstevel@tonic-gate 	 * version 9 or greater. Use bus_intr_op interface in place of
1607c478bd9Sstevel@tonic-gate 	 * these obsolete interfaces.
1617c478bd9Sstevel@tonic-gate 	 */
1627c478bd9Sstevel@tonic-gate 	ddi_intrspec_t	(*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
1637c478bd9Sstevel@tonic-gate 			    uint_t inumber);
1647c478bd9Sstevel@tonic-gate 	int		(*bus_add_intrspec)(dev_info_t *dip,
1657c478bd9Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
1667c478bd9Sstevel@tonic-gate 			    ddi_iblock_cookie_t *ibcp,
1677c478bd9Sstevel@tonic-gate 			    ddi_idevice_cookie_t *idcp,
1687c478bd9Sstevel@tonic-gate 			    uint_t (*int_handler)(caddr_t intr_handler_arg),
1697c478bd9Sstevel@tonic-gate 			    caddr_t intr_handler_arg, int kind);
1707c478bd9Sstevel@tonic-gate 	void		(*bus_remove_intrspec)(dev_info_t *dip,
1717c478bd9Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
1727c478bd9Sstevel@tonic-gate 			    ddi_iblock_cookie_t iblock_cookie);
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	int		(*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
1757c478bd9Sstevel@tonic-gate 			    struct hat *hat, struct seg *seg, caddr_t addr,
1767c478bd9Sstevel@tonic-gate 			    struct devpage *dp, pfn_t pfn, uint_t prot,
1777c478bd9Sstevel@tonic-gate 			    uint_t lock);
1787c478bd9Sstevel@tonic-gate 	int		(*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
1797c478bd9Sstevel@tonic-gate 			    struct ddi_dma_req *dmareq,
1807c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t *handlep);
1817c478bd9Sstevel@tonic-gate 	int		(*bus_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip,
1827c478bd9Sstevel@tonic-gate 			    ddi_dma_attr_t *attr, int (*waitfp)(caddr_t),
1837c478bd9Sstevel@tonic-gate 			    caddr_t arg, ddi_dma_handle_t *handlep);
1847c478bd9Sstevel@tonic-gate 	int		(*bus_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip,
1857c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t handle);
1867c478bd9Sstevel@tonic-gate 	int		(*bus_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip,
1877c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
1887c478bd9Sstevel@tonic-gate 			    ddi_dma_cookie_t *, uint_t *);
1897c478bd9Sstevel@tonic-gate 	int		(*bus_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip,
1907c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t handle);
1917c478bd9Sstevel@tonic-gate 	int		(*bus_dma_flush)(dev_info_t *dip, dev_info_t *rdip,
1927c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t handle, off_t off,
1937c478bd9Sstevel@tonic-gate 			    size_t len, uint_t cache_flags);
1947c478bd9Sstevel@tonic-gate 	int		(*bus_dma_win)(dev_info_t *dip, dev_info_t *rdip,
1957c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t handle, uint_t win, off_t *offp,
1967c478bd9Sstevel@tonic-gate 			    size_t *lenp, ddi_dma_cookie_t *cookiep,
1977c478bd9Sstevel@tonic-gate 			    uint_t *ccountp);
1987c478bd9Sstevel@tonic-gate 	int		(*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
1997c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t handle,
2007c478bd9Sstevel@tonic-gate 			    enum ddi_dma_ctlops request, off_t *offp,
2017c478bd9Sstevel@tonic-gate 			    size_t *lenp, caddr_t *objp, uint_t flags);
2027c478bd9Sstevel@tonic-gate 	int		(*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
2037c478bd9Sstevel@tonic-gate 			    ddi_ctl_enum_t ctlop, void *arg, void *result);
2047c478bd9Sstevel@tonic-gate 	int		(*bus_prop_op)(dev_t dev, dev_info_t *dip,
2057c478bd9Sstevel@tonic-gate 			    dev_info_t *child_dip, ddi_prop_op_t prop_op,
2067c478bd9Sstevel@tonic-gate 			    int mod_flags, char *name, caddr_t valuep,
2077c478bd9Sstevel@tonic-gate 			    int *length);
2087c478bd9Sstevel@tonic-gate 	/*
2097c478bd9Sstevel@tonic-gate 	 * NOTE: the following 4 busops entrypoints are only available
2107c478bd9Sstevel@tonic-gate 	 * with version 3 or greater.  Due to interface modifications, these
2117c478bd9Sstevel@tonic-gate 	 * entrypoints can only be used with version 6 or greater.
2127c478bd9Sstevel@tonic-gate 	 */
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate 	int		(*bus_get_eventcookie)(dev_info_t *dip,
2157c478bd9Sstevel@tonic-gate 			    dev_info_t *rdip, char *eventname,
2167c478bd9Sstevel@tonic-gate 			    ddi_eventcookie_t *cookiep);
2177c478bd9Sstevel@tonic-gate 	int		(*bus_add_eventcall)(dev_info_t *dip, dev_info_t *rdip,
2187c478bd9Sstevel@tonic-gate 			    ddi_eventcookie_t eventid,
2197c478bd9Sstevel@tonic-gate 			    void (*event_hdlr)(dev_info_t *dip,
2207c478bd9Sstevel@tonic-gate 			    ddi_eventcookie_t event, void *arg,
2217c478bd9Sstevel@tonic-gate 			    void *bus_impldata), void *arg,
2227c478bd9Sstevel@tonic-gate 			    ddi_callback_id_t *cb_id);
2237c478bd9Sstevel@tonic-gate 	int		(*bus_remove_eventcall)(dev_info_t *devi,
2247c478bd9Sstevel@tonic-gate 			    ddi_callback_id_t cb_id);
2257c478bd9Sstevel@tonic-gate 	int		(*bus_post_event)(dev_info_t *dip, dev_info_t *rdip,
2267c478bd9Sstevel@tonic-gate 			    ddi_eventcookie_t event, void *impl_data);
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 	/*
2297c478bd9Sstevel@tonic-gate 	 * NOTE: the following bus_intr_ctl entrypoint is obsoleted with
2307c478bd9Sstevel@tonic-gate 	 * version 9 or greater. Use bus_intr_op interface in place of
2317c478bd9Sstevel@tonic-gate 	 * this obsolete interface.
2327c478bd9Sstevel@tonic-gate 	 */
2337c478bd9Sstevel@tonic-gate 	int		(*bus_intr_ctl)(dev_info_t *dip, dev_info_t *rdip,
2347c478bd9Sstevel@tonic-gate 			    ddi_intr_ctlop_t ctlop, void * arg, void * result);
2357c478bd9Sstevel@tonic-gate 	/*
2367c478bd9Sstevel@tonic-gate 	 * NOTE: the following busop entrypoints are available with version
2377c478bd9Sstevel@tonic-gate 	 * 5 or greater.
2387c478bd9Sstevel@tonic-gate 	 */
2397c478bd9Sstevel@tonic-gate 	int		(*bus_config)(dev_info_t *parent, uint_t flags,
2407c478bd9Sstevel@tonic-gate 			    ddi_bus_config_op_t op, void *arg,
2417c478bd9Sstevel@tonic-gate 			    dev_info_t **childp);
2427c478bd9Sstevel@tonic-gate 	int		(*bus_unconfig)(dev_info_t *parent, uint_t flags,
2437c478bd9Sstevel@tonic-gate 			    ddi_bus_config_op_t op, void *arg);
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate 	/*
2467c478bd9Sstevel@tonic-gate 	 * NOTE: the following busop entrypoints are available with version
2477c478bd9Sstevel@tonic-gate 	 * 6 or greater.
2487c478bd9Sstevel@tonic-gate 	 */
2497c478bd9Sstevel@tonic-gate 	int		(*bus_fm_init)(dev_info_t *dip, dev_info_t *tdip,
2507c478bd9Sstevel@tonic-gate 			    int cap, ddi_iblock_cookie_t *ibc);
2517c478bd9Sstevel@tonic-gate 	void		(*bus_fm_fini)(dev_info_t *dip, dev_info_t *tdip);
2527c478bd9Sstevel@tonic-gate 	void		(*bus_fm_access_enter)(dev_info_t *dip,
2537c478bd9Sstevel@tonic-gate 			    ddi_acc_handle_t handle);
2547c478bd9Sstevel@tonic-gate 	void		(*bus_fm_access_exit)(dev_info_t *dip,
2557c478bd9Sstevel@tonic-gate 			    ddi_acc_handle_t handle);
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 	/*
2587c478bd9Sstevel@tonic-gate 	 * NOTE: the following busop entrypoint is available with version
2597c478bd9Sstevel@tonic-gate 	 * 7 or greater.
2607c478bd9Sstevel@tonic-gate 	 */
2617c478bd9Sstevel@tonic-gate 	int		(*bus_power)(dev_info_t *dip, void *impl_arg,
2627c478bd9Sstevel@tonic-gate 			    pm_bus_power_op_t op, void *arg, void *result);
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate 	/*
2657c478bd9Sstevel@tonic-gate 	 * NOTE: the following busop entrypoint is available with version
2667c478bd9Sstevel@tonic-gate 	 * 9 or greater.
2677c478bd9Sstevel@tonic-gate 	 */
2687c478bd9Sstevel@tonic-gate 	int		(*bus_intr_op)(dev_info_t *dip, dev_info_t *rdip,
2697c478bd9Sstevel@tonic-gate 			    ddi_intr_op_t op, ddi_intr_handle_impl_t *hdlp,
2707c478bd9Sstevel@tonic-gate 			    void *result);
2717c478bd9Sstevel@tonic-gate };
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate /*
2747c478bd9Sstevel@tonic-gate  * REV 1 bus ops structure
2757c478bd9Sstevel@tonic-gate  */
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate struct bus_ops_rev1 {
2787c478bd9Sstevel@tonic-gate 	int		(*bus_map)(dev_info_t *dip, dev_info_t *rdip,
2797c478bd9Sstevel@tonic-gate 			    ddi_map_req_t *mp, off_t offset, off_t len,
2807c478bd9Sstevel@tonic-gate 			    caddr_t *vaddrp);
2817c478bd9Sstevel@tonic-gate 	ddi_intrspec_t	(*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
2827c478bd9Sstevel@tonic-gate 			    uint_t inumber);
2837c478bd9Sstevel@tonic-gate 	int		(*bus_add_intrspec)(dev_info_t *dip,
2847c478bd9Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
2857c478bd9Sstevel@tonic-gate 			    ddi_iblock_cookie_t *ibcp,
2867c478bd9Sstevel@tonic-gate 			    ddi_idevice_cookie_t *idcp,
2877c478bd9Sstevel@tonic-gate 			    uint_t (*int_handler)(caddr_t intr_handler_arg),
2887c478bd9Sstevel@tonic-gate 			    caddr_t intr_handler_arg, int kind);
2897c478bd9Sstevel@tonic-gate 	void		(*bus_remove_intrspec)(dev_info_t *dip,
2907c478bd9Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
2917c478bd9Sstevel@tonic-gate 			    ddi_iblock_cookie_t iblock_cookie);
2927c478bd9Sstevel@tonic-gate 	int		(*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
2937c478bd9Sstevel@tonic-gate 			    struct hat *hat, struct seg *seg, caddr_t addr,
2947c478bd9Sstevel@tonic-gate 			    struct devpage *dp, pfn_t pfn, uint_t prot,
2957c478bd9Sstevel@tonic-gate 			    uint_t lock);
2967c478bd9Sstevel@tonic-gate 	int		(*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
2977c478bd9Sstevel@tonic-gate 			    struct ddi_dma_req *dmareq,
2987c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t *handlep);
2997c478bd9Sstevel@tonic-gate 	int		(*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
3007c478bd9Sstevel@tonic-gate 			    ddi_dma_handle_t handle,
3017c478bd9Sstevel@tonic-gate 			    enum ddi_dma_ctlops request, off_t *offp,
3027c478bd9Sstevel@tonic-gate 			    uint_t *lenp, caddr_t *objp, uint_t flags);
3037c478bd9Sstevel@tonic-gate 	int		(*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
3047c478bd9Sstevel@tonic-gate 			    ddi_ctl_enum_t ctlop, void *arg, void *result);
3057c478bd9Sstevel@tonic-gate 	int		(*bus_prop_op)(dev_t dev, dev_info_t *dip,
3067c478bd9Sstevel@tonic-gate 			    dev_info_t *child_dip, ddi_prop_op_t prop_op,
3077c478bd9Sstevel@tonic-gate 			    int mod_flags, char *name, caddr_t valuep,
3087c478bd9Sstevel@tonic-gate 			    int *length);
3097c478bd9Sstevel@tonic-gate };
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate /*
3127c478bd9Sstevel@tonic-gate  * dev_ops:	Contains driver common fields and pointers
3137c478bd9Sstevel@tonic-gate  *		to the bus_ops and/or cb_ops parts.
3147c478bd9Sstevel@tonic-gate  *
3157c478bd9Sstevel@tonic-gate  * Drivers should set devo_rev to DEVO_REV at compile time.
3167c478bd9Sstevel@tonic-gate  * All drivers should support these entry points.
3177c478bd9Sstevel@tonic-gate  *
3187c478bd9Sstevel@tonic-gate  * the following device functions are provided in the device operations
3197c478bd9Sstevel@tonic-gate  * structure.
3207c478bd9Sstevel@tonic-gate  *
3217c478bd9Sstevel@tonic-gate  *	devo_getinfo		-  Device handle conversion
3227c478bd9Sstevel@tonic-gate  *	devo_identify		-  Obsolete, set to nulldev
3237c478bd9Sstevel@tonic-gate  *	devo_probe		-  Probe for device's existence
3247c478bd9Sstevel@tonic-gate  *	devo_attach		-  Attach driver to dev_info
3257c478bd9Sstevel@tonic-gate  *	devo_detach		-  Detach/prepare driver to unload
3267c478bd9Sstevel@tonic-gate  *	devo_reset		-  Reset device
327*19397407SSherry Moore  *	devo_quiesce		-  Quiesce device
3287c478bd9Sstevel@tonic-gate  */
3297c478bd9Sstevel@tonic-gate 
330*19397407SSherry Moore #define		DEVO_REV		4
3317c478bd9Sstevel@tonic-gate #define		CB_REV			1
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate  * Return from driver's devo_probe function:
3357c478bd9Sstevel@tonic-gate  */
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate #define	DDI_PROBE_FAILURE	ENXIO	/* matches nodev return */
3387c478bd9Sstevel@tonic-gate #define	DDI_PROBE_DONTCARE	0	/* matches nulldev return */
3397c478bd9Sstevel@tonic-gate #define	DDI_PROBE_PARTIAL	1
3407c478bd9Sstevel@tonic-gate #define	DDI_PROBE_SUCCESS	2
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate /*
3437c478bd9Sstevel@tonic-gate  * Typedefs for the info, attach, detach and reset routines.
3447c478bd9Sstevel@tonic-gate  * These are mostly placeholders for now.
3457c478bd9Sstevel@tonic-gate  *
3467c478bd9Sstevel@tonic-gate  * NOTE: DDI_INFO_DEVT2DEVINFO is deprecated
3477c478bd9Sstevel@tonic-gate  */
3487c478bd9Sstevel@tonic-gate typedef enum {
3497c478bd9Sstevel@tonic-gate 	DDI_INFO_DEVT2DEVINFO = 0,	/* Convert a dev_t to a dev_info_t */
3507c478bd9Sstevel@tonic-gate 	DDI_INFO_DEVT2INSTANCE = 1	/* Convert a dev_t to an instance # */
3517c478bd9Sstevel@tonic-gate } ddi_info_cmd_t;
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate typedef enum {
3547c478bd9Sstevel@tonic-gate 	DDI_ATTACH = 0,
3557c478bd9Sstevel@tonic-gate 	DDI_RESUME = 1,
3567c478bd9Sstevel@tonic-gate 	DDI_PM_RESUME = 2
3577c478bd9Sstevel@tonic-gate } ddi_attach_cmd_t;
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate typedef enum {
3607c478bd9Sstevel@tonic-gate 	DDI_DETACH = 0,
3617c478bd9Sstevel@tonic-gate 	DDI_SUSPEND = 1,
3627c478bd9Sstevel@tonic-gate 	DDI_PM_SUSPEND = 2,
3637c478bd9Sstevel@tonic-gate 	DDI_HOTPLUG_DETACH = 3		/* detach, don't try to auto-unconfig */
3647c478bd9Sstevel@tonic-gate } ddi_detach_cmd_t;
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate typedef enum {
3677c478bd9Sstevel@tonic-gate 	DDI_RESET_FORCE = 0
3687c478bd9Sstevel@tonic-gate } ddi_reset_cmd_t;
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate struct dev_ops  {
3717c478bd9Sstevel@tonic-gate 	int		devo_rev;	/* Driver build version		*/
3727c478bd9Sstevel@tonic-gate 	int		devo_refcnt;	/* device reference count	*/
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate 	int		(*devo_getinfo)(dev_info_t *dip,
3757c478bd9Sstevel@tonic-gate 			    ddi_info_cmd_t infocmd, void *arg, void **result);
3767c478bd9Sstevel@tonic-gate 	int		(*devo_identify)(dev_info_t *dip);
3777c478bd9Sstevel@tonic-gate 	int		(*devo_probe)(dev_info_t *dip);
3787c478bd9Sstevel@tonic-gate 	int		(*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd);
3797c478bd9Sstevel@tonic-gate 	int		(*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd);
3807c478bd9Sstevel@tonic-gate 	int		(*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd);
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 	struct cb_ops	*devo_cb_ops;	/* cb_ops pointer for leaf drivers   */
3837c478bd9Sstevel@tonic-gate 	struct bus_ops	*devo_bus_ops;	/* bus_ops pointer for nexus drivers */
3847c478bd9Sstevel@tonic-gate 	int		(*devo_power)(dev_info_t *dip, int component,
3857c478bd9Sstevel@tonic-gate 			    int level);
386*19397407SSherry Moore 	int		(*devo_quiesce)(dev_info_t *dip);
3877c478bd9Sstevel@tonic-gate };
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate /*
3907c478bd9Sstevel@tonic-gate  * Create a dev_ops suitable for a streams driver:
3917c478bd9Sstevel@tonic-gate  *
3927c478bd9Sstevel@tonic-gate  * XXX: Note:  Since this is a macro, it is NOT supported as
3937c478bd9Sstevel@tonic-gate  * XXX: part of the Sun DDI.  It is not a documented Sun DDI interface.
3947c478bd9Sstevel@tonic-gate  *
3957c478bd9Sstevel@tonic-gate  * STR_OPS(name, identify, probe, attach, detach, reset,
3967c478bd9Sstevel@tonic-gate  *	info, flag, stream_tab);
3977c478bd9Sstevel@tonic-gate  *
3987c478bd9Sstevel@tonic-gate  *	XXname is the name of the dev_ops structure.
3997c478bd9Sstevel@tonic-gate  *	XXidentify must be set to nulldev
4007c478bd9Sstevel@tonic-gate  *	XXprobe is the name of the probe routine, or nulldev
4017c478bd9Sstevel@tonic-gate  *	XXattach is the name of the attach routine
4027c478bd9Sstevel@tonic-gate  *	XXdetach is the name of the detach routine, or nodev
4037c478bd9Sstevel@tonic-gate  *	XXreset is the name of the reset routine, or nodev
4047c478bd9Sstevel@tonic-gate  *	XXinfo is the name of the info routine
4057c478bd9Sstevel@tonic-gate  *	XXflag is driver flag (cb_flag) in cb_ops,
4067c478bd9Sstevel@tonic-gate  *	XXstream_tab is the obvious.
407*19397407SSherry Moore  *	XXquiesce is the name of the quiesce routine. It must be implemented
408*19397407SSherry Moore  *		for fast reboot to succeed.
4097c478bd9Sstevel@tonic-gate  *	cb_##XXname is the name of the internally defined cb_ops struct.
4107c478bd9Sstevel@tonic-gate  *
4117c478bd9Sstevel@tonic-gate  * uses cb_XXname as name of static cb_ops structure.
4127c478bd9Sstevel@tonic-gate  */
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate /*
4157c478bd9Sstevel@tonic-gate  * This file is included by genassym.c now and I couldn't get it to take the
4167c478bd9Sstevel@tonic-gate  * next line if it was broken into two lines joined by a '\'.  So, don't try
4177c478bd9Sstevel@tonic-gate  * to reformat it to satisfy Cstyle because genassym.c won't compile.
4187c478bd9Sstevel@tonic-gate  */
4197c478bd9Sstevel@tonic-gate /* CSTYLED */
420*19397407SSherry Moore #define	DDI_DEFINE_STREAM_OPS(XXname, XXidentify, XXprobe, XXattach, XXdetach, XXreset, XXgetinfo, XXflag, XXstream_tab, XXquiesce) \
4217c478bd9Sstevel@tonic-gate static struct cb_ops cb_##XXname = {					\
4227c478bd9Sstevel@tonic-gate 	nulldev,		/* cb_open */				\
4237c478bd9Sstevel@tonic-gate 	nulldev,		/* cb_close */				\
4247c478bd9Sstevel@tonic-gate 	nodev,			/* cb_strategy */			\
4257c478bd9Sstevel@tonic-gate 	nodev,			/* cb_print */				\
4267c478bd9Sstevel@tonic-gate 	nodev,			/* cb_dump */				\
4277c478bd9Sstevel@tonic-gate 	nodev,			/* cb_read */				\
4287c478bd9Sstevel@tonic-gate 	nodev,			/* cb_write */				\
4297c478bd9Sstevel@tonic-gate 	nodev,			/* cb_ioctl */				\
4307c478bd9Sstevel@tonic-gate 	nodev,			/* cb_devmap */				\
4317c478bd9Sstevel@tonic-gate 	nodev,			/* cb_mmap */				\
4327c478bd9Sstevel@tonic-gate 	nodev,			/* cb_segmap */				\
4337c478bd9Sstevel@tonic-gate 	nochpoll,		/* cb_chpoll */				\
4347c478bd9Sstevel@tonic-gate 	ddi_prop_op,		/* cb_prop_op */			\
4357c478bd9Sstevel@tonic-gate 	(XXstream_tab),		/* cb_stream */				\
4367c478bd9Sstevel@tonic-gate 	(int)(XXflag),		/* cb_flag */				\
4377c478bd9Sstevel@tonic-gate 	CB_REV,			/* cb_rev */				\
4387c478bd9Sstevel@tonic-gate 	nodev,			/* cb_aread */				\
4397c478bd9Sstevel@tonic-gate 	nodev,			/* cb_awrite */				\
4407c478bd9Sstevel@tonic-gate };									\
4417c478bd9Sstevel@tonic-gate 									\
4427c478bd9Sstevel@tonic-gate static struct dev_ops XXname = {					\
4437c478bd9Sstevel@tonic-gate 	DEVO_REV,		/* devo_rev */				\
4447c478bd9Sstevel@tonic-gate 	0,			/* devo_refcnt */			\
4457c478bd9Sstevel@tonic-gate 	(XXgetinfo),		/* devo_getinfo */			\
4467c478bd9Sstevel@tonic-gate 	(XXidentify),		/* devo_identify */			\
4477c478bd9Sstevel@tonic-gate 	(XXprobe),		/* devo_probe */			\
4487c478bd9Sstevel@tonic-gate 	(XXattach),		/* devo_attach */			\
4497c478bd9Sstevel@tonic-gate 	(XXdetach),		/* devo_detach */			\
4507c478bd9Sstevel@tonic-gate 	(XXreset),		/* devo_reset */			\
4517c478bd9Sstevel@tonic-gate 	&(cb_##XXname),		/* devo_cb_ops */			\
4527c478bd9Sstevel@tonic-gate 	(struct bus_ops *)NULL,	/* devo_bus_ops */			\
453*19397407SSherry Moore 	NULL,			/* devo_power */			\
454*19397407SSherry Moore 	(XXquiesce)		/* devo_quiesce */			\
4557c478bd9Sstevel@tonic-gate }
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4607c478bd9Sstevel@tonic-gate }
4617c478bd9Sstevel@tonic-gate #endif
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate #endif	/* _SYS_DEVOPS_H */
464