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