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