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