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