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_SUNDDI_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_SUNDDI_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Sun Specific DDI definitions 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/devops.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/ddidevmap.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/ddi_implfuncs.h> 45*7c478bd9Sstevel@tonic-gate #include <sys/ddi_isa.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/model.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/devctl.h> 48*7c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) 49*7c478bd9Sstevel@tonic-gate #include <sys/dma_engine.h> 50*7c478bd9Sstevel@tonic-gate #endif 51*7c478bd9Sstevel@tonic-gate #include <sys/sunpm.h> 52*7c478bd9Sstevel@tonic-gate #include <sys/nvpair.h> 53*7c478bd9Sstevel@tonic-gate #include <sys/sysevent.h> 54*7c478bd9Sstevel@tonic-gate #include <sys/thread.h> 55*7c478bd9Sstevel@tonic-gate #include <sys/stream.h> 56*7c478bd9Sstevel@tonic-gate #if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL) 57*7c478bd9Sstevel@tonic-gate #include <asm/sunddi.h> 58*7c478bd9Sstevel@tonic-gate #endif 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 61*7c478bd9Sstevel@tonic-gate extern "C" { 62*7c478bd9Sstevel@tonic-gate #endif 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * Generic Sun DDI definitions. 66*7c478bd9Sstevel@tonic-gate */ 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate #define DDI_SUCCESS (0) /* successful return */ 69*7c478bd9Sstevel@tonic-gate #define DDI_FAILURE (-1) /* unsuccessful return */ 70*7c478bd9Sstevel@tonic-gate #define DDI_NOT_WELL_FORMED (-2) /* A dev_info node is not valid */ 71*7c478bd9Sstevel@tonic-gate #define DDI_EAGAIN (-3) /* not enough interrupt resources */ 72*7c478bd9Sstevel@tonic-gate #define DDI_EINVAL (-4) /* invalid request or arguments */ 73*7c478bd9Sstevel@tonic-gate #define DDI_ENOTSUP (-5) /* operation is not supported */ 74*7c478bd9Sstevel@tonic-gate #define DDI_EPENDING (-6) /* operation or an event is pending */ 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate /* 77*7c478bd9Sstevel@tonic-gate * General-purpose DDI error return value definitions 78*7c478bd9Sstevel@tonic-gate */ 79*7c478bd9Sstevel@tonic-gate #define DDI_ENOMEM 1 /* memory not available */ 80*7c478bd9Sstevel@tonic-gate #define DDI_EBUSY 2 /* busy */ 81*7c478bd9Sstevel@tonic-gate #define DDI_ETRANSPORT 3 /* transport down */ 82*7c478bd9Sstevel@tonic-gate #define DDI_ECONTEXT 4 /* context error */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate /* 86*7c478bd9Sstevel@tonic-gate * General DDI sleep/nosleep allocation flags 87*7c478bd9Sstevel@tonic-gate */ 88*7c478bd9Sstevel@tonic-gate #define DDI_SLEEP 0 89*7c478bd9Sstevel@tonic-gate #define DDI_NOSLEEP 1 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate /* 92*7c478bd9Sstevel@tonic-gate * The following special nodeid values are reserved for use when creating 93*7c478bd9Sstevel@tonic-gate * nodes ONLY. They specify the attributes of the DDI_NC_PSEUDO class node 94*7c478bd9Sstevel@tonic-gate * being created: 95*7c478bd9Sstevel@tonic-gate * 96*7c478bd9Sstevel@tonic-gate * o DEVI_PSEUDO_NODEID specifics a node without persistence. 97*7c478bd9Sstevel@tonic-gate * o DEVI_SID_NODEID specifies a node with persistence. 98*7c478bd9Sstevel@tonic-gate * 99*7c478bd9Sstevel@tonic-gate * A node with the 'persistent' attribute will not be automatically removed by 100*7c478bd9Sstevel@tonic-gate * the framework in the current implementation - driver.conf nodes are without 101*7c478bd9Sstevel@tonic-gate * persistence. 102*7c478bd9Sstevel@tonic-gate * 103*7c478bd9Sstevel@tonic-gate * The actual nodeid value may be assigned by the framework and may be 104*7c478bd9Sstevel@tonic-gate * different than these special values. Drivers may not make assumptions 105*7c478bd9Sstevel@tonic-gate * about the nodeid value that is actually assigned to the node. 106*7c478bd9Sstevel@tonic-gate */ 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #define DEVI_PSEUDO_NODEID ((int)-1) 109*7c478bd9Sstevel@tonic-gate #define DEVI_SID_NODEID ((int)-2) 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate #define DEVI_PSEUDO_NEXNAME "pseudo" 112*7c478bd9Sstevel@tonic-gate #define DEVI_ISA_NEXNAME "isa" 113*7c478bd9Sstevel@tonic-gate #define DEVI_EISA_NEXNAME "eisa" 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate /* 116*7c478bd9Sstevel@tonic-gate * ddi_create_minor_node flags 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate #define CLONE_DEV 1 /* device is a clone device */ 119*7c478bd9Sstevel@tonic-gate #define PRIVONLY_DEV 0x10 /* policy-based permissions only */ 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate /* 122*7c478bd9Sstevel@tonic-gate * Historical values used for the flag field in ddi_create_minor_node. 123*7c478bd9Sstevel@tonic-gate * Future use of flag bits should avoid these fields to keep binary 124*7c478bd9Sstevel@tonic-gate * compatibility 125*7c478bd9Sstevel@tonic-gate * #define GLOBAL_DEV 0x2 126*7c478bd9Sstevel@tonic-gate * #define NODEBOUND_DEV 0x4 127*7c478bd9Sstevel@tonic-gate * #define NODESPECIFIC_DEV 0x6 128*7c478bd9Sstevel@tonic-gate * #define ENUMERATED_DEV 0x8 129*7c478bd9Sstevel@tonic-gate */ 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate /* 132*7c478bd9Sstevel@tonic-gate * Device type defines which are used by the 'node_type' element of the 133*7c478bd9Sstevel@tonic-gate * ddi_minor_data structure 134*7c478bd9Sstevel@tonic-gate */ 135*7c478bd9Sstevel@tonic-gate #define DDI_NT_SERIAL "ddi_serial" /* Serial port */ 136*7c478bd9Sstevel@tonic-gate #define DDI_NT_SERIAL_MB "ddi_serial:mb" /* the 'built-in' serial */ 137*7c478bd9Sstevel@tonic-gate /* ports (the old ttya, b */ 138*7c478bd9Sstevel@tonic-gate /* (,c ,d)) */ 139*7c478bd9Sstevel@tonic-gate #define DDI_NT_SERIAL_DO "ddi_serial:dialout" /* dialout ports */ 140*7c478bd9Sstevel@tonic-gate #define DDI_NT_SERIAL_MB_DO "ddi_serial:dialout,mb" /* dialout for onboard */ 141*7c478bd9Sstevel@tonic-gate /* ports */ 142*7c478bd9Sstevel@tonic-gate #define DDI_NT_SERIAL_LOMCON "ddi_serial:lomcon" /* LOMlite2 console port */ 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate /* 145*7c478bd9Sstevel@tonic-gate * *_CHAN disk type devices have channel numbers or target numbers. 146*7c478bd9Sstevel@tonic-gate * (i.e. ipi and scsi devices) 147*7c478bd9Sstevel@tonic-gate */ 148*7c478bd9Sstevel@tonic-gate #define DDI_NT_BLOCK "ddi_block" /* hard disks */ 149*7c478bd9Sstevel@tonic-gate /* 150*7c478bd9Sstevel@tonic-gate * The next define is for block type devices that can possible exist on 151*7c478bd9Sstevel@tonic-gate * a sub-bus like the scsi bus or the ipi channel. The 'disks' program 152*7c478bd9Sstevel@tonic-gate * will pick up on this and create logical names like c0t0d0s0 instead of 153*7c478bd9Sstevel@tonic-gate * c0d0s0 154*7c478bd9Sstevel@tonic-gate */ 155*7c478bd9Sstevel@tonic-gate #define DDI_NT_BLOCK_CHAN "ddi_block:channel" 156*7c478bd9Sstevel@tonic-gate #define DDI_NT_BLOCK_WWN "ddi_block:wwn" 157*7c478bd9Sstevel@tonic-gate #define DDI_NT_CD "ddi_block:cdrom" /* rom drives (cd-rom) */ 158*7c478bd9Sstevel@tonic-gate #define DDI_NT_CD_CHAN "ddi_block:cdrom:channel" /* rom drives (scsi type) */ 159*7c478bd9Sstevel@tonic-gate #define DDI_NT_FD "ddi_block:diskette" /* floppy disks */ 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate #define DDI_NT_ENCLOSURE "ddi_enclosure" 162*7c478bd9Sstevel@tonic-gate #define DDI_NT_SCSI_ENCLOSURE "ddi_enclosure:scsi" 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate #define DDI_NT_TAPE "ddi_byte:tape" /* tape drives */ 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate #define DDI_NT_NET "ddi_network" /* DLPI network devices */ 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate #define DDI_NT_MAC "ddi_mac" /* MAC devices */ 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate #define DDI_NT_DISPLAY "ddi_display" /* display devices */ 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate #define DDI_PSEUDO "ddi_pseudo" /* general pseudo devices */ 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate #define DDI_NT_AUDIO "ddi_audio" /* audio device */ 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate #define DDI_NT_MOUSE "ddi_mouse" /* mouse device */ 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate #define DDI_NT_KEYBOARD "ddi_keyboard" /* keyboard device */ 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate #define DDI_NT_PARALLEL "ddi_parallel" /* parallel port */ 182*7c478bd9Sstevel@tonic-gate 183*7c478bd9Sstevel@tonic-gate #define DDI_NT_PRINTER "ddi_printer" /* printer device */ 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate #define DDI_NT_UGEN "ddi_generic:usb" /* USB generic drv */ 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate #define DDI_NT_NEXUS "ddi_ctl:devctl" /* nexus drivers */ 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate #define DDI_NT_SCSI_NEXUS "ddi_ctl:devctl:scsi" /* nexus drivers */ 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate #define DDI_NT_ATTACHMENT_POINT "ddi_ctl:attachment_point" /* attachment pt */ 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate #define DDI_NT_SCSI_ATTACHMENT_POINT "ddi_ctl:attachment_point:scsi" 194*7c478bd9Sstevel@tonic-gate /* scsi attachment pt */ 195*7c478bd9Sstevel@tonic-gate #define DDI_NT_PCI_ATTACHMENT_POINT "ddi_ctl:attachment_point:pci" 196*7c478bd9Sstevel@tonic-gate /* PCI attachment pt */ 197*7c478bd9Sstevel@tonic-gate #define DDI_NT_SBD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sbd" 198*7c478bd9Sstevel@tonic-gate /* generic bd attachment pt */ 199*7c478bd9Sstevel@tonic-gate #define DDI_NT_FC_ATTACHMENT_POINT "ddi_ctl:attachment_point:fc" 200*7c478bd9Sstevel@tonic-gate /* FC attachment pt */ 201*7c478bd9Sstevel@tonic-gate #define DDI_NT_USB_ATTACHMENT_POINT "ddi_ctl:attachment_point:usb" 202*7c478bd9Sstevel@tonic-gate /* USB devices */ 203*7c478bd9Sstevel@tonic-gate #define DDI_NT_BLOCK_FABRIC "ddi_block:fabric" 204*7c478bd9Sstevel@tonic-gate /* Fabric Devices */ 205*7c478bd9Sstevel@tonic-gate #define DDI_NT_IB_ATTACHMENT_POINT "ddi_ctl:attachment_point:ib" 206*7c478bd9Sstevel@tonic-gate /* IB devices */ 207*7c478bd9Sstevel@tonic-gate #define DDI_NT_SMARTCARD_READER "ddi_smartcard_reader" /* Smartcard reader */ 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate #define DDI_NT_AV_ASYNC "ddi_av:async" /* asynchronous AV device */ 210*7c478bd9Sstevel@tonic-gate #define DDI_NT_AV_ISOCH "ddi_av:isoch" /* isochronous AV device */ 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate /* Device types used for agpgart driver related devices */ 213*7c478bd9Sstevel@tonic-gate #define DDI_NT_AGP_PSEUDO "ddi_agp:pseudo" /* agpgart pseudo device */ 214*7c478bd9Sstevel@tonic-gate #define DDI_NT_AGP_MASTER "ddi_agp:master" /* agp master device */ 215*7c478bd9Sstevel@tonic-gate #define DDI_NT_AGP_TARGET "ddi_agp:target" /* agp target device */ 216*7c478bd9Sstevel@tonic-gate #define DDI_NT_AGP_CPUGART "ddi_agp:cpugart" /* amd64 on-cpu gart device */ 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate /* 219*7c478bd9Sstevel@tonic-gate * DDI event definitions 220*7c478bd9Sstevel@tonic-gate */ 221*7c478bd9Sstevel@tonic-gate #define EC_DEVFS "EC_devfs" /* Event class devfs */ 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate /* Class devfs subclasses */ 224*7c478bd9Sstevel@tonic-gate #define ESC_DEVFS_MINOR_CREATE "ESC_devfs_minor_create" 225*7c478bd9Sstevel@tonic-gate #define ESC_DEVFS_MINOR_REMOVE "ESC_devfs_minor_remove" 226*7c478bd9Sstevel@tonic-gate #define ESC_DEVFS_DEVI_ADD "ESC_devfs_devi_add" 227*7c478bd9Sstevel@tonic-gate #define ESC_DEVFS_DEVI_REMOVE "ESC_devfs_devi_remove" 228*7c478bd9Sstevel@tonic-gate #define ESC_DEVFS_INSTANCE_MOD "ESC_devfs_instance_mod" 229*7c478bd9Sstevel@tonic-gate #define ESC_DEVFS_BRANCH_ADD "ESC_devfs_branch_add" 230*7c478bd9Sstevel@tonic-gate #define ESC_DEVFS_BRANCH_REMOVE "ESC_devfs_branch_remove" 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate /* DDI/NDI event publisher */ 233*7c478bd9Sstevel@tonic-gate #define EP_DDI SUNW_KERN_PUB"ddi" 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate /* 236*7c478bd9Sstevel@tonic-gate * devfs event class attributes 237*7c478bd9Sstevel@tonic-gate * 238*7c478bd9Sstevel@tonic-gate * The following attributes are private to EC_DEVFS 239*7c478bd9Sstevel@tonic-gate * event data. 240*7c478bd9Sstevel@tonic-gate */ 241*7c478bd9Sstevel@tonic-gate #define DEVFS_DRIVER_NAME "di.driver" 242*7c478bd9Sstevel@tonic-gate #define DEVFS_INSTANCE "di.instance" 243*7c478bd9Sstevel@tonic-gate #define DEVFS_PATHNAME "di.path" 244*7c478bd9Sstevel@tonic-gate #define DEVFS_DEVI_CLASS "di.devi_class" 245*7c478bd9Sstevel@tonic-gate #define DEVFS_BRANCH_EVENT "di.branch_event" 246*7c478bd9Sstevel@tonic-gate #define DEVFS_MINOR_NAME "mi.name" 247*7c478bd9Sstevel@tonic-gate #define DEVFS_MINOR_NODETYPE "mi.nodetype" 248*7c478bd9Sstevel@tonic-gate #define DEVFS_MINOR_ISCLONE "mi.isclone" 249*7c478bd9Sstevel@tonic-gate #define DEVFS_MINOR_MAJNUM "mi.majorno" 250*7c478bd9Sstevel@tonic-gate #define DEVFS_MINOR_MINORNUM "mi.minorno" 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate /* 253*7c478bd9Sstevel@tonic-gate * Fault-related definitions 254*7c478bd9Sstevel@tonic-gate * 255*7c478bd9Sstevel@tonic-gate * The specific numeric values have been chosen to be ordered, but 256*7c478bd9Sstevel@tonic-gate * not consecutive, to allow for future interpolation if required. 257*7c478bd9Sstevel@tonic-gate */ 258*7c478bd9Sstevel@tonic-gate typedef enum { 259*7c478bd9Sstevel@tonic-gate DDI_SERVICE_LOST = -32, 260*7c478bd9Sstevel@tonic-gate DDI_SERVICE_DEGRADED = -16, 261*7c478bd9Sstevel@tonic-gate DDI_SERVICE_UNAFFECTED = 0, 262*7c478bd9Sstevel@tonic-gate DDI_SERVICE_RESTORED = 16 263*7c478bd9Sstevel@tonic-gate } ddi_fault_impact_t; 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate typedef enum { 266*7c478bd9Sstevel@tonic-gate DDI_DATAPATH_FAULT = -32, 267*7c478bd9Sstevel@tonic-gate DDI_DEVICE_FAULT = -16, 268*7c478bd9Sstevel@tonic-gate DDI_EXTERNAL_FAULT = 0 269*7c478bd9Sstevel@tonic-gate } ddi_fault_location_t; 270*7c478bd9Sstevel@tonic-gate 271*7c478bd9Sstevel@tonic-gate typedef enum { 272*7c478bd9Sstevel@tonic-gate DDI_DEVSTATE_OFFLINE = -32, 273*7c478bd9Sstevel@tonic-gate DDI_DEVSTATE_DOWN = -16, 274*7c478bd9Sstevel@tonic-gate DDI_DEVSTATE_QUIESCED = 0, 275*7c478bd9Sstevel@tonic-gate DDI_DEVSTATE_DEGRADED = 16, 276*7c478bd9Sstevel@tonic-gate DDI_DEVSTATE_UP = 32 277*7c478bd9Sstevel@tonic-gate } ddi_devstate_t; 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate /* 282*7c478bd9Sstevel@tonic-gate * Common property definitions 283*7c478bd9Sstevel@tonic-gate */ 284*7c478bd9Sstevel@tonic-gate #define DDI_FORCEATTACH "ddi-forceattach" 285*7c478bd9Sstevel@tonic-gate #define DDI_NO_AUTODETACH "ddi-no-autodetach" 286*7c478bd9Sstevel@tonic-gate 287*7c478bd9Sstevel@tonic-gate /* 288*7c478bd9Sstevel@tonic-gate * Values that the function supplied to the dev_info 289*7c478bd9Sstevel@tonic-gate * tree traversal functions defined below must return. 290*7c478bd9Sstevel@tonic-gate */ 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate /* 293*7c478bd9Sstevel@tonic-gate * Continue search, if appropriate. 294*7c478bd9Sstevel@tonic-gate */ 295*7c478bd9Sstevel@tonic-gate #define DDI_WALK_CONTINUE 0 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate /* 298*7c478bd9Sstevel@tonic-gate * Terminate current depth of traversal. That is, terminate 299*7c478bd9Sstevel@tonic-gate * the current traversal of children nodes, but continue 300*7c478bd9Sstevel@tonic-gate * traversing sibling nodes and their children (if any). 301*7c478bd9Sstevel@tonic-gate */ 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate #define DDI_WALK_PRUNECHILD -1 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate /* 306*7c478bd9Sstevel@tonic-gate * Terminate current width of traversal. That is, terminate 307*7c478bd9Sstevel@tonic-gate * the current traversal of sibling nodes, but continue with 308*7c478bd9Sstevel@tonic-gate * traversing children nodes and their siblings (if appropriate). 309*7c478bd9Sstevel@tonic-gate */ 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate #define DDI_WALK_PRUNESIB -2 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate /* 314*7c478bd9Sstevel@tonic-gate * Terminate the entire search. 315*7c478bd9Sstevel@tonic-gate */ 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate #define DDI_WALK_TERMINATE -3 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate /* 320*7c478bd9Sstevel@tonic-gate * Terminate the entire search because an error occurred in function 321*7c478bd9Sstevel@tonic-gate */ 322*7c478bd9Sstevel@tonic-gate #define DDI_WALK_ERROR -4 323*7c478bd9Sstevel@tonic-gate 324*7c478bd9Sstevel@tonic-gate /* 325*7c478bd9Sstevel@tonic-gate * Drivers that are prepared to support full driver layering 326*7c478bd9Sstevel@tonic-gate * should create and export a null-valued property of the following 327*7c478bd9Sstevel@tonic-gate * name. 328*7c478bd9Sstevel@tonic-gate * 329*7c478bd9Sstevel@tonic-gate * Such drivers should be prepared to be called with FKLYR in 330*7c478bd9Sstevel@tonic-gate * the 'flag' argument of their open(9E), close(9E) routines, and 331*7c478bd9Sstevel@tonic-gate * with FKIOCTL in the 'mode' argument of their ioctl(9E) routines. 332*7c478bd9Sstevel@tonic-gate * 333*7c478bd9Sstevel@tonic-gate * See ioctl(9E) and ddi_copyin(9F) for details. 334*7c478bd9Sstevel@tonic-gate */ 335*7c478bd9Sstevel@tonic-gate #define DDI_KERNEL_IOCTL "ddi-kernel-ioctl" 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate /* 338*7c478bd9Sstevel@tonic-gate * Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F). 339*7c478bd9Sstevel@tonic-gate */ 340*7c478bd9Sstevel@tonic-gate #define DDI_MODEL_MASK DATAMODEL_MASK /* Note: 0x0FF00000 */ 341*7c478bd9Sstevel@tonic-gate #define DDI_MODEL_ILP32 DATAMODEL_ILP32 342*7c478bd9Sstevel@tonic-gate #define DDI_MODEL_LP64 DATAMODEL_LP64 343*7c478bd9Sstevel@tonic-gate #define DDI_MODEL_NATIVE DATAMODEL_NATIVE 344*7c478bd9Sstevel@tonic-gate #define DDI_MODEL_NONE DATAMODEL_NONE 345*7c478bd9Sstevel@tonic-gate 346*7c478bd9Sstevel@tonic-gate /* 347*7c478bd9Sstevel@tonic-gate * Functions and data references which really should be in <sys/ddi.h> 348*7c478bd9Sstevel@tonic-gate */ 349*7c478bd9Sstevel@tonic-gate 350*7c478bd9Sstevel@tonic-gate extern int maxphys; 351*7c478bd9Sstevel@tonic-gate extern void minphys(struct buf *); 352*7c478bd9Sstevel@tonic-gate extern int physio(int (*)(struct buf *), struct buf *, dev_t, 353*7c478bd9Sstevel@tonic-gate int, void (*)(struct buf *), struct uio *); 354*7c478bd9Sstevel@tonic-gate extern void disksort(struct diskhd *, struct buf *); 355*7c478bd9Sstevel@tonic-gate 356*7c478bd9Sstevel@tonic-gate extern long strtol(const char *, char **, int); 357*7c478bd9Sstevel@tonic-gate extern unsigned long strtoul(const char *, char **, int); 358*7c478bd9Sstevel@tonic-gate extern size_t strlen(const char *) __PURE; 359*7c478bd9Sstevel@tonic-gate extern char *strcpy(char *, const char *); 360*7c478bd9Sstevel@tonic-gate extern char *strncpy(char *, const char *, size_t); 361*7c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for strchr() */ 362*7c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L 363*7c478bd9Sstevel@tonic-gate extern const char *strchr(const char *, int); 364*7c478bd9Sstevel@tonic-gate #ifndef _STRCHR_INLINE 365*7c478bd9Sstevel@tonic-gate #define _STRCHR_INLINE 366*7c478bd9Sstevel@tonic-gate extern "C++" { 367*7c478bd9Sstevel@tonic-gate inline char *strchr(char *__s, int __c) { 368*7c478bd9Sstevel@tonic-gate return (char *)strchr((const char *)__s, __c); 369*7c478bd9Sstevel@tonic-gate } 370*7c478bd9Sstevel@tonic-gate } 371*7c478bd9Sstevel@tonic-gate #endif /* _STRCHR_INLINE */ 372*7c478bd9Sstevel@tonic-gate #else 373*7c478bd9Sstevel@tonic-gate extern char *strchr(const char *, int); 374*7c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */ 375*7c478bd9Sstevel@tonic-gate extern int strcmp(const char *, const char *) __PURE; 376*7c478bd9Sstevel@tonic-gate extern int strncmp(const char *, const char *, size_t) __PURE; 377*7c478bd9Sstevel@tonic-gate extern char *strncat(char *, const char *, size_t); 378*7c478bd9Sstevel@tonic-gate extern size_t strlcat(char *, const char *, size_t); 379*7c478bd9Sstevel@tonic-gate extern size_t strlcpy(char *, const char *, size_t); 380*7c478bd9Sstevel@tonic-gate extern size_t strspn(const char *, const char *); 381*7c478bd9Sstevel@tonic-gate extern int bcmp(const void *, const void *, size_t) __PURE; 382*7c478bd9Sstevel@tonic-gate extern int stoi(char **); 383*7c478bd9Sstevel@tonic-gate extern void numtos(ulong_t, char *); 384*7c478bd9Sstevel@tonic-gate extern void bcopy(const void *, void *, size_t); 385*7c478bd9Sstevel@tonic-gate extern void bzero(void *, size_t); 386*7c478bd9Sstevel@tonic-gate 387*7c478bd9Sstevel@tonic-gate extern void *memcpy(void *, const void *, size_t); 388*7c478bd9Sstevel@tonic-gate extern void *memset(void *, int, size_t); 389*7c478bd9Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t); 390*7c478bd9Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t) __PURE; 391*7c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for memchr() */ 392*7c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L 393*7c478bd9Sstevel@tonic-gate extern const void *memchr(const void *, int, size_t); 394*7c478bd9Sstevel@tonic-gate #ifndef _MEMCHR_INLINE 395*7c478bd9Sstevel@tonic-gate #define _MEMCHR_INLINE 396*7c478bd9Sstevel@tonic-gate extern "C++" { 397*7c478bd9Sstevel@tonic-gate inline void *memchr(void * __s, int __c, size_t __n) { 398*7c478bd9Sstevel@tonic-gate return (void *)memchr((const void *)__s, __c, __n); 399*7c478bd9Sstevel@tonic-gate } 400*7c478bd9Sstevel@tonic-gate } 401*7c478bd9Sstevel@tonic-gate #endif /* _MEMCHR_INLINE */ 402*7c478bd9Sstevel@tonic-gate #else 403*7c478bd9Sstevel@tonic-gate extern void *memchr(const void *, int, size_t); 404*7c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */ 405*7c478bd9Sstevel@tonic-gate 406*7c478bd9Sstevel@tonic-gate extern int ddi_strtol(const char *, char **, int, long *); 407*7c478bd9Sstevel@tonic-gate extern int ddi_strtoul(const char *, char **, int, unsigned long *); 408*7c478bd9Sstevel@tonic-gate 409*7c478bd9Sstevel@tonic-gate /* 410*7c478bd9Sstevel@tonic-gate * ddi_map_regs 411*7c478bd9Sstevel@tonic-gate * 412*7c478bd9Sstevel@tonic-gate * Map in the register set given by rnumber. 413*7c478bd9Sstevel@tonic-gate * The register number determine which register 414*7c478bd9Sstevel@tonic-gate * set will be mapped if more than one exists. 415*7c478bd9Sstevel@tonic-gate * The parent driver gets the information 416*7c478bd9Sstevel@tonic-gate * from parent private data and sets up the 417*7c478bd9Sstevel@tonic-gate * appropriate mappings and returns the kernel 418*7c478bd9Sstevel@tonic-gate * virtual address of the register set in *kaddrp. 419*7c478bd9Sstevel@tonic-gate * The offset specifies an offset into the register 420*7c478bd9Sstevel@tonic-gate * space to start from and len indicates the size 421*7c478bd9Sstevel@tonic-gate * of the area to map. If len and offset are 0 then 422*7c478bd9Sstevel@tonic-gate * the entire space is mapped. It returns DDI_SUCCESS on 423*7c478bd9Sstevel@tonic-gate * success or DDI_FAILURE otherwise. 424*7c478bd9Sstevel@tonic-gate * 425*7c478bd9Sstevel@tonic-gate */ 426*7c478bd9Sstevel@tonic-gate int 427*7c478bd9Sstevel@tonic-gate ddi_map_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp, 428*7c478bd9Sstevel@tonic-gate off_t offset, off_t len); 429*7c478bd9Sstevel@tonic-gate 430*7c478bd9Sstevel@tonic-gate /* 431*7c478bd9Sstevel@tonic-gate * ddi_unmap_regs 432*7c478bd9Sstevel@tonic-gate * 433*7c478bd9Sstevel@tonic-gate * Undo mappings set up by ddi_map_regs. 434*7c478bd9Sstevel@tonic-gate * The register number determines which register 435*7c478bd9Sstevel@tonic-gate * set will be unmapped if more than one exists. 436*7c478bd9Sstevel@tonic-gate * This is provided for drivers preparing 437*7c478bd9Sstevel@tonic-gate * to detach themselves from the system to 438*7c478bd9Sstevel@tonic-gate * allow them to release allocated mappings. 439*7c478bd9Sstevel@tonic-gate * 440*7c478bd9Sstevel@tonic-gate * The kaddrp and len specify the area to be 441*7c478bd9Sstevel@tonic-gate * unmapped. *kaddrp was returned from ddi_map_regs 442*7c478bd9Sstevel@tonic-gate * and len should match what ddi_map_regs was called 443*7c478bd9Sstevel@tonic-gate * with. 444*7c478bd9Sstevel@tonic-gate */ 445*7c478bd9Sstevel@tonic-gate 446*7c478bd9Sstevel@tonic-gate void 447*7c478bd9Sstevel@tonic-gate ddi_unmap_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp, 448*7c478bd9Sstevel@tonic-gate off_t offset, off_t len); 449*7c478bd9Sstevel@tonic-gate 450*7c478bd9Sstevel@tonic-gate int 451*7c478bd9Sstevel@tonic-gate ddi_map(dev_info_t *dp, ddi_map_req_t *mp, off_t offset, off_t len, 452*7c478bd9Sstevel@tonic-gate caddr_t *addrp); 453*7c478bd9Sstevel@tonic-gate 454*7c478bd9Sstevel@tonic-gate int 455*7c478bd9Sstevel@tonic-gate ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp); 456*7c478bd9Sstevel@tonic-gate 457*7c478bd9Sstevel@tonic-gate /* 458*7c478bd9Sstevel@tonic-gate * ddi_rnumber_to_regspec: Not for use by leaf drivers. 459*7c478bd9Sstevel@tonic-gate */ 460*7c478bd9Sstevel@tonic-gate struct regspec * 461*7c478bd9Sstevel@tonic-gate ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber); 462*7c478bd9Sstevel@tonic-gate 463*7c478bd9Sstevel@tonic-gate int 464*7c478bd9Sstevel@tonic-gate ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset, 465*7c478bd9Sstevel@tonic-gate off_t len, caddr_t *vaddrp); 466*7c478bd9Sstevel@tonic-gate 467*7c478bd9Sstevel@tonic-gate int 468*7c478bd9Sstevel@tonic-gate nullbusmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset, 469*7c478bd9Sstevel@tonic-gate off_t len, caddr_t *vaddrp); 470*7c478bd9Sstevel@tonic-gate 471*7c478bd9Sstevel@tonic-gate #ifdef _LP64 472*7c478bd9Sstevel@tonic-gate 473*7c478bd9Sstevel@tonic-gate int ddi_peek8(dev_info_t *dip, int8_t *addr, int8_t *val_p); 474*7c478bd9Sstevel@tonic-gate int ddi_peek16(dev_info_t *dip, int16_t *addr, int16_t *val_p); 475*7c478bd9Sstevel@tonic-gate int ddi_peek32(dev_info_t *dip, int32_t *addr, int32_t *val_p); 476*7c478bd9Sstevel@tonic-gate int ddi_peek64(dev_info_t *dip, int64_t *addr, int64_t *val_p); 477*7c478bd9Sstevel@tonic-gate 478*7c478bd9Sstevel@tonic-gate int ddi_poke8(dev_info_t *dip, int8_t *addr, int8_t val); 479*7c478bd9Sstevel@tonic-gate int ddi_poke16(dev_info_t *dip, int16_t *addr, int16_t val); 480*7c478bd9Sstevel@tonic-gate int ddi_poke32(dev_info_t *dip, int32_t *addr, int32_t val); 481*7c478bd9Sstevel@tonic-gate int ddi_poke64(dev_info_t *dip, int64_t *addr, int64_t val); 482*7c478bd9Sstevel@tonic-gate 483*7c478bd9Sstevel@tonic-gate #else /* _ILP32 */ 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate int ddi_peekc(dev_info_t *dip, int8_t *addr, int8_t *val_p); 486*7c478bd9Sstevel@tonic-gate #define ddi_peek8 ddi_peekc 487*7c478bd9Sstevel@tonic-gate 488*7c478bd9Sstevel@tonic-gate int ddi_peeks(dev_info_t *dip, int16_t *addr, int16_t *val_p); 489*7c478bd9Sstevel@tonic-gate #define ddi_peek16 ddi_peeks 490*7c478bd9Sstevel@tonic-gate 491*7c478bd9Sstevel@tonic-gate int ddi_peekl(dev_info_t *dip, int32_t *addr, int32_t *val_p); 492*7c478bd9Sstevel@tonic-gate #define ddi_peek32 ddi_peekl 493*7c478bd9Sstevel@tonic-gate 494*7c478bd9Sstevel@tonic-gate int ddi_peekd(dev_info_t *dip, int64_t *addr, int64_t *val_p); 495*7c478bd9Sstevel@tonic-gate #define ddi_peek64 ddi_peekd 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate int ddi_pokec(dev_info_t *dip, int8_t *addr, int8_t val); 498*7c478bd9Sstevel@tonic-gate #define ddi_poke8 ddi_pokec 499*7c478bd9Sstevel@tonic-gate 500*7c478bd9Sstevel@tonic-gate int ddi_pokes(dev_info_t *dip, int16_t *addr, int16_t val); 501*7c478bd9Sstevel@tonic-gate #define ddi_poke16 ddi_pokes 502*7c478bd9Sstevel@tonic-gate 503*7c478bd9Sstevel@tonic-gate int ddi_pokel(dev_info_t *dip, int32_t *addr, int32_t val); 504*7c478bd9Sstevel@tonic-gate #define ddi_poke32 ddi_pokel 505*7c478bd9Sstevel@tonic-gate 506*7c478bd9Sstevel@tonic-gate int ddi_poked(dev_info_t *dip, int64_t *addr, int64_t val); 507*7c478bd9Sstevel@tonic-gate #define ddi_poke64 ddi_poked 508*7c478bd9Sstevel@tonic-gate 509*7c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 510*7c478bd9Sstevel@tonic-gate 511*7c478bd9Sstevel@tonic-gate /* 512*7c478bd9Sstevel@tonic-gate * Peek and poke to and from a uio structure in xfersize pieces, 513*7c478bd9Sstevel@tonic-gate * using the parent nexi. 514*7c478bd9Sstevel@tonic-gate */ 515*7c478bd9Sstevel@tonic-gate int ddi_peekpokeio(dev_info_t *devi, struct uio *uio, enum uio_rw rw, 516*7c478bd9Sstevel@tonic-gate caddr_t addr, size_t len, uint_t xfersize); 517*7c478bd9Sstevel@tonic-gate 518*7c478bd9Sstevel@tonic-gate /* 519*7c478bd9Sstevel@tonic-gate * Pagesize conversions using the parent nexi 520*7c478bd9Sstevel@tonic-gate */ 521*7c478bd9Sstevel@tonic-gate unsigned long ddi_btop(dev_info_t *dip, unsigned long bytes); 522*7c478bd9Sstevel@tonic-gate unsigned long ddi_btopr(dev_info_t *dip, unsigned long bytes); 523*7c478bd9Sstevel@tonic-gate unsigned long ddi_ptob(dev_info_t *dip, unsigned long pages); 524*7c478bd9Sstevel@tonic-gate 525*7c478bd9Sstevel@tonic-gate /* 526*7c478bd9Sstevel@tonic-gate * There are no more "block" interrupt functions, per se. 527*7c478bd9Sstevel@tonic-gate * All thread of control should be done with MP/MT lockings. 528*7c478bd9Sstevel@tonic-gate * 529*7c478bd9Sstevel@tonic-gate * However, there are certain times in which a driver needs 530*7c478bd9Sstevel@tonic-gate * absolutely a critical guaranteed non-preemptable time 531*7c478bd9Sstevel@tonic-gate * in which to execute a few instructions. 532*7c478bd9Sstevel@tonic-gate * 533*7c478bd9Sstevel@tonic-gate * The following pair of functions attempt to guarantee this, 534*7c478bd9Sstevel@tonic-gate * but they are dangerous to use. That is, use them with 535*7c478bd9Sstevel@tonic-gate * extreme care. They do not guarantee to stop other processors 536*7c478bd9Sstevel@tonic-gate * from executing, but they do guarantee that the caller 537*7c478bd9Sstevel@tonic-gate * of ddi_enter_critical will continue to run until the 538*7c478bd9Sstevel@tonic-gate * caller calls ddi_exit_critical. No intervening DDI functions 539*7c478bd9Sstevel@tonic-gate * may be called between an entry and an exit from a critical 540*7c478bd9Sstevel@tonic-gate * region. 541*7c478bd9Sstevel@tonic-gate * 542*7c478bd9Sstevel@tonic-gate * ddi_enter_critical returns an integer identifier which must 543*7c478bd9Sstevel@tonic-gate * be passed to ddi_exit_critical. 544*7c478bd9Sstevel@tonic-gate * 545*7c478bd9Sstevel@tonic-gate * Be very sparing in the use of these functions since it is 546*7c478bd9Sstevel@tonic-gate * likely that absolutely nothing else can occur in the system 547*7c478bd9Sstevel@tonic-gate * whilst in the critical region. 548*7c478bd9Sstevel@tonic-gate */ 549*7c478bd9Sstevel@tonic-gate 550*7c478bd9Sstevel@tonic-gate unsigned int 551*7c478bd9Sstevel@tonic-gate ddi_enter_critical(void); 552*7c478bd9Sstevel@tonic-gate 553*7c478bd9Sstevel@tonic-gate void 554*7c478bd9Sstevel@tonic-gate ddi_exit_critical(unsigned int); 555*7c478bd9Sstevel@tonic-gate 556*7c478bd9Sstevel@tonic-gate /* 557*7c478bd9Sstevel@tonic-gate * devmap functions 558*7c478bd9Sstevel@tonic-gate */ 559*7c478bd9Sstevel@tonic-gate int 560*7c478bd9Sstevel@tonic-gate devmap_setup(dev_t dev, offset_t off, ddi_as_handle_t as, caddr_t *addrp, 561*7c478bd9Sstevel@tonic-gate size_t len, uint_t prot, uint_t maxprot, uint_t flags, 562*7c478bd9Sstevel@tonic-gate struct cred *cred); 563*7c478bd9Sstevel@tonic-gate 564*7c478bd9Sstevel@tonic-gate int 565*7c478bd9Sstevel@tonic-gate ddi_devmap_segmap(dev_t dev, off_t off, ddi_as_handle_t as, caddr_t *addrp, 566*7c478bd9Sstevel@tonic-gate off_t len, uint_t prot, uint_t maxprot, uint_t flags, 567*7c478bd9Sstevel@tonic-gate struct cred *cred); 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate int 570*7c478bd9Sstevel@tonic-gate devmap_load(devmap_cookie_t dhp, offset_t offset, size_t len, uint_t type, 571*7c478bd9Sstevel@tonic-gate uint_t rw); 572*7c478bd9Sstevel@tonic-gate 573*7c478bd9Sstevel@tonic-gate int 574*7c478bd9Sstevel@tonic-gate devmap_unload(devmap_cookie_t dhp, offset_t offset, size_t len); 575*7c478bd9Sstevel@tonic-gate 576*7c478bd9Sstevel@tonic-gate int 577*7c478bd9Sstevel@tonic-gate devmap_devmem_setup(devmap_cookie_t dhp, dev_info_t *dip, 578*7c478bd9Sstevel@tonic-gate struct devmap_callback_ctl *callback_ops, 579*7c478bd9Sstevel@tonic-gate uint_t rnumber, offset_t roff, size_t len, uint_t maxprot, 580*7c478bd9Sstevel@tonic-gate uint_t flags, ddi_device_acc_attr_t *accattrp); 581*7c478bd9Sstevel@tonic-gate 582*7c478bd9Sstevel@tonic-gate int 583*7c478bd9Sstevel@tonic-gate devmap_umem_setup(devmap_cookie_t dhp, dev_info_t *dip, 584*7c478bd9Sstevel@tonic-gate struct devmap_callback_ctl *callback_ops, 585*7c478bd9Sstevel@tonic-gate ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot, 586*7c478bd9Sstevel@tonic-gate uint_t flags, ddi_device_acc_attr_t *accattrp); 587*7c478bd9Sstevel@tonic-gate 588*7c478bd9Sstevel@tonic-gate int 589*7c478bd9Sstevel@tonic-gate devmap_devmem_remap(devmap_cookie_t dhp, dev_info_t *dip, 590*7c478bd9Sstevel@tonic-gate uint_t rnumber, offset_t roff, size_t len, uint_t maxprot, 591*7c478bd9Sstevel@tonic-gate uint_t flags, ddi_device_acc_attr_t *accattrp); 592*7c478bd9Sstevel@tonic-gate 593*7c478bd9Sstevel@tonic-gate int 594*7c478bd9Sstevel@tonic-gate devmap_umem_remap(devmap_cookie_t dhp, dev_info_t *dip, 595*7c478bd9Sstevel@tonic-gate ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot, 596*7c478bd9Sstevel@tonic-gate uint_t flags, ddi_device_acc_attr_t *accattrp); 597*7c478bd9Sstevel@tonic-gate 598*7c478bd9Sstevel@tonic-gate void 599*7c478bd9Sstevel@tonic-gate devmap_set_ctx_timeout(devmap_cookie_t dhp, clock_t ticks); 600*7c478bd9Sstevel@tonic-gate 601*7c478bd9Sstevel@tonic-gate int 602*7c478bd9Sstevel@tonic-gate devmap_default_access(devmap_cookie_t dhp, void *pvtp, offset_t off, 603*7c478bd9Sstevel@tonic-gate size_t len, uint_t type, uint_t rw); 604*7c478bd9Sstevel@tonic-gate 605*7c478bd9Sstevel@tonic-gate int 606*7c478bd9Sstevel@tonic-gate devmap_do_ctxmgt(devmap_cookie_t dhp, void *pvtp, offset_t off, size_t len, 607*7c478bd9Sstevel@tonic-gate uint_t type, uint_t rw, int (*ctxmgt)(devmap_cookie_t, void *, offset_t, 608*7c478bd9Sstevel@tonic-gate size_t, uint_t, uint_t)); 609*7c478bd9Sstevel@tonic-gate 610*7c478bd9Sstevel@tonic-gate 611*7c478bd9Sstevel@tonic-gate void *ddi_umem_alloc(size_t size, int flag, ddi_umem_cookie_t *cookiep); 612*7c478bd9Sstevel@tonic-gate 613*7c478bd9Sstevel@tonic-gate void ddi_umem_free(ddi_umem_cookie_t cookie); 614*7c478bd9Sstevel@tonic-gate 615*7c478bd9Sstevel@tonic-gate /* 616*7c478bd9Sstevel@tonic-gate * Functions to lock user memory and do repeated I/O or do devmap_umem_setup 617*7c478bd9Sstevel@tonic-gate */ 618*7c478bd9Sstevel@tonic-gate int 619*7c478bd9Sstevel@tonic-gate ddi_umem_lock(caddr_t addr, size_t size, int flags, ddi_umem_cookie_t *cookie); 620*7c478bd9Sstevel@tonic-gate 621*7c478bd9Sstevel@tonic-gate void 622*7c478bd9Sstevel@tonic-gate ddi_umem_unlock(ddi_umem_cookie_t cookie); 623*7c478bd9Sstevel@tonic-gate 624*7c478bd9Sstevel@tonic-gate struct buf * 625*7c478bd9Sstevel@tonic-gate ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction, 626*7c478bd9Sstevel@tonic-gate dev_t dev, daddr_t blkno, int (*iodone)(struct buf *), int sleepflag); 627*7c478bd9Sstevel@tonic-gate 628*7c478bd9Sstevel@tonic-gate /* 629*7c478bd9Sstevel@tonic-gate * Mapping functions 630*7c478bd9Sstevel@tonic-gate */ 631*7c478bd9Sstevel@tonic-gate int 632*7c478bd9Sstevel@tonic-gate ddi_segmap(dev_t dev, off_t offset, struct as *asp, caddr_t *addrp, off_t len, 633*7c478bd9Sstevel@tonic-gate uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp); 634*7c478bd9Sstevel@tonic-gate 635*7c478bd9Sstevel@tonic-gate int 636*7c478bd9Sstevel@tonic-gate ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, caddr_t *addrp, 637*7c478bd9Sstevel@tonic-gate off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cred, 638*7c478bd9Sstevel@tonic-gate ddi_device_acc_attr_t *accattrp, uint_t rnumber); 639*7c478bd9Sstevel@tonic-gate 640*7c478bd9Sstevel@tonic-gate int 641*7c478bd9Sstevel@tonic-gate ddi_map_fault(dev_info_t *dip, struct hat *hat, struct seg *seg, caddr_t addr, 642*7c478bd9Sstevel@tonic-gate struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock); 643*7c478bd9Sstevel@tonic-gate 644*7c478bd9Sstevel@tonic-gate int 645*7c478bd9Sstevel@tonic-gate ddi_device_mapping_check(dev_t dev, ddi_device_acc_attr_t *accattrp, 646*7c478bd9Sstevel@tonic-gate uint_t rnumber, uint_t *hat_flags); 647*7c478bd9Sstevel@tonic-gate 648*7c478bd9Sstevel@tonic-gate /* 649*7c478bd9Sstevel@tonic-gate * Property functions: See also, ddipropdefs.h. 650*7c478bd9Sstevel@tonic-gate * In general, the underlying driver MUST be held 651*7c478bd9Sstevel@tonic-gate * to call it's property functions. 652*7c478bd9Sstevel@tonic-gate */ 653*7c478bd9Sstevel@tonic-gate 654*7c478bd9Sstevel@tonic-gate /* 655*7c478bd9Sstevel@tonic-gate * Used to create, modify, and lookup integer properties 656*7c478bd9Sstevel@tonic-gate */ 657*7c478bd9Sstevel@tonic-gate int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags, 658*7c478bd9Sstevel@tonic-gate char *name, int defvalue); 659*7c478bd9Sstevel@tonic-gate int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags, 660*7c478bd9Sstevel@tonic-gate char *name, int64_t defvalue); 661*7c478bd9Sstevel@tonic-gate int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, uint_t flags, 662*7c478bd9Sstevel@tonic-gate char *name, int **data, uint_t *nelements); 663*7c478bd9Sstevel@tonic-gate int ddi_prop_lookup_int64_array(dev_t match_dev, dev_info_t *dip, uint_t flags, 664*7c478bd9Sstevel@tonic-gate char *name, int64_t **data, uint_t *nelements); 665*7c478bd9Sstevel@tonic-gate int ddi_prop_update_int(dev_t match_dev, dev_info_t *dip, 666*7c478bd9Sstevel@tonic-gate char *name, int data); 667*7c478bd9Sstevel@tonic-gate int ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip, 668*7c478bd9Sstevel@tonic-gate char *name, int64_t data); 669*7c478bd9Sstevel@tonic-gate int ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, 670*7c478bd9Sstevel@tonic-gate char *name, int *data, uint_t nelements); 671*7c478bd9Sstevel@tonic-gate int ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, 672*7c478bd9Sstevel@tonic-gate char *name, int64_t *data, uint_t nelements); 673*7c478bd9Sstevel@tonic-gate /* 674*7c478bd9Sstevel@tonic-gate * Used to create, modify, and lookup string properties 675*7c478bd9Sstevel@tonic-gate */ 676*7c478bd9Sstevel@tonic-gate int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, uint_t flags, 677*7c478bd9Sstevel@tonic-gate char *name, char **data); 678*7c478bd9Sstevel@tonic-gate int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, uint_t flags, 679*7c478bd9Sstevel@tonic-gate char *name, char ***data, uint_t *nelements); 680*7c478bd9Sstevel@tonic-gate int ddi_prop_update_string(dev_t match_dev, dev_info_t *dip, 681*7c478bd9Sstevel@tonic-gate char *name, char *data); 682*7c478bd9Sstevel@tonic-gate int ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip, 683*7c478bd9Sstevel@tonic-gate char *name, char **data, uint_t nelements); 684*7c478bd9Sstevel@tonic-gate 685*7c478bd9Sstevel@tonic-gate /* 686*7c478bd9Sstevel@tonic-gate * Used to create, modify, and lookup byte properties 687*7c478bd9Sstevel@tonic-gate */ 688*7c478bd9Sstevel@tonic-gate int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, uint_t flags, 689*7c478bd9Sstevel@tonic-gate char *name, uchar_t **data, uint_t *nelements); 690*7c478bd9Sstevel@tonic-gate int ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip, 691*7c478bd9Sstevel@tonic-gate char *name, uchar_t *data, uint_t nelements); 692*7c478bd9Sstevel@tonic-gate 693*7c478bd9Sstevel@tonic-gate /* 694*7c478bd9Sstevel@tonic-gate * Used to verify the existence of a property or to see if a boolean 695*7c478bd9Sstevel@tonic-gate * property exists. 696*7c478bd9Sstevel@tonic-gate */ 697*7c478bd9Sstevel@tonic-gate int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name); 698*7c478bd9Sstevel@tonic-gate 699*7c478bd9Sstevel@tonic-gate /* 700*7c478bd9Sstevel@tonic-gate * Used to free the data returned by the above property routines. 701*7c478bd9Sstevel@tonic-gate */ 702*7c478bd9Sstevel@tonic-gate void ddi_prop_free(void *data); 703*7c478bd9Sstevel@tonic-gate 704*7c478bd9Sstevel@tonic-gate /* 705*7c478bd9Sstevel@tonic-gate * nopropop: For internal use in `dummy' cb_prop_op functions only 706*7c478bd9Sstevel@tonic-gate */ 707*7c478bd9Sstevel@tonic-gate 708*7c478bd9Sstevel@tonic-gate int 709*7c478bd9Sstevel@tonic-gate nopropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, 710*7c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 711*7c478bd9Sstevel@tonic-gate 712*7c478bd9Sstevel@tonic-gate /* 713*7c478bd9Sstevel@tonic-gate * ddi_prop_op: The basic property operator for drivers. 714*7c478bd9Sstevel@tonic-gate * 715*7c478bd9Sstevel@tonic-gate * In ddi_prop_op, the type of valuep is interpreted based on prop_op: 716*7c478bd9Sstevel@tonic-gate * 717*7c478bd9Sstevel@tonic-gate * prop_op valuep 718*7c478bd9Sstevel@tonic-gate * ------ ------ 719*7c478bd9Sstevel@tonic-gate * 720*7c478bd9Sstevel@tonic-gate * PROP_LEN <unused> 721*7c478bd9Sstevel@tonic-gate * 722*7c478bd9Sstevel@tonic-gate * PROP_LEN_AND_VAL_BUF Pointer to callers buffer 723*7c478bd9Sstevel@tonic-gate * 724*7c478bd9Sstevel@tonic-gate * PROP_LEN_AND_VAL_ALLOC Address of callers pointer (will be set to 725*7c478bd9Sstevel@tonic-gate * address of allocated buffer, if successful) 726*7c478bd9Sstevel@tonic-gate */ 727*7c478bd9Sstevel@tonic-gate 728*7c478bd9Sstevel@tonic-gate int 729*7c478bd9Sstevel@tonic-gate ddi_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, 730*7c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 731*7c478bd9Sstevel@tonic-gate 732*7c478bd9Sstevel@tonic-gate /* ddi_prop_op_size: for drivers that implement size in bytes */ 733*7c478bd9Sstevel@tonic-gate int 734*7c478bd9Sstevel@tonic-gate ddi_prop_op_size(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, 735*7c478bd9Sstevel@tonic-gate int mod_flags, char *name, caddr_t valuep, int *lengthp, 736*7c478bd9Sstevel@tonic-gate uint64_t size64); 737*7c478bd9Sstevel@tonic-gate 738*7c478bd9Sstevel@tonic-gate /* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */ 739*7c478bd9Sstevel@tonic-gate int 740*7c478bd9Sstevel@tonic-gate ddi_prop_op_nblocks(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, 741*7c478bd9Sstevel@tonic-gate int mod_flags, char *name, caddr_t valuep, int *lengthp, 742*7c478bd9Sstevel@tonic-gate uint64_t nblocks64); 743*7c478bd9Sstevel@tonic-gate 744*7c478bd9Sstevel@tonic-gate /* 745*7c478bd9Sstevel@tonic-gate * Variable length props... 746*7c478bd9Sstevel@tonic-gate */ 747*7c478bd9Sstevel@tonic-gate 748*7c478bd9Sstevel@tonic-gate /* 749*7c478bd9Sstevel@tonic-gate * ddi_getlongprop: Get variable length property len+val into a buffer 750*7c478bd9Sstevel@tonic-gate * allocated by property provider via kmem_alloc. Requester 751*7c478bd9Sstevel@tonic-gate * is responsible for freeing returned property via kmem_free. 752*7c478bd9Sstevel@tonic-gate * 753*7c478bd9Sstevel@tonic-gate * Arguments: 754*7c478bd9Sstevel@tonic-gate * 755*7c478bd9Sstevel@tonic-gate * dev: Input: dev_t of property. 756*7c478bd9Sstevel@tonic-gate * dip: Input: dev_info_t pointer of child. 757*7c478bd9Sstevel@tonic-gate * flags: Input: Possible flag modifiers are: 758*7c478bd9Sstevel@tonic-gate * DDI_PROP_DONTPASS: Don't pass to parent if prop not found. 759*7c478bd9Sstevel@tonic-gate * DDI_PROP_CANSLEEP: Memory allocation may sleep. 760*7c478bd9Sstevel@tonic-gate * name: Input: name of property. 761*7c478bd9Sstevel@tonic-gate * valuep: Output: Addr of callers buffer pointer. 762*7c478bd9Sstevel@tonic-gate * lengthp:Output: *lengthp will contain prop length on exit. 763*7c478bd9Sstevel@tonic-gate * 764*7c478bd9Sstevel@tonic-gate * Possible Returns: 765*7c478bd9Sstevel@tonic-gate * 766*7c478bd9Sstevel@tonic-gate * DDI_PROP_SUCCESS: Prop found and returned. 767*7c478bd9Sstevel@tonic-gate * DDI_PROP_NOT_FOUND: Prop not found 768*7c478bd9Sstevel@tonic-gate * DDI_PROP_UNDEFINED: Prop explicitly undefined. 769*7c478bd9Sstevel@tonic-gate * DDI_PROP_NO_MEMORY: Prop found, but unable to alloc mem. 770*7c478bd9Sstevel@tonic-gate */ 771*7c478bd9Sstevel@tonic-gate 772*7c478bd9Sstevel@tonic-gate int 773*7c478bd9Sstevel@tonic-gate ddi_getlongprop(dev_t dev, dev_info_t *dip, int flags, 774*7c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 775*7c478bd9Sstevel@tonic-gate 776*7c478bd9Sstevel@tonic-gate /* 777*7c478bd9Sstevel@tonic-gate * 778*7c478bd9Sstevel@tonic-gate * ddi_getlongprop_buf: Get long prop into pre-allocated callers 779*7c478bd9Sstevel@tonic-gate * buffer. (no memory allocation by provider). 780*7c478bd9Sstevel@tonic-gate * 781*7c478bd9Sstevel@tonic-gate * dev: Input: dev_t of property. 782*7c478bd9Sstevel@tonic-gate * dip: Input: dev_info_t pointer of child. 783*7c478bd9Sstevel@tonic-gate * flags: Input: DDI_PROP_DONTPASS or NULL 784*7c478bd9Sstevel@tonic-gate * name: Input: name of property 785*7c478bd9Sstevel@tonic-gate * valuep: Input: ptr to callers buffer. 786*7c478bd9Sstevel@tonic-gate * lengthp:I/O: ptr to length of callers buffer on entry, 787*7c478bd9Sstevel@tonic-gate * actual length of property on exit. 788*7c478bd9Sstevel@tonic-gate * 789*7c478bd9Sstevel@tonic-gate * Possible returns: 790*7c478bd9Sstevel@tonic-gate * 791*7c478bd9Sstevel@tonic-gate * DDI_PROP_SUCCESS Prop found and returned 792*7c478bd9Sstevel@tonic-gate * DDI_PROP_NOT_FOUND Prop not found 793*7c478bd9Sstevel@tonic-gate * DDI_PROP_UNDEFINED Prop explicitly undefined. 794*7c478bd9Sstevel@tonic-gate * DDI_PROP_BUF_TOO_SMALL Prop found, callers buf too small, 795*7c478bd9Sstevel@tonic-gate * no value returned, but actual prop 796*7c478bd9Sstevel@tonic-gate * length returned in *lengthp 797*7c478bd9Sstevel@tonic-gate * 798*7c478bd9Sstevel@tonic-gate */ 799*7c478bd9Sstevel@tonic-gate 800*7c478bd9Sstevel@tonic-gate int 801*7c478bd9Sstevel@tonic-gate ddi_getlongprop_buf(dev_t dev, dev_info_t *dip, int flags, 802*7c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 803*7c478bd9Sstevel@tonic-gate 804*7c478bd9Sstevel@tonic-gate /* 805*7c478bd9Sstevel@tonic-gate * Integer/boolean sized props. 806*7c478bd9Sstevel@tonic-gate * 807*7c478bd9Sstevel@tonic-gate * Call is value only... returns found boolean or int sized prop value or 808*7c478bd9Sstevel@tonic-gate * defvalue if prop not found or is wrong length or is explicitly undefined. 809*7c478bd9Sstevel@tonic-gate * Only flag is DDI_PROP_DONTPASS... 810*7c478bd9Sstevel@tonic-gate * 811*7c478bd9Sstevel@tonic-gate * By convention, this interface returns boolean (0) sized properties 812*7c478bd9Sstevel@tonic-gate * as value (int)1. 813*7c478bd9Sstevel@tonic-gate */ 814*7c478bd9Sstevel@tonic-gate 815*7c478bd9Sstevel@tonic-gate int 816*7c478bd9Sstevel@tonic-gate ddi_getprop(dev_t dev, dev_info_t *dip, int flags, char *name, int defvalue); 817*7c478bd9Sstevel@tonic-gate 818*7c478bd9Sstevel@tonic-gate /* 819*7c478bd9Sstevel@tonic-gate * Get prop length interface: flags are 0 or DDI_PROP_DONTPASS 820*7c478bd9Sstevel@tonic-gate * if returns DDI_PROP_SUCCESS, length returned in *lengthp. 821*7c478bd9Sstevel@tonic-gate */ 822*7c478bd9Sstevel@tonic-gate 823*7c478bd9Sstevel@tonic-gate int 824*7c478bd9Sstevel@tonic-gate ddi_getproplen(dev_t dev, dev_info_t *dip, int flags, char *name, int *lengthp); 825*7c478bd9Sstevel@tonic-gate 826*7c478bd9Sstevel@tonic-gate 827*7c478bd9Sstevel@tonic-gate /* 828*7c478bd9Sstevel@tonic-gate * Interface to create/modify a managed property on child's behalf... 829*7c478bd9Sstevel@tonic-gate * Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep 830*7c478bd9Sstevel@tonic-gate * if no memory available for internal prop structure. Long property 831*7c478bd9Sstevel@tonic-gate * (non integer sized) value references are not copied. 832*7c478bd9Sstevel@tonic-gate * 833*7c478bd9Sstevel@tonic-gate * Define property with DDI_DEV_T_NONE dev_t for properties not associated 834*7c478bd9Sstevel@tonic-gate * with any particular dev_t. Use the same dev_t when modifying or undefining 835*7c478bd9Sstevel@tonic-gate * a property. 836*7c478bd9Sstevel@tonic-gate * 837*7c478bd9Sstevel@tonic-gate * No guarantee on order of property search, so don't mix the same 838*7c478bd9Sstevel@tonic-gate * property name with wildcard and non-wildcard dev_t's. 839*7c478bd9Sstevel@tonic-gate */ 840*7c478bd9Sstevel@tonic-gate 841*7c478bd9Sstevel@tonic-gate /* 842*7c478bd9Sstevel@tonic-gate * ddi_prop_create: Define a managed property: 843*7c478bd9Sstevel@tonic-gate */ 844*7c478bd9Sstevel@tonic-gate 845*7c478bd9Sstevel@tonic-gate int 846*7c478bd9Sstevel@tonic-gate ddi_prop_create(dev_t dev, dev_info_t *dip, int flag, 847*7c478bd9Sstevel@tonic-gate char *name, caddr_t value, int length); 848*7c478bd9Sstevel@tonic-gate 849*7c478bd9Sstevel@tonic-gate /* 850*7c478bd9Sstevel@tonic-gate * ddi_prop_modify: Modify a managed property value 851*7c478bd9Sstevel@tonic-gate */ 852*7c478bd9Sstevel@tonic-gate 853*7c478bd9Sstevel@tonic-gate int 854*7c478bd9Sstevel@tonic-gate ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag, 855*7c478bd9Sstevel@tonic-gate char *name, caddr_t value, int length); 856*7c478bd9Sstevel@tonic-gate 857*7c478bd9Sstevel@tonic-gate /* 858*7c478bd9Sstevel@tonic-gate * ddi_prop_remove: Undefine a managed property: 859*7c478bd9Sstevel@tonic-gate */ 860*7c478bd9Sstevel@tonic-gate 861*7c478bd9Sstevel@tonic-gate int 862*7c478bd9Sstevel@tonic-gate ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name); 863*7c478bd9Sstevel@tonic-gate 864*7c478bd9Sstevel@tonic-gate /* 865*7c478bd9Sstevel@tonic-gate * ddi_prop_remove_all: Used before unloading a driver to remove 866*7c478bd9Sstevel@tonic-gate * all properties. (undefines all dev_t's props.) 867*7c478bd9Sstevel@tonic-gate * Also removes `undefined' prop defs. 868*7c478bd9Sstevel@tonic-gate */ 869*7c478bd9Sstevel@tonic-gate 870*7c478bd9Sstevel@tonic-gate void 871*7c478bd9Sstevel@tonic-gate ddi_prop_remove_all(dev_info_t *dip); 872*7c478bd9Sstevel@tonic-gate 873*7c478bd9Sstevel@tonic-gate 874*7c478bd9Sstevel@tonic-gate /* 875*7c478bd9Sstevel@tonic-gate * ddi_prop_undefine: Explicitly undefine a property. Property 876*7c478bd9Sstevel@tonic-gate * searches which match this property return 877*7c478bd9Sstevel@tonic-gate * the error code DDI_PROP_UNDEFINED. 878*7c478bd9Sstevel@tonic-gate * 879*7c478bd9Sstevel@tonic-gate * Use ddi_prop_remove to negate effect of 880*7c478bd9Sstevel@tonic-gate * ddi_prop_undefine 881*7c478bd9Sstevel@tonic-gate */ 882*7c478bd9Sstevel@tonic-gate 883*7c478bd9Sstevel@tonic-gate int 884*7c478bd9Sstevel@tonic-gate ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name); 885*7c478bd9Sstevel@tonic-gate 886*7c478bd9Sstevel@tonic-gate 887*7c478bd9Sstevel@tonic-gate /* 888*7c478bd9Sstevel@tonic-gate * The default ddi_bus_prop_op wrapper... 889*7c478bd9Sstevel@tonic-gate */ 890*7c478bd9Sstevel@tonic-gate 891*7c478bd9Sstevel@tonic-gate int 892*7c478bd9Sstevel@tonic-gate ddi_bus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip, 893*7c478bd9Sstevel@tonic-gate ddi_prop_op_t prop_op, int mod_flags, 894*7c478bd9Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 895*7c478bd9Sstevel@tonic-gate 896*7c478bd9Sstevel@tonic-gate 897*7c478bd9Sstevel@tonic-gate /* 898*7c478bd9Sstevel@tonic-gate * Routines to traverse the tree of dev_info nodes. 899*7c478bd9Sstevel@tonic-gate * The general idea of these functions is to provide 900*7c478bd9Sstevel@tonic-gate * various tree traversal utilities. For each node 901*7c478bd9Sstevel@tonic-gate * that the tree traversal function finds, a caller 902*7c478bd9Sstevel@tonic-gate * supplied function is called with arguments of 903*7c478bd9Sstevel@tonic-gate * the current node and a caller supplied argument. 904*7c478bd9Sstevel@tonic-gate * The caller supplied function should return one 905*7c478bd9Sstevel@tonic-gate * of the integer values defined below which will 906*7c478bd9Sstevel@tonic-gate * indicate to the tree traversal function whether 907*7c478bd9Sstevel@tonic-gate * the traversal should be continued, and if so, how, 908*7c478bd9Sstevel@tonic-gate * or whether the traversal should terminate. 909*7c478bd9Sstevel@tonic-gate */ 910*7c478bd9Sstevel@tonic-gate 911*7c478bd9Sstevel@tonic-gate /* 912*7c478bd9Sstevel@tonic-gate * This general-purpose routine traverses the tree of dev_info nodes, 913*7c478bd9Sstevel@tonic-gate * starting from the given node, and calls the given function for each 914*7c478bd9Sstevel@tonic-gate * node that it finds with the current node and the pointer arg (which 915*7c478bd9Sstevel@tonic-gate * can point to a structure of information that the function 916*7c478bd9Sstevel@tonic-gate * needs) as arguments. 917*7c478bd9Sstevel@tonic-gate * 918*7c478bd9Sstevel@tonic-gate * It does the walk a layer at a time, not depth-first. 919*7c478bd9Sstevel@tonic-gate * 920*7c478bd9Sstevel@tonic-gate * The given function must return one of the values defined above. 921*7c478bd9Sstevel@tonic-gate * 922*7c478bd9Sstevel@tonic-gate */ 923*7c478bd9Sstevel@tonic-gate 924*7c478bd9Sstevel@tonic-gate void 925*7c478bd9Sstevel@tonic-gate ddi_walk_devs(dev_info_t *, int (*)(dev_info_t *, void *), void *); 926*7c478bd9Sstevel@tonic-gate 927*7c478bd9Sstevel@tonic-gate /* 928*7c478bd9Sstevel@tonic-gate * Routines to get at elements of the dev_info structure 929*7c478bd9Sstevel@tonic-gate */ 930*7c478bd9Sstevel@tonic-gate 931*7c478bd9Sstevel@tonic-gate /* 932*7c478bd9Sstevel@tonic-gate * ddi_node_name gets the device's 'name' from the device node. 933*7c478bd9Sstevel@tonic-gate * 934*7c478bd9Sstevel@tonic-gate * ddi_binding_name gets the string the OS used to bind the node to a driver, 935*7c478bd9Sstevel@tonic-gate * in certain cases, the binding name may be different from the node name, 936*7c478bd9Sstevel@tonic-gate * if the node name does not name a specific device driver. 937*7c478bd9Sstevel@tonic-gate * 938*7c478bd9Sstevel@tonic-gate * ddi_get_name is a synonym for ddi_binding_name(). 939*7c478bd9Sstevel@tonic-gate */ 940*7c478bd9Sstevel@tonic-gate char * 941*7c478bd9Sstevel@tonic-gate ddi_get_name(dev_info_t *dip); 942*7c478bd9Sstevel@tonic-gate 943*7c478bd9Sstevel@tonic-gate char * 944*7c478bd9Sstevel@tonic-gate ddi_binding_name(dev_info_t *dip); 945*7c478bd9Sstevel@tonic-gate 946*7c478bd9Sstevel@tonic-gate const char * 947*7c478bd9Sstevel@tonic-gate ddi_driver_name(dev_info_t *dip); 948*7c478bd9Sstevel@tonic-gate 949*7c478bd9Sstevel@tonic-gate major_t 950*7c478bd9Sstevel@tonic-gate ddi_driver_major(dev_info_t *dip); 951*7c478bd9Sstevel@tonic-gate 952*7c478bd9Sstevel@tonic-gate major_t 953*7c478bd9Sstevel@tonic-gate ddi_compatible_driver_major(dev_info_t *dip, char **formp); 954*7c478bd9Sstevel@tonic-gate 955*7c478bd9Sstevel@tonic-gate char * 956*7c478bd9Sstevel@tonic-gate ddi_node_name(dev_info_t *dip); 957*7c478bd9Sstevel@tonic-gate 958*7c478bd9Sstevel@tonic-gate int 959*7c478bd9Sstevel@tonic-gate ddi_get_nodeid(dev_info_t *dip); 960*7c478bd9Sstevel@tonic-gate 961*7c478bd9Sstevel@tonic-gate int 962*7c478bd9Sstevel@tonic-gate ddi_get_instance(dev_info_t *dip); 963*7c478bd9Sstevel@tonic-gate 964*7c478bd9Sstevel@tonic-gate struct dev_ops * 965*7c478bd9Sstevel@tonic-gate ddi_get_driver(dev_info_t *dip); 966*7c478bd9Sstevel@tonic-gate 967*7c478bd9Sstevel@tonic-gate void 968*7c478bd9Sstevel@tonic-gate ddi_set_driver(dev_info_t *dip, struct dev_ops *devo); 969*7c478bd9Sstevel@tonic-gate 970*7c478bd9Sstevel@tonic-gate void 971*7c478bd9Sstevel@tonic-gate ddi_set_driver_private(dev_info_t *dip, void *data); 972*7c478bd9Sstevel@tonic-gate 973*7c478bd9Sstevel@tonic-gate void * 974*7c478bd9Sstevel@tonic-gate ddi_get_driver_private(dev_info_t *dip); 975*7c478bd9Sstevel@tonic-gate 976*7c478bd9Sstevel@tonic-gate /* 977*7c478bd9Sstevel@tonic-gate * ddi_dev_is_needed tells system that a device is about to use a 978*7c478bd9Sstevel@tonic-gate * component. Returns when component is ready. 979*7c478bd9Sstevel@tonic-gate */ 980*7c478bd9Sstevel@tonic-gate int 981*7c478bd9Sstevel@tonic-gate ddi_dev_is_needed(dev_info_t *dip, int cmpt, int level); 982*7c478bd9Sstevel@tonic-gate 983*7c478bd9Sstevel@tonic-gate /* 984*7c478bd9Sstevel@tonic-gate * check if DDI_SUSPEND may result in power being removed from a device. 985*7c478bd9Sstevel@tonic-gate */ 986*7c478bd9Sstevel@tonic-gate int 987*7c478bd9Sstevel@tonic-gate ddi_removing_power(dev_info_t *dip); 988*7c478bd9Sstevel@tonic-gate 989*7c478bd9Sstevel@tonic-gate /* 990*7c478bd9Sstevel@tonic-gate * (Obsolete) power entry point 991*7c478bd9Sstevel@tonic-gate */ 992*7c478bd9Sstevel@tonic-gate int 993*7c478bd9Sstevel@tonic-gate ddi_power(dev_info_t *dip, int cmpt, int level); 994*7c478bd9Sstevel@tonic-gate 995*7c478bd9Sstevel@tonic-gate /* 996*7c478bd9Sstevel@tonic-gate * ddi_get_parent requires that the branch of the tree with the 997*7c478bd9Sstevel@tonic-gate * node be held (ddi_hold_installed_driver) or that the devinfo tree 998*7c478bd9Sstevel@tonic-gate * lock be held 999*7c478bd9Sstevel@tonic-gate */ 1000*7c478bd9Sstevel@tonic-gate dev_info_t * 1001*7c478bd9Sstevel@tonic-gate ddi_get_parent(dev_info_t *dip); 1002*7c478bd9Sstevel@tonic-gate 1003*7c478bd9Sstevel@tonic-gate /* 1004*7c478bd9Sstevel@tonic-gate * ddi_get_child and ddi_get_next_sibling require that the devinfo 1005*7c478bd9Sstevel@tonic-gate * tree lock be held 1006*7c478bd9Sstevel@tonic-gate */ 1007*7c478bd9Sstevel@tonic-gate dev_info_t * 1008*7c478bd9Sstevel@tonic-gate ddi_get_child(dev_info_t *dip); 1009*7c478bd9Sstevel@tonic-gate 1010*7c478bd9Sstevel@tonic-gate dev_info_t * 1011*7c478bd9Sstevel@tonic-gate ddi_get_next_sibling(dev_info_t *dip); 1012*7c478bd9Sstevel@tonic-gate 1013*7c478bd9Sstevel@tonic-gate dev_info_t * 1014*7c478bd9Sstevel@tonic-gate ddi_get_next(dev_info_t *dip); 1015*7c478bd9Sstevel@tonic-gate 1016*7c478bd9Sstevel@tonic-gate void 1017*7c478bd9Sstevel@tonic-gate ddi_set_next(dev_info_t *dip, dev_info_t *nextdip); 1018*7c478bd9Sstevel@tonic-gate 1019*7c478bd9Sstevel@tonic-gate /* 1020*7c478bd9Sstevel@tonic-gate * dev_info manipulation functions 1021*7c478bd9Sstevel@tonic-gate */ 1022*7c478bd9Sstevel@tonic-gate 1023*7c478bd9Sstevel@tonic-gate /* 1024*7c478bd9Sstevel@tonic-gate * Add and remove child devices. These are part of the system framework. 1025*7c478bd9Sstevel@tonic-gate * 1026*7c478bd9Sstevel@tonic-gate * ddi_add_child creates a dev_info structure with the passed name, 1027*7c478bd9Sstevel@tonic-gate * nodeid and instance arguments and makes it a child of pdip. Devices 1028*7c478bd9Sstevel@tonic-gate * that are known directly by the hardware have real nodeids; devices 1029*7c478bd9Sstevel@tonic-gate * that are software constructs use the defined DEVI_PSEUDO_NODEID 1030*7c478bd9Sstevel@tonic-gate * for the node id. 1031*7c478bd9Sstevel@tonic-gate * 1032*7c478bd9Sstevel@tonic-gate * ddi_remove_node removes the node from the tree. This fails if this 1033*7c478bd9Sstevel@tonic-gate * child has children. Parent and driver private data should already 1034*7c478bd9Sstevel@tonic-gate * be released (freed) prior to calling this function. If flag is 1035*7c478bd9Sstevel@tonic-gate * non-zero, the child is removed from it's linked list of instances. 1036*7c478bd9Sstevel@tonic-gate */ 1037*7c478bd9Sstevel@tonic-gate dev_info_t * 1038*7c478bd9Sstevel@tonic-gate ddi_add_child(dev_info_t *pdip, char *name, uint_t nodeid, uint_t instance); 1039*7c478bd9Sstevel@tonic-gate 1040*7c478bd9Sstevel@tonic-gate int 1041*7c478bd9Sstevel@tonic-gate ddi_remove_child(dev_info_t *dip, int flag); 1042*7c478bd9Sstevel@tonic-gate 1043*7c478bd9Sstevel@tonic-gate /* 1044*7c478bd9Sstevel@tonic-gate * Given the major number for a driver, make sure that dev_info nodes 1045*7c478bd9Sstevel@tonic-gate * are created form the driver's hwconf file, the driver for the named 1046*7c478bd9Sstevel@tonic-gate * device is loaded and attached, as well as any drivers for parent devices. 1047*7c478bd9Sstevel@tonic-gate * Return a pointer to the driver's dev_ops struct with the dev_ops held. 1048*7c478bd9Sstevel@tonic-gate * Note - Callers must release the dev_ops with ddi_rele_driver. 1049*7c478bd9Sstevel@tonic-gate * 1050*7c478bd9Sstevel@tonic-gate * When a driver is held, the branch of the devinfo tree from any of the 1051*7c478bd9Sstevel@tonic-gate * drivers devinfos to the root node are automatically held. This only 1052*7c478bd9Sstevel@tonic-gate * applies to tree traversals up (and back down) the tree following the 1053*7c478bd9Sstevel@tonic-gate * parent pointers. 1054*7c478bd9Sstevel@tonic-gate * 1055*7c478bd9Sstevel@tonic-gate * Use of this interface is discouraged, it may be removed in a future release. 1056*7c478bd9Sstevel@tonic-gate */ 1057*7c478bd9Sstevel@tonic-gate struct dev_ops * 1058*7c478bd9Sstevel@tonic-gate ddi_hold_installed_driver(major_t major); 1059*7c478bd9Sstevel@tonic-gate 1060*7c478bd9Sstevel@tonic-gate void 1061*7c478bd9Sstevel@tonic-gate ddi_rele_driver(major_t major); 1062*7c478bd9Sstevel@tonic-gate 1063*7c478bd9Sstevel@tonic-gate /* 1064*7c478bd9Sstevel@tonic-gate * Attach and hold the specified instance of a driver. The flags argument 1065*7c478bd9Sstevel@tonic-gate * should be zero. 1066*7c478bd9Sstevel@tonic-gate */ 1067*7c478bd9Sstevel@tonic-gate dev_info_t * 1068*7c478bd9Sstevel@tonic-gate ddi_hold_devi_by_instance(major_t major, int instance, int flags); 1069*7c478bd9Sstevel@tonic-gate 1070*7c478bd9Sstevel@tonic-gate void 1071*7c478bd9Sstevel@tonic-gate ddi_release_devi(dev_info_t *); 1072*7c478bd9Sstevel@tonic-gate 1073*7c478bd9Sstevel@tonic-gate /* 1074*7c478bd9Sstevel@tonic-gate * Associate a streams queue with a devinfo node 1075*7c478bd9Sstevel@tonic-gate */ 1076*7c478bd9Sstevel@tonic-gate void 1077*7c478bd9Sstevel@tonic-gate ddi_assoc_queue_with_devi(queue_t *, dev_info_t *); 1078*7c478bd9Sstevel@tonic-gate 1079*7c478bd9Sstevel@tonic-gate /* 1080*7c478bd9Sstevel@tonic-gate * Given the identifier string passed, make sure that dev_info nodes 1081*7c478bd9Sstevel@tonic-gate * are created form the driver's hwconf file, the driver for the named 1082*7c478bd9Sstevel@tonic-gate * device is loaded and attached, as well as any drivers for parent devices. 1083*7c478bd9Sstevel@tonic-gate * 1084*7c478bd9Sstevel@tonic-gate * Note that the driver is not held and is subject to being removed the instant 1085*7c478bd9Sstevel@tonic-gate * this call completes. You probably really want ddi_hold_installed_driver. 1086*7c478bd9Sstevel@tonic-gate */ 1087*7c478bd9Sstevel@tonic-gate int 1088*7c478bd9Sstevel@tonic-gate ddi_install_driver(char *idstring); 1089*7c478bd9Sstevel@tonic-gate 1090*7c478bd9Sstevel@tonic-gate /* 1091*7c478bd9Sstevel@tonic-gate * Routines that return specific nodes 1092*7c478bd9Sstevel@tonic-gate */ 1093*7c478bd9Sstevel@tonic-gate 1094*7c478bd9Sstevel@tonic-gate dev_info_t * 1095*7c478bd9Sstevel@tonic-gate ddi_root_node(void); 1096*7c478bd9Sstevel@tonic-gate 1097*7c478bd9Sstevel@tonic-gate /* 1098*7c478bd9Sstevel@tonic-gate * Given a name and an instance number, find and return the 1099*7c478bd9Sstevel@tonic-gate * dev_info from the current state of the device tree. 1100*7c478bd9Sstevel@tonic-gate * 1101*7c478bd9Sstevel@tonic-gate * If instance number is -1, return the first named instance. 1102*7c478bd9Sstevel@tonic-gate * 1103*7c478bd9Sstevel@tonic-gate * If attached is 1, exclude all nodes that are < DS_ATTACHED 1104*7c478bd9Sstevel@tonic-gate * 1105*7c478bd9Sstevel@tonic-gate * Requires that the devinfo tree be locked. 1106*7c478bd9Sstevel@tonic-gate * If attached is 1, the driver must be held. 1107*7c478bd9Sstevel@tonic-gate */ 1108*7c478bd9Sstevel@tonic-gate dev_info_t * 1109*7c478bd9Sstevel@tonic-gate ddi_find_devinfo(char *name, int instance, int attached); 1110*7c478bd9Sstevel@tonic-gate 1111*7c478bd9Sstevel@tonic-gate /* 1112*7c478bd9Sstevel@tonic-gate * DMA Mapping Setup 1113*7c478bd9Sstevel@tonic-gate * 1114*7c478bd9Sstevel@tonic-gate * The basic interface function is ddi_dma_setup(). This function 1115*7c478bd9Sstevel@tonic-gate * is to designed to allow a DMA mapping to be established to a 1116*7c478bd9Sstevel@tonic-gate * memory object. This function returns DDI_DMA_MAPPED if the 1117*7c478bd9Sstevel@tonic-gate * request was successfully filled. If this occurs, then the 1118*7c478bd9Sstevel@tonic-gate * argument handlep is filled in. This value is the DMA handle 1119*7c478bd9Sstevel@tonic-gate * for the mapping, and is used in a variety of other functions. 1120*7c478bd9Sstevel@tonic-gate * The handle is an opaque handle on the mapping, and no further 1121*7c478bd9Sstevel@tonic-gate * information may be inferred from it by the caller. 1122*7c478bd9Sstevel@tonic-gate * 1123*7c478bd9Sstevel@tonic-gate * Specifics of arguments to ddi_dma_setup: 1124*7c478bd9Sstevel@tonic-gate * 1125*7c478bd9Sstevel@tonic-gate * dip - devinfo pointer, which identifies the base device that wishes 1126*7c478bd9Sstevel@tonic-gate * to establish a dma mapping. The device may either be a leaf device, 1127*7c478bd9Sstevel@tonic-gate * or a device which is both a leaf and a nexus (e.g., a device which 1128*7c478bd9Sstevel@tonic-gate * has a dma engine but no children devices). 1129*7c478bd9Sstevel@tonic-gate * 1130*7c478bd9Sstevel@tonic-gate * dmareqp - pointer to a dma request structure. This structure contains 1131*7c478bd9Sstevel@tonic-gate * all the info necessary to establish the mapping (see <sys/ddidmareq.h>). 1132*7c478bd9Sstevel@tonic-gate * This structure may be impermanent, as its information is copied and 1133*7c478bd9Sstevel@tonic-gate * saved, if necessary, by implementation specific functions. The caller 1134*7c478bd9Sstevel@tonic-gate * is responsible for filling in the dmar_flags, dmar_length, dmar_type, 1135*7c478bd9Sstevel@tonic-gate * dmar_addr_un, dmar_fp and dmar_arg fields. Any other elements of the 1136*7c478bd9Sstevel@tonic-gate * ddi_dma_req structure should neither be examined or modified by the 1137*7c478bd9Sstevel@tonic-gate * caller. 1138*7c478bd9Sstevel@tonic-gate * 1139*7c478bd9Sstevel@tonic-gate * handlep - this is a pointer to a ddi_dma_handle_t. It is the callers 1140*7c478bd9Sstevel@tonic-gate * responsibility to hang on to this handle, because it becomes the token 1141*7c478bd9Sstevel@tonic-gate * used in all other DDI dma functions. If the handle pointer is NULL, 1142*7c478bd9Sstevel@tonic-gate * then no mapping is made, and the call is being used by the caller 1143*7c478bd9Sstevel@tonic-gate * to simply determine whether such a mapping *could* be made. 1144*7c478bd9Sstevel@tonic-gate * 1145*7c478bd9Sstevel@tonic-gate * Discussion of DMA resource callback functions: 1146*7c478bd9Sstevel@tonic-gate * 1147*7c478bd9Sstevel@tonic-gate * If a request could not be filled, it was because either there were 1148*7c478bd9Sstevel@tonic-gate * not enough mapping resources available to satisfy the request, and the 1149*7c478bd9Sstevel@tonic-gate * dmar_fp field was not set to DDI_DMA_SLEEP, or the mapping could not 1150*7c478bd9Sstevel@tonic-gate * be established at all (DDI_DMA_NOMAPPING) due to a basic inability of 1151*7c478bd9Sstevel@tonic-gate * available hardware to map the object. Callers should be prepared to deal 1152*7c478bd9Sstevel@tonic-gate * with all possible returns. It is suggested that the appropriate system 1153*7c478bd9Sstevel@tonic-gate * error number for the DDI_DMA_NOMAPPING returns is EFAULT. 1154*7c478bd9Sstevel@tonic-gate * 1155*7c478bd9Sstevel@tonic-gate * If the caller does not care whether a DMA mapping can be set up now, 1156*7c478bd9Sstevel@tonic-gate * the caller should set the field dmar_fp to DDI_DMA_DONTWAIT. This 1157*7c478bd9Sstevel@tonic-gate * implies that the caller will appropriately deal with resource 1158*7c478bd9Sstevel@tonic-gate * exhaustion. 1159*7c478bd9Sstevel@tonic-gate * 1160*7c478bd9Sstevel@tonic-gate * If the caller either cannot or does not wish to sleep awaiting mapping 1161*7c478bd9Sstevel@tonic-gate * resources, the caller may specify, via the field dmar_fp, a function to 1162*7c478bd9Sstevel@tonic-gate * call with the argument specified in dmar_arg, when resources might have 1163*7c478bd9Sstevel@tonic-gate * become available. The callback function will be called from interrupt 1164*7c478bd9Sstevel@tonic-gate * context, but in such a fashion to guarantee that spl blocking (in systems 1165*7c478bd9Sstevel@tonic-gate * that use this method of data protection) by the caller will not be 1166*7c478bd9Sstevel@tonic-gate * bypassed. 1167*7c478bd9Sstevel@tonic-gate * 1168*7c478bd9Sstevel@tonic-gate * 1169*7c478bd9Sstevel@tonic-gate * When function specified via dmar_fp is called, it may attempt to try and get 1170*7c478bd9Sstevel@tonic-gate * the mapping again. If it succeeds in getting the mapping, or does not need 1171*7c478bd9Sstevel@tonic-gate * to get the mapping any more, it must return 1. If it tries to get the 1172*7c478bd9Sstevel@tonic-gate * mapping but fails to do so, and it wants to be called back later, it 1173*7c478bd9Sstevel@tonic-gate * must return 0. 1174*7c478bd9Sstevel@tonic-gate * 1175*7c478bd9Sstevel@tonic-gate * Failure to observe this protocol will have unpredictable results. 1176*7c478bd9Sstevel@tonic-gate * 1177*7c478bd9Sstevel@tonic-gate * The callback function must provide its own data structure integrity 1178*7c478bd9Sstevel@tonic-gate * when it is invoked. 1179*7c478bd9Sstevel@tonic-gate */ 1180*7c478bd9Sstevel@tonic-gate 1181*7c478bd9Sstevel@tonic-gate int 1182*7c478bd9Sstevel@tonic-gate ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp, 1183*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t *handlep); 1184*7c478bd9Sstevel@tonic-gate 1185*7c478bd9Sstevel@tonic-gate /* 1186*7c478bd9Sstevel@tonic-gate * The following three functions are convenience wrappers for ddi_dma_setup(). 1187*7c478bd9Sstevel@tonic-gate */ 1188*7c478bd9Sstevel@tonic-gate 1189*7c478bd9Sstevel@tonic-gate int 1190*7c478bd9Sstevel@tonic-gate ddi_dma_addr_setup(dev_info_t *dip, struct as *as, caddr_t addr, size_t len, 1191*7c478bd9Sstevel@tonic-gate uint_t flags, int (*waitfp)(), caddr_t arg, 1192*7c478bd9Sstevel@tonic-gate ddi_dma_lim_t *limits, ddi_dma_handle_t *handlep); 1193*7c478bd9Sstevel@tonic-gate 1194*7c478bd9Sstevel@tonic-gate int 1195*7c478bd9Sstevel@tonic-gate ddi_dma_buf_setup(dev_info_t *dip, struct buf *bp, uint_t flags, 1196*7c478bd9Sstevel@tonic-gate int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits, 1197*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t *handlep); 1198*7c478bd9Sstevel@tonic-gate 1199*7c478bd9Sstevel@tonic-gate /* 1200*7c478bd9Sstevel@tonic-gate * Kernel addressability of the DMA object 1201*7c478bd9Sstevel@tonic-gate * 1202*7c478bd9Sstevel@tonic-gate * It might often be very useful to be able to get an IU mapping 1203*7c478bd9Sstevel@tonic-gate * to the object which has DMA active to/from it. In fact, it might 1204*7c478bd9Sstevel@tonic-gate * even really be a requirement. 1205*7c478bd9Sstevel@tonic-gate * 1206*7c478bd9Sstevel@tonic-gate * The cacheability of the object with respect to I/O and I/U caches 1207*7c478bd9Sstevel@tonic-gate * is affected by this function as follows: 1208*7c478bd9Sstevel@tonic-gate * 1209*7c478bd9Sstevel@tonic-gate * If a kernel virtual mapping to the object owned by the handle 1210*7c478bd9Sstevel@tonic-gate * existed already, and is IU cacheable, then the extant mapping 1211*7c478bd9Sstevel@tonic-gate * is locked and returned in kaddrp. By inference, kaddrp will 1212*7c478bd9Sstevel@tonic-gate * be an IU cacheable reference. 1213*7c478bd9Sstevel@tonic-gate * 1214*7c478bd9Sstevel@tonic-gate * If a kernel virtual mapping to the object owned by the handle 1215*7c478bd9Sstevel@tonic-gate * existed already, and is not IU cacheable, then the extant mapping 1216*7c478bd9Sstevel@tonic-gate * is locked and returned in kaddrp. By inference, kaddrp will 1217*7c478bd9Sstevel@tonic-gate * *not* be an IU cacheable reference. 1218*7c478bd9Sstevel@tonic-gate * 1219*7c478bd9Sstevel@tonic-gate * If a kernel virtual mapping to the object owned by the handle 1220*7c478bd9Sstevel@tonic-gate * does not exist already, a mapping will be created that will 1221*7c478bd9Sstevel@tonic-gate * *not* be an IU cacheable reference. 1222*7c478bd9Sstevel@tonic-gate * 1223*7c478bd9Sstevel@tonic-gate * The IO cacheability of the object owned by the handle is ignored 1224*7c478bd9Sstevel@tonic-gate * and unaffected. 1225*7c478bd9Sstevel@tonic-gate * 1226*7c478bd9Sstevel@tonic-gate * This function returns the mapping values as describe above. 1227*7c478bd9Sstevel@tonic-gate * 1228*7c478bd9Sstevel@tonic-gate * When the DMA object owned by handle is freed (by ddi_dma_free()- see 1229*7c478bd9Sstevel@tonic-gate * below), any mappings created by ddi_dma_kvaddrp() cease to be valid. 1230*7c478bd9Sstevel@tonic-gate * This will be the convention that drivers must follow, as it will be 1231*7c478bd9Sstevel@tonic-gate * impossible to enforce this programmatically. 1232*7c478bd9Sstevel@tonic-gate */ 1233*7c478bd9Sstevel@tonic-gate 1234*7c478bd9Sstevel@tonic-gate int 1235*7c478bd9Sstevel@tonic-gate ddi_dma_kvaddrp(ddi_dma_handle_t, off_t, size_t, caddr_t *); 1236*7c478bd9Sstevel@tonic-gate 1237*7c478bd9Sstevel@tonic-gate 1238*7c478bd9Sstevel@tonic-gate /* 1239*7c478bd9Sstevel@tonic-gate * Device addressability of the DMA object 1240*7c478bd9Sstevel@tonic-gate * 1241*7c478bd9Sstevel@tonic-gate * The handle that identifies an object mapped for DMA is an opaque entity. 1242*7c478bd9Sstevel@tonic-gate * When a device driver wishes to load its dma engine with the appropriate 1243*7c478bd9Sstevel@tonic-gate * values for transferring data to the mapped object, it has to get the 1244*7c478bd9Sstevel@tonic-gate * value. Since the exact shape and form of this address is device specific, 1245*7c478bd9Sstevel@tonic-gate * the value returned is a 'cookie' that each device may then interpret 1246*7c478bd9Sstevel@tonic-gate * as it needs to. See <sys/dditypes.h> for the form of what the DMA cookie 1247*7c478bd9Sstevel@tonic-gate * looks like. 1248*7c478bd9Sstevel@tonic-gate * 1249*7c478bd9Sstevel@tonic-gate * Returns DDI_SUCCESS for successful cookie generation, 1250*7c478bd9Sstevel@tonic-gate * or DDI_FAILURE if it cannot generate the DMA cookie. 1251*7c478bd9Sstevel@tonic-gate */ 1252*7c478bd9Sstevel@tonic-gate 1253*7c478bd9Sstevel@tonic-gate int 1254*7c478bd9Sstevel@tonic-gate ddi_dma_htoc(ddi_dma_handle_t handle, off_t off, ddi_dma_cookie_t *cookiep); 1255*7c478bd9Sstevel@tonic-gate 1256*7c478bd9Sstevel@tonic-gate /* 1257*7c478bd9Sstevel@tonic-gate * Given a DMA cookie, return its offset within the object referred to 1258*7c478bd9Sstevel@tonic-gate * by the DMA handle. This is so at the end of a dma transfer, the device 1259*7c478bd9Sstevel@tonic-gate * may take its specific ending address and find out how far into the 1260*7c478bd9Sstevel@tonic-gate * memory object described by the handle the device got. 1261*7c478bd9Sstevel@tonic-gate */ 1262*7c478bd9Sstevel@tonic-gate 1263*7c478bd9Sstevel@tonic-gate int 1264*7c478bd9Sstevel@tonic-gate ddi_dma_coff(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep, off_t *offp); 1265*7c478bd9Sstevel@tonic-gate 1266*7c478bd9Sstevel@tonic-gate /* 1267*7c478bd9Sstevel@tonic-gate * DMA mapping manipulation 1268*7c478bd9Sstevel@tonic-gate * 1269*7c478bd9Sstevel@tonic-gate * It may be desirable or convenient for some devices to allow partial 1270*7c478bd9Sstevel@tonic-gate * mapping of an object for dma. This allows the mapping for DMA of 1271*7c478bd9Sstevel@tonic-gate * arbitrarily large objects since only a portion of the object may 1272*7c478bd9Sstevel@tonic-gate * be mapped for DMA at any point in time. 1273*7c478bd9Sstevel@tonic-gate * 1274*7c478bd9Sstevel@tonic-gate * In order to support this as well as other operations, the paradigm 1275*7c478bd9Sstevel@tonic-gate * of a 'mapping window' is defined here. The object to be mapped has 1276*7c478bd9Sstevel@tonic-gate * attributes of location and length. A window can be established upon 1277*7c478bd9Sstevel@tonic-gate * this object. The window has attributes of offset (from the base mapping 1278*7c478bd9Sstevel@tonic-gate * of the object) and length. It is assumed that length and offset are 1279*7c478bd9Sstevel@tonic-gate * positive with respect to the base of the mapped object. 1280*7c478bd9Sstevel@tonic-gate * 1281*7c478bd9Sstevel@tonic-gate * In order to get support for such a window, the flag DDI_DMA_PARTIAL 1282*7c478bd9Sstevel@tonic-gate * must be set in the request flags when the object is mapped for DMA. 1283*7c478bd9Sstevel@tonic-gate * Each implementation may elect whether or not to support such an 1284*7c478bd9Sstevel@tonic-gate * operation. Each implementation may also choose to ignore the request 1285*7c478bd9Sstevel@tonic-gate * for a PARTIAL mapping and either reject the mapping of the object 1286*7c478bd9Sstevel@tonic-gate * for being too big (DDI_DMA_TOOBIG) or may map the entire object. 1287*7c478bd9Sstevel@tonic-gate * The caller who asks the object to be mapped for DMA will know 1288*7c478bd9Sstevel@tonic-gate * whether a partial mapping has been made by receiving the qualified 1289*7c478bd9Sstevel@tonic-gate * return value of DDI_DMA_PARTIAL_MAP instead of DDI_DMA_MAPPED. 1290*7c478bd9Sstevel@tonic-gate * All dma window functions will return DDI_FAILURE if the object 1291*7c478bd9Sstevel@tonic-gate * is not mapped partially. 1292*7c478bd9Sstevel@tonic-gate * 1293*7c478bd9Sstevel@tonic-gate * All other DDI dma functions (except ddi_dma_Free) operate *only* on 1294*7c478bd9Sstevel@tonic-gate * the mapped portion of the object. That is, functions such as ddi_dma_sync, 1295*7c478bd9Sstevel@tonic-gate * ddi_dma_segtocookie, and so on, only operate on the currently mapped 1296*7c478bd9Sstevel@tonic-gate * window. 1297*7c478bd9Sstevel@tonic-gate */ 1298*7c478bd9Sstevel@tonic-gate 1299*7c478bd9Sstevel@tonic-gate #if defined(__sparc) 1300*7c478bd9Sstevel@tonic-gate 1301*7c478bd9Sstevel@tonic-gate /* 1302*7c478bd9Sstevel@tonic-gate * ddi_dma_movwin - Move window from current offset/length to new 1303*7c478bd9Sstevel@tonic-gate * offset/length. Returns DDI_SUCCESS if able to do so, else returns 1304*7c478bd9Sstevel@tonic-gate * DDI_FAILURE if unable to do so, or the new window would be out of bounds 1305*7c478bd9Sstevel@tonic-gate * or the object isn't set up for windows. If length is (off_t) -1, the 1306*7c478bd9Sstevel@tonic-gate * If the optional cp argument is specified, an implicit ddi_dma_htoc 1307*7c478bd9Sstevel@tonic-gate * is done to fill that in. The new offset and length will be returned 1308*7c478bd9Sstevel@tonic-gate * in the arguments *offp and *lenp (resp). 1309*7c478bd9Sstevel@tonic-gate * 1310*7c478bd9Sstevel@tonic-gate * In this implementation, only fixed width windows are used. It is 1311*7c478bd9Sstevel@tonic-gate * recommended that the windowsize should be retrieved via the function 1312*7c478bd9Sstevel@tonic-gate * ddi_dma_curwin (below) and that used to specify new offsets and lengths 1313*7c478bd9Sstevel@tonic-gate * since the window will be fixed at that size and will only move modulo 1314*7c478bd9Sstevel@tonic-gate * winsize. 1315*7c478bd9Sstevel@tonic-gate * 1316*7c478bd9Sstevel@tonic-gate * The caller must guarantee that their device's dma engine is quiescent 1317*7c478bd9Sstevel@tonic-gate * with respect to the current DMA window. 1318*7c478bd9Sstevel@tonic-gate * 1319*7c478bd9Sstevel@tonic-gate * The implementation will try to be rapid with respect to moving a window, 1320*7c478bd9Sstevel@tonic-gate * but since an appropriate ddi_dma_sync() is likely to be done, there 1321*7c478bd9Sstevel@tonic-gate * will be no guaranteed latency. In practice this should not be too 1322*7c478bd9Sstevel@tonic-gate * horrible, but don't depend upon any particular latency. 1323*7c478bd9Sstevel@tonic-gate */ 1324*7c478bd9Sstevel@tonic-gate 1325*7c478bd9Sstevel@tonic-gate int 1326*7c478bd9Sstevel@tonic-gate ddi_dma_movwin(ddi_dma_handle_t, off_t *offp, size_t *lenp, ddi_dma_cookie_t *); 1327*7c478bd9Sstevel@tonic-gate 1328*7c478bd9Sstevel@tonic-gate #endif 1329*7c478bd9Sstevel@tonic-gate 1330*7c478bd9Sstevel@tonic-gate /* 1331*7c478bd9Sstevel@tonic-gate * ddi_dma_curwin - report the current offset/length of the window. 1332*7c478bd9Sstevel@tonic-gate * 1333*7c478bd9Sstevel@tonic-gate * Returns DDI_SUCCESS if offset and length 1334*7c478bd9Sstevel@tonic-gate * successfully established, else DDI_FAILURE. 1335*7c478bd9Sstevel@tonic-gate */ 1336*7c478bd9Sstevel@tonic-gate 1337*7c478bd9Sstevel@tonic-gate int 1338*7c478bd9Sstevel@tonic-gate ddi_dma_curwin(ddi_dma_handle_t handle, off_t *offp, size_t *lenp); 1339*7c478bd9Sstevel@tonic-gate 1340*7c478bd9Sstevel@tonic-gate /* 1341*7c478bd9Sstevel@tonic-gate * Get next dma window 1342*7c478bd9Sstevel@tonic-gate * 1343*7c478bd9Sstevel@tonic-gate * ddi_dma_nextwin takes a handle and a window, and fills in a pointer to 1344*7c478bd9Sstevel@tonic-gate * the next window within the object. If win is "NULL", a pointer to the 1345*7c478bd9Sstevel@tonic-gate * first window within the object is filled in. 1346*7c478bd9Sstevel@tonic-gate * 1347*7c478bd9Sstevel@tonic-gate * Returns DDI_SUCCESS if successfully filled in the window pointer, 1348*7c478bd9Sstevel@tonic-gate * DDI_DMA_STALE if win does not refer to the currently active 1349*7c478bd9Sstevel@tonic-gate * window, 1350*7c478bd9Sstevel@tonic-gate * DDI_DMA_DONE else there is no next window. 1351*7c478bd9Sstevel@tonic-gate */ 1352*7c478bd9Sstevel@tonic-gate 1353*7c478bd9Sstevel@tonic-gate int 1354*7c478bd9Sstevel@tonic-gate ddi_dma_nextwin(ddi_dma_handle_t, ddi_dma_win_t, ddi_dma_win_t *); 1355*7c478bd9Sstevel@tonic-gate 1356*7c478bd9Sstevel@tonic-gate /* 1357*7c478bd9Sstevel@tonic-gate * Get next segment 1358*7c478bd9Sstevel@tonic-gate * 1359*7c478bd9Sstevel@tonic-gate * ddi_dma_nextseg takes a window and a segment and fills in a pointer to 1360*7c478bd9Sstevel@tonic-gate * the next segment within the window. If seg is "NULL", a pointer to the 1361*7c478bd9Sstevel@tonic-gate * first segment within the window is filled in. 1362*7c478bd9Sstevel@tonic-gate * 1363*7c478bd9Sstevel@tonic-gate * Returns DDI_SUCCESS if successfully filled in the segment pointer, 1364*7c478bd9Sstevel@tonic-gate * DDI_DMA_STALE if win does not refer to the currently active 1365*7c478bd9Sstevel@tonic-gate * window. 1366*7c478bd9Sstevel@tonic-gate * DDI_DMA_DONE else there is no next segment. 1367*7c478bd9Sstevel@tonic-gate */ 1368*7c478bd9Sstevel@tonic-gate 1369*7c478bd9Sstevel@tonic-gate int 1370*7c478bd9Sstevel@tonic-gate ddi_dma_nextseg(ddi_dma_win_t, ddi_dma_seg_t, ddi_dma_seg_t *); 1371*7c478bd9Sstevel@tonic-gate 1372*7c478bd9Sstevel@tonic-gate /* 1373*7c478bd9Sstevel@tonic-gate * Segment to cookie 1374*7c478bd9Sstevel@tonic-gate * 1375*7c478bd9Sstevel@tonic-gate * ddi_dma_segtocookie takes a segment and fills in the cookie pointed 1376*7c478bd9Sstevel@tonic-gate * to by cookiep with the appropriate address, length and bus type to be 1377*7c478bd9Sstevel@tonic-gate * used to program the DMA engine. ddi_dma_segtocookie also fills in the 1378*7c478bd9Sstevel@tonic-gate * range within the object (specified by <off, len>) this particular 1379*7c478bd9Sstevel@tonic-gate * segment is mapping. <off, len> are filled in to give some control 1380*7c478bd9Sstevel@tonic-gate * where in the object the current dma transfer is active. 1381*7c478bd9Sstevel@tonic-gate * 1382*7c478bd9Sstevel@tonic-gate * Returns DDI_SUCCESS if successfully filled in all values, 1383*7c478bd9Sstevel@tonic-gate * else DDI_FAILURE 1384*7c478bd9Sstevel@tonic-gate * 1385*7c478bd9Sstevel@tonic-gate * This function is documented as Obsolete and is replaced by 1386*7c478bd9Sstevel@tonic-gate * ddi_dma_nextcookie(9F) 1387*7c478bd9Sstevel@tonic-gate */ 1388*7c478bd9Sstevel@tonic-gate 1389*7c478bd9Sstevel@tonic-gate int 1390*7c478bd9Sstevel@tonic-gate ddi_dma_segtocookie(ddi_dma_seg_t, off_t *, off_t *, ddi_dma_cookie_t *); 1391*7c478bd9Sstevel@tonic-gate 1392*7c478bd9Sstevel@tonic-gate /* 1393*7c478bd9Sstevel@tonic-gate * Synchronization of I/O with respect to various 1394*7c478bd9Sstevel@tonic-gate * caches and system write buffers. 1395*7c478bd9Sstevel@tonic-gate * 1396*7c478bd9Sstevel@tonic-gate * Done at varying points during an I/O transfer (including at the 1397*7c478bd9Sstevel@tonic-gate * removal of an I/O mapping). 1398*7c478bd9Sstevel@tonic-gate * 1399*7c478bd9Sstevel@tonic-gate * Due to the support of systems with write buffers which may 1400*7c478bd9Sstevel@tonic-gate * not be able to be turned off, this function *must* used at 1401*7c478bd9Sstevel@tonic-gate * any point in which data consistency might be required. 1402*7c478bd9Sstevel@tonic-gate * 1403*7c478bd9Sstevel@tonic-gate * Generally this means that if a memory object has multiple mappings 1404*7c478bd9Sstevel@tonic-gate * (both for I/O, as described by the handle, and the IU, via, e.g. 1405*7c478bd9Sstevel@tonic-gate * a call to ddi_dma_kvaddrp), and one mapping may have been 1406*7c478bd9Sstevel@tonic-gate * used to modify the memory object, this function must be called 1407*7c478bd9Sstevel@tonic-gate * to ensure that the modification of the memory object is 1408*7c478bd9Sstevel@tonic-gate * complete, as well as possibly to inform other mappings of 1409*7c478bd9Sstevel@tonic-gate * the object that any cached references to the object are 1410*7c478bd9Sstevel@tonic-gate * now stale (and flush or invalidate these stale cache references 1411*7c478bd9Sstevel@tonic-gate * as necessary). 1412*7c478bd9Sstevel@tonic-gate * 1413*7c478bd9Sstevel@tonic-gate * The function ddi_dma_sync() provides the general interface with 1414*7c478bd9Sstevel@tonic-gate * respect to this capability. Generally, ddi_dma_free() (below) may 1415*7c478bd9Sstevel@tonic-gate * be used in preference to ddi_dma_sync() as ddi_dma_free() calls 1416*7c478bd9Sstevel@tonic-gate * ddi_dma_sync(). 1417*7c478bd9Sstevel@tonic-gate * 1418*7c478bd9Sstevel@tonic-gate * Returns 0 if all caches that exist and are specified by cache_flags 1419*7c478bd9Sstevel@tonic-gate * are successfully operated on, else -1. 1420*7c478bd9Sstevel@tonic-gate * 1421*7c478bd9Sstevel@tonic-gate * The argument offset specifies an offset into the mapping of the mapped 1422*7c478bd9Sstevel@tonic-gate * object in which to perform the synchronization. It will be silently 1423*7c478bd9Sstevel@tonic-gate * truncated to the granularity of underlying cache line sizes as 1424*7c478bd9Sstevel@tonic-gate * appropriate. 1425*7c478bd9Sstevel@tonic-gate * 1426*7c478bd9Sstevel@tonic-gate * The argument len specifies a length starting from offset in which to 1427*7c478bd9Sstevel@tonic-gate * perform the synchronization. A value of (uint_t) -1 means that the length 1428*7c478bd9Sstevel@tonic-gate * proceeds from offset to the end of the mapping. The length argument 1429*7c478bd9Sstevel@tonic-gate * will silently rounded up to the granularity of underlying cache line 1430*7c478bd9Sstevel@tonic-gate * sizes as appropriate. 1431*7c478bd9Sstevel@tonic-gate * 1432*7c478bd9Sstevel@tonic-gate * The argument flags specifies what to synchronize (the device's view of 1433*7c478bd9Sstevel@tonic-gate * the object or the cpu's view of the object). 1434*7c478bd9Sstevel@tonic-gate * 1435*7c478bd9Sstevel@tonic-gate * Inquiring minds want to know when ddi_dma_sync should be used: 1436*7c478bd9Sstevel@tonic-gate * 1437*7c478bd9Sstevel@tonic-gate * + When an object is mapped for dma, assume that an 1438*7c478bd9Sstevel@tonic-gate * implicit ddi_dma_sync() is done for you. 1439*7c478bd9Sstevel@tonic-gate * 1440*7c478bd9Sstevel@tonic-gate * + When an object is unmapped (ddi_dma_free()), assume 1441*7c478bd9Sstevel@tonic-gate * that an implicit ddi_dma_sync() is done for you. 1442*7c478bd9Sstevel@tonic-gate * 1443*7c478bd9Sstevel@tonic-gate * + At any time between the two times above that the 1444*7c478bd9Sstevel@tonic-gate * memory object may have been modified by either 1445*7c478bd9Sstevel@tonic-gate * the DMA device or a processor and you wish that 1446*7c478bd9Sstevel@tonic-gate * the change be noticed by the master that didn't 1447*7c478bd9Sstevel@tonic-gate * do the modifying. 1448*7c478bd9Sstevel@tonic-gate * 1449*7c478bd9Sstevel@tonic-gate * Clearly, only the third case above requires the use of ddi_dma_sync. 1450*7c478bd9Sstevel@tonic-gate * 1451*7c478bd9Sstevel@tonic-gate * Inquiring minds also want to know which flag to use: 1452*7c478bd9Sstevel@tonic-gate * 1453*7c478bd9Sstevel@tonic-gate * + If you *modify* with a cpu the object, you use 1454*7c478bd9Sstevel@tonic-gate * ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure 1455*7c478bd9Sstevel@tonic-gate * that the DMA device sees the changes you made). 1456*7c478bd9Sstevel@tonic-gate * 1457*7c478bd9Sstevel@tonic-gate * + If you are checking, with the processor, an area 1458*7c478bd9Sstevel@tonic-gate * of the object that the DMA device *may* have modified, 1459*7c478bd9Sstevel@tonic-gate * you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are 1460*7c478bd9Sstevel@tonic-gate * making sure that the processor(s) will see the changes 1461*7c478bd9Sstevel@tonic-gate * that the DMA device may have made). 1462*7c478bd9Sstevel@tonic-gate */ 1463*7c478bd9Sstevel@tonic-gate 1464*7c478bd9Sstevel@tonic-gate int 1465*7c478bd9Sstevel@tonic-gate ddi_dma_sync(ddi_dma_handle_t handle, off_t offset, size_t len, uint_t flags); 1466*7c478bd9Sstevel@tonic-gate 1467*7c478bd9Sstevel@tonic-gate /* 1468*7c478bd9Sstevel@tonic-gate * DMA mapping de-allocation 1469*7c478bd9Sstevel@tonic-gate * 1470*7c478bd9Sstevel@tonic-gate * When an I/O transfer completes, the resources required to map the 1471*7c478bd9Sstevel@tonic-gate * object for DMA should be completely released. As a side effect, 1472*7c478bd9Sstevel@tonic-gate * various cache synchronization might need to occur (see above). 1473*7c478bd9Sstevel@tonic-gate * 1474*7c478bd9Sstevel@tonic-gate * Returns DDI_SUCCESS if the all underlying caches are successfully 1475*7c478bd9Sstevel@tonic-gate * flushed, else DDI_FAILURE. 1476*7c478bd9Sstevel@tonic-gate * 1477*7c478bd9Sstevel@tonic-gate */ 1478*7c478bd9Sstevel@tonic-gate 1479*7c478bd9Sstevel@tonic-gate int 1480*7c478bd9Sstevel@tonic-gate ddi_dma_free(ddi_dma_handle_t handle); 1481*7c478bd9Sstevel@tonic-gate 1482*7c478bd9Sstevel@tonic-gate /* 1483*7c478bd9Sstevel@tonic-gate * Device constraint cognizant kernel memory allocation- consistent access. 1484*7c478bd9Sstevel@tonic-gate * 1485*7c478bd9Sstevel@tonic-gate * IOPB allocation and de-allocation 1486*7c478bd9Sstevel@tonic-gate * 1487*7c478bd9Sstevel@tonic-gate * An IOPB allocation allocates some primary memory such that both 1488*7c478bd9Sstevel@tonic-gate * the kernel and the specified DMA device might be able to access it in a 1489*7c478bd9Sstevel@tonic-gate * non-cacheable (otherwise known as byte-consistent or non-streaming mode) 1490*7c478bd9Sstevel@tonic-gate * fashion. The allocation will obey the beginning alignment and padding 1491*7c478bd9Sstevel@tonic-gate * constraints as specified in the initial limits argument and as subsequently 1492*7c478bd9Sstevel@tonic-gate * modified by intervening parents. The limits argument may be NULL, in 1493*7c478bd9Sstevel@tonic-gate * which case the system picks a reasonable beginning limits. 1494*7c478bd9Sstevel@tonic-gate * 1495*7c478bd9Sstevel@tonic-gate * A kernel virtual address to the allocated primary memory is returned, 1496*7c478bd9Sstevel@tonic-gate * but no DMA mapping to the object is established (drivers must use the 1497*7c478bd9Sstevel@tonic-gate * ddi_dma_map() routines for that). 1498*7c478bd9Sstevel@tonic-gate * 1499*7c478bd9Sstevel@tonic-gate * If no iopb space can be allocated, DDI_FAILURE is returned. 1500*7c478bd9Sstevel@tonic-gate */ 1501*7c478bd9Sstevel@tonic-gate 1502*7c478bd9Sstevel@tonic-gate int 1503*7c478bd9Sstevel@tonic-gate ddi_iopb_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length, 1504*7c478bd9Sstevel@tonic-gate caddr_t *iopbp); 1505*7c478bd9Sstevel@tonic-gate 1506*7c478bd9Sstevel@tonic-gate /* 1507*7c478bd9Sstevel@tonic-gate * Deallocate an IOPB kernel virtual mapping. 1508*7c478bd9Sstevel@tonic-gate */ 1509*7c478bd9Sstevel@tonic-gate 1510*7c478bd9Sstevel@tonic-gate void 1511*7c478bd9Sstevel@tonic-gate ddi_iopb_free(caddr_t iopb); 1512*7c478bd9Sstevel@tonic-gate 1513*7c478bd9Sstevel@tonic-gate /* 1514*7c478bd9Sstevel@tonic-gate * Device constraint cognizant kernel memory allocation- streaming access. 1515*7c478bd9Sstevel@tonic-gate * 1516*7c478bd9Sstevel@tonic-gate * Similar to ddi_iopb_alloc, but for primary memory that is intended 1517*7c478bd9Sstevel@tonic-gate * to be accessed in a streaming fashion. The allocation will obey the 1518*7c478bd9Sstevel@tonic-gate * beginning alignment and padding constraints as specified in the initial 1519*7c478bd9Sstevel@tonic-gate * limits argument and as subsequently modified by intervening parents. 1520*7c478bd9Sstevel@tonic-gate * The limits argument may be NULL, in which case the system picks a 1521*7c478bd9Sstevel@tonic-gate * reasonable beginning limits. 1522*7c478bd9Sstevel@tonic-gate * 1523*7c478bd9Sstevel@tonic-gate * A flags value of 0x1 indicates whether the caller can wait for 1524*7c478bd9Sstevel@tonic-gate * memory to become available. Other bits in the flags argument 1525*7c478bd9Sstevel@tonic-gate * are reserved for future use and must be zero. 1526*7c478bd9Sstevel@tonic-gate * 1527*7c478bd9Sstevel@tonic-gate * Upon return from a successful call, the new real length of 1528*7c478bd9Sstevel@tonic-gate * the allocation is returned (for use in mapping the memory 1529*7c478bd9Sstevel@tonic-gate * later). 1530*7c478bd9Sstevel@tonic-gate */ 1531*7c478bd9Sstevel@tonic-gate 1532*7c478bd9Sstevel@tonic-gate int 1533*7c478bd9Sstevel@tonic-gate ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length, 1534*7c478bd9Sstevel@tonic-gate uint_t flags, caddr_t *kaddrp, uint_t *real_length); 1535*7c478bd9Sstevel@tonic-gate 1536*7c478bd9Sstevel@tonic-gate /* 1537*7c478bd9Sstevel@tonic-gate * Free the memory allocated via ddi_mem_alloc(). 1538*7c478bd9Sstevel@tonic-gate * 1539*7c478bd9Sstevel@tonic-gate * Note that passing an address not allocated via ddi_mem_alloc() 1540*7c478bd9Sstevel@tonic-gate * will panic the system. 1541*7c478bd9Sstevel@tonic-gate */ 1542*7c478bd9Sstevel@tonic-gate 1543*7c478bd9Sstevel@tonic-gate void 1544*7c478bd9Sstevel@tonic-gate ddi_mem_free(caddr_t kaddr); 1545*7c478bd9Sstevel@tonic-gate 1546*7c478bd9Sstevel@tonic-gate /* 1547*7c478bd9Sstevel@tonic-gate * Dma alignment, minimum transfers sizes, and burst sizes allowed. 1548*7c478bd9Sstevel@tonic-gate * Some with tears, some without. 1549*7c478bd9Sstevel@tonic-gate */ 1550*7c478bd9Sstevel@tonic-gate 1551*7c478bd9Sstevel@tonic-gate /* 1552*7c478bd9Sstevel@tonic-gate * Return a copy of the DMA attributes for the given handle. 1553*7c478bd9Sstevel@tonic-gate */ 1554*7c478bd9Sstevel@tonic-gate 1555*7c478bd9Sstevel@tonic-gate int 1556*7c478bd9Sstevel@tonic-gate ddi_dma_get_attr(ddi_dma_handle_t handle, ddi_dma_attr_t *attrp); 1557*7c478bd9Sstevel@tonic-gate 1558*7c478bd9Sstevel@tonic-gate /* 1559*7c478bd9Sstevel@tonic-gate * Return the allowable DMA burst size for the object mapped by handle. 1560*7c478bd9Sstevel@tonic-gate * The burst sizes will returned in an integer that encodes power 1561*7c478bd9Sstevel@tonic-gate * of two burst sizes that are allowed in bit encoded format. For 1562*7c478bd9Sstevel@tonic-gate * example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts 1563*7c478bd9Sstevel@tonic-gate * would be encoded as 0x2f. A transfer that could be allowed as solely 1564*7c478bd9Sstevel@tonic-gate * a halfword (2 byte) transfers would be returned as 0x2. 1565*7c478bd9Sstevel@tonic-gate */ 1566*7c478bd9Sstevel@tonic-gate 1567*7c478bd9Sstevel@tonic-gate int 1568*7c478bd9Sstevel@tonic-gate ddi_dma_burstsizes(ddi_dma_handle_t handle); 1569*7c478bd9Sstevel@tonic-gate 1570*7c478bd9Sstevel@tonic-gate /* 1571*7c478bd9Sstevel@tonic-gate * Return the required beginning alignment for a transfer and 1572*7c478bd9Sstevel@tonic-gate * the minimum sized effect a transfer would have. The beginning 1573*7c478bd9Sstevel@tonic-gate * alignment will be some power of two. The minimum sized effect 1574*7c478bd9Sstevel@tonic-gate * indicates, for writes, how much of the mapped object will be 1575*7c478bd9Sstevel@tonic-gate * affected by the minimum access and for reads how much of the 1576*7c478bd9Sstevel@tonic-gate * mapped object will accessed. 1577*7c478bd9Sstevel@tonic-gate */ 1578*7c478bd9Sstevel@tonic-gate 1579*7c478bd9Sstevel@tonic-gate int 1580*7c478bd9Sstevel@tonic-gate ddi_dma_devalign(ddi_dma_handle_t handle, uint_t *alignment, uint_t *mineffect); 1581*7c478bd9Sstevel@tonic-gate 1582*7c478bd9Sstevel@tonic-gate /* 1583*7c478bd9Sstevel@tonic-gate * Like ddi_dma_devalign, but without having to map the object. 1584*7c478bd9Sstevel@tonic-gate * The object is assumed to be primary memory, and it is assumed 1585*7c478bd9Sstevel@tonic-gate * a minimum effective transfer is also the appropriate alignment 1586*7c478bd9Sstevel@tonic-gate * to be using. The streaming flag, if non-zero, indicates that the 1587*7c478bd9Sstevel@tonic-gate * returned value should be modified to account for streaming mode 1588*7c478bd9Sstevel@tonic-gate * accesses (e.g., with I/O caches enabled). The initial value 1589*7c478bd9Sstevel@tonic-gate * is passed by the requester if it has a dma engine that has 1590*7c478bd9Sstevel@tonic-gate * a minimum cycle constraint (or, for streaming mode, the most 1591*7c478bd9Sstevel@tonic-gate * efficient size). 1592*7c478bd9Sstevel@tonic-gate */ 1593*7c478bd9Sstevel@tonic-gate 1594*7c478bd9Sstevel@tonic-gate int 1595*7c478bd9Sstevel@tonic-gate ddi_iomin(dev_info_t *dip, int initial, int streaming); 1596*7c478bd9Sstevel@tonic-gate 1597*7c478bd9Sstevel@tonic-gate /* 1598*7c478bd9Sstevel@tonic-gate * Given two DMA limit structures, apply the limitations 1599*7c478bd9Sstevel@tonic-gate * of one to the other, following the rules of limits 1600*7c478bd9Sstevel@tonic-gate * and the wishes of the caller. 1601*7c478bd9Sstevel@tonic-gate * 1602*7c478bd9Sstevel@tonic-gate * The rules of dma limit structures are that you cannot 1603*7c478bd9Sstevel@tonic-gate * make things *less* restrictive as you apply one set 1604*7c478bd9Sstevel@tonic-gate * of limits to another. 1605*7c478bd9Sstevel@tonic-gate * 1606*7c478bd9Sstevel@tonic-gate */ 1607*7c478bd9Sstevel@tonic-gate 1608*7c478bd9Sstevel@tonic-gate void 1609*7c478bd9Sstevel@tonic-gate ddi_dmalim_merge(ddi_dma_lim_t *limit, ddi_dma_lim_t *modifier); 1610*7c478bd9Sstevel@tonic-gate 1611*7c478bd9Sstevel@tonic-gate /* 1612*7c478bd9Sstevel@tonic-gate * Merge DMA attributes 1613*7c478bd9Sstevel@tonic-gate */ 1614*7c478bd9Sstevel@tonic-gate 1615*7c478bd9Sstevel@tonic-gate void 1616*7c478bd9Sstevel@tonic-gate ddi_dma_attr_merge(ddi_dma_attr_t *attr, ddi_dma_attr_t *mod); 1617*7c478bd9Sstevel@tonic-gate 1618*7c478bd9Sstevel@tonic-gate /* 1619*7c478bd9Sstevel@tonic-gate * Allocate a DMA handle 1620*7c478bd9Sstevel@tonic-gate */ 1621*7c478bd9Sstevel@tonic-gate 1622*7c478bd9Sstevel@tonic-gate int 1623*7c478bd9Sstevel@tonic-gate ddi_dma_alloc_handle(dev_info_t *dip, ddi_dma_attr_t *attr, 1624*7c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, 1625*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t *handlep); 1626*7c478bd9Sstevel@tonic-gate 1627*7c478bd9Sstevel@tonic-gate /* 1628*7c478bd9Sstevel@tonic-gate * Free DMA handle 1629*7c478bd9Sstevel@tonic-gate */ 1630*7c478bd9Sstevel@tonic-gate 1631*7c478bd9Sstevel@tonic-gate void 1632*7c478bd9Sstevel@tonic-gate ddi_dma_free_handle(ddi_dma_handle_t *handlep); 1633*7c478bd9Sstevel@tonic-gate 1634*7c478bd9Sstevel@tonic-gate /* 1635*7c478bd9Sstevel@tonic-gate * Allocate memory for DMA transfers 1636*7c478bd9Sstevel@tonic-gate */ 1637*7c478bd9Sstevel@tonic-gate 1638*7c478bd9Sstevel@tonic-gate int 1639*7c478bd9Sstevel@tonic-gate ddi_dma_mem_alloc(ddi_dma_handle_t handle, size_t length, 1640*7c478bd9Sstevel@tonic-gate ddi_device_acc_attr_t *accattrp, uint_t xfermodes, 1641*7c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, caddr_t *kaddrp, 1642*7c478bd9Sstevel@tonic-gate size_t *real_length, ddi_acc_handle_t *handlep); 1643*7c478bd9Sstevel@tonic-gate 1644*7c478bd9Sstevel@tonic-gate /* 1645*7c478bd9Sstevel@tonic-gate * Free DMA memory 1646*7c478bd9Sstevel@tonic-gate */ 1647*7c478bd9Sstevel@tonic-gate 1648*7c478bd9Sstevel@tonic-gate void 1649*7c478bd9Sstevel@tonic-gate ddi_dma_mem_free(ddi_acc_handle_t *hp); 1650*7c478bd9Sstevel@tonic-gate 1651*7c478bd9Sstevel@tonic-gate /* 1652*7c478bd9Sstevel@tonic-gate * bind address to a DMA handle 1653*7c478bd9Sstevel@tonic-gate */ 1654*7c478bd9Sstevel@tonic-gate 1655*7c478bd9Sstevel@tonic-gate int 1656*7c478bd9Sstevel@tonic-gate ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as, 1657*7c478bd9Sstevel@tonic-gate caddr_t addr, size_t len, uint_t flags, 1658*7c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, 1659*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t *cookiep, uint_t *ccountp); 1660*7c478bd9Sstevel@tonic-gate 1661*7c478bd9Sstevel@tonic-gate /* 1662*7c478bd9Sstevel@tonic-gate * bind buffer to DMA handle 1663*7c478bd9Sstevel@tonic-gate */ 1664*7c478bd9Sstevel@tonic-gate 1665*7c478bd9Sstevel@tonic-gate int 1666*7c478bd9Sstevel@tonic-gate ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp, 1667*7c478bd9Sstevel@tonic-gate uint_t flags, int (*waitfp)(caddr_t), caddr_t arg, 1668*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t *cookiep, uint_t *ccountp); 1669*7c478bd9Sstevel@tonic-gate 1670*7c478bd9Sstevel@tonic-gate /* 1671*7c478bd9Sstevel@tonic-gate * unbind mapping object to handle 1672*7c478bd9Sstevel@tonic-gate */ 1673*7c478bd9Sstevel@tonic-gate 1674*7c478bd9Sstevel@tonic-gate int 1675*7c478bd9Sstevel@tonic-gate ddi_dma_unbind_handle(ddi_dma_handle_t handle); 1676*7c478bd9Sstevel@tonic-gate 1677*7c478bd9Sstevel@tonic-gate /* 1678*7c478bd9Sstevel@tonic-gate * get next DMA cookie 1679*7c478bd9Sstevel@tonic-gate */ 1680*7c478bd9Sstevel@tonic-gate 1681*7c478bd9Sstevel@tonic-gate void 1682*7c478bd9Sstevel@tonic-gate ddi_dma_nextcookie(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep); 1683*7c478bd9Sstevel@tonic-gate 1684*7c478bd9Sstevel@tonic-gate /* 1685*7c478bd9Sstevel@tonic-gate * get number of DMA windows 1686*7c478bd9Sstevel@tonic-gate */ 1687*7c478bd9Sstevel@tonic-gate 1688*7c478bd9Sstevel@tonic-gate int 1689*7c478bd9Sstevel@tonic-gate ddi_dma_numwin(ddi_dma_handle_t handle, uint_t *nwinp); 1690*7c478bd9Sstevel@tonic-gate 1691*7c478bd9Sstevel@tonic-gate /* 1692*7c478bd9Sstevel@tonic-gate * get specific DMA window 1693*7c478bd9Sstevel@tonic-gate */ 1694*7c478bd9Sstevel@tonic-gate 1695*7c478bd9Sstevel@tonic-gate int 1696*7c478bd9Sstevel@tonic-gate ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp, 1697*7c478bd9Sstevel@tonic-gate size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); 1698*7c478bd9Sstevel@tonic-gate 1699*7c478bd9Sstevel@tonic-gate /* 1700*7c478bd9Sstevel@tonic-gate * activate 64 bit SBus support 1701*7c478bd9Sstevel@tonic-gate */ 1702*7c478bd9Sstevel@tonic-gate 1703*7c478bd9Sstevel@tonic-gate int 1704*7c478bd9Sstevel@tonic-gate ddi_dma_set_sbus64(ddi_dma_handle_t handle, ulong_t burstsizes); 1705*7c478bd9Sstevel@tonic-gate 1706*7c478bd9Sstevel@tonic-gate /* 1707*7c478bd9Sstevel@tonic-gate * Miscellaneous functions 1708*7c478bd9Sstevel@tonic-gate */ 1709*7c478bd9Sstevel@tonic-gate 1710*7c478bd9Sstevel@tonic-gate /* 1711*7c478bd9Sstevel@tonic-gate * ddi_report_dev: Report a successful attach. 1712*7c478bd9Sstevel@tonic-gate */ 1713*7c478bd9Sstevel@tonic-gate 1714*7c478bd9Sstevel@tonic-gate void 1715*7c478bd9Sstevel@tonic-gate ddi_report_dev(dev_info_t *dev); 1716*7c478bd9Sstevel@tonic-gate 1717*7c478bd9Sstevel@tonic-gate /* 1718*7c478bd9Sstevel@tonic-gate * ddi_dev_regsize 1719*7c478bd9Sstevel@tonic-gate * 1720*7c478bd9Sstevel@tonic-gate * If the device has h/w register(s), report 1721*7c478bd9Sstevel@tonic-gate * the size, in bytes, of the specified one into *resultp. 1722*7c478bd9Sstevel@tonic-gate * 1723*7c478bd9Sstevel@tonic-gate * Returns DDI_FAILURE if there are not registers, 1724*7c478bd9Sstevel@tonic-gate * or the specified register doesn't exist. 1725*7c478bd9Sstevel@tonic-gate */ 1726*7c478bd9Sstevel@tonic-gate 1727*7c478bd9Sstevel@tonic-gate int 1728*7c478bd9Sstevel@tonic-gate ddi_dev_regsize(dev_info_t *dev, uint_t rnumber, off_t *resultp); 1729*7c478bd9Sstevel@tonic-gate 1730*7c478bd9Sstevel@tonic-gate /* 1731*7c478bd9Sstevel@tonic-gate * ddi_dev_nregs 1732*7c478bd9Sstevel@tonic-gate * 1733*7c478bd9Sstevel@tonic-gate * If the device has h/w register(s), report 1734*7c478bd9Sstevel@tonic-gate * how many of them that there are into resultp. 1735*7c478bd9Sstevel@tonic-gate * Return DDI_FAILURE if the device has no registers. 1736*7c478bd9Sstevel@tonic-gate */ 1737*7c478bd9Sstevel@tonic-gate 1738*7c478bd9Sstevel@tonic-gate int 1739*7c478bd9Sstevel@tonic-gate ddi_dev_nregs(dev_info_t *dev, int *resultp); 1740*7c478bd9Sstevel@tonic-gate 1741*7c478bd9Sstevel@tonic-gate /* 1742*7c478bd9Sstevel@tonic-gate * ddi_dev_is_sid 1743*7c478bd9Sstevel@tonic-gate * 1744*7c478bd9Sstevel@tonic-gate * If the device is self-identifying, i.e., 1745*7c478bd9Sstevel@tonic-gate * has already been probed by a smart PROM 1746*7c478bd9Sstevel@tonic-gate * (and thus registers are known to be valid) 1747*7c478bd9Sstevel@tonic-gate * return DDI_SUCCESS, else DDI_FAILURE. 1748*7c478bd9Sstevel@tonic-gate */ 1749*7c478bd9Sstevel@tonic-gate 1750*7c478bd9Sstevel@tonic-gate 1751*7c478bd9Sstevel@tonic-gate int 1752*7c478bd9Sstevel@tonic-gate ddi_dev_is_sid(dev_info_t *dev); 1753*7c478bd9Sstevel@tonic-gate 1754*7c478bd9Sstevel@tonic-gate /* 1755*7c478bd9Sstevel@tonic-gate * ddi_slaveonly 1756*7c478bd9Sstevel@tonic-gate * 1757*7c478bd9Sstevel@tonic-gate * If the device is on a bus that precludes 1758*7c478bd9Sstevel@tonic-gate * the device from being either a dma master or 1759*7c478bd9Sstevel@tonic-gate * a dma slave, return DDI_SUCCESS. 1760*7c478bd9Sstevel@tonic-gate */ 1761*7c478bd9Sstevel@tonic-gate 1762*7c478bd9Sstevel@tonic-gate int 1763*7c478bd9Sstevel@tonic-gate ddi_slaveonly(dev_info_t *); 1764*7c478bd9Sstevel@tonic-gate 1765*7c478bd9Sstevel@tonic-gate 1766*7c478bd9Sstevel@tonic-gate /* 1767*7c478bd9Sstevel@tonic-gate * ddi_dev_affinity 1768*7c478bd9Sstevel@tonic-gate * 1769*7c478bd9Sstevel@tonic-gate * Report, via DDI_SUCCESS, whether there exists 1770*7c478bd9Sstevel@tonic-gate * an 'affinity' between two dev_info_t's. An 1771*7c478bd9Sstevel@tonic-gate * affinity is defined to be either a parent-child, 1772*7c478bd9Sstevel@tonic-gate * or a sibling relationship such that the siblings 1773*7c478bd9Sstevel@tonic-gate * or in the same part of the bus they happen to be 1774*7c478bd9Sstevel@tonic-gate * on. 1775*7c478bd9Sstevel@tonic-gate */ 1776*7c478bd9Sstevel@tonic-gate 1777*7c478bd9Sstevel@tonic-gate int 1778*7c478bd9Sstevel@tonic-gate ddi_dev_affinity(dev_info_t *deva, dev_info_t *devb); 1779*7c478bd9Sstevel@tonic-gate 1780*7c478bd9Sstevel@tonic-gate 1781*7c478bd9Sstevel@tonic-gate /* 1782*7c478bd9Sstevel@tonic-gate * ddi_set_callback 1783*7c478bd9Sstevel@tonic-gate * 1784*7c478bd9Sstevel@tonic-gate * Set a function/arg pair into the callback list identified 1785*7c478bd9Sstevel@tonic-gate * by listid. *listid must always initially start out as zero. 1786*7c478bd9Sstevel@tonic-gate */ 1787*7c478bd9Sstevel@tonic-gate 1788*7c478bd9Sstevel@tonic-gate void 1789*7c478bd9Sstevel@tonic-gate ddi_set_callback(int (*funcp)(caddr_t), caddr_t arg, uintptr_t *listid); 1790*7c478bd9Sstevel@tonic-gate 1791*7c478bd9Sstevel@tonic-gate /* 1792*7c478bd9Sstevel@tonic-gate * ddi_run_callback 1793*7c478bd9Sstevel@tonic-gate * 1794*7c478bd9Sstevel@tonic-gate * Run the callback list identified by listid. 1795*7c478bd9Sstevel@tonic-gate */ 1796*7c478bd9Sstevel@tonic-gate 1797*7c478bd9Sstevel@tonic-gate void 1798*7c478bd9Sstevel@tonic-gate ddi_run_callback(uintptr_t *listid); 1799*7c478bd9Sstevel@tonic-gate 1800*7c478bd9Sstevel@tonic-gate /* 1801*7c478bd9Sstevel@tonic-gate * More miscellaneous 1802*7c478bd9Sstevel@tonic-gate */ 1803*7c478bd9Sstevel@tonic-gate 1804*7c478bd9Sstevel@tonic-gate int 1805*7c478bd9Sstevel@tonic-gate nochpoll(dev_t dev, short events, int anyyet, short *reventsp, 1806*7c478bd9Sstevel@tonic-gate struct pollhead **phpp); 1807*7c478bd9Sstevel@tonic-gate 1808*7c478bd9Sstevel@tonic-gate dev_info_t * 1809*7c478bd9Sstevel@tonic-gate nodevinfo(dev_t dev, int otyp); 1810*7c478bd9Sstevel@tonic-gate 1811*7c478bd9Sstevel@tonic-gate int 1812*7c478bd9Sstevel@tonic-gate ddi_no_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result); 1813*7c478bd9Sstevel@tonic-gate 1814*7c478bd9Sstevel@tonic-gate int 1815*7c478bd9Sstevel@tonic-gate ddi_getinfo_1to1(dev_info_t *dip, ddi_info_cmd_t infocmd, 1816*7c478bd9Sstevel@tonic-gate void *arg, void **result); 1817*7c478bd9Sstevel@tonic-gate 1818*7c478bd9Sstevel@tonic-gate int 1819*7c478bd9Sstevel@tonic-gate ddifail(dev_info_t *devi, ddi_attach_cmd_t cmd); 1820*7c478bd9Sstevel@tonic-gate 1821*7c478bd9Sstevel@tonic-gate int 1822*7c478bd9Sstevel@tonic-gate ddi_no_dma_map(dev_info_t *dip, dev_info_t *rdip, 1823*7c478bd9Sstevel@tonic-gate struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep); 1824*7c478bd9Sstevel@tonic-gate 1825*7c478bd9Sstevel@tonic-gate int 1826*7c478bd9Sstevel@tonic-gate ddi_no_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr, 1827*7c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep); 1828*7c478bd9Sstevel@tonic-gate 1829*7c478bd9Sstevel@tonic-gate int 1830*7c478bd9Sstevel@tonic-gate ddi_no_dma_freehdl(dev_info_t *dip, dev_info_t *rdip, 1831*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle); 1832*7c478bd9Sstevel@tonic-gate 1833*7c478bd9Sstevel@tonic-gate int 1834*7c478bd9Sstevel@tonic-gate ddi_no_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip, 1835*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, 1836*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t *cp, uint_t *ccountp); 1837*7c478bd9Sstevel@tonic-gate 1838*7c478bd9Sstevel@tonic-gate int 1839*7c478bd9Sstevel@tonic-gate ddi_no_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip, 1840*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle); 1841*7c478bd9Sstevel@tonic-gate 1842*7c478bd9Sstevel@tonic-gate int 1843*7c478bd9Sstevel@tonic-gate ddi_no_dma_flush(dev_info_t *dip, dev_info_t *rdip, 1844*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, off_t off, size_t len, 1845*7c478bd9Sstevel@tonic-gate uint_t cache_flags); 1846*7c478bd9Sstevel@tonic-gate 1847*7c478bd9Sstevel@tonic-gate int 1848*7c478bd9Sstevel@tonic-gate ddi_no_dma_win(dev_info_t *dip, dev_info_t *rdip, 1849*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, uint_t win, off_t *offp, 1850*7c478bd9Sstevel@tonic-gate size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); 1851*7c478bd9Sstevel@tonic-gate 1852*7c478bd9Sstevel@tonic-gate int 1853*7c478bd9Sstevel@tonic-gate ddi_no_dma_mctl(register dev_info_t *dip, dev_info_t *rdip, 1854*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, enum ddi_dma_ctlops request, 1855*7c478bd9Sstevel@tonic-gate off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags); 1856*7c478bd9Sstevel@tonic-gate 1857*7c478bd9Sstevel@tonic-gate void 1858*7c478bd9Sstevel@tonic-gate ddivoid(); 1859*7c478bd9Sstevel@tonic-gate 1860*7c478bd9Sstevel@tonic-gate cred_t * 1861*7c478bd9Sstevel@tonic-gate ddi_get_cred(void); 1862*7c478bd9Sstevel@tonic-gate 1863*7c478bd9Sstevel@tonic-gate clock_t 1864*7c478bd9Sstevel@tonic-gate ddi_get_lbolt(void); 1865*7c478bd9Sstevel@tonic-gate 1866*7c478bd9Sstevel@tonic-gate time_t 1867*7c478bd9Sstevel@tonic-gate ddi_get_time(void); 1868*7c478bd9Sstevel@tonic-gate 1869*7c478bd9Sstevel@tonic-gate pid_t 1870*7c478bd9Sstevel@tonic-gate ddi_get_pid(void); 1871*7c478bd9Sstevel@tonic-gate 1872*7c478bd9Sstevel@tonic-gate kt_did_t 1873*7c478bd9Sstevel@tonic-gate ddi_get_kt_did(void); 1874*7c478bd9Sstevel@tonic-gate 1875*7c478bd9Sstevel@tonic-gate boolean_t 1876*7c478bd9Sstevel@tonic-gate ddi_can_receive_sig(void); 1877*7c478bd9Sstevel@tonic-gate 1878*7c478bd9Sstevel@tonic-gate void 1879*7c478bd9Sstevel@tonic-gate swab(void *src, void *dst, size_t nbytes); 1880*7c478bd9Sstevel@tonic-gate 1881*7c478bd9Sstevel@tonic-gate int 1882*7c478bd9Sstevel@tonic-gate ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type, 1883*7c478bd9Sstevel@tonic-gate minor_t minor_num, char *node_type, int flag); 1884*7c478bd9Sstevel@tonic-gate 1885*7c478bd9Sstevel@tonic-gate int 1886*7c478bd9Sstevel@tonic-gate ddi_create_priv_minor_node(dev_info_t *dip, char *name, int spec_type, 1887*7c478bd9Sstevel@tonic-gate minor_t minor_num, char *node_type, int flag, 1888*7c478bd9Sstevel@tonic-gate const char *rdpriv, const char *wrpriv, mode_t priv_mode); 1889*7c478bd9Sstevel@tonic-gate 1890*7c478bd9Sstevel@tonic-gate void 1891*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dev_info_t *dip, char *name); 1892*7c478bd9Sstevel@tonic-gate 1893*7c478bd9Sstevel@tonic-gate int 1894*7c478bd9Sstevel@tonic-gate ddi_in_panic(void); 1895*7c478bd9Sstevel@tonic-gate 1896*7c478bd9Sstevel@tonic-gate int 1897*7c478bd9Sstevel@tonic-gate ddi_streams_driver(dev_info_t *dip); 1898*7c478bd9Sstevel@tonic-gate 1899*7c478bd9Sstevel@tonic-gate /* 1900*7c478bd9Sstevel@tonic-gate * DDI wrappers for ffs and fls 1901*7c478bd9Sstevel@tonic-gate */ 1902*7c478bd9Sstevel@tonic-gate int 1903*7c478bd9Sstevel@tonic-gate ddi_ffs(long mask); 1904*7c478bd9Sstevel@tonic-gate 1905*7c478bd9Sstevel@tonic-gate int 1906*7c478bd9Sstevel@tonic-gate ddi_fls(long mask); 1907*7c478bd9Sstevel@tonic-gate 1908*7c478bd9Sstevel@tonic-gate /* 1909*7c478bd9Sstevel@tonic-gate * The next five routines comprise generic storage management utilities 1910*7c478bd9Sstevel@tonic-gate * for driver soft state structures. 1911*7c478bd9Sstevel@tonic-gate */ 1912*7c478bd9Sstevel@tonic-gate 1913*7c478bd9Sstevel@tonic-gate /* 1914*7c478bd9Sstevel@tonic-gate * Allocate a set of pointers to 'n_items' objects of size 'size' 1915*7c478bd9Sstevel@tonic-gate * bytes. Each pointer is initialized to nil. 'n_items' is a hint i.e. 1916*7c478bd9Sstevel@tonic-gate * zero is allowed. 1917*7c478bd9Sstevel@tonic-gate */ 1918*7c478bd9Sstevel@tonic-gate int 1919*7c478bd9Sstevel@tonic-gate ddi_soft_state_init(void **state_p, size_t size, size_t n_items); 1920*7c478bd9Sstevel@tonic-gate 1921*7c478bd9Sstevel@tonic-gate /* 1922*7c478bd9Sstevel@tonic-gate * Allocate a state structure of size 'size' to be associated 1923*7c478bd9Sstevel@tonic-gate * with item 'item'. 1924*7c478bd9Sstevel@tonic-gate */ 1925*7c478bd9Sstevel@tonic-gate int 1926*7c478bd9Sstevel@tonic-gate ddi_soft_state_zalloc(void *state, int item); 1927*7c478bd9Sstevel@tonic-gate 1928*7c478bd9Sstevel@tonic-gate /* 1929*7c478bd9Sstevel@tonic-gate * Fetch a pointer to the allocated soft state structure 1930*7c478bd9Sstevel@tonic-gate * corresponding to 'item.' 1931*7c478bd9Sstevel@tonic-gate */ 1932*7c478bd9Sstevel@tonic-gate void * 1933*7c478bd9Sstevel@tonic-gate ddi_get_soft_state(void *state, int item); 1934*7c478bd9Sstevel@tonic-gate 1935*7c478bd9Sstevel@tonic-gate /* 1936*7c478bd9Sstevel@tonic-gate * Free the state structure corresponding to 'item.' 1937*7c478bd9Sstevel@tonic-gate */ 1938*7c478bd9Sstevel@tonic-gate void 1939*7c478bd9Sstevel@tonic-gate ddi_soft_state_free(void *state, int item); 1940*7c478bd9Sstevel@tonic-gate 1941*7c478bd9Sstevel@tonic-gate /* 1942*7c478bd9Sstevel@tonic-gate * Free the handle, and any associated soft state structures. 1943*7c478bd9Sstevel@tonic-gate */ 1944*7c478bd9Sstevel@tonic-gate void 1945*7c478bd9Sstevel@tonic-gate ddi_soft_state_fini(void **state_p); 1946*7c478bd9Sstevel@tonic-gate 1947*7c478bd9Sstevel@tonic-gate /* 1948*7c478bd9Sstevel@tonic-gate * Set the addr field of the name in dip to name 1949*7c478bd9Sstevel@tonic-gate */ 1950*7c478bd9Sstevel@tonic-gate void 1951*7c478bd9Sstevel@tonic-gate ddi_set_name_addr(dev_info_t *dip, char *name); 1952*7c478bd9Sstevel@tonic-gate 1953*7c478bd9Sstevel@tonic-gate /* 1954*7c478bd9Sstevel@tonic-gate * Get the address part of the name. 1955*7c478bd9Sstevel@tonic-gate */ 1956*7c478bd9Sstevel@tonic-gate char * 1957*7c478bd9Sstevel@tonic-gate ddi_get_name_addr(dev_info_t *dip); 1958*7c478bd9Sstevel@tonic-gate 1959*7c478bd9Sstevel@tonic-gate void 1960*7c478bd9Sstevel@tonic-gate ddi_set_parent_data(dev_info_t *dip, void *pd); 1961*7c478bd9Sstevel@tonic-gate 1962*7c478bd9Sstevel@tonic-gate void * 1963*7c478bd9Sstevel@tonic-gate ddi_get_parent_data(dev_info_t *dip); 1964*7c478bd9Sstevel@tonic-gate 1965*7c478bd9Sstevel@tonic-gate int 1966*7c478bd9Sstevel@tonic-gate ddi_initchild(dev_info_t *parent, dev_info_t *proto); 1967*7c478bd9Sstevel@tonic-gate 1968*7c478bd9Sstevel@tonic-gate int 1969*7c478bd9Sstevel@tonic-gate ddi_uninitchild(dev_info_t *dip); 1970*7c478bd9Sstevel@tonic-gate 1971*7c478bd9Sstevel@tonic-gate major_t 1972*7c478bd9Sstevel@tonic-gate ddi_name_to_major(char *name); 1973*7c478bd9Sstevel@tonic-gate 1974*7c478bd9Sstevel@tonic-gate char * 1975*7c478bd9Sstevel@tonic-gate ddi_major_to_name(major_t major); 1976*7c478bd9Sstevel@tonic-gate 1977*7c478bd9Sstevel@tonic-gate char * 1978*7c478bd9Sstevel@tonic-gate ddi_deviname(dev_info_t *dip, char *name); 1979*7c478bd9Sstevel@tonic-gate 1980*7c478bd9Sstevel@tonic-gate char * 1981*7c478bd9Sstevel@tonic-gate ddi_pathname(dev_info_t *dip, char *path); 1982*7c478bd9Sstevel@tonic-gate 1983*7c478bd9Sstevel@tonic-gate int 1984*7c478bd9Sstevel@tonic-gate ddi_dev_pathname(dev_t devt, int spec_type, char *name); 1985*7c478bd9Sstevel@tonic-gate 1986*7c478bd9Sstevel@tonic-gate dev_t 1987*7c478bd9Sstevel@tonic-gate ddi_pathname_to_dev_t(char *pathname); 1988*7c478bd9Sstevel@tonic-gate 1989*7c478bd9Sstevel@tonic-gate /* 1990*7c478bd9Sstevel@tonic-gate * High resolution system timer functions. 1991*7c478bd9Sstevel@tonic-gate * 1992*7c478bd9Sstevel@tonic-gate * These functions are already in the kernel (see sys/time.h). 1993*7c478bd9Sstevel@tonic-gate * The ddi supports the notion of a hrtime_t type and the 1994*7c478bd9Sstevel@tonic-gate * functions gethrtime, hrtadd, hrtsub and hrtcmp. 1995*7c478bd9Sstevel@tonic-gate */ 1996*7c478bd9Sstevel@tonic-gate 1997*7c478bd9Sstevel@tonic-gate 1998*7c478bd9Sstevel@tonic-gate /* 1999*7c478bd9Sstevel@tonic-gate * Nexus wrapper functions 2000*7c478bd9Sstevel@tonic-gate * 2001*7c478bd9Sstevel@tonic-gate * These functions are for entries in a bus nexus driver's bus_ops 2002*7c478bd9Sstevel@tonic-gate * structure for when the driver doesn't have such a function and 2003*7c478bd9Sstevel@tonic-gate * doesn't wish to prohibit such a function from existing. They 2004*7c478bd9Sstevel@tonic-gate * may also be called to start passing a request up the dev_info 2005*7c478bd9Sstevel@tonic-gate * tree. 2006*7c478bd9Sstevel@tonic-gate */ 2007*7c478bd9Sstevel@tonic-gate 2008*7c478bd9Sstevel@tonic-gate /* 2009*7c478bd9Sstevel@tonic-gate * bus_ctl wrapper 2010*7c478bd9Sstevel@tonic-gate */ 2011*7c478bd9Sstevel@tonic-gate 2012*7c478bd9Sstevel@tonic-gate int 2013*7c478bd9Sstevel@tonic-gate ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v); 2014*7c478bd9Sstevel@tonic-gate 2015*7c478bd9Sstevel@tonic-gate /* 2016*7c478bd9Sstevel@tonic-gate * bus_dma_map wrapper 2017*7c478bd9Sstevel@tonic-gate */ 2018*7c478bd9Sstevel@tonic-gate 2019*7c478bd9Sstevel@tonic-gate int 2020*7c478bd9Sstevel@tonic-gate ddi_dma_map(dev_info_t *dip, dev_info_t *rdip, 2021*7c478bd9Sstevel@tonic-gate struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep); 2022*7c478bd9Sstevel@tonic-gate 2023*7c478bd9Sstevel@tonic-gate int 2024*7c478bd9Sstevel@tonic-gate ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr, 2025*7c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep); 2026*7c478bd9Sstevel@tonic-gate 2027*7c478bd9Sstevel@tonic-gate int 2028*7c478bd9Sstevel@tonic-gate ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip, 2029*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle); 2030*7c478bd9Sstevel@tonic-gate 2031*7c478bd9Sstevel@tonic-gate int 2032*7c478bd9Sstevel@tonic-gate ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip, 2033*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, struct ddi_dma_req *dmareq, 2034*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t *cp, uint_t *ccountp); 2035*7c478bd9Sstevel@tonic-gate 2036*7c478bd9Sstevel@tonic-gate int 2037*7c478bd9Sstevel@tonic-gate ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip, 2038*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle); 2039*7c478bd9Sstevel@tonic-gate 2040*7c478bd9Sstevel@tonic-gate int 2041*7c478bd9Sstevel@tonic-gate ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip, 2042*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, off_t off, size_t len, 2043*7c478bd9Sstevel@tonic-gate uint_t cache_flags); 2044*7c478bd9Sstevel@tonic-gate 2045*7c478bd9Sstevel@tonic-gate int 2046*7c478bd9Sstevel@tonic-gate ddi_dma_win(dev_info_t *dip, dev_info_t *rdip, 2047*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, uint_t win, off_t *offp, 2048*7c478bd9Sstevel@tonic-gate size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); 2049*7c478bd9Sstevel@tonic-gate 2050*7c478bd9Sstevel@tonic-gate /* 2051*7c478bd9Sstevel@tonic-gate * bus_dma_ctl wrapper 2052*7c478bd9Sstevel@tonic-gate */ 2053*7c478bd9Sstevel@tonic-gate 2054*7c478bd9Sstevel@tonic-gate int 2055*7c478bd9Sstevel@tonic-gate ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle, 2056*7c478bd9Sstevel@tonic-gate enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, 2057*7c478bd9Sstevel@tonic-gate caddr_t *objp, uint_t flags); 2058*7c478bd9Sstevel@tonic-gate 2059*7c478bd9Sstevel@tonic-gate /* 2060*7c478bd9Sstevel@tonic-gate * dvma support for networking drivers 2061*7c478bd9Sstevel@tonic-gate */ 2062*7c478bd9Sstevel@tonic-gate 2063*7c478bd9Sstevel@tonic-gate unsigned long 2064*7c478bd9Sstevel@tonic-gate dvma_pagesize(dev_info_t *dip); 2065*7c478bd9Sstevel@tonic-gate 2066*7c478bd9Sstevel@tonic-gate int 2067*7c478bd9Sstevel@tonic-gate dvma_reserve(dev_info_t *dip, ddi_dma_lim_t *limp, uint_t pages, 2068*7c478bd9Sstevel@tonic-gate ddi_dma_handle_t *handlep); 2069*7c478bd9Sstevel@tonic-gate 2070*7c478bd9Sstevel@tonic-gate void 2071*7c478bd9Sstevel@tonic-gate dvma_release(ddi_dma_handle_t h); 2072*7c478bd9Sstevel@tonic-gate 2073*7c478bd9Sstevel@tonic-gate void 2074*7c478bd9Sstevel@tonic-gate dvma_kaddr_load(ddi_dma_handle_t h, caddr_t a, uint_t len, uint_t index, 2075*7c478bd9Sstevel@tonic-gate ddi_dma_cookie_t *cp); 2076*7c478bd9Sstevel@tonic-gate 2077*7c478bd9Sstevel@tonic-gate void 2078*7c478bd9Sstevel@tonic-gate dvma_unload(ddi_dma_handle_t h, uint_t objindex, uint_t type); 2079*7c478bd9Sstevel@tonic-gate 2080*7c478bd9Sstevel@tonic-gate void 2081*7c478bd9Sstevel@tonic-gate dvma_sync(ddi_dma_handle_t h, uint_t objindex, uint_t type); 2082*7c478bd9Sstevel@tonic-gate 2083*7c478bd9Sstevel@tonic-gate /* 2084*7c478bd9Sstevel@tonic-gate * Layered driver support 2085*7c478bd9Sstevel@tonic-gate */ 2086*7c478bd9Sstevel@tonic-gate 2087*7c478bd9Sstevel@tonic-gate extern int ddi_copyin(const void *, void *, size_t, int); 2088*7c478bd9Sstevel@tonic-gate extern int ddi_copyout(const void *, void *, size_t, int); 2089*7c478bd9Sstevel@tonic-gate 2090*7c478bd9Sstevel@tonic-gate /* 2091*7c478bd9Sstevel@tonic-gate * Send signals to processes 2092*7c478bd9Sstevel@tonic-gate */ 2093*7c478bd9Sstevel@tonic-gate extern void *proc_ref(void); 2094*7c478bd9Sstevel@tonic-gate extern void proc_unref(void *pref); 2095*7c478bd9Sstevel@tonic-gate extern int proc_signal(void *pref, int sig); 2096*7c478bd9Sstevel@tonic-gate 2097*7c478bd9Sstevel@tonic-gate /* I/O port access routines */ 2098*7c478bd9Sstevel@tonic-gate extern uint8_t inb(int port); 2099*7c478bd9Sstevel@tonic-gate extern uint16_t inw(int port); 2100*7c478bd9Sstevel@tonic-gate extern uint32_t inl(int port); 2101*7c478bd9Sstevel@tonic-gate extern void repinsb(int port, uint8_t *addr, int count); 2102*7c478bd9Sstevel@tonic-gate extern void repinsw(int port, uint16_t *addr, int count); 2103*7c478bd9Sstevel@tonic-gate extern void repinsd(int port, uint32_t *addr, int count); 2104*7c478bd9Sstevel@tonic-gate extern void outb(int port, uint8_t value); 2105*7c478bd9Sstevel@tonic-gate extern void outw(int port, uint16_t value); 2106*7c478bd9Sstevel@tonic-gate extern void outl(int port, uint32_t value); 2107*7c478bd9Sstevel@tonic-gate extern void repoutsb(int port, uint8_t *addr, int count); 2108*7c478bd9Sstevel@tonic-gate extern void repoutsw(int port, uint16_t *addr, int count); 2109*7c478bd9Sstevel@tonic-gate extern void repoutsd(int port, uint32_t *addr, int count); 2110*7c478bd9Sstevel@tonic-gate 2111*7c478bd9Sstevel@tonic-gate /* 2112*7c478bd9Sstevel@tonic-gate * Console bell routines 2113*7c478bd9Sstevel@tonic-gate */ 2114*7c478bd9Sstevel@tonic-gate extern void ddi_ring_console_bell(clock_t duration); 2115*7c478bd9Sstevel@tonic-gate extern void ddi_set_console_bell(void (*bellfunc)(clock_t duration)); 2116*7c478bd9Sstevel@tonic-gate 2117*7c478bd9Sstevel@tonic-gate /* 2118*7c478bd9Sstevel@tonic-gate * Fault-related functions 2119*7c478bd9Sstevel@tonic-gate */ 2120*7c478bd9Sstevel@tonic-gate extern int ddi_check_acc_handle(ddi_acc_handle_t); 2121*7c478bd9Sstevel@tonic-gate extern int ddi_check_dma_handle(ddi_dma_handle_t); 2122*7c478bd9Sstevel@tonic-gate extern void ddi_dev_report_fault(dev_info_t *, ddi_fault_impact_t, 2123*7c478bd9Sstevel@tonic-gate ddi_fault_location_t, const char *); 2124*7c478bd9Sstevel@tonic-gate extern ddi_devstate_t ddi_get_devstate(dev_info_t *); 2125*7c478bd9Sstevel@tonic-gate 2126*7c478bd9Sstevel@tonic-gate /* 2127*7c478bd9Sstevel@tonic-gate * Miscellaneous redefines 2128*7c478bd9Sstevel@tonic-gate */ 2129*7c478bd9Sstevel@tonic-gate #define uiophysio physio 2130*7c478bd9Sstevel@tonic-gate 2131*7c478bd9Sstevel@tonic-gate /* 2132*7c478bd9Sstevel@tonic-gate * utilities - "reg" mapping and all common portable data access functions 2133*7c478bd9Sstevel@tonic-gate */ 2134*7c478bd9Sstevel@tonic-gate 2135*7c478bd9Sstevel@tonic-gate /* 2136*7c478bd9Sstevel@tonic-gate * error code from ddi_regs_map_setup 2137*7c478bd9Sstevel@tonic-gate */ 2138*7c478bd9Sstevel@tonic-gate 2139*7c478bd9Sstevel@tonic-gate #define DDI_REGS_ACC_CONFLICT (-10) 2140*7c478bd9Sstevel@tonic-gate 2141*7c478bd9Sstevel@tonic-gate /* 2142*7c478bd9Sstevel@tonic-gate * Device address advance flags 2143*7c478bd9Sstevel@tonic-gate */ 2144*7c478bd9Sstevel@tonic-gate 2145*7c478bd9Sstevel@tonic-gate #define DDI_DEV_NO_AUTOINCR 0x0000 2146*7c478bd9Sstevel@tonic-gate #define DDI_DEV_AUTOINCR 0x0001 2147*7c478bd9Sstevel@tonic-gate 2148*7c478bd9Sstevel@tonic-gate int 2149*7c478bd9Sstevel@tonic-gate ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber, caddr_t *addrp, 2150*7c478bd9Sstevel@tonic-gate offset_t offset, offset_t len, ddi_device_acc_attr_t *accattrp, 2151*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t *handle); 2152*7c478bd9Sstevel@tonic-gate 2153*7c478bd9Sstevel@tonic-gate void 2154*7c478bd9Sstevel@tonic-gate ddi_regs_map_free(ddi_acc_handle_t *handle); 2155*7c478bd9Sstevel@tonic-gate 2156*7c478bd9Sstevel@tonic-gate /* 2157*7c478bd9Sstevel@tonic-gate * these are the prototypes for the common portable data access functions 2158*7c478bd9Sstevel@tonic-gate */ 2159*7c478bd9Sstevel@tonic-gate 2160*7c478bd9Sstevel@tonic-gate #ifdef _LP64 2161*7c478bd9Sstevel@tonic-gate 2162*7c478bd9Sstevel@tonic-gate uint8_t 2163*7c478bd9Sstevel@tonic-gate ddi_get8(ddi_acc_handle_t handle, uint8_t *addr); 2164*7c478bd9Sstevel@tonic-gate 2165*7c478bd9Sstevel@tonic-gate uint16_t 2166*7c478bd9Sstevel@tonic-gate ddi_get16(ddi_acc_handle_t handle, uint16_t *addr); 2167*7c478bd9Sstevel@tonic-gate 2168*7c478bd9Sstevel@tonic-gate uint32_t 2169*7c478bd9Sstevel@tonic-gate ddi_get32(ddi_acc_handle_t handle, uint32_t *addr); 2170*7c478bd9Sstevel@tonic-gate 2171*7c478bd9Sstevel@tonic-gate uint64_t 2172*7c478bd9Sstevel@tonic-gate ddi_get64(ddi_acc_handle_t handle, uint64_t *addr); 2173*7c478bd9Sstevel@tonic-gate 2174*7c478bd9Sstevel@tonic-gate void 2175*7c478bd9Sstevel@tonic-gate ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr, 2176*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2177*7c478bd9Sstevel@tonic-gate 2178*7c478bd9Sstevel@tonic-gate void 2179*7c478bd9Sstevel@tonic-gate ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr, 2180*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2181*7c478bd9Sstevel@tonic-gate 2182*7c478bd9Sstevel@tonic-gate void 2183*7c478bd9Sstevel@tonic-gate ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr, 2184*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2185*7c478bd9Sstevel@tonic-gate 2186*7c478bd9Sstevel@tonic-gate void 2187*7c478bd9Sstevel@tonic-gate ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr, 2188*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2189*7c478bd9Sstevel@tonic-gate 2190*7c478bd9Sstevel@tonic-gate void 2191*7c478bd9Sstevel@tonic-gate ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value); 2192*7c478bd9Sstevel@tonic-gate 2193*7c478bd9Sstevel@tonic-gate void 2194*7c478bd9Sstevel@tonic-gate ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value); 2195*7c478bd9Sstevel@tonic-gate 2196*7c478bd9Sstevel@tonic-gate void 2197*7c478bd9Sstevel@tonic-gate ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value); 2198*7c478bd9Sstevel@tonic-gate 2199*7c478bd9Sstevel@tonic-gate void 2200*7c478bd9Sstevel@tonic-gate ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value); 2201*7c478bd9Sstevel@tonic-gate 2202*7c478bd9Sstevel@tonic-gate void 2203*7c478bd9Sstevel@tonic-gate ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr, 2204*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2205*7c478bd9Sstevel@tonic-gate void 2206*7c478bd9Sstevel@tonic-gate ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr, 2207*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2208*7c478bd9Sstevel@tonic-gate void 2209*7c478bd9Sstevel@tonic-gate ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr, 2210*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2211*7c478bd9Sstevel@tonic-gate 2212*7c478bd9Sstevel@tonic-gate void 2213*7c478bd9Sstevel@tonic-gate ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr, 2214*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2215*7c478bd9Sstevel@tonic-gate 2216*7c478bd9Sstevel@tonic-gate #else /* _ILP32 */ 2217*7c478bd9Sstevel@tonic-gate 2218*7c478bd9Sstevel@tonic-gate uint8_t 2219*7c478bd9Sstevel@tonic-gate ddi_getb(ddi_acc_handle_t handle, uint8_t *addr); 2220*7c478bd9Sstevel@tonic-gate #define ddi_get8 ddi_getb 2221*7c478bd9Sstevel@tonic-gate 2222*7c478bd9Sstevel@tonic-gate uint16_t 2223*7c478bd9Sstevel@tonic-gate ddi_getw(ddi_acc_handle_t handle, uint16_t *addr); 2224*7c478bd9Sstevel@tonic-gate #define ddi_get16 ddi_getw 2225*7c478bd9Sstevel@tonic-gate 2226*7c478bd9Sstevel@tonic-gate uint32_t 2227*7c478bd9Sstevel@tonic-gate ddi_getl(ddi_acc_handle_t handle, uint32_t *addr); 2228*7c478bd9Sstevel@tonic-gate #define ddi_get32 ddi_getl 2229*7c478bd9Sstevel@tonic-gate 2230*7c478bd9Sstevel@tonic-gate uint64_t 2231*7c478bd9Sstevel@tonic-gate ddi_getll(ddi_acc_handle_t handle, uint64_t *addr); 2232*7c478bd9Sstevel@tonic-gate #define ddi_get64 ddi_getll 2233*7c478bd9Sstevel@tonic-gate 2234*7c478bd9Sstevel@tonic-gate void 2235*7c478bd9Sstevel@tonic-gate ddi_rep_getb(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr, 2236*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2237*7c478bd9Sstevel@tonic-gate #define ddi_rep_get8 ddi_rep_getb 2238*7c478bd9Sstevel@tonic-gate 2239*7c478bd9Sstevel@tonic-gate void 2240*7c478bd9Sstevel@tonic-gate ddi_rep_getw(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr, 2241*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2242*7c478bd9Sstevel@tonic-gate #define ddi_rep_get16 ddi_rep_getw 2243*7c478bd9Sstevel@tonic-gate 2244*7c478bd9Sstevel@tonic-gate void 2245*7c478bd9Sstevel@tonic-gate ddi_rep_getl(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr, 2246*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2247*7c478bd9Sstevel@tonic-gate #define ddi_rep_get32 ddi_rep_getl 2248*7c478bd9Sstevel@tonic-gate 2249*7c478bd9Sstevel@tonic-gate void 2250*7c478bd9Sstevel@tonic-gate ddi_rep_getll(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr, 2251*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2252*7c478bd9Sstevel@tonic-gate #define ddi_rep_get64 ddi_rep_getll 2253*7c478bd9Sstevel@tonic-gate 2254*7c478bd9Sstevel@tonic-gate void 2255*7c478bd9Sstevel@tonic-gate ddi_putb(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value); 2256*7c478bd9Sstevel@tonic-gate #define ddi_put8 ddi_putb 2257*7c478bd9Sstevel@tonic-gate 2258*7c478bd9Sstevel@tonic-gate void 2259*7c478bd9Sstevel@tonic-gate ddi_putw(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value); 2260*7c478bd9Sstevel@tonic-gate #define ddi_put16 ddi_putw 2261*7c478bd9Sstevel@tonic-gate 2262*7c478bd9Sstevel@tonic-gate void 2263*7c478bd9Sstevel@tonic-gate ddi_putl(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value); 2264*7c478bd9Sstevel@tonic-gate #define ddi_put32 ddi_putl 2265*7c478bd9Sstevel@tonic-gate 2266*7c478bd9Sstevel@tonic-gate void 2267*7c478bd9Sstevel@tonic-gate ddi_putll(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value); 2268*7c478bd9Sstevel@tonic-gate #define ddi_put64 ddi_putll 2269*7c478bd9Sstevel@tonic-gate 2270*7c478bd9Sstevel@tonic-gate void 2271*7c478bd9Sstevel@tonic-gate ddi_rep_putb(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr, 2272*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2273*7c478bd9Sstevel@tonic-gate #define ddi_rep_put8 ddi_rep_putb 2274*7c478bd9Sstevel@tonic-gate 2275*7c478bd9Sstevel@tonic-gate void 2276*7c478bd9Sstevel@tonic-gate ddi_rep_putw(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr, 2277*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2278*7c478bd9Sstevel@tonic-gate #define ddi_rep_put16 ddi_rep_putw 2279*7c478bd9Sstevel@tonic-gate 2280*7c478bd9Sstevel@tonic-gate void 2281*7c478bd9Sstevel@tonic-gate ddi_rep_putl(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr, 2282*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2283*7c478bd9Sstevel@tonic-gate #define ddi_rep_put32 ddi_rep_putl 2284*7c478bd9Sstevel@tonic-gate 2285*7c478bd9Sstevel@tonic-gate void 2286*7c478bd9Sstevel@tonic-gate ddi_rep_putll(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr, 2287*7c478bd9Sstevel@tonic-gate size_t repcount, uint_t flags); 2288*7c478bd9Sstevel@tonic-gate #define ddi_rep_put64 ddi_rep_putll 2289*7c478bd9Sstevel@tonic-gate 2290*7c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 2291*7c478bd9Sstevel@tonic-gate 2292*7c478bd9Sstevel@tonic-gate /* 2293*7c478bd9Sstevel@tonic-gate * these are special device handling functions 2294*7c478bd9Sstevel@tonic-gate */ 2295*7c478bd9Sstevel@tonic-gate int 2296*7c478bd9Sstevel@tonic-gate ddi_device_zero(ddi_acc_handle_t handle, caddr_t dev_addr, 2297*7c478bd9Sstevel@tonic-gate size_t bytecount, ssize_t dev_advcnt, uint_t dev_datasz); 2298*7c478bd9Sstevel@tonic-gate 2299*7c478bd9Sstevel@tonic-gate int 2300*7c478bd9Sstevel@tonic-gate ddi_device_copy( 2301*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t src_handle, caddr_t src_addr, ssize_t src_advcnt, 2302*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t dest_handle, caddr_t dest_addr, ssize_t dest_advcnt, 2303*7c478bd9Sstevel@tonic-gate size_t bytecount, uint_t dev_datasz); 2304*7c478bd9Sstevel@tonic-gate 2305*7c478bd9Sstevel@tonic-gate /* 2306*7c478bd9Sstevel@tonic-gate * these are software byte swapping functions 2307*7c478bd9Sstevel@tonic-gate */ 2308*7c478bd9Sstevel@tonic-gate uint16_t 2309*7c478bd9Sstevel@tonic-gate ddi_swap16(uint16_t value); 2310*7c478bd9Sstevel@tonic-gate 2311*7c478bd9Sstevel@tonic-gate uint32_t 2312*7c478bd9Sstevel@tonic-gate ddi_swap32(uint32_t value); 2313*7c478bd9Sstevel@tonic-gate 2314*7c478bd9Sstevel@tonic-gate uint64_t 2315*7c478bd9Sstevel@tonic-gate ddi_swap64(uint64_t value); 2316*7c478bd9Sstevel@tonic-gate 2317*7c478bd9Sstevel@tonic-gate /* 2318*7c478bd9Sstevel@tonic-gate * these are the prototypes for PCI local bus functions 2319*7c478bd9Sstevel@tonic-gate */ 2320*7c478bd9Sstevel@tonic-gate /* 2321*7c478bd9Sstevel@tonic-gate * PCI power management capabilities reporting in addition to those 2322*7c478bd9Sstevel@tonic-gate * provided by the PCI Power Management Specification. 2323*7c478bd9Sstevel@tonic-gate */ 2324*7c478bd9Sstevel@tonic-gate #define PCI_PM_IDLESPEED 0x1 /* clock for idle dev - cap */ 2325*7c478bd9Sstevel@tonic-gate #define PCI_PM_IDLESPEED_ANY (void *)-1 /* any clock for idle dev */ 2326*7c478bd9Sstevel@tonic-gate #define PCI_PM_IDLESPEED_NONE (void *)-2 /* regular clock for idle dev */ 2327*7c478bd9Sstevel@tonic-gate 2328*7c478bd9Sstevel@tonic-gate int 2329*7c478bd9Sstevel@tonic-gate pci_config_setup(dev_info_t *dip, ddi_acc_handle_t *handle); 2330*7c478bd9Sstevel@tonic-gate 2331*7c478bd9Sstevel@tonic-gate void 2332*7c478bd9Sstevel@tonic-gate pci_config_teardown(ddi_acc_handle_t *handle); 2333*7c478bd9Sstevel@tonic-gate 2334*7c478bd9Sstevel@tonic-gate #ifdef _LP64 2335*7c478bd9Sstevel@tonic-gate 2336*7c478bd9Sstevel@tonic-gate uint8_t 2337*7c478bd9Sstevel@tonic-gate pci_config_get8(ddi_acc_handle_t handle, off_t offset); 2338*7c478bd9Sstevel@tonic-gate 2339*7c478bd9Sstevel@tonic-gate uint16_t 2340*7c478bd9Sstevel@tonic-gate pci_config_get16(ddi_acc_handle_t handle, off_t offset); 2341*7c478bd9Sstevel@tonic-gate 2342*7c478bd9Sstevel@tonic-gate uint32_t 2343*7c478bd9Sstevel@tonic-gate pci_config_get32(ddi_acc_handle_t handle, off_t offset); 2344*7c478bd9Sstevel@tonic-gate 2345*7c478bd9Sstevel@tonic-gate uint64_t 2346*7c478bd9Sstevel@tonic-gate pci_config_get64(ddi_acc_handle_t handle, off_t offset); 2347*7c478bd9Sstevel@tonic-gate 2348*7c478bd9Sstevel@tonic-gate void 2349*7c478bd9Sstevel@tonic-gate pci_config_put8(ddi_acc_handle_t handle, off_t offset, uint8_t value); 2350*7c478bd9Sstevel@tonic-gate 2351*7c478bd9Sstevel@tonic-gate void 2352*7c478bd9Sstevel@tonic-gate pci_config_put16(ddi_acc_handle_t handle, off_t offset, uint16_t value); 2353*7c478bd9Sstevel@tonic-gate 2354*7c478bd9Sstevel@tonic-gate void 2355*7c478bd9Sstevel@tonic-gate pci_config_put32(ddi_acc_handle_t handle, off_t offset, uint32_t value); 2356*7c478bd9Sstevel@tonic-gate 2357*7c478bd9Sstevel@tonic-gate void 2358*7c478bd9Sstevel@tonic-gate pci_config_put64(ddi_acc_handle_t handle, off_t offset, uint64_t value); 2359*7c478bd9Sstevel@tonic-gate 2360*7c478bd9Sstevel@tonic-gate #else /* _ILP32 */ 2361*7c478bd9Sstevel@tonic-gate 2362*7c478bd9Sstevel@tonic-gate uint8_t 2363*7c478bd9Sstevel@tonic-gate pci_config_getb(ddi_acc_handle_t handle, off_t offset); 2364*7c478bd9Sstevel@tonic-gate #define pci_config_get8 pci_config_getb 2365*7c478bd9Sstevel@tonic-gate 2366*7c478bd9Sstevel@tonic-gate uint16_t 2367*7c478bd9Sstevel@tonic-gate pci_config_getw(ddi_acc_handle_t handle, off_t offset); 2368*7c478bd9Sstevel@tonic-gate #define pci_config_get16 pci_config_getw 2369*7c478bd9Sstevel@tonic-gate 2370*7c478bd9Sstevel@tonic-gate uint32_t 2371*7c478bd9Sstevel@tonic-gate pci_config_getl(ddi_acc_handle_t handle, off_t offset); 2372*7c478bd9Sstevel@tonic-gate #define pci_config_get32 pci_config_getl 2373*7c478bd9Sstevel@tonic-gate 2374*7c478bd9Sstevel@tonic-gate uint64_t 2375*7c478bd9Sstevel@tonic-gate pci_config_getll(ddi_acc_handle_t handle, off_t offset); 2376*7c478bd9Sstevel@tonic-gate #define pci_config_get64 pci_config_getll 2377*7c478bd9Sstevel@tonic-gate 2378*7c478bd9Sstevel@tonic-gate void 2379*7c478bd9Sstevel@tonic-gate pci_config_putb(ddi_acc_handle_t handle, off_t offset, uint8_t value); 2380*7c478bd9Sstevel@tonic-gate #define pci_config_put8 pci_config_putb 2381*7c478bd9Sstevel@tonic-gate 2382*7c478bd9Sstevel@tonic-gate void 2383*7c478bd9Sstevel@tonic-gate pci_config_putw(ddi_acc_handle_t handle, off_t offset, uint16_t value); 2384*7c478bd9Sstevel@tonic-gate #define pci_config_put16 pci_config_putw 2385*7c478bd9Sstevel@tonic-gate 2386*7c478bd9Sstevel@tonic-gate void 2387*7c478bd9Sstevel@tonic-gate pci_config_putl(ddi_acc_handle_t handle, off_t offset, uint32_t value); 2388*7c478bd9Sstevel@tonic-gate #define pci_config_put32 pci_config_putl 2389*7c478bd9Sstevel@tonic-gate 2390*7c478bd9Sstevel@tonic-gate void 2391*7c478bd9Sstevel@tonic-gate pci_config_putll(ddi_acc_handle_t handle, off_t offset, uint64_t value); 2392*7c478bd9Sstevel@tonic-gate #define pci_config_put64 pci_config_putll 2393*7c478bd9Sstevel@tonic-gate 2394*7c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 2395*7c478bd9Sstevel@tonic-gate 2396*7c478bd9Sstevel@tonic-gate int 2397*7c478bd9Sstevel@tonic-gate pci_report_pmcap(dev_info_t *dip, int cap, void *arg); 2398*7c478bd9Sstevel@tonic-gate 2399*7c478bd9Sstevel@tonic-gate int 2400*7c478bd9Sstevel@tonic-gate pci_restore_config_regs(dev_info_t *dip); 2401*7c478bd9Sstevel@tonic-gate 2402*7c478bd9Sstevel@tonic-gate int 2403*7c478bd9Sstevel@tonic-gate pci_save_config_regs(dev_info_t *dip); 2404*7c478bd9Sstevel@tonic-gate 2405*7c478bd9Sstevel@tonic-gate void 2406*7c478bd9Sstevel@tonic-gate pci_ereport_setup(dev_info_t *dip); 2407*7c478bd9Sstevel@tonic-gate 2408*7c478bd9Sstevel@tonic-gate void 2409*7c478bd9Sstevel@tonic-gate pci_ereport_teardown(dev_info_t *dip); 2410*7c478bd9Sstevel@tonic-gate 2411*7c478bd9Sstevel@tonic-gate void 2412*7c478bd9Sstevel@tonic-gate pci_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status); 2413*7c478bd9Sstevel@tonic-gate 2414*7c478bd9Sstevel@tonic-gate void 2415*7c478bd9Sstevel@tonic-gate pci_bdg_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status); 2416*7c478bd9Sstevel@tonic-gate 2417*7c478bd9Sstevel@tonic-gate int 2418*7c478bd9Sstevel@tonic-gate pci_bdg_check_status(dev_info_t *dip, ddi_fm_error_t *derr, 2419*7c478bd9Sstevel@tonic-gate uint16_t pci_cfg_stat, uint16_t pci_cfg_sec_stat); 2420*7c478bd9Sstevel@tonic-gate 2421*7c478bd9Sstevel@tonic-gate /* 2422*7c478bd9Sstevel@tonic-gate * the prototype for the C Language Type Model inquiry. 2423*7c478bd9Sstevel@tonic-gate */ 2424*7c478bd9Sstevel@tonic-gate model_t ddi_mmap_get_model(void); 2425*7c478bd9Sstevel@tonic-gate model_t ddi_model_convert_from(model_t); 2426*7c478bd9Sstevel@tonic-gate 2427*7c478bd9Sstevel@tonic-gate /* 2428*7c478bd9Sstevel@tonic-gate * these are the prototypes for device id functions. 2429*7c478bd9Sstevel@tonic-gate */ 2430*7c478bd9Sstevel@tonic-gate int 2431*7c478bd9Sstevel@tonic-gate ddi_devid_valid(ddi_devid_t devid); 2432*7c478bd9Sstevel@tonic-gate 2433*7c478bd9Sstevel@tonic-gate int 2434*7c478bd9Sstevel@tonic-gate ddi_devid_register(dev_info_t *dip, ddi_devid_t devid); 2435*7c478bd9Sstevel@tonic-gate 2436*7c478bd9Sstevel@tonic-gate void 2437*7c478bd9Sstevel@tonic-gate ddi_devid_unregister(dev_info_t *dip); 2438*7c478bd9Sstevel@tonic-gate 2439*7c478bd9Sstevel@tonic-gate int 2440*7c478bd9Sstevel@tonic-gate ddi_devid_init(dev_info_t *dip, ushort_t devid_type, ushort_t nbytes, 2441*7c478bd9Sstevel@tonic-gate void *id, ddi_devid_t *ret_devid); 2442*7c478bd9Sstevel@tonic-gate 2443*7c478bd9Sstevel@tonic-gate size_t 2444*7c478bd9Sstevel@tonic-gate ddi_devid_sizeof(ddi_devid_t devid); 2445*7c478bd9Sstevel@tonic-gate 2446*7c478bd9Sstevel@tonic-gate void 2447*7c478bd9Sstevel@tonic-gate ddi_devid_free(ddi_devid_t devid); 2448*7c478bd9Sstevel@tonic-gate 2449*7c478bd9Sstevel@tonic-gate int 2450*7c478bd9Sstevel@tonic-gate ddi_devid_compare(ddi_devid_t id1, ddi_devid_t id2); 2451*7c478bd9Sstevel@tonic-gate 2452*7c478bd9Sstevel@tonic-gate int 2453*7c478bd9Sstevel@tonic-gate ddi_devid_scsi_encode(int version, char *driver_name, 2454*7c478bd9Sstevel@tonic-gate uchar_t *inq, size_t inq_len, uchar_t *inq80, size_t inq80_len, 2455*7c478bd9Sstevel@tonic-gate uchar_t *inq83, size_t inq83_len, ddi_devid_t *ret_devid); 2456*7c478bd9Sstevel@tonic-gate 2457*7c478bd9Sstevel@tonic-gate char 2458*7c478bd9Sstevel@tonic-gate *ddi_devid_to_guid(ddi_devid_t devid); 2459*7c478bd9Sstevel@tonic-gate 2460*7c478bd9Sstevel@tonic-gate void 2461*7c478bd9Sstevel@tonic-gate ddi_devid_free_guid(char *guid); 2462*7c478bd9Sstevel@tonic-gate 2463*7c478bd9Sstevel@tonic-gate int 2464*7c478bd9Sstevel@tonic-gate ddi_lyr_get_devid(dev_t dev, ddi_devid_t *ret_devid); 2465*7c478bd9Sstevel@tonic-gate 2466*7c478bd9Sstevel@tonic-gate int 2467*7c478bd9Sstevel@tonic-gate ddi_lyr_get_minor_name(dev_t dev, int spec_type, char **minor_name); 2468*7c478bd9Sstevel@tonic-gate 2469*7c478bd9Sstevel@tonic-gate int 2470*7c478bd9Sstevel@tonic-gate ddi_lyr_devid_to_devlist(ddi_devid_t devid, char *minor_name, int *retndevs, 2471*7c478bd9Sstevel@tonic-gate dev_t **retdevs); 2472*7c478bd9Sstevel@tonic-gate 2473*7c478bd9Sstevel@tonic-gate void 2474*7c478bd9Sstevel@tonic-gate ddi_lyr_free_devlist(dev_t *devlist, int ndevs); 2475*7c478bd9Sstevel@tonic-gate 2476*7c478bd9Sstevel@tonic-gate char * 2477*7c478bd9Sstevel@tonic-gate ddi_devid_str_encode(ddi_devid_t devid, char *minor_name); 2478*7c478bd9Sstevel@tonic-gate 2479*7c478bd9Sstevel@tonic-gate int 2480*7c478bd9Sstevel@tonic-gate ddi_devid_str_decode(char *devidstr, ddi_devid_t *devidp, char **minor_namep); 2481*7c478bd9Sstevel@tonic-gate 2482*7c478bd9Sstevel@tonic-gate void 2483*7c478bd9Sstevel@tonic-gate ddi_devid_str_free(char *devidstr); 2484*7c478bd9Sstevel@tonic-gate 2485*7c478bd9Sstevel@tonic-gate int 2486*7c478bd9Sstevel@tonic-gate ddi_devid_str_compare(char *id1_str, char *id2_str); 2487*7c478bd9Sstevel@tonic-gate 2488*7c478bd9Sstevel@tonic-gate /* 2489*7c478bd9Sstevel@tonic-gate * Event to post to when a devinfo node is removed. 2490*7c478bd9Sstevel@tonic-gate */ 2491*7c478bd9Sstevel@tonic-gate #define DDI_DEVI_REMOVE_EVENT "DDI:DEVI_REMOVE" 2492*7c478bd9Sstevel@tonic-gate #define DDI_DEVI_INSERT_EVENT "DDI:DEVI_INSERT" 2493*7c478bd9Sstevel@tonic-gate #define DDI_DEVI_BUS_RESET_EVENT "DDI:DEVI_BUS_RESET" 2494*7c478bd9Sstevel@tonic-gate #define DDI_DEVI_DEVICE_RESET_EVENT "DDI:DEVI_DEVICE_RESET" 2495*7c478bd9Sstevel@tonic-gate 2496*7c478bd9Sstevel@tonic-gate /* 2497*7c478bd9Sstevel@tonic-gate * Invoke bus nexus driver's implementation of the 2498*7c478bd9Sstevel@tonic-gate * (*bus_remove_eventcall)() interface to remove a registered 2499*7c478bd9Sstevel@tonic-gate * callback handler for "event". 2500*7c478bd9Sstevel@tonic-gate */ 2501*7c478bd9Sstevel@tonic-gate int 2502*7c478bd9Sstevel@tonic-gate ddi_remove_event_handler(ddi_callback_id_t id); 2503*7c478bd9Sstevel@tonic-gate 2504*7c478bd9Sstevel@tonic-gate /* 2505*7c478bd9Sstevel@tonic-gate * Invoke bus nexus driver's implementation of the 2506*7c478bd9Sstevel@tonic-gate * (*bus_add_eventcall)() interface to register a callback handler 2507*7c478bd9Sstevel@tonic-gate * for "event". 2508*7c478bd9Sstevel@tonic-gate */ 2509*7c478bd9Sstevel@tonic-gate int 2510*7c478bd9Sstevel@tonic-gate ddi_add_event_handler(dev_info_t *dip, ddi_eventcookie_t event, 2511*7c478bd9Sstevel@tonic-gate void (*handler)(dev_info_t *, ddi_eventcookie_t, void *, void *), 2512*7c478bd9Sstevel@tonic-gate void *arg, ddi_callback_id_t *id); 2513*7c478bd9Sstevel@tonic-gate 2514*7c478bd9Sstevel@tonic-gate /* 2515*7c478bd9Sstevel@tonic-gate * Return a handle for event "name" by calling up the device tree 2516*7c478bd9Sstevel@tonic-gate * hierarchy via (*bus_get_eventcookie)() interface until claimed 2517*7c478bd9Sstevel@tonic-gate * by a bus nexus or top of dev_info tree is reached. 2518*7c478bd9Sstevel@tonic-gate */ 2519*7c478bd9Sstevel@tonic-gate int 2520*7c478bd9Sstevel@tonic-gate ddi_get_eventcookie(dev_info_t *dip, char *name, 2521*7c478bd9Sstevel@tonic-gate ddi_eventcookie_t *event_cookiep); 2522*7c478bd9Sstevel@tonic-gate 2523*7c478bd9Sstevel@tonic-gate /* 2524*7c478bd9Sstevel@tonic-gate * log a system event 2525*7c478bd9Sstevel@tonic-gate */ 2526*7c478bd9Sstevel@tonic-gate int 2527*7c478bd9Sstevel@tonic-gate ddi_log_sysevent(dev_info_t *dip, char *vendor, char *class_name, 2528*7c478bd9Sstevel@tonic-gate char *subclass_name, nvlist_t *attr_list, sysevent_id_t *eidp, 2529*7c478bd9Sstevel@tonic-gate int sleep_flag); 2530*7c478bd9Sstevel@tonic-gate 2531*7c478bd9Sstevel@tonic-gate /* 2532*7c478bd9Sstevel@tonic-gate * ddi_log_sysevent() vendors 2533*7c478bd9Sstevel@tonic-gate */ 2534*7c478bd9Sstevel@tonic-gate #define DDI_VENDOR_SUNW "SUNW" 2535*7c478bd9Sstevel@tonic-gate 2536*7c478bd9Sstevel@tonic-gate /* 2537*7c478bd9Sstevel@tonic-gate * Opaque task queue handle. 2538*7c478bd9Sstevel@tonic-gate */ 2539*7c478bd9Sstevel@tonic-gate typedef struct ddi_taskq ddi_taskq_t; 2540*7c478bd9Sstevel@tonic-gate 2541*7c478bd9Sstevel@tonic-gate /* 2542*7c478bd9Sstevel@tonic-gate * Use default system priority. 2543*7c478bd9Sstevel@tonic-gate */ 2544*7c478bd9Sstevel@tonic-gate #define TASKQ_DEFAULTPRI -1 2545*7c478bd9Sstevel@tonic-gate 2546*7c478bd9Sstevel@tonic-gate /* 2547*7c478bd9Sstevel@tonic-gate * Create a task queue 2548*7c478bd9Sstevel@tonic-gate */ 2549*7c478bd9Sstevel@tonic-gate ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name, 2550*7c478bd9Sstevel@tonic-gate int nthreads, pri_t pri, uint_t cflags); 2551*7c478bd9Sstevel@tonic-gate 2552*7c478bd9Sstevel@tonic-gate /* 2553*7c478bd9Sstevel@tonic-gate * destroy a task queue 2554*7c478bd9Sstevel@tonic-gate */ 2555*7c478bd9Sstevel@tonic-gate void ddi_taskq_destroy(ddi_taskq_t *tq); 2556*7c478bd9Sstevel@tonic-gate 2557*7c478bd9Sstevel@tonic-gate /* 2558*7c478bd9Sstevel@tonic-gate * Dispatch a task to a task queue 2559*7c478bd9Sstevel@tonic-gate */ 2560*7c478bd9Sstevel@tonic-gate int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *), 2561*7c478bd9Sstevel@tonic-gate void *arg, uint_t dflags); 2562*7c478bd9Sstevel@tonic-gate 2563*7c478bd9Sstevel@tonic-gate /* 2564*7c478bd9Sstevel@tonic-gate * Wait for all previously scheduled tasks to complete. 2565*7c478bd9Sstevel@tonic-gate */ 2566*7c478bd9Sstevel@tonic-gate void ddi_taskq_wait(ddi_taskq_t *tq); 2567*7c478bd9Sstevel@tonic-gate 2568*7c478bd9Sstevel@tonic-gate /* 2569*7c478bd9Sstevel@tonic-gate * Suspend all task execution. 2570*7c478bd9Sstevel@tonic-gate */ 2571*7c478bd9Sstevel@tonic-gate void ddi_taskq_suspend(ddi_taskq_t *tq); 2572*7c478bd9Sstevel@tonic-gate 2573*7c478bd9Sstevel@tonic-gate /* 2574*7c478bd9Sstevel@tonic-gate * Resume task execution. 2575*7c478bd9Sstevel@tonic-gate */ 2576*7c478bd9Sstevel@tonic-gate void ddi_taskq_resume(ddi_taskq_t *tq); 2577*7c478bd9Sstevel@tonic-gate 2578*7c478bd9Sstevel@tonic-gate /* 2579*7c478bd9Sstevel@tonic-gate * Is task queue suspended? 2580*7c478bd9Sstevel@tonic-gate */ 2581*7c478bd9Sstevel@tonic-gate boolean_t ddi_taskq_suspended(ddi_taskq_t *tq); 2582*7c478bd9Sstevel@tonic-gate 2583*7c478bd9Sstevel@tonic-gate /* 2584*7c478bd9Sstevel@tonic-gate * Parse an interface name of the form <alphanumeric>##<numeric> where 2585*7c478bd9Sstevel@tonic-gate * <numeric> is maximal. 2586*7c478bd9Sstevel@tonic-gate */ 2587*7c478bd9Sstevel@tonic-gate int ddi_parse(const char *, char *, uint_t *); 2588*7c478bd9Sstevel@tonic-gate 2589*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2590*7c478bd9Sstevel@tonic-gate 2591*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2592*7c478bd9Sstevel@tonic-gate } 2593*7c478bd9Sstevel@tonic-gate #endif 2594*7c478bd9Sstevel@tonic-gate 2595*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SUNDDI_H */ 2596