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