xref: /titanic_50/usr/src/uts/common/sys/sunddi.h (revision 7851eb825442b34b70077920364eeee5f91c43fa)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_SUNDDI_H
287c478bd9Sstevel@tonic-gate #define	_SYS_SUNDDI_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * Sun Specific DDI definitions
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
377c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
387c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h>
397c478bd9Sstevel@tonic-gate #include <sys/devops.h>
407c478bd9Sstevel@tonic-gate #include <sys/time.h>
417c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
427c478bd9Sstevel@tonic-gate #include <sys/ddidevmap.h>
437c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
447c478bd9Sstevel@tonic-gate #include <sys/ddi_implfuncs.h>
457c478bd9Sstevel@tonic-gate #include <sys/ddi_isa.h>
467c478bd9Sstevel@tonic-gate #include <sys/model.h>
477c478bd9Sstevel@tonic-gate #include <sys/devctl.h>
487c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
497c478bd9Sstevel@tonic-gate #include <sys/dma_engine.h>
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate #include <sys/sunpm.h>
527c478bd9Sstevel@tonic-gate #include <sys/nvpair.h>
537c478bd9Sstevel@tonic-gate #include <sys/sysevent.h>
547c478bd9Sstevel@tonic-gate #include <sys/thread.h>
557c478bd9Sstevel@tonic-gate #include <sys/stream.h>
567c478bd9Sstevel@tonic-gate #if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL)
577c478bd9Sstevel@tonic-gate #include <asm/sunddi.h>
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
617c478bd9Sstevel@tonic-gate extern "C" {
627c478bd9Sstevel@tonic-gate #endif
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Generic Sun DDI definitions.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	DDI_SUCCESS	(0)	/* successful return */
697c478bd9Sstevel@tonic-gate #define	DDI_FAILURE	(-1)	/* unsuccessful return */
707c478bd9Sstevel@tonic-gate #define	DDI_NOT_WELL_FORMED (-2)  /* A dev_info node is not valid */
717c478bd9Sstevel@tonic-gate #define	DDI_EAGAIN	(-3)	/* not enough interrupt resources */
727c478bd9Sstevel@tonic-gate #define	DDI_EINVAL	(-4)	/* invalid request or arguments */
737c478bd9Sstevel@tonic-gate #define	DDI_ENOTSUP	(-5)	/* operation is not supported */
747c478bd9Sstevel@tonic-gate #define	DDI_EPENDING	(-6)	/* operation or an event is pending */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * General-purpose DDI error return value definitions
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate #define	DDI_ENOMEM		1	/* memory not available */
807c478bd9Sstevel@tonic-gate #define	DDI_EBUSY		2	/* busy */
817c478bd9Sstevel@tonic-gate #define	DDI_ETRANSPORT		3	/* transport down */
827c478bd9Sstevel@tonic-gate #define	DDI_ECONTEXT		4	/* context error */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  * General DDI sleep/nosleep allocation flags
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate #define	DDI_SLEEP	0
897c478bd9Sstevel@tonic-gate #define	DDI_NOSLEEP	1
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*
927c478bd9Sstevel@tonic-gate  * The following special nodeid values are reserved for use when creating
937c478bd9Sstevel@tonic-gate  * nodes ONLY.  They specify the attributes of the DDI_NC_PSEUDO class node
947c478bd9Sstevel@tonic-gate  * being created:
957c478bd9Sstevel@tonic-gate  *
967c478bd9Sstevel@tonic-gate  *  o	DEVI_PSEUDO_NODEID specifics a node without persistence.
977c478bd9Sstevel@tonic-gate  *  o	DEVI_SID_NODEID specifies a node with persistence.
987c478bd9Sstevel@tonic-gate  *
997c478bd9Sstevel@tonic-gate  * A node with the 'persistent' attribute will not be automatically removed by
1007c478bd9Sstevel@tonic-gate  * the framework in the current implementation - driver.conf nodes are without
1017c478bd9Sstevel@tonic-gate  * persistence.
1027c478bd9Sstevel@tonic-gate  *
1037c478bd9Sstevel@tonic-gate  * The actual nodeid value may be assigned by the framework and may be
1047c478bd9Sstevel@tonic-gate  * different than these special values. Drivers may not make assumptions
1057c478bd9Sstevel@tonic-gate  * about the nodeid value that is actually assigned to the node.
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate #define	DEVI_PSEUDO_NODEID	((int)-1)
1097c478bd9Sstevel@tonic-gate #define	DEVI_SID_NODEID		((int)-2)
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #define	DEVI_PSEUDO_NEXNAME	"pseudo"
1127c478bd9Sstevel@tonic-gate #define	DEVI_ISA_NEXNAME	"isa"
1137c478bd9Sstevel@tonic-gate #define	DEVI_EISA_NEXNAME	"eisa"
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * ddi_create_minor_node flags
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #define	CLONE_DEV		1	/* device is a clone device */
1197c478bd9Sstevel@tonic-gate #define	PRIVONLY_DEV		0x10	/* policy-based permissions only */
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * Historical values used for the flag field in ddi_create_minor_node.
1237c478bd9Sstevel@tonic-gate  * Future use of flag bits should avoid these fields to keep binary
1247c478bd9Sstevel@tonic-gate  * compatibility
1257c478bd9Sstevel@tonic-gate  * #define	GLOBAL_DEV		0x2
1267c478bd9Sstevel@tonic-gate  * #define	NODEBOUND_DEV		0x4
1277c478bd9Sstevel@tonic-gate  * #define	NODESPECIFIC_DEV	0x6
1287c478bd9Sstevel@tonic-gate  * #define	ENUMERATED_DEV		0x8
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate /*
1327c478bd9Sstevel@tonic-gate  * Device type defines which are used by the 'node_type' element of the
1337c478bd9Sstevel@tonic-gate  * ddi_minor_data structure
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL	"ddi_serial"		/* Serial port */
1367c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_MB "ddi_serial:mb"	/* the 'built-in' serial */
1377c478bd9Sstevel@tonic-gate 						/* ports (the old ttya, b */
1387c478bd9Sstevel@tonic-gate 						/* (,c ,d)) */
1397c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_DO "ddi_serial:dialout"	/* dialout ports */
1407c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_MB_DO "ddi_serial:dialout,mb" /* dialout for onboard */
1417c478bd9Sstevel@tonic-gate 						/* ports */
1427c478bd9Sstevel@tonic-gate #define	DDI_NT_SERIAL_LOMCON "ddi_serial:lomcon" /* LOMlite2 console port */
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate /*
1457c478bd9Sstevel@tonic-gate  * *_CHAN disk type devices have channel numbers or target numbers.
1467c478bd9Sstevel@tonic-gate  * (i.e. ipi and scsi devices)
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK	"ddi_block"		/* hard disks */
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  * The next define is for block type devices that can possible exist on
1517c478bd9Sstevel@tonic-gate  * a sub-bus like the scsi bus or the ipi channel.  The 'disks' program
1527c478bd9Sstevel@tonic-gate  * will pick up on this and create logical names like c0t0d0s0 instead of
1537c478bd9Sstevel@tonic-gate  * c0d0s0
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK_CHAN	"ddi_block:channel"
1567c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK_WWN	"ddi_block:wwn"
1577c478bd9Sstevel@tonic-gate #define	DDI_NT_CD	"ddi_block:cdrom"	/* rom drives (cd-rom) */
1587c478bd9Sstevel@tonic-gate #define	DDI_NT_CD_CHAN	"ddi_block:cdrom:channel" /* rom drives (scsi type) */
1597c478bd9Sstevel@tonic-gate #define	DDI_NT_FD	"ddi_block:diskette"	/* floppy disks */
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #define	DDI_NT_ENCLOSURE	"ddi_enclosure"
1627c478bd9Sstevel@tonic-gate #define	DDI_NT_SCSI_ENCLOSURE	"ddi_enclosure:scsi"
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate #define	DDI_NT_TAPE	"ddi_byte:tape"		/* tape drives */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate #define	DDI_NT_NET	"ddi_network"		/* DLPI network devices */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate #define	DDI_NT_MAC	"ddi_mac"		/* MAC devices */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate #define	DDI_NT_DISPLAY	"ddi_display"		/* display devices */
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #define	DDI_PSEUDO	"ddi_pseudo"		/* general pseudo devices */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate #define	DDI_NT_AUDIO	"ddi_audio"		/* audio device */
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate #define	DDI_NT_MOUSE	"ddi_mouse"		/* mouse device */
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate #define	DDI_NT_KEYBOARD	"ddi_keyboard"		/* keyboard device */
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate #define	DDI_NT_PARALLEL "ddi_parallel"		/* parallel port */
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate #define	DDI_NT_PRINTER	"ddi_printer"		/* printer device */
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate #define	DDI_NT_UGEN	"ddi_generic:usb"	/* USB generic drv */
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate #define	DDI_NT_NEXUS	"ddi_ctl:devctl"	/* nexus drivers */
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate #define	DDI_NT_SCSI_NEXUS	"ddi_ctl:devctl:scsi"	/* nexus drivers */
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate #define	DDI_NT_ATTACHMENT_POINT	"ddi_ctl:attachment_point" /* attachment pt */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate #define	DDI_NT_SCSI_ATTACHMENT_POINT	"ddi_ctl:attachment_point:scsi"
1947c478bd9Sstevel@tonic-gate 						/* scsi attachment pt */
1957c478bd9Sstevel@tonic-gate #define	DDI_NT_PCI_ATTACHMENT_POINT	"ddi_ctl:attachment_point:pci"
1967c478bd9Sstevel@tonic-gate 						/* PCI attachment pt */
1977c478bd9Sstevel@tonic-gate #define	DDI_NT_SBD_ATTACHMENT_POINT	"ddi_ctl:attachment_point:sbd"
1987c478bd9Sstevel@tonic-gate 						/* generic bd attachment pt */
1997c478bd9Sstevel@tonic-gate #define	DDI_NT_FC_ATTACHMENT_POINT	"ddi_ctl:attachment_point:fc"
2007c478bd9Sstevel@tonic-gate 						/* FC attachment pt */
2017c478bd9Sstevel@tonic-gate #define	DDI_NT_USB_ATTACHMENT_POINT	"ddi_ctl:attachment_point:usb"
2027c478bd9Sstevel@tonic-gate 						/* USB devices */
2037c478bd9Sstevel@tonic-gate #define	DDI_NT_BLOCK_FABRIC		"ddi_block:fabric"
2047c478bd9Sstevel@tonic-gate 						/* Fabric Devices */
2057c478bd9Sstevel@tonic-gate #define	DDI_NT_IB_ATTACHMENT_POINT	"ddi_ctl:attachment_point:ib"
2067c478bd9Sstevel@tonic-gate 						/* IB devices */
2077c478bd9Sstevel@tonic-gate #define	DDI_NT_SMARTCARD_READER	"ddi_smartcard_reader" /* Smartcard reader */
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate #define	DDI_NT_AV_ASYNC "ddi_av:async"		/* asynchronous AV device */
2107c478bd9Sstevel@tonic-gate #define	DDI_NT_AV_ISOCH "ddi_av:isoch"		/* isochronous AV device */
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate /* Device types used for agpgart driver related devices */
2137c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_PSEUDO	"ddi_agp:pseudo" /* agpgart pseudo device */
2147c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_MASTER	"ddi_agp:master" /* agp master device */
2157c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_TARGET	"ddi_agp:target" /* agp target device */
2167c478bd9Sstevel@tonic-gate #define	DDI_NT_AGP_CPUGART	"ddi_agp:cpugart" /* amd64 on-cpu gart device */
2177c478bd9Sstevel@tonic-gate 
218*7851eb82Sschwartz #define	DDI_NT_REGACC		"ddi_tool_reg"	/* tool register access */
219*7851eb82Sschwartz #define	DDI_NT_INTRCTL		"ddi_tool_intr"	/* tool intr access */
220*7851eb82Sschwartz 
2217c478bd9Sstevel@tonic-gate /*
2227c478bd9Sstevel@tonic-gate  * DDI event definitions
2237c478bd9Sstevel@tonic-gate  */
2247c478bd9Sstevel@tonic-gate #define	EC_DEVFS	"EC_devfs"	/* Event class devfs */
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /* Class devfs subclasses */
2277c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_MINOR_CREATE	"ESC_devfs_minor_create"
2287c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_MINOR_REMOVE	"ESC_devfs_minor_remove"
2297c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_DEVI_ADD	"ESC_devfs_devi_add"
2307c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_DEVI_REMOVE	"ESC_devfs_devi_remove"
2317c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_INSTANCE_MOD	"ESC_devfs_instance_mod"
2327c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_BRANCH_ADD	"ESC_devfs_branch_add"
2337c478bd9Sstevel@tonic-gate #define	ESC_DEVFS_BRANCH_REMOVE	"ESC_devfs_branch_remove"
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate /* DDI/NDI event publisher */
2367c478bd9Sstevel@tonic-gate #define	EP_DDI	SUNW_KERN_PUB"ddi"
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate /*
2397c478bd9Sstevel@tonic-gate  * devfs event class attributes
2407c478bd9Sstevel@tonic-gate  *
2417c478bd9Sstevel@tonic-gate  * The following attributes are private to EC_DEVFS
2427c478bd9Sstevel@tonic-gate  * event data.
2437c478bd9Sstevel@tonic-gate  */
2447c478bd9Sstevel@tonic-gate #define	DEVFS_DRIVER_NAME	"di.driver"
2457c478bd9Sstevel@tonic-gate #define	DEVFS_INSTANCE		"di.instance"
2467c478bd9Sstevel@tonic-gate #define	DEVFS_PATHNAME		"di.path"
2477c478bd9Sstevel@tonic-gate #define	DEVFS_DEVI_CLASS	"di.devi_class"
2487c478bd9Sstevel@tonic-gate #define	DEVFS_BRANCH_EVENT	"di.branch_event"
2497c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_NAME	"mi.name"
2507c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_NODETYPE	"mi.nodetype"
2517c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_ISCLONE	"mi.isclone"
2527c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_MAJNUM	"mi.majorno"
2537c478bd9Sstevel@tonic-gate #define	DEVFS_MINOR_MINORNUM	"mi.minorno"
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate /*
2567c478bd9Sstevel@tonic-gate  * Fault-related definitions
2577c478bd9Sstevel@tonic-gate  *
2587c478bd9Sstevel@tonic-gate  * The specific numeric values have been chosen to be ordered, but
2597c478bd9Sstevel@tonic-gate  * not consecutive, to allow for future interpolation if required.
2607c478bd9Sstevel@tonic-gate  */
2617c478bd9Sstevel@tonic-gate typedef enum {
2627c478bd9Sstevel@tonic-gate     DDI_SERVICE_LOST = -32,
2637c478bd9Sstevel@tonic-gate     DDI_SERVICE_DEGRADED = -16,
2647c478bd9Sstevel@tonic-gate     DDI_SERVICE_UNAFFECTED = 0,
2657c478bd9Sstevel@tonic-gate     DDI_SERVICE_RESTORED = 16
2667c478bd9Sstevel@tonic-gate } ddi_fault_impact_t;
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate typedef enum {
2697c478bd9Sstevel@tonic-gate     DDI_DATAPATH_FAULT = -32,
2707c478bd9Sstevel@tonic-gate     DDI_DEVICE_FAULT = -16,
2717c478bd9Sstevel@tonic-gate     DDI_EXTERNAL_FAULT = 0
2727c478bd9Sstevel@tonic-gate } ddi_fault_location_t;
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate typedef enum {
2757c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_OFFLINE = -32,
2767c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_DOWN = -16,
2777c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_QUIESCED = 0,
2787c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_DEGRADED = 16,
2797c478bd9Sstevel@tonic-gate     DDI_DEVSTATE_UP = 32
2807c478bd9Sstevel@tonic-gate } ddi_devstate_t;
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate /*
2857c478bd9Sstevel@tonic-gate  * Common property definitions
2867c478bd9Sstevel@tonic-gate  */
2877c478bd9Sstevel@tonic-gate #define	DDI_FORCEATTACH		"ddi-forceattach"
2887c478bd9Sstevel@tonic-gate #define	DDI_NO_AUTODETACH	"ddi-no-autodetach"
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  * Values that the function supplied to the dev_info
2927c478bd9Sstevel@tonic-gate  * tree traversal functions defined below must return.
2937c478bd9Sstevel@tonic-gate  */
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate /*
2967c478bd9Sstevel@tonic-gate  * Continue search, if appropriate.
2977c478bd9Sstevel@tonic-gate  */
2987c478bd9Sstevel@tonic-gate #define	DDI_WALK_CONTINUE	0
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate /*
3017c478bd9Sstevel@tonic-gate  * Terminate current depth of traversal. That is, terminate
3027c478bd9Sstevel@tonic-gate  * the current traversal of children nodes, but continue
3037c478bd9Sstevel@tonic-gate  * traversing sibling nodes and their children (if any).
3047c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate #define	DDI_WALK_PRUNECHILD	-1
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate /*
3097c478bd9Sstevel@tonic-gate  * Terminate current width of traversal. That is, terminate
3107c478bd9Sstevel@tonic-gate  * the current traversal of sibling nodes, but continue with
3117c478bd9Sstevel@tonic-gate  * traversing children nodes and their siblings (if appropriate).
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #define	DDI_WALK_PRUNESIB	-2
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * Terminate the entire search.
3187c478bd9Sstevel@tonic-gate  */
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate #define	DDI_WALK_TERMINATE	-3
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /*
3237c478bd9Sstevel@tonic-gate  * Terminate the entire search because an error occurred in function
3247c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate #define	DDI_WALK_ERROR		-4
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate /*
3287c478bd9Sstevel@tonic-gate  * Drivers that are prepared to support full driver layering
3297c478bd9Sstevel@tonic-gate  * should create and export a null-valued property of the following
3307c478bd9Sstevel@tonic-gate  * name.
3317c478bd9Sstevel@tonic-gate  *
3327c478bd9Sstevel@tonic-gate  * Such drivers should be prepared to be called with FKLYR in
3337c478bd9Sstevel@tonic-gate  * the 'flag' argument of their open(9E), close(9E) routines, and
3347c478bd9Sstevel@tonic-gate  * with FKIOCTL in the 'mode' argument of their ioctl(9E) routines.
3357c478bd9Sstevel@tonic-gate  *
3367c478bd9Sstevel@tonic-gate  * See ioctl(9E) and ddi_copyin(9F) for details.
3377c478bd9Sstevel@tonic-gate  */
3387c478bd9Sstevel@tonic-gate #define	DDI_KERNEL_IOCTL	"ddi-kernel-ioctl"
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate /*
3417c478bd9Sstevel@tonic-gate  * Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F).
3427c478bd9Sstevel@tonic-gate  */
3437c478bd9Sstevel@tonic-gate #define	DDI_MODEL_MASK		DATAMODEL_MASK	/* Note: 0x0FF00000 */
3447c478bd9Sstevel@tonic-gate #define	DDI_MODEL_ILP32		DATAMODEL_ILP32
3457c478bd9Sstevel@tonic-gate #define	DDI_MODEL_LP64		DATAMODEL_LP64
3467c478bd9Sstevel@tonic-gate #define	DDI_MODEL_NATIVE	DATAMODEL_NATIVE
3477c478bd9Sstevel@tonic-gate #define	DDI_MODEL_NONE		DATAMODEL_NONE
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate /*
3507c478bd9Sstevel@tonic-gate  * Functions and data references which really should be in <sys/ddi.h>
3517c478bd9Sstevel@tonic-gate  */
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate extern int maxphys;
3547c478bd9Sstevel@tonic-gate extern void minphys(struct buf *);
3557c478bd9Sstevel@tonic-gate extern int physio(int (*)(struct buf *), struct buf *, dev_t,
3567c478bd9Sstevel@tonic-gate 	int, void (*)(struct buf *), struct uio *);
3577c478bd9Sstevel@tonic-gate extern void disksort(struct diskhd *, struct buf *);
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate extern long strtol(const char *, char **, int);
3607c478bd9Sstevel@tonic-gate extern unsigned long strtoul(const char *, char **, int);
3617c478bd9Sstevel@tonic-gate extern size_t strlen(const char *) __PURE;
3627c478bd9Sstevel@tonic-gate extern char *strcpy(char *, const char *);
3637c478bd9Sstevel@tonic-gate extern char *strncpy(char *, const char *, size_t);
3647c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for strchr() */
3657c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
3667c478bd9Sstevel@tonic-gate extern const char *strchr(const char *, int);
3677c478bd9Sstevel@tonic-gate #ifndef	_STRCHR_INLINE
3687c478bd9Sstevel@tonic-gate #define	_STRCHR_INLINE
3697c478bd9Sstevel@tonic-gate extern	"C++" {
3707c478bd9Sstevel@tonic-gate 	inline char *strchr(char *__s, int __c) {
3717c478bd9Sstevel@tonic-gate 		return (char *)strchr((const char *)__s, __c);
3727c478bd9Sstevel@tonic-gate 	}
3737c478bd9Sstevel@tonic-gate }
3747c478bd9Sstevel@tonic-gate #endif	/* _STRCHR_INLINE */
3757c478bd9Sstevel@tonic-gate #else
3767c478bd9Sstevel@tonic-gate extern char *strchr(const char *, int);
3777c478bd9Sstevel@tonic-gate #endif	/* __cplusplus >= 199711L */
3787c478bd9Sstevel@tonic-gate extern int strcmp(const char *, const char *) __PURE;
3797c478bd9Sstevel@tonic-gate extern int strncmp(const char *, const char *, size_t) __PURE;
3807c478bd9Sstevel@tonic-gate extern char *strncat(char *, const char *, size_t);
3817c478bd9Sstevel@tonic-gate extern size_t strlcat(char *, const char *, size_t);
3827c478bd9Sstevel@tonic-gate extern size_t strlcpy(char *, const char *, size_t);
3837c478bd9Sstevel@tonic-gate extern size_t strspn(const char *, const char *);
3847c478bd9Sstevel@tonic-gate extern int bcmp(const void *, const void *, size_t) __PURE;
3857c478bd9Sstevel@tonic-gate extern int stoi(char **);
3867c478bd9Sstevel@tonic-gate extern void numtos(ulong_t, char *);
3877c478bd9Sstevel@tonic-gate extern void bcopy(const void *, void *, size_t);
3887c478bd9Sstevel@tonic-gate extern void bzero(void *, size_t);
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate extern void *memcpy(void *, const  void  *, size_t);
3917c478bd9Sstevel@tonic-gate extern void *memset(void *, int, size_t);
3927c478bd9Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t);
3937c478bd9Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t) __PURE;
3947c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for memchr() */
3957c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
3967c478bd9Sstevel@tonic-gate extern const void *memchr(const void *, int, size_t);
3977c478bd9Sstevel@tonic-gate #ifndef	_MEMCHR_INLINE
3987c478bd9Sstevel@tonic-gate #define	_MEMCHR_INLINE
3997c478bd9Sstevel@tonic-gate extern "C++" {
4007c478bd9Sstevel@tonic-gate 	inline void *memchr(void * __s, int __c, size_t __n) {
4017c478bd9Sstevel@tonic-gate 		return (void *)memchr((const void *)__s, __c, __n);
4027c478bd9Sstevel@tonic-gate 	}
4037c478bd9Sstevel@tonic-gate }
4047c478bd9Sstevel@tonic-gate #endif  /* _MEMCHR_INLINE */
4057c478bd9Sstevel@tonic-gate #else
4067c478bd9Sstevel@tonic-gate extern void *memchr(const void *, int, size_t);
4077c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
4087c478bd9Sstevel@tonic-gate 
4097c478bd9Sstevel@tonic-gate extern int ddi_strtol(const char *, char **, int, long *);
4107c478bd9Sstevel@tonic-gate extern int ddi_strtoul(const char *, char **, int, unsigned long *);
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate /*
4137c478bd9Sstevel@tonic-gate  * ddi_map_regs
4147c478bd9Sstevel@tonic-gate  *
4157c478bd9Sstevel@tonic-gate  *	Map in the register set given by rnumber.
4167c478bd9Sstevel@tonic-gate  *	The register number determine which register
4177c478bd9Sstevel@tonic-gate  *	set will be mapped if more than one exists.
4187c478bd9Sstevel@tonic-gate  *	The parent driver gets the information
4197c478bd9Sstevel@tonic-gate  *	from parent private data and sets up the
4207c478bd9Sstevel@tonic-gate  *	appropriate mappings and returns the kernel
4217c478bd9Sstevel@tonic-gate  *	virtual address of the register set in *kaddrp.
4227c478bd9Sstevel@tonic-gate  *	The offset specifies an offset into the register
4237c478bd9Sstevel@tonic-gate  *	space to start from and len indicates the size
4247c478bd9Sstevel@tonic-gate  *	of the area to map. If len and offset are 0 then
4257c478bd9Sstevel@tonic-gate  *	the entire space is mapped.  It returns DDI_SUCCESS on
4267c478bd9Sstevel@tonic-gate  *	success or DDI_FAILURE otherwise.
4277c478bd9Sstevel@tonic-gate  *
4287c478bd9Sstevel@tonic-gate  */
4297c478bd9Sstevel@tonic-gate int
4307c478bd9Sstevel@tonic-gate ddi_map_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
4317c478bd9Sstevel@tonic-gate 	off_t offset, off_t len);
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate /*
4347c478bd9Sstevel@tonic-gate  * ddi_unmap_regs
4357c478bd9Sstevel@tonic-gate  *
4367c478bd9Sstevel@tonic-gate  *	Undo mappings set up by ddi_map_regs.
4377c478bd9Sstevel@tonic-gate  *	The register number determines which register
4387c478bd9Sstevel@tonic-gate  *	set will be unmapped if more than one exists.
4397c478bd9Sstevel@tonic-gate  *	This is provided for drivers preparing
4407c478bd9Sstevel@tonic-gate  *	to detach themselves from the system to
4417c478bd9Sstevel@tonic-gate  *	allow them to release allocated mappings.
4427c478bd9Sstevel@tonic-gate  *
4437c478bd9Sstevel@tonic-gate  *	The kaddrp and len specify the area to be
4447c478bd9Sstevel@tonic-gate  *	unmapped. *kaddrp was returned from ddi_map_regs
4457c478bd9Sstevel@tonic-gate  *	and len should match what ddi_map_regs was called
4467c478bd9Sstevel@tonic-gate  *	with.
4477c478bd9Sstevel@tonic-gate  */
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate void
4507c478bd9Sstevel@tonic-gate ddi_unmap_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
4517c478bd9Sstevel@tonic-gate 	off_t offset, off_t len);
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate int
4547c478bd9Sstevel@tonic-gate ddi_map(dev_info_t *dp, ddi_map_req_t *mp, off_t offset, off_t len,
4557c478bd9Sstevel@tonic-gate 	caddr_t *addrp);
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate int
4587c478bd9Sstevel@tonic-gate ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate /*
4617c478bd9Sstevel@tonic-gate  * ddi_rnumber_to_regspec: Not for use by leaf drivers.
4627c478bd9Sstevel@tonic-gate  */
4637c478bd9Sstevel@tonic-gate struct regspec *
4647c478bd9Sstevel@tonic-gate ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
4657c478bd9Sstevel@tonic-gate 
4667c478bd9Sstevel@tonic-gate int
4677c478bd9Sstevel@tonic-gate ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
4687c478bd9Sstevel@tonic-gate 	off_t len, caddr_t *vaddrp);
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate int
4717c478bd9Sstevel@tonic-gate nullbusmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
4727c478bd9Sstevel@tonic-gate 	off_t len, caddr_t *vaddrp);
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate #ifdef _LP64
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate int ddi_peek8(dev_info_t *dip, int8_t *addr, int8_t *val_p);
4777c478bd9Sstevel@tonic-gate int ddi_peek16(dev_info_t *dip, int16_t *addr, int16_t *val_p);
4787c478bd9Sstevel@tonic-gate int ddi_peek32(dev_info_t *dip, int32_t *addr, int32_t *val_p);
4797c478bd9Sstevel@tonic-gate int ddi_peek64(dev_info_t *dip, int64_t *addr, int64_t *val_p);
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate int ddi_poke8(dev_info_t *dip, int8_t *addr, int8_t val);
4827c478bd9Sstevel@tonic-gate int ddi_poke16(dev_info_t *dip, int16_t *addr, int16_t val);
4837c478bd9Sstevel@tonic-gate int ddi_poke32(dev_info_t *dip, int32_t *addr, int32_t val);
4847c478bd9Sstevel@tonic-gate int ddi_poke64(dev_info_t *dip, int64_t *addr, int64_t val);
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate #else /* _ILP32 */
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate int ddi_peekc(dev_info_t *dip, int8_t *addr, int8_t *val_p);
4897c478bd9Sstevel@tonic-gate #define	ddi_peek8	ddi_peekc
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate int ddi_peeks(dev_info_t *dip, int16_t *addr, int16_t *val_p);
4927c478bd9Sstevel@tonic-gate #define	ddi_peek16	ddi_peeks
4937c478bd9Sstevel@tonic-gate 
4947c478bd9Sstevel@tonic-gate int ddi_peekl(dev_info_t *dip, int32_t *addr, int32_t *val_p);
4957c478bd9Sstevel@tonic-gate #define	ddi_peek32	ddi_peekl
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate int ddi_peekd(dev_info_t *dip, int64_t *addr, int64_t *val_p);
4987c478bd9Sstevel@tonic-gate #define	ddi_peek64	ddi_peekd
4997c478bd9Sstevel@tonic-gate 
5007c478bd9Sstevel@tonic-gate int ddi_pokec(dev_info_t *dip, int8_t *addr, int8_t val);
5017c478bd9Sstevel@tonic-gate #define	ddi_poke8	ddi_pokec
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate int ddi_pokes(dev_info_t *dip, int16_t *addr, int16_t val);
5047c478bd9Sstevel@tonic-gate #define	ddi_poke16	ddi_pokes
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate int ddi_pokel(dev_info_t *dip, int32_t *addr, int32_t val);
5077c478bd9Sstevel@tonic-gate #define	ddi_poke32	ddi_pokel
5087c478bd9Sstevel@tonic-gate 
5097c478bd9Sstevel@tonic-gate int ddi_poked(dev_info_t *dip, int64_t *addr, int64_t val);
5107c478bd9Sstevel@tonic-gate #define	ddi_poke64	ddi_poked
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate #endif /* _LP64 */
5137c478bd9Sstevel@tonic-gate 
5147c478bd9Sstevel@tonic-gate /*
5157c478bd9Sstevel@tonic-gate  * Peek and poke to and from a uio structure in xfersize pieces,
5167c478bd9Sstevel@tonic-gate  * using the parent nexi.
5177c478bd9Sstevel@tonic-gate  */
5187c478bd9Sstevel@tonic-gate int ddi_peekpokeio(dev_info_t *devi, struct uio *uio, enum uio_rw rw,
5197c478bd9Sstevel@tonic-gate 	caddr_t addr, size_t len, uint_t xfersize);
5207c478bd9Sstevel@tonic-gate 
5217c478bd9Sstevel@tonic-gate /*
5227c478bd9Sstevel@tonic-gate  * Pagesize conversions using the parent nexi
5237c478bd9Sstevel@tonic-gate  */
5247c478bd9Sstevel@tonic-gate unsigned long ddi_btop(dev_info_t *dip, unsigned long bytes);
5257c478bd9Sstevel@tonic-gate unsigned long ddi_btopr(dev_info_t *dip, unsigned long bytes);
5267c478bd9Sstevel@tonic-gate unsigned long ddi_ptob(dev_info_t *dip, unsigned long pages);
5277c478bd9Sstevel@tonic-gate 
5287c478bd9Sstevel@tonic-gate /*
5297c478bd9Sstevel@tonic-gate  * There are no more "block" interrupt functions, per se.
5307c478bd9Sstevel@tonic-gate  * All thread of control should be done with MP/MT lockings.
5317c478bd9Sstevel@tonic-gate  *
5327c478bd9Sstevel@tonic-gate  * However, there are certain times in which a driver needs
5337c478bd9Sstevel@tonic-gate  * absolutely a critical guaranteed non-preemptable time
5347c478bd9Sstevel@tonic-gate  * in which to execute a few instructions.
5357c478bd9Sstevel@tonic-gate  *
5367c478bd9Sstevel@tonic-gate  * The following pair of functions attempt to guarantee this,
5377c478bd9Sstevel@tonic-gate  * but they are dangerous to use. That is, use them with
5387c478bd9Sstevel@tonic-gate  * extreme care. They do not guarantee to stop other processors
5397c478bd9Sstevel@tonic-gate  * from executing, but they do guarantee that the caller
5407c478bd9Sstevel@tonic-gate  * of ddi_enter_critical will continue to run until the
5417c478bd9Sstevel@tonic-gate  * caller calls ddi_exit_critical. No intervening DDI functions
5427c478bd9Sstevel@tonic-gate  * may be called between an entry and an exit from a critical
5437c478bd9Sstevel@tonic-gate  * region.
5447c478bd9Sstevel@tonic-gate  *
5457c478bd9Sstevel@tonic-gate  * ddi_enter_critical returns an integer identifier which must
5467c478bd9Sstevel@tonic-gate  * be passed to ddi_exit_critical.
5477c478bd9Sstevel@tonic-gate  *
5487c478bd9Sstevel@tonic-gate  * Be very sparing in the use of these functions since it is
5497c478bd9Sstevel@tonic-gate  * likely that absolutely nothing else can occur in the system
5507c478bd9Sstevel@tonic-gate  * whilst in the critical region.
5517c478bd9Sstevel@tonic-gate  */
5527c478bd9Sstevel@tonic-gate 
5537c478bd9Sstevel@tonic-gate unsigned int
5547c478bd9Sstevel@tonic-gate ddi_enter_critical(void);
5557c478bd9Sstevel@tonic-gate 
5567c478bd9Sstevel@tonic-gate void
5577c478bd9Sstevel@tonic-gate ddi_exit_critical(unsigned int);
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate /*
5607c478bd9Sstevel@tonic-gate  * devmap functions
5617c478bd9Sstevel@tonic-gate  */
5627c478bd9Sstevel@tonic-gate int
5637c478bd9Sstevel@tonic-gate devmap_setup(dev_t dev, offset_t off, ddi_as_handle_t as, caddr_t *addrp,
5647c478bd9Sstevel@tonic-gate 	size_t len, uint_t prot, uint_t maxprot, uint_t flags,
5657c478bd9Sstevel@tonic-gate 	struct cred *cred);
5667c478bd9Sstevel@tonic-gate 
5677c478bd9Sstevel@tonic-gate int
5687c478bd9Sstevel@tonic-gate ddi_devmap_segmap(dev_t dev, off_t off, ddi_as_handle_t as, caddr_t *addrp,
5697c478bd9Sstevel@tonic-gate 	off_t len, uint_t prot, uint_t maxprot, uint_t flags,
5707c478bd9Sstevel@tonic-gate 	struct cred *cred);
5717c478bd9Sstevel@tonic-gate 
5727c478bd9Sstevel@tonic-gate int
5737c478bd9Sstevel@tonic-gate devmap_load(devmap_cookie_t dhp, offset_t offset, size_t len, uint_t type,
5747c478bd9Sstevel@tonic-gate 	uint_t rw);
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate int
5777c478bd9Sstevel@tonic-gate devmap_unload(devmap_cookie_t dhp, offset_t offset, size_t len);
5787c478bd9Sstevel@tonic-gate 
5797c478bd9Sstevel@tonic-gate int
5807c478bd9Sstevel@tonic-gate devmap_devmem_setup(devmap_cookie_t dhp, dev_info_t *dip,
5817c478bd9Sstevel@tonic-gate 	struct devmap_callback_ctl *callback_ops,
5827c478bd9Sstevel@tonic-gate 	uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
5837c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
5847c478bd9Sstevel@tonic-gate 
5857c478bd9Sstevel@tonic-gate int
5867c478bd9Sstevel@tonic-gate devmap_umem_setup(devmap_cookie_t dhp, dev_info_t *dip,
5877c478bd9Sstevel@tonic-gate 	struct devmap_callback_ctl *callback_ops,
5887c478bd9Sstevel@tonic-gate 	ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
5897c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
5907c478bd9Sstevel@tonic-gate 
5917c478bd9Sstevel@tonic-gate int
5927c478bd9Sstevel@tonic-gate devmap_devmem_remap(devmap_cookie_t dhp, dev_info_t *dip,
5937c478bd9Sstevel@tonic-gate 	uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
5947c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
5957c478bd9Sstevel@tonic-gate 
5967c478bd9Sstevel@tonic-gate int
5977c478bd9Sstevel@tonic-gate devmap_umem_remap(devmap_cookie_t dhp, dev_info_t *dip,
5987c478bd9Sstevel@tonic-gate 	ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
5997c478bd9Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6007c478bd9Sstevel@tonic-gate 
6017c478bd9Sstevel@tonic-gate void
6027c478bd9Sstevel@tonic-gate devmap_set_ctx_timeout(devmap_cookie_t dhp, clock_t ticks);
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate int
6057c478bd9Sstevel@tonic-gate devmap_default_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
6067c478bd9Sstevel@tonic-gate 	size_t len, uint_t type, uint_t rw);
6077c478bd9Sstevel@tonic-gate 
6087c478bd9Sstevel@tonic-gate int
6097c478bd9Sstevel@tonic-gate devmap_do_ctxmgt(devmap_cookie_t dhp, void *pvtp, offset_t off, size_t len,
6107c478bd9Sstevel@tonic-gate 	uint_t type, uint_t rw, int (*ctxmgt)(devmap_cookie_t, void *, offset_t,
6117c478bd9Sstevel@tonic-gate 	size_t, uint_t, uint_t));
6127c478bd9Sstevel@tonic-gate 
6137c478bd9Sstevel@tonic-gate 
6147c478bd9Sstevel@tonic-gate void *ddi_umem_alloc(size_t size, int flag, ddi_umem_cookie_t *cookiep);
6157c478bd9Sstevel@tonic-gate 
6167c478bd9Sstevel@tonic-gate void ddi_umem_free(ddi_umem_cookie_t cookie);
6177c478bd9Sstevel@tonic-gate 
6187c478bd9Sstevel@tonic-gate /*
6197c478bd9Sstevel@tonic-gate  * Functions to lock user memory and do repeated I/O or do devmap_umem_setup
6207c478bd9Sstevel@tonic-gate  */
6217c478bd9Sstevel@tonic-gate int
6227c478bd9Sstevel@tonic-gate ddi_umem_lock(caddr_t addr, size_t size, int flags, ddi_umem_cookie_t *cookie);
6237c478bd9Sstevel@tonic-gate 
6247c478bd9Sstevel@tonic-gate void
6257c478bd9Sstevel@tonic-gate ddi_umem_unlock(ddi_umem_cookie_t cookie);
6267c478bd9Sstevel@tonic-gate 
6277c478bd9Sstevel@tonic-gate struct buf *
6287c478bd9Sstevel@tonic-gate ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction,
6297c478bd9Sstevel@tonic-gate     dev_t dev, daddr_t blkno, int (*iodone)(struct buf *), int sleepflag);
6307c478bd9Sstevel@tonic-gate 
6317c478bd9Sstevel@tonic-gate /*
6327c478bd9Sstevel@tonic-gate  * Mapping functions
6337c478bd9Sstevel@tonic-gate  */
6347c478bd9Sstevel@tonic-gate int
6357c478bd9Sstevel@tonic-gate ddi_segmap(dev_t dev, off_t offset, struct as *asp, caddr_t *addrp, off_t len,
6367c478bd9Sstevel@tonic-gate 	uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp);
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate int
6397c478bd9Sstevel@tonic-gate ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, caddr_t *addrp,
6407c478bd9Sstevel@tonic-gate 	off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cred,
6417c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, uint_t rnumber);
6427c478bd9Sstevel@tonic-gate 
6437c478bd9Sstevel@tonic-gate int
6447c478bd9Sstevel@tonic-gate ddi_map_fault(dev_info_t *dip, struct hat *hat, struct seg *seg, caddr_t addr,
6457c478bd9Sstevel@tonic-gate 	struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
6467c478bd9Sstevel@tonic-gate 
6477c478bd9Sstevel@tonic-gate int
6487c478bd9Sstevel@tonic-gate ddi_device_mapping_check(dev_t dev, ddi_device_acc_attr_t *accattrp,
6497c478bd9Sstevel@tonic-gate 	uint_t rnumber, uint_t *hat_flags);
6507c478bd9Sstevel@tonic-gate 
6517c478bd9Sstevel@tonic-gate /*
6527c478bd9Sstevel@tonic-gate  * Property functions:   See also, ddipropdefs.h.
6537c478bd9Sstevel@tonic-gate  *			In general, the underlying driver MUST be held
6547c478bd9Sstevel@tonic-gate  *			to call it's property functions.
6557c478bd9Sstevel@tonic-gate  */
6567c478bd9Sstevel@tonic-gate 
6577c478bd9Sstevel@tonic-gate /*
6587c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup integer properties
6597c478bd9Sstevel@tonic-gate  */
6607c478bd9Sstevel@tonic-gate int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags,
6617c478bd9Sstevel@tonic-gate     char *name, int defvalue);
6627c478bd9Sstevel@tonic-gate int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags,
6637c478bd9Sstevel@tonic-gate     char *name, int64_t defvalue);
6647c478bd9Sstevel@tonic-gate int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
6657c478bd9Sstevel@tonic-gate     char *name, int **data, uint_t *nelements);
6667c478bd9Sstevel@tonic-gate int ddi_prop_lookup_int64_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
6677c478bd9Sstevel@tonic-gate     char *name, int64_t **data, uint_t *nelements);
6687c478bd9Sstevel@tonic-gate int ddi_prop_update_int(dev_t match_dev, dev_info_t *dip,
6697c478bd9Sstevel@tonic-gate     char *name, int data);
6707c478bd9Sstevel@tonic-gate int ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip,
6717c478bd9Sstevel@tonic-gate     char *name, int64_t data);
6727c478bd9Sstevel@tonic-gate int ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip,
6737c478bd9Sstevel@tonic-gate     char *name, int *data, uint_t nelements);
6747c478bd9Sstevel@tonic-gate int ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip,
6757c478bd9Sstevel@tonic-gate     char *name, int64_t *data, uint_t nelements);
6767c478bd9Sstevel@tonic-gate /*
6777c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup string properties
6787c478bd9Sstevel@tonic-gate  */
6797c478bd9Sstevel@tonic-gate int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, uint_t flags,
6807c478bd9Sstevel@tonic-gate     char *name, char **data);
6817c478bd9Sstevel@tonic-gate int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
6827c478bd9Sstevel@tonic-gate     char *name, char ***data, uint_t *nelements);
6837c478bd9Sstevel@tonic-gate int ddi_prop_update_string(dev_t match_dev, dev_info_t *dip,
6847c478bd9Sstevel@tonic-gate     char *name, char *data);
6857c478bd9Sstevel@tonic-gate int ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
6867c478bd9Sstevel@tonic-gate     char *name, char **data, uint_t nelements);
6877c478bd9Sstevel@tonic-gate 
6887c478bd9Sstevel@tonic-gate /*
6897c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup byte properties
6907c478bd9Sstevel@tonic-gate  */
6917c478bd9Sstevel@tonic-gate int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
6927c478bd9Sstevel@tonic-gate     char *name, uchar_t **data, uint_t *nelements);
6937c478bd9Sstevel@tonic-gate int ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
6947c478bd9Sstevel@tonic-gate     char *name, uchar_t *data, uint_t nelements);
6957c478bd9Sstevel@tonic-gate 
6967c478bd9Sstevel@tonic-gate /*
6977c478bd9Sstevel@tonic-gate  * Used to verify the existence of a property or to see if a boolean
6987c478bd9Sstevel@tonic-gate  * property exists.
6997c478bd9Sstevel@tonic-gate  */
7007c478bd9Sstevel@tonic-gate int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name);
7017c478bd9Sstevel@tonic-gate 
7027c478bd9Sstevel@tonic-gate /*
7037c478bd9Sstevel@tonic-gate  * Used to free the data returned by the above property routines.
7047c478bd9Sstevel@tonic-gate  */
7057c478bd9Sstevel@tonic-gate void ddi_prop_free(void *data);
7067c478bd9Sstevel@tonic-gate 
7077c478bd9Sstevel@tonic-gate /*
7087c478bd9Sstevel@tonic-gate  * nopropop: For internal use in `dummy' cb_prop_op functions only
7097c478bd9Sstevel@tonic-gate  */
7107c478bd9Sstevel@tonic-gate 
7117c478bd9Sstevel@tonic-gate int
7127c478bd9Sstevel@tonic-gate nopropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
7137c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7147c478bd9Sstevel@tonic-gate 
7157c478bd9Sstevel@tonic-gate /*
7167c478bd9Sstevel@tonic-gate  * ddi_prop_op: The basic property operator for drivers.
7177c478bd9Sstevel@tonic-gate  *
7187c478bd9Sstevel@tonic-gate  * In ddi_prop_op, the type of valuep is interpreted based on prop_op:
7197c478bd9Sstevel@tonic-gate  *
7207c478bd9Sstevel@tonic-gate  *	prop_op			valuep
7217c478bd9Sstevel@tonic-gate  *	------			------
7227c478bd9Sstevel@tonic-gate  *
7237c478bd9Sstevel@tonic-gate  *	PROP_LEN		<unused>
7247c478bd9Sstevel@tonic-gate  *
7257c478bd9Sstevel@tonic-gate  *	PROP_LEN_AND_VAL_BUF	Pointer to callers buffer
7267c478bd9Sstevel@tonic-gate  *
7277c478bd9Sstevel@tonic-gate  *	PROP_LEN_AND_VAL_ALLOC	Address of callers pointer (will be set to
7287c478bd9Sstevel@tonic-gate  *				address of allocated buffer, if successful)
7297c478bd9Sstevel@tonic-gate  */
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate int
7327c478bd9Sstevel@tonic-gate ddi_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
7337c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7347c478bd9Sstevel@tonic-gate 
7357c478bd9Sstevel@tonic-gate /* ddi_prop_op_size: for drivers that implement size in bytes */
7367c478bd9Sstevel@tonic-gate int
7377c478bd9Sstevel@tonic-gate ddi_prop_op_size(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
7387c478bd9Sstevel@tonic-gate 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
7397c478bd9Sstevel@tonic-gate 	uint64_t size64);
7407c478bd9Sstevel@tonic-gate 
7417c478bd9Sstevel@tonic-gate /* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */
7427c478bd9Sstevel@tonic-gate int
7437c478bd9Sstevel@tonic-gate ddi_prop_op_nblocks(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
7447c478bd9Sstevel@tonic-gate 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
7457c478bd9Sstevel@tonic-gate 	uint64_t nblocks64);
7467c478bd9Sstevel@tonic-gate 
7477c478bd9Sstevel@tonic-gate /*
7487c478bd9Sstevel@tonic-gate  * Variable length props...
7497c478bd9Sstevel@tonic-gate  */
7507c478bd9Sstevel@tonic-gate 
7517c478bd9Sstevel@tonic-gate /*
7527c478bd9Sstevel@tonic-gate  * ddi_getlongprop:	Get variable length property len+val into a buffer
7537c478bd9Sstevel@tonic-gate  *		allocated by property provider via kmem_alloc. Requester
7547c478bd9Sstevel@tonic-gate  *		is responsible for freeing returned property via kmem_free.
7557c478bd9Sstevel@tonic-gate  *
7567c478bd9Sstevel@tonic-gate  * 	Arguments:
7577c478bd9Sstevel@tonic-gate  *
7587c478bd9Sstevel@tonic-gate  *	dev:	Input:	dev_t of property.
7597c478bd9Sstevel@tonic-gate  *	dip:	Input:	dev_info_t pointer of child.
7607c478bd9Sstevel@tonic-gate  *	flags:	Input:	Possible flag modifiers are:
7617c478bd9Sstevel@tonic-gate  *		DDI_PROP_DONTPASS:	Don't pass to parent if prop not found.
7627c478bd9Sstevel@tonic-gate  *		DDI_PROP_CANSLEEP:	Memory allocation may sleep.
7637c478bd9Sstevel@tonic-gate  *	name:	Input:	name of property.
7647c478bd9Sstevel@tonic-gate  *	valuep:	Output:	Addr of callers buffer pointer.
7657c478bd9Sstevel@tonic-gate  *	lengthp:Output:	*lengthp will contain prop length on exit.
7667c478bd9Sstevel@tonic-gate  *
7677c478bd9Sstevel@tonic-gate  * 	Possible Returns:
7687c478bd9Sstevel@tonic-gate  *
7697c478bd9Sstevel@tonic-gate  *		DDI_PROP_SUCCESS:	Prop found and returned.
7707c478bd9Sstevel@tonic-gate  *		DDI_PROP_NOT_FOUND:	Prop not found
7717c478bd9Sstevel@tonic-gate  *		DDI_PROP_UNDEFINED:	Prop explicitly undefined.
7727c478bd9Sstevel@tonic-gate  *		DDI_PROP_NO_MEMORY:	Prop found, but unable to alloc mem.
7737c478bd9Sstevel@tonic-gate  */
7747c478bd9Sstevel@tonic-gate 
7757c478bd9Sstevel@tonic-gate int
7767c478bd9Sstevel@tonic-gate ddi_getlongprop(dev_t dev, dev_info_t *dip, int flags,
7777c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7787c478bd9Sstevel@tonic-gate 
7797c478bd9Sstevel@tonic-gate /*
7807c478bd9Sstevel@tonic-gate  *
7817c478bd9Sstevel@tonic-gate  * ddi_getlongprop_buf:		Get long prop into pre-allocated callers
7827c478bd9Sstevel@tonic-gate  *				buffer. (no memory allocation by provider).
7837c478bd9Sstevel@tonic-gate  *
7847c478bd9Sstevel@tonic-gate  *	dev:	Input:	dev_t of property.
7857c478bd9Sstevel@tonic-gate  *	dip:	Input:	dev_info_t pointer of child.
7867c478bd9Sstevel@tonic-gate  *	flags:	Input:	DDI_PROP_DONTPASS or NULL
7877c478bd9Sstevel@tonic-gate  *	name:	Input:	name of property
7887c478bd9Sstevel@tonic-gate  *	valuep:	Input:	ptr to callers buffer.
7897c478bd9Sstevel@tonic-gate  *	lengthp:I/O:	ptr to length of callers buffer on entry,
7907c478bd9Sstevel@tonic-gate  *			actual length of property on exit.
7917c478bd9Sstevel@tonic-gate  *
7927c478bd9Sstevel@tonic-gate  *	Possible returns:
7937c478bd9Sstevel@tonic-gate  *
7947c478bd9Sstevel@tonic-gate  *		DDI_PROP_SUCCESS	Prop found and returned
7957c478bd9Sstevel@tonic-gate  *		DDI_PROP_NOT_FOUND	Prop not found
7967c478bd9Sstevel@tonic-gate  *		DDI_PROP_UNDEFINED	Prop explicitly undefined.
7977c478bd9Sstevel@tonic-gate  *		DDI_PROP_BUF_TOO_SMALL	Prop found, callers buf too small,
7987c478bd9Sstevel@tonic-gate  *					no value returned, but actual prop
7997c478bd9Sstevel@tonic-gate  *					length returned in *lengthp
8007c478bd9Sstevel@tonic-gate  *
8017c478bd9Sstevel@tonic-gate  */
8027c478bd9Sstevel@tonic-gate 
8037c478bd9Sstevel@tonic-gate int
8047c478bd9Sstevel@tonic-gate ddi_getlongprop_buf(dev_t dev, dev_info_t *dip, int flags,
8057c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
8067c478bd9Sstevel@tonic-gate 
8077c478bd9Sstevel@tonic-gate /*
8087c478bd9Sstevel@tonic-gate  * Integer/boolean sized props.
8097c478bd9Sstevel@tonic-gate  *
8107c478bd9Sstevel@tonic-gate  * Call is value only... returns found boolean or int sized prop value or
8117c478bd9Sstevel@tonic-gate  * defvalue if prop not found or is wrong length or is explicitly undefined.
8127c478bd9Sstevel@tonic-gate  * Only flag is DDI_PROP_DONTPASS...
8137c478bd9Sstevel@tonic-gate  *
8147c478bd9Sstevel@tonic-gate  * By convention, this interface returns boolean (0) sized properties
8157c478bd9Sstevel@tonic-gate  * as value (int)1.
8167c478bd9Sstevel@tonic-gate  */
8177c478bd9Sstevel@tonic-gate 
8187c478bd9Sstevel@tonic-gate int
8197c478bd9Sstevel@tonic-gate ddi_getprop(dev_t dev, dev_info_t *dip, int flags, char *name, int defvalue);
8207c478bd9Sstevel@tonic-gate 
8217c478bd9Sstevel@tonic-gate /*
8227c478bd9Sstevel@tonic-gate  * Get prop length interface: flags are 0 or DDI_PROP_DONTPASS
8237c478bd9Sstevel@tonic-gate  * if returns DDI_PROP_SUCCESS, length returned in *lengthp.
8247c478bd9Sstevel@tonic-gate  */
8257c478bd9Sstevel@tonic-gate 
8267c478bd9Sstevel@tonic-gate int
8277c478bd9Sstevel@tonic-gate ddi_getproplen(dev_t dev, dev_info_t *dip, int flags, char *name, int *lengthp);
8287c478bd9Sstevel@tonic-gate 
8297c478bd9Sstevel@tonic-gate 
8307c478bd9Sstevel@tonic-gate /*
8317c478bd9Sstevel@tonic-gate  * Interface to create/modify a managed property on child's behalf...
8327c478bd9Sstevel@tonic-gate  * Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep
8337c478bd9Sstevel@tonic-gate  * if no memory available for internal prop structure.  Long property
8347c478bd9Sstevel@tonic-gate  * (non integer sized) value references are not copied.
8357c478bd9Sstevel@tonic-gate  *
8367c478bd9Sstevel@tonic-gate  * Define property with DDI_DEV_T_NONE dev_t for properties not associated
8377c478bd9Sstevel@tonic-gate  * with any particular dev_t. Use the same dev_t when modifying or undefining
8387c478bd9Sstevel@tonic-gate  * a property.
8397c478bd9Sstevel@tonic-gate  *
8407c478bd9Sstevel@tonic-gate  * No guarantee on order of property search, so don't mix the same
8417c478bd9Sstevel@tonic-gate  * property name with wildcard and non-wildcard dev_t's.
8427c478bd9Sstevel@tonic-gate  */
8437c478bd9Sstevel@tonic-gate 
8447c478bd9Sstevel@tonic-gate /*
8457c478bd9Sstevel@tonic-gate  * ddi_prop_create:	Define a managed property:
8467c478bd9Sstevel@tonic-gate  */
8477c478bd9Sstevel@tonic-gate 
8487c478bd9Sstevel@tonic-gate int
8497c478bd9Sstevel@tonic-gate ddi_prop_create(dev_t dev, dev_info_t *dip, int flag,
8507c478bd9Sstevel@tonic-gate 	char *name, caddr_t value, int length);
8517c478bd9Sstevel@tonic-gate 
8527c478bd9Sstevel@tonic-gate /*
8537c478bd9Sstevel@tonic-gate  * ddi_prop_modify:	Modify a managed property value
8547c478bd9Sstevel@tonic-gate  */
8557c478bd9Sstevel@tonic-gate 
8567c478bd9Sstevel@tonic-gate int
8577c478bd9Sstevel@tonic-gate ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag,
8587c478bd9Sstevel@tonic-gate 	char *name, caddr_t value, int length);
8597c478bd9Sstevel@tonic-gate 
8607c478bd9Sstevel@tonic-gate /*
8617c478bd9Sstevel@tonic-gate  * ddi_prop_remove:	Undefine a managed property:
8627c478bd9Sstevel@tonic-gate  */
8637c478bd9Sstevel@tonic-gate 
8647c478bd9Sstevel@tonic-gate int
8657c478bd9Sstevel@tonic-gate ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
8667c478bd9Sstevel@tonic-gate 
8677c478bd9Sstevel@tonic-gate /*
8687c478bd9Sstevel@tonic-gate  * ddi_prop_remove_all:		Used before unloading a driver to remove
8697c478bd9Sstevel@tonic-gate  *				all properties. (undefines all dev_t's props.)
8707c478bd9Sstevel@tonic-gate  *				Also removes `undefined' prop defs.
8717c478bd9Sstevel@tonic-gate  */
8727c478bd9Sstevel@tonic-gate 
8737c478bd9Sstevel@tonic-gate void
8747c478bd9Sstevel@tonic-gate ddi_prop_remove_all(dev_info_t *dip);
8757c478bd9Sstevel@tonic-gate 
8767c478bd9Sstevel@tonic-gate 
8777c478bd9Sstevel@tonic-gate /*
8787c478bd9Sstevel@tonic-gate  * ddi_prop_undefine:	Explicitly undefine a property.  Property
8797c478bd9Sstevel@tonic-gate  *			searches which match this property return
8807c478bd9Sstevel@tonic-gate  *			the error code DDI_PROP_UNDEFINED.
8817c478bd9Sstevel@tonic-gate  *
8827c478bd9Sstevel@tonic-gate  *			Use ddi_prop_remove to negate effect of
8837c478bd9Sstevel@tonic-gate  *			ddi_prop_undefine
8847c478bd9Sstevel@tonic-gate  */
8857c478bd9Sstevel@tonic-gate 
8867c478bd9Sstevel@tonic-gate int
8877c478bd9Sstevel@tonic-gate ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name);
8887c478bd9Sstevel@tonic-gate 
8897c478bd9Sstevel@tonic-gate 
8907c478bd9Sstevel@tonic-gate /*
8917c478bd9Sstevel@tonic-gate  * The default ddi_bus_prop_op wrapper...
8927c478bd9Sstevel@tonic-gate  */
8937c478bd9Sstevel@tonic-gate 
8947c478bd9Sstevel@tonic-gate int
8957c478bd9Sstevel@tonic-gate ddi_bus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip,
8967c478bd9Sstevel@tonic-gate 	ddi_prop_op_t prop_op, int mod_flags,
8977c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
8987c478bd9Sstevel@tonic-gate 
8997c478bd9Sstevel@tonic-gate 
9007c478bd9Sstevel@tonic-gate /*
9017c478bd9Sstevel@tonic-gate  * Routines to traverse the tree of dev_info nodes.
9027c478bd9Sstevel@tonic-gate  * The general idea of these functions is to provide
9037c478bd9Sstevel@tonic-gate  * various tree traversal utilities. For each node
9047c478bd9Sstevel@tonic-gate  * that the tree traversal function finds, a caller
9057c478bd9Sstevel@tonic-gate  * supplied function is called with arguments of
9067c478bd9Sstevel@tonic-gate  * the current node and a caller supplied argument.
9077c478bd9Sstevel@tonic-gate  * The caller supplied function should return one
9087c478bd9Sstevel@tonic-gate  * of the integer values defined below which will
9097c478bd9Sstevel@tonic-gate  * indicate to the tree traversal function whether
9107c478bd9Sstevel@tonic-gate  * the traversal should be continued, and if so, how,
9117c478bd9Sstevel@tonic-gate  * or whether the traversal should terminate.
9127c478bd9Sstevel@tonic-gate  */
9137c478bd9Sstevel@tonic-gate 
9147c478bd9Sstevel@tonic-gate /*
9157c478bd9Sstevel@tonic-gate  * This general-purpose routine traverses the tree of dev_info nodes,
9167c478bd9Sstevel@tonic-gate  * starting from the given node, and calls the given function for each
9177c478bd9Sstevel@tonic-gate  * node that it finds with the current node and the pointer arg (which
9187c478bd9Sstevel@tonic-gate  * can point to a structure of information that the function
9197c478bd9Sstevel@tonic-gate  * needs) as arguments.
9207c478bd9Sstevel@tonic-gate  *
9217c478bd9Sstevel@tonic-gate  * It does the walk a layer at a time, not depth-first.
9227c478bd9Sstevel@tonic-gate  *
9237c478bd9Sstevel@tonic-gate  * The given function must return one of the values defined above.
9247c478bd9Sstevel@tonic-gate  *
9257c478bd9Sstevel@tonic-gate  */
9267c478bd9Sstevel@tonic-gate 
9277c478bd9Sstevel@tonic-gate void
9287c478bd9Sstevel@tonic-gate ddi_walk_devs(dev_info_t *, int (*)(dev_info_t *, void *), void *);
9297c478bd9Sstevel@tonic-gate 
9307c478bd9Sstevel@tonic-gate /*
9317c478bd9Sstevel@tonic-gate  * Routines to get at elements of the dev_info structure
9327c478bd9Sstevel@tonic-gate  */
9337c478bd9Sstevel@tonic-gate 
9347c478bd9Sstevel@tonic-gate /*
9357c478bd9Sstevel@tonic-gate  * ddi_node_name gets the device's 'name' from the device node.
9367c478bd9Sstevel@tonic-gate  *
9377c478bd9Sstevel@tonic-gate  * ddi_binding_name gets the string the OS used to bind the node to a driver,
9387c478bd9Sstevel@tonic-gate  * in certain cases, the binding name may be different from the node name,
9397c478bd9Sstevel@tonic-gate  * if the node name does not name a specific device driver.
9407c478bd9Sstevel@tonic-gate  *
9417c478bd9Sstevel@tonic-gate  * ddi_get_name is a synonym for ddi_binding_name().
9427c478bd9Sstevel@tonic-gate  */
9437c478bd9Sstevel@tonic-gate char *
9447c478bd9Sstevel@tonic-gate ddi_get_name(dev_info_t *dip);
9457c478bd9Sstevel@tonic-gate 
9467c478bd9Sstevel@tonic-gate char *
9477c478bd9Sstevel@tonic-gate ddi_binding_name(dev_info_t *dip);
9487c478bd9Sstevel@tonic-gate 
9497c478bd9Sstevel@tonic-gate const char *
9507c478bd9Sstevel@tonic-gate ddi_driver_name(dev_info_t *dip);
9517c478bd9Sstevel@tonic-gate 
9527c478bd9Sstevel@tonic-gate major_t
9537c478bd9Sstevel@tonic-gate ddi_driver_major(dev_info_t *dip);
9547c478bd9Sstevel@tonic-gate 
9557c478bd9Sstevel@tonic-gate major_t
9567c478bd9Sstevel@tonic-gate ddi_compatible_driver_major(dev_info_t *dip, char **formp);
9577c478bd9Sstevel@tonic-gate 
9587c478bd9Sstevel@tonic-gate char *
9597c478bd9Sstevel@tonic-gate ddi_node_name(dev_info_t *dip);
9607c478bd9Sstevel@tonic-gate 
9617c478bd9Sstevel@tonic-gate int
9627c478bd9Sstevel@tonic-gate ddi_get_nodeid(dev_info_t *dip);
9637c478bd9Sstevel@tonic-gate 
9647c478bd9Sstevel@tonic-gate int
9657c478bd9Sstevel@tonic-gate ddi_get_instance(dev_info_t *dip);
9667c478bd9Sstevel@tonic-gate 
9677c478bd9Sstevel@tonic-gate struct dev_ops *
9687c478bd9Sstevel@tonic-gate ddi_get_driver(dev_info_t *dip);
9697c478bd9Sstevel@tonic-gate 
9707c478bd9Sstevel@tonic-gate void
9717c478bd9Sstevel@tonic-gate ddi_set_driver(dev_info_t *dip, struct dev_ops *devo);
9727c478bd9Sstevel@tonic-gate 
9737c478bd9Sstevel@tonic-gate void
9747c478bd9Sstevel@tonic-gate ddi_set_driver_private(dev_info_t *dip, void *data);
9757c478bd9Sstevel@tonic-gate 
9767c478bd9Sstevel@tonic-gate void *
9777c478bd9Sstevel@tonic-gate ddi_get_driver_private(dev_info_t *dip);
9787c478bd9Sstevel@tonic-gate 
9797c478bd9Sstevel@tonic-gate /*
9807c478bd9Sstevel@tonic-gate  * ddi_dev_is_needed tells system that a device is about to use a
9817c478bd9Sstevel@tonic-gate  * component. Returns when component is ready.
9827c478bd9Sstevel@tonic-gate  */
9837c478bd9Sstevel@tonic-gate int
9847c478bd9Sstevel@tonic-gate ddi_dev_is_needed(dev_info_t *dip, int cmpt, int level);
9857c478bd9Sstevel@tonic-gate 
9867c478bd9Sstevel@tonic-gate /*
9877c478bd9Sstevel@tonic-gate  * check if DDI_SUSPEND may result in power being removed from a device.
9887c478bd9Sstevel@tonic-gate  */
9897c478bd9Sstevel@tonic-gate int
9907c478bd9Sstevel@tonic-gate ddi_removing_power(dev_info_t *dip);
9917c478bd9Sstevel@tonic-gate 
9927c478bd9Sstevel@tonic-gate /*
9937c478bd9Sstevel@tonic-gate  *  (Obsolete) power entry point
9947c478bd9Sstevel@tonic-gate  */
9957c478bd9Sstevel@tonic-gate int
9967c478bd9Sstevel@tonic-gate ddi_power(dev_info_t *dip, int cmpt, int level);
9977c478bd9Sstevel@tonic-gate 
9987c478bd9Sstevel@tonic-gate /*
9997c478bd9Sstevel@tonic-gate  * ddi_get_parent requires that the branch of the tree with the
10007c478bd9Sstevel@tonic-gate  * node be held (ddi_hold_installed_driver) or that the devinfo tree
10017c478bd9Sstevel@tonic-gate  * lock be held
10027c478bd9Sstevel@tonic-gate  */
10037c478bd9Sstevel@tonic-gate dev_info_t *
10047c478bd9Sstevel@tonic-gate ddi_get_parent(dev_info_t *dip);
10057c478bd9Sstevel@tonic-gate 
10067c478bd9Sstevel@tonic-gate /*
10077c478bd9Sstevel@tonic-gate  * ddi_get_child and ddi_get_next_sibling require that the devinfo
10087c478bd9Sstevel@tonic-gate  * tree lock be held
10097c478bd9Sstevel@tonic-gate  */
10107c478bd9Sstevel@tonic-gate dev_info_t *
10117c478bd9Sstevel@tonic-gate ddi_get_child(dev_info_t *dip);
10127c478bd9Sstevel@tonic-gate 
10137c478bd9Sstevel@tonic-gate dev_info_t *
10147c478bd9Sstevel@tonic-gate ddi_get_next_sibling(dev_info_t *dip);
10157c478bd9Sstevel@tonic-gate 
10167c478bd9Sstevel@tonic-gate dev_info_t *
10177c478bd9Sstevel@tonic-gate ddi_get_next(dev_info_t *dip);
10187c478bd9Sstevel@tonic-gate 
10197c478bd9Sstevel@tonic-gate void
10207c478bd9Sstevel@tonic-gate ddi_set_next(dev_info_t *dip, dev_info_t *nextdip);
10217c478bd9Sstevel@tonic-gate 
10227c478bd9Sstevel@tonic-gate /*
10237c478bd9Sstevel@tonic-gate  * dev_info manipulation functions
10247c478bd9Sstevel@tonic-gate  */
10257c478bd9Sstevel@tonic-gate 
10267c478bd9Sstevel@tonic-gate /*
10277c478bd9Sstevel@tonic-gate  * Add and remove child devices. These are part of the system framework.
10287c478bd9Sstevel@tonic-gate  *
10297c478bd9Sstevel@tonic-gate  * ddi_add_child creates a dev_info structure with the passed name,
10307c478bd9Sstevel@tonic-gate  * nodeid and instance arguments and makes it a child of pdip. Devices
10317c478bd9Sstevel@tonic-gate  * that are known directly by the hardware have real nodeids; devices
10327c478bd9Sstevel@tonic-gate  * that are software constructs use the defined DEVI_PSEUDO_NODEID
10337c478bd9Sstevel@tonic-gate  * for the node id.
10347c478bd9Sstevel@tonic-gate  *
10357c478bd9Sstevel@tonic-gate  * ddi_remove_node removes the node from the tree. This fails if this
10367c478bd9Sstevel@tonic-gate  * child has children. Parent and driver private data should already
10377c478bd9Sstevel@tonic-gate  * be released (freed) prior to calling this function.  If flag is
10387c478bd9Sstevel@tonic-gate  * non-zero, the child is removed from it's linked list of instances.
10397c478bd9Sstevel@tonic-gate  */
10407c478bd9Sstevel@tonic-gate dev_info_t *
10417c478bd9Sstevel@tonic-gate ddi_add_child(dev_info_t *pdip, char *name, uint_t nodeid, uint_t instance);
10427c478bd9Sstevel@tonic-gate 
10437c478bd9Sstevel@tonic-gate int
10447c478bd9Sstevel@tonic-gate ddi_remove_child(dev_info_t *dip, int flag);
10457c478bd9Sstevel@tonic-gate 
10467c478bd9Sstevel@tonic-gate /*
10477c478bd9Sstevel@tonic-gate  * Given the major number for a driver, make sure that dev_info nodes
10487c478bd9Sstevel@tonic-gate  * are created form the driver's hwconf file, the driver for the named
10497c478bd9Sstevel@tonic-gate  * device is loaded and attached, as well as any drivers for parent devices.
10507c478bd9Sstevel@tonic-gate  * Return a pointer to the driver's dev_ops struct with the dev_ops held.
10517c478bd9Sstevel@tonic-gate  * Note - Callers must release the dev_ops with ddi_rele_driver.
10527c478bd9Sstevel@tonic-gate  *
10537c478bd9Sstevel@tonic-gate  * When a driver is held, the branch of the devinfo tree from any of the
10547c478bd9Sstevel@tonic-gate  * drivers devinfos to the root node are automatically held.  This only
10557c478bd9Sstevel@tonic-gate  * applies to tree traversals up (and back down) the tree following the
10567c478bd9Sstevel@tonic-gate  * parent pointers.
10577c478bd9Sstevel@tonic-gate  *
10587c478bd9Sstevel@tonic-gate  * Use of this interface is discouraged, it may be removed in a future release.
10597c478bd9Sstevel@tonic-gate  */
10607c478bd9Sstevel@tonic-gate struct dev_ops *
10617c478bd9Sstevel@tonic-gate ddi_hold_installed_driver(major_t major);
10627c478bd9Sstevel@tonic-gate 
10637c478bd9Sstevel@tonic-gate void
10647c478bd9Sstevel@tonic-gate ddi_rele_driver(major_t major);
10657c478bd9Sstevel@tonic-gate 
10667c478bd9Sstevel@tonic-gate /*
10677c478bd9Sstevel@tonic-gate  * Attach and hold the specified instance of a driver.  The flags argument
10687c478bd9Sstevel@tonic-gate  * should be zero.
10697c478bd9Sstevel@tonic-gate  */
10707c478bd9Sstevel@tonic-gate dev_info_t *
10717c478bd9Sstevel@tonic-gate ddi_hold_devi_by_instance(major_t major, int instance, int flags);
10727c478bd9Sstevel@tonic-gate 
10737c478bd9Sstevel@tonic-gate void
10747c478bd9Sstevel@tonic-gate ddi_release_devi(dev_info_t *);
10757c478bd9Sstevel@tonic-gate 
10767c478bd9Sstevel@tonic-gate /*
10777c478bd9Sstevel@tonic-gate  * Associate a streams queue with a devinfo node
10787c478bd9Sstevel@tonic-gate  */
10797c478bd9Sstevel@tonic-gate void
10807c478bd9Sstevel@tonic-gate ddi_assoc_queue_with_devi(queue_t *, dev_info_t *);
10817c478bd9Sstevel@tonic-gate 
10827c478bd9Sstevel@tonic-gate /*
10837c478bd9Sstevel@tonic-gate  * Given the identifier string passed, make sure that dev_info nodes
10847c478bd9Sstevel@tonic-gate  * are created form the driver's hwconf file, the driver for the named
10857c478bd9Sstevel@tonic-gate  * device is loaded and attached, as well as any drivers for parent devices.
10867c478bd9Sstevel@tonic-gate  *
10877c478bd9Sstevel@tonic-gate  * Note that the driver is not held and is subject to being removed the instant
10887c478bd9Sstevel@tonic-gate  * this call completes.  You probably really want ddi_hold_installed_driver.
10897c478bd9Sstevel@tonic-gate  */
10907c478bd9Sstevel@tonic-gate int
10917c478bd9Sstevel@tonic-gate ddi_install_driver(char *idstring);
10927c478bd9Sstevel@tonic-gate 
10937c478bd9Sstevel@tonic-gate /*
10947c478bd9Sstevel@tonic-gate  * Routines that return specific nodes
10957c478bd9Sstevel@tonic-gate  */
10967c478bd9Sstevel@tonic-gate 
10977c478bd9Sstevel@tonic-gate dev_info_t *
10987c478bd9Sstevel@tonic-gate ddi_root_node(void);
10997c478bd9Sstevel@tonic-gate 
11007c478bd9Sstevel@tonic-gate /*
11017c478bd9Sstevel@tonic-gate  * Given a name and an instance number, find and return the
11027c478bd9Sstevel@tonic-gate  * dev_info from the current state of the device tree.
11037c478bd9Sstevel@tonic-gate  *
11047c478bd9Sstevel@tonic-gate  * If instance number is -1, return the first named instance.
11057c478bd9Sstevel@tonic-gate  *
11067c478bd9Sstevel@tonic-gate  * If attached is 1, exclude all nodes that are < DS_ATTACHED
11077c478bd9Sstevel@tonic-gate  *
11087c478bd9Sstevel@tonic-gate  * Requires that the devinfo tree be locked.
11097c478bd9Sstevel@tonic-gate  * If attached is 1, the driver must be held.
11107c478bd9Sstevel@tonic-gate  */
11117c478bd9Sstevel@tonic-gate dev_info_t *
11127c478bd9Sstevel@tonic-gate ddi_find_devinfo(char *name, int instance, int attached);
11137c478bd9Sstevel@tonic-gate 
11147c478bd9Sstevel@tonic-gate /*
11157c478bd9Sstevel@tonic-gate  * DMA Mapping Setup
11167c478bd9Sstevel@tonic-gate  *
11177c478bd9Sstevel@tonic-gate  * The basic interface function is ddi_dma_setup(). This function
11187c478bd9Sstevel@tonic-gate  * is to designed to allow a DMA mapping to be established to a
11197c478bd9Sstevel@tonic-gate  * memory object. This function returns DDI_DMA_MAPPED if the
11207c478bd9Sstevel@tonic-gate  * request was successfully filled. If this occurs, then the
11217c478bd9Sstevel@tonic-gate  * argument handlep is filled in. This value is the DMA handle
11227c478bd9Sstevel@tonic-gate  * for the mapping, and is used in a variety of other functions.
11237c478bd9Sstevel@tonic-gate  * The handle is an opaque handle on the mapping, and no further
11247c478bd9Sstevel@tonic-gate  * information may be inferred from it by the caller.
11257c478bd9Sstevel@tonic-gate  *
11267c478bd9Sstevel@tonic-gate  * Specifics of arguments to ddi_dma_setup:
11277c478bd9Sstevel@tonic-gate  *
11287c478bd9Sstevel@tonic-gate  * dip - devinfo pointer, which identifies the base device that wishes
11297c478bd9Sstevel@tonic-gate  * to establish a dma mapping. The device may either be a leaf device,
11307c478bd9Sstevel@tonic-gate  * or a device which is both a leaf and a nexus (e.g., a device which
11317c478bd9Sstevel@tonic-gate  * has a dma engine but no children devices).
11327c478bd9Sstevel@tonic-gate  *
11337c478bd9Sstevel@tonic-gate  * dmareqp - pointer to a dma request structure. This structure contains
11347c478bd9Sstevel@tonic-gate  * all the info necessary to establish the mapping (see <sys/ddidmareq.h>).
11357c478bd9Sstevel@tonic-gate  * This structure may be impermanent, as its information is copied and
11367c478bd9Sstevel@tonic-gate  * saved, if necessary, by implementation specific functions. The caller
11377c478bd9Sstevel@tonic-gate  * is responsible for filling in the dmar_flags, dmar_length, dmar_type,
11387c478bd9Sstevel@tonic-gate  * dmar_addr_un, dmar_fp and dmar_arg fields. Any other elements of the
11397c478bd9Sstevel@tonic-gate  * ddi_dma_req structure should neither be examined or modified by the
11407c478bd9Sstevel@tonic-gate  * caller.
11417c478bd9Sstevel@tonic-gate  *
11427c478bd9Sstevel@tonic-gate  * handlep - this is a pointer to a ddi_dma_handle_t. It is the callers
11437c478bd9Sstevel@tonic-gate  * responsibility to hang on to this handle, because it becomes the token
11447c478bd9Sstevel@tonic-gate  * used in all other DDI dma functions. If the handle pointer is NULL,
11457c478bd9Sstevel@tonic-gate  * then no mapping is made, and the call is being used by the caller
11467c478bd9Sstevel@tonic-gate  * to simply determine whether such a mapping *could* be made.
11477c478bd9Sstevel@tonic-gate  *
11487c478bd9Sstevel@tonic-gate  * Discussion of DMA resource callback functions:
11497c478bd9Sstevel@tonic-gate  *
11507c478bd9Sstevel@tonic-gate  * If a request could not be filled, it was because either there were
11517c478bd9Sstevel@tonic-gate  * not enough mapping resources available to satisfy the request, and the
11527c478bd9Sstevel@tonic-gate  * dmar_fp field was not set to DDI_DMA_SLEEP, or the mapping could not
11537c478bd9Sstevel@tonic-gate  * be established at all (DDI_DMA_NOMAPPING) due to a basic inability of
11547c478bd9Sstevel@tonic-gate  * available hardware to map the object. Callers should be prepared to deal
11557c478bd9Sstevel@tonic-gate  * with all possible returns. It is suggested that the appropriate system
11567c478bd9Sstevel@tonic-gate  * error number for the DDI_DMA_NOMAPPING returns is EFAULT.
11577c478bd9Sstevel@tonic-gate  *
11587c478bd9Sstevel@tonic-gate  * If the caller does not care whether a DMA mapping can be set up now,
11597c478bd9Sstevel@tonic-gate  * the caller should set the field dmar_fp to DDI_DMA_DONTWAIT. This
11607c478bd9Sstevel@tonic-gate  * implies that the caller will appropriately deal with resource
11617c478bd9Sstevel@tonic-gate  * exhaustion.
11627c478bd9Sstevel@tonic-gate  *
11637c478bd9Sstevel@tonic-gate  * If the caller either cannot or does not wish to sleep awaiting mapping
11647c478bd9Sstevel@tonic-gate  * resources, the caller may specify, via the field dmar_fp, a function to
11657c478bd9Sstevel@tonic-gate  * call with the argument specified in dmar_arg, when resources might have
11667c478bd9Sstevel@tonic-gate  * become available. The callback function will be called from interrupt
11677c478bd9Sstevel@tonic-gate  * context, but in such a fashion to guarantee that spl blocking (in systems
11687c478bd9Sstevel@tonic-gate  * that use this method of data protection) by the caller will not be
11697c478bd9Sstevel@tonic-gate  * bypassed.
11707c478bd9Sstevel@tonic-gate  *
11717c478bd9Sstevel@tonic-gate  *
11727c478bd9Sstevel@tonic-gate  * When function specified via dmar_fp is called, it may attempt to try and get
11737c478bd9Sstevel@tonic-gate  * the mapping again. If it succeeds in getting the mapping, or does not need
11747c478bd9Sstevel@tonic-gate  * to get the mapping any more, it must return 1. If it tries to get the
11757c478bd9Sstevel@tonic-gate  * mapping but fails to do so, and it wants to be called back later, it
11767c478bd9Sstevel@tonic-gate  * must return 0.
11777c478bd9Sstevel@tonic-gate  *
11787c478bd9Sstevel@tonic-gate  * Failure to observe this protocol will have unpredictable results.
11797c478bd9Sstevel@tonic-gate  *
11807c478bd9Sstevel@tonic-gate  * The callback function must provide its own data structure integrity
11817c478bd9Sstevel@tonic-gate  * when it is invoked.
11827c478bd9Sstevel@tonic-gate  */
11837c478bd9Sstevel@tonic-gate 
11847c478bd9Sstevel@tonic-gate int
11857c478bd9Sstevel@tonic-gate ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp,
11867c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
11877c478bd9Sstevel@tonic-gate 
11887c478bd9Sstevel@tonic-gate /*
11897c478bd9Sstevel@tonic-gate  * The following three functions are convenience wrappers for ddi_dma_setup().
11907c478bd9Sstevel@tonic-gate  */
11917c478bd9Sstevel@tonic-gate 
11927c478bd9Sstevel@tonic-gate int
11937c478bd9Sstevel@tonic-gate ddi_dma_addr_setup(dev_info_t *dip, struct as *as, caddr_t addr, size_t len,
11947c478bd9Sstevel@tonic-gate 	uint_t flags, int (*waitfp)(), caddr_t arg,
11957c478bd9Sstevel@tonic-gate 	ddi_dma_lim_t *limits, ddi_dma_handle_t *handlep);
11967c478bd9Sstevel@tonic-gate 
11977c478bd9Sstevel@tonic-gate int
11987c478bd9Sstevel@tonic-gate ddi_dma_buf_setup(dev_info_t *dip, struct buf *bp, uint_t flags,
11997c478bd9Sstevel@tonic-gate 	int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits,
12007c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
12017c478bd9Sstevel@tonic-gate 
12027c478bd9Sstevel@tonic-gate /*
12037c478bd9Sstevel@tonic-gate  * Kernel addressability of the DMA object
12047c478bd9Sstevel@tonic-gate  *
12057c478bd9Sstevel@tonic-gate  * It might often be very useful to be able to get an IU mapping
12067c478bd9Sstevel@tonic-gate  * to the object which has DMA active to/from it. In fact, it might
12077c478bd9Sstevel@tonic-gate  * even really be a requirement.
12087c478bd9Sstevel@tonic-gate  *
12097c478bd9Sstevel@tonic-gate  * The cacheability of the object with respect to I/O and I/U caches
12107c478bd9Sstevel@tonic-gate  * is affected by this function as follows:
12117c478bd9Sstevel@tonic-gate  *
12127c478bd9Sstevel@tonic-gate  *	If a kernel virtual mapping to the object owned by the handle
12137c478bd9Sstevel@tonic-gate  *	existed already, and is IU cacheable, then the extant mapping
12147c478bd9Sstevel@tonic-gate  *	is locked and returned in kaddrp. By inference, kaddrp will
12157c478bd9Sstevel@tonic-gate  *	be an IU cacheable reference.
12167c478bd9Sstevel@tonic-gate  *
12177c478bd9Sstevel@tonic-gate  *	If a kernel virtual mapping to the object owned by the handle
12187c478bd9Sstevel@tonic-gate  *	existed already, and is not IU cacheable, then the extant mapping
12197c478bd9Sstevel@tonic-gate  *	is locked and returned in kaddrp. By inference, kaddrp will
12207c478bd9Sstevel@tonic-gate  *	*not* be an IU cacheable reference.
12217c478bd9Sstevel@tonic-gate  *
12227c478bd9Sstevel@tonic-gate  *	If a kernel virtual mapping to the object owned by the handle
12237c478bd9Sstevel@tonic-gate  *	does not exist already, a mapping will be created that will
12247c478bd9Sstevel@tonic-gate  *	*not* be an IU cacheable reference.
12257c478bd9Sstevel@tonic-gate  *
12267c478bd9Sstevel@tonic-gate  *	The IO cacheability of the object owned by the handle is ignored
12277c478bd9Sstevel@tonic-gate  *	and unaffected.
12287c478bd9Sstevel@tonic-gate  *
12297c478bd9Sstevel@tonic-gate  * This function returns the mapping values as describe above.
12307c478bd9Sstevel@tonic-gate  *
12317c478bd9Sstevel@tonic-gate  * When the DMA object owned by handle is freed (by ddi_dma_free()- see
12327c478bd9Sstevel@tonic-gate  * below), any mappings created by ddi_dma_kvaddrp() cease to be valid.
12337c478bd9Sstevel@tonic-gate  * This will be the convention that drivers must follow, as it will be
12347c478bd9Sstevel@tonic-gate  * impossible to enforce this programmatically.
12357c478bd9Sstevel@tonic-gate  */
12367c478bd9Sstevel@tonic-gate 
12377c478bd9Sstevel@tonic-gate int
12387c478bd9Sstevel@tonic-gate ddi_dma_kvaddrp(ddi_dma_handle_t, off_t, size_t, caddr_t *);
12397c478bd9Sstevel@tonic-gate 
12407c478bd9Sstevel@tonic-gate 
12417c478bd9Sstevel@tonic-gate /*
12427c478bd9Sstevel@tonic-gate  * Device addressability of the DMA object
12437c478bd9Sstevel@tonic-gate  *
12447c478bd9Sstevel@tonic-gate  * The handle that identifies an object mapped for DMA is an opaque entity.
12457c478bd9Sstevel@tonic-gate  * When a device driver wishes to load its dma engine with the appropriate
12467c478bd9Sstevel@tonic-gate  * values for transferring data to the mapped object, it has to get the
12477c478bd9Sstevel@tonic-gate  * value. Since the exact shape and form of this address is device specific,
12487c478bd9Sstevel@tonic-gate  * the value returned is a 'cookie' that each device may then interpret
12497c478bd9Sstevel@tonic-gate  * as it needs to. See <sys/dditypes.h> for the form of what the DMA cookie
12507c478bd9Sstevel@tonic-gate  * looks like.
12517c478bd9Sstevel@tonic-gate  *
12527c478bd9Sstevel@tonic-gate  * Returns DDI_SUCCESS for successful cookie generation,
12537c478bd9Sstevel@tonic-gate  * or DDI_FAILURE if it cannot generate the DMA cookie.
12547c478bd9Sstevel@tonic-gate  */
12557c478bd9Sstevel@tonic-gate 
12567c478bd9Sstevel@tonic-gate int
12577c478bd9Sstevel@tonic-gate ddi_dma_htoc(ddi_dma_handle_t handle, off_t off, ddi_dma_cookie_t *cookiep);
12587c478bd9Sstevel@tonic-gate 
12597c478bd9Sstevel@tonic-gate /*
12607c478bd9Sstevel@tonic-gate  * Given a DMA cookie, return its offset within the object referred to
12617c478bd9Sstevel@tonic-gate  * by the DMA handle. This is so at the end of a dma transfer, the device
12627c478bd9Sstevel@tonic-gate  * may take its specific ending address and find out how far into the
12637c478bd9Sstevel@tonic-gate  * memory object described by the handle the device got.
12647c478bd9Sstevel@tonic-gate  */
12657c478bd9Sstevel@tonic-gate 
12667c478bd9Sstevel@tonic-gate int
12677c478bd9Sstevel@tonic-gate ddi_dma_coff(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep, off_t *offp);
12687c478bd9Sstevel@tonic-gate 
12697c478bd9Sstevel@tonic-gate /*
12707c478bd9Sstevel@tonic-gate  * DMA mapping manipulation
12717c478bd9Sstevel@tonic-gate  *
12727c478bd9Sstevel@tonic-gate  * It may be desirable or convenient for some devices to allow partial
12737c478bd9Sstevel@tonic-gate  * mapping of an object for dma. This allows the mapping for DMA of
12747c478bd9Sstevel@tonic-gate  * arbitrarily large objects since only a portion of the object may
12757c478bd9Sstevel@tonic-gate  * be mapped for DMA at any point in time.
12767c478bd9Sstevel@tonic-gate  *
12777c478bd9Sstevel@tonic-gate  * In order to support this as well as other operations, the paradigm
12787c478bd9Sstevel@tonic-gate  * of a 'mapping window' is defined here. The object to be mapped has
12797c478bd9Sstevel@tonic-gate  * attributes of location and length. A window can be established upon
12807c478bd9Sstevel@tonic-gate  * this object. The window has attributes of offset (from the base mapping
12817c478bd9Sstevel@tonic-gate  * of the object) and length. It is assumed that length and offset are
12827c478bd9Sstevel@tonic-gate  * positive with respect to the base of the mapped object.
12837c478bd9Sstevel@tonic-gate  *
12847c478bd9Sstevel@tonic-gate  * In order to get support for such a window, the flag DDI_DMA_PARTIAL
12857c478bd9Sstevel@tonic-gate  * must be set in the request flags when the object is mapped for DMA.
12867c478bd9Sstevel@tonic-gate  * Each implementation may elect whether or not to support such an
12877c478bd9Sstevel@tonic-gate  * operation. Each implementation may also choose to ignore the request
12887c478bd9Sstevel@tonic-gate  * for a PARTIAL mapping and either reject the mapping of the object
12897c478bd9Sstevel@tonic-gate  * for being too big (DDI_DMA_TOOBIG) or may map the entire object.
12907c478bd9Sstevel@tonic-gate  * The caller who asks the object to be mapped for DMA will know
12917c478bd9Sstevel@tonic-gate  * whether a partial mapping has been made by receiving the qualified
12927c478bd9Sstevel@tonic-gate  * return value of DDI_DMA_PARTIAL_MAP instead of DDI_DMA_MAPPED.
12937c478bd9Sstevel@tonic-gate  * All dma window functions will return DDI_FAILURE if the object
12947c478bd9Sstevel@tonic-gate  * is not mapped partially.
12957c478bd9Sstevel@tonic-gate  *
12967c478bd9Sstevel@tonic-gate  * All other DDI dma functions (except ddi_dma_Free) operate *only* on
12977c478bd9Sstevel@tonic-gate  * the mapped portion of the object. That is, functions such as ddi_dma_sync,
12987c478bd9Sstevel@tonic-gate  * ddi_dma_segtocookie, and so on, only operate on the currently mapped
12997c478bd9Sstevel@tonic-gate  * window.
13007c478bd9Sstevel@tonic-gate  */
13017c478bd9Sstevel@tonic-gate 
13027c478bd9Sstevel@tonic-gate #if defined(__sparc)
13037c478bd9Sstevel@tonic-gate 
13047c478bd9Sstevel@tonic-gate /*
13057c478bd9Sstevel@tonic-gate  * ddi_dma_movwin - Move window from current offset/length to new
13067c478bd9Sstevel@tonic-gate  * offset/length. Returns DDI_SUCCESS if able to do so, else returns
13077c478bd9Sstevel@tonic-gate  * DDI_FAILURE if unable to do so, or the new window would be out of bounds
13087c478bd9Sstevel@tonic-gate  * or the object isn't set up for windows. If length is (off_t) -1, the
13097c478bd9Sstevel@tonic-gate  * If the optional cp argument is specified, an implicit ddi_dma_htoc
13107c478bd9Sstevel@tonic-gate  * is done to fill that in. The new offset and length will be returned
13117c478bd9Sstevel@tonic-gate  * in the arguments *offp and *lenp (resp).
13127c478bd9Sstevel@tonic-gate  *
13137c478bd9Sstevel@tonic-gate  * In this implementation, only fixed width windows are used. It is
13147c478bd9Sstevel@tonic-gate  * recommended that the windowsize should be retrieved via the function
13157c478bd9Sstevel@tonic-gate  * ddi_dma_curwin (below) and that used to specify new offsets and lengths
13167c478bd9Sstevel@tonic-gate  * since the window will be fixed at that size and will only move modulo
13177c478bd9Sstevel@tonic-gate  * winsize.
13187c478bd9Sstevel@tonic-gate  *
13197c478bd9Sstevel@tonic-gate  * The caller must guarantee that their device's dma engine is quiescent
13207c478bd9Sstevel@tonic-gate  * with respect to the current DMA window.
13217c478bd9Sstevel@tonic-gate  *
13227c478bd9Sstevel@tonic-gate  * The implementation will try to be rapid with respect to moving a window,
13237c478bd9Sstevel@tonic-gate  * but since an appropriate ddi_dma_sync() is likely to be done, there
13247c478bd9Sstevel@tonic-gate  * will be no guaranteed latency. In practice this should not be too
13257c478bd9Sstevel@tonic-gate  * horrible, but don't depend upon any particular latency.
13267c478bd9Sstevel@tonic-gate  */
13277c478bd9Sstevel@tonic-gate 
13287c478bd9Sstevel@tonic-gate int
13297c478bd9Sstevel@tonic-gate ddi_dma_movwin(ddi_dma_handle_t, off_t *offp, size_t *lenp, ddi_dma_cookie_t *);
13307c478bd9Sstevel@tonic-gate 
13317c478bd9Sstevel@tonic-gate #endif
13327c478bd9Sstevel@tonic-gate 
13337c478bd9Sstevel@tonic-gate /*
13347c478bd9Sstevel@tonic-gate  * ddi_dma_curwin - report the current offset/length of the window.
13357c478bd9Sstevel@tonic-gate  *
13367c478bd9Sstevel@tonic-gate  * Returns DDI_SUCCESS if offset and length
13377c478bd9Sstevel@tonic-gate  * successfully established, else DDI_FAILURE.
13387c478bd9Sstevel@tonic-gate  */
13397c478bd9Sstevel@tonic-gate 
13407c478bd9Sstevel@tonic-gate int
13417c478bd9Sstevel@tonic-gate ddi_dma_curwin(ddi_dma_handle_t handle, off_t *offp, size_t *lenp);
13427c478bd9Sstevel@tonic-gate 
13437c478bd9Sstevel@tonic-gate /*
13447c478bd9Sstevel@tonic-gate  * Get next dma window
13457c478bd9Sstevel@tonic-gate  *
13467c478bd9Sstevel@tonic-gate  * ddi_dma_nextwin takes a handle and a window, and fills in a pointer to
13477c478bd9Sstevel@tonic-gate  * the next window within the object. If win is "NULL", a pointer to the
13487c478bd9Sstevel@tonic-gate  * first window within the object is filled in.
13497c478bd9Sstevel@tonic-gate  *
13507c478bd9Sstevel@tonic-gate  * Returns	DDI_SUCCESS if successfully filled in the window pointer,
13517c478bd9Sstevel@tonic-gate  *		DDI_DMA_STALE if win does not refer to the currently active
13527c478bd9Sstevel@tonic-gate  *				 window,
13537c478bd9Sstevel@tonic-gate  *		DDI_DMA_DONE else there is no next window.
13547c478bd9Sstevel@tonic-gate  */
13557c478bd9Sstevel@tonic-gate 
13567c478bd9Sstevel@tonic-gate int
13577c478bd9Sstevel@tonic-gate ddi_dma_nextwin(ddi_dma_handle_t, ddi_dma_win_t, ddi_dma_win_t *);
13587c478bd9Sstevel@tonic-gate 
13597c478bd9Sstevel@tonic-gate /*
13607c478bd9Sstevel@tonic-gate  * Get next segment
13617c478bd9Sstevel@tonic-gate  *
13627c478bd9Sstevel@tonic-gate  * ddi_dma_nextseg takes a window and a segment and fills in a pointer to
13637c478bd9Sstevel@tonic-gate  * the next segment within the window. If seg is "NULL", a pointer to the
13647c478bd9Sstevel@tonic-gate  * first segment within the window is filled in.
13657c478bd9Sstevel@tonic-gate  *
13667c478bd9Sstevel@tonic-gate  * Returns	DDI_SUCCESS if successfully filled in the segment pointer,
13677c478bd9Sstevel@tonic-gate  *		DDI_DMA_STALE if win does not refer to the currently active
13687c478bd9Sstevel@tonic-gate  *				 window.
13697c478bd9Sstevel@tonic-gate  *		DDI_DMA_DONE else there is no next segment.
13707c478bd9Sstevel@tonic-gate  */
13717c478bd9Sstevel@tonic-gate 
13727c478bd9Sstevel@tonic-gate int
13737c478bd9Sstevel@tonic-gate ddi_dma_nextseg(ddi_dma_win_t, ddi_dma_seg_t, ddi_dma_seg_t *);
13747c478bd9Sstevel@tonic-gate 
13757c478bd9Sstevel@tonic-gate /*
13767c478bd9Sstevel@tonic-gate  * Segment to cookie
13777c478bd9Sstevel@tonic-gate  *
13787c478bd9Sstevel@tonic-gate  * ddi_dma_segtocookie takes a segment and fills in the cookie pointed
13797c478bd9Sstevel@tonic-gate  * to by cookiep with the appropriate address, length and bus type to be
13807c478bd9Sstevel@tonic-gate  * used to program the DMA engine. ddi_dma_segtocookie also fills in the
13817c478bd9Sstevel@tonic-gate  * range within the object (specified by <off, len>) this particular
13827c478bd9Sstevel@tonic-gate  * segment is mapping. <off, len> are filled in to give some control
13837c478bd9Sstevel@tonic-gate  * where in the object the current dma transfer is active.
13847c478bd9Sstevel@tonic-gate  *
13857c478bd9Sstevel@tonic-gate  * Returns	DDI_SUCCESS if successfully filled in all values,
13867c478bd9Sstevel@tonic-gate  * else		DDI_FAILURE
13877c478bd9Sstevel@tonic-gate  *
13887c478bd9Sstevel@tonic-gate  * This function is documented as Obsolete and is replaced by
13897c478bd9Sstevel@tonic-gate  * ddi_dma_nextcookie(9F)
13907c478bd9Sstevel@tonic-gate  */
13917c478bd9Sstevel@tonic-gate 
13927c478bd9Sstevel@tonic-gate int
13937c478bd9Sstevel@tonic-gate ddi_dma_segtocookie(ddi_dma_seg_t, off_t *, off_t *, ddi_dma_cookie_t *);
13947c478bd9Sstevel@tonic-gate 
13957c478bd9Sstevel@tonic-gate /*
13967c478bd9Sstevel@tonic-gate  * Synchronization of I/O with respect to various
13977c478bd9Sstevel@tonic-gate  * caches and system write buffers.
13987c478bd9Sstevel@tonic-gate  *
13997c478bd9Sstevel@tonic-gate  * Done at varying points during an I/O transfer (including at the
14007c478bd9Sstevel@tonic-gate  * removal of an I/O mapping).
14017c478bd9Sstevel@tonic-gate  *
14027c478bd9Sstevel@tonic-gate  * Due to the support of systems with write buffers which may
14037c478bd9Sstevel@tonic-gate  * not be able to be turned off, this function *must* used at
14047c478bd9Sstevel@tonic-gate  * any point in which data consistency might be required.
14057c478bd9Sstevel@tonic-gate  *
14067c478bd9Sstevel@tonic-gate  * Generally this means that if a memory object has multiple mappings
14077c478bd9Sstevel@tonic-gate  * (both for I/O, as described by the handle, and the IU, via, e.g.
14087c478bd9Sstevel@tonic-gate  * a call to ddi_dma_kvaddrp), and one mapping may have been
14097c478bd9Sstevel@tonic-gate  * used to modify the memory object, this function must be called
14107c478bd9Sstevel@tonic-gate  * to ensure that the modification of the memory object is
14117c478bd9Sstevel@tonic-gate  * complete, as well as possibly to inform other mappings of
14127c478bd9Sstevel@tonic-gate  * the object that any cached references to the object are
14137c478bd9Sstevel@tonic-gate  * now stale (and flush or invalidate these stale cache references
14147c478bd9Sstevel@tonic-gate  * as necessary).
14157c478bd9Sstevel@tonic-gate  *
14167c478bd9Sstevel@tonic-gate  * The function ddi_dma_sync() provides the general interface with
14177c478bd9Sstevel@tonic-gate  * respect to this capability. Generally, ddi_dma_free() (below) may
14187c478bd9Sstevel@tonic-gate  * be used in preference to ddi_dma_sync() as ddi_dma_free() calls
14197c478bd9Sstevel@tonic-gate  * ddi_dma_sync().
14207c478bd9Sstevel@tonic-gate  *
14217c478bd9Sstevel@tonic-gate  * Returns 0 if all caches that exist and are specified by cache_flags
14227c478bd9Sstevel@tonic-gate  * are successfully operated on, else -1.
14237c478bd9Sstevel@tonic-gate  *
14247c478bd9Sstevel@tonic-gate  * The argument offset specifies an offset into the mapping of the mapped
14257c478bd9Sstevel@tonic-gate  * object in which to perform the synchronization. It will be silently
14267c478bd9Sstevel@tonic-gate  * truncated to the granularity of underlying cache line sizes as
14277c478bd9Sstevel@tonic-gate  * appropriate.
14287c478bd9Sstevel@tonic-gate  *
14297c478bd9Sstevel@tonic-gate  * The argument len specifies a length starting from offset in which to
14307c478bd9Sstevel@tonic-gate  * perform the synchronization. A value of (uint_t) -1 means that the length
14317c478bd9Sstevel@tonic-gate  * proceeds from offset to the end of the mapping. The length argument
14327c478bd9Sstevel@tonic-gate  * will silently rounded up to the granularity of underlying cache line
14337c478bd9Sstevel@tonic-gate  * sizes  as appropriate.
14347c478bd9Sstevel@tonic-gate  *
14357c478bd9Sstevel@tonic-gate  * The argument flags specifies what to synchronize (the device's view of
14367c478bd9Sstevel@tonic-gate  * the object or the cpu's view of the object).
14377c478bd9Sstevel@tonic-gate  *
14387c478bd9Sstevel@tonic-gate  * Inquiring minds want to know when ddi_dma_sync should be used:
14397c478bd9Sstevel@tonic-gate  *
14407c478bd9Sstevel@tonic-gate  * +	When an object is mapped for dma, assume that an
14417c478bd9Sstevel@tonic-gate  *	implicit ddi_dma_sync() is done for you.
14427c478bd9Sstevel@tonic-gate  *
14437c478bd9Sstevel@tonic-gate  * +	When an object is unmapped (ddi_dma_free()), assume
14447c478bd9Sstevel@tonic-gate  *	that an implicit ddi_dma_sync() is done for you.
14457c478bd9Sstevel@tonic-gate  *
14467c478bd9Sstevel@tonic-gate  * +	At any time between the two times above that the
14477c478bd9Sstevel@tonic-gate  *	memory object may have been modified by either
14487c478bd9Sstevel@tonic-gate  *	the DMA device or a processor and you wish that
14497c478bd9Sstevel@tonic-gate  *	the change be noticed by the master that didn't
14507c478bd9Sstevel@tonic-gate  *	do the modifying.
14517c478bd9Sstevel@tonic-gate  *
14527c478bd9Sstevel@tonic-gate  * Clearly, only the third case above requires the use of ddi_dma_sync.
14537c478bd9Sstevel@tonic-gate  *
14547c478bd9Sstevel@tonic-gate  * Inquiring minds also want to know which flag to use:
14557c478bd9Sstevel@tonic-gate  *
14567c478bd9Sstevel@tonic-gate  * +	If you *modify* with a cpu the object, you use
14577c478bd9Sstevel@tonic-gate  *	ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure
14587c478bd9Sstevel@tonic-gate  *	that the DMA device sees the changes you made).
14597c478bd9Sstevel@tonic-gate  *
14607c478bd9Sstevel@tonic-gate  * +	If you are checking, with the processor, an area
14617c478bd9Sstevel@tonic-gate  *	of the object that the DMA device *may* have modified,
14627c478bd9Sstevel@tonic-gate  *	you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are
14637c478bd9Sstevel@tonic-gate  *	making sure that the processor(s) will see the changes
14647c478bd9Sstevel@tonic-gate  *	that the DMA device may have made).
14657c478bd9Sstevel@tonic-gate  */
14667c478bd9Sstevel@tonic-gate 
14677c478bd9Sstevel@tonic-gate int
14687c478bd9Sstevel@tonic-gate ddi_dma_sync(ddi_dma_handle_t handle, off_t offset, size_t len, uint_t flags);
14697c478bd9Sstevel@tonic-gate 
14707c478bd9Sstevel@tonic-gate /*
14717c478bd9Sstevel@tonic-gate  * DMA mapping de-allocation
14727c478bd9Sstevel@tonic-gate  *
14737c478bd9Sstevel@tonic-gate  * When an I/O transfer completes, the resources required to map the
14747c478bd9Sstevel@tonic-gate  * object for DMA should be completely released. As a side effect,
14757c478bd9Sstevel@tonic-gate  * various cache synchronization might need to occur (see above).
14767c478bd9Sstevel@tonic-gate  *
14777c478bd9Sstevel@tonic-gate  * Returns DDI_SUCCESS if the all underlying caches are successfully
14787c478bd9Sstevel@tonic-gate  * flushed, else DDI_FAILURE.
14797c478bd9Sstevel@tonic-gate  *
14807c478bd9Sstevel@tonic-gate  */
14817c478bd9Sstevel@tonic-gate 
14827c478bd9Sstevel@tonic-gate int
14837c478bd9Sstevel@tonic-gate ddi_dma_free(ddi_dma_handle_t handle);
14847c478bd9Sstevel@tonic-gate 
14857c478bd9Sstevel@tonic-gate /*
14867c478bd9Sstevel@tonic-gate  * Device constraint cognizant kernel memory allocation- consistent access.
14877c478bd9Sstevel@tonic-gate  *
14887c478bd9Sstevel@tonic-gate  * IOPB allocation and de-allocation
14897c478bd9Sstevel@tonic-gate  *
14907c478bd9Sstevel@tonic-gate  * An IOPB allocation allocates some primary memory such that both
14917c478bd9Sstevel@tonic-gate  * the kernel and the specified DMA device might be able to access it in a
14927c478bd9Sstevel@tonic-gate  * non-cacheable (otherwise known as byte-consistent or non-streaming mode)
14937c478bd9Sstevel@tonic-gate  * fashion. The allocation will obey the beginning alignment and padding
14947c478bd9Sstevel@tonic-gate  * constraints as specified in the initial limits argument and as subsequently
14957c478bd9Sstevel@tonic-gate  * modified by intervening parents. The limits argument may be NULL, in
14967c478bd9Sstevel@tonic-gate  * which case the system picks a reasonable beginning limits.
14977c478bd9Sstevel@tonic-gate  *
14987c478bd9Sstevel@tonic-gate  * A kernel virtual address to the allocated primary memory is returned,
14997c478bd9Sstevel@tonic-gate  * but no DMA mapping to the object is established (drivers must use the
15007c478bd9Sstevel@tonic-gate  * ddi_dma_map() routines for that).
15017c478bd9Sstevel@tonic-gate  *
15027c478bd9Sstevel@tonic-gate  * If no iopb space can be allocated, DDI_FAILURE is returned.
15037c478bd9Sstevel@tonic-gate  */
15047c478bd9Sstevel@tonic-gate 
15057c478bd9Sstevel@tonic-gate int
15067c478bd9Sstevel@tonic-gate ddi_iopb_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length,
15077c478bd9Sstevel@tonic-gate 	caddr_t *iopbp);
15087c478bd9Sstevel@tonic-gate 
15097c478bd9Sstevel@tonic-gate /*
15107c478bd9Sstevel@tonic-gate  * Deallocate an IOPB kernel virtual mapping.
15117c478bd9Sstevel@tonic-gate  */
15127c478bd9Sstevel@tonic-gate 
15137c478bd9Sstevel@tonic-gate void
15147c478bd9Sstevel@tonic-gate ddi_iopb_free(caddr_t iopb);
15157c478bd9Sstevel@tonic-gate 
15167c478bd9Sstevel@tonic-gate /*
15177c478bd9Sstevel@tonic-gate  * Device constraint cognizant kernel memory allocation- streaming access.
15187c478bd9Sstevel@tonic-gate  *
15197c478bd9Sstevel@tonic-gate  * Similar to ddi_iopb_alloc, but for primary memory that is intended
15207c478bd9Sstevel@tonic-gate  * to be accessed in a streaming fashion. The allocation will obey the
15217c478bd9Sstevel@tonic-gate  * beginning alignment and padding constraints as specified in the initial
15227c478bd9Sstevel@tonic-gate  * limits argument and as subsequently modified by intervening parents.
15237c478bd9Sstevel@tonic-gate  * The limits argument may be NULL, in which case the system picks a
15247c478bd9Sstevel@tonic-gate  * reasonable beginning limits.
15257c478bd9Sstevel@tonic-gate  *
15267c478bd9Sstevel@tonic-gate  * A flags value of 0x1 indicates whether the caller can wait for
15277c478bd9Sstevel@tonic-gate  * memory to become available. Other bits in the flags argument
15287c478bd9Sstevel@tonic-gate  * are reserved for future use and must be zero.
15297c478bd9Sstevel@tonic-gate  *
15307c478bd9Sstevel@tonic-gate  * Upon return from a successful call, the new real length of
15317c478bd9Sstevel@tonic-gate  * the allocation is returned (for use in mapping the memory
15327c478bd9Sstevel@tonic-gate  * later).
15337c478bd9Sstevel@tonic-gate  */
15347c478bd9Sstevel@tonic-gate 
15357c478bd9Sstevel@tonic-gate int
15367c478bd9Sstevel@tonic-gate ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length,
15377c478bd9Sstevel@tonic-gate 	uint_t flags, caddr_t *kaddrp, uint_t *real_length);
15387c478bd9Sstevel@tonic-gate 
15397c478bd9Sstevel@tonic-gate /*
15407c478bd9Sstevel@tonic-gate  * Free the memory allocated via ddi_mem_alloc().
15417c478bd9Sstevel@tonic-gate  *
15427c478bd9Sstevel@tonic-gate  * Note that passing an address not allocated via ddi_mem_alloc()
15437c478bd9Sstevel@tonic-gate  * will panic the system.
15447c478bd9Sstevel@tonic-gate  */
15457c478bd9Sstevel@tonic-gate 
15467c478bd9Sstevel@tonic-gate void
15477c478bd9Sstevel@tonic-gate ddi_mem_free(caddr_t kaddr);
15487c478bd9Sstevel@tonic-gate 
15497c478bd9Sstevel@tonic-gate /*
15507c478bd9Sstevel@tonic-gate  * Dma alignment, minimum transfers sizes, and burst sizes allowed.
15517c478bd9Sstevel@tonic-gate  * Some with tears, some without.
15527c478bd9Sstevel@tonic-gate  */
15537c478bd9Sstevel@tonic-gate 
15547c478bd9Sstevel@tonic-gate /*
15557c478bd9Sstevel@tonic-gate  * Return a copy of the DMA attributes for the given handle.
15567c478bd9Sstevel@tonic-gate  */
15577c478bd9Sstevel@tonic-gate 
15587c478bd9Sstevel@tonic-gate int
15597c478bd9Sstevel@tonic-gate ddi_dma_get_attr(ddi_dma_handle_t handle, ddi_dma_attr_t *attrp);
15607c478bd9Sstevel@tonic-gate 
15617c478bd9Sstevel@tonic-gate /*
15627c478bd9Sstevel@tonic-gate  * Return the allowable DMA burst size for the object mapped by handle.
15637c478bd9Sstevel@tonic-gate  * The burst sizes will returned in an integer that encodes power
15647c478bd9Sstevel@tonic-gate  * of two burst sizes that are allowed in bit encoded format. For
15657c478bd9Sstevel@tonic-gate  * example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts
15667c478bd9Sstevel@tonic-gate  * would be encoded as 0x2f. A transfer that could be allowed as solely
15677c478bd9Sstevel@tonic-gate  * a halfword (2 byte) transfers would be returned as 0x2.
15687c478bd9Sstevel@tonic-gate  */
15697c478bd9Sstevel@tonic-gate 
15707c478bd9Sstevel@tonic-gate int
15717c478bd9Sstevel@tonic-gate ddi_dma_burstsizes(ddi_dma_handle_t handle);
15727c478bd9Sstevel@tonic-gate 
15737c478bd9Sstevel@tonic-gate /*
15747c478bd9Sstevel@tonic-gate  * Return the required beginning alignment for a transfer and
15757c478bd9Sstevel@tonic-gate  * the minimum sized effect a transfer would have. The beginning
15767c478bd9Sstevel@tonic-gate  * alignment will be some power of two. The minimum sized effect
15777c478bd9Sstevel@tonic-gate  * indicates, for writes, how much of the mapped object will be
15787c478bd9Sstevel@tonic-gate  * affected by the minimum access and for reads how much of the
15797c478bd9Sstevel@tonic-gate  * mapped object will accessed.
15807c478bd9Sstevel@tonic-gate  */
15817c478bd9Sstevel@tonic-gate 
15827c478bd9Sstevel@tonic-gate int
15837c478bd9Sstevel@tonic-gate ddi_dma_devalign(ddi_dma_handle_t handle, uint_t *alignment, uint_t *mineffect);
15847c478bd9Sstevel@tonic-gate 
15857c478bd9Sstevel@tonic-gate /*
15867c478bd9Sstevel@tonic-gate  * Like ddi_dma_devalign, but without having to map the object.
15877c478bd9Sstevel@tonic-gate  * The object is assumed to be primary memory, and it is assumed
15887c478bd9Sstevel@tonic-gate  * a minimum effective transfer is also the appropriate alignment
15897c478bd9Sstevel@tonic-gate  * to be using. The streaming flag, if non-zero, indicates that the
15907c478bd9Sstevel@tonic-gate  * returned value should be modified to account for streaming mode
15917c478bd9Sstevel@tonic-gate  * accesses (e.g., with I/O caches enabled). The initial value
15927c478bd9Sstevel@tonic-gate  * is passed by the requester if it has a dma engine that has
15937c478bd9Sstevel@tonic-gate  * a minimum cycle constraint (or, for streaming mode, the most
15947c478bd9Sstevel@tonic-gate  * efficient size).
15957c478bd9Sstevel@tonic-gate  */
15967c478bd9Sstevel@tonic-gate 
15977c478bd9Sstevel@tonic-gate int
15987c478bd9Sstevel@tonic-gate ddi_iomin(dev_info_t *dip, int initial, int streaming);
15997c478bd9Sstevel@tonic-gate 
16007c478bd9Sstevel@tonic-gate /*
16017c478bd9Sstevel@tonic-gate  * Given two DMA limit structures, apply the limitations
16027c478bd9Sstevel@tonic-gate  * of one to the other, following the rules of limits
16037c478bd9Sstevel@tonic-gate  * and the wishes of the caller.
16047c478bd9Sstevel@tonic-gate  *
16057c478bd9Sstevel@tonic-gate  * The rules of dma limit structures are that you cannot
16067c478bd9Sstevel@tonic-gate  * make things *less* restrictive as you apply one set
16077c478bd9Sstevel@tonic-gate  * of limits to another.
16087c478bd9Sstevel@tonic-gate  *
16097c478bd9Sstevel@tonic-gate  */
16107c478bd9Sstevel@tonic-gate 
16117c478bd9Sstevel@tonic-gate void
16127c478bd9Sstevel@tonic-gate ddi_dmalim_merge(ddi_dma_lim_t *limit, ddi_dma_lim_t *modifier);
16137c478bd9Sstevel@tonic-gate 
16147c478bd9Sstevel@tonic-gate /*
16157c478bd9Sstevel@tonic-gate  * Merge DMA attributes
16167c478bd9Sstevel@tonic-gate  */
16177c478bd9Sstevel@tonic-gate 
16187c478bd9Sstevel@tonic-gate void
16197c478bd9Sstevel@tonic-gate ddi_dma_attr_merge(ddi_dma_attr_t *attr, ddi_dma_attr_t *mod);
16207c478bd9Sstevel@tonic-gate 
16217c478bd9Sstevel@tonic-gate /*
16227c478bd9Sstevel@tonic-gate  * Allocate a DMA handle
16237c478bd9Sstevel@tonic-gate  */
16247c478bd9Sstevel@tonic-gate 
16257c478bd9Sstevel@tonic-gate int
16267c478bd9Sstevel@tonic-gate ddi_dma_alloc_handle(dev_info_t *dip, ddi_dma_attr_t *attr,
16277c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg,
16287c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
16297c478bd9Sstevel@tonic-gate 
16307c478bd9Sstevel@tonic-gate /*
16317c478bd9Sstevel@tonic-gate  * Free DMA handle
16327c478bd9Sstevel@tonic-gate  */
16337c478bd9Sstevel@tonic-gate 
16347c478bd9Sstevel@tonic-gate void
16357c478bd9Sstevel@tonic-gate ddi_dma_free_handle(ddi_dma_handle_t *handlep);
16367c478bd9Sstevel@tonic-gate 
16377c478bd9Sstevel@tonic-gate /*
16387c478bd9Sstevel@tonic-gate  * Allocate memory for DMA transfers
16397c478bd9Sstevel@tonic-gate  */
16407c478bd9Sstevel@tonic-gate 
16417c478bd9Sstevel@tonic-gate int
16427c478bd9Sstevel@tonic-gate ddi_dma_mem_alloc(ddi_dma_handle_t handle, size_t length,
16437c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, uint_t xfermodes,
16447c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg, caddr_t *kaddrp,
16457c478bd9Sstevel@tonic-gate 	size_t *real_length, ddi_acc_handle_t *handlep);
16467c478bd9Sstevel@tonic-gate 
16477c478bd9Sstevel@tonic-gate /*
16487c478bd9Sstevel@tonic-gate  * Free DMA memory
16497c478bd9Sstevel@tonic-gate  */
16507c478bd9Sstevel@tonic-gate 
16517c478bd9Sstevel@tonic-gate void
16527c478bd9Sstevel@tonic-gate ddi_dma_mem_free(ddi_acc_handle_t *hp);
16537c478bd9Sstevel@tonic-gate 
16547c478bd9Sstevel@tonic-gate /*
16557c478bd9Sstevel@tonic-gate  * bind address to a DMA handle
16567c478bd9Sstevel@tonic-gate  */
16577c478bd9Sstevel@tonic-gate 
16587c478bd9Sstevel@tonic-gate int
16597c478bd9Sstevel@tonic-gate ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as,
16607c478bd9Sstevel@tonic-gate 	caddr_t addr, size_t len, uint_t flags,
16617c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg,
16627c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, uint_t *ccountp);
16637c478bd9Sstevel@tonic-gate 
16647c478bd9Sstevel@tonic-gate /*
16657c478bd9Sstevel@tonic-gate  * bind buffer to DMA handle
16667c478bd9Sstevel@tonic-gate  */
16677c478bd9Sstevel@tonic-gate 
16687c478bd9Sstevel@tonic-gate int
16697c478bd9Sstevel@tonic-gate ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp,
16707c478bd9Sstevel@tonic-gate 	uint_t flags, int (*waitfp)(caddr_t), caddr_t arg,
16717c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, uint_t *ccountp);
16727c478bd9Sstevel@tonic-gate 
16737c478bd9Sstevel@tonic-gate /*
16747c478bd9Sstevel@tonic-gate  * unbind mapping object to handle
16757c478bd9Sstevel@tonic-gate  */
16767c478bd9Sstevel@tonic-gate 
16777c478bd9Sstevel@tonic-gate int
16787c478bd9Sstevel@tonic-gate ddi_dma_unbind_handle(ddi_dma_handle_t handle);
16797c478bd9Sstevel@tonic-gate 
16807c478bd9Sstevel@tonic-gate /*
16817c478bd9Sstevel@tonic-gate  * get next DMA cookie
16827c478bd9Sstevel@tonic-gate  */
16837c478bd9Sstevel@tonic-gate 
16847c478bd9Sstevel@tonic-gate void
16857c478bd9Sstevel@tonic-gate ddi_dma_nextcookie(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep);
16867c478bd9Sstevel@tonic-gate 
16877c478bd9Sstevel@tonic-gate /*
16887c478bd9Sstevel@tonic-gate  * get number of DMA windows
16897c478bd9Sstevel@tonic-gate  */
16907c478bd9Sstevel@tonic-gate 
16917c478bd9Sstevel@tonic-gate int
16927c478bd9Sstevel@tonic-gate ddi_dma_numwin(ddi_dma_handle_t handle, uint_t *nwinp);
16937c478bd9Sstevel@tonic-gate 
16947c478bd9Sstevel@tonic-gate /*
16957c478bd9Sstevel@tonic-gate  * get specific DMA window
16967c478bd9Sstevel@tonic-gate  */
16977c478bd9Sstevel@tonic-gate 
16987c478bd9Sstevel@tonic-gate int
16997c478bd9Sstevel@tonic-gate ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp,
17007c478bd9Sstevel@tonic-gate 	size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
17017c478bd9Sstevel@tonic-gate 
17027c478bd9Sstevel@tonic-gate /*
17037c478bd9Sstevel@tonic-gate  * activate 64 bit SBus support
17047c478bd9Sstevel@tonic-gate  */
17057c478bd9Sstevel@tonic-gate 
17067c478bd9Sstevel@tonic-gate int
17077c478bd9Sstevel@tonic-gate ddi_dma_set_sbus64(ddi_dma_handle_t handle, ulong_t burstsizes);
17087c478bd9Sstevel@tonic-gate 
17097c478bd9Sstevel@tonic-gate /*
17107c478bd9Sstevel@tonic-gate  * Miscellaneous functions
17117c478bd9Sstevel@tonic-gate  */
17127c478bd9Sstevel@tonic-gate 
17137c478bd9Sstevel@tonic-gate /*
17147c478bd9Sstevel@tonic-gate  * ddi_report_dev:	Report a successful attach.
17157c478bd9Sstevel@tonic-gate  */
17167c478bd9Sstevel@tonic-gate 
17177c478bd9Sstevel@tonic-gate void
17187c478bd9Sstevel@tonic-gate ddi_report_dev(dev_info_t *dev);
17197c478bd9Sstevel@tonic-gate 
17207c478bd9Sstevel@tonic-gate /*
17217c478bd9Sstevel@tonic-gate  * ddi_dev_regsize
17227c478bd9Sstevel@tonic-gate  *
17237c478bd9Sstevel@tonic-gate  *	If the device has h/w register(s), report
17247c478bd9Sstevel@tonic-gate  *	the size, in bytes, of the specified one into *resultp.
17257c478bd9Sstevel@tonic-gate  *
17267c478bd9Sstevel@tonic-gate  *	Returns DDI_FAILURE if there are not registers,
17277c478bd9Sstevel@tonic-gate  *	or the specified register doesn't exist.
17287c478bd9Sstevel@tonic-gate  */
17297c478bd9Sstevel@tonic-gate 
17307c478bd9Sstevel@tonic-gate int
17317c478bd9Sstevel@tonic-gate ddi_dev_regsize(dev_info_t *dev, uint_t rnumber, off_t *resultp);
17327c478bd9Sstevel@tonic-gate 
17337c478bd9Sstevel@tonic-gate /*
17347c478bd9Sstevel@tonic-gate  * ddi_dev_nregs
17357c478bd9Sstevel@tonic-gate  *
17367c478bd9Sstevel@tonic-gate  *	If the device has h/w register(s), report
17377c478bd9Sstevel@tonic-gate  *	how many of them that there are into resultp.
17387c478bd9Sstevel@tonic-gate  *	Return DDI_FAILURE if the device has no registers.
17397c478bd9Sstevel@tonic-gate  */
17407c478bd9Sstevel@tonic-gate 
17417c478bd9Sstevel@tonic-gate int
17427c478bd9Sstevel@tonic-gate ddi_dev_nregs(dev_info_t *dev, int *resultp);
17437c478bd9Sstevel@tonic-gate 
17447c478bd9Sstevel@tonic-gate /*
17457c478bd9Sstevel@tonic-gate  * ddi_dev_is_sid
17467c478bd9Sstevel@tonic-gate  *
17477c478bd9Sstevel@tonic-gate  *	If the device is self-identifying, i.e.,
17487c478bd9Sstevel@tonic-gate  *	has already been probed by a smart PROM
17497c478bd9Sstevel@tonic-gate  *	(and thus registers are known to be valid)
17507c478bd9Sstevel@tonic-gate  *	return DDI_SUCCESS, else DDI_FAILURE.
17517c478bd9Sstevel@tonic-gate  */
17527c478bd9Sstevel@tonic-gate 
17537c478bd9Sstevel@tonic-gate 
17547c478bd9Sstevel@tonic-gate int
17557c478bd9Sstevel@tonic-gate ddi_dev_is_sid(dev_info_t *dev);
17567c478bd9Sstevel@tonic-gate 
17577c478bd9Sstevel@tonic-gate /*
17587c478bd9Sstevel@tonic-gate  * ddi_slaveonly
17597c478bd9Sstevel@tonic-gate  *
17607c478bd9Sstevel@tonic-gate  *	If the device is on a bus that precludes
17617c478bd9Sstevel@tonic-gate  *	the device from being either a dma master or
17627c478bd9Sstevel@tonic-gate  *	a dma slave, return DDI_SUCCESS.
17637c478bd9Sstevel@tonic-gate  */
17647c478bd9Sstevel@tonic-gate 
17657c478bd9Sstevel@tonic-gate int
17667c478bd9Sstevel@tonic-gate ddi_slaveonly(dev_info_t *);
17677c478bd9Sstevel@tonic-gate 
17687c478bd9Sstevel@tonic-gate 
17697c478bd9Sstevel@tonic-gate /*
17707c478bd9Sstevel@tonic-gate  * ddi_dev_affinity
17717c478bd9Sstevel@tonic-gate  *
17727c478bd9Sstevel@tonic-gate  *	Report, via DDI_SUCCESS, whether there exists
17737c478bd9Sstevel@tonic-gate  *	an 'affinity' between two dev_info_t's. An
17747c478bd9Sstevel@tonic-gate  *	affinity is defined to be either a parent-child,
17757c478bd9Sstevel@tonic-gate  *	or a sibling relationship such that the siblings
17767c478bd9Sstevel@tonic-gate  *	or in the same part of the bus they happen to be
17777c478bd9Sstevel@tonic-gate  *	on.
17787c478bd9Sstevel@tonic-gate  */
17797c478bd9Sstevel@tonic-gate 
17807c478bd9Sstevel@tonic-gate int
17817c478bd9Sstevel@tonic-gate ddi_dev_affinity(dev_info_t *deva, dev_info_t *devb);
17827c478bd9Sstevel@tonic-gate 
17837c478bd9Sstevel@tonic-gate 
17847c478bd9Sstevel@tonic-gate /*
17857c478bd9Sstevel@tonic-gate  * ddi_set_callback
17867c478bd9Sstevel@tonic-gate  *
17877c478bd9Sstevel@tonic-gate  *	Set a function/arg pair into the callback list identified
17887c478bd9Sstevel@tonic-gate  *	by listid. *listid must always initially start out as zero.
17897c478bd9Sstevel@tonic-gate  */
17907c478bd9Sstevel@tonic-gate 
17917c478bd9Sstevel@tonic-gate void
17927c478bd9Sstevel@tonic-gate ddi_set_callback(int (*funcp)(caddr_t), caddr_t arg, uintptr_t *listid);
17937c478bd9Sstevel@tonic-gate 
17947c478bd9Sstevel@tonic-gate /*
17957c478bd9Sstevel@tonic-gate  * ddi_run_callback
17967c478bd9Sstevel@tonic-gate  *
17977c478bd9Sstevel@tonic-gate  *	Run the callback list identified by listid.
17987c478bd9Sstevel@tonic-gate  */
17997c478bd9Sstevel@tonic-gate 
18007c478bd9Sstevel@tonic-gate void
18017c478bd9Sstevel@tonic-gate ddi_run_callback(uintptr_t *listid);
18027c478bd9Sstevel@tonic-gate 
18037c478bd9Sstevel@tonic-gate /*
18047c478bd9Sstevel@tonic-gate  * More miscellaneous
18057c478bd9Sstevel@tonic-gate  */
18067c478bd9Sstevel@tonic-gate 
18077c478bd9Sstevel@tonic-gate int
18087c478bd9Sstevel@tonic-gate nochpoll(dev_t dev, short events, int anyyet, short *reventsp,
18097c478bd9Sstevel@tonic-gate 	struct pollhead **phpp);
18107c478bd9Sstevel@tonic-gate 
18117c478bd9Sstevel@tonic-gate dev_info_t *
18127c478bd9Sstevel@tonic-gate nodevinfo(dev_t dev, int otyp);
18137c478bd9Sstevel@tonic-gate 
18147c478bd9Sstevel@tonic-gate int
18157c478bd9Sstevel@tonic-gate ddi_no_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result);
18167c478bd9Sstevel@tonic-gate 
18177c478bd9Sstevel@tonic-gate int
18187c478bd9Sstevel@tonic-gate ddi_getinfo_1to1(dev_info_t *dip, ddi_info_cmd_t infocmd,
18197c478bd9Sstevel@tonic-gate     void *arg, void **result);
18207c478bd9Sstevel@tonic-gate 
18217c478bd9Sstevel@tonic-gate int
18227c478bd9Sstevel@tonic-gate ddifail(dev_info_t *devi, ddi_attach_cmd_t cmd);
18237c478bd9Sstevel@tonic-gate 
18247c478bd9Sstevel@tonic-gate int
18257c478bd9Sstevel@tonic-gate ddi_no_dma_map(dev_info_t *dip, dev_info_t *rdip,
18267c478bd9Sstevel@tonic-gate     struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
18277c478bd9Sstevel@tonic-gate 
18287c478bd9Sstevel@tonic-gate int
18297c478bd9Sstevel@tonic-gate ddi_no_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
18307c478bd9Sstevel@tonic-gate     int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
18317c478bd9Sstevel@tonic-gate 
18327c478bd9Sstevel@tonic-gate int
18337c478bd9Sstevel@tonic-gate ddi_no_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
18347c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle);
18357c478bd9Sstevel@tonic-gate 
18367c478bd9Sstevel@tonic-gate int
18377c478bd9Sstevel@tonic-gate ddi_no_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
18387c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
18397c478bd9Sstevel@tonic-gate     ddi_dma_cookie_t *cp, uint_t *ccountp);
18407c478bd9Sstevel@tonic-gate 
18417c478bd9Sstevel@tonic-gate int
18427c478bd9Sstevel@tonic-gate ddi_no_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
18437c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle);
18447c478bd9Sstevel@tonic-gate 
18457c478bd9Sstevel@tonic-gate int
18467c478bd9Sstevel@tonic-gate ddi_no_dma_flush(dev_info_t *dip, dev_info_t *rdip,
18477c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, off_t off, size_t len,
18487c478bd9Sstevel@tonic-gate     uint_t cache_flags);
18497c478bd9Sstevel@tonic-gate 
18507c478bd9Sstevel@tonic-gate int
18517c478bd9Sstevel@tonic-gate ddi_no_dma_win(dev_info_t *dip, dev_info_t *rdip,
18527c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, uint_t win, off_t *offp,
18537c478bd9Sstevel@tonic-gate     size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
18547c478bd9Sstevel@tonic-gate 
18557c478bd9Sstevel@tonic-gate int
18567c478bd9Sstevel@tonic-gate ddi_no_dma_mctl(register dev_info_t *dip, dev_info_t *rdip,
18577c478bd9Sstevel@tonic-gate     ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
18587c478bd9Sstevel@tonic-gate     off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags);
18597c478bd9Sstevel@tonic-gate 
18607c478bd9Sstevel@tonic-gate void
18617c478bd9Sstevel@tonic-gate ddivoid();
18627c478bd9Sstevel@tonic-gate 
18637c478bd9Sstevel@tonic-gate cred_t *
18647c478bd9Sstevel@tonic-gate ddi_get_cred(void);
18657c478bd9Sstevel@tonic-gate 
18667c478bd9Sstevel@tonic-gate clock_t
18677c478bd9Sstevel@tonic-gate ddi_get_lbolt(void);
18687c478bd9Sstevel@tonic-gate 
18697c478bd9Sstevel@tonic-gate time_t
18707c478bd9Sstevel@tonic-gate ddi_get_time(void);
18717c478bd9Sstevel@tonic-gate 
18727c478bd9Sstevel@tonic-gate pid_t
18737c478bd9Sstevel@tonic-gate ddi_get_pid(void);
18747c478bd9Sstevel@tonic-gate 
18757c478bd9Sstevel@tonic-gate kt_did_t
18767c478bd9Sstevel@tonic-gate ddi_get_kt_did(void);
18777c478bd9Sstevel@tonic-gate 
18787c478bd9Sstevel@tonic-gate boolean_t
18797c478bd9Sstevel@tonic-gate ddi_can_receive_sig(void);
18807c478bd9Sstevel@tonic-gate 
18817c478bd9Sstevel@tonic-gate void
18827c478bd9Sstevel@tonic-gate swab(void *src, void *dst, size_t nbytes);
18837c478bd9Sstevel@tonic-gate 
18847c478bd9Sstevel@tonic-gate int
18857c478bd9Sstevel@tonic-gate ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type,
18867c478bd9Sstevel@tonic-gate     minor_t minor_num, char *node_type, int flag);
18877c478bd9Sstevel@tonic-gate 
18887c478bd9Sstevel@tonic-gate int
18897c478bd9Sstevel@tonic-gate ddi_create_priv_minor_node(dev_info_t *dip, char *name, int spec_type,
18907c478bd9Sstevel@tonic-gate     minor_t minor_num, char *node_type, int flag,
18917c478bd9Sstevel@tonic-gate     const char *rdpriv, const char *wrpriv, mode_t priv_mode);
18927c478bd9Sstevel@tonic-gate 
18937c478bd9Sstevel@tonic-gate void
18947c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dev_info_t *dip, char *name);
18957c478bd9Sstevel@tonic-gate 
18967c478bd9Sstevel@tonic-gate int
18977c478bd9Sstevel@tonic-gate ddi_in_panic(void);
18987c478bd9Sstevel@tonic-gate 
18997c478bd9Sstevel@tonic-gate int
19007c478bd9Sstevel@tonic-gate ddi_streams_driver(dev_info_t *dip);
19017c478bd9Sstevel@tonic-gate 
19027c478bd9Sstevel@tonic-gate /*
19037c478bd9Sstevel@tonic-gate  * DDI wrappers for ffs and fls
19047c478bd9Sstevel@tonic-gate  */
19057c478bd9Sstevel@tonic-gate int
19067c478bd9Sstevel@tonic-gate ddi_ffs(long mask);
19077c478bd9Sstevel@tonic-gate 
19087c478bd9Sstevel@tonic-gate int
19097c478bd9Sstevel@tonic-gate ddi_fls(long mask);
19107c478bd9Sstevel@tonic-gate 
19117c478bd9Sstevel@tonic-gate /*
19127c478bd9Sstevel@tonic-gate  * The next five routines comprise generic storage management utilities
19137c478bd9Sstevel@tonic-gate  * for driver soft state structures.
19147c478bd9Sstevel@tonic-gate  */
19157c478bd9Sstevel@tonic-gate 
19167c478bd9Sstevel@tonic-gate /*
19177c478bd9Sstevel@tonic-gate  * Allocate a set of pointers to 'n_items' objects of size 'size'
19187c478bd9Sstevel@tonic-gate  * bytes.  Each pointer is initialized to nil. 'n_items' is a hint i.e.
19197c478bd9Sstevel@tonic-gate  * zero is allowed.
19207c478bd9Sstevel@tonic-gate  */
19217c478bd9Sstevel@tonic-gate int
19227c478bd9Sstevel@tonic-gate ddi_soft_state_init(void **state_p, size_t size, size_t n_items);
19237c478bd9Sstevel@tonic-gate 
19247c478bd9Sstevel@tonic-gate /*
19257c478bd9Sstevel@tonic-gate  * Allocate a state structure of size 'size' to be associated
19267c478bd9Sstevel@tonic-gate  * with item 'item'.
19277c478bd9Sstevel@tonic-gate  */
19287c478bd9Sstevel@tonic-gate int
19297c478bd9Sstevel@tonic-gate ddi_soft_state_zalloc(void *state, int item);
19307c478bd9Sstevel@tonic-gate 
19317c478bd9Sstevel@tonic-gate /*
19327c478bd9Sstevel@tonic-gate  * Fetch a pointer to the allocated soft state structure
19337c478bd9Sstevel@tonic-gate  * corresponding to 'item.'
19347c478bd9Sstevel@tonic-gate  */
19357c478bd9Sstevel@tonic-gate void *
19367c478bd9Sstevel@tonic-gate ddi_get_soft_state(void *state, int item);
19377c478bd9Sstevel@tonic-gate 
19387c478bd9Sstevel@tonic-gate /*
19397c478bd9Sstevel@tonic-gate  * Free the state structure corresponding to 'item.'
19407c478bd9Sstevel@tonic-gate  */
19417c478bd9Sstevel@tonic-gate void
19427c478bd9Sstevel@tonic-gate ddi_soft_state_free(void *state, int item);
19437c478bd9Sstevel@tonic-gate 
19447c478bd9Sstevel@tonic-gate /*
19457c478bd9Sstevel@tonic-gate  * Free the handle, and any associated soft state structures.
19467c478bd9Sstevel@tonic-gate  */
19477c478bd9Sstevel@tonic-gate void
19487c478bd9Sstevel@tonic-gate ddi_soft_state_fini(void **state_p);
19497c478bd9Sstevel@tonic-gate 
19507c478bd9Sstevel@tonic-gate /*
19517c478bd9Sstevel@tonic-gate  * Set the addr field of the name in dip to name
19527c478bd9Sstevel@tonic-gate  */
19537c478bd9Sstevel@tonic-gate void
19547c478bd9Sstevel@tonic-gate ddi_set_name_addr(dev_info_t *dip, char *name);
19557c478bd9Sstevel@tonic-gate 
19567c478bd9Sstevel@tonic-gate /*
19577c478bd9Sstevel@tonic-gate  * Get the address part of the name.
19587c478bd9Sstevel@tonic-gate  */
19597c478bd9Sstevel@tonic-gate char *
19607c478bd9Sstevel@tonic-gate ddi_get_name_addr(dev_info_t *dip);
19617c478bd9Sstevel@tonic-gate 
19627c478bd9Sstevel@tonic-gate void
19637c478bd9Sstevel@tonic-gate ddi_set_parent_data(dev_info_t *dip, void *pd);
19647c478bd9Sstevel@tonic-gate 
19657c478bd9Sstevel@tonic-gate void *
19667c478bd9Sstevel@tonic-gate ddi_get_parent_data(dev_info_t *dip);
19677c478bd9Sstevel@tonic-gate 
19687c478bd9Sstevel@tonic-gate int
19697c478bd9Sstevel@tonic-gate ddi_initchild(dev_info_t *parent, dev_info_t *proto);
19707c478bd9Sstevel@tonic-gate 
19717c478bd9Sstevel@tonic-gate int
19727c478bd9Sstevel@tonic-gate ddi_uninitchild(dev_info_t *dip);
19737c478bd9Sstevel@tonic-gate 
19747c478bd9Sstevel@tonic-gate major_t
19757c478bd9Sstevel@tonic-gate ddi_name_to_major(char *name);
19767c478bd9Sstevel@tonic-gate 
19777c478bd9Sstevel@tonic-gate char *
19787c478bd9Sstevel@tonic-gate ddi_major_to_name(major_t major);
19797c478bd9Sstevel@tonic-gate 
19807c478bd9Sstevel@tonic-gate char *
19817c478bd9Sstevel@tonic-gate ddi_deviname(dev_info_t *dip, char *name);
19827c478bd9Sstevel@tonic-gate 
19837c478bd9Sstevel@tonic-gate char *
19847c478bd9Sstevel@tonic-gate ddi_pathname(dev_info_t *dip, char *path);
19857c478bd9Sstevel@tonic-gate 
19867c478bd9Sstevel@tonic-gate int
19877c478bd9Sstevel@tonic-gate ddi_dev_pathname(dev_t devt, int spec_type, char *name);
19887c478bd9Sstevel@tonic-gate 
19897c478bd9Sstevel@tonic-gate dev_t
19907c478bd9Sstevel@tonic-gate ddi_pathname_to_dev_t(char *pathname);
19917c478bd9Sstevel@tonic-gate 
19927c478bd9Sstevel@tonic-gate /*
19937c478bd9Sstevel@tonic-gate  * High resolution system timer functions.
19947c478bd9Sstevel@tonic-gate  *
19957c478bd9Sstevel@tonic-gate  * These functions are already in the kernel (see sys/time.h).
19967c478bd9Sstevel@tonic-gate  * The ddi supports the notion of a hrtime_t type and the
19977c478bd9Sstevel@tonic-gate  * functions gethrtime, hrtadd, hrtsub and hrtcmp.
19987c478bd9Sstevel@tonic-gate  */
19997c478bd9Sstevel@tonic-gate 
20007c478bd9Sstevel@tonic-gate 
20017c478bd9Sstevel@tonic-gate /*
20027c478bd9Sstevel@tonic-gate  * Nexus wrapper functions
20037c478bd9Sstevel@tonic-gate  *
20047c478bd9Sstevel@tonic-gate  * These functions are for entries in a bus nexus driver's bus_ops
20057c478bd9Sstevel@tonic-gate  * structure for when the driver doesn't have such a function and
20067c478bd9Sstevel@tonic-gate  * doesn't wish to prohibit such a function from existing. They
20077c478bd9Sstevel@tonic-gate  * may also be called to start passing a request up the dev_info
20087c478bd9Sstevel@tonic-gate  * tree.
20097c478bd9Sstevel@tonic-gate  */
20107c478bd9Sstevel@tonic-gate 
20117c478bd9Sstevel@tonic-gate /*
20127c478bd9Sstevel@tonic-gate  * bus_ctl wrapper
20137c478bd9Sstevel@tonic-gate  */
20147c478bd9Sstevel@tonic-gate 
20157c478bd9Sstevel@tonic-gate int
20167c478bd9Sstevel@tonic-gate ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v);
20177c478bd9Sstevel@tonic-gate 
20187c478bd9Sstevel@tonic-gate /*
20197c478bd9Sstevel@tonic-gate  * bus_dma_map wrapper
20207c478bd9Sstevel@tonic-gate  */
20217c478bd9Sstevel@tonic-gate 
20227c478bd9Sstevel@tonic-gate int
20237c478bd9Sstevel@tonic-gate ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
20247c478bd9Sstevel@tonic-gate 	struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
20257c478bd9Sstevel@tonic-gate 
20267c478bd9Sstevel@tonic-gate int
20277c478bd9Sstevel@tonic-gate ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
20287c478bd9Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
20297c478bd9Sstevel@tonic-gate 
20307c478bd9Sstevel@tonic-gate int
20317c478bd9Sstevel@tonic-gate ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
20327c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle);
20337c478bd9Sstevel@tonic-gate 
20347c478bd9Sstevel@tonic-gate int
20357c478bd9Sstevel@tonic-gate ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
20367c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
20377c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cp, uint_t *ccountp);
20387c478bd9Sstevel@tonic-gate 
20397c478bd9Sstevel@tonic-gate int
20407c478bd9Sstevel@tonic-gate ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
20417c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle);
20427c478bd9Sstevel@tonic-gate 
20437c478bd9Sstevel@tonic-gate int
20447c478bd9Sstevel@tonic-gate ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip,
20457c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle, off_t off, size_t len,
20467c478bd9Sstevel@tonic-gate 	uint_t cache_flags);
20477c478bd9Sstevel@tonic-gate 
20487c478bd9Sstevel@tonic-gate int
20497c478bd9Sstevel@tonic-gate ddi_dma_win(dev_info_t *dip, dev_info_t *rdip,
20507c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t handle, uint_t win, off_t *offp,
20517c478bd9Sstevel@tonic-gate 	size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20527c478bd9Sstevel@tonic-gate 
20537c478bd9Sstevel@tonic-gate /*
20547c478bd9Sstevel@tonic-gate  * bus_dma_ctl wrapper
20557c478bd9Sstevel@tonic-gate  */
20567c478bd9Sstevel@tonic-gate 
20577c478bd9Sstevel@tonic-gate int
20587c478bd9Sstevel@tonic-gate ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
20597c478bd9Sstevel@tonic-gate 	enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
20607c478bd9Sstevel@tonic-gate 	caddr_t *objp, uint_t flags);
20617c478bd9Sstevel@tonic-gate 
20627c478bd9Sstevel@tonic-gate /*
20637c478bd9Sstevel@tonic-gate  * dvma support for networking drivers
20647c478bd9Sstevel@tonic-gate  */
20657c478bd9Sstevel@tonic-gate 
20667c478bd9Sstevel@tonic-gate unsigned long
20677c478bd9Sstevel@tonic-gate dvma_pagesize(dev_info_t *dip);
20687c478bd9Sstevel@tonic-gate 
20697c478bd9Sstevel@tonic-gate int
20707c478bd9Sstevel@tonic-gate dvma_reserve(dev_info_t *dip,  ddi_dma_lim_t *limp, uint_t pages,
20717c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
20727c478bd9Sstevel@tonic-gate 
20737c478bd9Sstevel@tonic-gate void
20747c478bd9Sstevel@tonic-gate dvma_release(ddi_dma_handle_t h);
20757c478bd9Sstevel@tonic-gate 
20767c478bd9Sstevel@tonic-gate void
20777c478bd9Sstevel@tonic-gate dvma_kaddr_load(ddi_dma_handle_t h, caddr_t a, uint_t len, uint_t index,
20787c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t *cp);
20797c478bd9Sstevel@tonic-gate 
20807c478bd9Sstevel@tonic-gate void
20817c478bd9Sstevel@tonic-gate dvma_unload(ddi_dma_handle_t h, uint_t objindex, uint_t type);
20827c478bd9Sstevel@tonic-gate 
20837c478bd9Sstevel@tonic-gate void
20847c478bd9Sstevel@tonic-gate dvma_sync(ddi_dma_handle_t h, uint_t objindex, uint_t type);
20857c478bd9Sstevel@tonic-gate 
20867c478bd9Sstevel@tonic-gate /*
20877c478bd9Sstevel@tonic-gate  * Layered driver support
20887c478bd9Sstevel@tonic-gate  */
20897c478bd9Sstevel@tonic-gate 
20907c478bd9Sstevel@tonic-gate extern int ddi_copyin(const void *, void *, size_t, int);
20917c478bd9Sstevel@tonic-gate extern int ddi_copyout(const void *, void *, size_t, int);
20927c478bd9Sstevel@tonic-gate 
20937c478bd9Sstevel@tonic-gate /*
20947c478bd9Sstevel@tonic-gate  * Send signals to processes
20957c478bd9Sstevel@tonic-gate  */
20967c478bd9Sstevel@tonic-gate extern void *proc_ref(void);
20977c478bd9Sstevel@tonic-gate extern void proc_unref(void *pref);
20987c478bd9Sstevel@tonic-gate extern int proc_signal(void *pref, int sig);
20997c478bd9Sstevel@tonic-gate 
21007c478bd9Sstevel@tonic-gate /* I/O port access routines */
21017c478bd9Sstevel@tonic-gate extern uint8_t inb(int port);
21027c478bd9Sstevel@tonic-gate extern uint16_t inw(int port);
21037c478bd9Sstevel@tonic-gate extern uint32_t inl(int port);
21047c478bd9Sstevel@tonic-gate extern void repinsb(int port, uint8_t *addr, int count);
21057c478bd9Sstevel@tonic-gate extern void repinsw(int port, uint16_t *addr, int count);
21067c478bd9Sstevel@tonic-gate extern void repinsd(int port, uint32_t *addr, int count);
21077c478bd9Sstevel@tonic-gate extern void outb(int port, uint8_t value);
21087c478bd9Sstevel@tonic-gate extern void outw(int port, uint16_t value);
21097c478bd9Sstevel@tonic-gate extern void outl(int port, uint32_t value);
21107c478bd9Sstevel@tonic-gate extern void repoutsb(int port, uint8_t *addr, int count);
21117c478bd9Sstevel@tonic-gate extern void repoutsw(int port, uint16_t *addr, int count);
21127c478bd9Sstevel@tonic-gate extern void repoutsd(int port, uint32_t *addr, int count);
21137c478bd9Sstevel@tonic-gate 
21147c478bd9Sstevel@tonic-gate /*
21157c478bd9Sstevel@tonic-gate  * Console bell routines
21167c478bd9Sstevel@tonic-gate  */
21177c478bd9Sstevel@tonic-gate extern void ddi_ring_console_bell(clock_t duration);
21187c478bd9Sstevel@tonic-gate extern void ddi_set_console_bell(void (*bellfunc)(clock_t duration));
21197c478bd9Sstevel@tonic-gate 
21207c478bd9Sstevel@tonic-gate /*
21217c478bd9Sstevel@tonic-gate  * Fault-related functions
21227c478bd9Sstevel@tonic-gate  */
21237c478bd9Sstevel@tonic-gate extern int ddi_check_acc_handle(ddi_acc_handle_t);
21247c478bd9Sstevel@tonic-gate extern int ddi_check_dma_handle(ddi_dma_handle_t);
21257c478bd9Sstevel@tonic-gate extern void ddi_dev_report_fault(dev_info_t *, ddi_fault_impact_t,
21267c478bd9Sstevel@tonic-gate 	ddi_fault_location_t, const char *);
21277c478bd9Sstevel@tonic-gate extern ddi_devstate_t ddi_get_devstate(dev_info_t *);
21287c478bd9Sstevel@tonic-gate 
21297c478bd9Sstevel@tonic-gate /*
21307c478bd9Sstevel@tonic-gate  * Miscellaneous redefines
21317c478bd9Sstevel@tonic-gate  */
21327c478bd9Sstevel@tonic-gate #define	uiophysio	physio
21337c478bd9Sstevel@tonic-gate 
21347c478bd9Sstevel@tonic-gate /*
21357c478bd9Sstevel@tonic-gate  * utilities - "reg" mapping and all common portable data access functions
21367c478bd9Sstevel@tonic-gate  */
21377c478bd9Sstevel@tonic-gate 
21387c478bd9Sstevel@tonic-gate /*
21397c478bd9Sstevel@tonic-gate  * error code from ddi_regs_map_setup
21407c478bd9Sstevel@tonic-gate  */
21417c478bd9Sstevel@tonic-gate 
21427c478bd9Sstevel@tonic-gate #define	DDI_REGS_ACC_CONFLICT	(-10)
21437c478bd9Sstevel@tonic-gate 
21447c478bd9Sstevel@tonic-gate /*
21457c478bd9Sstevel@tonic-gate  * Device address advance flags
21467c478bd9Sstevel@tonic-gate  */
21477c478bd9Sstevel@tonic-gate 
21487c478bd9Sstevel@tonic-gate #define	 DDI_DEV_NO_AUTOINCR	0x0000
21497c478bd9Sstevel@tonic-gate #define	 DDI_DEV_AUTOINCR	0x0001
21507c478bd9Sstevel@tonic-gate 
21517c478bd9Sstevel@tonic-gate int
21527c478bd9Sstevel@tonic-gate ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber, caddr_t *addrp,
21537c478bd9Sstevel@tonic-gate 	offset_t offset, offset_t len, ddi_device_acc_attr_t *accattrp,
21547c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t *handle);
21557c478bd9Sstevel@tonic-gate 
21567c478bd9Sstevel@tonic-gate void
21577c478bd9Sstevel@tonic-gate ddi_regs_map_free(ddi_acc_handle_t *handle);
21587c478bd9Sstevel@tonic-gate 
21597c478bd9Sstevel@tonic-gate /*
21607c478bd9Sstevel@tonic-gate  * these are the prototypes for the common portable data access functions
21617c478bd9Sstevel@tonic-gate  */
21627c478bd9Sstevel@tonic-gate 
21637c478bd9Sstevel@tonic-gate #ifdef _LP64
21647c478bd9Sstevel@tonic-gate 
21657c478bd9Sstevel@tonic-gate uint8_t
21667c478bd9Sstevel@tonic-gate ddi_get8(ddi_acc_handle_t handle, uint8_t *addr);
21677c478bd9Sstevel@tonic-gate 
21687c478bd9Sstevel@tonic-gate uint16_t
21697c478bd9Sstevel@tonic-gate ddi_get16(ddi_acc_handle_t handle, uint16_t *addr);
21707c478bd9Sstevel@tonic-gate 
21717c478bd9Sstevel@tonic-gate uint32_t
21727c478bd9Sstevel@tonic-gate ddi_get32(ddi_acc_handle_t handle, uint32_t *addr);
21737c478bd9Sstevel@tonic-gate 
21747c478bd9Sstevel@tonic-gate uint64_t
21757c478bd9Sstevel@tonic-gate ddi_get64(ddi_acc_handle_t handle, uint64_t *addr);
21767c478bd9Sstevel@tonic-gate 
21777c478bd9Sstevel@tonic-gate void
21787c478bd9Sstevel@tonic-gate ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
21797c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
21807c478bd9Sstevel@tonic-gate 
21817c478bd9Sstevel@tonic-gate void
21827c478bd9Sstevel@tonic-gate ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
21837c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
21847c478bd9Sstevel@tonic-gate 
21857c478bd9Sstevel@tonic-gate void
21867c478bd9Sstevel@tonic-gate ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
21877c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
21887c478bd9Sstevel@tonic-gate 
21897c478bd9Sstevel@tonic-gate void
21907c478bd9Sstevel@tonic-gate ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
21917c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
21927c478bd9Sstevel@tonic-gate 
21937c478bd9Sstevel@tonic-gate void
21947c478bd9Sstevel@tonic-gate ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value);
21957c478bd9Sstevel@tonic-gate 
21967c478bd9Sstevel@tonic-gate void
21977c478bd9Sstevel@tonic-gate ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value);
21987c478bd9Sstevel@tonic-gate 
21997c478bd9Sstevel@tonic-gate void
22007c478bd9Sstevel@tonic-gate ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value);
22017c478bd9Sstevel@tonic-gate 
22027c478bd9Sstevel@tonic-gate void
22037c478bd9Sstevel@tonic-gate ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value);
22047c478bd9Sstevel@tonic-gate 
22057c478bd9Sstevel@tonic-gate void
22067c478bd9Sstevel@tonic-gate ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
22077c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22087c478bd9Sstevel@tonic-gate void
22097c478bd9Sstevel@tonic-gate ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
22107c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22117c478bd9Sstevel@tonic-gate void
22127c478bd9Sstevel@tonic-gate ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
22137c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22147c478bd9Sstevel@tonic-gate 
22157c478bd9Sstevel@tonic-gate void
22167c478bd9Sstevel@tonic-gate ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
22177c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22187c478bd9Sstevel@tonic-gate 
22197c478bd9Sstevel@tonic-gate #else /* _ILP32 */
22207c478bd9Sstevel@tonic-gate 
22217c478bd9Sstevel@tonic-gate uint8_t
22227c478bd9Sstevel@tonic-gate ddi_getb(ddi_acc_handle_t handle, uint8_t *addr);
22237c478bd9Sstevel@tonic-gate #define	ddi_get8	ddi_getb
22247c478bd9Sstevel@tonic-gate 
22257c478bd9Sstevel@tonic-gate uint16_t
22267c478bd9Sstevel@tonic-gate ddi_getw(ddi_acc_handle_t handle, uint16_t *addr);
22277c478bd9Sstevel@tonic-gate #define	ddi_get16	ddi_getw
22287c478bd9Sstevel@tonic-gate 
22297c478bd9Sstevel@tonic-gate uint32_t
22307c478bd9Sstevel@tonic-gate ddi_getl(ddi_acc_handle_t handle, uint32_t *addr);
22317c478bd9Sstevel@tonic-gate #define	ddi_get32	ddi_getl
22327c478bd9Sstevel@tonic-gate 
22337c478bd9Sstevel@tonic-gate uint64_t
22347c478bd9Sstevel@tonic-gate ddi_getll(ddi_acc_handle_t handle, uint64_t *addr);
22357c478bd9Sstevel@tonic-gate #define	ddi_get64	ddi_getll
22367c478bd9Sstevel@tonic-gate 
22377c478bd9Sstevel@tonic-gate void
22387c478bd9Sstevel@tonic-gate ddi_rep_getb(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
22397c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22407c478bd9Sstevel@tonic-gate #define	ddi_rep_get8	ddi_rep_getb
22417c478bd9Sstevel@tonic-gate 
22427c478bd9Sstevel@tonic-gate void
22437c478bd9Sstevel@tonic-gate ddi_rep_getw(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
22447c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22457c478bd9Sstevel@tonic-gate #define	ddi_rep_get16	ddi_rep_getw
22467c478bd9Sstevel@tonic-gate 
22477c478bd9Sstevel@tonic-gate void
22487c478bd9Sstevel@tonic-gate ddi_rep_getl(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
22497c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22507c478bd9Sstevel@tonic-gate #define	ddi_rep_get32	ddi_rep_getl
22517c478bd9Sstevel@tonic-gate 
22527c478bd9Sstevel@tonic-gate void
22537c478bd9Sstevel@tonic-gate ddi_rep_getll(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
22547c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22557c478bd9Sstevel@tonic-gate #define	ddi_rep_get64	ddi_rep_getll
22567c478bd9Sstevel@tonic-gate 
22577c478bd9Sstevel@tonic-gate void
22587c478bd9Sstevel@tonic-gate ddi_putb(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value);
22597c478bd9Sstevel@tonic-gate #define	ddi_put8	ddi_putb
22607c478bd9Sstevel@tonic-gate 
22617c478bd9Sstevel@tonic-gate void
22627c478bd9Sstevel@tonic-gate ddi_putw(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value);
22637c478bd9Sstevel@tonic-gate #define	ddi_put16	ddi_putw
22647c478bd9Sstevel@tonic-gate 
22657c478bd9Sstevel@tonic-gate void
22667c478bd9Sstevel@tonic-gate ddi_putl(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value);
22677c478bd9Sstevel@tonic-gate #define	ddi_put32	ddi_putl
22687c478bd9Sstevel@tonic-gate 
22697c478bd9Sstevel@tonic-gate void
22707c478bd9Sstevel@tonic-gate ddi_putll(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value);
22717c478bd9Sstevel@tonic-gate #define	ddi_put64	ddi_putll
22727c478bd9Sstevel@tonic-gate 
22737c478bd9Sstevel@tonic-gate void
22747c478bd9Sstevel@tonic-gate ddi_rep_putb(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
22757c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22767c478bd9Sstevel@tonic-gate #define	ddi_rep_put8	ddi_rep_putb
22777c478bd9Sstevel@tonic-gate 
22787c478bd9Sstevel@tonic-gate void
22797c478bd9Sstevel@tonic-gate ddi_rep_putw(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
22807c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22817c478bd9Sstevel@tonic-gate #define	ddi_rep_put16	ddi_rep_putw
22827c478bd9Sstevel@tonic-gate 
22837c478bd9Sstevel@tonic-gate void
22847c478bd9Sstevel@tonic-gate ddi_rep_putl(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
22857c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22867c478bd9Sstevel@tonic-gate #define	ddi_rep_put32	ddi_rep_putl
22877c478bd9Sstevel@tonic-gate 
22887c478bd9Sstevel@tonic-gate void
22897c478bd9Sstevel@tonic-gate ddi_rep_putll(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
22907c478bd9Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22917c478bd9Sstevel@tonic-gate #define	ddi_rep_put64	ddi_rep_putll
22927c478bd9Sstevel@tonic-gate 
22937c478bd9Sstevel@tonic-gate #endif /* _LP64 */
22947c478bd9Sstevel@tonic-gate 
22957c478bd9Sstevel@tonic-gate /*
22967c478bd9Sstevel@tonic-gate  * these are special device handling functions
22977c478bd9Sstevel@tonic-gate  */
22987c478bd9Sstevel@tonic-gate int
22997c478bd9Sstevel@tonic-gate ddi_device_zero(ddi_acc_handle_t handle, caddr_t dev_addr,
23007c478bd9Sstevel@tonic-gate 	size_t bytecount, ssize_t dev_advcnt, uint_t dev_datasz);
23017c478bd9Sstevel@tonic-gate 
23027c478bd9Sstevel@tonic-gate int
23037c478bd9Sstevel@tonic-gate ddi_device_copy(
23047c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t src_handle, caddr_t src_addr, ssize_t src_advcnt,
23057c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t dest_handle, caddr_t dest_addr, ssize_t dest_advcnt,
23067c478bd9Sstevel@tonic-gate 	size_t bytecount, uint_t dev_datasz);
23077c478bd9Sstevel@tonic-gate 
23087c478bd9Sstevel@tonic-gate /*
23097c478bd9Sstevel@tonic-gate  * these are software byte swapping functions
23107c478bd9Sstevel@tonic-gate  */
23117c478bd9Sstevel@tonic-gate uint16_t
23127c478bd9Sstevel@tonic-gate ddi_swap16(uint16_t value);
23137c478bd9Sstevel@tonic-gate 
23147c478bd9Sstevel@tonic-gate uint32_t
23157c478bd9Sstevel@tonic-gate ddi_swap32(uint32_t value);
23167c478bd9Sstevel@tonic-gate 
23177c478bd9Sstevel@tonic-gate uint64_t
23187c478bd9Sstevel@tonic-gate ddi_swap64(uint64_t value);
23197c478bd9Sstevel@tonic-gate 
23207c478bd9Sstevel@tonic-gate /*
23217c478bd9Sstevel@tonic-gate  * these are the prototypes for PCI local bus functions
23227c478bd9Sstevel@tonic-gate  */
23237c478bd9Sstevel@tonic-gate /*
23247c478bd9Sstevel@tonic-gate  * PCI power management capabilities reporting in addition to those
23257c478bd9Sstevel@tonic-gate  * provided by the PCI Power Management Specification.
23267c478bd9Sstevel@tonic-gate  */
23277c478bd9Sstevel@tonic-gate #define	PCI_PM_IDLESPEED	0x1		/* clock for idle dev - cap  */
23287c478bd9Sstevel@tonic-gate #define	PCI_PM_IDLESPEED_ANY	(void *)-1	/* any clock for idle dev */
23297c478bd9Sstevel@tonic-gate #define	PCI_PM_IDLESPEED_NONE	(void *)-2	/* regular clock for idle dev */
23307c478bd9Sstevel@tonic-gate 
23317c478bd9Sstevel@tonic-gate int
23327c478bd9Sstevel@tonic-gate pci_config_setup(dev_info_t *dip, ddi_acc_handle_t *handle);
23337c478bd9Sstevel@tonic-gate 
23347c478bd9Sstevel@tonic-gate void
23357c478bd9Sstevel@tonic-gate pci_config_teardown(ddi_acc_handle_t *handle);
23367c478bd9Sstevel@tonic-gate 
23377c478bd9Sstevel@tonic-gate #ifdef _LP64
23387c478bd9Sstevel@tonic-gate 
23397c478bd9Sstevel@tonic-gate uint8_t
23407c478bd9Sstevel@tonic-gate pci_config_get8(ddi_acc_handle_t handle, off_t offset);
23417c478bd9Sstevel@tonic-gate 
23427c478bd9Sstevel@tonic-gate uint16_t
23437c478bd9Sstevel@tonic-gate pci_config_get16(ddi_acc_handle_t handle, off_t offset);
23447c478bd9Sstevel@tonic-gate 
23457c478bd9Sstevel@tonic-gate uint32_t
23467c478bd9Sstevel@tonic-gate pci_config_get32(ddi_acc_handle_t handle, off_t offset);
23477c478bd9Sstevel@tonic-gate 
23487c478bd9Sstevel@tonic-gate uint64_t
23497c478bd9Sstevel@tonic-gate pci_config_get64(ddi_acc_handle_t handle, off_t offset);
23507c478bd9Sstevel@tonic-gate 
23517c478bd9Sstevel@tonic-gate void
23527c478bd9Sstevel@tonic-gate pci_config_put8(ddi_acc_handle_t handle, off_t offset, uint8_t value);
23537c478bd9Sstevel@tonic-gate 
23547c478bd9Sstevel@tonic-gate void
23557c478bd9Sstevel@tonic-gate pci_config_put16(ddi_acc_handle_t handle, off_t offset, uint16_t value);
23567c478bd9Sstevel@tonic-gate 
23577c478bd9Sstevel@tonic-gate void
23587c478bd9Sstevel@tonic-gate pci_config_put32(ddi_acc_handle_t handle, off_t offset, uint32_t value);
23597c478bd9Sstevel@tonic-gate 
23607c478bd9Sstevel@tonic-gate void
23617c478bd9Sstevel@tonic-gate pci_config_put64(ddi_acc_handle_t handle, off_t offset, uint64_t value);
23627c478bd9Sstevel@tonic-gate 
23637c478bd9Sstevel@tonic-gate #else /* _ILP32 */
23647c478bd9Sstevel@tonic-gate 
23657c478bd9Sstevel@tonic-gate uint8_t
23667c478bd9Sstevel@tonic-gate pci_config_getb(ddi_acc_handle_t handle, off_t offset);
23677c478bd9Sstevel@tonic-gate #define	pci_config_get8		pci_config_getb
23687c478bd9Sstevel@tonic-gate 
23697c478bd9Sstevel@tonic-gate uint16_t
23707c478bd9Sstevel@tonic-gate pci_config_getw(ddi_acc_handle_t handle, off_t offset);
23717c478bd9Sstevel@tonic-gate #define	pci_config_get16	pci_config_getw
23727c478bd9Sstevel@tonic-gate 
23737c478bd9Sstevel@tonic-gate uint32_t
23747c478bd9Sstevel@tonic-gate pci_config_getl(ddi_acc_handle_t handle, off_t offset);
23757c478bd9Sstevel@tonic-gate #define	pci_config_get32	pci_config_getl
23767c478bd9Sstevel@tonic-gate 
23777c478bd9Sstevel@tonic-gate uint64_t
23787c478bd9Sstevel@tonic-gate pci_config_getll(ddi_acc_handle_t handle, off_t offset);
23797c478bd9Sstevel@tonic-gate #define	pci_config_get64	pci_config_getll
23807c478bd9Sstevel@tonic-gate 
23817c478bd9Sstevel@tonic-gate void
23827c478bd9Sstevel@tonic-gate pci_config_putb(ddi_acc_handle_t handle, off_t offset, uint8_t value);
23837c478bd9Sstevel@tonic-gate #define	pci_config_put8		pci_config_putb
23847c478bd9Sstevel@tonic-gate 
23857c478bd9Sstevel@tonic-gate void
23867c478bd9Sstevel@tonic-gate pci_config_putw(ddi_acc_handle_t handle, off_t offset, uint16_t value);
23877c478bd9Sstevel@tonic-gate #define	pci_config_put16	pci_config_putw
23887c478bd9Sstevel@tonic-gate 
23897c478bd9Sstevel@tonic-gate void
23907c478bd9Sstevel@tonic-gate pci_config_putl(ddi_acc_handle_t handle, off_t offset, uint32_t value);
23917c478bd9Sstevel@tonic-gate #define	pci_config_put32	pci_config_putl
23927c478bd9Sstevel@tonic-gate 
23937c478bd9Sstevel@tonic-gate void
23947c478bd9Sstevel@tonic-gate pci_config_putll(ddi_acc_handle_t handle, off_t offset, uint64_t value);
23957c478bd9Sstevel@tonic-gate #define	pci_config_put64	pci_config_putll
23967c478bd9Sstevel@tonic-gate 
23977c478bd9Sstevel@tonic-gate #endif /* _LP64 */
23987c478bd9Sstevel@tonic-gate 
23997c478bd9Sstevel@tonic-gate int
24007c478bd9Sstevel@tonic-gate pci_report_pmcap(dev_info_t *dip, int cap, void *arg);
24017c478bd9Sstevel@tonic-gate 
24027c478bd9Sstevel@tonic-gate int
24037c478bd9Sstevel@tonic-gate pci_restore_config_regs(dev_info_t *dip);
24047c478bd9Sstevel@tonic-gate 
24057c478bd9Sstevel@tonic-gate int
24067c478bd9Sstevel@tonic-gate pci_save_config_regs(dev_info_t *dip);
24077c478bd9Sstevel@tonic-gate 
24087c478bd9Sstevel@tonic-gate void
24097c478bd9Sstevel@tonic-gate pci_ereport_setup(dev_info_t *dip);
24107c478bd9Sstevel@tonic-gate 
24117c478bd9Sstevel@tonic-gate void
24127c478bd9Sstevel@tonic-gate pci_ereport_teardown(dev_info_t *dip);
24137c478bd9Sstevel@tonic-gate 
24147c478bd9Sstevel@tonic-gate void
24157c478bd9Sstevel@tonic-gate pci_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status);
24167c478bd9Sstevel@tonic-gate 
24177c478bd9Sstevel@tonic-gate void
24187c478bd9Sstevel@tonic-gate pci_bdg_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status);
24197c478bd9Sstevel@tonic-gate 
24207c478bd9Sstevel@tonic-gate int
24217c478bd9Sstevel@tonic-gate pci_bdg_check_status(dev_info_t *dip, ddi_fm_error_t *derr,
24227c478bd9Sstevel@tonic-gate     uint16_t pci_cfg_stat, uint16_t pci_cfg_sec_stat);
24237c478bd9Sstevel@tonic-gate 
24247c478bd9Sstevel@tonic-gate /*
24257c478bd9Sstevel@tonic-gate  * the prototype for the C Language Type Model inquiry.
24267c478bd9Sstevel@tonic-gate  */
24277c478bd9Sstevel@tonic-gate model_t	ddi_mmap_get_model(void);
24287c478bd9Sstevel@tonic-gate model_t	ddi_model_convert_from(model_t);
24297c478bd9Sstevel@tonic-gate 
24307c478bd9Sstevel@tonic-gate /*
24317c478bd9Sstevel@tonic-gate  * these are the prototypes for device id functions.
24327c478bd9Sstevel@tonic-gate  */
24337c478bd9Sstevel@tonic-gate int
24347c478bd9Sstevel@tonic-gate ddi_devid_valid(ddi_devid_t devid);
24357c478bd9Sstevel@tonic-gate 
24367c478bd9Sstevel@tonic-gate int
24377c478bd9Sstevel@tonic-gate ddi_devid_register(dev_info_t *dip, ddi_devid_t devid);
24387c478bd9Sstevel@tonic-gate 
24397c478bd9Sstevel@tonic-gate void
24407c478bd9Sstevel@tonic-gate ddi_devid_unregister(dev_info_t *dip);
24417c478bd9Sstevel@tonic-gate 
24427c478bd9Sstevel@tonic-gate int
24437c478bd9Sstevel@tonic-gate ddi_devid_init(dev_info_t *dip, ushort_t devid_type, ushort_t nbytes,
24447c478bd9Sstevel@tonic-gate     void *id, ddi_devid_t *ret_devid);
24457c478bd9Sstevel@tonic-gate 
24467c478bd9Sstevel@tonic-gate size_t
24477c478bd9Sstevel@tonic-gate ddi_devid_sizeof(ddi_devid_t devid);
24487c478bd9Sstevel@tonic-gate 
24497c478bd9Sstevel@tonic-gate void
24507c478bd9Sstevel@tonic-gate ddi_devid_free(ddi_devid_t devid);
24517c478bd9Sstevel@tonic-gate 
24527c478bd9Sstevel@tonic-gate int
24537c478bd9Sstevel@tonic-gate ddi_devid_compare(ddi_devid_t id1, ddi_devid_t id2);
24547c478bd9Sstevel@tonic-gate 
24557c478bd9Sstevel@tonic-gate int
24567c478bd9Sstevel@tonic-gate ddi_devid_scsi_encode(int version, char *driver_name,
24577c478bd9Sstevel@tonic-gate     uchar_t *inq, size_t inq_len, uchar_t *inq80, size_t inq80_len,
24587c478bd9Sstevel@tonic-gate     uchar_t *inq83, size_t inq83_len, ddi_devid_t *ret_devid);
24597c478bd9Sstevel@tonic-gate 
24607c478bd9Sstevel@tonic-gate char
24617c478bd9Sstevel@tonic-gate *ddi_devid_to_guid(ddi_devid_t devid);
24627c478bd9Sstevel@tonic-gate 
24637c478bd9Sstevel@tonic-gate void
24647c478bd9Sstevel@tonic-gate ddi_devid_free_guid(char *guid);
24657c478bd9Sstevel@tonic-gate 
24667c478bd9Sstevel@tonic-gate int
24677c478bd9Sstevel@tonic-gate ddi_lyr_get_devid(dev_t dev, ddi_devid_t *ret_devid);
24687c478bd9Sstevel@tonic-gate 
24697c478bd9Sstevel@tonic-gate int
24707c478bd9Sstevel@tonic-gate ddi_lyr_get_minor_name(dev_t dev, int spec_type, char **minor_name);
24717c478bd9Sstevel@tonic-gate 
24727c478bd9Sstevel@tonic-gate int
24737c478bd9Sstevel@tonic-gate ddi_lyr_devid_to_devlist(ddi_devid_t devid, char *minor_name, int *retndevs,
24747c478bd9Sstevel@tonic-gate     dev_t **retdevs);
24757c478bd9Sstevel@tonic-gate 
24767c478bd9Sstevel@tonic-gate void
24777c478bd9Sstevel@tonic-gate ddi_lyr_free_devlist(dev_t *devlist, int ndevs);
24787c478bd9Sstevel@tonic-gate 
24797c478bd9Sstevel@tonic-gate char *
24807c478bd9Sstevel@tonic-gate ddi_devid_str_encode(ddi_devid_t devid, char *minor_name);
24817c478bd9Sstevel@tonic-gate 
24827c478bd9Sstevel@tonic-gate int
24837c478bd9Sstevel@tonic-gate ddi_devid_str_decode(char *devidstr, ddi_devid_t *devidp, char **minor_namep);
24847c478bd9Sstevel@tonic-gate 
24857c478bd9Sstevel@tonic-gate void
24867c478bd9Sstevel@tonic-gate ddi_devid_str_free(char *devidstr);
24877c478bd9Sstevel@tonic-gate 
24887c478bd9Sstevel@tonic-gate int
24897c478bd9Sstevel@tonic-gate ddi_devid_str_compare(char *id1_str, char *id2_str);
24907c478bd9Sstevel@tonic-gate 
24917c478bd9Sstevel@tonic-gate /*
24927c478bd9Sstevel@tonic-gate  * Event to post to when a devinfo node is removed.
24937c478bd9Sstevel@tonic-gate  */
24947c478bd9Sstevel@tonic-gate #define	DDI_DEVI_REMOVE_EVENT		"DDI:DEVI_REMOVE"
24957c478bd9Sstevel@tonic-gate #define	DDI_DEVI_INSERT_EVENT		"DDI:DEVI_INSERT"
24967c478bd9Sstevel@tonic-gate #define	DDI_DEVI_BUS_RESET_EVENT	"DDI:DEVI_BUS_RESET"
24977c478bd9Sstevel@tonic-gate #define	DDI_DEVI_DEVICE_RESET_EVENT	"DDI:DEVI_DEVICE_RESET"
24987c478bd9Sstevel@tonic-gate 
24997c478bd9Sstevel@tonic-gate /*
25007c478bd9Sstevel@tonic-gate  * Invoke bus nexus driver's implementation of the
25017c478bd9Sstevel@tonic-gate  * (*bus_remove_eventcall)() interface to remove a registered
25027c478bd9Sstevel@tonic-gate  * callback handler for "event".
25037c478bd9Sstevel@tonic-gate  */
25047c478bd9Sstevel@tonic-gate int
25057c478bd9Sstevel@tonic-gate ddi_remove_event_handler(ddi_callback_id_t id);
25067c478bd9Sstevel@tonic-gate 
25077c478bd9Sstevel@tonic-gate /*
25087c478bd9Sstevel@tonic-gate  * Invoke bus nexus driver's implementation of the
25097c478bd9Sstevel@tonic-gate  * (*bus_add_eventcall)() interface to register a callback handler
25107c478bd9Sstevel@tonic-gate  * for "event".
25117c478bd9Sstevel@tonic-gate  */
25127c478bd9Sstevel@tonic-gate int
25137c478bd9Sstevel@tonic-gate ddi_add_event_handler(dev_info_t *dip, ddi_eventcookie_t event,
25147c478bd9Sstevel@tonic-gate 	void (*handler)(dev_info_t *, ddi_eventcookie_t, void *, void *),
25157c478bd9Sstevel@tonic-gate 	void *arg, ddi_callback_id_t *id);
25167c478bd9Sstevel@tonic-gate 
25177c478bd9Sstevel@tonic-gate /*
25187c478bd9Sstevel@tonic-gate  * Return a handle for event "name" by calling up the device tree
25197c478bd9Sstevel@tonic-gate  * hierarchy via  (*bus_get_eventcookie)() interface until claimed
25207c478bd9Sstevel@tonic-gate  * by a bus nexus or top of dev_info tree is reached.
25217c478bd9Sstevel@tonic-gate  */
25227c478bd9Sstevel@tonic-gate int
25237c478bd9Sstevel@tonic-gate ddi_get_eventcookie(dev_info_t *dip, char *name,
25247c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t *event_cookiep);
25257c478bd9Sstevel@tonic-gate 
25267c478bd9Sstevel@tonic-gate /*
25277c478bd9Sstevel@tonic-gate  * log a system event
25287c478bd9Sstevel@tonic-gate  */
25297c478bd9Sstevel@tonic-gate int
25307c478bd9Sstevel@tonic-gate ddi_log_sysevent(dev_info_t *dip, char *vendor, char *class_name,
25317c478bd9Sstevel@tonic-gate 	char *subclass_name, nvlist_t *attr_list, sysevent_id_t *eidp,
25327c478bd9Sstevel@tonic-gate 	int sleep_flag);
25337c478bd9Sstevel@tonic-gate 
25347c478bd9Sstevel@tonic-gate /*
25357c478bd9Sstevel@tonic-gate  * ddi_log_sysevent() vendors
25367c478bd9Sstevel@tonic-gate  */
25377c478bd9Sstevel@tonic-gate #define	DDI_VENDOR_SUNW		"SUNW"
25387c478bd9Sstevel@tonic-gate 
25397c478bd9Sstevel@tonic-gate /*
25407c478bd9Sstevel@tonic-gate  * Opaque task queue handle.
25417c478bd9Sstevel@tonic-gate  */
25427c478bd9Sstevel@tonic-gate typedef struct ddi_taskq ddi_taskq_t;
25437c478bd9Sstevel@tonic-gate 
25447c478bd9Sstevel@tonic-gate /*
25457c478bd9Sstevel@tonic-gate  * Use default system priority.
25467c478bd9Sstevel@tonic-gate  */
25477c478bd9Sstevel@tonic-gate #define	TASKQ_DEFAULTPRI -1
25487c478bd9Sstevel@tonic-gate 
25497c478bd9Sstevel@tonic-gate /*
25507c478bd9Sstevel@tonic-gate  * Create a task queue
25517c478bd9Sstevel@tonic-gate  */
25527c478bd9Sstevel@tonic-gate ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name,
25537c478bd9Sstevel@tonic-gate 	int nthreads, pri_t pri, uint_t cflags);
25547c478bd9Sstevel@tonic-gate 
25557c478bd9Sstevel@tonic-gate /*
25567c478bd9Sstevel@tonic-gate  * destroy a task queue
25577c478bd9Sstevel@tonic-gate  */
25587c478bd9Sstevel@tonic-gate void ddi_taskq_destroy(ddi_taskq_t *tq);
25597c478bd9Sstevel@tonic-gate 
25607c478bd9Sstevel@tonic-gate /*
25617c478bd9Sstevel@tonic-gate  * Dispatch a task to a task queue
25627c478bd9Sstevel@tonic-gate  */
25637c478bd9Sstevel@tonic-gate int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *),
25647c478bd9Sstevel@tonic-gate 	void *arg, uint_t dflags);
25657c478bd9Sstevel@tonic-gate 
25667c478bd9Sstevel@tonic-gate /*
25677c478bd9Sstevel@tonic-gate  * Wait for all previously scheduled tasks to complete.
25687c478bd9Sstevel@tonic-gate  */
25697c478bd9Sstevel@tonic-gate void ddi_taskq_wait(ddi_taskq_t *tq);
25707c478bd9Sstevel@tonic-gate 
25717c478bd9Sstevel@tonic-gate /*
25727c478bd9Sstevel@tonic-gate  * Suspend all task execution.
25737c478bd9Sstevel@tonic-gate  */
25747c478bd9Sstevel@tonic-gate void ddi_taskq_suspend(ddi_taskq_t *tq);
25757c478bd9Sstevel@tonic-gate 
25767c478bd9Sstevel@tonic-gate /*
25777c478bd9Sstevel@tonic-gate  * Resume task execution.
25787c478bd9Sstevel@tonic-gate  */
25797c478bd9Sstevel@tonic-gate void ddi_taskq_resume(ddi_taskq_t *tq);
25807c478bd9Sstevel@tonic-gate 
25817c478bd9Sstevel@tonic-gate /*
25827c478bd9Sstevel@tonic-gate  * Is task queue suspended?
25837c478bd9Sstevel@tonic-gate  */
25847c478bd9Sstevel@tonic-gate boolean_t ddi_taskq_suspended(ddi_taskq_t *tq);
25857c478bd9Sstevel@tonic-gate 
25867c478bd9Sstevel@tonic-gate /*
25877c478bd9Sstevel@tonic-gate  * Parse an interface name of the form <alphanumeric>##<numeric> where
25887c478bd9Sstevel@tonic-gate  * <numeric> is maximal.
25897c478bd9Sstevel@tonic-gate  */
25907c478bd9Sstevel@tonic-gate int ddi_parse(const char *, char *, uint_t *);
25917c478bd9Sstevel@tonic-gate 
25927c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
25937c478bd9Sstevel@tonic-gate 
25947c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
25957c478bd9Sstevel@tonic-gate }
25967c478bd9Sstevel@tonic-gate #endif
25977c478bd9Sstevel@tonic-gate 
25987c478bd9Sstevel@tonic-gate #endif	/* _SYS_SUNDDI_H */
2599