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