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