pkg: ship usr/lib/security/amd64/*.so links
[unleashed.git] / include / sys / sunddi.h
blob8167711372f790e74b0207e0d3887bb0349e1e60
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
25 * Copyright (c) 2012 by Delphix. All rights reserved.
26 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
29 #ifndef _SYS_SUNDDI_H
30 #define _SYS_SUNDDI_H
33 * Sun Specific DDI definitions
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>
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
70 * Generic Sun DDI definitions.
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 #define DDI_EALREADY (-7) /* operation already in progress */
83 * General-purpose DDI error return value definitions
85 #define DDI_ENOMEM 1 /* memory not available */
86 #define DDI_EBUSY 2 /* busy */
87 #define DDI_ETRANSPORT 3 /* transport down */
88 #define DDI_ECONTEXT 4 /* context error */
92 * General DDI sleep/nosleep allocation flags
94 #define DDI_SLEEP 0
95 #define DDI_NOSLEEP 1
98 * The following special nodeid values are reserved for use when creating
99 * nodes ONLY. They specify the attributes of the DDI_NC_PSEUDO class node
100 * being created:
102 * o DEVI_PSEUDO_NODEID specifics a node without persistence.
103 * o DEVI_SID_NODEID specifies a node with persistence.
104 * o DEVI_SID_HIDDEN_NODEID specifies a hidden node with persistence.
106 * A node with the 'hidden' attribute will not show up in devinfo snapshots
107 * or in /devices file system.
109 * A node with the 'persistent' attribute will not be automatically removed by
110 * the framework in the current implementation - driver.conf nodes are without
111 * persistence.
113 * The actual nodeid value may be assigned by the framework and may be
114 * different than these special values. Drivers may not make assumptions
115 * about the nodeid value that is actually assigned to the node.
118 #define DEVI_PSEUDO_NODEID ((int)-1)
119 #define DEVI_SID_NODEID ((int)-2)
120 #define DEVI_SID_HIDDEN_NODEID ((int)-3)
121 #define DEVI_SID_HP_NODEID ((int)-4)
122 #define DEVI_SID_HP_HIDDEN_NODEID ((int)-5)
124 #define DEVI_PSEUDO_NEXNAME "pseudo"
125 #define DEVI_ISA_NEXNAME "isa"
126 #define DEVI_EISA_NEXNAME "eisa"
129 * ddi_create_minor_node flags
131 #define CLONE_DEV 1 /* device is a clone device */
132 #define PRIVONLY_DEV 0x10 /* policy-based permissions only */
135 * Historical values used for the flag field in ddi_create_minor_node.
136 * Future use of flag bits should avoid these fields to keep binary
137 * compatibility
138 * #define GLOBAL_DEV 0x2
139 * #define NODEBOUND_DEV 0x4
140 * #define NODESPECIFIC_DEV 0x6
141 * #define ENUMERATED_DEV 0x8
145 * Device type defines which are used by the 'node_type' element of the
146 * ddi_minor_data structure
148 #define DDI_NT_SERIAL "ddi_serial" /* Serial port */
149 #define DDI_NT_SERIAL_MB "ddi_serial:mb" /* the 'built-in' serial */
150 /* ports (the old ttya, b */
151 /* (,c ,d)) */
152 #define DDI_NT_SERIAL_DO "ddi_serial:dialout" /* dialout ports */
153 #define DDI_NT_SERIAL_MB_DO "ddi_serial:dialout,mb" /* dialout for onboard */
154 /* ports */
155 #define DDI_NT_SERIAL_LOMCON "ddi_serial:lomcon" /* LOMlite2 console port */
158 * *_CHAN disk type devices have channel numbers or target numbers.
159 * (i.e. ipi and scsi devices)
161 #define DDI_NT_BLOCK "ddi_block" /* hard disks */
163 * The next define is for block type devices that can possible exist on
164 * a sub-bus like the scsi bus or the ipi channel. The 'disks' program
165 * will pick up on this and create logical names like c0t0d0s0 instead of
166 * c0d0s0
168 #define DDI_NT_BLOCK_CHAN "ddi_block:channel"
169 #define DDI_NT_BLOCK_WWN "ddi_block:wwn"
170 #define DDI_NT_CD "ddi_block:cdrom" /* rom drives (cd-rom) */
171 #define DDI_NT_CD_CHAN "ddi_block:cdrom:channel" /* rom drives (scsi type) */
172 #define DDI_NT_FD "ddi_block:diskette" /* floppy disks */
174 #define DDI_NT_ENCLOSURE "ddi_enclosure"
175 #define DDI_NT_SCSI_ENCLOSURE "ddi_enclosure:scsi"
177 #define DDI_NT_BLOCK_SAS "ddi_block:sas"
178 #define DDI_NT_BLOCK_BLKDEV "ddi_block:blkdev"
181 * xVM virtual block devices
183 #define DDI_NT_BLOCK_XVMD "ddi_block:xvmd"
184 #define DDI_NT_CD_XVMD "ddi_block:cdrom:xvmd"
187 #define DDI_NT_TAPE "ddi_byte:tape" /* tape drives */
189 #define DDI_NT_NET "ddi_network" /* DLPI network devices */
191 #define DDI_NT_NET_WIFI "ddi_network:wifi" /* wifi devices */
193 #define DDI_NT_DISPLAY "ddi_display" /* display devices */
195 #define DDI_NT_DISPLAY_DRM "ddi_display:drm" /* drm display devices */
197 #define DDI_PSEUDO "ddi_pseudo" /* general pseudo devices */
199 #define DDI_NT_AUDIO "ddi_audio" /* audio device */
201 #define DDI_NT_MOUSE "ddi_mouse" /* mouse device */
203 #define DDI_NT_KEYBOARD "ddi_keyboard" /* keyboard device */
205 #define DDI_NT_PARALLEL "ddi_parallel" /* parallel port */
207 #define DDI_NT_PRINTER "ddi_printer" /* printer device */
209 #define DDI_NT_UGEN "ddi_generic:usb" /* USB generic drv */
211 #define DDI_NT_SMP "ddi_sas_smp" /* smp devcies */
213 #define DDI_NT_NEXUS "ddi_ctl:devctl" /* nexus drivers */
215 #define DDI_NT_NVME_NEXUS "ddi_ctl:devctl:nvme" /* nexus drivers */
217 #define DDI_NT_SCSI_NEXUS "ddi_ctl:devctl:scsi" /* nexus drivers */
219 #define DDI_NT_SATA_NEXUS "ddi_ctl:devctl:sata" /* nexus drivers */
221 #define DDI_NT_IB_NEXUS "ddi_ctl:devctl:ib" /* nexus drivers */
223 #define DDI_NT_ATTACHMENT_POINT "ddi_ctl:attachment_point" /* attachment pt */
225 #define DDI_NT_NVME_ATTACHMENT_POINT "ddi_ctl:attachment_point:nvme"
226 /* nvme attachment pt */
228 #define DDI_NT_SCSI_ATTACHMENT_POINT "ddi_ctl:attachment_point:scsi"
229 /* scsi attachment pt */
231 #define DDI_NT_SATA_ATTACHMENT_POINT "ddi_ctl:attachment_point:sata"
232 /* sata attachment pt */
234 #define DDI_NT_SDCARD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sdcard"
235 /* sdcard attachment pt */
237 #define DDI_NT_PCI_ATTACHMENT_POINT "ddi_ctl:attachment_point:pci"
238 /* PCI attachment pt */
239 #define DDI_NT_SBD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sbd"
240 /* generic bd attachment pt */
241 #define DDI_NT_FC_ATTACHMENT_POINT "ddi_ctl:attachment_point:fc"
242 /* FC attachment pt */
243 #define DDI_NT_USB_ATTACHMENT_POINT "ddi_ctl:attachment_point:usb"
244 /* USB devices */
245 #define DDI_NT_BLOCK_FABRIC "ddi_block:fabric"
246 /* Fabric Devices */
247 #define DDI_NT_IB_ATTACHMENT_POINT "ddi_ctl:attachment_point:ib"
248 /* IB devices */
250 #define DDI_NT_AV_ASYNC "ddi_av:async" /* asynchronous AV device */
251 #define DDI_NT_AV_ISOCH "ddi_av:isoch" /* isochronous AV device */
253 /* Device types used for agpgart driver related devices */
254 #define DDI_NT_AGP_PSEUDO "ddi_agp:pseudo" /* agpgart pseudo device */
255 #define DDI_NT_AGP_MASTER "ddi_agp:master" /* agp master device */
256 #define DDI_NT_AGP_TARGET "ddi_agp:target" /* agp target device */
257 #define DDI_NT_AGP_CPUGART "ddi_agp:cpugart" /* amd64 on-cpu gart device */
259 #define DDI_NT_REGACC "ddi_tool_reg" /* tool register access */
260 #define DDI_NT_INTRCTL "ddi_tool_intr" /* tool intr access */
263 * DDI event definitions
265 #define EC_DEVFS "EC_devfs" /* Event class devfs */
266 #define EC_DDI "EC_ddi" /* Event class ddi */
268 /* Class devfs subclasses */
269 #define ESC_DEVFS_MINOR_CREATE "ESC_devfs_minor_create"
270 #define ESC_DEVFS_MINOR_REMOVE "ESC_devfs_minor_remove"
271 #define ESC_DEVFS_DEVI_ADD "ESC_devfs_devi_add"
272 #define ESC_DEVFS_DEVI_REMOVE "ESC_devfs_devi_remove"
273 #define ESC_DEVFS_INSTANCE_MOD "ESC_devfs_instance_mod"
274 #define ESC_DEVFS_BRANCH_ADD "ESC_devfs_branch_add"
275 #define ESC_DEVFS_BRANCH_REMOVE "ESC_devfs_branch_remove"
276 #define ESC_DEVFS_START "ESC_devfs_start"
278 /* Class ddi subclasses */
279 #define ESC_DDI_INITIATOR_REGISTER "ESC_ddi_initiator_register"
280 #define ESC_DDI_INITIATOR_UNREGISTER "ESC_ddi_initiator_unregister"
282 /* DDI/NDI event publisher */
283 #define EP_DDI SUNW_KERN_PUB"ddi"
286 * devfs event class attributes
288 * The following attributes are private to EC_DEVFS event data.
290 #define DEVFS_DRIVER_NAME "di.driver"
291 #define DEVFS_INSTANCE "di.instance"
292 #define DEVFS_PATHNAME "di.path"
293 #define DEVFS_DEVI_CLASS "di.devi_class"
294 #define DEVFS_BRANCH_EVENT "di.branch_event"
295 #define DEVFS_MINOR_NAME "mi.name"
296 #define DEVFS_MINOR_NODETYPE "mi.nodetype"
297 #define DEVFS_MINOR_ISCLONE "mi.isclone"
298 #define DEVFS_MINOR_MAJNUM "mi.majorno"
299 #define DEVFS_MINOR_MINORNUM "mi.minorno"
302 * ddi event class payload
304 * The following attributes are private to EC_DDI event data.
306 #define DDI_DRIVER_NAME "ddi.driver"
307 #define DDI_DRIVER_MAJOR "ddi.major"
308 #define DDI_INSTANCE "ddi.instance"
309 #define DDI_PATHNAME "ddi.path"
310 #define DDI_CLASS "ddi.class"
313 * Fault-related definitions
315 * The specific numeric values have been chosen to be ordered, but
316 * not consecutive, to allow for future interpolation if required.
318 typedef enum {
319 DDI_SERVICE_LOST = -32,
320 DDI_SERVICE_DEGRADED = -16,
321 DDI_SERVICE_UNAFFECTED = 0,
322 DDI_SERVICE_RESTORED = 16
323 } ddi_fault_impact_t;
325 typedef enum {
326 DDI_DATAPATH_FAULT = -32,
327 DDI_DEVICE_FAULT = -16,
328 DDI_EXTERNAL_FAULT = 0
329 } ddi_fault_location_t;
331 typedef enum {
332 DDI_DEVSTATE_OFFLINE = -32,
333 DDI_DEVSTATE_DOWN = -16,
334 DDI_DEVSTATE_QUIESCED = 0,
335 DDI_DEVSTATE_DEGRADED = 16,
336 DDI_DEVSTATE_UP = 32
337 } ddi_devstate_t;
339 #if defined(_KERNEL)
342 * Common property definitions
344 #define DDI_FORCEATTACH "ddi-forceattach"
345 #define DDI_NO_AUTODETACH "ddi-no-autodetach"
346 #define DDI_VHCI_CLASS "ddi-vhci-class"
347 #define DDI_NO_ROOT_SUPPORT "ddi-no-root-support"
348 #define DDI_OPEN_RETURNS_EINTR "ddi-open-returns-eintr"
349 #define DDI_DEVID_REGISTRANT "ddi-devid-registrant"
352 * Values that the function supplied to the dev_info
353 * tree traversal functions defined below must return.
357 * Continue search, if appropriate.
359 #define DDI_WALK_CONTINUE 0
362 * Terminate current depth of traversal. That is, terminate
363 * the current traversal of children nodes, but continue
364 * traversing sibling nodes and their children (if any).
367 #define DDI_WALK_PRUNECHILD -1
370 * Terminate current width of traversal. That is, terminate
371 * the current traversal of sibling nodes, but continue with
372 * traversing children nodes and their siblings (if appropriate).
375 #define DDI_WALK_PRUNESIB -2
378 * Terminate the entire search.
381 #define DDI_WALK_TERMINATE -3
384 * Terminate the entire search because an error occurred in function
386 #define DDI_WALK_ERROR -4
389 * Drivers that are prepared to support full driver layering
390 * should create and export a null-valued property of the following
391 * name.
393 * Such drivers should be prepared to be called with FKLYR in
394 * the 'flag' argument of their open(9E), close(9E) routines, and
395 * with FKIOCTL in the 'mode' argument of their ioctl(9E) routines.
397 * See ioctl(9E) and ddi_copyin(9F) for details.
399 #define DDI_KERNEL_IOCTL "ddi-kernel-ioctl"
402 * Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F).
404 #define DDI_MODEL_MASK DATAMODEL_MASK /* Note: 0x0FF00000 */
405 #define DDI_MODEL_ILP32 DATAMODEL_ILP32
406 #define DDI_MODEL_LP64 DATAMODEL_LP64
407 #define DDI_MODEL_NATIVE DATAMODEL_NATIVE
408 #define DDI_MODEL_NONE DATAMODEL_NONE
410 /* if set to B_TRUE is DER_MODE is equivalent to DERE_PANIC */
411 extern boolean_t ddi_err_panic;
414 * Defines for ddi_err().
416 typedef enum {
417 DER_INVALID = 0, /* must be 0 */
418 DER_CONT = 1,
419 DER_CONS,
420 DER_LOG,
421 DER_VERB,
422 DER_NOTE,
423 DER_WARN,
424 DER_PANIC,
425 DER_MODE,
426 DER_DEBUG
427 } ddi_err_t;
429 extern void ddi_err(ddi_err_t de, dev_info_t *rdip, const char *fmt, ...);
432 extern char *ddi_strdup(const char *str, int flag);
433 extern char *strdup(const char *str);
434 extern void strfree(char *str);
437 * Functions and data references which really should be in <sys/ddi.h>
440 extern int maxphys;
441 extern void minphys(struct buf *);
442 extern int physio(int (*)(struct buf *), struct buf *, dev_t,
443 int, void (*)(struct buf *), struct uio *);
444 extern void disksort(struct diskhd *, struct buf *);
446 extern size_t strlen(const char *) __PURE;
447 extern size_t strnlen(const char *, size_t) __PURE;
448 extern char *strcpy(char *, const char *);
449 extern char *strncpy(char *, const char *, size_t);
450 /* Need to be consistent with <string.h> C++ definition for strchr() */
451 #if __cplusplus >= 199711L
452 extern const char *strchr(const char *, int);
453 #ifndef _STRCHR_INLINE
454 #define _STRCHR_INLINE
455 extern "C++" {
456 inline char *strchr(char *__s, int __c) {
457 return (char *)strchr((const char *)__s, __c);
460 #endif /* _STRCHR_INLINE */
461 #else
462 extern char *strchr(const char *, int);
463 #endif /* __cplusplus >= 199711L */
464 #define DDI_STRSAME(s1, s2) ((*(s1) == *(s2)) && (strcmp((s1), (s2)) == 0))
465 extern int strcmp(const char *, const char *) __PURE;
466 extern int strncmp(const char *, const char *, size_t) __PURE;
467 extern char *strncat(char *, const char *, size_t);
468 extern size_t strlcat(char *, const char *, size_t);
469 extern size_t strlcpy(char *, const char *, size_t);
470 extern size_t strspn(const char *, const char *);
471 extern size_t strcspn(const char *, const char *);
472 extern char *strsep(char **, const char *);
473 extern int bcmp(const void *, const void *, size_t) __PURE;
474 extern int stoi(char **);
475 extern void numtos(ulong_t, char *);
476 extern void bcopy(const void *, void *, size_t);
477 extern void bzero(void *, size_t);
479 extern void *memcpy(void *, const void *, size_t);
480 extern void *memset(void *, int, size_t);
481 extern void *memmove(void *, const void *, size_t);
482 extern int memcmp(const void *, const void *, size_t) __PURE;
483 /* Need to be consistent with <string.h> C++ definition for memchr() */
484 #if __cplusplus >= 199711L
485 extern const void *memchr(const void *, int, size_t);
486 #ifndef _MEMCHR_INLINE
487 #define _MEMCHR_INLINE
488 extern "C++" {
489 inline void *memchr(void * __s, int __c, size_t __n) {
490 return (void *)memchr((const void *)__s, __c, __n);
493 #endif /* _MEMCHR_INLINE */
494 #else
495 extern void *memchr(const void *, int, size_t);
496 #endif /* __cplusplus >= 199711L */
498 extern int ddi_strtol(const char *, char **, int, long *);
499 extern int ddi_strtoul(const char *, char **, int, unsigned long *);
500 extern int ddi_strtoll(const char *, char **, int, longlong_t *);
501 extern int ddi_strtoull(const char *, char **, int, u_longlong_t *);
504 * kiconv functions and their macros.
506 #define KICONV_IGNORE_NULL (0x0001)
507 #define KICONV_REPLACE_INVALID (0x0002)
509 extern kiconv_t kiconv_open(const char *, const char *);
510 extern size_t kiconv(kiconv_t, char **, size_t *, char **, size_t *, int *);
511 extern int kiconv_close(kiconv_t);
512 extern size_t kiconvstr(const char *, const char *, char *, size_t *, char *,
513 size_t *, int, int *);
516 * ddi_map_regs
518 * Map in the register set given by rnumber.
519 * The register number determine which register
520 * set will be mapped if more than one exists.
521 * The parent driver gets the information
522 * from parent private data and sets up the
523 * appropriate mappings and returns the kernel
524 * virtual address of the register set in *kaddrp.
525 * The offset specifies an offset into the register
526 * space to start from and len indicates the size
527 * of the area to map. If len and offset are 0 then
528 * the entire space is mapped. It returns DDI_SUCCESS on
529 * success or DDI_FAILURE otherwise.
533 ddi_map_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
534 off_t offset, off_t len);
537 * ddi_unmap_regs
539 * Undo mappings set up by ddi_map_regs.
540 * The register number determines which register
541 * set will be unmapped if more than one exists.
542 * This is provided for drivers preparing
543 * to detach themselves from the system to
544 * allow them to release allocated mappings.
546 * The kaddrp and len specify the area to be
547 * unmapped. *kaddrp was returned from ddi_map_regs
548 * and len should match what ddi_map_regs was called
549 * with.
552 void
553 ddi_unmap_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
554 off_t offset, off_t len);
557 ddi_map(dev_info_t *dp, ddi_map_req_t *mp, off_t offset, off_t len,
558 caddr_t *addrp);
561 ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
564 * ddi_rnumber_to_regspec: Not for use by leaf drivers.
566 struct regspec *
567 ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
570 ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
571 off_t len, caddr_t *vaddrp);
574 nullbusmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
575 off_t len, caddr_t *vaddrp);
577 int ddi_peek8(dev_info_t *dip, int8_t *addr, int8_t *val_p);
578 int ddi_peek16(dev_info_t *dip, int16_t *addr, int16_t *val_p);
579 int ddi_peek32(dev_info_t *dip, int32_t *addr, int32_t *val_p);
580 int ddi_peek64(dev_info_t *dip, int64_t *addr, int64_t *val_p);
582 int ddi_poke8(dev_info_t *dip, int8_t *addr, int8_t val);
583 int ddi_poke16(dev_info_t *dip, int16_t *addr, int16_t val);
584 int ddi_poke32(dev_info_t *dip, int32_t *addr, int32_t val);
585 int ddi_poke64(dev_info_t *dip, int64_t *addr, int64_t val);
588 * Peek and poke to and from a uio structure in xfersize pieces,
589 * using the parent nexi.
591 int ddi_peekpokeio(dev_info_t *devi, struct uio *uio, enum uio_rw rw,
592 caddr_t addr, size_t len, uint_t xfersize);
595 * Pagesize conversions using the parent nexi
597 unsigned long ddi_btop(dev_info_t *dip, unsigned long bytes);
598 unsigned long ddi_btopr(dev_info_t *dip, unsigned long bytes);
599 unsigned long ddi_ptob(dev_info_t *dip, unsigned long pages);
602 * There are no more "block" interrupt functions, per se.
603 * All thread of control should be done with MP/MT lockings.
605 * However, there are certain times in which a driver needs
606 * absolutely a critical guaranteed non-preemptable time
607 * in which to execute a few instructions.
609 * The following pair of functions attempt to guarantee this,
610 * but they are dangerous to use. That is, use them with
611 * extreme care. They do not guarantee to stop other processors
612 * from executing, but they do guarantee that the caller
613 * of ddi_enter_critical will continue to run until the
614 * caller calls ddi_exit_critical. No intervening DDI functions
615 * may be called between an entry and an exit from a critical
616 * region.
618 * ddi_enter_critical returns an integer identifier which must
619 * be passed to ddi_exit_critical.
621 * Be very sparing in the use of these functions since it is
622 * likely that absolutely nothing else can occur in the system
623 * whilst in the critical region.
626 unsigned int
627 ddi_enter_critical(void);
629 void
630 ddi_exit_critical(unsigned int);
633 * devmap functions
636 devmap_setup(dev_t dev, offset_t off, ddi_as_handle_t as, caddr_t *addrp,
637 size_t len, uint_t prot, uint_t maxprot, uint_t flags, struct cred *cred);
640 ddi_devmap_segmap(dev_t dev, off_t off, ddi_as_handle_t as, caddr_t *addrp,
641 off_t len, uint_t prot, uint_t maxprot, uint_t flags, struct cred *cred);
644 devmap_load(devmap_cookie_t dhp, offset_t offset, size_t len, uint_t type,
645 uint_t rw);
648 devmap_unload(devmap_cookie_t dhp, offset_t offset, size_t len);
651 devmap_devmem_setup(devmap_cookie_t dhp, dev_info_t *dip,
652 struct devmap_callback_ctl *callback_ops,
653 uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
654 uint_t flags, ddi_device_acc_attr_t *accattrp);
657 devmap_umem_setup(devmap_cookie_t dhp, dev_info_t *dip,
658 struct devmap_callback_ctl *callback_ops,
659 ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
660 uint_t flags, ddi_device_acc_attr_t *accattrp);
663 devmap_devmem_remap(devmap_cookie_t dhp, dev_info_t *dip,
664 uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
665 uint_t flags, ddi_device_acc_attr_t *accattrp);
668 devmap_umem_remap(devmap_cookie_t dhp, dev_info_t *dip,
669 ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
670 uint_t flags, ddi_device_acc_attr_t *accattrp);
672 void
673 devmap_set_ctx_timeout(devmap_cookie_t dhp, clock_t ticks);
676 devmap_default_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
677 size_t len, uint_t type, uint_t rw);
680 devmap_do_ctxmgt(devmap_cookie_t dhp, void *pvtp, offset_t off, size_t len,
681 uint_t type, uint_t rw, int (*ctxmgt)(devmap_cookie_t, void *, offset_t,
682 size_t, uint_t, uint_t));
685 void *ddi_umem_alloc(size_t size, int flag, ddi_umem_cookie_t *cookiep);
687 void ddi_umem_free(ddi_umem_cookie_t cookie);
690 * Functions to lock user memory and do repeated I/O or do devmap_umem_setup
693 ddi_umem_lock(caddr_t addr, size_t size, int flags, ddi_umem_cookie_t *cookie);
695 void
696 ddi_umem_unlock(ddi_umem_cookie_t cookie);
698 struct buf *
699 ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction,
700 dev_t dev, daddr_t blkno, int (*iodone)(struct buf *), int sleepflag);
703 * Mapping functions
706 ddi_segmap(dev_t dev, off_t offset, struct as *asp, caddr_t *addrp, off_t len,
707 uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp);
710 ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, caddr_t *addrp,
711 off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cred,
712 ddi_device_acc_attr_t *accattrp, uint_t rnumber);
715 ddi_map_fault(dev_info_t *dip, struct hat *hat, struct seg *seg, caddr_t addr,
716 struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
719 ddi_device_mapping_check(dev_t dev, ddi_device_acc_attr_t *accattrp,
720 uint_t rnumber, uint_t *hat_flags);
723 * Property functions: See also, ddipropdefs.h.
724 * In general, the underlying driver MUST be held
725 * to call it's property functions.
729 * Used to create, modify, and lookup integer properties
731 int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags,
732 char *name, int defvalue);
733 int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags,
734 char *name, int64_t defvalue);
735 int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
736 char *name, int **data, uint_t *nelements);
737 int ddi_prop_lookup_int64_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
738 char *name, int64_t **data, uint_t *nelements);
739 int ddi_prop_update_int(dev_t match_dev, dev_info_t *dip,
740 char *name, int data);
741 int ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip,
742 char *name, int64_t data);
743 int ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip,
744 char *name, int *data, uint_t nelements);
745 int ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip,
746 char *name, int64_t *data, uint_t nelements);
748 * Used to create, modify, and lookup string properties
750 int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, uint_t flags,
751 char *name, char **data);
752 int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
753 char *name, char ***data, uint_t *nelements);
754 int ddi_prop_update_string(dev_t match_dev, dev_info_t *dip,
755 char *name, char *data);
756 int ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
757 char *name, char **data, uint_t nelements);
760 * Used to create, modify, and lookup byte properties
762 int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
763 char *name, uchar_t **data, uint_t *nelements);
764 int ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
765 char *name, uchar_t *data, uint_t nelements);
768 * Used to verify the existence of a property or to see if a boolean
769 * property exists.
771 int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name);
774 * Used to free the data returned by the above property routines.
776 void ddi_prop_free(void *data);
779 * nopropop: For internal use in `dummy' cb_prop_op functions only
783 nopropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
784 char *name, caddr_t valuep, int *lengthp);
787 * ddi_prop_op: The basic property operator for drivers.
789 * In ddi_prop_op, the type of valuep is interpreted based on prop_op:
791 * prop_op valuep
792 * ------ ------
794 * PROP_LEN <unused>
796 * PROP_LEN_AND_VAL_BUF Pointer to callers buffer
798 * PROP_LEN_AND_VAL_ALLOC Address of callers pointer (will be set to
799 * address of allocated buffer, if successful)
803 ddi_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
804 char *name, caddr_t valuep, int *lengthp);
806 /* ddi_prop_op_size: for drivers that implement size in bytes */
808 ddi_prop_op_size(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
809 int mod_flags, char *name, caddr_t valuep, int *lengthp,
810 uint64_t size64);
812 /* ddi_prop_op_size_blksize: like ddi_prop_op_size, in blksize blocks */
814 ddi_prop_op_size_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
815 int mod_flags, char *name, caddr_t valuep, int *lengthp,
816 uint64_t size64, uint_t blksize);
818 /* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */
820 ddi_prop_op_nblocks(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
821 int mod_flags, char *name, caddr_t valuep, int *lengthp,
822 uint64_t nblocks64);
824 /* ddi_prop_op_nblocks_blksize: like ddi_prop_op_nblocks, in blksize blocks */
826 ddi_prop_op_nblocks_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
827 int mod_flags, char *name, caddr_t valuep, int *lengthp,
828 uint64_t nblocks64, uint_t blksize);
831 * Variable length props...
835 * ddi_getlongprop: Get variable length property len+val into a buffer
836 * allocated by property provider via kmem_alloc. Requester
837 * is responsible for freeing returned property via kmem_free.
839 * Arguments:
841 * dev: Input: dev_t of property.
842 * dip: Input: dev_info_t pointer of child.
843 * flags: Input: Possible flag modifiers are:
844 * DDI_PROP_DONTPASS: Don't pass to parent if prop not found.
845 * DDI_PROP_CANSLEEP: Memory allocation may sleep.
846 * name: Input: name of property.
847 * valuep: Output: Addr of callers buffer pointer.
848 * lengthp:Output: *lengthp will contain prop length on exit.
850 * Possible Returns:
852 * DDI_PROP_SUCCESS: Prop found and returned.
853 * DDI_PROP_NOT_FOUND: Prop not found
854 * DDI_PROP_UNDEFINED: Prop explicitly undefined.
855 * DDI_PROP_NO_MEMORY: Prop found, but unable to alloc mem.
859 ddi_getlongprop(dev_t dev, dev_info_t *dip, int flags,
860 char *name, caddr_t valuep, int *lengthp);
864 * ddi_getlongprop_buf: Get long prop into pre-allocated callers
865 * buffer. (no memory allocation by provider).
867 * dev: Input: dev_t of property.
868 * dip: Input: dev_info_t pointer of child.
869 * flags: Input: DDI_PROP_DONTPASS or NULL
870 * name: Input: name of property
871 * valuep: Input: ptr to callers buffer.
872 * lengthp:I/O: ptr to length of callers buffer on entry,
873 * actual length of property on exit.
875 * Possible returns:
877 * DDI_PROP_SUCCESS Prop found and returned
878 * DDI_PROP_NOT_FOUND Prop not found
879 * DDI_PROP_UNDEFINED Prop explicitly undefined.
880 * DDI_PROP_BUF_TOO_SMALL Prop found, callers buf too small,
881 * no value returned, but actual prop
882 * length returned in *lengthp
887 ddi_getlongprop_buf(dev_t dev, dev_info_t *dip, int flags,
888 char *name, caddr_t valuep, int *lengthp);
891 * Integer/boolean sized props.
893 * Call is value only... returns found boolean or int sized prop value or
894 * defvalue if prop not found or is wrong length or is explicitly undefined.
895 * Only flag is DDI_PROP_DONTPASS...
897 * By convention, this interface returns boolean (0) sized properties
898 * as value (int)1.
902 ddi_getprop(dev_t dev, dev_info_t *dip, int flags, char *name, int defvalue);
905 * Get prop length interface: flags are 0 or DDI_PROP_DONTPASS
906 * if returns DDI_PROP_SUCCESS, length returned in *lengthp.
910 ddi_getproplen(dev_t dev, dev_info_t *dip, int flags, char *name, int *lengthp);
914 * Interface to create/modify a managed property on child's behalf...
915 * Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep
916 * if no memory available for internal prop structure. Long property
917 * (non integer sized) value references are not copied.
919 * Define property with DDI_DEV_T_NONE dev_t for properties not associated
920 * with any particular dev_t. Use the same dev_t when modifying or undefining
921 * a property.
923 * No guarantee on order of property search, so don't mix the same
924 * property name with wildcard and non-wildcard dev_t's.
928 * ddi_prop_create: Define a managed property:
932 ddi_prop_create(dev_t dev, dev_info_t *dip, int flag,
933 char *name, caddr_t value, int length);
936 * ddi_prop_modify: Modify a managed property value
940 ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag,
941 char *name, caddr_t value, int length);
944 * ddi_prop_remove: Undefine a managed property:
948 ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
951 * ddi_prop_remove_all: Used before unloading a driver to remove
952 * all properties. (undefines all dev_t's props.)
953 * Also removes `undefined' prop defs.
956 void
957 ddi_prop_remove_all(dev_info_t *dip);
961 * ddi_prop_undefine: Explicitly undefine a property. Property
962 * searches which match this property return
963 * the error code DDI_PROP_UNDEFINED.
965 * Use ddi_prop_remove to negate effect of
966 * ddi_prop_undefine
970 ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name);
974 * ddi_prop_cache_invalidate
975 * Invalidate a property in the current cached
976 * devinfo snapshot - next cached snapshot will
977 * return the latest property value available.
979 void
980 ddi_prop_cache_invalidate(dev_t dev, dev_info_t *dip, char *name, int flags);
983 * The default ddi_bus_prop_op wrapper...
987 ddi_bus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip,
988 ddi_prop_op_t prop_op, int mod_flags,
989 char *name, caddr_t valuep, int *lengthp);
993 * Routines to traverse the tree of dev_info nodes.
994 * The general idea of these functions is to provide
995 * various tree traversal utilities. For each node
996 * that the tree traversal function finds, a caller
997 * supplied function is called with arguments of
998 * the current node and a caller supplied argument.
999 * The caller supplied function should return one
1000 * of the integer values defined below which will
1001 * indicate to the tree traversal function whether
1002 * the traversal should be continued, and if so, how,
1003 * or whether the traversal should terminate.
1007 * This general-purpose routine traverses the tree of dev_info nodes,
1008 * starting from the given node, and calls the given function for each
1009 * node that it finds with the current node and the pointer arg (which
1010 * can point to a structure of information that the function
1011 * needs) as arguments.
1013 * It does the walk a layer at a time, not depth-first.
1015 * The given function must return one of the values defined above.
1019 void
1020 ddi_walk_devs(dev_info_t *, int (*)(dev_info_t *, void *), void *);
1023 * Routines to get at elements of the dev_info structure
1027 * ddi_node_name gets the device's 'name' from the device node.
1029 * ddi_binding_name gets the string the OS used to bind the node to a driver,
1030 * in certain cases, the binding name may be different from the node name,
1031 * if the node name does not name a specific device driver.
1033 * ddi_get_name is a synonym for ddi_binding_name().
1035 char *
1036 ddi_get_name(dev_info_t *dip);
1038 char *
1039 ddi_binding_name(dev_info_t *dip);
1041 const char *
1042 ddi_driver_name(dev_info_t *dip);
1044 major_t
1045 ddi_driver_major(dev_info_t *dip);
1047 major_t
1048 ddi_compatible_driver_major(dev_info_t *dip, char **formp);
1050 char *
1051 ddi_node_name(dev_info_t *dip);
1054 ddi_get_nodeid(dev_info_t *dip);
1057 ddi_get_instance(dev_info_t *dip);
1059 struct dev_ops *
1060 ddi_get_driver(dev_info_t *dip);
1062 void
1063 ddi_set_driver(dev_info_t *dip, struct dev_ops *devo);
1065 void
1066 ddi_set_driver_private(dev_info_t *dip, void *data);
1068 void *
1069 ddi_get_driver_private(dev_info_t *dip);
1072 * ddi_dev_is_needed tells system that a device is about to use a
1073 * component. Returns when component is ready.
1076 ddi_dev_is_needed(dev_info_t *dip, int cmpt, int level);
1079 * check if DDI_SUSPEND may result in power being removed from a device.
1082 ddi_removing_power(dev_info_t *dip);
1085 * (Obsolete) power entry point
1088 ddi_power(dev_info_t *dip, int cmpt, int level);
1091 * ddi_get_parent requires that the branch of the tree with the
1092 * node be held (ddi_hold_installed_driver) or that the devinfo tree
1093 * lock be held
1095 dev_info_t *
1096 ddi_get_parent(dev_info_t *dip);
1099 * ddi_get_child and ddi_get_next_sibling require that the devinfo
1100 * tree lock be held
1102 dev_info_t *
1103 ddi_get_child(dev_info_t *dip);
1105 dev_info_t *
1106 ddi_get_next_sibling(dev_info_t *dip);
1108 dev_info_t *
1109 ddi_get_next(dev_info_t *dip);
1111 void
1112 ddi_set_next(dev_info_t *dip, dev_info_t *nextdip);
1115 * dev_info manipulation functions
1119 * Add and remove child devices. These are part of the system framework.
1121 * ddi_add_child creates a dev_info structure with the passed name,
1122 * nodeid and instance arguments and makes it a child of pdip. Devices
1123 * that are known directly by the hardware have real nodeids; devices
1124 * that are software constructs use the defined DEVI_PSEUDO_NODEID
1125 * for the node id.
1127 * ddi_remove_node removes the node from the tree. This fails if this
1128 * child has children. Parent and driver private data should already
1129 * be released (freed) prior to calling this function. If flag is
1130 * non-zero, the child is removed from it's linked list of instances.
1132 dev_info_t *
1133 ddi_add_child(dev_info_t *pdip, char *name, uint_t nodeid, uint_t instance);
1136 ddi_remove_child(dev_info_t *dip, int flag);
1139 * Given the major number for a driver, make sure that dev_info nodes
1140 * are created form the driver's hwconf file, the driver for the named
1141 * device is loaded and attached, as well as any drivers for parent devices.
1142 * Return a pointer to the driver's dev_ops struct with the dev_ops held.
1143 * Note - Callers must release the dev_ops with ddi_rele_driver.
1145 * When a driver is held, the branch of the devinfo tree from any of the
1146 * drivers devinfos to the root node are automatically held. This only
1147 * applies to tree traversals up (and back down) the tree following the
1148 * parent pointers.
1150 * Use of this interface is discouraged, it may be removed in a future release.
1152 struct dev_ops *
1153 ddi_hold_installed_driver(major_t major);
1155 void
1156 ddi_rele_driver(major_t major);
1159 * Attach and hold the specified instance of a driver. The flags argument
1160 * should be zero.
1162 dev_info_t *
1163 ddi_hold_devi_by_instance(major_t major, int instance, int flags);
1165 void
1166 ddi_release_devi(dev_info_t *);
1169 * Associate a streams queue with a devinfo node
1171 void
1172 ddi_assoc_queue_with_devi(queue_t *, dev_info_t *);
1175 * Given the identifier string passed, make sure that dev_info nodes
1176 * are created form the driver's hwconf file, the driver for the named
1177 * device is loaded and attached, as well as any drivers for parent devices.
1179 * Note that the driver is not held and is subject to being removed the instant
1180 * this call completes. You probably really want ddi_hold_installed_driver.
1183 ddi_install_driver(char *idstring);
1186 * Routines that return specific nodes
1189 dev_info_t *
1190 ddi_root_node(void);
1193 * Given a name and an instance number, find and return the
1194 * dev_info from the current state of the device tree.
1196 * If instance number is -1, return the first named instance.
1198 * If attached is 1, exclude all nodes that are < DS_ATTACHED
1200 * Requires that the devinfo tree be locked.
1201 * If attached is 1, the driver must be held.
1203 dev_info_t *
1204 ddi_find_devinfo(char *name, int instance, int attached);
1207 * Synchronization of I/O with respect to various
1208 * caches and system write buffers.
1210 * Done at varying points during an I/O transfer (including at the
1211 * removal of an I/O mapping).
1213 * Due to the support of systems with write buffers which may
1214 * not be able to be turned off, this function *must* used at
1215 * any point in which data consistency might be required.
1217 * Generally this means that if a memory object has multiple mappings
1218 * (both for I/O, as described by the handle, and the IU, via, e.g.
1219 * a call to ddi_dma_kvaddrp), and one mapping may have been
1220 * used to modify the memory object, this function must be called
1221 * to ensure that the modification of the memory object is
1222 * complete, as well as possibly to inform other mappings of
1223 * the object that any cached references to the object are
1224 * now stale (and flush or invalidate these stale cache references
1225 * as necessary).
1227 * The function ddi_dma_sync() provides the general interface with
1228 * respect to this capability. Generally, ddi_dma_free() (below) may
1229 * be used in preference to ddi_dma_sync() as ddi_dma_free() calls
1230 * ddi_dma_sync().
1232 * Returns 0 if all caches that exist and are specified by cache_flags
1233 * are successfully operated on, else -1.
1235 * The argument offset specifies an offset into the mapping of the mapped
1236 * object in which to perform the synchronization. It will be silently
1237 * truncated to the granularity of underlying cache line sizes as
1238 * appropriate.
1240 * The argument len specifies a length starting from offset in which to
1241 * perform the synchronization. A value of (uint_t) -1 means that the length
1242 * proceeds from offset to the end of the mapping. The length argument
1243 * will silently rounded up to the granularity of underlying cache line
1244 * sizes as appropriate.
1246 * The argument flags specifies what to synchronize (the device's view of
1247 * the object or the cpu's view of the object).
1249 * Inquiring minds want to know when ddi_dma_sync should be used:
1251 * + When an object is mapped for dma, assume that an
1252 * implicit ddi_dma_sync() is done for you.
1254 * + When an object is unmapped (ddi_dma_free()), assume
1255 * that an implicit ddi_dma_sync() is done for you.
1257 * + At any time between the two times above that the
1258 * memory object may have been modified by either
1259 * the DMA device or a processor and you wish that
1260 * the change be noticed by the master that didn't
1261 * do the modifying.
1263 * Clearly, only the third case above requires the use of ddi_dma_sync.
1265 * Inquiring minds also want to know which flag to use:
1267 * + If you *modify* with a cpu the object, you use
1268 * ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure
1269 * that the DMA device sees the changes you made).
1271 * + If you are checking, with the processor, an area
1272 * of the object that the DMA device *may* have modified,
1273 * you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are
1274 * making sure that the processor(s) will see the changes
1275 * that the DMA device may have made).
1279 ddi_dma_sync(ddi_dma_handle_t handle, off_t offset, size_t len, uint_t flags);
1282 * Return the allowable DMA burst size for the object mapped by handle.
1283 * The burst sizes will returned in an integer that encodes power
1284 * of two burst sizes that are allowed in bit encoded format. For
1285 * example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts
1286 * would be encoded as 0x2f. A transfer that could be allowed as solely
1287 * a halfword (2 byte) transfers would be returned as 0x2.
1291 ddi_dma_burstsizes(ddi_dma_handle_t handle);
1294 * Merge DMA attributes
1297 void
1298 ddi_dma_attr_merge(ddi_dma_attr_t *attr, ddi_dma_attr_t *mod);
1301 * Allocate a DMA handle
1305 ddi_dma_alloc_handle(dev_info_t *dip, ddi_dma_attr_t *attr,
1306 int (*waitfp)(caddr_t), caddr_t arg,
1307 ddi_dma_handle_t *handlep);
1310 * Free DMA handle
1313 void
1314 ddi_dma_free_handle(ddi_dma_handle_t *handlep);
1317 * Allocate memory for DMA transfers
1321 ddi_dma_mem_alloc(ddi_dma_handle_t handle, size_t length,
1322 ddi_device_acc_attr_t *accattrp, uint_t xfermodes,
1323 int (*waitfp)(caddr_t), caddr_t arg, caddr_t *kaddrp,
1324 size_t *real_length, ddi_acc_handle_t *handlep);
1327 * Free DMA memory
1330 void
1331 ddi_dma_mem_free(ddi_acc_handle_t *hp);
1334 * bind address to a DMA handle
1338 ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as,
1339 caddr_t addr, size_t len, uint_t flags,
1340 int (*waitfp)(caddr_t), caddr_t arg,
1341 ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1344 * bind buffer to DMA handle
1348 ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp,
1349 uint_t flags, int (*waitfp)(caddr_t), caddr_t arg,
1350 ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1353 * unbind mapping object to handle
1357 ddi_dma_unbind_handle(ddi_dma_handle_t handle);
1360 * get next DMA cookie
1363 void
1364 ddi_dma_nextcookie(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep);
1367 * get number of DMA windows
1371 ddi_dma_numwin(ddi_dma_handle_t handle, uint_t *nwinp);
1374 * get specific DMA window
1378 ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp,
1379 size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1382 * activate 64 bit SBus support
1386 ddi_dma_set_sbus64(ddi_dma_handle_t handle, ulong_t burstsizes);
1389 * Miscellaneous functions
1393 * ddi_report_dev: Report a successful attach.
1396 void
1397 ddi_report_dev(dev_info_t *dev);
1400 * ddi_dev_regsize
1402 * If the device has h/w register(s), report
1403 * the size, in bytes, of the specified one into *resultp.
1405 * Returns DDI_FAILURE if there are not registers,
1406 * or the specified register doesn't exist.
1410 ddi_dev_regsize(dev_info_t *dev, uint_t rnumber, off_t *resultp);
1413 * ddi_dev_nregs
1415 * If the device has h/w register(s), report
1416 * how many of them that there are into resultp.
1417 * Return DDI_FAILURE if the device has no registers.
1421 ddi_dev_nregs(dev_info_t *dev, int *resultp);
1424 * ddi_dev_is_sid
1426 * If the device is self-identifying, i.e.,
1427 * has already been probed by a smart PROM
1428 * (and thus registers are known to be valid)
1429 * return DDI_SUCCESS, else DDI_FAILURE.
1434 ddi_dev_is_sid(dev_info_t *dev);
1437 * ddi_slaveonly
1439 * If the device is on a bus that precludes
1440 * the device from being either a dma master or
1441 * a dma slave, return DDI_SUCCESS.
1445 ddi_slaveonly(dev_info_t *);
1449 * ddi_dev_affinity
1451 * Report, via DDI_SUCCESS, whether there exists
1452 * an 'affinity' between two dev_info_t's. An
1453 * affinity is defined to be either a parent-child,
1454 * or a sibling relationship such that the siblings
1455 * or in the same part of the bus they happen to be
1456 * on.
1460 ddi_dev_affinity(dev_info_t *deva, dev_info_t *devb);
1464 * ddi_set_callback
1466 * Set a function/arg pair into the callback list identified
1467 * by listid. *listid must always initially start out as zero.
1470 void
1471 ddi_set_callback(int (*funcp)(caddr_t), caddr_t arg, uintptr_t *listid);
1474 * ddi_run_callback
1476 * Run the callback list identified by listid.
1479 void
1480 ddi_run_callback(uintptr_t *listid);
1483 * More miscellaneous
1487 nochpoll(dev_t dev, short events, int anyyet, short *reventsp,
1488 struct pollhead **phpp);
1490 dev_info_t *
1491 nodevinfo(dev_t dev, int otyp);
1494 ddi_no_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result);
1497 ddi_getinfo_1to1(dev_info_t *dip, ddi_info_cmd_t infocmd,
1498 void *arg, void **result);
1501 ddifail(dev_info_t *devi, ddi_attach_cmd_t cmd);
1504 ddi_no_dma_map(dev_info_t *dip, dev_info_t *rdip,
1505 struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
1508 ddi_no_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
1509 int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
1512 ddi_no_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
1513 ddi_dma_handle_t handle);
1516 ddi_no_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
1517 ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
1518 ddi_dma_cookie_t *cp, uint_t *ccountp);
1521 ddi_no_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
1522 ddi_dma_handle_t handle);
1525 ddi_no_dma_flush(dev_info_t *dip, dev_info_t *rdip,
1526 ddi_dma_handle_t handle, off_t off, size_t len,
1527 uint_t cache_flags);
1530 ddi_no_dma_win(dev_info_t *dip, dev_info_t *rdip,
1531 ddi_dma_handle_t handle, uint_t win, off_t *offp,
1532 size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1535 ddi_no_dma_mctl(register dev_info_t *dip, dev_info_t *rdip,
1536 ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
1537 off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags);
1539 void
1540 ddivoid();
1542 cred_t *
1543 ddi_get_cred(void);
1545 time_t
1546 ddi_get_time(void);
1548 pid_t
1549 ddi_get_pid(void);
1551 kt_did_t
1552 ddi_get_kt_did(void);
1554 boolean_t
1555 ddi_can_receive_sig(void);
1557 void
1558 swab(void *src, void *dst, size_t nbytes);
1561 ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type,
1562 minor_t minor_num, char *node_type, int flag);
1565 ddi_create_priv_minor_node(dev_info_t *dip, char *name, int spec_type,
1566 minor_t minor_num, char *node_type, int flag,
1567 const char *rdpriv, const char *wrpriv, mode_t priv_mode);
1569 void
1570 ddi_remove_minor_node(dev_info_t *dip, char *name);
1573 ddi_in_panic(void);
1576 ddi_streams_driver(dev_info_t *dip);
1579 * DDI wrappers for ffs and fls
1582 ddi_ffs(long mask);
1585 ddi_fls(long mask);
1588 * The ddi_soft_state* routines comprise generic storage management utilities
1589 * for driver soft state structures. Two types of soft_state indexes are
1590 * supported: 'integer index', and 'string index'.
1592 typedef struct __ddi_soft_state_bystr ddi_soft_state_bystr;
1595 * Initialize a soft_state set, establishing the 'size' of soft state objects
1596 * in the set.
1598 * For an 'integer indexed' soft_state set, the initial set will accommodate
1599 * 'n_items' objects - 'n_items' is a hint (i.e. zero is allowed), allocations
1600 * that exceed 'n_items' have additional overhead.
1602 * For a 'string indexed' soft_state set, 'n_items' should be the typical
1603 * number of soft state objects in the set - 'n_items' is a hint, there may
1604 * be additional overhead if the hint is too small (and wasted memory if the
1605 * hint is too big).
1608 ddi_soft_state_init(void **state_p, size_t size, size_t n_items);
1610 ddi_soft_state_bystr_init(ddi_soft_state_bystr **state_p,
1611 size_t size, int n_items);
1614 * Allocate a soft state object associated with either 'integer index' or
1615 * 'string index' from a soft_state set.
1618 ddi_soft_state_zalloc(void *state, int item);
1620 ddi_soft_state_bystr_zalloc(ddi_soft_state_bystr *state, const char *str);
1623 * Get the pointer to the allocated soft state object associated with
1624 * either 'integer index' or 'string index'.
1626 void *
1627 ddi_get_soft_state(void *state, int item);
1628 void *
1629 ddi_soft_state_bystr_get(ddi_soft_state_bystr *state, const char *str);
1632 * Free the soft state object associated with either 'integer index'
1633 * or 'string index'.
1635 void
1636 ddi_soft_state_free(void *state, int item);
1637 void
1638 ddi_soft_state_bystr_free(ddi_soft_state_bystr *state, const char *str);
1641 * Free the soft state set and any associated soft state objects.
1643 void
1644 ddi_soft_state_fini(void **state_p);
1645 void
1646 ddi_soft_state_bystr_fini(ddi_soft_state_bystr **state_p);
1649 * The ddi_strid_* routines provide string-to-index management utilities.
1651 typedef struct __ddi_strid ddi_strid;
1653 ddi_strid_init(ddi_strid **strid_p, int n_items);
1654 id_t
1655 ddi_strid_alloc(ddi_strid *strid, char *str);
1656 id_t
1657 ddi_strid_str2id(ddi_strid *strid, char *str);
1658 char *
1659 ddi_strid_id2str(ddi_strid *strid, id_t id);
1660 void
1661 ddi_strid_free(ddi_strid *strid, id_t id);
1662 void
1663 ddi_strid_fini(ddi_strid **strid_p);
1666 * Set the addr field of the name in dip to name
1668 void
1669 ddi_set_name_addr(dev_info_t *dip, char *name);
1672 * Get the address part of the name.
1674 char *
1675 ddi_get_name_addr(dev_info_t *dip);
1677 void
1678 ddi_set_parent_data(dev_info_t *dip, void *pd);
1680 void *
1681 ddi_get_parent_data(dev_info_t *dip);
1684 ddi_initchild(dev_info_t *parent, dev_info_t *proto);
1687 ddi_uninitchild(dev_info_t *dip);
1689 major_t
1690 ddi_name_to_major(char *name);
1692 char *
1693 ddi_major_to_name(major_t major);
1695 char *
1696 ddi_deviname(dev_info_t *dip, char *name);
1698 char *
1699 ddi_pathname(dev_info_t *dip, char *path);
1701 char *
1702 ddi_pathname_minor(struct ddi_minor_data *dmdp, char *path);
1704 char *
1705 ddi_pathname_obp(dev_info_t *dip, char *path);
1708 ddi_pathname_obp_set(dev_info_t *dip, char *component);
1711 ddi_dev_pathname(dev_t devt, int spec_type, char *name);
1713 dev_t
1714 ddi_pathname_to_dev_t(char *pathname);
1717 * High resolution system timer functions.
1719 * These functions are already in the kernel (see sys/time.h).
1720 * The ddi supports the notion of a hrtime_t type and the
1721 * functions gethrtime, hrtadd, hrtsub and hrtcmp.
1726 * Nexus wrapper functions
1728 * These functions are for entries in a bus nexus driver's bus_ops
1729 * structure for when the driver doesn't have such a function and
1730 * doesn't wish to prohibit such a function from existing. They
1731 * may also be called to start passing a request up the dev_info
1732 * tree.
1736 * bus_ctl wrapper
1740 ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v);
1743 * bus_dma_map wrapper
1747 ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
1748 int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
1751 ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
1752 ddi_dma_handle_t handle);
1755 ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
1756 ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
1757 ddi_dma_cookie_t *cp, uint_t *ccountp);
1760 ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
1761 ddi_dma_handle_t handle);
1764 ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip,
1765 ddi_dma_handle_t handle, off_t off, size_t len,
1766 uint_t cache_flags);
1769 ddi_dma_win(dev_info_t *dip, dev_info_t *rdip,
1770 ddi_dma_handle_t handle, uint_t win, off_t *offp,
1771 size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1774 * bus_dma_ctl wrapper
1778 ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
1779 enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
1780 caddr_t *objp, uint_t flags);
1783 * dvma support for networking drivers
1786 unsigned long
1787 dvma_pagesize(dev_info_t *dip);
1790 dvma_reserve(dev_info_t *dip, ddi_dma_lim_t *limp, uint_t pages,
1791 ddi_dma_handle_t *handlep);
1793 void
1794 dvma_release(ddi_dma_handle_t h);
1796 void
1797 dvma_kaddr_load(ddi_dma_handle_t h, caddr_t a, uint_t len, uint_t index,
1798 ddi_dma_cookie_t *cp);
1800 void
1801 dvma_unload(ddi_dma_handle_t h, uint_t objindex, uint_t type);
1803 void
1804 dvma_sync(ddi_dma_handle_t h, uint_t objindex, uint_t type);
1807 * Layered driver support
1810 extern int ddi_copyin(const void *, void *, size_t, int);
1811 extern int ddi_copyout(const void *, void *, size_t, int);
1814 * Send signals to processes
1816 extern void *proc_ref(void);
1817 extern void proc_unref(void *pref);
1818 extern int proc_signal(void *pref, int sig);
1820 /* I/O port access routines */
1821 extern uint8_t inb(int port);
1822 extern uint16_t inw(int port);
1823 extern uint32_t inl(int port);
1824 extern void outb(int port, uint8_t value);
1825 extern void outw(int port, uint16_t value);
1826 extern void outl(int port, uint32_t value);
1829 * Console bell routines
1831 extern void ddi_ring_console_bell(clock_t duration);
1832 extern void ddi_set_console_bell(void (*bellfunc)(clock_t duration));
1835 * Fault-related functions
1837 extern int ddi_check_acc_handle(ddi_acc_handle_t);
1838 extern int ddi_check_dma_handle(ddi_dma_handle_t);
1839 extern void ddi_dev_report_fault(dev_info_t *, ddi_fault_impact_t,
1840 ddi_fault_location_t, const char *);
1841 extern ddi_devstate_t ddi_get_devstate(dev_info_t *);
1844 * Miscellaneous redefines
1846 #define uiophysio physio
1849 * utilities - "reg" mapping and all common portable data access functions
1853 * error code from ddi_regs_map_setup
1856 #define DDI_REGS_ACC_CONFLICT (-10)
1859 * Device address advance flags
1862 #define DDI_DEV_NO_AUTOINCR 0x0000
1863 #define DDI_DEV_AUTOINCR 0x0001
1866 ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber, caddr_t *addrp,
1867 offset_t offset, offset_t len, ddi_device_acc_attr_t *accattrp,
1868 ddi_acc_handle_t *handle);
1870 void
1871 ddi_regs_map_free(ddi_acc_handle_t *handle);
1874 * these are the prototypes for the common portable data access functions
1877 uint8_t
1878 ddi_get8(ddi_acc_handle_t handle, uint8_t *addr);
1880 uint16_t
1881 ddi_get16(ddi_acc_handle_t handle, uint16_t *addr);
1883 uint32_t
1884 ddi_get32(ddi_acc_handle_t handle, uint32_t *addr);
1886 uint64_t
1887 ddi_get64(ddi_acc_handle_t handle, uint64_t *addr);
1889 void
1890 ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
1891 size_t repcount, uint_t flags);
1893 void
1894 ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
1895 size_t repcount, uint_t flags);
1897 void
1898 ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
1899 size_t repcount, uint_t flags);
1901 void
1902 ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
1903 size_t repcount, uint_t flags);
1905 void
1906 ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value);
1908 void
1909 ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value);
1911 void
1912 ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value);
1914 void
1915 ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value);
1917 void
1918 ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
1919 size_t repcount, uint_t flags);
1920 void
1921 ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
1922 size_t repcount, uint_t flags);
1923 void
1924 ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
1925 size_t repcount, uint_t flags);
1927 void
1928 ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
1929 size_t repcount, uint_t flags);
1932 * these are special device handling functions
1935 ddi_device_zero(ddi_acc_handle_t handle, caddr_t dev_addr,
1936 size_t bytecount, ssize_t dev_advcnt, uint_t dev_datasz);
1939 ddi_device_copy(
1940 ddi_acc_handle_t src_handle, caddr_t src_addr, ssize_t src_advcnt,
1941 ddi_acc_handle_t dest_handle, caddr_t dest_addr, ssize_t dest_advcnt,
1942 size_t bytecount, uint_t dev_datasz);
1945 * these are software byte swapping functions
1947 uint16_t
1948 ddi_swap16(uint16_t value);
1950 uint32_t
1951 ddi_swap32(uint32_t value);
1953 uint64_t
1954 ddi_swap64(uint64_t value);
1957 * these are the prototypes for PCI local bus functions
1960 * PCI power management capabilities reporting in addition to those
1961 * provided by the PCI Power Management Specification.
1963 #define PCI_PM_IDLESPEED 0x1 /* clock for idle dev - cap */
1964 #define PCI_PM_IDLESPEED_ANY (void *)-1 /* any clock for idle dev */
1965 #define PCI_PM_IDLESPEED_NONE (void *)-2 /* regular clock for idle dev */
1968 pci_config_setup(dev_info_t *dip, ddi_acc_handle_t *handle);
1970 void
1971 pci_config_teardown(ddi_acc_handle_t *handle);
1973 uint8_t
1974 pci_config_get8(ddi_acc_handle_t handle, off_t offset);
1976 uint16_t
1977 pci_config_get16(ddi_acc_handle_t handle, off_t offset);
1979 uint32_t
1980 pci_config_get32(ddi_acc_handle_t handle, off_t offset);
1982 uint64_t
1983 pci_config_get64(ddi_acc_handle_t handle, off_t offset);
1985 void
1986 pci_config_put8(ddi_acc_handle_t handle, off_t offset, uint8_t value);
1988 void
1989 pci_config_put16(ddi_acc_handle_t handle, off_t offset, uint16_t value);
1991 void
1992 pci_config_put32(ddi_acc_handle_t handle, off_t offset, uint32_t value);
1994 void
1995 pci_config_put64(ddi_acc_handle_t handle, off_t offset, uint64_t value);
1998 pci_report_pmcap(dev_info_t *dip, int cap, void *arg);
2001 pci_restore_config_regs(dev_info_t *dip);
2004 pci_save_config_regs(dev_info_t *dip);
2006 void
2007 pci_ereport_setup(dev_info_t *dip);
2009 void
2010 pci_ereport_teardown(dev_info_t *dip);
2012 void
2013 pci_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status);
2015 #if defined(__i386) || defined(__amd64)
2017 pci_peekpoke_check(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *,
2018 int (*handler)(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *),
2019 kmutex_t *, kmutex_t *, void (*scan)(dev_info_t *, ddi_fm_error_t *));
2020 #endif
2022 void
2023 pci_target_enqueue(uint64_t, char *, char *, uint64_t);
2025 void
2026 pci_targetq_init(void);
2029 pci_post_suspend(dev_info_t *dip);
2032 pci_pre_resume(dev_info_t *dip);
2035 * the prototype for the C Language Type Model inquiry.
2037 model_t ddi_mmap_get_model(void);
2038 model_t ddi_model_convert_from(model_t);
2041 * these are the prototypes for device id functions.
2044 ddi_devid_valid(ddi_devid_t devid);
2047 ddi_devid_register(dev_info_t *dip, ddi_devid_t devid);
2049 void
2050 ddi_devid_unregister(dev_info_t *dip);
2053 ddi_devid_init(dev_info_t *dip, ushort_t devid_type, ushort_t nbytes,
2054 void *id, ddi_devid_t *ret_devid);
2057 ddi_devid_get(dev_info_t *dip, ddi_devid_t *ret_devid);
2059 size_t
2060 ddi_devid_sizeof(ddi_devid_t devid);
2062 void
2063 ddi_devid_free(ddi_devid_t devid);
2066 ddi_devid_compare(ddi_devid_t id1, ddi_devid_t id2);
2069 ddi_devid_scsi_encode(int version, char *driver_name,
2070 uchar_t *inq, size_t inq_len, uchar_t *inq80, size_t inq80_len,
2071 uchar_t *inq83, size_t inq83_len, ddi_devid_t *ret_devid);
2074 ddi_devid_smp_encode(int version, char *driver_name,
2075 char *wwnstr, uchar_t *srmir_buf, size_t srmir_len,
2076 ddi_devid_t *ret_devid);
2078 char
2079 *ddi_devid_to_guid(ddi_devid_t devid);
2081 void
2082 ddi_devid_free_guid(char *guid);
2085 ddi_lyr_get_devid(dev_t dev, ddi_devid_t *ret_devid);
2088 ddi_lyr_get_minor_name(dev_t dev, int spec_type, char **minor_name);
2091 ddi_lyr_devid_to_devlist(ddi_devid_t devid, char *minor_name, int *retndevs,
2092 dev_t **retdevs);
2094 void
2095 ddi_lyr_free_devlist(dev_t *devlist, int ndevs);
2097 char *
2098 ddi_devid_str_encode(ddi_devid_t devid, char *minor_name);
2101 ddi_devid_str_decode(char *devidstr, ddi_devid_t *devidp, char **minor_namep);
2103 void
2104 ddi_devid_str_free(char *devidstr);
2107 ddi_devid_str_compare(char *id1_str, char *id2_str);
2110 * Event to post to when a devinfo node is removed.
2112 #define DDI_DEVI_REMOVE_EVENT "DDI:DEVI_REMOVE"
2113 #define DDI_DEVI_INSERT_EVENT "DDI:DEVI_INSERT"
2114 #define DDI_DEVI_BUS_RESET_EVENT "DDI:DEVI_BUS_RESET"
2115 #define DDI_DEVI_DEVICE_RESET_EVENT "DDI:DEVI_DEVICE_RESET"
2118 * Invoke bus nexus driver's implementation of the
2119 * (*bus_remove_eventcall)() interface to remove a registered
2120 * callback handler for "event".
2123 ddi_remove_event_handler(ddi_callback_id_t id);
2126 * Invoke bus nexus driver's implementation of the
2127 * (*bus_add_eventcall)() interface to register a callback handler
2128 * for "event".
2131 ddi_add_event_handler(dev_info_t *dip, ddi_eventcookie_t event,
2132 void (*handler)(dev_info_t *, ddi_eventcookie_t, void *, void *),
2133 void *arg, ddi_callback_id_t *id);
2136 * Return a handle for event "name" by calling up the device tree
2137 * hierarchy via (*bus_get_eventcookie)() interface until claimed
2138 * by a bus nexus or top of dev_info tree is reached.
2141 ddi_get_eventcookie(dev_info_t *dip, char *name,
2142 ddi_eventcookie_t *event_cookiep);
2145 * log a system event
2148 ddi_log_sysevent(dev_info_t *dip, char *vendor, char *class_name,
2149 char *subclass_name, nvlist_t *attr_list, sysevent_id_t *eidp,
2150 int sleep_flag);
2153 * ddi_log_sysevent() vendors
2155 #define DDI_VENDOR_SUNW "SUNW"
2158 * Opaque task queue handle.
2160 typedef struct ddi_taskq ddi_taskq_t;
2163 * Use default system priority.
2165 #define TASKQ_DEFAULTPRI -1
2168 * Create a task queue
2170 ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name,
2171 int nthreads, pri_t pri, uint_t cflags);
2174 * destroy a task queue
2176 void ddi_taskq_destroy(ddi_taskq_t *tq);
2179 * Dispatch a task to a task queue
2181 int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *),
2182 void *arg, uint_t dflags);
2185 * Wait for all previously scheduled tasks to complete.
2187 void ddi_taskq_wait(ddi_taskq_t *tq);
2190 * Suspend all task execution.
2192 void ddi_taskq_suspend(ddi_taskq_t *tq);
2195 * Resume task execution.
2197 void ddi_taskq_resume(ddi_taskq_t *tq);
2200 * Is task queue suspended?
2202 boolean_t ddi_taskq_suspended(ddi_taskq_t *tq);
2205 * Parse an interface name of the form <alphanumeric>##<numeric> where
2206 * <numeric> is maximal.
2208 int ddi_parse(const char *, char *, uint_t *);
2211 * DDI interrupt priority level
2213 #define DDI_IPL_0 (0) /* kernel context */
2214 #define DDI_IPL_1 (1) /* interrupt priority level 1 */
2215 #define DDI_IPL_2 (2) /* interrupt priority level 2 */
2216 #define DDI_IPL_3 (3) /* interrupt priority level 3 */
2217 #define DDI_IPL_4 (4) /* interrupt priority level 4 */
2218 #define DDI_IPL_5 (5) /* interrupt priority level 5 */
2219 #define DDI_IPL_6 (6) /* interrupt priority level 6 */
2220 #define DDI_IPL_7 (7) /* interrupt priority level 7 */
2221 #define DDI_IPL_8 (8) /* interrupt priority level 8 */
2222 #define DDI_IPL_9 (9) /* interrupt priority level 9 */
2223 #define DDI_IPL_10 (10) /* interrupt priority level 10 */
2226 * DDI periodic timeout interface
2228 ddi_periodic_t ddi_periodic_add(void (*)(void *), void *, hrtime_t, int);
2229 void ddi_periodic_delete(ddi_periodic_t);
2232 * Default quiesce(9E) implementation for drivers that don't need to do
2233 * anything.
2235 int ddi_quiesce_not_needed(dev_info_t *);
2238 * Default quiesce(9E) initialization function for drivers that should
2239 * implement quiesce but haven't yet.
2241 int ddi_quiesce_not_supported(dev_info_t *);
2244 * DDI generic callback interface
2247 typedef struct __ddi_cb **ddi_cb_handle_t;
2249 int ddi_cb_register(dev_info_t *dip, ddi_cb_flags_t flags,
2250 ddi_cb_func_t cbfunc, void *arg1, void *arg2,
2251 ddi_cb_handle_t *ret_hdlp);
2252 int ddi_cb_unregister(ddi_cb_handle_t hdl);
2254 /* Notify DDI of memory added */
2255 void ddi_mem_update(uint64_t addr, uint64_t size);
2257 /* Path alias interfaces */
2258 typedef struct plat_alias {
2259 char *pali_current;
2260 uint64_t pali_naliases;
2261 char **pali_aliases;
2262 } plat_alias_t;
2264 typedef struct alias_pair {
2265 char *pair_alias;
2266 char *pair_curr;
2267 } alias_pair_t;
2269 extern boolean_t ddi_aliases_present;
2271 typedef struct ddi_alias {
2272 alias_pair_t *dali_alias_pairs;
2273 alias_pair_t *dali_curr_pairs;
2274 int dali_num_pairs;
2275 mod_hash_t *dali_alias_TLB;
2276 mod_hash_t *dali_curr_TLB;
2277 } ddi_alias_t;
2279 extern ddi_alias_t ddi_aliases;
2281 void ddi_register_aliases(plat_alias_t *pali, uint64_t npali);
2282 dev_info_t *ddi_alias_redirect(char *alias);
2283 char *ddi_curr_redirect(char *curr);
2285 #endif /* _KERNEL */
2287 #ifdef __cplusplus
2289 #endif
2291 #endif /* _SYS_SUNDDI_H */