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