xref: /onnv-gate/usr/src/uts/common/sys/devops.h (revision 10923:df470fd79c3c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57656SSherry.Moore@Sun.COM  * Common Development and Distribution License (the "License").
67656SSherry.Moore@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*10923SEvan.Yan@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_DEVOPS_H
270Sstevel@tonic-gate #define	_SYS_DEVOPS_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/cred.h>
310Sstevel@tonic-gate #include <sys/uio.h>
320Sstevel@tonic-gate #include <sys/buf.h>
330Sstevel@tonic-gate #include <sys/poll.h>
340Sstevel@tonic-gate #include <vm/as.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <sys/dditypes.h>
370Sstevel@tonic-gate #include <sys/ddidmareq.h>
380Sstevel@tonic-gate #include <sys/ddimapreq.h>
390Sstevel@tonic-gate #include <sys/ddipropdefs.h>
400Sstevel@tonic-gate #include <sys/ddidevmap.h>
410Sstevel@tonic-gate #include <sys/ddifm.h>
420Sstevel@tonic-gate #include <sys/nexusdefs.h>
430Sstevel@tonic-gate #include <sys/ddi_intr.h>
44*10923SEvan.Yan@Sun.COM #include <sys/ddi_hp.h>
45*10923SEvan.Yan@Sun.COM #include <sys/ddi_hp_impl.h>
460Sstevel@tonic-gate #include <sys/aio_req.h>
470Sstevel@tonic-gate #include <vm/page.h>
480Sstevel@tonic-gate 
490Sstevel@tonic-gate #ifdef	__cplusplus
500Sstevel@tonic-gate extern "C" {
510Sstevel@tonic-gate #endif
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #ifdef	_KERNEL
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * cb_ops:	Leaf device drivers or bus nexus drivers supporting
570Sstevel@tonic-gate  *		direct user process access (open/close/etc).
580Sstevel@tonic-gate  *
590Sstevel@tonic-gate  * This is an OR of cdevsw and bdevsw fields for drivers that
600Sstevel@tonic-gate  * support both character and block entry points.
610Sstevel@tonic-gate  *
620Sstevel@tonic-gate  * For streams stuff, see also sys/stream.h.
630Sstevel@tonic-gate  *
640Sstevel@tonic-gate  * The following DDI/DKI or DKI only or DDI only functions are
650Sstevel@tonic-gate  * provided in the character/block driver operations structure.
660Sstevel@tonic-gate  *
670Sstevel@tonic-gate  *	block/char	Function	description
680Sstevel@tonic-gate  *	b/c		XXopen		DDI/DKI
690Sstevel@tonic-gate  *	b/c		XXclose		DDI/DKI
700Sstevel@tonic-gate  *	b		XXstrategy	DDI/DKI
710Sstevel@tonic-gate  *	b  		XXprint		DDI/DKI
720Sstevel@tonic-gate  *	b  		XXdump		DDI(Sun)
730Sstevel@tonic-gate  *	  c		XXread		DDI/DKI
740Sstevel@tonic-gate  *	  c		XXwrite		DDI/DKI
750Sstevel@tonic-gate  *	  c		XXioctl		DDI/DKI
760Sstevel@tonic-gate  *	  c		XXdevmap	DDI(Sun)
770Sstevel@tonic-gate  *	  c		XXmmap		DKI
780Sstevel@tonic-gate  *	  c		XXsegmap	DKI
790Sstevel@tonic-gate  *	  c		XXchpoll	DDI/DKI
800Sstevel@tonic-gate  *	  c		XXprop_op	DDI(Sun)
810Sstevel@tonic-gate  */
820Sstevel@tonic-gate 
830Sstevel@tonic-gate struct cb_ops  {
840Sstevel@tonic-gate 	int	(*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
850Sstevel@tonic-gate 	int	(*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
860Sstevel@tonic-gate 	int	(*cb_strategy)(struct buf *bp);
870Sstevel@tonic-gate 	int	(*cb_print)(dev_t dev, char *str);
880Sstevel@tonic-gate 	int	(*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
890Sstevel@tonic-gate 	int	(*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
900Sstevel@tonic-gate 	int	(*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
910Sstevel@tonic-gate 	int	(*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
920Sstevel@tonic-gate 		    cred_t *credp, int *rvalp);
930Sstevel@tonic-gate 	int	(*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
940Sstevel@tonic-gate 			size_t len, size_t *maplen, uint_t model);
950Sstevel@tonic-gate 	int	(*cb_mmap)(dev_t dev, off_t off, int prot);
960Sstevel@tonic-gate 	int	(*cb_segmap)(dev_t dev, off_t off, struct as *asp,
970Sstevel@tonic-gate 		    caddr_t *addrp, off_t len, unsigned int prot,
980Sstevel@tonic-gate 		    unsigned int maxprot, unsigned int flags, cred_t *credp);
990Sstevel@tonic-gate 	int	(*cb_chpoll)(dev_t dev, short events, int anyyet,
1000Sstevel@tonic-gate 		    short *reventsp, struct pollhead **phpp);
1010Sstevel@tonic-gate 	int	(*cb_prop_op)(dev_t dev, dev_info_t *dip,
1020Sstevel@tonic-gate 		    ddi_prop_op_t prop_op, int mod_flags,
1030Sstevel@tonic-gate 		    char *name, caddr_t valuep, int *length);
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate 	struct streamtab *cb_str;	/* streams information */
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 	/*
1080Sstevel@tonic-gate 	 * The cb_flag fields are here to tell the system a
1090Sstevel@tonic-gate 	 * bit about the device. The bit definitions are
1100Sstevel@tonic-gate 	 * in <sys/conf.h>.
1110Sstevel@tonic-gate 	 */
1120Sstevel@tonic-gate 	int	cb_flag;		/* driver compatibility flag */
1130Sstevel@tonic-gate 	int	cb_rev;			/* cb_ops version number */
1140Sstevel@tonic-gate 	int	(*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
1150Sstevel@tonic-gate 	int	(*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
1160Sstevel@tonic-gate };
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate /*
1190Sstevel@tonic-gate  * bus_ops:	bus nexus drivers only.
1200Sstevel@tonic-gate  *
1210Sstevel@tonic-gate  * These functions are used to implement the Sun DDI functions
1220Sstevel@tonic-gate  * described elsewhere.
1230Sstevel@tonic-gate  *
1240Sstevel@tonic-gate  * Only nexus drivers support these entry points.
1250Sstevel@tonic-gate  *
1260Sstevel@tonic-gate  * The following bus nexus functions are provided in the bus nexus
1270Sstevel@tonic-gate  * driver operations structure.  Note that all functions take both
1280Sstevel@tonic-gate  * their dip and the requesters dip except for the child functions since
1290Sstevel@tonic-gate  * they will be called from outside the ddi.
1300Sstevel@tonic-gate  *
1310Sstevel@tonic-gate  *	bus_map			-  Map/unmap/control IU -> device mappings.
1320Sstevel@tonic-gate  *	bus_get_intrspec	-  get interrupt specification by number
1330Sstevel@tonic-gate  *	bus_add_intrspec	-  add interrupt specification, return cookie
1340Sstevel@tonic-gate  *	bus_remove_intrspec	-  remove interrupt specification
1350Sstevel@tonic-gate  *	bus_map_fault		-  bus fault handler
1360Sstevel@tonic-gate  *	bus_dma_map		-  setup dma mapping
1370Sstevel@tonic-gate  *	bus_dma_mapctl		-  control (and free) dma mapping
1380Sstevel@tonic-gate  *	bus_ctl			-  generic control operations
1390Sstevel@tonic-gate  *	bus_prop_op		_  request for property
1400Sstevel@tonic-gate  */
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate #define	BUSO_REV_3	3
1430Sstevel@tonic-gate #define	BUSO_REV_4	4
1440Sstevel@tonic-gate #define	BUSO_REV_5	5
1450Sstevel@tonic-gate #define	BUSO_REV_6	6
1460Sstevel@tonic-gate #define	BUSO_REV_7	7
1470Sstevel@tonic-gate #define	BUSO_REV_8	8
1480Sstevel@tonic-gate #define	BUSO_REV_9	9
149*10923SEvan.Yan@Sun.COM #define	BUSO_REV_10	10
150*10923SEvan.Yan@Sun.COM #define	BUSO_REV	BUSO_REV_10
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate struct bus_ops  {
1540Sstevel@tonic-gate 	int		busops_rev;	/* rev of this structure */
1550Sstevel@tonic-gate 	int		(*bus_map)(dev_info_t *dip, dev_info_t *rdip,
1560Sstevel@tonic-gate 			    ddi_map_req_t *mp, off_t offset, off_t len,
1570Sstevel@tonic-gate 			    caddr_t *vaddrp);
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate 	/*
1600Sstevel@tonic-gate 	 * NOTE: the following 3 busops entrypoints are obsoleted with
1610Sstevel@tonic-gate 	 * version 9 or greater. Use bus_intr_op interface in place of
1620Sstevel@tonic-gate 	 * these obsolete interfaces.
1630Sstevel@tonic-gate 	 */
1640Sstevel@tonic-gate 	ddi_intrspec_t	(*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
1650Sstevel@tonic-gate 			    uint_t inumber);
1660Sstevel@tonic-gate 	int		(*bus_add_intrspec)(dev_info_t *dip,
1670Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
1680Sstevel@tonic-gate 			    ddi_iblock_cookie_t *ibcp,
1690Sstevel@tonic-gate 			    ddi_idevice_cookie_t *idcp,
1700Sstevel@tonic-gate 			    uint_t (*int_handler)(caddr_t intr_handler_arg),
1710Sstevel@tonic-gate 			    caddr_t intr_handler_arg, int kind);
1720Sstevel@tonic-gate 	void		(*bus_remove_intrspec)(dev_info_t *dip,
1730Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
1740Sstevel@tonic-gate 			    ddi_iblock_cookie_t iblock_cookie);
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate 	int		(*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
1770Sstevel@tonic-gate 			    struct hat *hat, struct seg *seg, caddr_t addr,
1780Sstevel@tonic-gate 			    struct devpage *dp, pfn_t pfn, uint_t prot,
1790Sstevel@tonic-gate 			    uint_t lock);
1800Sstevel@tonic-gate 	int		(*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
1810Sstevel@tonic-gate 			    struct ddi_dma_req *dmareq,
1820Sstevel@tonic-gate 			    ddi_dma_handle_t *handlep);
1830Sstevel@tonic-gate 	int		(*bus_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip,
1840Sstevel@tonic-gate 			    ddi_dma_attr_t *attr, int (*waitfp)(caddr_t),
1850Sstevel@tonic-gate 			    caddr_t arg, ddi_dma_handle_t *handlep);
1860Sstevel@tonic-gate 	int		(*bus_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip,
1870Sstevel@tonic-gate 			    ddi_dma_handle_t handle);
1880Sstevel@tonic-gate 	int		(*bus_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip,
1890Sstevel@tonic-gate 			    ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
1900Sstevel@tonic-gate 			    ddi_dma_cookie_t *, uint_t *);
1910Sstevel@tonic-gate 	int		(*bus_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip,
1920Sstevel@tonic-gate 			    ddi_dma_handle_t handle);
1930Sstevel@tonic-gate 	int		(*bus_dma_flush)(dev_info_t *dip, dev_info_t *rdip,
1940Sstevel@tonic-gate 			    ddi_dma_handle_t handle, off_t off,
1950Sstevel@tonic-gate 			    size_t len, uint_t cache_flags);
1960Sstevel@tonic-gate 	int		(*bus_dma_win)(dev_info_t *dip, dev_info_t *rdip,
1970Sstevel@tonic-gate 			    ddi_dma_handle_t handle, uint_t win, off_t *offp,
1980Sstevel@tonic-gate 			    size_t *lenp, ddi_dma_cookie_t *cookiep,
1990Sstevel@tonic-gate 			    uint_t *ccountp);
2000Sstevel@tonic-gate 	int		(*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
2010Sstevel@tonic-gate 			    ddi_dma_handle_t handle,
2020Sstevel@tonic-gate 			    enum ddi_dma_ctlops request, off_t *offp,
2030Sstevel@tonic-gate 			    size_t *lenp, caddr_t *objp, uint_t flags);
2040Sstevel@tonic-gate 	int		(*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
2050Sstevel@tonic-gate 			    ddi_ctl_enum_t ctlop, void *arg, void *result);
2060Sstevel@tonic-gate 	int		(*bus_prop_op)(dev_t dev, dev_info_t *dip,
2070Sstevel@tonic-gate 			    dev_info_t *child_dip, ddi_prop_op_t prop_op,
2080Sstevel@tonic-gate 			    int mod_flags, char *name, caddr_t valuep,
2090Sstevel@tonic-gate 			    int *length);
2100Sstevel@tonic-gate 	/*
2110Sstevel@tonic-gate 	 * NOTE: the following 4 busops entrypoints are only available
2120Sstevel@tonic-gate 	 * with version 3 or greater.  Due to interface modifications, these
2130Sstevel@tonic-gate 	 * entrypoints can only be used with version 6 or greater.
2140Sstevel@tonic-gate 	 */
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate 	int		(*bus_get_eventcookie)(dev_info_t *dip,
2170Sstevel@tonic-gate 			    dev_info_t *rdip, char *eventname,
2180Sstevel@tonic-gate 			    ddi_eventcookie_t *cookiep);
2190Sstevel@tonic-gate 	int		(*bus_add_eventcall)(dev_info_t *dip, dev_info_t *rdip,
2200Sstevel@tonic-gate 			    ddi_eventcookie_t eventid,
2210Sstevel@tonic-gate 			    void (*event_hdlr)(dev_info_t *dip,
2220Sstevel@tonic-gate 			    ddi_eventcookie_t event, void *arg,
2230Sstevel@tonic-gate 			    void *bus_impldata), void *arg,
2240Sstevel@tonic-gate 			    ddi_callback_id_t *cb_id);
2250Sstevel@tonic-gate 	int		(*bus_remove_eventcall)(dev_info_t *devi,
2260Sstevel@tonic-gate 			    ddi_callback_id_t cb_id);
2270Sstevel@tonic-gate 	int		(*bus_post_event)(dev_info_t *dip, dev_info_t *rdip,
2280Sstevel@tonic-gate 			    ddi_eventcookie_t event, void *impl_data);
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate 	/*
2310Sstevel@tonic-gate 	 * NOTE: the following bus_intr_ctl entrypoint is obsoleted with
2320Sstevel@tonic-gate 	 * version 9 or greater. Use bus_intr_op interface in place of
2330Sstevel@tonic-gate 	 * this obsolete interface.
2340Sstevel@tonic-gate 	 */
2350Sstevel@tonic-gate 	int		(*bus_intr_ctl)(dev_info_t *dip, dev_info_t *rdip,
2360Sstevel@tonic-gate 			    ddi_intr_ctlop_t ctlop, void * arg, void * result);
2370Sstevel@tonic-gate 	/*
2380Sstevel@tonic-gate 	 * NOTE: the following busop entrypoints are available with version
2390Sstevel@tonic-gate 	 * 5 or greater.
2400Sstevel@tonic-gate 	 */
2410Sstevel@tonic-gate 	int		(*bus_config)(dev_info_t *parent, uint_t flags,
2420Sstevel@tonic-gate 			    ddi_bus_config_op_t op, void *arg,
2430Sstevel@tonic-gate 			    dev_info_t **childp);
2440Sstevel@tonic-gate 	int		(*bus_unconfig)(dev_info_t *parent, uint_t flags,
2450Sstevel@tonic-gate 			    ddi_bus_config_op_t op, void *arg);
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate 	/*
2480Sstevel@tonic-gate 	 * NOTE: the following busop entrypoints are available with version
2490Sstevel@tonic-gate 	 * 6 or greater.
2500Sstevel@tonic-gate 	 */
2510Sstevel@tonic-gate 	int		(*bus_fm_init)(dev_info_t *dip, dev_info_t *tdip,
2520Sstevel@tonic-gate 			    int cap, ddi_iblock_cookie_t *ibc);
2530Sstevel@tonic-gate 	void		(*bus_fm_fini)(dev_info_t *dip, dev_info_t *tdip);
2540Sstevel@tonic-gate 	void		(*bus_fm_access_enter)(dev_info_t *dip,
2550Sstevel@tonic-gate 			    ddi_acc_handle_t handle);
2560Sstevel@tonic-gate 	void		(*bus_fm_access_exit)(dev_info_t *dip,
2570Sstevel@tonic-gate 			    ddi_acc_handle_t handle);
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate 	/*
2600Sstevel@tonic-gate 	 * NOTE: the following busop entrypoint is available with version
2610Sstevel@tonic-gate 	 * 7 or greater.
2620Sstevel@tonic-gate 	 */
2630Sstevel@tonic-gate 	int		(*bus_power)(dev_info_t *dip, void *impl_arg,
2640Sstevel@tonic-gate 			    pm_bus_power_op_t op, void *arg, void *result);
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate 	/*
2670Sstevel@tonic-gate 	 * NOTE: the following busop entrypoint is available with version
2680Sstevel@tonic-gate 	 * 9 or greater.
2690Sstevel@tonic-gate 	 */
2700Sstevel@tonic-gate 	int		(*bus_intr_op)(dev_info_t *dip, dev_info_t *rdip,
2710Sstevel@tonic-gate 			    ddi_intr_op_t op, ddi_intr_handle_impl_t *hdlp,
2720Sstevel@tonic-gate 			    void *result);
273*10923SEvan.Yan@Sun.COM 
274*10923SEvan.Yan@Sun.COM 	/*
275*10923SEvan.Yan@Sun.COM 	 * NOTE: the following busop entrypoint is available with version
276*10923SEvan.Yan@Sun.COM 	 * 10 or greater.
277*10923SEvan.Yan@Sun.COM 	 */
278*10923SEvan.Yan@Sun.COM 	int		(*bus_hp_op)(dev_info_t *dip, char *cn_name,
279*10923SEvan.Yan@Sun.COM 			    ddi_hp_op_t op, void *arg, void *result);
2800Sstevel@tonic-gate };
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate /*
2830Sstevel@tonic-gate  * REV 1 bus ops structure
2840Sstevel@tonic-gate  */
2850Sstevel@tonic-gate 
2860Sstevel@tonic-gate struct bus_ops_rev1 {
2870Sstevel@tonic-gate 	int		(*bus_map)(dev_info_t *dip, dev_info_t *rdip,
2880Sstevel@tonic-gate 			    ddi_map_req_t *mp, off_t offset, off_t len,
2890Sstevel@tonic-gate 			    caddr_t *vaddrp);
2900Sstevel@tonic-gate 	ddi_intrspec_t	(*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip,
2910Sstevel@tonic-gate 			    uint_t inumber);
2920Sstevel@tonic-gate 	int		(*bus_add_intrspec)(dev_info_t *dip,
2930Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
2940Sstevel@tonic-gate 			    ddi_iblock_cookie_t *ibcp,
2950Sstevel@tonic-gate 			    ddi_idevice_cookie_t *idcp,
2960Sstevel@tonic-gate 			    uint_t (*int_handler)(caddr_t intr_handler_arg),
2970Sstevel@tonic-gate 			    caddr_t intr_handler_arg, int kind);
2980Sstevel@tonic-gate 	void		(*bus_remove_intrspec)(dev_info_t *dip,
2990Sstevel@tonic-gate 			    dev_info_t *rdip, ddi_intrspec_t intrspec,
3000Sstevel@tonic-gate 			    ddi_iblock_cookie_t iblock_cookie);
3010Sstevel@tonic-gate 	int		(*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip,
3020Sstevel@tonic-gate 			    struct hat *hat, struct seg *seg, caddr_t addr,
3030Sstevel@tonic-gate 			    struct devpage *dp, pfn_t pfn, uint_t prot,
3040Sstevel@tonic-gate 			    uint_t lock);
3050Sstevel@tonic-gate 	int		(*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip,
3060Sstevel@tonic-gate 			    struct ddi_dma_req *dmareq,
3070Sstevel@tonic-gate 			    ddi_dma_handle_t *handlep);
3080Sstevel@tonic-gate 	int		(*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip,
3090Sstevel@tonic-gate 			    ddi_dma_handle_t handle,
3100Sstevel@tonic-gate 			    enum ddi_dma_ctlops request, off_t *offp,
3110Sstevel@tonic-gate 			    uint_t *lenp, caddr_t *objp, uint_t flags);
3120Sstevel@tonic-gate 	int		(*bus_ctl)(dev_info_t *dip, dev_info_t *rdip,
3130Sstevel@tonic-gate 			    ddi_ctl_enum_t ctlop, void *arg, void *result);
3140Sstevel@tonic-gate 	int		(*bus_prop_op)(dev_t dev, dev_info_t *dip,
3150Sstevel@tonic-gate 			    dev_info_t *child_dip, ddi_prop_op_t prop_op,
3160Sstevel@tonic-gate 			    int mod_flags, char *name, caddr_t valuep,
3170Sstevel@tonic-gate 			    int *length);
3180Sstevel@tonic-gate };
3190Sstevel@tonic-gate 
3200Sstevel@tonic-gate /*
3210Sstevel@tonic-gate  * dev_ops:	Contains driver common fields and pointers
3220Sstevel@tonic-gate  *		to the bus_ops and/or cb_ops parts.
3230Sstevel@tonic-gate  *
3240Sstevel@tonic-gate  * Drivers should set devo_rev to DEVO_REV at compile time.
3250Sstevel@tonic-gate  * All drivers should support these entry points.
3260Sstevel@tonic-gate  *
3270Sstevel@tonic-gate  * the following device functions are provided in the device operations
3280Sstevel@tonic-gate  * structure.
3290Sstevel@tonic-gate  *
3300Sstevel@tonic-gate  *	devo_getinfo		-  Device handle conversion
3310Sstevel@tonic-gate  *	devo_identify		-  Obsolete, set to nulldev
3320Sstevel@tonic-gate  *	devo_probe		-  Probe for device's existence
3330Sstevel@tonic-gate  *	devo_attach		-  Attach driver to dev_info
3340Sstevel@tonic-gate  *	devo_detach		-  Detach/prepare driver to unload
3350Sstevel@tonic-gate  *	devo_reset		-  Reset device
3367656SSherry.Moore@Sun.COM  *	devo_quiesce		-  Quiesce device
3370Sstevel@tonic-gate  */
3380Sstevel@tonic-gate 
3397656SSherry.Moore@Sun.COM #define		DEVO_REV		4
3400Sstevel@tonic-gate #define		CB_REV			1
3410Sstevel@tonic-gate 
3420Sstevel@tonic-gate /*
3430Sstevel@tonic-gate  * Return from driver's devo_probe function:
3440Sstevel@tonic-gate  */
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate #define	DDI_PROBE_FAILURE	ENXIO	/* matches nodev return */
3470Sstevel@tonic-gate #define	DDI_PROBE_DONTCARE	0	/* matches nulldev return */
3480Sstevel@tonic-gate #define	DDI_PROBE_PARTIAL	1
3490Sstevel@tonic-gate #define	DDI_PROBE_SUCCESS	2
3500Sstevel@tonic-gate 
3510Sstevel@tonic-gate /*
3520Sstevel@tonic-gate  * Typedefs for the info, attach, detach and reset routines.
3530Sstevel@tonic-gate  * These are mostly placeholders for now.
3540Sstevel@tonic-gate  *
3550Sstevel@tonic-gate  * NOTE: DDI_INFO_DEVT2DEVINFO is deprecated
3560Sstevel@tonic-gate  */
3570Sstevel@tonic-gate typedef enum {
3580Sstevel@tonic-gate 	DDI_INFO_DEVT2DEVINFO = 0,	/* Convert a dev_t to a dev_info_t */
3590Sstevel@tonic-gate 	DDI_INFO_DEVT2INSTANCE = 1	/* Convert a dev_t to an instance # */
3600Sstevel@tonic-gate } ddi_info_cmd_t;
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate typedef enum {
3630Sstevel@tonic-gate 	DDI_ATTACH = 0,
3640Sstevel@tonic-gate 	DDI_RESUME = 1,
3650Sstevel@tonic-gate 	DDI_PM_RESUME = 2
3660Sstevel@tonic-gate } ddi_attach_cmd_t;
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate typedef enum {
3690Sstevel@tonic-gate 	DDI_DETACH = 0,
3700Sstevel@tonic-gate 	DDI_SUSPEND = 1,
3710Sstevel@tonic-gate 	DDI_PM_SUSPEND = 2,
3720Sstevel@tonic-gate 	DDI_HOTPLUG_DETACH = 3		/* detach, don't try to auto-unconfig */
3730Sstevel@tonic-gate } ddi_detach_cmd_t;
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate typedef enum {
3760Sstevel@tonic-gate 	DDI_RESET_FORCE = 0
3770Sstevel@tonic-gate } ddi_reset_cmd_t;
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate struct dev_ops  {
3800Sstevel@tonic-gate 	int		devo_rev;	/* Driver build version		*/
3810Sstevel@tonic-gate 	int		devo_refcnt;	/* device reference count	*/
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate 	int		(*devo_getinfo)(dev_info_t *dip,
3840Sstevel@tonic-gate 			    ddi_info_cmd_t infocmd, void *arg, void **result);
3850Sstevel@tonic-gate 	int		(*devo_identify)(dev_info_t *dip);
3860Sstevel@tonic-gate 	int		(*devo_probe)(dev_info_t *dip);
3870Sstevel@tonic-gate 	int		(*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd);
3880Sstevel@tonic-gate 	int		(*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd);
3890Sstevel@tonic-gate 	int		(*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd);
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 	struct cb_ops	*devo_cb_ops;	/* cb_ops pointer for leaf drivers   */
3920Sstevel@tonic-gate 	struct bus_ops	*devo_bus_ops;	/* bus_ops pointer for nexus drivers */
3930Sstevel@tonic-gate 	int		(*devo_power)(dev_info_t *dip, int component,
3940Sstevel@tonic-gate 			    int level);
3957656SSherry.Moore@Sun.COM 	int		(*devo_quiesce)(dev_info_t *dip);
3960Sstevel@tonic-gate };
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate /*
3990Sstevel@tonic-gate  * Create a dev_ops suitable for a streams driver:
4000Sstevel@tonic-gate  *
4010Sstevel@tonic-gate  * XXX: Note:  Since this is a macro, it is NOT supported as
4020Sstevel@tonic-gate  * XXX: part of the Sun DDI.  It is not a documented Sun DDI interface.
4030Sstevel@tonic-gate  *
4040Sstevel@tonic-gate  * STR_OPS(name, identify, probe, attach, detach, reset,
4050Sstevel@tonic-gate  *	info, flag, stream_tab);
4060Sstevel@tonic-gate  *
4070Sstevel@tonic-gate  *	XXname is the name of the dev_ops structure.
4080Sstevel@tonic-gate  *	XXidentify must be set to nulldev
4090Sstevel@tonic-gate  *	XXprobe is the name of the probe routine, or nulldev
4100Sstevel@tonic-gate  *	XXattach is the name of the attach routine
4110Sstevel@tonic-gate  *	XXdetach is the name of the detach routine, or nodev
4120Sstevel@tonic-gate  *	XXreset is the name of the reset routine, or nodev
4130Sstevel@tonic-gate  *	XXinfo is the name of the info routine
4140Sstevel@tonic-gate  *	XXflag is driver flag (cb_flag) in cb_ops,
4150Sstevel@tonic-gate  *	XXstream_tab is the obvious.
4167656SSherry.Moore@Sun.COM  *	XXquiesce is the name of the quiesce routine. It must be implemented
4177656SSherry.Moore@Sun.COM  *		for fast reboot to succeed.
4180Sstevel@tonic-gate  *	cb_##XXname is the name of the internally defined cb_ops struct.
4190Sstevel@tonic-gate  *
4200Sstevel@tonic-gate  * uses cb_XXname as name of static cb_ops structure.
4210Sstevel@tonic-gate  */
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate /*
4240Sstevel@tonic-gate  * This file is included by genassym.c now and I couldn't get it to take the
4250Sstevel@tonic-gate  * next line if it was broken into two lines joined by a '\'.  So, don't try
4260Sstevel@tonic-gate  * to reformat it to satisfy Cstyle because genassym.c won't compile.
4270Sstevel@tonic-gate  */
4280Sstevel@tonic-gate /* CSTYLED */
4297656SSherry.Moore@Sun.COM #define	DDI_DEFINE_STREAM_OPS(XXname, XXidentify, XXprobe, XXattach, XXdetach, XXreset, XXgetinfo, XXflag, XXstream_tab, XXquiesce) \
4300Sstevel@tonic-gate static struct cb_ops cb_##XXname = {					\
4310Sstevel@tonic-gate 	nulldev,		/* cb_open */				\
4320Sstevel@tonic-gate 	nulldev,		/* cb_close */				\
4330Sstevel@tonic-gate 	nodev,			/* cb_strategy */			\
4340Sstevel@tonic-gate 	nodev,			/* cb_print */				\
4350Sstevel@tonic-gate 	nodev,			/* cb_dump */				\
4360Sstevel@tonic-gate 	nodev,			/* cb_read */				\
4370Sstevel@tonic-gate 	nodev,			/* cb_write */				\
4380Sstevel@tonic-gate 	nodev,			/* cb_ioctl */				\
4390Sstevel@tonic-gate 	nodev,			/* cb_devmap */				\
4400Sstevel@tonic-gate 	nodev,			/* cb_mmap */				\
4410Sstevel@tonic-gate 	nodev,			/* cb_segmap */				\
4420Sstevel@tonic-gate 	nochpoll,		/* cb_chpoll */				\
4430Sstevel@tonic-gate 	ddi_prop_op,		/* cb_prop_op */			\
4440Sstevel@tonic-gate 	(XXstream_tab),		/* cb_stream */				\
4450Sstevel@tonic-gate 	(int)(XXflag),		/* cb_flag */				\
4460Sstevel@tonic-gate 	CB_REV,			/* cb_rev */				\
4470Sstevel@tonic-gate 	nodev,			/* cb_aread */				\
4480Sstevel@tonic-gate 	nodev,			/* cb_awrite */				\
4490Sstevel@tonic-gate };									\
4500Sstevel@tonic-gate 									\
4510Sstevel@tonic-gate static struct dev_ops XXname = {					\
4520Sstevel@tonic-gate 	DEVO_REV,		/* devo_rev */				\
4530Sstevel@tonic-gate 	0,			/* devo_refcnt */			\
4540Sstevel@tonic-gate 	(XXgetinfo),		/* devo_getinfo */			\
4550Sstevel@tonic-gate 	(XXidentify),		/* devo_identify */			\
4560Sstevel@tonic-gate 	(XXprobe),		/* devo_probe */			\
4570Sstevel@tonic-gate 	(XXattach),		/* devo_attach */			\
4580Sstevel@tonic-gate 	(XXdetach),		/* devo_detach */			\
4590Sstevel@tonic-gate 	(XXreset),		/* devo_reset */			\
4600Sstevel@tonic-gate 	&(cb_##XXname),		/* devo_cb_ops */			\
4610Sstevel@tonic-gate 	(struct bus_ops *)NULL,	/* devo_bus_ops */			\
4627656SSherry.Moore@Sun.COM 	NULL,			/* devo_power */			\
4637656SSherry.Moore@Sun.COM 	(XXquiesce)		/* devo_quiesce */			\
4640Sstevel@tonic-gate }
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate #endif	/* _KERNEL */
4670Sstevel@tonic-gate 
4680Sstevel@tonic-gate #ifdef	__cplusplus
4690Sstevel@tonic-gate }
4700Sstevel@tonic-gate #endif
4710Sstevel@tonic-gate 
4720Sstevel@tonic-gate #endif	/* _SYS_DEVOPS_H */
473