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