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