xref: /titanic_44/usr/src/uts/common/sys/sunddi.h (revision 6f25ad7ffa9acba13c9da0cb230544442ab650ce)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54ab75253Smrj  * Common Development and Distribution License (the "License").
64ab75253Smrj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
2166f9d5cbSmlf 
227c478bd9Sstevel@tonic-gate /*
2394c894bbSVikram Hegde  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_SUNDDI_H
277c478bd9Sstevel@tonic-gate #define	_SYS_SUNDDI_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Sun Specific DDI definitions
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
347c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
357c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h>
367c478bd9Sstevel@tonic-gate #include <sys/devops.h>
377c478bd9Sstevel@tonic-gate #include <sys/time.h>
387c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
397c478bd9Sstevel@tonic-gate #include <sys/ddidevmap.h>
407c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
417c478bd9Sstevel@tonic-gate #include <sys/ddi_implfuncs.h>
427c478bd9Sstevel@tonic-gate #include <sys/ddi_isa.h>
437c478bd9Sstevel@tonic-gate #include <sys/model.h>
447c478bd9Sstevel@tonic-gate #include <sys/devctl.h>
457c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
467c478bd9Sstevel@tonic-gate #include <sys/dma_engine.h>
477c478bd9Sstevel@tonic-gate #endif
487c478bd9Sstevel@tonic-gate #include <sys/sunpm.h>
497c478bd9Sstevel@tonic-gate #include <sys/nvpair.h>
507c478bd9Sstevel@tonic-gate #include <sys/sysevent.h>
517c478bd9Sstevel@tonic-gate #include <sys/thread.h>
527c478bd9Sstevel@tonic-gate #include <sys/stream.h>
537c478bd9Sstevel@tonic-gate #if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL)
547c478bd9Sstevel@tonic-gate #include <asm/sunddi.h>
557c478bd9Sstevel@tonic-gate #endif
564ab75253Smrj #ifdef _KERNEL
574ab75253Smrj #include <sys/ddi_obsolete.h>
584ab75253Smrj #endif
594703203dSis #include <sys/u8_textprep.h>
60d14d7d31Sis #include <sys/kiconv.h>
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
637c478bd9Sstevel@tonic-gate extern "C" {
647c478bd9Sstevel@tonic-gate #endif
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * Generic Sun DDI definitions.
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate #define	DDI_SUCCESS	(0)	/* successful return */
717c478bd9Sstevel@tonic-gate #define	DDI_FAILURE	(-1)	/* unsuccessful return */
727c478bd9Sstevel@tonic-gate #define	DDI_NOT_WELL_FORMED (-2)  /* A dev_info node is not valid */
737c478bd9Sstevel@tonic-gate #define	DDI_EAGAIN	(-3)	/* not enough interrupt resources */
747c478bd9Sstevel@tonic-gate #define	DDI_EINVAL	(-4)	/* invalid request or arguments */
757c478bd9Sstevel@tonic-gate #define	DDI_ENOTSUP	(-5)	/* operation is not supported */
767c478bd9Sstevel@tonic-gate #define	DDI_EPENDING	(-6)	/* operation or an event is pending */
775febcb4aSScott Carter, SD IOSW #define	DDI_EALREADY	(-7)	/* operation already in progress */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate /*
807c478bd9Sstevel@tonic-gate  * General-purpose DDI error return value definitions
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate #define	DDI_ENOMEM		1	/* memory not available */
837c478bd9Sstevel@tonic-gate #define	DDI_EBUSY		2	/* busy */
847c478bd9Sstevel@tonic-gate #define	DDI_ETRANSPORT		3	/* transport down */
857c478bd9Sstevel@tonic-gate #define	DDI_ECONTEXT		4	/* context error */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * General DDI sleep/nosleep allocation flags
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate #define	DDI_SLEEP	0
927c478bd9Sstevel@tonic-gate #define	DDI_NOSLEEP	1
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * The following special nodeid values are reserved for use when creating
967c478bd9Sstevel@tonic-gate  * nodes ONLY.  They specify the attributes of the DDI_NC_PSEUDO class node
977c478bd9Sstevel@tonic-gate  * being created:
987c478bd9Sstevel@tonic-gate  *
997c478bd9Sstevel@tonic-gate  *  o	DEVI_PSEUDO_NODEID specifics a node without persistence.
1007c478bd9Sstevel@tonic-gate  *  o	DEVI_SID_NODEID specifies a node with persistence.
101027021c7SChris Horne  *  o	DEVI_SID_HIDDEN_NODEID specifies a hidden node with persistence.
102027021c7SChris Horne  *
103027021c7SChris Horne  * A node with the 'hidden' attribute will not show up in devinfo snapshots
104027021c7SChris Horne  * or in /devices file system.
1057c478bd9Sstevel@tonic-gate  *
1067c478bd9Sstevel@tonic-gate  * A node with the 'persistent' attribute will not be automatically removed by
1077c478bd9Sstevel@tonic-gate  * the framework in the current implementation - driver.conf nodes are without
1087c478bd9Sstevel@tonic-gate  * persistence.
1097c478bd9Sstevel@tonic-gate  *
1107c478bd9Sstevel@tonic-gate  * The actual nodeid value may be assigned by the framework and may be
1117c478bd9Sstevel@tonic-gate  * different than these special values. Drivers may not make assumptions
1127c478bd9Sstevel@tonic-gate  * about the nodeid value that is actually assigned to the node.
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define	DEVI_PSEUDO_NODEID	((int)-1)
1167c478bd9Sstevel@tonic-gate #define	DEVI_SID_NODEID		((int)-2)
117027021c7SChris Horne #define	DEVI_SID_HIDDEN_NODEID	((int)-3)
1184c06356bSdh142964 #define	DEVI_SID_HP_NODEID	((int)-4)
1194c06356bSdh142964 #define	DEVI_SID_HP_HIDDEN_NODEID ((int)-5)
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate #define	DEVI_PSEUDO_NEXNAME	"pseudo"
1227c478bd9Sstevel@tonic-gate #define	DEVI_ISA_NEXNAME	"isa"
1237c478bd9Sstevel@tonic-gate #define	DEVI_EISA_NEXNAME	"eisa"
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /*
1267c478bd9Sstevel@tonic-gate  * ddi_create_minor_node flags
1277c478bd9Sstevel@tonic-gate  */
1287c478bd9Sstevel@tonic-gate #define	CLONE_DEV		1	/* device is a clone device */
1297c478bd9Sstevel@tonic-gate #define	PRIVONLY_DEV		0x10	/* policy-based permissions only */
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate /*
1327c478bd9Sstevel@tonic-gate  * Historical values used for the flag field in ddi_create_minor_node.
1337c478bd9Sstevel@tonic-gate  * Future use of flag bits should avoid these fields to keep binary
1347c478bd9Sstevel@tonic-gate  * compatibility
1357c478bd9Sstevel@tonic-gate  * #define	GLOBAL_DEV		0x2
1367c478bd9Sstevel@tonic-gate  * #define	NODEBOUND_DEV		0x4
1377c478bd9Sstevel@tonic-gate  * #define	NODESPECIFIC_DEV	0x6
1387c478bd9Sstevel@tonic-gate  * #define	ENUMERATED_DEV		0x8
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate /*
1427c478bd9Sstevel@tonic-gate  * Device type defines which are used by the 'node_type' element of the
1437c478bd9Sstevel@tonic-gate  * ddi_minor_data structure
1447c478bd9Sstevel@tonic-gate  */
1457c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL	"ddi_serial"		/* Serial port */
1467c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_MB "ddi_serial:mb"	/* the 'built-in' serial */
1477c478bd9Sstevel@tonic-gate 						/* ports (the old ttya, b */
1487c478bd9Sstevel@tonic-gate 						/* (,c ,d)) */
1497c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_DO "ddi_serial:dialout"	/* dialout ports */
1507c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_MB_DO "ddi_serial:dialout,mb" /* dialout for onboard */
1517c478bd9Sstevel@tonic-gate 						/* ports */
1527c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_LOMCON "ddi_serial:lomcon" /* LOMlite2 console port */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * *_CHAN disk type devices have channel numbers or target numbers.
1567c478bd9Sstevel@tonic-gate  * (i.e. ipi and scsi devices)
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK	"ddi_block"		/* hard disks */
1597c478bd9Sstevel@tonic-gate /*
1607c478bd9Sstevel@tonic-gate  * The next define is for block type devices that can possible exist on
1617c478bd9Sstevel@tonic-gate  * a sub-bus like the scsi bus or the ipi channel.  The 'disks' program
1627c478bd9Sstevel@tonic-gate  * will pick up on this and create logical names like c0t0d0s0 instead of
1637c478bd9Sstevel@tonic-gate  * c0d0s0
1647c478bd9Sstevel@tonic-gate  */
1657c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK_CHAN	"ddi_block:channel"
1667c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK_WWN	"ddi_block:wwn"
1677c478bd9Sstevel@tonic-gate #define	DDI_NT_CD	"ddi_block:cdrom"	/* rom drives (cd-rom) */
1687c478bd9Sstevel@tonic-gate #define	DDI_NT_CD_CHAN	"ddi_block:cdrom:channel" /* rom drives (scsi type) */
1697c478bd9Sstevel@tonic-gate #define	DDI_NT_FD	"ddi_block:diskette"	/* floppy disks */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate #define	DDI_NT_ENCLOSURE	"ddi_enclosure"
1727c478bd9Sstevel@tonic-gate #define	DDI_NT_SCSI_ENCLOSURE	"ddi_enclosure:scsi"
1737c478bd9Sstevel@tonic-gate 
174d88e498aSjiang wu - Sun Microsystems - Beijing China #define	DDI_NT_BLOCK_SAS	"ddi_block:sas"
175d88e498aSjiang wu - Sun Microsystems - Beijing China 
17697869ac5Sjhd /*
17797869ac5Sjhd  * xVM virtual block devices
17897869ac5Sjhd  */
17997869ac5Sjhd #define	DDI_NT_BLOCK_XVMD	"ddi_block:xvmd"
18097869ac5Sjhd #define	DDI_NT_CD_XVMD		"ddi_block:cdrom:xvmd"
18197869ac5Sjhd 
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate #define	DDI_NT_TAPE	"ddi_byte:tape"		/* tape drives */
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate #define	DDI_NT_NET	"ddi_network"		/* DLPI network devices */
1867c478bd9Sstevel@tonic-gate 
187516fc7f3Shx147065 #define	DDI_NT_NET_WIFI	"ddi_network:wifi"	/* wifi devices */
188516fc7f3Shx147065 
1897c478bd9Sstevel@tonic-gate #define	DDI_NT_DISPLAY	"ddi_display"		/* display devices */
1907c478bd9Sstevel@tonic-gate 
19160405de4Skz151634 #define	DDI_NT_DISPLAY_DRM	"ddi_display:drm" /* drm display devices */
19260405de4Skz151634 
1937c478bd9Sstevel@tonic-gate #define	DDI_PSEUDO	"ddi_pseudo"		/* general pseudo devices */
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate #define	DDI_NT_AUDIO	"ddi_audio"		/* audio device */
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate #define	DDI_NT_MOUSE	"ddi_mouse"		/* mouse device */
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate #define	DDI_NT_KEYBOARD	"ddi_keyboard"		/* keyboard device */
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate #define	DDI_NT_PARALLEL "ddi_parallel"		/* parallel port */
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate #define	DDI_NT_PRINTER	"ddi_printer"		/* printer device */
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate #define	DDI_NT_UGEN	"ddi_generic:usb"	/* USB generic drv */
2067c478bd9Sstevel@tonic-gate 
207936b7af6Sjw149990 #define	DDI_NT_SMP	"ddi_sas_smp" 		/* smp devcies */
208936b7af6Sjw149990 
2097c478bd9Sstevel@tonic-gate #define	DDI_NT_NEXUS	"ddi_ctl:devctl"	/* nexus drivers */
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate #define	DDI_NT_SCSI_NEXUS	"ddi_ctl:devctl:scsi"	/* nexus drivers */
2127c478bd9Sstevel@tonic-gate 
21366f9d5cbSmlf #define	DDI_NT_SATA_NEXUS	"ddi_ctl:devctl:sata"	/* nexus drivers */
21466f9d5cbSmlf 
215d1a5c838SRamaswamy Tummala #define	DDI_NT_IB_NEXUS		"ddi_ctl:devctl:ib"	/* nexus drivers */
216d1a5c838SRamaswamy Tummala 
2177c478bd9Sstevel@tonic-gate #define	DDI_NT_ATTACHMENT_POINT	"ddi_ctl:attachment_point" /* attachment pt */
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate #define	DDI_NT_SCSI_ATTACHMENT_POINT	"ddi_ctl:attachment_point:scsi"
2207c478bd9Sstevel@tonic-gate 						/* scsi attachment pt */
22166f9d5cbSmlf 
22266f9d5cbSmlf #define	DDI_NT_SATA_ATTACHMENT_POINT	"ddi_ctl:attachment_point:sata"
22366f9d5cbSmlf 						/* sata attachment pt */
22466f9d5cbSmlf 
2254bb7efa7SGarrett D'Amore #define	DDI_NT_SDCARD_ATTACHMENT_POINT	"ddi_ctl:attachment_point:sdcard"
2264bb7efa7SGarrett D'Amore 						/* sdcard attachment pt */
2274bb7efa7SGarrett D'Amore 
2287c478bd9Sstevel@tonic-gate #define	DDI_NT_PCI_ATTACHMENT_POINT	"ddi_ctl:attachment_point:pci"
2297c478bd9Sstevel@tonic-gate 						/* PCI attachment pt */
2307c478bd9Sstevel@tonic-gate #define	DDI_NT_SBD_ATTACHMENT_POINT	"ddi_ctl:attachment_point:sbd"
2317c478bd9Sstevel@tonic-gate 						/* generic bd attachment pt */
2327c478bd9Sstevel@tonic-gate #define	DDI_NT_FC_ATTACHMENT_POINT	"ddi_ctl:attachment_point:fc"
2337c478bd9Sstevel@tonic-gate 						/* FC attachment pt */
2347c478bd9Sstevel@tonic-gate #define	DDI_NT_USB_ATTACHMENT_POINT	"ddi_ctl:attachment_point:usb"
2357c478bd9Sstevel@tonic-gate 						/* USB devices */
2367c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK_FABRIC		"ddi_block:fabric"
2377c478bd9Sstevel@tonic-gate 						/* Fabric Devices */
2387c478bd9Sstevel@tonic-gate #define	DDI_NT_IB_ATTACHMENT_POINT	"ddi_ctl:attachment_point:ib"
2397c478bd9Sstevel@tonic-gate 						/* IB devices */
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate #define	DDI_NT_AV_ASYNC "ddi_av:async"		/* asynchronous AV device */
2427c478bd9Sstevel@tonic-gate #define	DDI_NT_AV_ISOCH "ddi_av:isoch"		/* isochronous AV device */
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate /* Device types used for agpgart driver related devices */
2457c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_PSEUDO	"ddi_agp:pseudo" /* agpgart pseudo device */
2467c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_MASTER	"ddi_agp:master" /* agp master device */
2477c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_TARGET	"ddi_agp:target" /* agp target device */
2487c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_CPUGART	"ddi_agp:cpugart" /* amd64 on-cpu gart device */
2497c478bd9Sstevel@tonic-gate 
2507851eb82Sschwartz #define	DDI_NT_REGACC		"ddi_tool_reg"	/* tool register access */
2517851eb82Sschwartz #define	DDI_NT_INTRCTL		"ddi_tool_intr"	/* tool intr access */
2527851eb82Sschwartz 
2537c478bd9Sstevel@tonic-gate /*
2547c478bd9Sstevel@tonic-gate  * DDI event definitions
2557c478bd9Sstevel@tonic-gate  */
2567c478bd9Sstevel@tonic-gate #define	EC_DEVFS	"EC_devfs"	/* Event class devfs */
2578c4f8890Srs135747 #define	EC_DDI		"EC_ddi"	/* Event class ddi */
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate /* Class devfs subclasses */
2607c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_MINOR_CREATE	"ESC_devfs_minor_create"
2617c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_MINOR_REMOVE	"ESC_devfs_minor_remove"
2627c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_DEVI_ADD	"ESC_devfs_devi_add"
2637c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_DEVI_REMOVE	"ESC_devfs_devi_remove"
2647c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_INSTANCE_MOD	"ESC_devfs_instance_mod"
2657c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_BRANCH_ADD	"ESC_devfs_branch_add"
2667c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_BRANCH_REMOVE	"ESC_devfs_branch_remove"
267facf4a8dSllai1 #define	ESC_DEVFS_START		"ESC_devfs_start"
2687c478bd9Sstevel@tonic-gate 
2698c4f8890Srs135747 /* Class ddi subclasses */
2708c4f8890Srs135747 #define	ESC_DDI_INITIATOR_REGISTER	"ESC_ddi_initiator_register"
2718c4f8890Srs135747 #define	ESC_DDI_INITIATOR_UNREGISTER	"ESC_ddi_initiator_unregister"
2728c4f8890Srs135747 
2737c478bd9Sstevel@tonic-gate /* DDI/NDI event publisher */
2747c478bd9Sstevel@tonic-gate #define	EP_DDI	SUNW_KERN_PUB"ddi"
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /*
2777c478bd9Sstevel@tonic-gate  * devfs event class attributes
2787c478bd9Sstevel@tonic-gate  *
2798c4f8890Srs135747  * The following attributes are private to EC_DEVFS event data.
2807c478bd9Sstevel@tonic-gate  */
2817c478bd9Sstevel@tonic-gate #define	DEVFS_DRIVER_NAME	"di.driver"
2827c478bd9Sstevel@tonic-gate #define	DEVFS_INSTANCE		"di.instance"
2837c478bd9Sstevel@tonic-gate #define	DEVFS_PATHNAME		"di.path"
2847c478bd9Sstevel@tonic-gate #define	DEVFS_DEVI_CLASS	"di.devi_class"
2857c478bd9Sstevel@tonic-gate #define	DEVFS_BRANCH_EVENT	"di.branch_event"
2867c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_NAME	"mi.name"
2877c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_NODETYPE	"mi.nodetype"
2887c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_ISCLONE	"mi.isclone"
2897c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_MAJNUM	"mi.majorno"
2907c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_MINORNUM	"mi.minorno"
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate /*
2938c4f8890Srs135747  * ddi event class payload
2948c4f8890Srs135747  *
2958c4f8890Srs135747  * The following attributes are private to EC_DDI event data.
2968c4f8890Srs135747  */
2978c4f8890Srs135747 #define	DDI_DRIVER_NAME		"ddi.driver"
2988c4f8890Srs135747 #define	DDI_DRIVER_MAJOR	"ddi.major"
2998c4f8890Srs135747 #define	DDI_INSTANCE		"ddi.instance"
3008c4f8890Srs135747 #define	DDI_PATHNAME		"ddi.path"
3018c4f8890Srs135747 #define	DDI_CLASS		"ddi.class"
3028c4f8890Srs135747 
3038c4f8890Srs135747 /*
3047c478bd9Sstevel@tonic-gate  * Fault-related definitions
3057c478bd9Sstevel@tonic-gate  *
3067c478bd9Sstevel@tonic-gate  * The specific numeric values have been chosen to be ordered, but
3077c478bd9Sstevel@tonic-gate  * not consecutive, to allow for future interpolation if required.
3087c478bd9Sstevel@tonic-gate  */
3097c478bd9Sstevel@tonic-gate typedef enum {
3107c478bd9Sstevel@tonic-gate     DDI_SERVICE_LOST = -32,
3117c478bd9Sstevel@tonic-gate     DDI_SERVICE_DEGRADED = -16,
3127c478bd9Sstevel@tonic-gate     DDI_SERVICE_UNAFFECTED = 0,
3137c478bd9Sstevel@tonic-gate     DDI_SERVICE_RESTORED = 16
3147c478bd9Sstevel@tonic-gate } ddi_fault_impact_t;
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate typedef enum {
3177c478bd9Sstevel@tonic-gate     DDI_DATAPATH_FAULT = -32,
3187c478bd9Sstevel@tonic-gate     DDI_DEVICE_FAULT = -16,
3197c478bd9Sstevel@tonic-gate     DDI_EXTERNAL_FAULT = 0
3207c478bd9Sstevel@tonic-gate } ddi_fault_location_t;
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate typedef enum {
3237c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_OFFLINE = -32,
3247c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_DOWN = -16,
3257c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_QUIESCED = 0,
3267c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_DEGRADED = 16,
3277c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_UP = 32
3287c478bd9Sstevel@tonic-gate } ddi_devstate_t;
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate /*
3337c478bd9Sstevel@tonic-gate  * Common property definitions
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate #define	DDI_FORCEATTACH		"ddi-forceattach"
3367c478bd9Sstevel@tonic-gate #define	DDI_NO_AUTODETACH	"ddi-no-autodetach"
33752cac543Sramat #define	DDI_VHCI_CLASS		"ddi-vhci-class"
33852cac543Sramat #define	DDI_NO_ROOT_SUPPORT	"ddi-no-root-support"
339e099bf07Scth #define	DDI_OPEN_RETURNS_EINTR	"ddi-open-returns-eintr"
340*6f25ad7fSJerry Gilliam #define	DDI_DEVID_REGISTRANT	"ddi-devid-registrant"
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate /*
3437c478bd9Sstevel@tonic-gate  * Values that the function supplied to the dev_info
3447c478bd9Sstevel@tonic-gate  * tree traversal functions defined below must return.
3457c478bd9Sstevel@tonic-gate  */
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate /*
3487c478bd9Sstevel@tonic-gate  * Continue search, if appropriate.
3497c478bd9Sstevel@tonic-gate  */
3507c478bd9Sstevel@tonic-gate #define	DDI_WALK_CONTINUE	0
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate /*
3537c478bd9Sstevel@tonic-gate  * Terminate current depth of traversal. That is, terminate
3547c478bd9Sstevel@tonic-gate  * the current traversal of children nodes, but continue
3557c478bd9Sstevel@tonic-gate  * traversing sibling nodes and their children (if any).
3567c478bd9Sstevel@tonic-gate  */
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate #define	DDI_WALK_PRUNECHILD	-1
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate /*
3617c478bd9Sstevel@tonic-gate  * Terminate current width of traversal. That is, terminate
3627c478bd9Sstevel@tonic-gate  * the current traversal of sibling nodes, but continue with
3637c478bd9Sstevel@tonic-gate  * traversing children nodes and their siblings (if appropriate).
3647c478bd9Sstevel@tonic-gate  */
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate #define	DDI_WALK_PRUNESIB	-2
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /*
3697c478bd9Sstevel@tonic-gate  * Terminate the entire search.
3707c478bd9Sstevel@tonic-gate  */
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate #define	DDI_WALK_TERMINATE	-3
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate /*
3757c478bd9Sstevel@tonic-gate  * Terminate the entire search because an error occurred in function
3767c478bd9Sstevel@tonic-gate  */
3777c478bd9Sstevel@tonic-gate #define	DDI_WALK_ERROR		-4
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate /*
3807c478bd9Sstevel@tonic-gate  * Drivers that are prepared to support full driver layering
3817c478bd9Sstevel@tonic-gate  * should create and export a null-valued property of the following
3827c478bd9Sstevel@tonic-gate  * name.
3837c478bd9Sstevel@tonic-gate  *
3847c478bd9Sstevel@tonic-gate  * Such drivers should be prepared to be called with FKLYR in
3857c478bd9Sstevel@tonic-gate  * the 'flag' argument of their open(9E), close(9E) routines, and
3867c478bd9Sstevel@tonic-gate  * with FKIOCTL in the 'mode' argument of their ioctl(9E) routines.
3877c478bd9Sstevel@tonic-gate  *
3887c478bd9Sstevel@tonic-gate  * See ioctl(9E) and ddi_copyin(9F) for details.
3897c478bd9Sstevel@tonic-gate  */
3907c478bd9Sstevel@tonic-gate #define	DDI_KERNEL_IOCTL	"ddi-kernel-ioctl"
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate /*
3937c478bd9Sstevel@tonic-gate  * Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F).
3947c478bd9Sstevel@tonic-gate  */
3957c478bd9Sstevel@tonic-gate #define	DDI_MODEL_MASK		DATAMODEL_MASK	/* Note: 0x0FF00000 */
3967c478bd9Sstevel@tonic-gate #define	DDI_MODEL_ILP32		DATAMODEL_ILP32
3977c478bd9Sstevel@tonic-gate #define	DDI_MODEL_LP64		DATAMODEL_LP64
3987c478bd9Sstevel@tonic-gate #define	DDI_MODEL_NATIVE	DATAMODEL_NATIVE
3997c478bd9Sstevel@tonic-gate #define	DDI_MODEL_NONE		DATAMODEL_NONE
4007c478bd9Sstevel@tonic-gate 
40194c894bbSVikram Hegde /* if set to B_TRUE is DER_MODE is equivalent to DERE_PANIC */
40294c894bbSVikram Hegde extern boolean_t ddi_err_panic;
40394c894bbSVikram Hegde 
4043a634bfcSVikram Hegde /*
4053a634bfcSVikram Hegde  * Defines for ddi_err().
4063a634bfcSVikram Hegde  */
40794c894bbSVikram Hegde typedef enum {
4083a634bfcSVikram Hegde 	DER_INVALID = 0,	/* must be 0 */
4093a634bfcSVikram Hegde 	DER_CONT = 1,
4103a634bfcSVikram Hegde 	DER_CONS,
4113a634bfcSVikram Hegde 	DER_LOG,
4123a634bfcSVikram Hegde 	DER_VERB,
4133a634bfcSVikram Hegde 	DER_NOTE,
4143a634bfcSVikram Hegde 	DER_WARN,
4153a634bfcSVikram Hegde 	DER_PANIC,
4163a634bfcSVikram Hegde 	DER_MODE,
4173a634bfcSVikram Hegde 	DER_DEBUG
4183a634bfcSVikram Hegde } ddi_err_t;
4193a634bfcSVikram Hegde 
4203a634bfcSVikram Hegde extern void ddi_err(ddi_err_t de, dev_info_t *rdip, const char *fmt, ...);
4213a634bfcSVikram Hegde 
42294c894bbSVikram Hegde 
4237f0b8309SEdward Pilatowicz extern char *ddi_strdup(const char *str, int flag);
4247f0b8309SEdward Pilatowicz extern char *strdup(const char *str);
4257f0b8309SEdward Pilatowicz extern void strfree(char *str);
4267f0b8309SEdward Pilatowicz 
4277c478bd9Sstevel@tonic-gate /*
4287c478bd9Sstevel@tonic-gate  * Functions and data references which really should be in <sys/ddi.h>
4297c478bd9Sstevel@tonic-gate  */
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate extern int maxphys;
4327c478bd9Sstevel@tonic-gate extern void minphys(struct buf *);
4337c478bd9Sstevel@tonic-gate extern int physio(int (*)(struct buf *), struct buf *, dev_t,
4347c478bd9Sstevel@tonic-gate 	int, void (*)(struct buf *), struct uio *);
4357c478bd9Sstevel@tonic-gate extern void disksort(struct diskhd *, struct buf *);
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate extern size_t strlen(const char *) __PURE;
4387637daddSmyers extern size_t strnlen(const char *, size_t) __PURE;
4397c478bd9Sstevel@tonic-gate extern char *strcpy(char *, const char *);
4407c478bd9Sstevel@tonic-gate extern char *strncpy(char *, const char *, size_t);
4417c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for strchr() */
4427c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
4437c478bd9Sstevel@tonic-gate extern const char *strchr(const char *, int);
4447c478bd9Sstevel@tonic-gate #ifndef	_STRCHR_INLINE
4457c478bd9Sstevel@tonic-gate #define	_STRCHR_INLINE
4467c478bd9Sstevel@tonic-gate extern	"C++" {
4477c478bd9Sstevel@tonic-gate 	inline char *strchr(char *__s, int __c) {
4487c478bd9Sstevel@tonic-gate 		return (char *)strchr((const char *)__s, __c);
4497c478bd9Sstevel@tonic-gate 	}
4507c478bd9Sstevel@tonic-gate }
4517c478bd9Sstevel@tonic-gate #endif	/* _STRCHR_INLINE */
4527c478bd9Sstevel@tonic-gate #else
4537c478bd9Sstevel@tonic-gate extern char *strchr(const char *, int);
4547c478bd9Sstevel@tonic-gate #endif	/* __cplusplus >= 199711L */
4552cd7878fScth #define	DDI_STRSAME(s1, s2)	((*(s1) == *(s2)) && (strcmp((s1), (s2)) == 0))
4567c478bd9Sstevel@tonic-gate extern int strcmp(const char *, const char *) __PURE;
4577c478bd9Sstevel@tonic-gate extern int strncmp(const char *, const char *, size_t) __PURE;
4587c478bd9Sstevel@tonic-gate extern char *strncat(char *, const char *, size_t);
4597c478bd9Sstevel@tonic-gate extern size_t strlcat(char *, const char *, size_t);
4607c478bd9Sstevel@tonic-gate extern size_t strlcpy(char *, const char *, size_t);
4617c478bd9Sstevel@tonic-gate extern size_t strspn(const char *, const char *);
4627c478bd9Sstevel@tonic-gate extern int bcmp(const void *, const void *, size_t) __PURE;
4637c478bd9Sstevel@tonic-gate extern int stoi(char **);
4647c478bd9Sstevel@tonic-gate extern void numtos(ulong_t, char *);
4657c478bd9Sstevel@tonic-gate extern void bcopy(const void *, void *, size_t);
4667c478bd9Sstevel@tonic-gate extern void bzero(void *, size_t);
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate extern void *memcpy(void *, const  void  *, size_t);
4697c478bd9Sstevel@tonic-gate extern void *memset(void *, int, size_t);
4707c478bd9Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t);
4717c478bd9Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t) __PURE;
4727c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for memchr() */
4737c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
4747c478bd9Sstevel@tonic-gate extern const void *memchr(const void *, int, size_t);
4757c478bd9Sstevel@tonic-gate #ifndef	_MEMCHR_INLINE
4767c478bd9Sstevel@tonic-gate #define	_MEMCHR_INLINE
4777c478bd9Sstevel@tonic-gate extern "C++" {
4787c478bd9Sstevel@tonic-gate 	inline void *memchr(void * __s, int __c, size_t __n) {
4797c478bd9Sstevel@tonic-gate 		return (void *)memchr((const void *)__s, __c, __n);
4807c478bd9Sstevel@tonic-gate 	}
4817c478bd9Sstevel@tonic-gate }
4827c478bd9Sstevel@tonic-gate #endif  /* _MEMCHR_INLINE */
4837c478bd9Sstevel@tonic-gate #else
4847c478bd9Sstevel@tonic-gate extern void *memchr(const void *, int, size_t);
4857c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate extern int ddi_strtol(const char *, char **, int, long *);
4887c478bd9Sstevel@tonic-gate extern int ddi_strtoul(const char *, char **, int, unsigned long *);
4892ef9abdcSjv227347 extern int ddi_strtoll(const char *, char **, int, longlong_t *);
4902ef9abdcSjv227347 extern int ddi_strtoull(const char *, char **, int, u_longlong_t *);
4917c478bd9Sstevel@tonic-gate 
4927c478bd9Sstevel@tonic-gate /*
493d14d7d31Sis  * kiconv functions and their macros.
494d14d7d31Sis  */
495d14d7d31Sis #define	KICONV_IGNORE_NULL	(0x0001)
496d14d7d31Sis #define	KICONV_REPLACE_INVALID	(0x0002)
497d14d7d31Sis 
498d14d7d31Sis extern kiconv_t kiconv_open(const char *, const char *);
499d14d7d31Sis extern size_t kiconv(kiconv_t, char **, size_t *, char **, size_t *, int *);
500d14d7d31Sis extern int kiconv_close(kiconv_t);
501d14d7d31Sis extern size_t kiconvstr(const char *, const char *, char *, size_t *, char *,
502d14d7d31Sis 	size_t *, int, int *);
503d14d7d31Sis 
504d14d7d31Sis /*
5057c478bd9Sstevel@tonic-gate  * ddi_map_regs
5067c478bd9Sstevel@tonic-gate  *
5077c478bd9Sstevel@tonic-gate  *	Map in the register set given by rnumber.
5087c478bd9Sstevel@tonic-gate  *	The register number determine which register
5097c478bd9Sstevel@tonic-gate  *	set will be mapped if more than one exists.
5107c478bd9Sstevel@tonic-gate  *	The parent driver gets the information
5117c478bd9Sstevel@tonic-gate  *	from parent private data and sets up the
5127c478bd9Sstevel@tonic-gate  *	appropriate mappings and returns the kernel
5137c478bd9Sstevel@tonic-gate  *	virtual address of the register set in *kaddrp.
5147c478bd9Sstevel@tonic-gate  *	The offset specifies an offset into the register
5157c478bd9Sstevel@tonic-gate  *	space to start from and len indicates the size
5167c478bd9Sstevel@tonic-gate  *	of the area to map. If len and offset are 0 then
5177c478bd9Sstevel@tonic-gate  *	the entire space is mapped.  It returns DDI_SUCCESS on
5187c478bd9Sstevel@tonic-gate  *	success or DDI_FAILURE otherwise.
5197c478bd9Sstevel@tonic-gate  *
5207c478bd9Sstevel@tonic-gate  */
5217c478bd9Sstevel@tonic-gate int
5227c478bd9Sstevel@tonic-gate ddi_map_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
5237c478bd9Sstevel@tonic-gate 	off_t offset, off_t len);
5247c478bd9Sstevel@tonic-gate 
5257c478bd9Sstevel@tonic-gate /*
5267c478bd9Sstevel@tonic-gate  * ddi_unmap_regs
5277c478bd9Sstevel@tonic-gate  *
5287c478bd9Sstevel@tonic-gate  *	Undo mappings set up by ddi_map_regs.
5297c478bd9Sstevel@tonic-gate  *	The register number determines which register
5307c478bd9Sstevel@tonic-gate  *	set will be unmapped if more than one exists.
5317c478bd9Sstevel@tonic-gate  *	This is provided for drivers preparing
5327c478bd9Sstevel@tonic-gate  *	to detach themselves from the system to
5337c478bd9Sstevel@tonic-gate  *	allow them to release allocated mappings.
5347c478bd9Sstevel@tonic-gate  *
5357c478bd9Sstevel@tonic-gate  *	The kaddrp and len specify the area to be
5367c478bd9Sstevel@tonic-gate  *	unmapped. *kaddrp was returned from ddi_map_regs
5377c478bd9Sstevel@tonic-gate  *	and len should match what ddi_map_regs was called
5387c478bd9Sstevel@tonic-gate  *	with.
5397c478bd9Sstevel@tonic-gate  */
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate void
5427c478bd9Sstevel@tonic-gate ddi_unmap_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
5437c478bd9Sstevel@tonic-gate 	off_t offset, off_t len);
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate int
5467c478bd9Sstevel@tonic-gate ddi_map(dev_info_t *dp, ddi_map_req_t *mp, off_t offset, off_t len,
5477c478bd9Sstevel@tonic-gate 	caddr_t *addrp);
5487c478bd9Sstevel@tonic-gate 
5497c478bd9Sstevel@tonic-gate int
5507c478bd9Sstevel@tonic-gate ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate /*
5537c478bd9Sstevel@tonic-gate  * ddi_rnumber_to_regspec: Not for use by leaf drivers.
5547c478bd9Sstevel@tonic-gate  */
5557c478bd9Sstevel@tonic-gate struct regspec *
5567c478bd9Sstevel@tonic-gate ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
5577c478bd9Sstevel@tonic-gate 
5587c478bd9Sstevel@tonic-gate int
5597c478bd9Sstevel@tonic-gate ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
5607c478bd9Sstevel@tonic-gate 	off_t len, caddr_t *vaddrp);
5617c478bd9Sstevel@tonic-gate 
5627c478bd9Sstevel@tonic-gate int
5637c478bd9Sstevel@tonic-gate nullbusmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
5647c478bd9Sstevel@tonic-gate 	off_t len, caddr_t *vaddrp);
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate int ddi_peek8(dev_info_t *dip, int8_t *addr, int8_t *val_p);
5677c478bd9Sstevel@tonic-gate int ddi_peek16(dev_info_t *dip, int16_t *addr, int16_t *val_p);
5687c478bd9Sstevel@tonic-gate int ddi_peek32(dev_info_t *dip, int32_t *addr, int32_t *val_p);
5697c478bd9Sstevel@tonic-gate int ddi_peek64(dev_info_t *dip, int64_t *addr, int64_t *val_p);
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate int ddi_poke8(dev_info_t *dip, int8_t *addr, int8_t val);
5727c478bd9Sstevel@tonic-gate int ddi_poke16(dev_info_t *dip, int16_t *addr, int16_t val);
5737c478bd9Sstevel@tonic-gate int ddi_poke32(dev_info_t *dip, int32_t *addr, int32_t val);
5747c478bd9Sstevel@tonic-gate int ddi_poke64(dev_info_t *dip, int64_t *addr, int64_t val);
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate /*
5777c478bd9Sstevel@tonic-gate  * Peek and poke to and from a uio structure in xfersize pieces,
5787c478bd9Sstevel@tonic-gate  * using the parent nexi.
5797c478bd9Sstevel@tonic-gate  */
5807c478bd9Sstevel@tonic-gate int ddi_peekpokeio(dev_info_t *devi, struct uio *uio, enum uio_rw rw,
5817c478bd9Sstevel@tonic-gate 	caddr_t addr, size_t len, uint_t xfersize);
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate /*
5847c478bd9Sstevel@tonic-gate  * Pagesize conversions using the parent nexi
5857c478bd9Sstevel@tonic-gate  */
5867c478bd9Sstevel@tonic-gate unsigned long ddi_btop(dev_info_t *dip, unsigned long bytes);
5877c478bd9Sstevel@tonic-gate unsigned long ddi_btopr(dev_info_t *dip, unsigned long bytes);
5887c478bd9Sstevel@tonic-gate unsigned long ddi_ptob(dev_info_t *dip, unsigned long pages);
5897c478bd9Sstevel@tonic-gate 
5907c478bd9Sstevel@tonic-gate /*
5917c478bd9Sstevel@tonic-gate  * There are no more "block" interrupt functions, per se.
5927c478bd9Sstevel@tonic-gate  * All thread of control should be done with MP/MT lockings.
5937c478bd9Sstevel@tonic-gate  *
5947c478bd9Sstevel@tonic-gate  * However, there are certain times in which a driver needs
5957c478bd9Sstevel@tonic-gate  * absolutely a critical guaranteed non-preemptable time
5967c478bd9Sstevel@tonic-gate  * in which to execute a few instructions.
5977c478bd9Sstevel@tonic-gate  *
5987c478bd9Sstevel@tonic-gate  * The following pair of functions attempt to guarantee this,
5997c478bd9Sstevel@tonic-gate  * but they are dangerous to use. That is, use them with
6007c478bd9Sstevel@tonic-gate  * extreme care. They do not guarantee to stop other processors
6017c478bd9Sstevel@tonic-gate  * from executing, but they do guarantee that the caller
6027c478bd9Sstevel@tonic-gate  * of ddi_enter_critical will continue to run until the
6037c478bd9Sstevel@tonic-gate  * caller calls ddi_exit_critical. No intervening DDI functions
6047c478bd9Sstevel@tonic-gate  * may be called between an entry and an exit from a critical
6057c478bd9Sstevel@tonic-gate  * region.
6067c478bd9Sstevel@tonic-gate  *
6077c478bd9Sstevel@tonic-gate  * ddi_enter_critical returns an integer identifier which must
6087c478bd9Sstevel@tonic-gate  * be passed to ddi_exit_critical.
6097c478bd9Sstevel@tonic-gate  *
6107c478bd9Sstevel@tonic-gate  * Be very sparing in the use of these functions since it is
6117c478bd9Sstevel@tonic-gate  * likely that absolutely nothing else can occur in the system
6127c478bd9Sstevel@tonic-gate  * whilst in the critical region.
6137c478bd9Sstevel@tonic-gate  */
6147c478bd9Sstevel@tonic-gate 
6157c478bd9Sstevel@tonic-gate unsigned int
6167c478bd9Sstevel@tonic-gate ddi_enter_critical(void);
6177c478bd9Sstevel@tonic-gate 
6187c478bd9Sstevel@tonic-gate void
6197c478bd9Sstevel@tonic-gate ddi_exit_critical(unsigned int);
6207c478bd9Sstevel@tonic-gate 
6217c478bd9Sstevel@tonic-gate /*
6227c478bd9Sstevel@tonic-gate  * devmap functions
6237c478bd9Sstevel@tonic-gate  */
6247c478bd9Sstevel@tonic-gate int
6257c478bd9Sstevel@tonic-gate devmap_setup(dev_t dev, offset_t off, ddi_as_handle_t as, caddr_t *addrp,
6267c478bd9Sstevel@tonic-gate 	size_t len, uint_t prot, uint_t maxprot, uint_t flags,
6277c478bd9Sstevel@tonic-gate 	struct cred *cred);
6287c478bd9Sstevel@tonic-gate 
6297c478bd9Sstevel@tonic-gate int
6307c478bd9Sstevel@tonic-gate ddi_devmap_segmap(dev_t dev, off_t off, ddi_as_handle_t as, caddr_t *addrp,
6317c478bd9Sstevel@tonic-gate 	off_t len, uint_t prot, uint_t maxprot, uint_t flags,
6327c478bd9Sstevel@tonic-gate 	struct cred *cred);
6337c478bd9Sstevel@tonic-gate 
6347c478bd9Sstevel@tonic-gate int
6357c478bd9Sstevel@tonic-gate devmap_load(devmap_cookie_t dhp, offset_t offset, size_t len, uint_t type,
6367c478bd9Sstevel@tonic-gate 	uint_t rw);
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate int
6397c478bd9Sstevel@tonic-gate devmap_unload(devmap_cookie_t dhp, offset_t offset, size_t len);
6407c478bd9Sstevel@tonic-gate 
6417c478bd9Sstevel@tonic-gate int
6427c478bd9Sstevel@tonic-gate devmap_devmem_setup(devmap_cookie_t dhp, dev_info_t *dip,
6437c478bd9Sstevel@tonic-gate 	struct devmap_callback_ctl *callback_ops,
6447c478bd9Sstevel@tonic-gate 	uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
6457c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6467c478bd9Sstevel@tonic-gate 
6477c478bd9Sstevel@tonic-gate int
6487c478bd9Sstevel@tonic-gate devmap_umem_setup(devmap_cookie_t dhp, dev_info_t *dip,
6497c478bd9Sstevel@tonic-gate 	struct devmap_callback_ctl *callback_ops,
6507c478bd9Sstevel@tonic-gate 	ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
6517c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6527c478bd9Sstevel@tonic-gate 
6537c478bd9Sstevel@tonic-gate int
6547c478bd9Sstevel@tonic-gate devmap_devmem_remap(devmap_cookie_t dhp, dev_info_t *dip,
6557c478bd9Sstevel@tonic-gate 	uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
6567c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate int
6597c478bd9Sstevel@tonic-gate devmap_umem_remap(devmap_cookie_t dhp, dev_info_t *dip,
6607c478bd9Sstevel@tonic-gate 	ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
6617c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6627c478bd9Sstevel@tonic-gate 
6637c478bd9Sstevel@tonic-gate void
6647c478bd9Sstevel@tonic-gate devmap_set_ctx_timeout(devmap_cookie_t dhp, clock_t ticks);
6657c478bd9Sstevel@tonic-gate 
6667c478bd9Sstevel@tonic-gate int
6677c478bd9Sstevel@tonic-gate devmap_default_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
6687c478bd9Sstevel@tonic-gate 	size_t len, uint_t type, uint_t rw);
6697c478bd9Sstevel@tonic-gate 
6707c478bd9Sstevel@tonic-gate int
6717c478bd9Sstevel@tonic-gate devmap_do_ctxmgt(devmap_cookie_t dhp, void *pvtp, offset_t off, size_t len,
6727c478bd9Sstevel@tonic-gate 	uint_t type, uint_t rw, int (*ctxmgt)(devmap_cookie_t, void *, offset_t,
6737c478bd9Sstevel@tonic-gate 	size_t, uint_t, uint_t));
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate void *ddi_umem_alloc(size_t size, int flag, ddi_umem_cookie_t *cookiep);
6777c478bd9Sstevel@tonic-gate 
6787c478bd9Sstevel@tonic-gate void ddi_umem_free(ddi_umem_cookie_t cookie);
6797c478bd9Sstevel@tonic-gate 
6807c478bd9Sstevel@tonic-gate /*
6817c478bd9Sstevel@tonic-gate  * Functions to lock user memory and do repeated I/O or do devmap_umem_setup
6827c478bd9Sstevel@tonic-gate  */
6837c478bd9Sstevel@tonic-gate int
6847c478bd9Sstevel@tonic-gate ddi_umem_lock(caddr_t addr, size_t size, int flags, ddi_umem_cookie_t *cookie);
6857c478bd9Sstevel@tonic-gate 
6867c478bd9Sstevel@tonic-gate void
6877c478bd9Sstevel@tonic-gate ddi_umem_unlock(ddi_umem_cookie_t cookie);
6887c478bd9Sstevel@tonic-gate 
6897c478bd9Sstevel@tonic-gate struct buf *
6907c478bd9Sstevel@tonic-gate ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction,
6917c478bd9Sstevel@tonic-gate     dev_t dev, daddr_t blkno, int (*iodone)(struct buf *), int sleepflag);
6927c478bd9Sstevel@tonic-gate 
6937c478bd9Sstevel@tonic-gate /*
6947c478bd9Sstevel@tonic-gate  * Mapping functions
6957c478bd9Sstevel@tonic-gate  */
6967c478bd9Sstevel@tonic-gate int
6977c478bd9Sstevel@tonic-gate ddi_segmap(dev_t dev, off_t offset, struct as *asp, caddr_t *addrp, off_t len,
6987c478bd9Sstevel@tonic-gate 	uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp);
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate int
7017c478bd9Sstevel@tonic-gate ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, caddr_t *addrp,
7027c478bd9Sstevel@tonic-gate 	off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cred,
7037c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, uint_t rnumber);
7047c478bd9Sstevel@tonic-gate 
7057c478bd9Sstevel@tonic-gate int
7067c478bd9Sstevel@tonic-gate ddi_map_fault(dev_info_t *dip, struct hat *hat, struct seg *seg, caddr_t addr,
7077c478bd9Sstevel@tonic-gate 	struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate int
7107c478bd9Sstevel@tonic-gate ddi_device_mapping_check(dev_t dev, ddi_device_acc_attr_t *accattrp,
7117c478bd9Sstevel@tonic-gate 	uint_t rnumber, uint_t *hat_flags);
7127c478bd9Sstevel@tonic-gate 
7137c478bd9Sstevel@tonic-gate /*
7147c478bd9Sstevel@tonic-gate  * Property functions:   See also, ddipropdefs.h.
7157c478bd9Sstevel@tonic-gate  *			In general, the underlying driver MUST be held
7167c478bd9Sstevel@tonic-gate  *			to call it's property functions.
7177c478bd9Sstevel@tonic-gate  */
7187c478bd9Sstevel@tonic-gate 
7197c478bd9Sstevel@tonic-gate /*
7207c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup integer properties
7217c478bd9Sstevel@tonic-gate  */
7227c478bd9Sstevel@tonic-gate int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags,
7237c478bd9Sstevel@tonic-gate     char *name, int defvalue);
7247c478bd9Sstevel@tonic-gate int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags,
7257c478bd9Sstevel@tonic-gate     char *name, int64_t defvalue);
7267c478bd9Sstevel@tonic-gate int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
7277c478bd9Sstevel@tonic-gate     char *name, int **data, uint_t *nelements);
7287c478bd9Sstevel@tonic-gate int ddi_prop_lookup_int64_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
7297c478bd9Sstevel@tonic-gate     char *name, int64_t **data, uint_t *nelements);
7307c478bd9Sstevel@tonic-gate int ddi_prop_update_int(dev_t match_dev, dev_info_t *dip,
7317c478bd9Sstevel@tonic-gate     char *name, int data);
7327c478bd9Sstevel@tonic-gate int ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip,
7337c478bd9Sstevel@tonic-gate     char *name, int64_t data);
7347c478bd9Sstevel@tonic-gate int ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip,
7357c478bd9Sstevel@tonic-gate     char *name, int *data, uint_t nelements);
7367c478bd9Sstevel@tonic-gate int ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip,
7377c478bd9Sstevel@tonic-gate     char *name, int64_t *data, uint_t nelements);
7387c478bd9Sstevel@tonic-gate /*
7397c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup string properties
7407c478bd9Sstevel@tonic-gate  */
7417c478bd9Sstevel@tonic-gate int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, uint_t flags,
7427c478bd9Sstevel@tonic-gate     char *name, char **data);
7437c478bd9Sstevel@tonic-gate int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
7447c478bd9Sstevel@tonic-gate     char *name, char ***data, uint_t *nelements);
7457c478bd9Sstevel@tonic-gate int ddi_prop_update_string(dev_t match_dev, dev_info_t *dip,
7467c478bd9Sstevel@tonic-gate     char *name, char *data);
7477c478bd9Sstevel@tonic-gate int ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
7487c478bd9Sstevel@tonic-gate     char *name, char **data, uint_t nelements);
7497c478bd9Sstevel@tonic-gate 
7507c478bd9Sstevel@tonic-gate /*
7517c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup byte properties
7527c478bd9Sstevel@tonic-gate  */
7537c478bd9Sstevel@tonic-gate int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
7547c478bd9Sstevel@tonic-gate     char *name, uchar_t **data, uint_t *nelements);
7557c478bd9Sstevel@tonic-gate int ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
7567c478bd9Sstevel@tonic-gate     char *name, uchar_t *data, uint_t nelements);
7577c478bd9Sstevel@tonic-gate 
7587c478bd9Sstevel@tonic-gate /*
7597c478bd9Sstevel@tonic-gate  * Used to verify the existence of a property or to see if a boolean
7607c478bd9Sstevel@tonic-gate  * property exists.
7617c478bd9Sstevel@tonic-gate  */
7627c478bd9Sstevel@tonic-gate int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name);
7637c478bd9Sstevel@tonic-gate 
7647c478bd9Sstevel@tonic-gate /*
7657c478bd9Sstevel@tonic-gate  * Used to free the data returned by the above property routines.
7667c478bd9Sstevel@tonic-gate  */
7677c478bd9Sstevel@tonic-gate void ddi_prop_free(void *data);
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate /*
7707c478bd9Sstevel@tonic-gate  * nopropop: For internal use in `dummy' cb_prop_op functions only
7717c478bd9Sstevel@tonic-gate  */
7727c478bd9Sstevel@tonic-gate 
7737c478bd9Sstevel@tonic-gate int
7747c478bd9Sstevel@tonic-gate nopropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
7757c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7767c478bd9Sstevel@tonic-gate 
7777c478bd9Sstevel@tonic-gate /*
7787c478bd9Sstevel@tonic-gate  * ddi_prop_op: The basic property operator for drivers.
7797c478bd9Sstevel@tonic-gate  *
7807c478bd9Sstevel@tonic-gate  * In ddi_prop_op, the type of valuep is interpreted based on prop_op:
7817c478bd9Sstevel@tonic-gate  *
7827c478bd9Sstevel@tonic-gate  *	prop_op			valuep
7837c478bd9Sstevel@tonic-gate  *	------			------
7847c478bd9Sstevel@tonic-gate  *
7857c478bd9Sstevel@tonic-gate  *	PROP_LEN		<unused>
7867c478bd9Sstevel@tonic-gate  *
7877c478bd9Sstevel@tonic-gate  *	PROP_LEN_AND_VAL_BUF	Pointer to callers buffer
7887c478bd9Sstevel@tonic-gate  *
7897c478bd9Sstevel@tonic-gate  *	PROP_LEN_AND_VAL_ALLOC	Address of callers pointer (will be set to
7907c478bd9Sstevel@tonic-gate  *				address of allocated buffer, if successful)
7917c478bd9Sstevel@tonic-gate  */
7927c478bd9Sstevel@tonic-gate 
7937c478bd9Sstevel@tonic-gate int
7947c478bd9Sstevel@tonic-gate ddi_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
7957c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7967c478bd9Sstevel@tonic-gate 
7977c478bd9Sstevel@tonic-gate /* ddi_prop_op_size: for drivers that implement size in bytes */
7987c478bd9Sstevel@tonic-gate int
7997c478bd9Sstevel@tonic-gate ddi_prop_op_size(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
8007c478bd9Sstevel@tonic-gate 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
8017c478bd9Sstevel@tonic-gate 	uint64_t size64);
8027c478bd9Sstevel@tonic-gate 
803184cd04cScth /* ddi_prop_op_size_blksize: like ddi_prop_op_size, in blksize blocks */
804184cd04cScth int
805184cd04cScth ddi_prop_op_size_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
806184cd04cScth 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
807184cd04cScth 	uint64_t size64, uint_t blksize);
808184cd04cScth 
8097c478bd9Sstevel@tonic-gate /* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */
8107c478bd9Sstevel@tonic-gate int
8117c478bd9Sstevel@tonic-gate ddi_prop_op_nblocks(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
8127c478bd9Sstevel@tonic-gate 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
8137c478bd9Sstevel@tonic-gate 	uint64_t nblocks64);
8147c478bd9Sstevel@tonic-gate 
815184cd04cScth /* ddi_prop_op_nblocks_blksize: like ddi_prop_op_nblocks, in blksize blocks */
816184cd04cScth int
817184cd04cScth ddi_prop_op_nblocks_blksize(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
818184cd04cScth 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
819184cd04cScth 	uint64_t nblocks64, uint_t blksize);
820184cd04cScth 
8217c478bd9Sstevel@tonic-gate /*
8227c478bd9Sstevel@tonic-gate  * Variable length props...
8237c478bd9Sstevel@tonic-gate  */
8247c478bd9Sstevel@tonic-gate 
8257c478bd9Sstevel@tonic-gate /*
8267c478bd9Sstevel@tonic-gate  * ddi_getlongprop:	Get variable length property len+val into a buffer
8277c478bd9Sstevel@tonic-gate  *		allocated by property provider via kmem_alloc. Requester
8287c478bd9Sstevel@tonic-gate  *		is responsible for freeing returned property via kmem_free.
8297c478bd9Sstevel@tonic-gate  *
8307c478bd9Sstevel@tonic-gate  * 	Arguments:
8317c478bd9Sstevel@tonic-gate  *
8327c478bd9Sstevel@tonic-gate  *	dev:	Input:	dev_t of property.
8337c478bd9Sstevel@tonic-gate  *	dip:	Input:	dev_info_t pointer of child.
8347c478bd9Sstevel@tonic-gate  *	flags:	Input:	Possible flag modifiers are:
8357c478bd9Sstevel@tonic-gate  *		DDI_PROP_DONTPASS:	Don't pass to parent if prop not found.
8367c478bd9Sstevel@tonic-gate  *		DDI_PROP_CANSLEEP:	Memory allocation may sleep.
8377c478bd9Sstevel@tonic-gate  *	name:	Input:	name of property.
8387c478bd9Sstevel@tonic-gate  *	valuep:	Output:	Addr of callers buffer pointer.
8397c478bd9Sstevel@tonic-gate  *	lengthp:Output:	*lengthp will contain prop length on exit.
8407c478bd9Sstevel@tonic-gate  *
8417c478bd9Sstevel@tonic-gate  * 	Possible Returns:
8427c478bd9Sstevel@tonic-gate  *
8437c478bd9Sstevel@tonic-gate  *		DDI_PROP_SUCCESS:	Prop found and returned.
8447c478bd9Sstevel@tonic-gate  *		DDI_PROP_NOT_FOUND:	Prop not found
8457c478bd9Sstevel@tonic-gate  *		DDI_PROP_UNDEFINED:	Prop explicitly undefined.
8467c478bd9Sstevel@tonic-gate  *		DDI_PROP_NO_MEMORY:	Prop found, but unable to alloc mem.
8477c478bd9Sstevel@tonic-gate  */
8487c478bd9Sstevel@tonic-gate 
8497c478bd9Sstevel@tonic-gate int
8507c478bd9Sstevel@tonic-gate ddi_getlongprop(dev_t dev, dev_info_t *dip, int flags,
8517c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
8527c478bd9Sstevel@tonic-gate 
8537c478bd9Sstevel@tonic-gate /*
8547c478bd9Sstevel@tonic-gate  *
8557c478bd9Sstevel@tonic-gate  * ddi_getlongprop_buf:		Get long prop into pre-allocated callers
8567c478bd9Sstevel@tonic-gate  *				buffer. (no memory allocation by provider).
8577c478bd9Sstevel@tonic-gate  *
8587c478bd9Sstevel@tonic-gate  *	dev:	Input:	dev_t of property.
8597c478bd9Sstevel@tonic-gate  *	dip:	Input:	dev_info_t pointer of child.
8607c478bd9Sstevel@tonic-gate  *	flags:	Input:	DDI_PROP_DONTPASS or NULL
8617c478bd9Sstevel@tonic-gate  *	name:	Input:	name of property
8627c478bd9Sstevel@tonic-gate  *	valuep:	Input:	ptr to callers buffer.
8637c478bd9Sstevel@tonic-gate  *	lengthp:I/O:	ptr to length of callers buffer on entry,
8647c478bd9Sstevel@tonic-gate  *			actual length of property on exit.
8657c478bd9Sstevel@tonic-gate  *
8667c478bd9Sstevel@tonic-gate  *	Possible returns:
8677c478bd9Sstevel@tonic-gate  *
8687c478bd9Sstevel@tonic-gate  *		DDI_PROP_SUCCESS	Prop found and returned
8697c478bd9Sstevel@tonic-gate  *		DDI_PROP_NOT_FOUND	Prop not found
8707c478bd9Sstevel@tonic-gate  *		DDI_PROP_UNDEFINED	Prop explicitly undefined.
8717c478bd9Sstevel@tonic-gate  *		DDI_PROP_BUF_TOO_SMALL	Prop found, callers buf too small,
8727c478bd9Sstevel@tonic-gate  *					no value returned, but actual prop
8737c478bd9Sstevel@tonic-gate  *					length returned in *lengthp
8747c478bd9Sstevel@tonic-gate  *
8757c478bd9Sstevel@tonic-gate  */
8767c478bd9Sstevel@tonic-gate 
8777c478bd9Sstevel@tonic-gate int
8787c478bd9Sstevel@tonic-gate ddi_getlongprop_buf(dev_t dev, dev_info_t *dip, int flags,
8797c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
8807c478bd9Sstevel@tonic-gate 
8817c478bd9Sstevel@tonic-gate /*
8827c478bd9Sstevel@tonic-gate  * Integer/boolean sized props.
8837c478bd9Sstevel@tonic-gate  *
8847c478bd9Sstevel@tonic-gate  * Call is value only... returns found boolean or int sized prop value or
8857c478bd9Sstevel@tonic-gate  * defvalue if prop not found or is wrong length or is explicitly undefined.
8867c478bd9Sstevel@tonic-gate  * Only flag is DDI_PROP_DONTPASS...
8877c478bd9Sstevel@tonic-gate  *
8887c478bd9Sstevel@tonic-gate  * By convention, this interface returns boolean (0) sized properties
8897c478bd9Sstevel@tonic-gate  * as value (int)1.
8907c478bd9Sstevel@tonic-gate  */
8917c478bd9Sstevel@tonic-gate 
8927c478bd9Sstevel@tonic-gate int
8937c478bd9Sstevel@tonic-gate ddi_getprop(dev_t dev, dev_info_t *dip, int flags, char *name, int defvalue);
8947c478bd9Sstevel@tonic-gate 
8957c478bd9Sstevel@tonic-gate /*
8967c478bd9Sstevel@tonic-gate  * Get prop length interface: flags are 0 or DDI_PROP_DONTPASS
8977c478bd9Sstevel@tonic-gate  * if returns DDI_PROP_SUCCESS, length returned in *lengthp.
8987c478bd9Sstevel@tonic-gate  */
8997c478bd9Sstevel@tonic-gate 
9007c478bd9Sstevel@tonic-gate int
9017c478bd9Sstevel@tonic-gate ddi_getproplen(dev_t dev, dev_info_t *dip, int flags, char *name, int *lengthp);
9027c478bd9Sstevel@tonic-gate 
9037c478bd9Sstevel@tonic-gate 
9047c478bd9Sstevel@tonic-gate /*
9057c478bd9Sstevel@tonic-gate  * Interface to create/modify a managed property on child's behalf...
9067c478bd9Sstevel@tonic-gate  * Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep
9077c478bd9Sstevel@tonic-gate  * if no memory available for internal prop structure.  Long property
9087c478bd9Sstevel@tonic-gate  * (non integer sized) value references are not copied.
9097c478bd9Sstevel@tonic-gate  *
9107c478bd9Sstevel@tonic-gate  * Define property with DDI_DEV_T_NONE dev_t for properties not associated
9117c478bd9Sstevel@tonic-gate  * with any particular dev_t. Use the same dev_t when modifying or undefining
9127c478bd9Sstevel@tonic-gate  * a property.
9137c478bd9Sstevel@tonic-gate  *
9147c478bd9Sstevel@tonic-gate  * No guarantee on order of property search, so don't mix the same
9157c478bd9Sstevel@tonic-gate  * property name with wildcard and non-wildcard dev_t's.
9167c478bd9Sstevel@tonic-gate  */
9177c478bd9Sstevel@tonic-gate 
9187c478bd9Sstevel@tonic-gate /*
9197c478bd9Sstevel@tonic-gate  * ddi_prop_create:	Define a managed property:
9207c478bd9Sstevel@tonic-gate  */
9217c478bd9Sstevel@tonic-gate 
9227c478bd9Sstevel@tonic-gate int
9237c478bd9Sstevel@tonic-gate ddi_prop_create(dev_t dev, dev_info_t *dip, int flag,
9247c478bd9Sstevel@tonic-gate 	char *name, caddr_t value, int length);
9257c478bd9Sstevel@tonic-gate 
9267c478bd9Sstevel@tonic-gate /*
9277c478bd9Sstevel@tonic-gate  * ddi_prop_modify:	Modify a managed property value
9287c478bd9Sstevel@tonic-gate  */
9297c478bd9Sstevel@tonic-gate 
9307c478bd9Sstevel@tonic-gate int
9317c478bd9Sstevel@tonic-gate ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag,
9327c478bd9Sstevel@tonic-gate 	char *name, caddr_t value, int length);
9337c478bd9Sstevel@tonic-gate 
9347c478bd9Sstevel@tonic-gate /*
9357c478bd9Sstevel@tonic-gate  * ddi_prop_remove:	Undefine a managed property:
9367c478bd9Sstevel@tonic-gate  */
9377c478bd9Sstevel@tonic-gate 
9387c478bd9Sstevel@tonic-gate int
9397c478bd9Sstevel@tonic-gate ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
9407c478bd9Sstevel@tonic-gate 
9417c478bd9Sstevel@tonic-gate /*
9427c478bd9Sstevel@tonic-gate  * ddi_prop_remove_all:		Used before unloading a driver to remove
9437c478bd9Sstevel@tonic-gate  *				all properties. (undefines all dev_t's props.)
9447c478bd9Sstevel@tonic-gate  *				Also removes `undefined' prop defs.
9457c478bd9Sstevel@tonic-gate  */
9467c478bd9Sstevel@tonic-gate 
9477c478bd9Sstevel@tonic-gate void
9487c478bd9Sstevel@tonic-gate ddi_prop_remove_all(dev_info_t *dip);
9497c478bd9Sstevel@tonic-gate 
9507c478bd9Sstevel@tonic-gate 
9517c478bd9Sstevel@tonic-gate /*
9527c478bd9Sstevel@tonic-gate  * ddi_prop_undefine:	Explicitly undefine a property.  Property
9537c478bd9Sstevel@tonic-gate  *			searches which match this property return
9547c478bd9Sstevel@tonic-gate  *			the error code DDI_PROP_UNDEFINED.
9557c478bd9Sstevel@tonic-gate  *
9567c478bd9Sstevel@tonic-gate  *			Use ddi_prop_remove to negate effect of
9577c478bd9Sstevel@tonic-gate  *			ddi_prop_undefine
9587c478bd9Sstevel@tonic-gate  */
9597c478bd9Sstevel@tonic-gate 
9607c478bd9Sstevel@tonic-gate int
9617c478bd9Sstevel@tonic-gate ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name);
9627c478bd9Sstevel@tonic-gate 
9637c478bd9Sstevel@tonic-gate 
9647c478bd9Sstevel@tonic-gate /*
965b9ccdc5aScth  * ddi_prop_cache_invalidate
966b9ccdc5aScth  *			Invalidate a property in the current cached
967b9ccdc5aScth  *			devinfo snapshot - next cached snapshot will
968b9ccdc5aScth  *			return the latest property value available.
969b9ccdc5aScth  */
970b9ccdc5aScth void
971b9ccdc5aScth ddi_prop_cache_invalidate(dev_t dev, dev_info_t *dip, char *name, int flags);
972b9ccdc5aScth 
973b9ccdc5aScth /*
9747c478bd9Sstevel@tonic-gate  * The default ddi_bus_prop_op wrapper...
9757c478bd9Sstevel@tonic-gate  */
9767c478bd9Sstevel@tonic-gate 
9777c478bd9Sstevel@tonic-gate int
9787c478bd9Sstevel@tonic-gate ddi_bus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip,
9797c478bd9Sstevel@tonic-gate 	ddi_prop_op_t prop_op, int mod_flags,
9807c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
9817c478bd9Sstevel@tonic-gate 
9827c478bd9Sstevel@tonic-gate 
9837c478bd9Sstevel@tonic-gate /*
9847c478bd9Sstevel@tonic-gate  * Routines to traverse the tree of dev_info nodes.
9857c478bd9Sstevel@tonic-gate  * The general idea of these functions is to provide
9867c478bd9Sstevel@tonic-gate  * various tree traversal utilities. For each node
9877c478bd9Sstevel@tonic-gate  * that the tree traversal function finds, a caller
9887c478bd9Sstevel@tonic-gate  * supplied function is called with arguments of
9897c478bd9Sstevel@tonic-gate  * the current node and a caller supplied argument.
9907c478bd9Sstevel@tonic-gate  * The caller supplied function should return one
9917c478bd9Sstevel@tonic-gate  * of the integer values defined below which will
9927c478bd9Sstevel@tonic-gate  * indicate to the tree traversal function whether
9937c478bd9Sstevel@tonic-gate  * the traversal should be continued, and if so, how,
9947c478bd9Sstevel@tonic-gate  * or whether the traversal should terminate.
9957c478bd9Sstevel@tonic-gate  */
9967c478bd9Sstevel@tonic-gate 
9977c478bd9Sstevel@tonic-gate /*
9987c478bd9Sstevel@tonic-gate  * This general-purpose routine traverses the tree of dev_info nodes,
9997c478bd9Sstevel@tonic-gate  * starting from the given node, and calls the given function for each
10007c478bd9Sstevel@tonic-gate  * node that it finds with the current node and the pointer arg (which
10017c478bd9Sstevel@tonic-gate  * can point to a structure of information that the function
10027c478bd9Sstevel@tonic-gate  * needs) as arguments.
10037c478bd9Sstevel@tonic-gate  *
10047c478bd9Sstevel@tonic-gate  * It does the walk a layer at a time, not depth-first.
10057c478bd9Sstevel@tonic-gate  *
10067c478bd9Sstevel@tonic-gate  * The given function must return one of the values defined above.
10077c478bd9Sstevel@tonic-gate  *
10087c478bd9Sstevel@tonic-gate  */
10097c478bd9Sstevel@tonic-gate 
10107c478bd9Sstevel@tonic-gate void
10117c478bd9Sstevel@tonic-gate ddi_walk_devs(dev_info_t *, int (*)(dev_info_t *, void *), void *);
10127c478bd9Sstevel@tonic-gate 
10137c478bd9Sstevel@tonic-gate /*
10147c478bd9Sstevel@tonic-gate  * Routines to get at elements of the dev_info structure
10157c478bd9Sstevel@tonic-gate  */
10167c478bd9Sstevel@tonic-gate 
10177c478bd9Sstevel@tonic-gate /*
10187c478bd9Sstevel@tonic-gate  * ddi_node_name gets the device's 'name' from the device node.
10197c478bd9Sstevel@tonic-gate  *
10207c478bd9Sstevel@tonic-gate  * ddi_binding_name gets the string the OS used to bind the node to a driver,
10217c478bd9Sstevel@tonic-gate  * in certain cases, the binding name may be different from the node name,
10227c478bd9Sstevel@tonic-gate  * if the node name does not name a specific device driver.
10237c478bd9Sstevel@tonic-gate  *
10247c478bd9Sstevel@tonic-gate  * ddi_get_name is a synonym for ddi_binding_name().
10257c478bd9Sstevel@tonic-gate  */
10267c478bd9Sstevel@tonic-gate char *
10277c478bd9Sstevel@tonic-gate ddi_get_name(dev_info_t *dip);
10287c478bd9Sstevel@tonic-gate 
10297c478bd9Sstevel@tonic-gate char *
10307c478bd9Sstevel@tonic-gate ddi_binding_name(dev_info_t *dip);
10317c478bd9Sstevel@tonic-gate 
10327c478bd9Sstevel@tonic-gate const char *
10337c478bd9Sstevel@tonic-gate ddi_driver_name(dev_info_t *dip);
10347c478bd9Sstevel@tonic-gate 
10357c478bd9Sstevel@tonic-gate major_t
10367c478bd9Sstevel@tonic-gate ddi_driver_major(dev_info_t *dip);
10377c478bd9Sstevel@tonic-gate 
10387c478bd9Sstevel@tonic-gate major_t
10397c478bd9Sstevel@tonic-gate ddi_compatible_driver_major(dev_info_t *dip, char **formp);
10407c478bd9Sstevel@tonic-gate 
10417c478bd9Sstevel@tonic-gate char *
10427c478bd9Sstevel@tonic-gate ddi_node_name(dev_info_t *dip);
10437c478bd9Sstevel@tonic-gate 
10447c478bd9Sstevel@tonic-gate int
10457c478bd9Sstevel@tonic-gate ddi_get_nodeid(dev_info_t *dip);
10467c478bd9Sstevel@tonic-gate 
10477c478bd9Sstevel@tonic-gate int
10487c478bd9Sstevel@tonic-gate ddi_get_instance(dev_info_t *dip);
10497c478bd9Sstevel@tonic-gate 
10507c478bd9Sstevel@tonic-gate struct dev_ops *
10517c478bd9Sstevel@tonic-gate ddi_get_driver(dev_info_t *dip);
10527c478bd9Sstevel@tonic-gate 
10537c478bd9Sstevel@tonic-gate void
10547c478bd9Sstevel@tonic-gate ddi_set_driver(dev_info_t *dip, struct dev_ops *devo);
10557c478bd9Sstevel@tonic-gate 
10567c478bd9Sstevel@tonic-gate void
10577c478bd9Sstevel@tonic-gate ddi_set_driver_private(dev_info_t *dip, void *data);
10587c478bd9Sstevel@tonic-gate 
10597c478bd9Sstevel@tonic-gate void *
10607c478bd9Sstevel@tonic-gate ddi_get_driver_private(dev_info_t *dip);
10617c478bd9Sstevel@tonic-gate 
10627c478bd9Sstevel@tonic-gate /*
10637c478bd9Sstevel@tonic-gate  * ddi_dev_is_needed tells system that a device is about to use a
10647c478bd9Sstevel@tonic-gate  * component. Returns when component is ready.
10657c478bd9Sstevel@tonic-gate  */
10667c478bd9Sstevel@tonic-gate int
10677c478bd9Sstevel@tonic-gate ddi_dev_is_needed(dev_info_t *dip, int cmpt, int level);
10687c478bd9Sstevel@tonic-gate 
10697c478bd9Sstevel@tonic-gate /*
10707c478bd9Sstevel@tonic-gate  * check if DDI_SUSPEND may result in power being removed from a device.
10717c478bd9Sstevel@tonic-gate  */
10727c478bd9Sstevel@tonic-gate int
10737c478bd9Sstevel@tonic-gate ddi_removing_power(dev_info_t *dip);
10747c478bd9Sstevel@tonic-gate 
10757c478bd9Sstevel@tonic-gate /*
10767c478bd9Sstevel@tonic-gate  *  (Obsolete) power entry point
10777c478bd9Sstevel@tonic-gate  */
10787c478bd9Sstevel@tonic-gate int
10797c478bd9Sstevel@tonic-gate ddi_power(dev_info_t *dip, int cmpt, int level);
10807c478bd9Sstevel@tonic-gate 
10817c478bd9Sstevel@tonic-gate /*
10827c478bd9Sstevel@tonic-gate  * ddi_get_parent requires that the branch of the tree with the
10837c478bd9Sstevel@tonic-gate  * node be held (ddi_hold_installed_driver) or that the devinfo tree
10847c478bd9Sstevel@tonic-gate  * lock be held
10857c478bd9Sstevel@tonic-gate  */
10867c478bd9Sstevel@tonic-gate dev_info_t *
10877c478bd9Sstevel@tonic-gate ddi_get_parent(dev_info_t *dip);
10887c478bd9Sstevel@tonic-gate 
10897c478bd9Sstevel@tonic-gate /*
10907c478bd9Sstevel@tonic-gate  * ddi_get_child and ddi_get_next_sibling require that the devinfo
10917c478bd9Sstevel@tonic-gate  * tree lock be held
10927c478bd9Sstevel@tonic-gate  */
10937c478bd9Sstevel@tonic-gate dev_info_t *
10947c478bd9Sstevel@tonic-gate ddi_get_child(dev_info_t *dip);
10957c478bd9Sstevel@tonic-gate 
10967c478bd9Sstevel@tonic-gate dev_info_t *
10977c478bd9Sstevel@tonic-gate ddi_get_next_sibling(dev_info_t *dip);
10987c478bd9Sstevel@tonic-gate 
10997c478bd9Sstevel@tonic-gate dev_info_t *
11007c478bd9Sstevel@tonic-gate ddi_get_next(dev_info_t *dip);
11017c478bd9Sstevel@tonic-gate 
11027c478bd9Sstevel@tonic-gate void
11037c478bd9Sstevel@tonic-gate ddi_set_next(dev_info_t *dip, dev_info_t *nextdip);
11047c478bd9Sstevel@tonic-gate 
11057c478bd9Sstevel@tonic-gate /*
11067c478bd9Sstevel@tonic-gate  * dev_info manipulation functions
11077c478bd9Sstevel@tonic-gate  */
11087c478bd9Sstevel@tonic-gate 
11097c478bd9Sstevel@tonic-gate /*
11107c478bd9Sstevel@tonic-gate  * Add and remove child devices. These are part of the system framework.
11117c478bd9Sstevel@tonic-gate  *
11127c478bd9Sstevel@tonic-gate  * ddi_add_child creates a dev_info structure with the passed name,
11137c478bd9Sstevel@tonic-gate  * nodeid and instance arguments and makes it a child of pdip. Devices
11147c478bd9Sstevel@tonic-gate  * that are known directly by the hardware have real nodeids; devices
11157c478bd9Sstevel@tonic-gate  * that are software constructs use the defined DEVI_PSEUDO_NODEID
11167c478bd9Sstevel@tonic-gate  * for the node id.
11177c478bd9Sstevel@tonic-gate  *
11187c478bd9Sstevel@tonic-gate  * ddi_remove_node removes the node from the tree. This fails if this
11197c478bd9Sstevel@tonic-gate  * child has children. Parent and driver private data should already
11207c478bd9Sstevel@tonic-gate  * be released (freed) prior to calling this function.  If flag is
11217c478bd9Sstevel@tonic-gate  * non-zero, the child is removed from it's linked list of instances.
11227c478bd9Sstevel@tonic-gate  */
11237c478bd9Sstevel@tonic-gate dev_info_t *
11247c478bd9Sstevel@tonic-gate ddi_add_child(dev_info_t *pdip, char *name, uint_t nodeid, uint_t instance);
11257c478bd9Sstevel@tonic-gate 
11267c478bd9Sstevel@tonic-gate int
11277c478bd9Sstevel@tonic-gate ddi_remove_child(dev_info_t *dip, int flag);
11287c478bd9Sstevel@tonic-gate 
11297c478bd9Sstevel@tonic-gate /*
11307c478bd9Sstevel@tonic-gate  * Given the major number for a driver, make sure that dev_info nodes
11317c478bd9Sstevel@tonic-gate  * are created form the driver's hwconf file, the driver for the named
11327c478bd9Sstevel@tonic-gate  * device is loaded and attached, as well as any drivers for parent devices.
11337c478bd9Sstevel@tonic-gate  * Return a pointer to the driver's dev_ops struct with the dev_ops held.
11347c478bd9Sstevel@tonic-gate  * Note - Callers must release the dev_ops with ddi_rele_driver.
11357c478bd9Sstevel@tonic-gate  *
11367c478bd9Sstevel@tonic-gate  * When a driver is held, the branch of the devinfo tree from any of the
11377c478bd9Sstevel@tonic-gate  * drivers devinfos to the root node are automatically held.  This only
11387c478bd9Sstevel@tonic-gate  * applies to tree traversals up (and back down) the tree following the
11397c478bd9Sstevel@tonic-gate  * parent pointers.
11407c478bd9Sstevel@tonic-gate  *
11417c478bd9Sstevel@tonic-gate  * Use of this interface is discouraged, it may be removed in a future release.
11427c478bd9Sstevel@tonic-gate  */
11437c478bd9Sstevel@tonic-gate struct dev_ops *
11447c478bd9Sstevel@tonic-gate ddi_hold_installed_driver(major_t major);
11457c478bd9Sstevel@tonic-gate 
11467c478bd9Sstevel@tonic-gate void
11477c478bd9Sstevel@tonic-gate ddi_rele_driver(major_t major);
11487c478bd9Sstevel@tonic-gate 
11497c478bd9Sstevel@tonic-gate /*
11507c478bd9Sstevel@tonic-gate  * Attach and hold the specified instance of a driver.  The flags argument
11517c478bd9Sstevel@tonic-gate  * should be zero.
11527c478bd9Sstevel@tonic-gate  */
11537c478bd9Sstevel@tonic-gate dev_info_t *
11547c478bd9Sstevel@tonic-gate ddi_hold_devi_by_instance(major_t major, int instance, int flags);
11557c478bd9Sstevel@tonic-gate 
11567c478bd9Sstevel@tonic-gate void
11577c478bd9Sstevel@tonic-gate ddi_release_devi(dev_info_t *);
11587c478bd9Sstevel@tonic-gate 
11597c478bd9Sstevel@tonic-gate /*
11607c478bd9Sstevel@tonic-gate  * Associate a streams queue with a devinfo node
11617c478bd9Sstevel@tonic-gate  */
11627c478bd9Sstevel@tonic-gate void
11637c478bd9Sstevel@tonic-gate ddi_assoc_queue_with_devi(queue_t *, dev_info_t *);
11647c478bd9Sstevel@tonic-gate 
11657c478bd9Sstevel@tonic-gate /*
11667c478bd9Sstevel@tonic-gate  * Given the identifier string passed, make sure that dev_info nodes
11677c478bd9Sstevel@tonic-gate  * are created form the driver's hwconf file, the driver for the named
11687c478bd9Sstevel@tonic-gate  * device is loaded and attached, as well as any drivers for parent devices.
11697c478bd9Sstevel@tonic-gate  *
11707c478bd9Sstevel@tonic-gate  * Note that the driver is not held and is subject to being removed the instant
11717c478bd9Sstevel@tonic-gate  * this call completes.  You probably really want ddi_hold_installed_driver.
11727c478bd9Sstevel@tonic-gate  */
11737c478bd9Sstevel@tonic-gate int
11747c478bd9Sstevel@tonic-gate ddi_install_driver(char *idstring);
11757c478bd9Sstevel@tonic-gate 
11767c478bd9Sstevel@tonic-gate /*
11777c478bd9Sstevel@tonic-gate  * Routines that return specific nodes
11787c478bd9Sstevel@tonic-gate  */
11797c478bd9Sstevel@tonic-gate 
11807c478bd9Sstevel@tonic-gate dev_info_t *
11817c478bd9Sstevel@tonic-gate ddi_root_node(void);
11827c478bd9Sstevel@tonic-gate 
11837c478bd9Sstevel@tonic-gate /*
11847c478bd9Sstevel@tonic-gate  * Given a name and an instance number, find and return the
11857c478bd9Sstevel@tonic-gate  * dev_info from the current state of the device tree.
11867c478bd9Sstevel@tonic-gate  *
11877c478bd9Sstevel@tonic-gate  * If instance number is -1, return the first named instance.
11887c478bd9Sstevel@tonic-gate  *
11897c478bd9Sstevel@tonic-gate  * If attached is 1, exclude all nodes that are < DS_ATTACHED
11907c478bd9Sstevel@tonic-gate  *
11917c478bd9Sstevel@tonic-gate  * Requires that the devinfo tree be locked.
11927c478bd9Sstevel@tonic-gate  * If attached is 1, the driver must be held.
11937c478bd9Sstevel@tonic-gate  */
11947c478bd9Sstevel@tonic-gate dev_info_t *
11957c478bd9Sstevel@tonic-gate ddi_find_devinfo(char *name, int instance, int attached);
11967c478bd9Sstevel@tonic-gate 
11977c478bd9Sstevel@tonic-gate /*
11987c478bd9Sstevel@tonic-gate  * Synchronization of I/O with respect to various
11997c478bd9Sstevel@tonic-gate  * caches and system write buffers.
12007c478bd9Sstevel@tonic-gate  *
12017c478bd9Sstevel@tonic-gate  * Done at varying points during an I/O transfer (including at the
12027c478bd9Sstevel@tonic-gate  * removal of an I/O mapping).
12037c478bd9Sstevel@tonic-gate  *
12047c478bd9Sstevel@tonic-gate  * Due to the support of systems with write buffers which may
12057c478bd9Sstevel@tonic-gate  * not be able to be turned off, this function *must* used at
12067c478bd9Sstevel@tonic-gate  * any point in which data consistency might be required.
12077c478bd9Sstevel@tonic-gate  *
12087c478bd9Sstevel@tonic-gate  * Generally this means that if a memory object has multiple mappings
12097c478bd9Sstevel@tonic-gate  * (both for I/O, as described by the handle, and the IU, via, e.g.
12107c478bd9Sstevel@tonic-gate  * a call to ddi_dma_kvaddrp), and one mapping may have been
12117c478bd9Sstevel@tonic-gate  * used to modify the memory object, this function must be called
12127c478bd9Sstevel@tonic-gate  * to ensure that the modification of the memory object is
12137c478bd9Sstevel@tonic-gate  * complete, as well as possibly to inform other mappings of
12147c478bd9Sstevel@tonic-gate  * the object that any cached references to the object are
12157c478bd9Sstevel@tonic-gate  * now stale (and flush or invalidate these stale cache references
12167c478bd9Sstevel@tonic-gate  * as necessary).
12177c478bd9Sstevel@tonic-gate  *
12187c478bd9Sstevel@tonic-gate  * The function ddi_dma_sync() provides the general interface with
12197c478bd9Sstevel@tonic-gate  * respect to this capability. Generally, ddi_dma_free() (below) may
12207c478bd9Sstevel@tonic-gate  * be used in preference to ddi_dma_sync() as ddi_dma_free() calls
12217c478bd9Sstevel@tonic-gate  * ddi_dma_sync().
12227c478bd9Sstevel@tonic-gate  *
12237c478bd9Sstevel@tonic-gate  * Returns 0 if all caches that exist and are specified by cache_flags
12247c478bd9Sstevel@tonic-gate  * are successfully operated on, else -1.
12257c478bd9Sstevel@tonic-gate  *
12267c478bd9Sstevel@tonic-gate  * The argument offset specifies an offset into the mapping of the mapped
12277c478bd9Sstevel@tonic-gate  * object in which to perform the synchronization. It will be silently
12287c478bd9Sstevel@tonic-gate  * truncated to the granularity of underlying cache line sizes as
12297c478bd9Sstevel@tonic-gate  * appropriate.
12307c478bd9Sstevel@tonic-gate  *
12317c478bd9Sstevel@tonic-gate  * The argument len specifies a length starting from offset in which to
12327c478bd9Sstevel@tonic-gate  * perform the synchronization. A value of (uint_t) -1 means that the length
12337c478bd9Sstevel@tonic-gate  * proceeds from offset to the end of the mapping. The length argument
12347c478bd9Sstevel@tonic-gate  * will silently rounded up to the granularity of underlying cache line
12357c478bd9Sstevel@tonic-gate  * sizes  as appropriate.
12367c478bd9Sstevel@tonic-gate  *
12377c478bd9Sstevel@tonic-gate  * The argument flags specifies what to synchronize (the device's view of
12387c478bd9Sstevel@tonic-gate  * the object or the cpu's view of the object).
12397c478bd9Sstevel@tonic-gate  *
12407c478bd9Sstevel@tonic-gate  * Inquiring minds want to know when ddi_dma_sync should be used:
12417c478bd9Sstevel@tonic-gate  *
12427c478bd9Sstevel@tonic-gate  * +	When an object is mapped for dma, assume that an
12437c478bd9Sstevel@tonic-gate  *	implicit ddi_dma_sync() is done for you.
12447c478bd9Sstevel@tonic-gate  *
12457c478bd9Sstevel@tonic-gate  * +	When an object is unmapped (ddi_dma_free()), assume
12467c478bd9Sstevel@tonic-gate  *	that an implicit ddi_dma_sync() is done for you.
12477c478bd9Sstevel@tonic-gate  *
12487c478bd9Sstevel@tonic-gate  * +	At any time between the two times above that the
12497c478bd9Sstevel@tonic-gate  *	memory object may have been modified by either
12507c478bd9Sstevel@tonic-gate  *	the DMA device or a processor and you wish that
12517c478bd9Sstevel@tonic-gate  *	the change be noticed by the master that didn't
12527c478bd9Sstevel@tonic-gate  *	do the modifying.
12537c478bd9Sstevel@tonic-gate  *
12547c478bd9Sstevel@tonic-gate  * Clearly, only the third case above requires the use of ddi_dma_sync.
12557c478bd9Sstevel@tonic-gate  *
12567c478bd9Sstevel@tonic-gate  * Inquiring minds also want to know which flag to use:
12577c478bd9Sstevel@tonic-gate  *
12587c478bd9Sstevel@tonic-gate  * +	If you *modify* with a cpu the object, you use
12597c478bd9Sstevel@tonic-gate  *	ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure
12607c478bd9Sstevel@tonic-gate  *	that the DMA device sees the changes you made).
12617c478bd9Sstevel@tonic-gate  *
12627c478bd9Sstevel@tonic-gate  * +	If you are checking, with the processor, an area
12637c478bd9Sstevel@tonic-gate  *	of the object that the DMA device *may* have modified,
12647c478bd9Sstevel@tonic-gate  *	you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are
12657c478bd9Sstevel@tonic-gate  *	making sure that the processor(s) will see the changes
12667c478bd9Sstevel@tonic-gate  *	that the DMA device may have made).
12677c478bd9Sstevel@tonic-gate  */
12687c478bd9Sstevel@tonic-gate 
12697c478bd9Sstevel@tonic-gate int
12707c478bd9Sstevel@tonic-gate ddi_dma_sync(ddi_dma_handle_t handle, off_t offset, size_t len, uint_t flags);
12717c478bd9Sstevel@tonic-gate 
12727c478bd9Sstevel@tonic-gate /*
12737c478bd9Sstevel@tonic-gate  * Return the allowable DMA burst size for the object mapped by handle.
12747c478bd9Sstevel@tonic-gate  * The burst sizes will returned in an integer that encodes power
12757c478bd9Sstevel@tonic-gate  * of two burst sizes that are allowed in bit encoded format. For
12767c478bd9Sstevel@tonic-gate  * example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts
12777c478bd9Sstevel@tonic-gate  * would be encoded as 0x2f. A transfer that could be allowed as solely
12787c478bd9Sstevel@tonic-gate  * a halfword (2 byte) transfers would be returned as 0x2.
12797c478bd9Sstevel@tonic-gate  */
12807c478bd9Sstevel@tonic-gate 
12817c478bd9Sstevel@tonic-gate int
12827c478bd9Sstevel@tonic-gate ddi_dma_burstsizes(ddi_dma_handle_t handle);
12837c478bd9Sstevel@tonic-gate 
12847c478bd9Sstevel@tonic-gate /*
12857c478bd9Sstevel@tonic-gate  * Merge DMA attributes
12867c478bd9Sstevel@tonic-gate  */
12877c478bd9Sstevel@tonic-gate 
12887c478bd9Sstevel@tonic-gate void
12897c478bd9Sstevel@tonic-gate ddi_dma_attr_merge(ddi_dma_attr_t *attr, ddi_dma_attr_t *mod);
12907c478bd9Sstevel@tonic-gate 
12917c478bd9Sstevel@tonic-gate /*
12927c478bd9Sstevel@tonic-gate  * Allocate a DMA handle
12937c478bd9Sstevel@tonic-gate  */
12947c478bd9Sstevel@tonic-gate 
12957c478bd9Sstevel@tonic-gate int
12967c478bd9Sstevel@tonic-gate ddi_dma_alloc_handle(dev_info_t *dip, ddi_dma_attr_t *attr,
12977c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg,
12987c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
12997c478bd9Sstevel@tonic-gate 
13007c478bd9Sstevel@tonic-gate /*
13017c478bd9Sstevel@tonic-gate  * Free DMA handle
13027c478bd9Sstevel@tonic-gate  */
13037c478bd9Sstevel@tonic-gate 
13047c478bd9Sstevel@tonic-gate void
13057c478bd9Sstevel@tonic-gate ddi_dma_free_handle(ddi_dma_handle_t *handlep);
13067c478bd9Sstevel@tonic-gate 
13077c478bd9Sstevel@tonic-gate /*
13087c478bd9Sstevel@tonic-gate  * Allocate memory for DMA transfers
13097c478bd9Sstevel@tonic-gate  */
13107c478bd9Sstevel@tonic-gate 
13117c478bd9Sstevel@tonic-gate int
13127c478bd9Sstevel@tonic-gate ddi_dma_mem_alloc(ddi_dma_handle_t handle, size_t length,
13137c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, uint_t xfermodes,
13147c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg, caddr_t *kaddrp,
13157c478bd9Sstevel@tonic-gate 	size_t *real_length, ddi_acc_handle_t *handlep);
13167c478bd9Sstevel@tonic-gate 
13177c478bd9Sstevel@tonic-gate /*
13187c478bd9Sstevel@tonic-gate  * Free DMA memory
13197c478bd9Sstevel@tonic-gate  */
13207c478bd9Sstevel@tonic-gate 
13217c478bd9Sstevel@tonic-gate void
13227c478bd9Sstevel@tonic-gate ddi_dma_mem_free(ddi_acc_handle_t *hp);
13237c478bd9Sstevel@tonic-gate 
13247c478bd9Sstevel@tonic-gate /*
13257c478bd9Sstevel@tonic-gate  * bind address to a DMA handle
13267c478bd9Sstevel@tonic-gate  */
13277c478bd9Sstevel@tonic-gate 
13287c478bd9Sstevel@tonic-gate int
13297c478bd9Sstevel@tonic-gate ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as,
13307c478bd9Sstevel@tonic-gate 	caddr_t addr, size_t len, uint_t flags,
13317c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg,
13327c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, uint_t *ccountp);
13337c478bd9Sstevel@tonic-gate 
13347c478bd9Sstevel@tonic-gate /*
13357c478bd9Sstevel@tonic-gate  * bind buffer to DMA handle
13367c478bd9Sstevel@tonic-gate  */
13377c478bd9Sstevel@tonic-gate 
13387c478bd9Sstevel@tonic-gate int
13397c478bd9Sstevel@tonic-gate ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp,
13407c478bd9Sstevel@tonic-gate 	uint_t flags, int (*waitfp)(caddr_t), caddr_t arg,
13417c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, uint_t *ccountp);
13427c478bd9Sstevel@tonic-gate 
13437c478bd9Sstevel@tonic-gate /*
13447c478bd9Sstevel@tonic-gate  * unbind mapping object to handle
13457c478bd9Sstevel@tonic-gate  */
13467c478bd9Sstevel@tonic-gate 
13477c478bd9Sstevel@tonic-gate int
13487c478bd9Sstevel@tonic-gate ddi_dma_unbind_handle(ddi_dma_handle_t handle);
13497c478bd9Sstevel@tonic-gate 
13507c478bd9Sstevel@tonic-gate /*
13517c478bd9Sstevel@tonic-gate  * get next DMA cookie
13527c478bd9Sstevel@tonic-gate  */
13537c478bd9Sstevel@tonic-gate 
13547c478bd9Sstevel@tonic-gate void
13557c478bd9Sstevel@tonic-gate ddi_dma_nextcookie(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep);
13567c478bd9Sstevel@tonic-gate 
13577c478bd9Sstevel@tonic-gate /*
13587c478bd9Sstevel@tonic-gate  * get number of DMA windows
13597c478bd9Sstevel@tonic-gate  */
13607c478bd9Sstevel@tonic-gate 
13617c478bd9Sstevel@tonic-gate int
13627c478bd9Sstevel@tonic-gate ddi_dma_numwin(ddi_dma_handle_t handle, uint_t *nwinp);
13637c478bd9Sstevel@tonic-gate 
13647c478bd9Sstevel@tonic-gate /*
13657c478bd9Sstevel@tonic-gate  * get specific DMA window
13667c478bd9Sstevel@tonic-gate  */
13677c478bd9Sstevel@tonic-gate 
13687c478bd9Sstevel@tonic-gate int
13697c478bd9Sstevel@tonic-gate ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp,
13707c478bd9Sstevel@tonic-gate 	size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
13717c478bd9Sstevel@tonic-gate 
13727c478bd9Sstevel@tonic-gate /*
13737c478bd9Sstevel@tonic-gate  * activate 64 bit SBus support
13747c478bd9Sstevel@tonic-gate  */
13757c478bd9Sstevel@tonic-gate 
13767c478bd9Sstevel@tonic-gate int
13777c478bd9Sstevel@tonic-gate ddi_dma_set_sbus64(ddi_dma_handle_t handle, ulong_t burstsizes);
13787c478bd9Sstevel@tonic-gate 
13797c478bd9Sstevel@tonic-gate /*
13807c478bd9Sstevel@tonic-gate  * Miscellaneous functions
13817c478bd9Sstevel@tonic-gate  */
13827c478bd9Sstevel@tonic-gate 
13837c478bd9Sstevel@tonic-gate /*
13847c478bd9Sstevel@tonic-gate  * ddi_report_dev:	Report a successful attach.
13857c478bd9Sstevel@tonic-gate  */
13867c478bd9Sstevel@tonic-gate 
13877c478bd9Sstevel@tonic-gate void
13887c478bd9Sstevel@tonic-gate ddi_report_dev(dev_info_t *dev);
13897c478bd9Sstevel@tonic-gate 
13907c478bd9Sstevel@tonic-gate /*
13917c478bd9Sstevel@tonic-gate  * ddi_dev_regsize
13927c478bd9Sstevel@tonic-gate  *
13937c478bd9Sstevel@tonic-gate  *	If the device has h/w register(s), report
13947c478bd9Sstevel@tonic-gate  *	the size, in bytes, of the specified one into *resultp.
13957c478bd9Sstevel@tonic-gate  *
13967c478bd9Sstevel@tonic-gate  *	Returns DDI_FAILURE if there are not registers,
13977c478bd9Sstevel@tonic-gate  *	or the specified register doesn't exist.
13987c478bd9Sstevel@tonic-gate  */
13997c478bd9Sstevel@tonic-gate 
14007c478bd9Sstevel@tonic-gate int
14017c478bd9Sstevel@tonic-gate ddi_dev_regsize(dev_info_t *dev, uint_t rnumber, off_t *resultp);
14027c478bd9Sstevel@tonic-gate 
14037c478bd9Sstevel@tonic-gate /*
14047c478bd9Sstevel@tonic-gate  * ddi_dev_nregs
14057c478bd9Sstevel@tonic-gate  *
14067c478bd9Sstevel@tonic-gate  *	If the device has h/w register(s), report
14077c478bd9Sstevel@tonic-gate  *	how many of them that there are into resultp.
14087c478bd9Sstevel@tonic-gate  *	Return DDI_FAILURE if the device has no registers.
14097c478bd9Sstevel@tonic-gate  */
14107c478bd9Sstevel@tonic-gate 
14117c478bd9Sstevel@tonic-gate int
14127c478bd9Sstevel@tonic-gate ddi_dev_nregs(dev_info_t *dev, int *resultp);
14137c478bd9Sstevel@tonic-gate 
14147c478bd9Sstevel@tonic-gate /*
14157c478bd9Sstevel@tonic-gate  * ddi_dev_is_sid
14167c478bd9Sstevel@tonic-gate  *
14177c478bd9Sstevel@tonic-gate  *	If the device is self-identifying, i.e.,
14187c478bd9Sstevel@tonic-gate  *	has already been probed by a smart PROM
14197c478bd9Sstevel@tonic-gate  *	(and thus registers are known to be valid)
14207c478bd9Sstevel@tonic-gate  *	return DDI_SUCCESS, else DDI_FAILURE.
14217c478bd9Sstevel@tonic-gate  */
14227c478bd9Sstevel@tonic-gate 
14237c478bd9Sstevel@tonic-gate 
14247c478bd9Sstevel@tonic-gate int
14257c478bd9Sstevel@tonic-gate ddi_dev_is_sid(dev_info_t *dev);
14267c478bd9Sstevel@tonic-gate 
14277c478bd9Sstevel@tonic-gate /*
14287c478bd9Sstevel@tonic-gate  * ddi_slaveonly
14297c478bd9Sstevel@tonic-gate  *
14307c478bd9Sstevel@tonic-gate  *	If the device is on a bus that precludes
14317c478bd9Sstevel@tonic-gate  *	the device from being either a dma master or
14327c478bd9Sstevel@tonic-gate  *	a dma slave, return DDI_SUCCESS.
14337c478bd9Sstevel@tonic-gate  */
14347c478bd9Sstevel@tonic-gate 
14357c478bd9Sstevel@tonic-gate int
14367c478bd9Sstevel@tonic-gate ddi_slaveonly(dev_info_t *);
14377c478bd9Sstevel@tonic-gate 
14387c478bd9Sstevel@tonic-gate 
14397c478bd9Sstevel@tonic-gate /*
14407c478bd9Sstevel@tonic-gate  * ddi_dev_affinity
14417c478bd9Sstevel@tonic-gate  *
14427c478bd9Sstevel@tonic-gate  *	Report, via DDI_SUCCESS, whether there exists
14437c478bd9Sstevel@tonic-gate  *	an 'affinity' between two dev_info_t's. An
14447c478bd9Sstevel@tonic-gate  *	affinity is defined to be either a parent-child,
14457c478bd9Sstevel@tonic-gate  *	or a sibling relationship such that the siblings
14467c478bd9Sstevel@tonic-gate  *	or in the same part of the bus they happen to be
14477c478bd9Sstevel@tonic-gate  *	on.
14487c478bd9Sstevel@tonic-gate  */
14497c478bd9Sstevel@tonic-gate 
14507c478bd9Sstevel@tonic-gate int
14517c478bd9Sstevel@tonic-gate ddi_dev_affinity(dev_info_t *deva, dev_info_t *devb);
14527c478bd9Sstevel@tonic-gate 
14537c478bd9Sstevel@tonic-gate 
14547c478bd9Sstevel@tonic-gate /*
14557c478bd9Sstevel@tonic-gate  * ddi_set_callback
14567c478bd9Sstevel@tonic-gate  *
14577c478bd9Sstevel@tonic-gate  *	Set a function/arg pair into the callback list identified
14587c478bd9Sstevel@tonic-gate  *	by listid. *listid must always initially start out as zero.
14597c478bd9Sstevel@tonic-gate  */
14607c478bd9Sstevel@tonic-gate 
14617c478bd9Sstevel@tonic-gate void
14627c478bd9Sstevel@tonic-gate ddi_set_callback(int (*funcp)(caddr_t), caddr_t arg, uintptr_t *listid);
14637c478bd9Sstevel@tonic-gate 
14647c478bd9Sstevel@tonic-gate /*
14657c478bd9Sstevel@tonic-gate  * ddi_run_callback
14667c478bd9Sstevel@tonic-gate  *
14677c478bd9Sstevel@tonic-gate  *	Run the callback list identified by listid.
14687c478bd9Sstevel@tonic-gate  */
14697c478bd9Sstevel@tonic-gate 
14707c478bd9Sstevel@tonic-gate void
14717c478bd9Sstevel@tonic-gate ddi_run_callback(uintptr_t *listid);
14727c478bd9Sstevel@tonic-gate 
14737c478bd9Sstevel@tonic-gate /*
14747c478bd9Sstevel@tonic-gate  * More miscellaneous
14757c478bd9Sstevel@tonic-gate  */
14767c478bd9Sstevel@tonic-gate 
14777c478bd9Sstevel@tonic-gate int
14787c478bd9Sstevel@tonic-gate nochpoll(dev_t dev, short events, int anyyet, short *reventsp,
14797c478bd9Sstevel@tonic-gate 	struct pollhead **phpp);
14807c478bd9Sstevel@tonic-gate 
14817c478bd9Sstevel@tonic-gate dev_info_t *
14827c478bd9Sstevel@tonic-gate nodevinfo(dev_t dev, int otyp);
14837c478bd9Sstevel@tonic-gate 
14847c478bd9Sstevel@tonic-gate int
14857c478bd9Sstevel@tonic-gate ddi_no_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result);
14867c478bd9Sstevel@tonic-gate 
14877c478bd9Sstevel@tonic-gate int
14887c478bd9Sstevel@tonic-gate ddi_getinfo_1to1(dev_info_t *dip, ddi_info_cmd_t infocmd,
14897c478bd9Sstevel@tonic-gate     void *arg, void **result);
14907c478bd9Sstevel@tonic-gate 
14917c478bd9Sstevel@tonic-gate int
14927c478bd9Sstevel@tonic-gate ddifail(dev_info_t *devi, ddi_attach_cmd_t cmd);
14937c478bd9Sstevel@tonic-gate 
14947c478bd9Sstevel@tonic-gate int
14957c478bd9Sstevel@tonic-gate ddi_no_dma_map(dev_info_t *dip, dev_info_t *rdip,
14967c478bd9Sstevel@tonic-gate     struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
14977c478bd9Sstevel@tonic-gate 
14987c478bd9Sstevel@tonic-gate int
14997c478bd9Sstevel@tonic-gate ddi_no_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
15007c478bd9Sstevel@tonic-gate     int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
15017c478bd9Sstevel@tonic-gate 
15027c478bd9Sstevel@tonic-gate int
15037c478bd9Sstevel@tonic-gate ddi_no_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
15047c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle);
15057c478bd9Sstevel@tonic-gate 
15067c478bd9Sstevel@tonic-gate int
15077c478bd9Sstevel@tonic-gate ddi_no_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
15087c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
15097c478bd9Sstevel@tonic-gate     ddi_dma_cookie_t *cp, uint_t *ccountp);
15107c478bd9Sstevel@tonic-gate 
15117c478bd9Sstevel@tonic-gate int
15127c478bd9Sstevel@tonic-gate ddi_no_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
15137c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle);
15147c478bd9Sstevel@tonic-gate 
15157c478bd9Sstevel@tonic-gate int
15167c478bd9Sstevel@tonic-gate ddi_no_dma_flush(dev_info_t *dip, dev_info_t *rdip,
15177c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, off_t off, size_t len,
15187c478bd9Sstevel@tonic-gate     uint_t cache_flags);
15197c478bd9Sstevel@tonic-gate 
15207c478bd9Sstevel@tonic-gate int
15217c478bd9Sstevel@tonic-gate ddi_no_dma_win(dev_info_t *dip, dev_info_t *rdip,
15227c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, uint_t win, off_t *offp,
15237c478bd9Sstevel@tonic-gate     size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
15247c478bd9Sstevel@tonic-gate 
15257c478bd9Sstevel@tonic-gate int
15267c478bd9Sstevel@tonic-gate ddi_no_dma_mctl(register dev_info_t *dip, dev_info_t *rdip,
15277c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
15287c478bd9Sstevel@tonic-gate     off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags);
15297c478bd9Sstevel@tonic-gate 
15307c478bd9Sstevel@tonic-gate void
15317c478bd9Sstevel@tonic-gate ddivoid();
15327c478bd9Sstevel@tonic-gate 
15337c478bd9Sstevel@tonic-gate cred_t *
15347c478bd9Sstevel@tonic-gate ddi_get_cred(void);
15357c478bd9Sstevel@tonic-gate 
15367c478bd9Sstevel@tonic-gate time_t
15377c478bd9Sstevel@tonic-gate ddi_get_time(void);
15387c478bd9Sstevel@tonic-gate 
15397c478bd9Sstevel@tonic-gate pid_t
15407c478bd9Sstevel@tonic-gate ddi_get_pid(void);
15417c478bd9Sstevel@tonic-gate 
15427c478bd9Sstevel@tonic-gate kt_did_t
15437c478bd9Sstevel@tonic-gate ddi_get_kt_did(void);
15447c478bd9Sstevel@tonic-gate 
15457c478bd9Sstevel@tonic-gate boolean_t
15467c478bd9Sstevel@tonic-gate ddi_can_receive_sig(void);
15477c478bd9Sstevel@tonic-gate 
15487c478bd9Sstevel@tonic-gate void
15497c478bd9Sstevel@tonic-gate swab(void *src, void *dst, size_t nbytes);
15507c478bd9Sstevel@tonic-gate 
15517c478bd9Sstevel@tonic-gate int
15527c478bd9Sstevel@tonic-gate ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type,
15537c478bd9Sstevel@tonic-gate     minor_t minor_num, char *node_type, int flag);
15547c478bd9Sstevel@tonic-gate 
15557c478bd9Sstevel@tonic-gate int
15567c478bd9Sstevel@tonic-gate ddi_create_priv_minor_node(dev_info_t *dip, char *name, int spec_type,
15577c478bd9Sstevel@tonic-gate     minor_t minor_num, char *node_type, int flag,
15587c478bd9Sstevel@tonic-gate     const char *rdpriv, const char *wrpriv, mode_t priv_mode);
15597c478bd9Sstevel@tonic-gate 
15607c478bd9Sstevel@tonic-gate void
15617c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dev_info_t *dip, char *name);
15627c478bd9Sstevel@tonic-gate 
15637c478bd9Sstevel@tonic-gate int
15647c478bd9Sstevel@tonic-gate ddi_in_panic(void);
15657c478bd9Sstevel@tonic-gate 
15667c478bd9Sstevel@tonic-gate int
15677c478bd9Sstevel@tonic-gate ddi_streams_driver(dev_info_t *dip);
15687c478bd9Sstevel@tonic-gate 
15697c478bd9Sstevel@tonic-gate /*
15707c478bd9Sstevel@tonic-gate  * DDI wrappers for ffs and fls
15717c478bd9Sstevel@tonic-gate  */
15727c478bd9Sstevel@tonic-gate int
15737c478bd9Sstevel@tonic-gate ddi_ffs(long mask);
15747c478bd9Sstevel@tonic-gate 
15757c478bd9Sstevel@tonic-gate int
15767c478bd9Sstevel@tonic-gate ddi_fls(long mask);
15777c478bd9Sstevel@tonic-gate 
15787c478bd9Sstevel@tonic-gate /*
15794c06356bSdh142964  * The ddi_soft_state* routines comprise generic storage management utilities
15804c06356bSdh142964  * for driver soft state structures.  Two types of soft_state indexes are
15814c06356bSdh142964  * supported: 'integer index', and 'string index'.
15827c478bd9Sstevel@tonic-gate  */
15834c06356bSdh142964 typedef	struct __ddi_soft_state_bystr	ddi_soft_state_bystr;
15847c478bd9Sstevel@tonic-gate 
15857c478bd9Sstevel@tonic-gate /*
15864c06356bSdh142964  * Initialize a soft_state set, establishing the 'size' of soft state objects
15874c06356bSdh142964  * in the set.
15884c06356bSdh142964  *
15894c06356bSdh142964  * For an 'integer indexed' soft_state set, the initial set will accommodate
15904c06356bSdh142964  * 'n_items' objects - 'n_items' is a hint (i.e. zero is allowed), allocations
15914c06356bSdh142964  * that exceed 'n_items' have additional overhead.
15924c06356bSdh142964  *
15934c06356bSdh142964  * For a 'string indexed' soft_state set, 'n_items' should be the typical
15944c06356bSdh142964  * number of soft state objects in the set - 'n_items' is a hint, there may
15954c06356bSdh142964  * be additional overhead if the hint is too small (and wasted memory if the
15964c06356bSdh142964  * hint is too big).
15977c478bd9Sstevel@tonic-gate  */
15987c478bd9Sstevel@tonic-gate int
15997c478bd9Sstevel@tonic-gate ddi_soft_state_init(void **state_p, size_t size, size_t n_items);
16004c06356bSdh142964 int
16014c06356bSdh142964 ddi_soft_state_bystr_init(ddi_soft_state_bystr **state_p,
16024c06356bSdh142964     size_t size, int n_items);
16037c478bd9Sstevel@tonic-gate 
16047c478bd9Sstevel@tonic-gate /*
16054c06356bSdh142964  * Allocate a soft state object associated with either 'integer index' or
16064c06356bSdh142964  * 'string index' from a soft_state set.
16077c478bd9Sstevel@tonic-gate  */
16087c478bd9Sstevel@tonic-gate int
16097c478bd9Sstevel@tonic-gate ddi_soft_state_zalloc(void *state, int item);
16104c06356bSdh142964 int
16114c06356bSdh142964 ddi_soft_state_bystr_zalloc(ddi_soft_state_bystr *state, const char *str);
16127c478bd9Sstevel@tonic-gate 
16137c478bd9Sstevel@tonic-gate /*
16144c06356bSdh142964  * Get the pointer to the allocated soft state object associated with
16154c06356bSdh142964  * either 'integer index' or 'string index'.
16167c478bd9Sstevel@tonic-gate  */
16177c478bd9Sstevel@tonic-gate void *
16187c478bd9Sstevel@tonic-gate ddi_get_soft_state(void *state, int item);
16194c06356bSdh142964 void *
16204c06356bSdh142964 ddi_soft_state_bystr_get(ddi_soft_state_bystr *state, const char *str);
16217c478bd9Sstevel@tonic-gate 
16227c478bd9Sstevel@tonic-gate /*
16234c06356bSdh142964  * Free the soft state object associated with either 'integer index'
16244c06356bSdh142964  * or 'string index'.
16257c478bd9Sstevel@tonic-gate  */
16267c478bd9Sstevel@tonic-gate void
16277c478bd9Sstevel@tonic-gate ddi_soft_state_free(void *state, int item);
16284c06356bSdh142964 void
16294c06356bSdh142964 ddi_soft_state_bystr_free(ddi_soft_state_bystr *state, const char *str);
16307c478bd9Sstevel@tonic-gate 
16317c478bd9Sstevel@tonic-gate /*
16324c06356bSdh142964  * Free the soft state set and any associated soft state objects.
16337c478bd9Sstevel@tonic-gate  */
16347c478bd9Sstevel@tonic-gate void
16357c478bd9Sstevel@tonic-gate ddi_soft_state_fini(void **state_p);
16364c06356bSdh142964 void
16374c06356bSdh142964 ddi_soft_state_bystr_fini(ddi_soft_state_bystr **state_p);
16384c06356bSdh142964 
16394c06356bSdh142964 /*
16404c06356bSdh142964  * The ddi_strid_* routines provide string-to-index management utilities.
16414c06356bSdh142964  */
16424c06356bSdh142964 typedef	struct __ddi_strid	ddi_strid;
16434c06356bSdh142964 int
16444c06356bSdh142964 ddi_strid_init(ddi_strid **strid_p, int n_items);
16454c06356bSdh142964 id_t
16464c06356bSdh142964 ddi_strid_alloc(ddi_strid *strid, char *str);
16474c06356bSdh142964 id_t
16484c06356bSdh142964 ddi_strid_str2id(ddi_strid *strid, char *str);
16494c06356bSdh142964 char *
16504c06356bSdh142964 ddi_strid_id2str(ddi_strid *strid, id_t id);
16514c06356bSdh142964 void
16524c06356bSdh142964 ddi_strid_free(ddi_strid *strid, id_t id);
16534c06356bSdh142964 void
16544c06356bSdh142964 ddi_strid_fini(ddi_strid **strid_p);
16557c478bd9Sstevel@tonic-gate 
16567c478bd9Sstevel@tonic-gate /*
16577c478bd9Sstevel@tonic-gate  * Set the addr field of the name in dip to name
16587c478bd9Sstevel@tonic-gate  */
16597c478bd9Sstevel@tonic-gate void
16607c478bd9Sstevel@tonic-gate ddi_set_name_addr(dev_info_t *dip, char *name);
16617c478bd9Sstevel@tonic-gate 
16627c478bd9Sstevel@tonic-gate /*
16637c478bd9Sstevel@tonic-gate  * Get the address part of the name.
16647c478bd9Sstevel@tonic-gate  */
16657c478bd9Sstevel@tonic-gate char *
16667c478bd9Sstevel@tonic-gate ddi_get_name_addr(dev_info_t *dip);
16677c478bd9Sstevel@tonic-gate 
16687c478bd9Sstevel@tonic-gate void
16697c478bd9Sstevel@tonic-gate ddi_set_parent_data(dev_info_t *dip, void *pd);
16707c478bd9Sstevel@tonic-gate 
16717c478bd9Sstevel@tonic-gate void *
16727c478bd9Sstevel@tonic-gate ddi_get_parent_data(dev_info_t *dip);
16737c478bd9Sstevel@tonic-gate 
16747c478bd9Sstevel@tonic-gate int
16757c478bd9Sstevel@tonic-gate ddi_initchild(dev_info_t *parent, dev_info_t *proto);
16767c478bd9Sstevel@tonic-gate 
16777c478bd9Sstevel@tonic-gate int
16787c478bd9Sstevel@tonic-gate ddi_uninitchild(dev_info_t *dip);
16797c478bd9Sstevel@tonic-gate 
16807c478bd9Sstevel@tonic-gate major_t
16817c478bd9Sstevel@tonic-gate ddi_name_to_major(char *name);
16827c478bd9Sstevel@tonic-gate 
16837c478bd9Sstevel@tonic-gate char *
16847c478bd9Sstevel@tonic-gate ddi_major_to_name(major_t major);
16857c478bd9Sstevel@tonic-gate 
16867c478bd9Sstevel@tonic-gate char *
16877c478bd9Sstevel@tonic-gate ddi_deviname(dev_info_t *dip, char *name);
16887c478bd9Sstevel@tonic-gate 
16897c478bd9Sstevel@tonic-gate char *
16907c478bd9Sstevel@tonic-gate ddi_pathname(dev_info_t *dip, char *path);
16917c478bd9Sstevel@tonic-gate 
169238c67cbdSjiang wu - Sun Microsystems - Beijing China char *
1693f9722deaSChris Horne ddi_pathname_minor(struct ddi_minor_data *dmdp, char *path);
1694f9722deaSChris Horne 
1695f9722deaSChris Horne char *
169638c67cbdSjiang wu - Sun Microsystems - Beijing China ddi_pathname_obp(dev_info_t *dip, char *path);
169738c67cbdSjiang wu - Sun Microsystems - Beijing China 
169838c67cbdSjiang wu - Sun Microsystems - Beijing China int
169938c67cbdSjiang wu - Sun Microsystems - Beijing China ddi_pathname_obp_set(dev_info_t *dip, char *component);
170038c67cbdSjiang wu - Sun Microsystems - Beijing China 
17017c478bd9Sstevel@tonic-gate int
17027c478bd9Sstevel@tonic-gate ddi_dev_pathname(dev_t devt, int spec_type, char *name);
17037c478bd9Sstevel@tonic-gate 
17047c478bd9Sstevel@tonic-gate dev_t
17057c478bd9Sstevel@tonic-gate ddi_pathname_to_dev_t(char *pathname);
17067c478bd9Sstevel@tonic-gate 
17077c478bd9Sstevel@tonic-gate /*
17087c478bd9Sstevel@tonic-gate  * High resolution system timer functions.
17097c478bd9Sstevel@tonic-gate  *
17107c478bd9Sstevel@tonic-gate  * These functions are already in the kernel (see sys/time.h).
17117c478bd9Sstevel@tonic-gate  * The ddi supports the notion of a hrtime_t type and the
17127c478bd9Sstevel@tonic-gate  * functions gethrtime, hrtadd, hrtsub and hrtcmp.
17137c478bd9Sstevel@tonic-gate  */
17147c478bd9Sstevel@tonic-gate 
17157c478bd9Sstevel@tonic-gate 
17167c478bd9Sstevel@tonic-gate /*
17177c478bd9Sstevel@tonic-gate  * Nexus wrapper functions
17187c478bd9Sstevel@tonic-gate  *
17197c478bd9Sstevel@tonic-gate  * These functions are for entries in a bus nexus driver's bus_ops
17207c478bd9Sstevel@tonic-gate  * structure for when the driver doesn't have such a function and
17217c478bd9Sstevel@tonic-gate  * doesn't wish to prohibit such a function from existing. They
17227c478bd9Sstevel@tonic-gate  * may also be called to start passing a request up the dev_info
17237c478bd9Sstevel@tonic-gate  * tree.
17247c478bd9Sstevel@tonic-gate  */
17257c478bd9Sstevel@tonic-gate 
17267c478bd9Sstevel@tonic-gate /*
17277c478bd9Sstevel@tonic-gate  * bus_ctl wrapper
17287c478bd9Sstevel@tonic-gate  */
17297c478bd9Sstevel@tonic-gate 
17307c478bd9Sstevel@tonic-gate int
17317c478bd9Sstevel@tonic-gate ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v);
17327c478bd9Sstevel@tonic-gate 
17337c478bd9Sstevel@tonic-gate /*
17347c478bd9Sstevel@tonic-gate  * bus_dma_map wrapper
17357c478bd9Sstevel@tonic-gate  */
17367c478bd9Sstevel@tonic-gate 
17377c478bd9Sstevel@tonic-gate int
17387c478bd9Sstevel@tonic-gate ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
17397c478bd9Sstevel@tonic-gate 	struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
17407c478bd9Sstevel@tonic-gate 
17417c478bd9Sstevel@tonic-gate int
17427c478bd9Sstevel@tonic-gate ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
17437c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
17447c478bd9Sstevel@tonic-gate 
17457c478bd9Sstevel@tonic-gate int
17467c478bd9Sstevel@tonic-gate ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
17477c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle);
17487c478bd9Sstevel@tonic-gate 
17497c478bd9Sstevel@tonic-gate int
17507c478bd9Sstevel@tonic-gate ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
17517c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
17527c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cp, uint_t *ccountp);
17537c478bd9Sstevel@tonic-gate 
17547c478bd9Sstevel@tonic-gate int
17557c478bd9Sstevel@tonic-gate ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
17567c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle);
17577c478bd9Sstevel@tonic-gate 
17587c478bd9Sstevel@tonic-gate int
17597c478bd9Sstevel@tonic-gate ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip,
17607c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle, off_t off, size_t len,
17617c478bd9Sstevel@tonic-gate 	uint_t cache_flags);
17627c478bd9Sstevel@tonic-gate 
17637c478bd9Sstevel@tonic-gate int
17647c478bd9Sstevel@tonic-gate ddi_dma_win(dev_info_t *dip, dev_info_t *rdip,
17657c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle, uint_t win, off_t *offp,
17667c478bd9Sstevel@tonic-gate 	size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
17677c478bd9Sstevel@tonic-gate 
17687c478bd9Sstevel@tonic-gate /*
17697c478bd9Sstevel@tonic-gate  * bus_dma_ctl wrapper
17707c478bd9Sstevel@tonic-gate  */
17717c478bd9Sstevel@tonic-gate 
17727c478bd9Sstevel@tonic-gate int
17737c478bd9Sstevel@tonic-gate ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
17747c478bd9Sstevel@tonic-gate 	enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
17757c478bd9Sstevel@tonic-gate 	caddr_t *objp, uint_t flags);
17767c478bd9Sstevel@tonic-gate 
17777c478bd9Sstevel@tonic-gate /*
17787c478bd9Sstevel@tonic-gate  * dvma support for networking drivers
17797c478bd9Sstevel@tonic-gate  */
17807c478bd9Sstevel@tonic-gate 
17817c478bd9Sstevel@tonic-gate unsigned long
17827c478bd9Sstevel@tonic-gate dvma_pagesize(dev_info_t *dip);
17837c478bd9Sstevel@tonic-gate 
17847c478bd9Sstevel@tonic-gate int
17857c478bd9Sstevel@tonic-gate dvma_reserve(dev_info_t *dip,  ddi_dma_lim_t *limp, uint_t pages,
17867c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
17877c478bd9Sstevel@tonic-gate 
17887c478bd9Sstevel@tonic-gate void
17897c478bd9Sstevel@tonic-gate dvma_release(ddi_dma_handle_t h);
17907c478bd9Sstevel@tonic-gate 
17917c478bd9Sstevel@tonic-gate void
17927c478bd9Sstevel@tonic-gate dvma_kaddr_load(ddi_dma_handle_t h, caddr_t a, uint_t len, uint_t index,
17937c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cp);
17947c478bd9Sstevel@tonic-gate 
17957c478bd9Sstevel@tonic-gate void
17967c478bd9Sstevel@tonic-gate dvma_unload(ddi_dma_handle_t h, uint_t objindex, uint_t type);
17977c478bd9Sstevel@tonic-gate 
17987c478bd9Sstevel@tonic-gate void
17997c478bd9Sstevel@tonic-gate dvma_sync(ddi_dma_handle_t h, uint_t objindex, uint_t type);
18007c478bd9Sstevel@tonic-gate 
18017c478bd9Sstevel@tonic-gate /*
18027c478bd9Sstevel@tonic-gate  * Layered driver support
18037c478bd9Sstevel@tonic-gate  */
18047c478bd9Sstevel@tonic-gate 
18057c478bd9Sstevel@tonic-gate extern int ddi_copyin(const void *, void *, size_t, int);
18067c478bd9Sstevel@tonic-gate extern int ddi_copyout(const void *, void *, size_t, int);
18077c478bd9Sstevel@tonic-gate 
18087c478bd9Sstevel@tonic-gate /*
18097c478bd9Sstevel@tonic-gate  * Send signals to processes
18107c478bd9Sstevel@tonic-gate  */
18117c478bd9Sstevel@tonic-gate extern void *proc_ref(void);
18127c478bd9Sstevel@tonic-gate extern void proc_unref(void *pref);
18137c478bd9Sstevel@tonic-gate extern int proc_signal(void *pref, int sig);
18147c478bd9Sstevel@tonic-gate 
18157c478bd9Sstevel@tonic-gate /* I/O port access routines */
18167c478bd9Sstevel@tonic-gate extern uint8_t inb(int port);
18177c478bd9Sstevel@tonic-gate extern uint16_t inw(int port);
18187c478bd9Sstevel@tonic-gate extern uint32_t inl(int port);
18197c478bd9Sstevel@tonic-gate extern void outb(int port, uint8_t value);
18207c478bd9Sstevel@tonic-gate extern void outw(int port, uint16_t value);
18217c478bd9Sstevel@tonic-gate extern void outl(int port, uint32_t value);
18227c478bd9Sstevel@tonic-gate 
18237c478bd9Sstevel@tonic-gate /*
18247c478bd9Sstevel@tonic-gate  * Console bell routines
18257c478bd9Sstevel@tonic-gate  */
18267c478bd9Sstevel@tonic-gate extern void ddi_ring_console_bell(clock_t duration);
18277c478bd9Sstevel@tonic-gate extern void ddi_set_console_bell(void (*bellfunc)(clock_t duration));
18287c478bd9Sstevel@tonic-gate 
18297c478bd9Sstevel@tonic-gate /*
18307c478bd9Sstevel@tonic-gate  * Fault-related functions
18317c478bd9Sstevel@tonic-gate  */
18327c478bd9Sstevel@tonic-gate extern int ddi_check_acc_handle(ddi_acc_handle_t);
18337c478bd9Sstevel@tonic-gate extern int ddi_check_dma_handle(ddi_dma_handle_t);
18347c478bd9Sstevel@tonic-gate extern void ddi_dev_report_fault(dev_info_t *, ddi_fault_impact_t,
18357c478bd9Sstevel@tonic-gate 	ddi_fault_location_t, const char *);
18367c478bd9Sstevel@tonic-gate extern ddi_devstate_t ddi_get_devstate(dev_info_t *);
18377c478bd9Sstevel@tonic-gate 
18387c478bd9Sstevel@tonic-gate /*
18397c478bd9Sstevel@tonic-gate  * Miscellaneous redefines
18407c478bd9Sstevel@tonic-gate  */
18417c478bd9Sstevel@tonic-gate #define	uiophysio	physio
18427c478bd9Sstevel@tonic-gate 
18437c478bd9Sstevel@tonic-gate /*
18447c478bd9Sstevel@tonic-gate  * utilities - "reg" mapping and all common portable data access functions
18457c478bd9Sstevel@tonic-gate  */
18467c478bd9Sstevel@tonic-gate 
18477c478bd9Sstevel@tonic-gate /*
18487c478bd9Sstevel@tonic-gate  * error code from ddi_regs_map_setup
18497c478bd9Sstevel@tonic-gate  */
18507c478bd9Sstevel@tonic-gate 
18517c478bd9Sstevel@tonic-gate #define	DDI_REGS_ACC_CONFLICT	(-10)
18527c478bd9Sstevel@tonic-gate 
18537c478bd9Sstevel@tonic-gate /*
18547c478bd9Sstevel@tonic-gate  * Device address advance flags
18557c478bd9Sstevel@tonic-gate  */
18567c478bd9Sstevel@tonic-gate 
18577c478bd9Sstevel@tonic-gate #define	 DDI_DEV_NO_AUTOINCR	0x0000
18587c478bd9Sstevel@tonic-gate #define	 DDI_DEV_AUTOINCR	0x0001
18597c478bd9Sstevel@tonic-gate 
18607c478bd9Sstevel@tonic-gate int
18617c478bd9Sstevel@tonic-gate ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber, caddr_t *addrp,
18627c478bd9Sstevel@tonic-gate 	offset_t offset, offset_t len, ddi_device_acc_attr_t *accattrp,
18637c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t *handle);
18647c478bd9Sstevel@tonic-gate 
18657c478bd9Sstevel@tonic-gate void
18667c478bd9Sstevel@tonic-gate ddi_regs_map_free(ddi_acc_handle_t *handle);
18677c478bd9Sstevel@tonic-gate 
18687c478bd9Sstevel@tonic-gate /*
18697c478bd9Sstevel@tonic-gate  * these are the prototypes for the common portable data access functions
18707c478bd9Sstevel@tonic-gate  */
18717c478bd9Sstevel@tonic-gate 
18727c478bd9Sstevel@tonic-gate uint8_t
18737c478bd9Sstevel@tonic-gate ddi_get8(ddi_acc_handle_t handle, uint8_t *addr);
18747c478bd9Sstevel@tonic-gate 
18757c478bd9Sstevel@tonic-gate uint16_t
18767c478bd9Sstevel@tonic-gate ddi_get16(ddi_acc_handle_t handle, uint16_t *addr);
18777c478bd9Sstevel@tonic-gate 
18787c478bd9Sstevel@tonic-gate uint32_t
18797c478bd9Sstevel@tonic-gate ddi_get32(ddi_acc_handle_t handle, uint32_t *addr);
18807c478bd9Sstevel@tonic-gate 
18817c478bd9Sstevel@tonic-gate uint64_t
18827c478bd9Sstevel@tonic-gate ddi_get64(ddi_acc_handle_t handle, uint64_t *addr);
18837c478bd9Sstevel@tonic-gate 
18847c478bd9Sstevel@tonic-gate void
18857c478bd9Sstevel@tonic-gate ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
18867c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
18877c478bd9Sstevel@tonic-gate 
18887c478bd9Sstevel@tonic-gate void
18897c478bd9Sstevel@tonic-gate ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
18907c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
18917c478bd9Sstevel@tonic-gate 
18927c478bd9Sstevel@tonic-gate void
18937c478bd9Sstevel@tonic-gate ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
18947c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
18957c478bd9Sstevel@tonic-gate 
18967c478bd9Sstevel@tonic-gate void
18977c478bd9Sstevel@tonic-gate ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
18987c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
18997c478bd9Sstevel@tonic-gate 
19007c478bd9Sstevel@tonic-gate void
19017c478bd9Sstevel@tonic-gate ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value);
19027c478bd9Sstevel@tonic-gate 
19037c478bd9Sstevel@tonic-gate void
19047c478bd9Sstevel@tonic-gate ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value);
19057c478bd9Sstevel@tonic-gate 
19067c478bd9Sstevel@tonic-gate void
19077c478bd9Sstevel@tonic-gate ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value);
19087c478bd9Sstevel@tonic-gate 
19097c478bd9Sstevel@tonic-gate void
19107c478bd9Sstevel@tonic-gate ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value);
19117c478bd9Sstevel@tonic-gate 
19127c478bd9Sstevel@tonic-gate void
19137c478bd9Sstevel@tonic-gate ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
19147c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
19157c478bd9Sstevel@tonic-gate void
19167c478bd9Sstevel@tonic-gate ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
19177c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
19187c478bd9Sstevel@tonic-gate void
19197c478bd9Sstevel@tonic-gate ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
19207c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
19217c478bd9Sstevel@tonic-gate 
19227c478bd9Sstevel@tonic-gate void
19237c478bd9Sstevel@tonic-gate ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
19247c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
19257c478bd9Sstevel@tonic-gate 
19267c478bd9Sstevel@tonic-gate /*
19277c478bd9Sstevel@tonic-gate  * these are special device handling functions
19287c478bd9Sstevel@tonic-gate  */
19297c478bd9Sstevel@tonic-gate int
19307c478bd9Sstevel@tonic-gate ddi_device_zero(ddi_acc_handle_t handle, caddr_t dev_addr,
19317c478bd9Sstevel@tonic-gate 	size_t bytecount, ssize_t dev_advcnt, uint_t dev_datasz);
19327c478bd9Sstevel@tonic-gate 
19337c478bd9Sstevel@tonic-gate int
19347c478bd9Sstevel@tonic-gate ddi_device_copy(
19357c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t src_handle, caddr_t src_addr, ssize_t src_advcnt,
19367c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t dest_handle, caddr_t dest_addr, ssize_t dest_advcnt,
19377c478bd9Sstevel@tonic-gate 	size_t bytecount, uint_t dev_datasz);
19387c478bd9Sstevel@tonic-gate 
19397c478bd9Sstevel@tonic-gate /*
19407c478bd9Sstevel@tonic-gate  * these are software byte swapping functions
19417c478bd9Sstevel@tonic-gate  */
19427c478bd9Sstevel@tonic-gate uint16_t
19437c478bd9Sstevel@tonic-gate ddi_swap16(uint16_t value);
19447c478bd9Sstevel@tonic-gate 
19457c478bd9Sstevel@tonic-gate uint32_t
19467c478bd9Sstevel@tonic-gate ddi_swap32(uint32_t value);
19477c478bd9Sstevel@tonic-gate 
19487c478bd9Sstevel@tonic-gate uint64_t
19497c478bd9Sstevel@tonic-gate ddi_swap64(uint64_t value);
19507c478bd9Sstevel@tonic-gate 
19517c478bd9Sstevel@tonic-gate /*
19527c478bd9Sstevel@tonic-gate  * these are the prototypes for PCI local bus functions
19537c478bd9Sstevel@tonic-gate  */
19547c478bd9Sstevel@tonic-gate /*
19557c478bd9Sstevel@tonic-gate  * PCI power management capabilities reporting in addition to those
19567c478bd9Sstevel@tonic-gate  * provided by the PCI Power Management Specification.
19577c478bd9Sstevel@tonic-gate  */
19587c478bd9Sstevel@tonic-gate #define	PCI_PM_IDLESPEED	0x1		/* clock for idle dev - cap  */
19597c478bd9Sstevel@tonic-gate #define	PCI_PM_IDLESPEED_ANY	(void *)-1	/* any clock for idle dev */
19607c478bd9Sstevel@tonic-gate #define	PCI_PM_IDLESPEED_NONE	(void *)-2	/* regular clock for idle dev */
19617c478bd9Sstevel@tonic-gate 
19627c478bd9Sstevel@tonic-gate int
19637c478bd9Sstevel@tonic-gate pci_config_setup(dev_info_t *dip, ddi_acc_handle_t *handle);
19647c478bd9Sstevel@tonic-gate 
19657c478bd9Sstevel@tonic-gate void
19667c478bd9Sstevel@tonic-gate pci_config_teardown(ddi_acc_handle_t *handle);
19677c478bd9Sstevel@tonic-gate 
19687c478bd9Sstevel@tonic-gate uint8_t
19697c478bd9Sstevel@tonic-gate pci_config_get8(ddi_acc_handle_t handle, off_t offset);
19707c478bd9Sstevel@tonic-gate 
19717c478bd9Sstevel@tonic-gate uint16_t
19727c478bd9Sstevel@tonic-gate pci_config_get16(ddi_acc_handle_t handle, off_t offset);
19737c478bd9Sstevel@tonic-gate 
19747c478bd9Sstevel@tonic-gate uint32_t
19757c478bd9Sstevel@tonic-gate pci_config_get32(ddi_acc_handle_t handle, off_t offset);
19767c478bd9Sstevel@tonic-gate 
19777c478bd9Sstevel@tonic-gate uint64_t
19787c478bd9Sstevel@tonic-gate pci_config_get64(ddi_acc_handle_t handle, off_t offset);
19797c478bd9Sstevel@tonic-gate 
19807c478bd9Sstevel@tonic-gate void
19817c478bd9Sstevel@tonic-gate pci_config_put8(ddi_acc_handle_t handle, off_t offset, uint8_t value);
19827c478bd9Sstevel@tonic-gate 
19837c478bd9Sstevel@tonic-gate void
19847c478bd9Sstevel@tonic-gate pci_config_put16(ddi_acc_handle_t handle, off_t offset, uint16_t value);
19857c478bd9Sstevel@tonic-gate 
19867c478bd9Sstevel@tonic-gate void
19877c478bd9Sstevel@tonic-gate pci_config_put32(ddi_acc_handle_t handle, off_t offset, uint32_t value);
19887c478bd9Sstevel@tonic-gate 
19897c478bd9Sstevel@tonic-gate void
19907c478bd9Sstevel@tonic-gate pci_config_put64(ddi_acc_handle_t handle, off_t offset, uint64_t value);
19917c478bd9Sstevel@tonic-gate 
19927c478bd9Sstevel@tonic-gate int
19937c478bd9Sstevel@tonic-gate pci_report_pmcap(dev_info_t *dip, int cap, void *arg);
19947c478bd9Sstevel@tonic-gate 
19957c478bd9Sstevel@tonic-gate int
19967c478bd9Sstevel@tonic-gate pci_restore_config_regs(dev_info_t *dip);
19977c478bd9Sstevel@tonic-gate 
19987c478bd9Sstevel@tonic-gate int
19997c478bd9Sstevel@tonic-gate pci_save_config_regs(dev_info_t *dip);
20007c478bd9Sstevel@tonic-gate 
20017c478bd9Sstevel@tonic-gate void
20027c478bd9Sstevel@tonic-gate pci_ereport_setup(dev_info_t *dip);
20037c478bd9Sstevel@tonic-gate 
20047c478bd9Sstevel@tonic-gate void
20057c478bd9Sstevel@tonic-gate pci_ereport_teardown(dev_info_t *dip);
20067c478bd9Sstevel@tonic-gate 
20077c478bd9Sstevel@tonic-gate void
20087c478bd9Sstevel@tonic-gate pci_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status);
20097c478bd9Sstevel@tonic-gate 
201000d0963fSdilpreet #if defined(__i386) || defined(__amd64)
20117c478bd9Sstevel@tonic-gate int
201200d0963fSdilpreet pci_peekpoke_check(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *,
201300d0963fSdilpreet 	int (*handler)(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *,
2014eae2e508Skrishnae 	void *), kmutex_t *, kmutex_t *,
2015eae2e508Skrishnae 	void (*scan)(dev_info_t *, ddi_fm_error_t *));
201600d0963fSdilpreet #endif
201700d0963fSdilpreet 
201800d0963fSdilpreet void
201900d0963fSdilpreet pci_target_enqueue(uint64_t, char *, char *, uint64_t);
202000d0963fSdilpreet 
202100d0963fSdilpreet void
202200d0963fSdilpreet pci_targetq_init(void);
20237c478bd9Sstevel@tonic-gate 
20242df1fe9cSrandyf int
20252df1fe9cSrandyf pci_post_suspend(dev_info_t *dip);
20262df1fe9cSrandyf 
20272df1fe9cSrandyf int
20282df1fe9cSrandyf pci_pre_resume(dev_info_t *dip);
20292df1fe9cSrandyf 
20307c478bd9Sstevel@tonic-gate /*
20317c478bd9Sstevel@tonic-gate  * the prototype for the C Language Type Model inquiry.
20327c478bd9Sstevel@tonic-gate  */
20337c478bd9Sstevel@tonic-gate model_t	ddi_mmap_get_model(void);
20347c478bd9Sstevel@tonic-gate model_t	ddi_model_convert_from(model_t);
20357c478bd9Sstevel@tonic-gate 
20367c478bd9Sstevel@tonic-gate /*
20377c478bd9Sstevel@tonic-gate  * these are the prototypes for device id functions.
20387c478bd9Sstevel@tonic-gate  */
20397c478bd9Sstevel@tonic-gate int
20407c478bd9Sstevel@tonic-gate ddi_devid_valid(ddi_devid_t devid);
20417c478bd9Sstevel@tonic-gate 
20427c478bd9Sstevel@tonic-gate int
20437c478bd9Sstevel@tonic-gate ddi_devid_register(dev_info_t *dip, ddi_devid_t devid);
20447c478bd9Sstevel@tonic-gate 
20457c478bd9Sstevel@tonic-gate void
20467c478bd9Sstevel@tonic-gate ddi_devid_unregister(dev_info_t *dip);
20477c478bd9Sstevel@tonic-gate 
20487c478bd9Sstevel@tonic-gate int
20497c478bd9Sstevel@tonic-gate ddi_devid_init(dev_info_t *dip, ushort_t devid_type, ushort_t nbytes,
20507c478bd9Sstevel@tonic-gate     void *id, ddi_devid_t *ret_devid);
20517c478bd9Sstevel@tonic-gate 
20528d483882Smlf int
20538d483882Smlf ddi_devid_get(dev_info_t *dip, ddi_devid_t *ret_devid);
20548d483882Smlf 
20557c478bd9Sstevel@tonic-gate size_t
20567c478bd9Sstevel@tonic-gate ddi_devid_sizeof(ddi_devid_t devid);
20577c478bd9Sstevel@tonic-gate 
20587c478bd9Sstevel@tonic-gate void
20597c478bd9Sstevel@tonic-gate ddi_devid_free(ddi_devid_t devid);
20607c478bd9Sstevel@tonic-gate 
20617c478bd9Sstevel@tonic-gate int
20627c478bd9Sstevel@tonic-gate ddi_devid_compare(ddi_devid_t id1, ddi_devid_t id2);
20637c478bd9Sstevel@tonic-gate 
20647c478bd9Sstevel@tonic-gate int
20657c478bd9Sstevel@tonic-gate ddi_devid_scsi_encode(int version, char *driver_name,
20667c478bd9Sstevel@tonic-gate     uchar_t *inq, size_t inq_len, uchar_t *inq80, size_t inq80_len,
20677c478bd9Sstevel@tonic-gate     uchar_t *inq83, size_t inq83_len, ddi_devid_t *ret_devid);
20687c478bd9Sstevel@tonic-gate 
206996c4a178SChris Horne int
207096c4a178SChris Horne ddi_devid_smp_encode(int version, char *driver_name,
207196c4a178SChris Horne     char *wwnstr, uchar_t *srmir_buf, size_t srmir_len,
207296c4a178SChris Horne     ddi_devid_t *ret_devid);
207396c4a178SChris Horne 
20747c478bd9Sstevel@tonic-gate char
20757c478bd9Sstevel@tonic-gate *ddi_devid_to_guid(ddi_devid_t devid);
20767c478bd9Sstevel@tonic-gate 
20777c478bd9Sstevel@tonic-gate void
20787c478bd9Sstevel@tonic-gate ddi_devid_free_guid(char *guid);
20797c478bd9Sstevel@tonic-gate 
20807c478bd9Sstevel@tonic-gate int
20817c478bd9Sstevel@tonic-gate ddi_lyr_get_devid(dev_t dev, ddi_devid_t *ret_devid);
20827c478bd9Sstevel@tonic-gate 
20837c478bd9Sstevel@tonic-gate int
20847c478bd9Sstevel@tonic-gate ddi_lyr_get_minor_name(dev_t dev, int spec_type, char **minor_name);
20857c478bd9Sstevel@tonic-gate 
20867c478bd9Sstevel@tonic-gate int
20877c478bd9Sstevel@tonic-gate ddi_lyr_devid_to_devlist(ddi_devid_t devid, char *minor_name, int *retndevs,
20887c478bd9Sstevel@tonic-gate     dev_t **retdevs);
20897c478bd9Sstevel@tonic-gate 
20907c478bd9Sstevel@tonic-gate void
20917c478bd9Sstevel@tonic-gate ddi_lyr_free_devlist(dev_t *devlist, int ndevs);
20927c478bd9Sstevel@tonic-gate 
20937c478bd9Sstevel@tonic-gate char *
20947c478bd9Sstevel@tonic-gate ddi_devid_str_encode(ddi_devid_t devid, char *minor_name);
20957c478bd9Sstevel@tonic-gate 
20967c478bd9Sstevel@tonic-gate int
20977c478bd9Sstevel@tonic-gate ddi_devid_str_decode(char *devidstr, ddi_devid_t *devidp, char **minor_namep);
20987c478bd9Sstevel@tonic-gate 
20997c478bd9Sstevel@tonic-gate void
21007c478bd9Sstevel@tonic-gate ddi_devid_str_free(char *devidstr);
21017c478bd9Sstevel@tonic-gate 
21027c478bd9Sstevel@tonic-gate int
21037c478bd9Sstevel@tonic-gate ddi_devid_str_compare(char *id1_str, char *id2_str);
21047c478bd9Sstevel@tonic-gate 
21057c478bd9Sstevel@tonic-gate /*
21067c478bd9Sstevel@tonic-gate  * Event to post to when a devinfo node is removed.
21077c478bd9Sstevel@tonic-gate  */
21087c478bd9Sstevel@tonic-gate #define	DDI_DEVI_REMOVE_EVENT		"DDI:DEVI_REMOVE"
21097c478bd9Sstevel@tonic-gate #define	DDI_DEVI_INSERT_EVENT		"DDI:DEVI_INSERT"
21107c478bd9Sstevel@tonic-gate #define	DDI_DEVI_BUS_RESET_EVENT	"DDI:DEVI_BUS_RESET"
21117c478bd9Sstevel@tonic-gate #define	DDI_DEVI_DEVICE_RESET_EVENT	"DDI:DEVI_DEVICE_RESET"
21127c478bd9Sstevel@tonic-gate 
21137c478bd9Sstevel@tonic-gate /*
21147c478bd9Sstevel@tonic-gate  * Invoke bus nexus driver's implementation of the
21157c478bd9Sstevel@tonic-gate  * (*bus_remove_eventcall)() interface to remove a registered
21167c478bd9Sstevel@tonic-gate  * callback handler for "event".
21177c478bd9Sstevel@tonic-gate  */
21187c478bd9Sstevel@tonic-gate int
21197c478bd9Sstevel@tonic-gate ddi_remove_event_handler(ddi_callback_id_t id);
21207c478bd9Sstevel@tonic-gate 
21217c478bd9Sstevel@tonic-gate /*
21227c478bd9Sstevel@tonic-gate  * Invoke bus nexus driver's implementation of the
21237c478bd9Sstevel@tonic-gate  * (*bus_add_eventcall)() interface to register a callback handler
21247c478bd9Sstevel@tonic-gate  * for "event".
21257c478bd9Sstevel@tonic-gate  */
21267c478bd9Sstevel@tonic-gate int
21277c478bd9Sstevel@tonic-gate ddi_add_event_handler(dev_info_t *dip, ddi_eventcookie_t event,
21287c478bd9Sstevel@tonic-gate 	void (*handler)(dev_info_t *, ddi_eventcookie_t, void *, void *),
21297c478bd9Sstevel@tonic-gate 	void *arg, ddi_callback_id_t *id);
21307c478bd9Sstevel@tonic-gate 
21317c478bd9Sstevel@tonic-gate /*
21327c478bd9Sstevel@tonic-gate  * Return a handle for event "name" by calling up the device tree
21337c478bd9Sstevel@tonic-gate  * hierarchy via  (*bus_get_eventcookie)() interface until claimed
21347c478bd9Sstevel@tonic-gate  * by a bus nexus or top of dev_info tree is reached.
21357c478bd9Sstevel@tonic-gate  */
21367c478bd9Sstevel@tonic-gate int
21377c478bd9Sstevel@tonic-gate ddi_get_eventcookie(dev_info_t *dip, char *name,
21387c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t *event_cookiep);
21397c478bd9Sstevel@tonic-gate 
21407c478bd9Sstevel@tonic-gate /*
21417c478bd9Sstevel@tonic-gate  * log a system event
21427c478bd9Sstevel@tonic-gate  */
21437c478bd9Sstevel@tonic-gate int
21447c478bd9Sstevel@tonic-gate ddi_log_sysevent(dev_info_t *dip, char *vendor, char *class_name,
21457c478bd9Sstevel@tonic-gate 	char *subclass_name, nvlist_t *attr_list, sysevent_id_t *eidp,
21467c478bd9Sstevel@tonic-gate 	int sleep_flag);
21477c478bd9Sstevel@tonic-gate 
21487c478bd9Sstevel@tonic-gate /*
21497c478bd9Sstevel@tonic-gate  * ddi_log_sysevent() vendors
21507c478bd9Sstevel@tonic-gate  */
21517c478bd9Sstevel@tonic-gate #define	DDI_VENDOR_SUNW		"SUNW"
21527c478bd9Sstevel@tonic-gate 
21537c478bd9Sstevel@tonic-gate /*
21547c478bd9Sstevel@tonic-gate  * Opaque task queue handle.
21557c478bd9Sstevel@tonic-gate  */
21567c478bd9Sstevel@tonic-gate typedef struct ddi_taskq ddi_taskq_t;
21577c478bd9Sstevel@tonic-gate 
21587c478bd9Sstevel@tonic-gate /*
21597c478bd9Sstevel@tonic-gate  * Use default system priority.
21607c478bd9Sstevel@tonic-gate  */
21617c478bd9Sstevel@tonic-gate #define	TASKQ_DEFAULTPRI -1
21627c478bd9Sstevel@tonic-gate 
21637c478bd9Sstevel@tonic-gate /*
21647c478bd9Sstevel@tonic-gate  * Create a task queue
21657c478bd9Sstevel@tonic-gate  */
21667c478bd9Sstevel@tonic-gate ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name,
21677c478bd9Sstevel@tonic-gate 	int nthreads, pri_t pri, uint_t cflags);
21687c478bd9Sstevel@tonic-gate 
21697c478bd9Sstevel@tonic-gate /*
21707c478bd9Sstevel@tonic-gate  * destroy a task queue
21717c478bd9Sstevel@tonic-gate  */
21727c478bd9Sstevel@tonic-gate void ddi_taskq_destroy(ddi_taskq_t *tq);
21737c478bd9Sstevel@tonic-gate 
21747c478bd9Sstevel@tonic-gate /*
21757c478bd9Sstevel@tonic-gate  * Dispatch a task to a task queue
21767c478bd9Sstevel@tonic-gate  */
21777c478bd9Sstevel@tonic-gate int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *),
21787c478bd9Sstevel@tonic-gate 	void *arg, uint_t dflags);
21797c478bd9Sstevel@tonic-gate 
21807c478bd9Sstevel@tonic-gate /*
21817c478bd9Sstevel@tonic-gate  * Wait for all previously scheduled tasks to complete.
21827c478bd9Sstevel@tonic-gate  */
21837c478bd9Sstevel@tonic-gate void ddi_taskq_wait(ddi_taskq_t *tq);
21847c478bd9Sstevel@tonic-gate 
21857c478bd9Sstevel@tonic-gate /*
21867c478bd9Sstevel@tonic-gate  * Suspend all task execution.
21877c478bd9Sstevel@tonic-gate  */
21887c478bd9Sstevel@tonic-gate void ddi_taskq_suspend(ddi_taskq_t *tq);
21897c478bd9Sstevel@tonic-gate 
21907c478bd9Sstevel@tonic-gate /*
21917c478bd9Sstevel@tonic-gate  * Resume task execution.
21927c478bd9Sstevel@tonic-gate  */
21937c478bd9Sstevel@tonic-gate void ddi_taskq_resume(ddi_taskq_t *tq);
21947c478bd9Sstevel@tonic-gate 
21957c478bd9Sstevel@tonic-gate /*
21967c478bd9Sstevel@tonic-gate  * Is task queue suspended?
21977c478bd9Sstevel@tonic-gate  */
21987c478bd9Sstevel@tonic-gate boolean_t ddi_taskq_suspended(ddi_taskq_t *tq);
21997c478bd9Sstevel@tonic-gate 
22007c478bd9Sstevel@tonic-gate /*
22017c478bd9Sstevel@tonic-gate  * Parse an interface name of the form <alphanumeric>##<numeric> where
22027c478bd9Sstevel@tonic-gate  * <numeric> is maximal.
22037c478bd9Sstevel@tonic-gate  */
22047c478bd9Sstevel@tonic-gate int ddi_parse(const char *, char *, uint_t *);
22057c478bd9Sstevel@tonic-gate 
2206dd4eeefdSeota /*
2207dd4eeefdSeota  * DDI interrupt priority level
2208dd4eeefdSeota  */
2209dd4eeefdSeota #define	DDI_IPL_0	(0)	/* kernel context */
2210dd4eeefdSeota #define	DDI_IPL_1	(1)	/* interrupt priority level 1 */
2211dd4eeefdSeota #define	DDI_IPL_2	(2)	/* interrupt priority level 2 */
2212dd4eeefdSeota #define	DDI_IPL_3	(3)	/* interrupt priority level 3 */
2213dd4eeefdSeota #define	DDI_IPL_4	(4)	/* interrupt priority level 4 */
2214dd4eeefdSeota #define	DDI_IPL_5	(5)	/* interrupt priority level 5 */
2215dd4eeefdSeota #define	DDI_IPL_6	(6)	/* interrupt priority level 6 */
2216dd4eeefdSeota #define	DDI_IPL_7	(7)	/* interrupt priority level 7 */
2217dd4eeefdSeota #define	DDI_IPL_8	(8)	/* interrupt priority level 8 */
2218dd4eeefdSeota #define	DDI_IPL_9	(9)	/* interrupt priority level 9 */
2219dd4eeefdSeota #define	DDI_IPL_10	(10)	/* interrupt priority level 10 */
2220dd4eeefdSeota 
2221dd4eeefdSeota /*
2222dd4eeefdSeota  * DDI periodic timeout interface
2223dd4eeefdSeota  */
2224dd4eeefdSeota ddi_periodic_t ddi_periodic_add(void (*)(void *), void *, hrtime_t, int);
2225dd4eeefdSeota void ddi_periodic_delete(ddi_periodic_t);
222619397407SSherry Moore 
222719397407SSherry Moore /*
222819397407SSherry Moore  * Default quiesce(9E) implementation for drivers that don't need to do
222919397407SSherry Moore  * anything.
223019397407SSherry Moore  */
223119397407SSherry Moore int ddi_quiesce_not_needed(dev_info_t *);
223219397407SSherry Moore 
223319397407SSherry Moore /*
223419397407SSherry Moore  * Default quiesce(9E) initialization function for drivers that should
223519397407SSherry Moore  * implement quiesce but haven't yet.
223619397407SSherry Moore  */
223719397407SSherry Moore int ddi_quiesce_not_supported(dev_info_t *);
223819397407SSherry Moore 
22395febcb4aSScott Carter, SD IOSW /*
22405febcb4aSScott Carter, SD IOSW  * DDI generic callback interface
22415febcb4aSScott Carter, SD IOSW  */
22425febcb4aSScott Carter, SD IOSW 
22435febcb4aSScott Carter, SD IOSW typedef struct __ddi_cb **ddi_cb_handle_t;
22445febcb4aSScott Carter, SD IOSW 
22455febcb4aSScott Carter, SD IOSW int	ddi_cb_register(dev_info_t *dip, ddi_cb_flags_t flags,
22465febcb4aSScott Carter, SD IOSW 	    ddi_cb_func_t cbfunc, void *arg1, void *arg2,
22475febcb4aSScott Carter, SD IOSW 	    ddi_cb_handle_t *ret_hdlp);
22485febcb4aSScott Carter, SD IOSW int	ddi_cb_unregister(ddi_cb_handle_t hdl);
22495febcb4aSScott Carter, SD IOSW 
22503a634bfcSVikram Hegde /* Notify DDI of memory added */
22513a634bfcSVikram Hegde void ddi_mem_update(uint64_t addr, uint64_t size);
22523a634bfcSVikram Hegde 
225394c894bbSVikram Hegde /* Path alias interfaces */
225494c894bbSVikram Hegde typedef struct plat_alias {
225594c894bbSVikram Hegde 	char *pali_current;
225694c894bbSVikram Hegde 	uint64_t pali_naliases;
225794c894bbSVikram Hegde 	char **pali_aliases;
225894c894bbSVikram Hegde } plat_alias_t;
225994c894bbSVikram Hegde 
226094c894bbSVikram Hegde typedef struct alias_pair {
226194c894bbSVikram Hegde 	char *pair_alias;
226294c894bbSVikram Hegde 	char *pair_curr;
226394c894bbSVikram Hegde } alias_pair_t;
226494c894bbSVikram Hegde 
226594c894bbSVikram Hegde extern boolean_t ddi_aliases_present;
226694c894bbSVikram Hegde 
226794c894bbSVikram Hegde typedef struct ddi_alias {
226894c894bbSVikram Hegde 	alias_pair_t	*dali_alias_pairs;
226994c894bbSVikram Hegde 	alias_pair_t	*dali_curr_pairs;
227094c894bbSVikram Hegde 	int		dali_num_pairs;
227194c894bbSVikram Hegde 	mod_hash_t	*dali_alias_TLB;
227294c894bbSVikram Hegde 	mod_hash_t	*dali_curr_TLB;
227394c894bbSVikram Hegde } ddi_alias_t;
227494c894bbSVikram Hegde 
227594c894bbSVikram Hegde extern ddi_alias_t ddi_aliases;
227694c894bbSVikram Hegde 
227794c894bbSVikram Hegde void ddi_register_aliases(plat_alias_t *pali, uint64_t npali);
227894c894bbSVikram Hegde dev_info_t *ddi_alias_redirect(char *alias);
227994c894bbSVikram Hegde char *ddi_curr_redirect(char *curr);
228094c894bbSVikram Hegde 
22817c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
22827c478bd9Sstevel@tonic-gate 
22837c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
22847c478bd9Sstevel@tonic-gate }
22857c478bd9Sstevel@tonic-gate #endif
22867c478bd9Sstevel@tonic-gate 
22877c478bd9Sstevel@tonic-gate #endif	/* _SYS_SUNDDI_H */
2288