1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_DEVOPS_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_DEVOPS_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 */ 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/cred.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/uio.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/buf.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/poll.h> 37*7c478bd9Sstevel@tonic-gate #include <vm/as.h> 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/ddidmareq.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/ddimapreq.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/ddidevmap.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/ddifm.h> 45*7c478bd9Sstevel@tonic-gate #include <sys/nexusdefs.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/ddi_intr.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/aio_req.h> 48*7c478bd9Sstevel@tonic-gate #include <vm/page.h> 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 51*7c478bd9Sstevel@tonic-gate extern "C" { 52*7c478bd9Sstevel@tonic-gate #endif 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate /* 57*7c478bd9Sstevel@tonic-gate * cb_ops: Leaf device drivers or bus nexus drivers supporting 58*7c478bd9Sstevel@tonic-gate * direct user process access (open/close/etc). 59*7c478bd9Sstevel@tonic-gate * 60*7c478bd9Sstevel@tonic-gate * This is an OR of cdevsw and bdevsw fields for drivers that 61*7c478bd9Sstevel@tonic-gate * support both character and block entry points. 62*7c478bd9Sstevel@tonic-gate * 63*7c478bd9Sstevel@tonic-gate * For streams stuff, see also sys/stream.h. 64*7c478bd9Sstevel@tonic-gate * 65*7c478bd9Sstevel@tonic-gate * The following DDI/DKI or DKI only or DDI only functions are 66*7c478bd9Sstevel@tonic-gate * provided in the character/block driver operations structure. 67*7c478bd9Sstevel@tonic-gate * 68*7c478bd9Sstevel@tonic-gate * block/char Function description 69*7c478bd9Sstevel@tonic-gate * b/c XXopen DDI/DKI 70*7c478bd9Sstevel@tonic-gate * b/c XXclose DDI/DKI 71*7c478bd9Sstevel@tonic-gate * b XXstrategy DDI/DKI 72*7c478bd9Sstevel@tonic-gate * b XXprint DDI/DKI 73*7c478bd9Sstevel@tonic-gate * b XXdump DDI(Sun) 74*7c478bd9Sstevel@tonic-gate * c XXread DDI/DKI 75*7c478bd9Sstevel@tonic-gate * c XXwrite DDI/DKI 76*7c478bd9Sstevel@tonic-gate * c XXioctl DDI/DKI 77*7c478bd9Sstevel@tonic-gate * c XXdevmap DDI(Sun) 78*7c478bd9Sstevel@tonic-gate * c XXmmap DKI 79*7c478bd9Sstevel@tonic-gate * c XXsegmap DKI 80*7c478bd9Sstevel@tonic-gate * c XXchpoll DDI/DKI 81*7c478bd9Sstevel@tonic-gate * c XXprop_op DDI(Sun) 82*7c478bd9Sstevel@tonic-gate */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate struct cb_ops { 85*7c478bd9Sstevel@tonic-gate int (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp); 86*7c478bd9Sstevel@tonic-gate int (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp); 87*7c478bd9Sstevel@tonic-gate int (*cb_strategy)(struct buf *bp); 88*7c478bd9Sstevel@tonic-gate int (*cb_print)(dev_t dev, char *str); 89*7c478bd9Sstevel@tonic-gate int (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk); 90*7c478bd9Sstevel@tonic-gate int (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp); 91*7c478bd9Sstevel@tonic-gate int (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp); 92*7c478bd9Sstevel@tonic-gate int (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode, 93*7c478bd9Sstevel@tonic-gate cred_t *credp, int *rvalp); 94*7c478bd9Sstevel@tonic-gate int (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off, 95*7c478bd9Sstevel@tonic-gate size_t len, size_t *maplen, uint_t model); 96*7c478bd9Sstevel@tonic-gate int (*cb_mmap)(dev_t dev, off_t off, int prot); 97*7c478bd9Sstevel@tonic-gate int (*cb_segmap)(dev_t dev, off_t off, struct as *asp, 98*7c478bd9Sstevel@tonic-gate caddr_t *addrp, off_t len, unsigned int prot, 99*7c478bd9Sstevel@tonic-gate unsigned int maxprot, unsigned int flags, cred_t *credp); 100*7c478bd9Sstevel@tonic-gate int (*cb_chpoll)(dev_t dev, short events, int anyyet, 101*7c478bd9Sstevel@tonic-gate short *reventsp, struct pollhead **phpp); 102*7c478bd9Sstevel@tonic-gate int (*cb_prop_op)(dev_t dev, dev_info_t *dip, 103*7c478bd9Sstevel@tonic-gate ddi_prop_op_t prop_op, int mod_flags, 104*7c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *length); 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate struct streamtab *cb_str; /* streams information */ 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* 109*7c478bd9Sstevel@tonic-gate * The cb_flag fields are here to tell the system a 110*7c478bd9Sstevel@tonic-gate * bit about the device. The bit definitions are 111*7c478bd9Sstevel@tonic-gate * in <sys/conf.h>. 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate int cb_flag; /* driver compatibility flag */ 114*7c478bd9Sstevel@tonic-gate int cb_rev; /* cb_ops version number */ 115*7c478bd9Sstevel@tonic-gate int (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp); 116*7c478bd9Sstevel@tonic-gate int (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp); 117*7c478bd9Sstevel@tonic-gate }; 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate /* 120*7c478bd9Sstevel@tonic-gate * bus_ops: bus nexus drivers only. 121*7c478bd9Sstevel@tonic-gate * 122*7c478bd9Sstevel@tonic-gate * These functions are used to implement the Sun DDI functions 123*7c478bd9Sstevel@tonic-gate * described elsewhere. 124*7c478bd9Sstevel@tonic-gate * 125*7c478bd9Sstevel@tonic-gate * Only nexus drivers support these entry points. 126*7c478bd9Sstevel@tonic-gate * 127*7c478bd9Sstevel@tonic-gate * The following bus nexus functions are provided in the bus nexus 128*7c478bd9Sstevel@tonic-gate * driver operations structure. Note that all functions take both 129*7c478bd9Sstevel@tonic-gate * their dip and the requesters dip except for the child functions since 130*7c478bd9Sstevel@tonic-gate * they will be called from outside the ddi. 131*7c478bd9Sstevel@tonic-gate * 132*7c478bd9Sstevel@tonic-gate * bus_map - Map/unmap/control IU -> device mappings. 133*7c478bd9Sstevel@tonic-gate * bus_get_intrspec - get interrupt specification by number 134*7c478bd9Sstevel@tonic-gate * bus_add_intrspec - add interrupt specification, return cookie 135*7c478bd9Sstevel@tonic-gate * bus_remove_intrspec - remove interrupt specification 136*7c478bd9Sstevel@tonic-gate * bus_map_fault - bus fault handler 137*7c478bd9Sstevel@tonic-gate * bus_dma_map - setup dma mapping 138*7c478bd9Sstevel@tonic-gate * bus_dma_mapctl - control (and free) dma mapping 139*7c478bd9Sstevel@tonic-gate * bus_ctl - generic control operations 140*7c478bd9Sstevel@tonic-gate * bus_prop_op _ request for property 141*7c478bd9Sstevel@tonic-gate */ 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate #define BUSO_REV_3 3 144*7c478bd9Sstevel@tonic-gate #define BUSO_REV_4 4 145*7c478bd9Sstevel@tonic-gate #define BUSO_REV_5 5 146*7c478bd9Sstevel@tonic-gate #define BUSO_REV_6 6 147*7c478bd9Sstevel@tonic-gate #define BUSO_REV_7 7 148*7c478bd9Sstevel@tonic-gate #define BUSO_REV_8 8 149*7c478bd9Sstevel@tonic-gate #define BUSO_REV_9 9 150*7c478bd9Sstevel@tonic-gate #define BUSO_REV BUSO_REV_9 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate struct bus_ops { 154*7c478bd9Sstevel@tonic-gate int busops_rev; /* rev of this structure */ 155*7c478bd9Sstevel@tonic-gate int (*bus_map)(dev_info_t *dip, dev_info_t *rdip, 156*7c478bd9Sstevel@tonic-gate ddi_map_req_t *mp, off_t offset, off_t len, 157*7c478bd9Sstevel@tonic-gate caddr_t *vaddrp); 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate /* 160*7c478bd9Sstevel@tonic-gate * NOTE: the following 3 busops entrypoints are obsoleted with 161*7c478bd9Sstevel@tonic-gate * version 9 or greater. Use bus_intr_op interface in place of 162*7c478bd9Sstevel@tonic-gate * these obsolete interfaces. 163*7c478bd9Sstevel@tonic-gate */ 164*7c478bd9Sstevel@tonic-gate ddi_intrspec_t (*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip, 165*7c478bd9Sstevel@tonic-gate uint_t inumber); 166*7c478bd9Sstevel@tonic-gate int (*bus_add_intrspec)(dev_info_t *dip, 167*7c478bd9Sstevel@tonic-gate dev_info_t *rdip, ddi_intrspec_t intrspec, 168*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t *ibcp, 169*7c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t *idcp, 170*7c478bd9Sstevel@tonic-gate uint_t (*int_handler)(caddr_t intr_handler_arg), 171*7c478bd9Sstevel@tonic-gate caddr_t intr_handler_arg, int kind); 172*7c478bd9Sstevel@tonic-gate void (*bus_remove_intrspec)(dev_info_t *dip, 173*7c478bd9Sstevel@tonic-gate dev_info_t *rdip, ddi_intrspec_t intrspec, 174*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t iblock_cookie); 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate int (*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip, 177*7c478bd9Sstevel@tonic-gate struct hat *hat, struct seg *seg, caddr_t addr, 178*7c478bd9Sstevel@tonic-gate struct devpage *dp, pfn_t pfn, uint_t prot, 179*7c478bd9Sstevel@tonic-gate uint_t lock); 180*7c478bd9Sstevel@tonic-gate int (*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip, 181*7c478bd9Sstevel@tonic-gate struct ddi_dma_req *dmareq, 182*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t *handlep); 183*7c478bd9Sstevel@tonic-gate int (*bus_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip, 184*7c478bd9Sstevel@tonic-gate ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), 185*7c478bd9Sstevel@tonic-gate caddr_t arg, ddi_dma_handle_t *handlep); 186*7c478bd9Sstevel@tonic-gate int (*bus_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip, 187*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle); 188*7c478bd9Sstevel@tonic-gate int (*bus_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip, 189*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, 190*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t *, uint_t *); 191*7c478bd9Sstevel@tonic-gate int (*bus_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip, 192*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle); 193*7c478bd9Sstevel@tonic-gate int (*bus_dma_flush)(dev_info_t *dip, dev_info_t *rdip, 194*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, off_t off, 195*7c478bd9Sstevel@tonic-gate size_t len, uint_t cache_flags); 196*7c478bd9Sstevel@tonic-gate int (*bus_dma_win)(dev_info_t *dip, dev_info_t *rdip, 197*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, uint_t win, off_t *offp, 198*7c478bd9Sstevel@tonic-gate size_t *lenp, ddi_dma_cookie_t *cookiep, 199*7c478bd9Sstevel@tonic-gate uint_t *ccountp); 200*7c478bd9Sstevel@tonic-gate int (*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip, 201*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, 202*7c478bd9Sstevel@tonic-gate enum ddi_dma_ctlops request, off_t *offp, 203*7c478bd9Sstevel@tonic-gate size_t *lenp, caddr_t *objp, uint_t flags); 204*7c478bd9Sstevel@tonic-gate int (*bus_ctl)(dev_info_t *dip, dev_info_t *rdip, 205*7c478bd9Sstevel@tonic-gate ddi_ctl_enum_t ctlop, void *arg, void *result); 206*7c478bd9Sstevel@tonic-gate int (*bus_prop_op)(dev_t dev, dev_info_t *dip, 207*7c478bd9Sstevel@tonic-gate dev_info_t *child_dip, ddi_prop_op_t prop_op, 208*7c478bd9Sstevel@tonic-gate int mod_flags, char *name, caddr_t valuep, 209*7c478bd9Sstevel@tonic-gate int *length); 210*7c478bd9Sstevel@tonic-gate /* 211*7c478bd9Sstevel@tonic-gate * NOTE: the following 4 busops entrypoints are only available 212*7c478bd9Sstevel@tonic-gate * with version 3 or greater. Due to interface modifications, these 213*7c478bd9Sstevel@tonic-gate * entrypoints can only be used with version 6 or greater. 214*7c478bd9Sstevel@tonic-gate */ 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate int (*bus_get_eventcookie)(dev_info_t *dip, 217*7c478bd9Sstevel@tonic-gate dev_info_t *rdip, char *eventname, 218*7c478bd9Sstevel@tonic-gate ddi_eventcookie_t *cookiep); 219*7c478bd9Sstevel@tonic-gate int (*bus_add_eventcall)(dev_info_t *dip, dev_info_t *rdip, 220*7c478bd9Sstevel@tonic-gate ddi_eventcookie_t eventid, 221*7c478bd9Sstevel@tonic-gate void (*event_hdlr)(dev_info_t *dip, 222*7c478bd9Sstevel@tonic-gate ddi_eventcookie_t event, void *arg, 223*7c478bd9Sstevel@tonic-gate void *bus_impldata), void *arg, 224*7c478bd9Sstevel@tonic-gate ddi_callback_id_t *cb_id); 225*7c478bd9Sstevel@tonic-gate int (*bus_remove_eventcall)(dev_info_t *devi, 226*7c478bd9Sstevel@tonic-gate ddi_callback_id_t cb_id); 227*7c478bd9Sstevel@tonic-gate int (*bus_post_event)(dev_info_t *dip, dev_info_t *rdip, 228*7c478bd9Sstevel@tonic-gate ddi_eventcookie_t event, void *impl_data); 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate /* 231*7c478bd9Sstevel@tonic-gate * NOTE: the following bus_intr_ctl entrypoint is obsoleted with 232*7c478bd9Sstevel@tonic-gate * version 9 or greater. Use bus_intr_op interface in place of 233*7c478bd9Sstevel@tonic-gate * this obsolete interface. 234*7c478bd9Sstevel@tonic-gate */ 235*7c478bd9Sstevel@tonic-gate int (*bus_intr_ctl)(dev_info_t *dip, dev_info_t *rdip, 236*7c478bd9Sstevel@tonic-gate ddi_intr_ctlop_t ctlop, void * arg, void * result); 237*7c478bd9Sstevel@tonic-gate /* 238*7c478bd9Sstevel@tonic-gate * NOTE: the following busop entrypoints are available with version 239*7c478bd9Sstevel@tonic-gate * 5 or greater. 240*7c478bd9Sstevel@tonic-gate */ 241*7c478bd9Sstevel@tonic-gate int (*bus_config)(dev_info_t *parent, uint_t flags, 242*7c478bd9Sstevel@tonic-gate ddi_bus_config_op_t op, void *arg, 243*7c478bd9Sstevel@tonic-gate dev_info_t **childp); 244*7c478bd9Sstevel@tonic-gate int (*bus_unconfig)(dev_info_t *parent, uint_t flags, 245*7c478bd9Sstevel@tonic-gate ddi_bus_config_op_t op, void *arg); 246*7c478bd9Sstevel@tonic-gate 247*7c478bd9Sstevel@tonic-gate /* 248*7c478bd9Sstevel@tonic-gate * NOTE: the following busop entrypoints are available with version 249*7c478bd9Sstevel@tonic-gate * 6 or greater. 250*7c478bd9Sstevel@tonic-gate */ 251*7c478bd9Sstevel@tonic-gate int (*bus_fm_init)(dev_info_t *dip, dev_info_t *tdip, 252*7c478bd9Sstevel@tonic-gate int cap, ddi_iblock_cookie_t *ibc); 253*7c478bd9Sstevel@tonic-gate void (*bus_fm_fini)(dev_info_t *dip, dev_info_t *tdip); 254*7c478bd9Sstevel@tonic-gate void (*bus_fm_access_enter)(dev_info_t *dip, 255*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t handle); 256*7c478bd9Sstevel@tonic-gate void (*bus_fm_access_exit)(dev_info_t *dip, 257*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t handle); 258*7c478bd9Sstevel@tonic-gate 259*7c478bd9Sstevel@tonic-gate /* 260*7c478bd9Sstevel@tonic-gate * NOTE: the following busop entrypoint is available with version 261*7c478bd9Sstevel@tonic-gate * 7 or greater. 262*7c478bd9Sstevel@tonic-gate */ 263*7c478bd9Sstevel@tonic-gate int (*bus_power)(dev_info_t *dip, void *impl_arg, 264*7c478bd9Sstevel@tonic-gate pm_bus_power_op_t op, void *arg, void *result); 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate /* 267*7c478bd9Sstevel@tonic-gate * NOTE: the following busop entrypoint is available with version 268*7c478bd9Sstevel@tonic-gate * 9 or greater. 269*7c478bd9Sstevel@tonic-gate */ 270*7c478bd9Sstevel@tonic-gate int (*bus_intr_op)(dev_info_t *dip, dev_info_t *rdip, 271*7c478bd9Sstevel@tonic-gate ddi_intr_op_t op, ddi_intr_handle_impl_t *hdlp, 272*7c478bd9Sstevel@tonic-gate void *result); 273*7c478bd9Sstevel@tonic-gate }; 274*7c478bd9Sstevel@tonic-gate 275*7c478bd9Sstevel@tonic-gate /* 276*7c478bd9Sstevel@tonic-gate * REV 1 bus ops structure 277*7c478bd9Sstevel@tonic-gate */ 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate struct bus_ops_rev1 { 280*7c478bd9Sstevel@tonic-gate int (*bus_map)(dev_info_t *dip, dev_info_t *rdip, 281*7c478bd9Sstevel@tonic-gate ddi_map_req_t *mp, off_t offset, off_t len, 282*7c478bd9Sstevel@tonic-gate caddr_t *vaddrp); 283*7c478bd9Sstevel@tonic-gate ddi_intrspec_t (*bus_get_intrspec)(dev_info_t *dip, dev_info_t *rdip, 284*7c478bd9Sstevel@tonic-gate uint_t inumber); 285*7c478bd9Sstevel@tonic-gate int (*bus_add_intrspec)(dev_info_t *dip, 286*7c478bd9Sstevel@tonic-gate dev_info_t *rdip, ddi_intrspec_t intrspec, 287*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t *ibcp, 288*7c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t *idcp, 289*7c478bd9Sstevel@tonic-gate uint_t (*int_handler)(caddr_t intr_handler_arg), 290*7c478bd9Sstevel@tonic-gate caddr_t intr_handler_arg, int kind); 291*7c478bd9Sstevel@tonic-gate void (*bus_remove_intrspec)(dev_info_t *dip, 292*7c478bd9Sstevel@tonic-gate dev_info_t *rdip, ddi_intrspec_t intrspec, 293*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t iblock_cookie); 294*7c478bd9Sstevel@tonic-gate int (*bus_map_fault)(dev_info_t *dip, dev_info_t *rdip, 295*7c478bd9Sstevel@tonic-gate struct hat *hat, struct seg *seg, caddr_t addr, 296*7c478bd9Sstevel@tonic-gate struct devpage *dp, pfn_t pfn, uint_t prot, 297*7c478bd9Sstevel@tonic-gate uint_t lock); 298*7c478bd9Sstevel@tonic-gate int (*bus_dma_map)(dev_info_t *dip, dev_info_t *rdip, 299*7c478bd9Sstevel@tonic-gate struct ddi_dma_req *dmareq, 300*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t *handlep); 301*7c478bd9Sstevel@tonic-gate int (*bus_dma_ctl)(dev_info_t *dip, dev_info_t *rdip, 302*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, 303*7c478bd9Sstevel@tonic-gate enum ddi_dma_ctlops request, off_t *offp, 304*7c478bd9Sstevel@tonic-gate uint_t *lenp, caddr_t *objp, uint_t flags); 305*7c478bd9Sstevel@tonic-gate int (*bus_ctl)(dev_info_t *dip, dev_info_t *rdip, 306*7c478bd9Sstevel@tonic-gate ddi_ctl_enum_t ctlop, void *arg, void *result); 307*7c478bd9Sstevel@tonic-gate int (*bus_prop_op)(dev_t dev, dev_info_t *dip, 308*7c478bd9Sstevel@tonic-gate dev_info_t *child_dip, ddi_prop_op_t prop_op, 309*7c478bd9Sstevel@tonic-gate int mod_flags, char *name, caddr_t valuep, 310*7c478bd9Sstevel@tonic-gate int *length); 311*7c478bd9Sstevel@tonic-gate }; 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate /* 314*7c478bd9Sstevel@tonic-gate * dev_ops: Contains driver common fields and pointers 315*7c478bd9Sstevel@tonic-gate * to the bus_ops and/or cb_ops parts. 316*7c478bd9Sstevel@tonic-gate * 317*7c478bd9Sstevel@tonic-gate * Drivers should set devo_rev to DEVO_REV at compile time. 318*7c478bd9Sstevel@tonic-gate * All drivers should support these entry points. 319*7c478bd9Sstevel@tonic-gate * 320*7c478bd9Sstevel@tonic-gate * the following device functions are provided in the device operations 321*7c478bd9Sstevel@tonic-gate * structure. 322*7c478bd9Sstevel@tonic-gate * 323*7c478bd9Sstevel@tonic-gate * devo_getinfo - Device handle conversion 324*7c478bd9Sstevel@tonic-gate * devo_identify - Obsolete, set to nulldev 325*7c478bd9Sstevel@tonic-gate * devo_probe - Probe for device's existence 326*7c478bd9Sstevel@tonic-gate * devo_attach - Attach driver to dev_info 327*7c478bd9Sstevel@tonic-gate * devo_detach - Detach/prepare driver to unload 328*7c478bd9Sstevel@tonic-gate * devo_reset - Reset device 329*7c478bd9Sstevel@tonic-gate */ 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate #define DEVO_REV 3 332*7c478bd9Sstevel@tonic-gate #define CB_REV 1 333*7c478bd9Sstevel@tonic-gate 334*7c478bd9Sstevel@tonic-gate /* 335*7c478bd9Sstevel@tonic-gate * Return from driver's devo_probe function: 336*7c478bd9Sstevel@tonic-gate */ 337*7c478bd9Sstevel@tonic-gate 338*7c478bd9Sstevel@tonic-gate #define DDI_PROBE_FAILURE ENXIO /* matches nodev return */ 339*7c478bd9Sstevel@tonic-gate #define DDI_PROBE_DONTCARE 0 /* matches nulldev return */ 340*7c478bd9Sstevel@tonic-gate #define DDI_PROBE_PARTIAL 1 341*7c478bd9Sstevel@tonic-gate #define DDI_PROBE_SUCCESS 2 342*7c478bd9Sstevel@tonic-gate 343*7c478bd9Sstevel@tonic-gate /* 344*7c478bd9Sstevel@tonic-gate * Typedefs for the info, attach, detach and reset routines. 345*7c478bd9Sstevel@tonic-gate * These are mostly placeholders for now. 346*7c478bd9Sstevel@tonic-gate * 347*7c478bd9Sstevel@tonic-gate * NOTE: DDI_INFO_DEVT2DEVINFO is deprecated 348*7c478bd9Sstevel@tonic-gate */ 349*7c478bd9Sstevel@tonic-gate typedef enum { 350*7c478bd9Sstevel@tonic-gate DDI_INFO_DEVT2DEVINFO = 0, /* Convert a dev_t to a dev_info_t */ 351*7c478bd9Sstevel@tonic-gate DDI_INFO_DEVT2INSTANCE = 1 /* Convert a dev_t to an instance # */ 352*7c478bd9Sstevel@tonic-gate } ddi_info_cmd_t; 353*7c478bd9Sstevel@tonic-gate 354*7c478bd9Sstevel@tonic-gate typedef enum { 355*7c478bd9Sstevel@tonic-gate DDI_ATTACH = 0, 356*7c478bd9Sstevel@tonic-gate DDI_RESUME = 1, 357*7c478bd9Sstevel@tonic-gate DDI_PM_RESUME = 2 358*7c478bd9Sstevel@tonic-gate } ddi_attach_cmd_t; 359*7c478bd9Sstevel@tonic-gate 360*7c478bd9Sstevel@tonic-gate typedef enum { 361*7c478bd9Sstevel@tonic-gate DDI_DETACH = 0, 362*7c478bd9Sstevel@tonic-gate DDI_SUSPEND = 1, 363*7c478bd9Sstevel@tonic-gate DDI_PM_SUSPEND = 2, 364*7c478bd9Sstevel@tonic-gate DDI_HOTPLUG_DETACH = 3 /* detach, don't try to auto-unconfig */ 365*7c478bd9Sstevel@tonic-gate } ddi_detach_cmd_t; 366*7c478bd9Sstevel@tonic-gate 367*7c478bd9Sstevel@tonic-gate typedef enum { 368*7c478bd9Sstevel@tonic-gate DDI_RESET_FORCE = 0 369*7c478bd9Sstevel@tonic-gate } ddi_reset_cmd_t; 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate 372*7c478bd9Sstevel@tonic-gate struct dev_ops { 373*7c478bd9Sstevel@tonic-gate int devo_rev; /* Driver build version */ 374*7c478bd9Sstevel@tonic-gate int devo_refcnt; /* device reference count */ 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate int (*devo_getinfo)(dev_info_t *dip, 377*7c478bd9Sstevel@tonic-gate ddi_info_cmd_t infocmd, void *arg, void **result); 378*7c478bd9Sstevel@tonic-gate int (*devo_identify)(dev_info_t *dip); 379*7c478bd9Sstevel@tonic-gate int (*devo_probe)(dev_info_t *dip); 380*7c478bd9Sstevel@tonic-gate int (*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd); 381*7c478bd9Sstevel@tonic-gate int (*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd); 382*7c478bd9Sstevel@tonic-gate int (*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd); 383*7c478bd9Sstevel@tonic-gate 384*7c478bd9Sstevel@tonic-gate struct cb_ops *devo_cb_ops; /* cb_ops pointer for leaf drivers */ 385*7c478bd9Sstevel@tonic-gate struct bus_ops *devo_bus_ops; /* bus_ops pointer for nexus drivers */ 386*7c478bd9Sstevel@tonic-gate int (*devo_power)(dev_info_t *dip, int component, 387*7c478bd9Sstevel@tonic-gate int level); 388*7c478bd9Sstevel@tonic-gate }; 389*7c478bd9Sstevel@tonic-gate 390*7c478bd9Sstevel@tonic-gate /* 391*7c478bd9Sstevel@tonic-gate * Create a dev_ops suitable for a streams driver: 392*7c478bd9Sstevel@tonic-gate * 393*7c478bd9Sstevel@tonic-gate * XXX: Note: Since this is a macro, it is NOT supported as 394*7c478bd9Sstevel@tonic-gate * XXX: part of the Sun DDI. It is not a documented Sun DDI interface. 395*7c478bd9Sstevel@tonic-gate * 396*7c478bd9Sstevel@tonic-gate * STR_OPS(name, identify, probe, attach, detach, reset, 397*7c478bd9Sstevel@tonic-gate * info, flag, stream_tab); 398*7c478bd9Sstevel@tonic-gate * 399*7c478bd9Sstevel@tonic-gate * XXname is the name of the dev_ops structure. 400*7c478bd9Sstevel@tonic-gate * XXidentify must be set to nulldev 401*7c478bd9Sstevel@tonic-gate * XXprobe is the name of the probe routine, or nulldev 402*7c478bd9Sstevel@tonic-gate * XXattach is the name of the attach routine 403*7c478bd9Sstevel@tonic-gate * XXdetach is the name of the detach routine, or nodev 404*7c478bd9Sstevel@tonic-gate * XXreset is the name of the reset routine, or nodev 405*7c478bd9Sstevel@tonic-gate * XXinfo is the name of the info routine 406*7c478bd9Sstevel@tonic-gate * XXflag is driver flag (cb_flag) in cb_ops, 407*7c478bd9Sstevel@tonic-gate * XXstream_tab is the obvious. 408*7c478bd9Sstevel@tonic-gate * cb_##XXname is the name of the internally defined cb_ops struct. 409*7c478bd9Sstevel@tonic-gate * 410*7c478bd9Sstevel@tonic-gate * uses cb_XXname as name of static cb_ops structure. 411*7c478bd9Sstevel@tonic-gate */ 412*7c478bd9Sstevel@tonic-gate 413*7c478bd9Sstevel@tonic-gate /* 414*7c478bd9Sstevel@tonic-gate * This file is included by genassym.c now and I couldn't get it to take the 415*7c478bd9Sstevel@tonic-gate * next line if it was broken into two lines joined by a '\'. So, don't try 416*7c478bd9Sstevel@tonic-gate * to reformat it to satisfy Cstyle because genassym.c won't compile. 417*7c478bd9Sstevel@tonic-gate */ 418*7c478bd9Sstevel@tonic-gate /* CSTYLED */ 419*7c478bd9Sstevel@tonic-gate #define DDI_DEFINE_STREAM_OPS(XXname, XXidentify, XXprobe, XXattach, XXdetach, XXreset, XXgetinfo, XXflag, XXstream_tab) \ 420*7c478bd9Sstevel@tonic-gate static struct cb_ops cb_##XXname = { \ 421*7c478bd9Sstevel@tonic-gate nulldev, /* cb_open */ \ 422*7c478bd9Sstevel@tonic-gate nulldev, /* cb_close */ \ 423*7c478bd9Sstevel@tonic-gate nodev, /* cb_strategy */ \ 424*7c478bd9Sstevel@tonic-gate nodev, /* cb_print */ \ 425*7c478bd9Sstevel@tonic-gate nodev, /* cb_dump */ \ 426*7c478bd9Sstevel@tonic-gate nodev, /* cb_read */ \ 427*7c478bd9Sstevel@tonic-gate nodev, /* cb_write */ \ 428*7c478bd9Sstevel@tonic-gate nodev, /* cb_ioctl */ \ 429*7c478bd9Sstevel@tonic-gate nodev, /* cb_devmap */ \ 430*7c478bd9Sstevel@tonic-gate nodev, /* cb_mmap */ \ 431*7c478bd9Sstevel@tonic-gate nodev, /* cb_segmap */ \ 432*7c478bd9Sstevel@tonic-gate nochpoll, /* cb_chpoll */ \ 433*7c478bd9Sstevel@tonic-gate ddi_prop_op, /* cb_prop_op */ \ 434*7c478bd9Sstevel@tonic-gate (XXstream_tab), /* cb_stream */ \ 435*7c478bd9Sstevel@tonic-gate (int)(XXflag), /* cb_flag */ \ 436*7c478bd9Sstevel@tonic-gate CB_REV, /* cb_rev */ \ 437*7c478bd9Sstevel@tonic-gate nodev, /* cb_aread */ \ 438*7c478bd9Sstevel@tonic-gate nodev, /* cb_awrite */ \ 439*7c478bd9Sstevel@tonic-gate }; \ 440*7c478bd9Sstevel@tonic-gate \ 441*7c478bd9Sstevel@tonic-gate static struct dev_ops XXname = { \ 442*7c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev */ \ 443*7c478bd9Sstevel@tonic-gate 0, /* devo_refcnt */ \ 444*7c478bd9Sstevel@tonic-gate (XXgetinfo), /* devo_getinfo */ \ 445*7c478bd9Sstevel@tonic-gate (XXidentify), /* devo_identify */ \ 446*7c478bd9Sstevel@tonic-gate (XXprobe), /* devo_probe */ \ 447*7c478bd9Sstevel@tonic-gate (XXattach), /* devo_attach */ \ 448*7c478bd9Sstevel@tonic-gate (XXdetach), /* devo_detach */ \ 449*7c478bd9Sstevel@tonic-gate (XXreset), /* devo_reset */ \ 450*7c478bd9Sstevel@tonic-gate &(cb_##XXname), /* devo_cb_ops */ \ 451*7c478bd9Sstevel@tonic-gate (struct bus_ops *)NULL, /* devo_bus_ops */ \ 452*7c478bd9Sstevel@tonic-gate NULL /* devo_power */ \ 453*7c478bd9Sstevel@tonic-gate } 454*7c478bd9Sstevel@tonic-gate 455*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 456*7c478bd9Sstevel@tonic-gate 457*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 458*7c478bd9Sstevel@tonic-gate } 459*7c478bd9Sstevel@tonic-gate #endif 460*7c478bd9Sstevel@tonic-gate 461*7c478bd9Sstevel@tonic-gate #endif /* _SYS_DEVOPS_H */ 462