xref: /onnv-gate/usr/src/uts/common/sys/sunddi.h (revision 995:044a1b7c2e14)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
230Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SYS_SUNDDI_H
280Sstevel@tonic-gate #define	_SYS_SUNDDI_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate /*
330Sstevel@tonic-gate  * Sun Specific DDI definitions
340Sstevel@tonic-gate  */
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <sys/isa_defs.h>
370Sstevel@tonic-gate #include <sys/dditypes.h>
380Sstevel@tonic-gate #include <sys/ddipropdefs.h>
390Sstevel@tonic-gate #include <sys/devops.h>
400Sstevel@tonic-gate #include <sys/time.h>
410Sstevel@tonic-gate #include <sys/cmn_err.h>
420Sstevel@tonic-gate #include <sys/ddidevmap.h>
430Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
440Sstevel@tonic-gate #include <sys/ddi_implfuncs.h>
450Sstevel@tonic-gate #include <sys/ddi_isa.h>
460Sstevel@tonic-gate #include <sys/model.h>
470Sstevel@tonic-gate #include <sys/devctl.h>
480Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
490Sstevel@tonic-gate #include <sys/dma_engine.h>
500Sstevel@tonic-gate #endif
510Sstevel@tonic-gate #include <sys/sunpm.h>
520Sstevel@tonic-gate #include <sys/nvpair.h>
530Sstevel@tonic-gate #include <sys/sysevent.h>
540Sstevel@tonic-gate #include <sys/thread.h>
550Sstevel@tonic-gate #include <sys/stream.h>
560Sstevel@tonic-gate #if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL)
570Sstevel@tonic-gate #include <asm/sunddi.h>
580Sstevel@tonic-gate #endif
590Sstevel@tonic-gate 
600Sstevel@tonic-gate #ifdef	__cplusplus
610Sstevel@tonic-gate extern "C" {
620Sstevel@tonic-gate #endif
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate  * Generic Sun DDI definitions.
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #define	DDI_SUCCESS	(0)	/* successful return */
690Sstevel@tonic-gate #define	DDI_FAILURE	(-1)	/* unsuccessful return */
700Sstevel@tonic-gate #define	DDI_NOT_WELL_FORMED (-2)  /* A dev_info node is not valid */
710Sstevel@tonic-gate #define	DDI_EAGAIN	(-3)	/* not enough interrupt resources */
720Sstevel@tonic-gate #define	DDI_EINVAL	(-4)	/* invalid request or arguments */
730Sstevel@tonic-gate #define	DDI_ENOTSUP	(-5)	/* operation is not supported */
740Sstevel@tonic-gate #define	DDI_EPENDING	(-6)	/* operation or an event is pending */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate /*
770Sstevel@tonic-gate  * General-purpose DDI error return value definitions
780Sstevel@tonic-gate  */
790Sstevel@tonic-gate #define	DDI_ENOMEM		1	/* memory not available */
800Sstevel@tonic-gate #define	DDI_EBUSY		2	/* busy */
810Sstevel@tonic-gate #define	DDI_ETRANSPORT		3	/* transport down */
820Sstevel@tonic-gate #define	DDI_ECONTEXT		4	/* context error */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /*
860Sstevel@tonic-gate  * General DDI sleep/nosleep allocation flags
870Sstevel@tonic-gate  */
880Sstevel@tonic-gate #define	DDI_SLEEP	0
890Sstevel@tonic-gate #define	DDI_NOSLEEP	1
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * The following special nodeid values are reserved for use when creating
930Sstevel@tonic-gate  * nodes ONLY.  They specify the attributes of the DDI_NC_PSEUDO class node
940Sstevel@tonic-gate  * being created:
950Sstevel@tonic-gate  *
960Sstevel@tonic-gate  *  o	DEVI_PSEUDO_NODEID specifics a node without persistence.
970Sstevel@tonic-gate  *  o	DEVI_SID_NODEID specifies a node with persistence.
980Sstevel@tonic-gate  *
990Sstevel@tonic-gate  * A node with the 'persistent' attribute will not be automatically removed by
1000Sstevel@tonic-gate  * the framework in the current implementation - driver.conf nodes are without
1010Sstevel@tonic-gate  * persistence.
1020Sstevel@tonic-gate  *
1030Sstevel@tonic-gate  * The actual nodeid value may be assigned by the framework and may be
1040Sstevel@tonic-gate  * different than these special values. Drivers may not make assumptions
1050Sstevel@tonic-gate  * about the nodeid value that is actually assigned to the node.
1060Sstevel@tonic-gate  */
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate #define	DEVI_PSEUDO_NODEID	((int)-1)
1090Sstevel@tonic-gate #define	DEVI_SID_NODEID		((int)-2)
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate #define	DEVI_PSEUDO_NEXNAME	"pseudo"
1120Sstevel@tonic-gate #define	DEVI_ISA_NEXNAME	"isa"
1130Sstevel@tonic-gate #define	DEVI_EISA_NEXNAME	"eisa"
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate /*
1160Sstevel@tonic-gate  * ddi_create_minor_node flags
1170Sstevel@tonic-gate  */
1180Sstevel@tonic-gate #define	CLONE_DEV		1	/* device is a clone device */
1190Sstevel@tonic-gate #define	PRIVONLY_DEV		0x10	/* policy-based permissions only */
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate /*
1220Sstevel@tonic-gate  * Historical values used for the flag field in ddi_create_minor_node.
1230Sstevel@tonic-gate  * Future use of flag bits should avoid these fields to keep binary
1240Sstevel@tonic-gate  * compatibility
1250Sstevel@tonic-gate  * #define	GLOBAL_DEV		0x2
1260Sstevel@tonic-gate  * #define	NODEBOUND_DEV		0x4
1270Sstevel@tonic-gate  * #define	NODESPECIFIC_DEV	0x6
1280Sstevel@tonic-gate  * #define	ENUMERATED_DEV		0x8
1290Sstevel@tonic-gate  */
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate /*
1320Sstevel@tonic-gate  * Device type defines which are used by the 'node_type' element of the
1330Sstevel@tonic-gate  * ddi_minor_data structure
1340Sstevel@tonic-gate  */
1350Sstevel@tonic-gate #define	DDI_NT_SERIAL	"ddi_serial"		/* Serial port */
1360Sstevel@tonic-gate #define	DDI_NT_SERIAL_MB "ddi_serial:mb"	/* the 'built-in' serial */
1370Sstevel@tonic-gate 						/* ports (the old ttya, b */
1380Sstevel@tonic-gate 						/* (,c ,d)) */
1390Sstevel@tonic-gate #define	DDI_NT_SERIAL_DO "ddi_serial:dialout"	/* dialout ports */
1400Sstevel@tonic-gate #define	DDI_NT_SERIAL_MB_DO "ddi_serial:dialout,mb" /* dialout for onboard */
1410Sstevel@tonic-gate 						/* ports */
1420Sstevel@tonic-gate #define	DDI_NT_SERIAL_LOMCON "ddi_serial:lomcon" /* LOMlite2 console port */
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate /*
1450Sstevel@tonic-gate  * *_CHAN disk type devices have channel numbers or target numbers.
1460Sstevel@tonic-gate  * (i.e. ipi and scsi devices)
1470Sstevel@tonic-gate  */
1480Sstevel@tonic-gate #define	DDI_NT_BLOCK	"ddi_block"		/* hard disks */
1490Sstevel@tonic-gate /*
1500Sstevel@tonic-gate  * The next define is for block type devices that can possible exist on
1510Sstevel@tonic-gate  * a sub-bus like the scsi bus or the ipi channel.  The 'disks' program
1520Sstevel@tonic-gate  * will pick up on this and create logical names like c0t0d0s0 instead of
1530Sstevel@tonic-gate  * c0d0s0
1540Sstevel@tonic-gate  */
1550Sstevel@tonic-gate #define	DDI_NT_BLOCK_CHAN	"ddi_block:channel"
1560Sstevel@tonic-gate #define	DDI_NT_BLOCK_WWN	"ddi_block:wwn"
1570Sstevel@tonic-gate #define	DDI_NT_CD	"ddi_block:cdrom"	/* rom drives (cd-rom) */
1580Sstevel@tonic-gate #define	DDI_NT_CD_CHAN	"ddi_block:cdrom:channel" /* rom drives (scsi type) */
1590Sstevel@tonic-gate #define	DDI_NT_FD	"ddi_block:diskette"	/* floppy disks */
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate #define	DDI_NT_ENCLOSURE	"ddi_enclosure"
1620Sstevel@tonic-gate #define	DDI_NT_SCSI_ENCLOSURE	"ddi_enclosure:scsi"
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate #define	DDI_NT_TAPE	"ddi_byte:tape"		/* tape drives */
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate #define	DDI_NT_NET	"ddi_network"		/* DLPI network devices */
1680Sstevel@tonic-gate 
169*995Shx147065 #define	DDI_NT_NET_WIFI	"ddi_network:wifi"	/* wifi devices */
170*995Shx147065 
1710Sstevel@tonic-gate #define	DDI_NT_MAC	"ddi_mac"		/* MAC devices */
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate #define	DDI_NT_DISPLAY	"ddi_display"		/* display devices */
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate #define	DDI_PSEUDO	"ddi_pseudo"		/* general pseudo devices */
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate #define	DDI_NT_AUDIO	"ddi_audio"		/* audio device */
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate #define	DDI_NT_MOUSE	"ddi_mouse"		/* mouse device */
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate #define	DDI_NT_KEYBOARD	"ddi_keyboard"		/* keyboard device */
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate #define	DDI_NT_PARALLEL "ddi_parallel"		/* parallel port */
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate #define	DDI_NT_PRINTER	"ddi_printer"		/* printer device */
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate #define	DDI_NT_UGEN	"ddi_generic:usb"	/* USB generic drv */
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate #define	DDI_NT_NEXUS	"ddi_ctl:devctl"	/* nexus drivers */
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate #define	DDI_NT_SCSI_NEXUS	"ddi_ctl:devctl:scsi"	/* nexus drivers */
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate #define	DDI_NT_ATTACHMENT_POINT	"ddi_ctl:attachment_point" /* attachment pt */
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate #define	DDI_NT_SCSI_ATTACHMENT_POINT	"ddi_ctl:attachment_point:scsi"
1960Sstevel@tonic-gate 						/* scsi attachment pt */
1970Sstevel@tonic-gate #define	DDI_NT_PCI_ATTACHMENT_POINT	"ddi_ctl:attachment_point:pci"
1980Sstevel@tonic-gate 						/* PCI attachment pt */
1990Sstevel@tonic-gate #define	DDI_NT_SBD_ATTACHMENT_POINT	"ddi_ctl:attachment_point:sbd"
2000Sstevel@tonic-gate 						/* generic bd attachment pt */
2010Sstevel@tonic-gate #define	DDI_NT_FC_ATTACHMENT_POINT	"ddi_ctl:attachment_point:fc"
2020Sstevel@tonic-gate 						/* FC attachment pt */
2030Sstevel@tonic-gate #define	DDI_NT_USB_ATTACHMENT_POINT	"ddi_ctl:attachment_point:usb"
2040Sstevel@tonic-gate 						/* USB devices */
2050Sstevel@tonic-gate #define	DDI_NT_BLOCK_FABRIC		"ddi_block:fabric"
2060Sstevel@tonic-gate 						/* Fabric Devices */
2070Sstevel@tonic-gate #define	DDI_NT_IB_ATTACHMENT_POINT	"ddi_ctl:attachment_point:ib"
2080Sstevel@tonic-gate 						/* IB devices */
2090Sstevel@tonic-gate #define	DDI_NT_SMARTCARD_READER	"ddi_smartcard_reader" /* Smartcard reader */
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate #define	DDI_NT_AV_ASYNC "ddi_av:async"		/* asynchronous AV device */
2120Sstevel@tonic-gate #define	DDI_NT_AV_ISOCH "ddi_av:isoch"		/* isochronous AV device */
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate /* Device types used for agpgart driver related devices */
2150Sstevel@tonic-gate #define	DDI_NT_AGP_PSEUDO	"ddi_agp:pseudo" /* agpgart pseudo device */
2160Sstevel@tonic-gate #define	DDI_NT_AGP_MASTER	"ddi_agp:master" /* agp master device */
2170Sstevel@tonic-gate #define	DDI_NT_AGP_TARGET	"ddi_agp:target" /* agp target device */
2180Sstevel@tonic-gate #define	DDI_NT_AGP_CPUGART	"ddi_agp:cpugart" /* amd64 on-cpu gart device */
2190Sstevel@tonic-gate 
220117Sschwartz #define	DDI_NT_REGACC		"ddi_tool_reg"	/* tool register access */
221117Sschwartz #define	DDI_NT_INTRCTL		"ddi_tool_intr"	/* tool intr access */
222117Sschwartz 
2230Sstevel@tonic-gate /*
2240Sstevel@tonic-gate  * DDI event definitions
2250Sstevel@tonic-gate  */
2260Sstevel@tonic-gate #define	EC_DEVFS	"EC_devfs"	/* Event class devfs */
227893Srs135747 #define	EC_DDI		"EC_ddi"	/* Event class ddi */
2280Sstevel@tonic-gate 
2290Sstevel@tonic-gate /* Class devfs subclasses */
2300Sstevel@tonic-gate #define	ESC_DEVFS_MINOR_CREATE	"ESC_devfs_minor_create"
2310Sstevel@tonic-gate #define	ESC_DEVFS_MINOR_REMOVE	"ESC_devfs_minor_remove"
2320Sstevel@tonic-gate #define	ESC_DEVFS_DEVI_ADD	"ESC_devfs_devi_add"
2330Sstevel@tonic-gate #define	ESC_DEVFS_DEVI_REMOVE	"ESC_devfs_devi_remove"
2340Sstevel@tonic-gate #define	ESC_DEVFS_INSTANCE_MOD	"ESC_devfs_instance_mod"
2350Sstevel@tonic-gate #define	ESC_DEVFS_BRANCH_ADD	"ESC_devfs_branch_add"
2360Sstevel@tonic-gate #define	ESC_DEVFS_BRANCH_REMOVE	"ESC_devfs_branch_remove"
2370Sstevel@tonic-gate 
238893Srs135747 /* Class ddi subclasses */
239893Srs135747 #define	ESC_DDI_INITIATOR_REGISTER	"ESC_ddi_initiator_register"
240893Srs135747 #define	ESC_DDI_INITIATOR_UNREGISTER	"ESC_ddi_initiator_unregister"
241893Srs135747 
2420Sstevel@tonic-gate /* DDI/NDI event publisher */
2430Sstevel@tonic-gate #define	EP_DDI	SUNW_KERN_PUB"ddi"
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate /*
2460Sstevel@tonic-gate  * devfs event class attributes
2470Sstevel@tonic-gate  *
248893Srs135747  * The following attributes are private to EC_DEVFS event data.
2490Sstevel@tonic-gate  */
2500Sstevel@tonic-gate #define	DEVFS_DRIVER_NAME	"di.driver"
2510Sstevel@tonic-gate #define	DEVFS_INSTANCE		"di.instance"
2520Sstevel@tonic-gate #define	DEVFS_PATHNAME		"di.path"
2530Sstevel@tonic-gate #define	DEVFS_DEVI_CLASS	"di.devi_class"
2540Sstevel@tonic-gate #define	DEVFS_BRANCH_EVENT	"di.branch_event"
2550Sstevel@tonic-gate #define	DEVFS_MINOR_NAME	"mi.name"
2560Sstevel@tonic-gate #define	DEVFS_MINOR_NODETYPE	"mi.nodetype"
2570Sstevel@tonic-gate #define	DEVFS_MINOR_ISCLONE	"mi.isclone"
2580Sstevel@tonic-gate #define	DEVFS_MINOR_MAJNUM	"mi.majorno"
2590Sstevel@tonic-gate #define	DEVFS_MINOR_MINORNUM	"mi.minorno"
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate /*
262893Srs135747  * ddi event class payload
263893Srs135747  *
264893Srs135747  * The following attributes are private to EC_DDI event data.
265893Srs135747  */
266893Srs135747 #define	DDI_DRIVER_NAME		"ddi.driver"
267893Srs135747 #define	DDI_DRIVER_MAJOR	"ddi.major"
268893Srs135747 #define	DDI_INSTANCE		"ddi.instance"
269893Srs135747 #define	DDI_PATHNAME		"ddi.path"
270893Srs135747 #define	DDI_CLASS		"ddi.class"
271893Srs135747 
272893Srs135747 /*
2730Sstevel@tonic-gate  * Fault-related definitions
2740Sstevel@tonic-gate  *
2750Sstevel@tonic-gate  * The specific numeric values have been chosen to be ordered, but
2760Sstevel@tonic-gate  * not consecutive, to allow for future interpolation if required.
2770Sstevel@tonic-gate  */
2780Sstevel@tonic-gate typedef enum {
2790Sstevel@tonic-gate     DDI_SERVICE_LOST = -32,
2800Sstevel@tonic-gate     DDI_SERVICE_DEGRADED = -16,
2810Sstevel@tonic-gate     DDI_SERVICE_UNAFFECTED = 0,
2820Sstevel@tonic-gate     DDI_SERVICE_RESTORED = 16
2830Sstevel@tonic-gate } ddi_fault_impact_t;
2840Sstevel@tonic-gate 
2850Sstevel@tonic-gate typedef enum {
2860Sstevel@tonic-gate     DDI_DATAPATH_FAULT = -32,
2870Sstevel@tonic-gate     DDI_DEVICE_FAULT = -16,
2880Sstevel@tonic-gate     DDI_EXTERNAL_FAULT = 0
2890Sstevel@tonic-gate } ddi_fault_location_t;
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate typedef enum {
2920Sstevel@tonic-gate     DDI_DEVSTATE_OFFLINE = -32,
2930Sstevel@tonic-gate     DDI_DEVSTATE_DOWN = -16,
2940Sstevel@tonic-gate     DDI_DEVSTATE_QUIESCED = 0,
2950Sstevel@tonic-gate     DDI_DEVSTATE_DEGRADED = 16,
2960Sstevel@tonic-gate     DDI_DEVSTATE_UP = 32
2970Sstevel@tonic-gate } ddi_devstate_t;
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate #ifdef	_KERNEL
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /*
3020Sstevel@tonic-gate  * Common property definitions
3030Sstevel@tonic-gate  */
3040Sstevel@tonic-gate #define	DDI_FORCEATTACH		"ddi-forceattach"
3050Sstevel@tonic-gate #define	DDI_NO_AUTODETACH	"ddi-no-autodetach"
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate /*
3080Sstevel@tonic-gate  * Values that the function supplied to the dev_info
3090Sstevel@tonic-gate  * tree traversal functions defined below must return.
3100Sstevel@tonic-gate  */
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate /*
3130Sstevel@tonic-gate  * Continue search, if appropriate.
3140Sstevel@tonic-gate  */
3150Sstevel@tonic-gate #define	DDI_WALK_CONTINUE	0
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate /*
3180Sstevel@tonic-gate  * Terminate current depth of traversal. That is, terminate
3190Sstevel@tonic-gate  * the current traversal of children nodes, but continue
3200Sstevel@tonic-gate  * traversing sibling nodes and their children (if any).
3210Sstevel@tonic-gate  */
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate #define	DDI_WALK_PRUNECHILD	-1
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate /*
3260Sstevel@tonic-gate  * Terminate current width of traversal. That is, terminate
3270Sstevel@tonic-gate  * the current traversal of sibling nodes, but continue with
3280Sstevel@tonic-gate  * traversing children nodes and their siblings (if appropriate).
3290Sstevel@tonic-gate  */
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate #define	DDI_WALK_PRUNESIB	-2
3320Sstevel@tonic-gate 
3330Sstevel@tonic-gate /*
3340Sstevel@tonic-gate  * Terminate the entire search.
3350Sstevel@tonic-gate  */
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate #define	DDI_WALK_TERMINATE	-3
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate /*
3400Sstevel@tonic-gate  * Terminate the entire search because an error occurred in function
3410Sstevel@tonic-gate  */
3420Sstevel@tonic-gate #define	DDI_WALK_ERROR		-4
3430Sstevel@tonic-gate 
3440Sstevel@tonic-gate /*
3450Sstevel@tonic-gate  * Drivers that are prepared to support full driver layering
3460Sstevel@tonic-gate  * should create and export a null-valued property of the following
3470Sstevel@tonic-gate  * name.
3480Sstevel@tonic-gate  *
3490Sstevel@tonic-gate  * Such drivers should be prepared to be called with FKLYR in
3500Sstevel@tonic-gate  * the 'flag' argument of their open(9E), close(9E) routines, and
3510Sstevel@tonic-gate  * with FKIOCTL in the 'mode' argument of their ioctl(9E) routines.
3520Sstevel@tonic-gate  *
3530Sstevel@tonic-gate  * See ioctl(9E) and ddi_copyin(9F) for details.
3540Sstevel@tonic-gate  */
3550Sstevel@tonic-gate #define	DDI_KERNEL_IOCTL	"ddi-kernel-ioctl"
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate /*
3580Sstevel@tonic-gate  * Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F).
3590Sstevel@tonic-gate  */
3600Sstevel@tonic-gate #define	DDI_MODEL_MASK		DATAMODEL_MASK	/* Note: 0x0FF00000 */
3610Sstevel@tonic-gate #define	DDI_MODEL_ILP32		DATAMODEL_ILP32
3620Sstevel@tonic-gate #define	DDI_MODEL_LP64		DATAMODEL_LP64
3630Sstevel@tonic-gate #define	DDI_MODEL_NATIVE	DATAMODEL_NATIVE
3640Sstevel@tonic-gate #define	DDI_MODEL_NONE		DATAMODEL_NONE
3650Sstevel@tonic-gate 
3660Sstevel@tonic-gate /*
3670Sstevel@tonic-gate  * Functions and data references which really should be in <sys/ddi.h>
3680Sstevel@tonic-gate  */
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate extern int maxphys;
3710Sstevel@tonic-gate extern void minphys(struct buf *);
3720Sstevel@tonic-gate extern int physio(int (*)(struct buf *), struct buf *, dev_t,
3730Sstevel@tonic-gate 	int, void (*)(struct buf *), struct uio *);
3740Sstevel@tonic-gate extern void disksort(struct diskhd *, struct buf *);
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate extern long strtol(const char *, char **, int);
3770Sstevel@tonic-gate extern unsigned long strtoul(const char *, char **, int);
3780Sstevel@tonic-gate extern size_t strlen(const char *) __PURE;
3790Sstevel@tonic-gate extern char *strcpy(char *, const char *);
3800Sstevel@tonic-gate extern char *strncpy(char *, const char *, size_t);
3810Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for strchr() */
3820Sstevel@tonic-gate #if __cplusplus >= 199711L
3830Sstevel@tonic-gate extern const char *strchr(const char *, int);
3840Sstevel@tonic-gate #ifndef	_STRCHR_INLINE
3850Sstevel@tonic-gate #define	_STRCHR_INLINE
3860Sstevel@tonic-gate extern	"C++" {
3870Sstevel@tonic-gate 	inline char *strchr(char *__s, int __c) {
3880Sstevel@tonic-gate 		return (char *)strchr((const char *)__s, __c);
3890Sstevel@tonic-gate 	}
3900Sstevel@tonic-gate }
3910Sstevel@tonic-gate #endif	/* _STRCHR_INLINE */
3920Sstevel@tonic-gate #else
3930Sstevel@tonic-gate extern char *strchr(const char *, int);
3940Sstevel@tonic-gate #endif	/* __cplusplus >= 199711L */
395164Scth #define	DDI_STRSAME(s1, s2)	((*(s1) == *(s2)) && (strcmp((s1), (s2)) == 0))
3960Sstevel@tonic-gate extern int strcmp(const char *, const char *) __PURE;
3970Sstevel@tonic-gate extern int strncmp(const char *, const char *, size_t) __PURE;
3980Sstevel@tonic-gate extern char *strncat(char *, const char *, size_t);
3990Sstevel@tonic-gate extern size_t strlcat(char *, const char *, size_t);
4000Sstevel@tonic-gate extern size_t strlcpy(char *, const char *, size_t);
4010Sstevel@tonic-gate extern size_t strspn(const char *, const char *);
4020Sstevel@tonic-gate extern int bcmp(const void *, const void *, size_t) __PURE;
4030Sstevel@tonic-gate extern int stoi(char **);
4040Sstevel@tonic-gate extern void numtos(ulong_t, char *);
4050Sstevel@tonic-gate extern void bcopy(const void *, void *, size_t);
4060Sstevel@tonic-gate extern void bzero(void *, size_t);
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate extern void *memcpy(void *, const  void  *, size_t);
4090Sstevel@tonic-gate extern void *memset(void *, int, size_t);
4100Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t);
4110Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t) __PURE;
4120Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definition for memchr() */
4130Sstevel@tonic-gate #if __cplusplus >= 199711L
4140Sstevel@tonic-gate extern const void *memchr(const void *, int, size_t);
4150Sstevel@tonic-gate #ifndef	_MEMCHR_INLINE
4160Sstevel@tonic-gate #define	_MEMCHR_INLINE
4170Sstevel@tonic-gate extern "C++" {
4180Sstevel@tonic-gate 	inline void *memchr(void * __s, int __c, size_t __n) {
4190Sstevel@tonic-gate 		return (void *)memchr((const void *)__s, __c, __n);
4200Sstevel@tonic-gate 	}
4210Sstevel@tonic-gate }
4220Sstevel@tonic-gate #endif  /* _MEMCHR_INLINE */
4230Sstevel@tonic-gate #else
4240Sstevel@tonic-gate extern void *memchr(const void *, int, size_t);
4250Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate extern int ddi_strtol(const char *, char **, int, long *);
4280Sstevel@tonic-gate extern int ddi_strtoul(const char *, char **, int, unsigned long *);
4290Sstevel@tonic-gate 
4300Sstevel@tonic-gate /*
4310Sstevel@tonic-gate  * ddi_map_regs
4320Sstevel@tonic-gate  *
4330Sstevel@tonic-gate  *	Map in the register set given by rnumber.
4340Sstevel@tonic-gate  *	The register number determine which register
4350Sstevel@tonic-gate  *	set will be mapped if more than one exists.
4360Sstevel@tonic-gate  *	The parent driver gets the information
4370Sstevel@tonic-gate  *	from parent private data and sets up the
4380Sstevel@tonic-gate  *	appropriate mappings and returns the kernel
4390Sstevel@tonic-gate  *	virtual address of the register set in *kaddrp.
4400Sstevel@tonic-gate  *	The offset specifies an offset into the register
4410Sstevel@tonic-gate  *	space to start from and len indicates the size
4420Sstevel@tonic-gate  *	of the area to map. If len and offset are 0 then
4430Sstevel@tonic-gate  *	the entire space is mapped.  It returns DDI_SUCCESS on
4440Sstevel@tonic-gate  *	success or DDI_FAILURE otherwise.
4450Sstevel@tonic-gate  *
4460Sstevel@tonic-gate  */
4470Sstevel@tonic-gate int
4480Sstevel@tonic-gate ddi_map_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
4490Sstevel@tonic-gate 	off_t offset, off_t len);
4500Sstevel@tonic-gate 
4510Sstevel@tonic-gate /*
4520Sstevel@tonic-gate  * ddi_unmap_regs
4530Sstevel@tonic-gate  *
4540Sstevel@tonic-gate  *	Undo mappings set up by ddi_map_regs.
4550Sstevel@tonic-gate  *	The register number determines which register
4560Sstevel@tonic-gate  *	set will be unmapped if more than one exists.
4570Sstevel@tonic-gate  *	This is provided for drivers preparing
4580Sstevel@tonic-gate  *	to detach themselves from the system to
4590Sstevel@tonic-gate  *	allow them to release allocated mappings.
4600Sstevel@tonic-gate  *
4610Sstevel@tonic-gate  *	The kaddrp and len specify the area to be
4620Sstevel@tonic-gate  *	unmapped. *kaddrp was returned from ddi_map_regs
4630Sstevel@tonic-gate  *	and len should match what ddi_map_regs was called
4640Sstevel@tonic-gate  *	with.
4650Sstevel@tonic-gate  */
4660Sstevel@tonic-gate 
4670Sstevel@tonic-gate void
4680Sstevel@tonic-gate ddi_unmap_regs(dev_info_t *dip, uint_t rnumber, caddr_t *kaddrp,
4690Sstevel@tonic-gate 	off_t offset, off_t len);
4700Sstevel@tonic-gate 
4710Sstevel@tonic-gate int
4720Sstevel@tonic-gate ddi_map(dev_info_t *dp, ddi_map_req_t *mp, off_t offset, off_t len,
4730Sstevel@tonic-gate 	caddr_t *addrp);
4740Sstevel@tonic-gate 
4750Sstevel@tonic-gate int
4760Sstevel@tonic-gate ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate /*
4790Sstevel@tonic-gate  * ddi_rnumber_to_regspec: Not for use by leaf drivers.
4800Sstevel@tonic-gate  */
4810Sstevel@tonic-gate struct regspec *
4820Sstevel@tonic-gate ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
4830Sstevel@tonic-gate 
4840Sstevel@tonic-gate int
4850Sstevel@tonic-gate ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
4860Sstevel@tonic-gate 	off_t len, caddr_t *vaddrp);
4870Sstevel@tonic-gate 
4880Sstevel@tonic-gate int
4890Sstevel@tonic-gate nullbusmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
4900Sstevel@tonic-gate 	off_t len, caddr_t *vaddrp);
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate #ifdef _LP64
4930Sstevel@tonic-gate 
4940Sstevel@tonic-gate int ddi_peek8(dev_info_t *dip, int8_t *addr, int8_t *val_p);
4950Sstevel@tonic-gate int ddi_peek16(dev_info_t *dip, int16_t *addr, int16_t *val_p);
4960Sstevel@tonic-gate int ddi_peek32(dev_info_t *dip, int32_t *addr, int32_t *val_p);
4970Sstevel@tonic-gate int ddi_peek64(dev_info_t *dip, int64_t *addr, int64_t *val_p);
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate int ddi_poke8(dev_info_t *dip, int8_t *addr, int8_t val);
5000Sstevel@tonic-gate int ddi_poke16(dev_info_t *dip, int16_t *addr, int16_t val);
5010Sstevel@tonic-gate int ddi_poke32(dev_info_t *dip, int32_t *addr, int32_t val);
5020Sstevel@tonic-gate int ddi_poke64(dev_info_t *dip, int64_t *addr, int64_t val);
5030Sstevel@tonic-gate 
5040Sstevel@tonic-gate #else /* _ILP32 */
5050Sstevel@tonic-gate 
5060Sstevel@tonic-gate int ddi_peekc(dev_info_t *dip, int8_t *addr, int8_t *val_p);
5070Sstevel@tonic-gate #define	ddi_peek8	ddi_peekc
5080Sstevel@tonic-gate 
5090Sstevel@tonic-gate int ddi_peeks(dev_info_t *dip, int16_t *addr, int16_t *val_p);
5100Sstevel@tonic-gate #define	ddi_peek16	ddi_peeks
5110Sstevel@tonic-gate 
5120Sstevel@tonic-gate int ddi_peekl(dev_info_t *dip, int32_t *addr, int32_t *val_p);
5130Sstevel@tonic-gate #define	ddi_peek32	ddi_peekl
5140Sstevel@tonic-gate 
5150Sstevel@tonic-gate int ddi_peekd(dev_info_t *dip, int64_t *addr, int64_t *val_p);
5160Sstevel@tonic-gate #define	ddi_peek64	ddi_peekd
5170Sstevel@tonic-gate 
5180Sstevel@tonic-gate int ddi_pokec(dev_info_t *dip, int8_t *addr, int8_t val);
5190Sstevel@tonic-gate #define	ddi_poke8	ddi_pokec
5200Sstevel@tonic-gate 
5210Sstevel@tonic-gate int ddi_pokes(dev_info_t *dip, int16_t *addr, int16_t val);
5220Sstevel@tonic-gate #define	ddi_poke16	ddi_pokes
5230Sstevel@tonic-gate 
5240Sstevel@tonic-gate int ddi_pokel(dev_info_t *dip, int32_t *addr, int32_t val);
5250Sstevel@tonic-gate #define	ddi_poke32	ddi_pokel
5260Sstevel@tonic-gate 
5270Sstevel@tonic-gate int ddi_poked(dev_info_t *dip, int64_t *addr, int64_t val);
5280Sstevel@tonic-gate #define	ddi_poke64	ddi_poked
5290Sstevel@tonic-gate 
5300Sstevel@tonic-gate #endif /* _LP64 */
5310Sstevel@tonic-gate 
5320Sstevel@tonic-gate /*
5330Sstevel@tonic-gate  * Peek and poke to and from a uio structure in xfersize pieces,
5340Sstevel@tonic-gate  * using the parent nexi.
5350Sstevel@tonic-gate  */
5360Sstevel@tonic-gate int ddi_peekpokeio(dev_info_t *devi, struct uio *uio, enum uio_rw rw,
5370Sstevel@tonic-gate 	caddr_t addr, size_t len, uint_t xfersize);
5380Sstevel@tonic-gate 
5390Sstevel@tonic-gate /*
5400Sstevel@tonic-gate  * Pagesize conversions using the parent nexi
5410Sstevel@tonic-gate  */
5420Sstevel@tonic-gate unsigned long ddi_btop(dev_info_t *dip, unsigned long bytes);
5430Sstevel@tonic-gate unsigned long ddi_btopr(dev_info_t *dip, unsigned long bytes);
5440Sstevel@tonic-gate unsigned long ddi_ptob(dev_info_t *dip, unsigned long pages);
5450Sstevel@tonic-gate 
5460Sstevel@tonic-gate /*
5470Sstevel@tonic-gate  * There are no more "block" interrupt functions, per se.
5480Sstevel@tonic-gate  * All thread of control should be done with MP/MT lockings.
5490Sstevel@tonic-gate  *
5500Sstevel@tonic-gate  * However, there are certain times in which a driver needs
5510Sstevel@tonic-gate  * absolutely a critical guaranteed non-preemptable time
5520Sstevel@tonic-gate  * in which to execute a few instructions.
5530Sstevel@tonic-gate  *
5540Sstevel@tonic-gate  * The following pair of functions attempt to guarantee this,
5550Sstevel@tonic-gate  * but they are dangerous to use. That is, use them with
5560Sstevel@tonic-gate  * extreme care. They do not guarantee to stop other processors
5570Sstevel@tonic-gate  * from executing, but they do guarantee that the caller
5580Sstevel@tonic-gate  * of ddi_enter_critical will continue to run until the
5590Sstevel@tonic-gate  * caller calls ddi_exit_critical. No intervening DDI functions
5600Sstevel@tonic-gate  * may be called between an entry and an exit from a critical
5610Sstevel@tonic-gate  * region.
5620Sstevel@tonic-gate  *
5630Sstevel@tonic-gate  * ddi_enter_critical returns an integer identifier which must
5640Sstevel@tonic-gate  * be passed to ddi_exit_critical.
5650Sstevel@tonic-gate  *
5660Sstevel@tonic-gate  * Be very sparing in the use of these functions since it is
5670Sstevel@tonic-gate  * likely that absolutely nothing else can occur in the system
5680Sstevel@tonic-gate  * whilst in the critical region.
5690Sstevel@tonic-gate  */
5700Sstevel@tonic-gate 
5710Sstevel@tonic-gate unsigned int
5720Sstevel@tonic-gate ddi_enter_critical(void);
5730Sstevel@tonic-gate 
5740Sstevel@tonic-gate void
5750Sstevel@tonic-gate ddi_exit_critical(unsigned int);
5760Sstevel@tonic-gate 
5770Sstevel@tonic-gate /*
5780Sstevel@tonic-gate  * devmap functions
5790Sstevel@tonic-gate  */
5800Sstevel@tonic-gate int
5810Sstevel@tonic-gate devmap_setup(dev_t dev, offset_t off, ddi_as_handle_t as, caddr_t *addrp,
5820Sstevel@tonic-gate 	size_t len, uint_t prot, uint_t maxprot, uint_t flags,
5830Sstevel@tonic-gate 	struct cred *cred);
5840Sstevel@tonic-gate 
5850Sstevel@tonic-gate int
5860Sstevel@tonic-gate ddi_devmap_segmap(dev_t dev, off_t off, ddi_as_handle_t as, caddr_t *addrp,
5870Sstevel@tonic-gate 	off_t len, uint_t prot, uint_t maxprot, uint_t flags,
5880Sstevel@tonic-gate 	struct cred *cred);
5890Sstevel@tonic-gate 
5900Sstevel@tonic-gate int
5910Sstevel@tonic-gate devmap_load(devmap_cookie_t dhp, offset_t offset, size_t len, uint_t type,
5920Sstevel@tonic-gate 	uint_t rw);
5930Sstevel@tonic-gate 
5940Sstevel@tonic-gate int
5950Sstevel@tonic-gate devmap_unload(devmap_cookie_t dhp, offset_t offset, size_t len);
5960Sstevel@tonic-gate 
5970Sstevel@tonic-gate int
5980Sstevel@tonic-gate devmap_devmem_setup(devmap_cookie_t dhp, dev_info_t *dip,
5990Sstevel@tonic-gate 	struct devmap_callback_ctl *callback_ops,
6000Sstevel@tonic-gate 	uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
6010Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6020Sstevel@tonic-gate 
6030Sstevel@tonic-gate int
6040Sstevel@tonic-gate devmap_umem_setup(devmap_cookie_t dhp, dev_info_t *dip,
6050Sstevel@tonic-gate 	struct devmap_callback_ctl *callback_ops,
6060Sstevel@tonic-gate 	ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
6070Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6080Sstevel@tonic-gate 
6090Sstevel@tonic-gate int
6100Sstevel@tonic-gate devmap_devmem_remap(devmap_cookie_t dhp, dev_info_t *dip,
6110Sstevel@tonic-gate 	uint_t rnumber, offset_t roff, size_t len, uint_t maxprot,
6120Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6130Sstevel@tonic-gate 
6140Sstevel@tonic-gate int
6150Sstevel@tonic-gate devmap_umem_remap(devmap_cookie_t dhp, dev_info_t *dip,
6160Sstevel@tonic-gate 	ddi_umem_cookie_t cookie, offset_t off, size_t len, uint_t maxprot,
6170Sstevel@tonic-gate 	uint_t flags, ddi_device_acc_attr_t *accattrp);
6180Sstevel@tonic-gate 
6190Sstevel@tonic-gate void
6200Sstevel@tonic-gate devmap_set_ctx_timeout(devmap_cookie_t dhp, clock_t ticks);
6210Sstevel@tonic-gate 
6220Sstevel@tonic-gate int
6230Sstevel@tonic-gate devmap_default_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
6240Sstevel@tonic-gate 	size_t len, uint_t type, uint_t rw);
6250Sstevel@tonic-gate 
6260Sstevel@tonic-gate int
6270Sstevel@tonic-gate devmap_do_ctxmgt(devmap_cookie_t dhp, void *pvtp, offset_t off, size_t len,
6280Sstevel@tonic-gate 	uint_t type, uint_t rw, int (*ctxmgt)(devmap_cookie_t, void *, offset_t,
6290Sstevel@tonic-gate 	size_t, uint_t, uint_t));
6300Sstevel@tonic-gate 
6310Sstevel@tonic-gate 
6320Sstevel@tonic-gate void *ddi_umem_alloc(size_t size, int flag, ddi_umem_cookie_t *cookiep);
6330Sstevel@tonic-gate 
6340Sstevel@tonic-gate void ddi_umem_free(ddi_umem_cookie_t cookie);
6350Sstevel@tonic-gate 
6360Sstevel@tonic-gate /*
6370Sstevel@tonic-gate  * Functions to lock user memory and do repeated I/O or do devmap_umem_setup
6380Sstevel@tonic-gate  */
6390Sstevel@tonic-gate int
6400Sstevel@tonic-gate ddi_umem_lock(caddr_t addr, size_t size, int flags, ddi_umem_cookie_t *cookie);
6410Sstevel@tonic-gate 
6420Sstevel@tonic-gate void
6430Sstevel@tonic-gate ddi_umem_unlock(ddi_umem_cookie_t cookie);
6440Sstevel@tonic-gate 
6450Sstevel@tonic-gate struct buf *
6460Sstevel@tonic-gate ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction,
6470Sstevel@tonic-gate     dev_t dev, daddr_t blkno, int (*iodone)(struct buf *), int sleepflag);
6480Sstevel@tonic-gate 
6490Sstevel@tonic-gate /*
6500Sstevel@tonic-gate  * Mapping functions
6510Sstevel@tonic-gate  */
6520Sstevel@tonic-gate int
6530Sstevel@tonic-gate ddi_segmap(dev_t dev, off_t offset, struct as *asp, caddr_t *addrp, off_t len,
6540Sstevel@tonic-gate 	uint_t prot, uint_t maxprot, uint_t flags, cred_t *credp);
6550Sstevel@tonic-gate 
6560Sstevel@tonic-gate int
6570Sstevel@tonic-gate ddi_segmap_setup(dev_t dev, off_t offset, struct as *as, caddr_t *addrp,
6580Sstevel@tonic-gate 	off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cred,
6590Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, uint_t rnumber);
6600Sstevel@tonic-gate 
6610Sstevel@tonic-gate int
6620Sstevel@tonic-gate ddi_map_fault(dev_info_t *dip, struct hat *hat, struct seg *seg, caddr_t addr,
6630Sstevel@tonic-gate 	struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
6640Sstevel@tonic-gate 
6650Sstevel@tonic-gate int
6660Sstevel@tonic-gate ddi_device_mapping_check(dev_t dev, ddi_device_acc_attr_t *accattrp,
6670Sstevel@tonic-gate 	uint_t rnumber, uint_t *hat_flags);
6680Sstevel@tonic-gate 
6690Sstevel@tonic-gate /*
6700Sstevel@tonic-gate  * Property functions:   See also, ddipropdefs.h.
6710Sstevel@tonic-gate  *			In general, the underlying driver MUST be held
6720Sstevel@tonic-gate  *			to call it's property functions.
6730Sstevel@tonic-gate  */
6740Sstevel@tonic-gate 
6750Sstevel@tonic-gate /*
6760Sstevel@tonic-gate  * Used to create, modify, and lookup integer properties
6770Sstevel@tonic-gate  */
6780Sstevel@tonic-gate int ddi_prop_get_int(dev_t match_dev, dev_info_t *dip, uint_t flags,
6790Sstevel@tonic-gate     char *name, int defvalue);
6800Sstevel@tonic-gate int64_t ddi_prop_get_int64(dev_t match_dev, dev_info_t *dip, uint_t flags,
6810Sstevel@tonic-gate     char *name, int64_t defvalue);
6820Sstevel@tonic-gate int ddi_prop_lookup_int_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
6830Sstevel@tonic-gate     char *name, int **data, uint_t *nelements);
6840Sstevel@tonic-gate int ddi_prop_lookup_int64_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
6850Sstevel@tonic-gate     char *name, int64_t **data, uint_t *nelements);
6860Sstevel@tonic-gate int ddi_prop_update_int(dev_t match_dev, dev_info_t *dip,
6870Sstevel@tonic-gate     char *name, int data);
6880Sstevel@tonic-gate int ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip,
6890Sstevel@tonic-gate     char *name, int64_t data);
6900Sstevel@tonic-gate int ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip,
6910Sstevel@tonic-gate     char *name, int *data, uint_t nelements);
6920Sstevel@tonic-gate int ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip,
6930Sstevel@tonic-gate     char *name, int64_t *data, uint_t nelements);
6940Sstevel@tonic-gate /*
6950Sstevel@tonic-gate  * Used to create, modify, and lookup string properties
6960Sstevel@tonic-gate  */
6970Sstevel@tonic-gate int ddi_prop_lookup_string(dev_t match_dev, dev_info_t *dip, uint_t flags,
6980Sstevel@tonic-gate     char *name, char **data);
6990Sstevel@tonic-gate int ddi_prop_lookup_string_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
7000Sstevel@tonic-gate     char *name, char ***data, uint_t *nelements);
7010Sstevel@tonic-gate int ddi_prop_update_string(dev_t match_dev, dev_info_t *dip,
7020Sstevel@tonic-gate     char *name, char *data);
7030Sstevel@tonic-gate int ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
7040Sstevel@tonic-gate     char *name, char **data, uint_t nelements);
7050Sstevel@tonic-gate 
7060Sstevel@tonic-gate /*
7070Sstevel@tonic-gate  * Used to create, modify, and lookup byte properties
7080Sstevel@tonic-gate  */
7090Sstevel@tonic-gate int ddi_prop_lookup_byte_array(dev_t match_dev, dev_info_t *dip, uint_t flags,
7100Sstevel@tonic-gate     char *name, uchar_t **data, uint_t *nelements);
7110Sstevel@tonic-gate int ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
7120Sstevel@tonic-gate     char *name, uchar_t *data, uint_t nelements);
7130Sstevel@tonic-gate 
7140Sstevel@tonic-gate /*
7150Sstevel@tonic-gate  * Used to verify the existence of a property or to see if a boolean
7160Sstevel@tonic-gate  * property exists.
7170Sstevel@tonic-gate  */
7180Sstevel@tonic-gate int ddi_prop_exists(dev_t match_dev, dev_info_t *dip, uint_t flags, char *name);
7190Sstevel@tonic-gate 
7200Sstevel@tonic-gate /*
7210Sstevel@tonic-gate  * Used to free the data returned by the above property routines.
7220Sstevel@tonic-gate  */
7230Sstevel@tonic-gate void ddi_prop_free(void *data);
7240Sstevel@tonic-gate 
7250Sstevel@tonic-gate /*
7260Sstevel@tonic-gate  * nopropop: For internal use in `dummy' cb_prop_op functions only
7270Sstevel@tonic-gate  */
7280Sstevel@tonic-gate 
7290Sstevel@tonic-gate int
7300Sstevel@tonic-gate nopropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
7310Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7320Sstevel@tonic-gate 
7330Sstevel@tonic-gate /*
7340Sstevel@tonic-gate  * ddi_prop_op: The basic property operator for drivers.
7350Sstevel@tonic-gate  *
7360Sstevel@tonic-gate  * In ddi_prop_op, the type of valuep is interpreted based on prop_op:
7370Sstevel@tonic-gate  *
7380Sstevel@tonic-gate  *	prop_op			valuep
7390Sstevel@tonic-gate  *	------			------
7400Sstevel@tonic-gate  *
7410Sstevel@tonic-gate  *	PROP_LEN		<unused>
7420Sstevel@tonic-gate  *
7430Sstevel@tonic-gate  *	PROP_LEN_AND_VAL_BUF	Pointer to callers buffer
7440Sstevel@tonic-gate  *
7450Sstevel@tonic-gate  *	PROP_LEN_AND_VAL_ALLOC	Address of callers pointer (will be set to
7460Sstevel@tonic-gate  *				address of allocated buffer, if successful)
7470Sstevel@tonic-gate  */
7480Sstevel@tonic-gate 
7490Sstevel@tonic-gate int
7500Sstevel@tonic-gate ddi_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
7510Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7520Sstevel@tonic-gate 
7530Sstevel@tonic-gate /* ddi_prop_op_size: for drivers that implement size in bytes */
7540Sstevel@tonic-gate int
7550Sstevel@tonic-gate ddi_prop_op_size(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
7560Sstevel@tonic-gate 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
7570Sstevel@tonic-gate 	uint64_t size64);
7580Sstevel@tonic-gate 
7590Sstevel@tonic-gate /* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */
7600Sstevel@tonic-gate int
7610Sstevel@tonic-gate ddi_prop_op_nblocks(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
7620Sstevel@tonic-gate 	int mod_flags, char *name, caddr_t valuep, int *lengthp,
7630Sstevel@tonic-gate 	uint64_t nblocks64);
7640Sstevel@tonic-gate 
7650Sstevel@tonic-gate /*
7660Sstevel@tonic-gate  * Variable length props...
7670Sstevel@tonic-gate  */
7680Sstevel@tonic-gate 
7690Sstevel@tonic-gate /*
7700Sstevel@tonic-gate  * ddi_getlongprop:	Get variable length property len+val into a buffer
7710Sstevel@tonic-gate  *		allocated by property provider via kmem_alloc. Requester
7720Sstevel@tonic-gate  *		is responsible for freeing returned property via kmem_free.
7730Sstevel@tonic-gate  *
7740Sstevel@tonic-gate  * 	Arguments:
7750Sstevel@tonic-gate  *
7760Sstevel@tonic-gate  *	dev:	Input:	dev_t of property.
7770Sstevel@tonic-gate  *	dip:	Input:	dev_info_t pointer of child.
7780Sstevel@tonic-gate  *	flags:	Input:	Possible flag modifiers are:
7790Sstevel@tonic-gate  *		DDI_PROP_DONTPASS:	Don't pass to parent if prop not found.
7800Sstevel@tonic-gate  *		DDI_PROP_CANSLEEP:	Memory allocation may sleep.
7810Sstevel@tonic-gate  *	name:	Input:	name of property.
7820Sstevel@tonic-gate  *	valuep:	Output:	Addr of callers buffer pointer.
7830Sstevel@tonic-gate  *	lengthp:Output:	*lengthp will contain prop length on exit.
7840Sstevel@tonic-gate  *
7850Sstevel@tonic-gate  * 	Possible Returns:
7860Sstevel@tonic-gate  *
7870Sstevel@tonic-gate  *		DDI_PROP_SUCCESS:	Prop found and returned.
7880Sstevel@tonic-gate  *		DDI_PROP_NOT_FOUND:	Prop not found
7890Sstevel@tonic-gate  *		DDI_PROP_UNDEFINED:	Prop explicitly undefined.
7900Sstevel@tonic-gate  *		DDI_PROP_NO_MEMORY:	Prop found, but unable to alloc mem.
7910Sstevel@tonic-gate  */
7920Sstevel@tonic-gate 
7930Sstevel@tonic-gate int
7940Sstevel@tonic-gate ddi_getlongprop(dev_t dev, dev_info_t *dip, int flags,
7950Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
7960Sstevel@tonic-gate 
7970Sstevel@tonic-gate /*
7980Sstevel@tonic-gate  *
7990Sstevel@tonic-gate  * ddi_getlongprop_buf:		Get long prop into pre-allocated callers
8000Sstevel@tonic-gate  *				buffer. (no memory allocation by provider).
8010Sstevel@tonic-gate  *
8020Sstevel@tonic-gate  *	dev:	Input:	dev_t of property.
8030Sstevel@tonic-gate  *	dip:	Input:	dev_info_t pointer of child.
8040Sstevel@tonic-gate  *	flags:	Input:	DDI_PROP_DONTPASS or NULL
8050Sstevel@tonic-gate  *	name:	Input:	name of property
8060Sstevel@tonic-gate  *	valuep:	Input:	ptr to callers buffer.
8070Sstevel@tonic-gate  *	lengthp:I/O:	ptr to length of callers buffer on entry,
8080Sstevel@tonic-gate  *			actual length of property on exit.
8090Sstevel@tonic-gate  *
8100Sstevel@tonic-gate  *	Possible returns:
8110Sstevel@tonic-gate  *
8120Sstevel@tonic-gate  *		DDI_PROP_SUCCESS	Prop found and returned
8130Sstevel@tonic-gate  *		DDI_PROP_NOT_FOUND	Prop not found
8140Sstevel@tonic-gate  *		DDI_PROP_UNDEFINED	Prop explicitly undefined.
8150Sstevel@tonic-gate  *		DDI_PROP_BUF_TOO_SMALL	Prop found, callers buf too small,
8160Sstevel@tonic-gate  *					no value returned, but actual prop
8170Sstevel@tonic-gate  *					length returned in *lengthp
8180Sstevel@tonic-gate  *
8190Sstevel@tonic-gate  */
8200Sstevel@tonic-gate 
8210Sstevel@tonic-gate int
8220Sstevel@tonic-gate ddi_getlongprop_buf(dev_t dev, dev_info_t *dip, int flags,
8230Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
8240Sstevel@tonic-gate 
8250Sstevel@tonic-gate /*
8260Sstevel@tonic-gate  * Integer/boolean sized props.
8270Sstevel@tonic-gate  *
8280Sstevel@tonic-gate  * Call is value only... returns found boolean or int sized prop value or
8290Sstevel@tonic-gate  * defvalue if prop not found or is wrong length or is explicitly undefined.
8300Sstevel@tonic-gate  * Only flag is DDI_PROP_DONTPASS...
8310Sstevel@tonic-gate  *
8320Sstevel@tonic-gate  * By convention, this interface returns boolean (0) sized properties
8330Sstevel@tonic-gate  * as value (int)1.
8340Sstevel@tonic-gate  */
8350Sstevel@tonic-gate 
8360Sstevel@tonic-gate int
8370Sstevel@tonic-gate ddi_getprop(dev_t dev, dev_info_t *dip, int flags, char *name, int defvalue);
8380Sstevel@tonic-gate 
8390Sstevel@tonic-gate /*
8400Sstevel@tonic-gate  * Get prop length interface: flags are 0 or DDI_PROP_DONTPASS
8410Sstevel@tonic-gate  * if returns DDI_PROP_SUCCESS, length returned in *lengthp.
8420Sstevel@tonic-gate  */
8430Sstevel@tonic-gate 
8440Sstevel@tonic-gate int
8450Sstevel@tonic-gate ddi_getproplen(dev_t dev, dev_info_t *dip, int flags, char *name, int *lengthp);
8460Sstevel@tonic-gate 
8470Sstevel@tonic-gate 
8480Sstevel@tonic-gate /*
8490Sstevel@tonic-gate  * Interface to create/modify a managed property on child's behalf...
8500Sstevel@tonic-gate  * Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep
8510Sstevel@tonic-gate  * if no memory available for internal prop structure.  Long property
8520Sstevel@tonic-gate  * (non integer sized) value references are not copied.
8530Sstevel@tonic-gate  *
8540Sstevel@tonic-gate  * Define property with DDI_DEV_T_NONE dev_t for properties not associated
8550Sstevel@tonic-gate  * with any particular dev_t. Use the same dev_t when modifying or undefining
8560Sstevel@tonic-gate  * a property.
8570Sstevel@tonic-gate  *
8580Sstevel@tonic-gate  * No guarantee on order of property search, so don't mix the same
8590Sstevel@tonic-gate  * property name with wildcard and non-wildcard dev_t's.
8600Sstevel@tonic-gate  */
8610Sstevel@tonic-gate 
8620Sstevel@tonic-gate /*
8630Sstevel@tonic-gate  * ddi_prop_create:	Define a managed property:
8640Sstevel@tonic-gate  */
8650Sstevel@tonic-gate 
8660Sstevel@tonic-gate int
8670Sstevel@tonic-gate ddi_prop_create(dev_t dev, dev_info_t *dip, int flag,
8680Sstevel@tonic-gate 	char *name, caddr_t value, int length);
8690Sstevel@tonic-gate 
8700Sstevel@tonic-gate /*
8710Sstevel@tonic-gate  * ddi_prop_modify:	Modify a managed property value
8720Sstevel@tonic-gate  */
8730Sstevel@tonic-gate 
8740Sstevel@tonic-gate int
8750Sstevel@tonic-gate ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag,
8760Sstevel@tonic-gate 	char *name, caddr_t value, int length);
8770Sstevel@tonic-gate 
8780Sstevel@tonic-gate /*
8790Sstevel@tonic-gate  * ddi_prop_remove:	Undefine a managed property:
8800Sstevel@tonic-gate  */
8810Sstevel@tonic-gate 
8820Sstevel@tonic-gate int
8830Sstevel@tonic-gate ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
8840Sstevel@tonic-gate 
8850Sstevel@tonic-gate /*
8860Sstevel@tonic-gate  * ddi_prop_remove_all:		Used before unloading a driver to remove
8870Sstevel@tonic-gate  *				all properties. (undefines all dev_t's props.)
8880Sstevel@tonic-gate  *				Also removes `undefined' prop defs.
8890Sstevel@tonic-gate  */
8900Sstevel@tonic-gate 
8910Sstevel@tonic-gate void
8920Sstevel@tonic-gate ddi_prop_remove_all(dev_info_t *dip);
8930Sstevel@tonic-gate 
8940Sstevel@tonic-gate 
8950Sstevel@tonic-gate /*
8960Sstevel@tonic-gate  * ddi_prop_undefine:	Explicitly undefine a property.  Property
8970Sstevel@tonic-gate  *			searches which match this property return
8980Sstevel@tonic-gate  *			the error code DDI_PROP_UNDEFINED.
8990Sstevel@tonic-gate  *
9000Sstevel@tonic-gate  *			Use ddi_prop_remove to negate effect of
9010Sstevel@tonic-gate  *			ddi_prop_undefine
9020Sstevel@tonic-gate  */
9030Sstevel@tonic-gate 
9040Sstevel@tonic-gate int
9050Sstevel@tonic-gate ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name);
9060Sstevel@tonic-gate 
9070Sstevel@tonic-gate 
9080Sstevel@tonic-gate /*
9090Sstevel@tonic-gate  * The default ddi_bus_prop_op wrapper...
9100Sstevel@tonic-gate  */
9110Sstevel@tonic-gate 
9120Sstevel@tonic-gate int
9130Sstevel@tonic-gate ddi_bus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip,
9140Sstevel@tonic-gate 	ddi_prop_op_t prop_op, int mod_flags,
9150Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
9160Sstevel@tonic-gate 
9170Sstevel@tonic-gate 
9180Sstevel@tonic-gate /*
9190Sstevel@tonic-gate  * Routines to traverse the tree of dev_info nodes.
9200Sstevel@tonic-gate  * The general idea of these functions is to provide
9210Sstevel@tonic-gate  * various tree traversal utilities. For each node
9220Sstevel@tonic-gate  * that the tree traversal function finds, a caller
9230Sstevel@tonic-gate  * supplied function is called with arguments of
9240Sstevel@tonic-gate  * the current node and a caller supplied argument.
9250Sstevel@tonic-gate  * The caller supplied function should return one
9260Sstevel@tonic-gate  * of the integer values defined below which will
9270Sstevel@tonic-gate  * indicate to the tree traversal function whether
9280Sstevel@tonic-gate  * the traversal should be continued, and if so, how,
9290Sstevel@tonic-gate  * or whether the traversal should terminate.
9300Sstevel@tonic-gate  */
9310Sstevel@tonic-gate 
9320Sstevel@tonic-gate /*
9330Sstevel@tonic-gate  * This general-purpose routine traverses the tree of dev_info nodes,
9340Sstevel@tonic-gate  * starting from the given node, and calls the given function for each
9350Sstevel@tonic-gate  * node that it finds with the current node and the pointer arg (which
9360Sstevel@tonic-gate  * can point to a structure of information that the function
9370Sstevel@tonic-gate  * needs) as arguments.
9380Sstevel@tonic-gate  *
9390Sstevel@tonic-gate  * It does the walk a layer at a time, not depth-first.
9400Sstevel@tonic-gate  *
9410Sstevel@tonic-gate  * The given function must return one of the values defined above.
9420Sstevel@tonic-gate  *
9430Sstevel@tonic-gate  */
9440Sstevel@tonic-gate 
9450Sstevel@tonic-gate void
9460Sstevel@tonic-gate ddi_walk_devs(dev_info_t *, int (*)(dev_info_t *, void *), void *);
9470Sstevel@tonic-gate 
9480Sstevel@tonic-gate /*
9490Sstevel@tonic-gate  * Routines to get at elements of the dev_info structure
9500Sstevel@tonic-gate  */
9510Sstevel@tonic-gate 
9520Sstevel@tonic-gate /*
9530Sstevel@tonic-gate  * ddi_node_name gets the device's 'name' from the device node.
9540Sstevel@tonic-gate  *
9550Sstevel@tonic-gate  * ddi_binding_name gets the string the OS used to bind the node to a driver,
9560Sstevel@tonic-gate  * in certain cases, the binding name may be different from the node name,
9570Sstevel@tonic-gate  * if the node name does not name a specific device driver.
9580Sstevel@tonic-gate  *
9590Sstevel@tonic-gate  * ddi_get_name is a synonym for ddi_binding_name().
9600Sstevel@tonic-gate  */
9610Sstevel@tonic-gate char *
9620Sstevel@tonic-gate ddi_get_name(dev_info_t *dip);
9630Sstevel@tonic-gate 
9640Sstevel@tonic-gate char *
9650Sstevel@tonic-gate ddi_binding_name(dev_info_t *dip);
9660Sstevel@tonic-gate 
9670Sstevel@tonic-gate const char *
9680Sstevel@tonic-gate ddi_driver_name(dev_info_t *dip);
9690Sstevel@tonic-gate 
9700Sstevel@tonic-gate major_t
9710Sstevel@tonic-gate ddi_driver_major(dev_info_t *dip);
9720Sstevel@tonic-gate 
9730Sstevel@tonic-gate major_t
9740Sstevel@tonic-gate ddi_compatible_driver_major(dev_info_t *dip, char **formp);
9750Sstevel@tonic-gate 
9760Sstevel@tonic-gate char *
9770Sstevel@tonic-gate ddi_node_name(dev_info_t *dip);
9780Sstevel@tonic-gate 
9790Sstevel@tonic-gate int
9800Sstevel@tonic-gate ddi_get_nodeid(dev_info_t *dip);
9810Sstevel@tonic-gate 
9820Sstevel@tonic-gate int
9830Sstevel@tonic-gate ddi_get_instance(dev_info_t *dip);
9840Sstevel@tonic-gate 
9850Sstevel@tonic-gate struct dev_ops *
9860Sstevel@tonic-gate ddi_get_driver(dev_info_t *dip);
9870Sstevel@tonic-gate 
9880Sstevel@tonic-gate void
9890Sstevel@tonic-gate ddi_set_driver(dev_info_t *dip, struct dev_ops *devo);
9900Sstevel@tonic-gate 
9910Sstevel@tonic-gate void
9920Sstevel@tonic-gate ddi_set_driver_private(dev_info_t *dip, void *data);
9930Sstevel@tonic-gate 
9940Sstevel@tonic-gate void *
9950Sstevel@tonic-gate ddi_get_driver_private(dev_info_t *dip);
9960Sstevel@tonic-gate 
9970Sstevel@tonic-gate /*
9980Sstevel@tonic-gate  * ddi_dev_is_needed tells system that a device is about to use a
9990Sstevel@tonic-gate  * component. Returns when component is ready.
10000Sstevel@tonic-gate  */
10010Sstevel@tonic-gate int
10020Sstevel@tonic-gate ddi_dev_is_needed(dev_info_t *dip, int cmpt, int level);
10030Sstevel@tonic-gate 
10040Sstevel@tonic-gate /*
10050Sstevel@tonic-gate  * check if DDI_SUSPEND may result in power being removed from a device.
10060Sstevel@tonic-gate  */
10070Sstevel@tonic-gate int
10080Sstevel@tonic-gate ddi_removing_power(dev_info_t *dip);
10090Sstevel@tonic-gate 
10100Sstevel@tonic-gate /*
10110Sstevel@tonic-gate  *  (Obsolete) power entry point
10120Sstevel@tonic-gate  */
10130Sstevel@tonic-gate int
10140Sstevel@tonic-gate ddi_power(dev_info_t *dip, int cmpt, int level);
10150Sstevel@tonic-gate 
10160Sstevel@tonic-gate /*
10170Sstevel@tonic-gate  * ddi_get_parent requires that the branch of the tree with the
10180Sstevel@tonic-gate  * node be held (ddi_hold_installed_driver) or that the devinfo tree
10190Sstevel@tonic-gate  * lock be held
10200Sstevel@tonic-gate  */
10210Sstevel@tonic-gate dev_info_t *
10220Sstevel@tonic-gate ddi_get_parent(dev_info_t *dip);
10230Sstevel@tonic-gate 
10240Sstevel@tonic-gate /*
10250Sstevel@tonic-gate  * ddi_get_child and ddi_get_next_sibling require that the devinfo
10260Sstevel@tonic-gate  * tree lock be held
10270Sstevel@tonic-gate  */
10280Sstevel@tonic-gate dev_info_t *
10290Sstevel@tonic-gate ddi_get_child(dev_info_t *dip);
10300Sstevel@tonic-gate 
10310Sstevel@tonic-gate dev_info_t *
10320Sstevel@tonic-gate ddi_get_next_sibling(dev_info_t *dip);
10330Sstevel@tonic-gate 
10340Sstevel@tonic-gate dev_info_t *
10350Sstevel@tonic-gate ddi_get_next(dev_info_t *dip);
10360Sstevel@tonic-gate 
10370Sstevel@tonic-gate void
10380Sstevel@tonic-gate ddi_set_next(dev_info_t *dip, dev_info_t *nextdip);
10390Sstevel@tonic-gate 
10400Sstevel@tonic-gate /*
10410Sstevel@tonic-gate  * dev_info manipulation functions
10420Sstevel@tonic-gate  */
10430Sstevel@tonic-gate 
10440Sstevel@tonic-gate /*
10450Sstevel@tonic-gate  * Add and remove child devices. These are part of the system framework.
10460Sstevel@tonic-gate  *
10470Sstevel@tonic-gate  * ddi_add_child creates a dev_info structure with the passed name,
10480Sstevel@tonic-gate  * nodeid and instance arguments and makes it a child of pdip. Devices
10490Sstevel@tonic-gate  * that are known directly by the hardware have real nodeids; devices
10500Sstevel@tonic-gate  * that are software constructs use the defined DEVI_PSEUDO_NODEID
10510Sstevel@tonic-gate  * for the node id.
10520Sstevel@tonic-gate  *
10530Sstevel@tonic-gate  * ddi_remove_node removes the node from the tree. This fails if this
10540Sstevel@tonic-gate  * child has children. Parent and driver private data should already
10550Sstevel@tonic-gate  * be released (freed) prior to calling this function.  If flag is
10560Sstevel@tonic-gate  * non-zero, the child is removed from it's linked list of instances.
10570Sstevel@tonic-gate  */
10580Sstevel@tonic-gate dev_info_t *
10590Sstevel@tonic-gate ddi_add_child(dev_info_t *pdip, char *name, uint_t nodeid, uint_t instance);
10600Sstevel@tonic-gate 
10610Sstevel@tonic-gate int
10620Sstevel@tonic-gate ddi_remove_child(dev_info_t *dip, int flag);
10630Sstevel@tonic-gate 
10640Sstevel@tonic-gate /*
10650Sstevel@tonic-gate  * Given the major number for a driver, make sure that dev_info nodes
10660Sstevel@tonic-gate  * are created form the driver's hwconf file, the driver for the named
10670Sstevel@tonic-gate  * device is loaded and attached, as well as any drivers for parent devices.
10680Sstevel@tonic-gate  * Return a pointer to the driver's dev_ops struct with the dev_ops held.
10690Sstevel@tonic-gate  * Note - Callers must release the dev_ops with ddi_rele_driver.
10700Sstevel@tonic-gate  *
10710Sstevel@tonic-gate  * When a driver is held, the branch of the devinfo tree from any of the
10720Sstevel@tonic-gate  * drivers devinfos to the root node are automatically held.  This only
10730Sstevel@tonic-gate  * applies to tree traversals up (and back down) the tree following the
10740Sstevel@tonic-gate  * parent pointers.
10750Sstevel@tonic-gate  *
10760Sstevel@tonic-gate  * Use of this interface is discouraged, it may be removed in a future release.
10770Sstevel@tonic-gate  */
10780Sstevel@tonic-gate struct dev_ops *
10790Sstevel@tonic-gate ddi_hold_installed_driver(major_t major);
10800Sstevel@tonic-gate 
10810Sstevel@tonic-gate void
10820Sstevel@tonic-gate ddi_rele_driver(major_t major);
10830Sstevel@tonic-gate 
10840Sstevel@tonic-gate /*
10850Sstevel@tonic-gate  * Attach and hold the specified instance of a driver.  The flags argument
10860Sstevel@tonic-gate  * should be zero.
10870Sstevel@tonic-gate  */
10880Sstevel@tonic-gate dev_info_t *
10890Sstevel@tonic-gate ddi_hold_devi_by_instance(major_t major, int instance, int flags);
10900Sstevel@tonic-gate 
10910Sstevel@tonic-gate void
10920Sstevel@tonic-gate ddi_release_devi(dev_info_t *);
10930Sstevel@tonic-gate 
10940Sstevel@tonic-gate /*
10950Sstevel@tonic-gate  * Associate a streams queue with a devinfo node
10960Sstevel@tonic-gate  */
10970Sstevel@tonic-gate void
10980Sstevel@tonic-gate ddi_assoc_queue_with_devi(queue_t *, dev_info_t *);
10990Sstevel@tonic-gate 
11000Sstevel@tonic-gate /*
11010Sstevel@tonic-gate  * Given the identifier string passed, make sure that dev_info nodes
11020Sstevel@tonic-gate  * are created form the driver's hwconf file, the driver for the named
11030Sstevel@tonic-gate  * device is loaded and attached, as well as any drivers for parent devices.
11040Sstevel@tonic-gate  *
11050Sstevel@tonic-gate  * Note that the driver is not held and is subject to being removed the instant
11060Sstevel@tonic-gate  * this call completes.  You probably really want ddi_hold_installed_driver.
11070Sstevel@tonic-gate  */
11080Sstevel@tonic-gate int
11090Sstevel@tonic-gate ddi_install_driver(char *idstring);
11100Sstevel@tonic-gate 
11110Sstevel@tonic-gate /*
11120Sstevel@tonic-gate  * Routines that return specific nodes
11130Sstevel@tonic-gate  */
11140Sstevel@tonic-gate 
11150Sstevel@tonic-gate dev_info_t *
11160Sstevel@tonic-gate ddi_root_node(void);
11170Sstevel@tonic-gate 
11180Sstevel@tonic-gate /*
11190Sstevel@tonic-gate  * Given a name and an instance number, find and return the
11200Sstevel@tonic-gate  * dev_info from the current state of the device tree.
11210Sstevel@tonic-gate  *
11220Sstevel@tonic-gate  * If instance number is -1, return the first named instance.
11230Sstevel@tonic-gate  *
11240Sstevel@tonic-gate  * If attached is 1, exclude all nodes that are < DS_ATTACHED
11250Sstevel@tonic-gate  *
11260Sstevel@tonic-gate  * Requires that the devinfo tree be locked.
11270Sstevel@tonic-gate  * If attached is 1, the driver must be held.
11280Sstevel@tonic-gate  */
11290Sstevel@tonic-gate dev_info_t *
11300Sstevel@tonic-gate ddi_find_devinfo(char *name, int instance, int attached);
11310Sstevel@tonic-gate 
11320Sstevel@tonic-gate /*
11330Sstevel@tonic-gate  * DMA Mapping Setup
11340Sstevel@tonic-gate  *
11350Sstevel@tonic-gate  * The basic interface function is ddi_dma_setup(). This function
11360Sstevel@tonic-gate  * is to designed to allow a DMA mapping to be established to a
11370Sstevel@tonic-gate  * memory object. This function returns DDI_DMA_MAPPED if the
11380Sstevel@tonic-gate  * request was successfully filled. If this occurs, then the
11390Sstevel@tonic-gate  * argument handlep is filled in. This value is the DMA handle
11400Sstevel@tonic-gate  * for the mapping, and is used in a variety of other functions.
11410Sstevel@tonic-gate  * The handle is an opaque handle on the mapping, and no further
11420Sstevel@tonic-gate  * information may be inferred from it by the caller.
11430Sstevel@tonic-gate  *
11440Sstevel@tonic-gate  * Specifics of arguments to ddi_dma_setup:
11450Sstevel@tonic-gate  *
11460Sstevel@tonic-gate  * dip - devinfo pointer, which identifies the base device that wishes
11470Sstevel@tonic-gate  * to establish a dma mapping. The device may either be a leaf device,
11480Sstevel@tonic-gate  * or a device which is both a leaf and a nexus (e.g., a device which
11490Sstevel@tonic-gate  * has a dma engine but no children devices).
11500Sstevel@tonic-gate  *
11510Sstevel@tonic-gate  * dmareqp - pointer to a dma request structure. This structure contains
11520Sstevel@tonic-gate  * all the info necessary to establish the mapping (see <sys/ddidmareq.h>).
11530Sstevel@tonic-gate  * This structure may be impermanent, as its information is copied and
11540Sstevel@tonic-gate  * saved, if necessary, by implementation specific functions. The caller
11550Sstevel@tonic-gate  * is responsible for filling in the dmar_flags, dmar_length, dmar_type,
11560Sstevel@tonic-gate  * dmar_addr_un, dmar_fp and dmar_arg fields. Any other elements of the
11570Sstevel@tonic-gate  * ddi_dma_req structure should neither be examined or modified by the
11580Sstevel@tonic-gate  * caller.
11590Sstevel@tonic-gate  *
11600Sstevel@tonic-gate  * handlep - this is a pointer to a ddi_dma_handle_t. It is the callers
11610Sstevel@tonic-gate  * responsibility to hang on to this handle, because it becomes the token
11620Sstevel@tonic-gate  * used in all other DDI dma functions. If the handle pointer is NULL,
11630Sstevel@tonic-gate  * then no mapping is made, and the call is being used by the caller
11640Sstevel@tonic-gate  * to simply determine whether such a mapping *could* be made.
11650Sstevel@tonic-gate  *
11660Sstevel@tonic-gate  * Discussion of DMA resource callback functions:
11670Sstevel@tonic-gate  *
11680Sstevel@tonic-gate  * If a request could not be filled, it was because either there were
11690Sstevel@tonic-gate  * not enough mapping resources available to satisfy the request, and the
11700Sstevel@tonic-gate  * dmar_fp field was not set to DDI_DMA_SLEEP, or the mapping could not
11710Sstevel@tonic-gate  * be established at all (DDI_DMA_NOMAPPING) due to a basic inability of
11720Sstevel@tonic-gate  * available hardware to map the object. Callers should be prepared to deal
11730Sstevel@tonic-gate  * with all possible returns. It is suggested that the appropriate system
11740Sstevel@tonic-gate  * error number for the DDI_DMA_NOMAPPING returns is EFAULT.
11750Sstevel@tonic-gate  *
11760Sstevel@tonic-gate  * If the caller does not care whether a DMA mapping can be set up now,
11770Sstevel@tonic-gate  * the caller should set the field dmar_fp to DDI_DMA_DONTWAIT. This
11780Sstevel@tonic-gate  * implies that the caller will appropriately deal with resource
11790Sstevel@tonic-gate  * exhaustion.
11800Sstevel@tonic-gate  *
11810Sstevel@tonic-gate  * If the caller either cannot or does not wish to sleep awaiting mapping
11820Sstevel@tonic-gate  * resources, the caller may specify, via the field dmar_fp, a function to
11830Sstevel@tonic-gate  * call with the argument specified in dmar_arg, when resources might have
11840Sstevel@tonic-gate  * become available. The callback function will be called from interrupt
11850Sstevel@tonic-gate  * context, but in such a fashion to guarantee that spl blocking (in systems
11860Sstevel@tonic-gate  * that use this method of data protection) by the caller will not be
11870Sstevel@tonic-gate  * bypassed.
11880Sstevel@tonic-gate  *
11890Sstevel@tonic-gate  *
11900Sstevel@tonic-gate  * When function specified via dmar_fp is called, it may attempt to try and get
11910Sstevel@tonic-gate  * the mapping again. If it succeeds in getting the mapping, or does not need
11920Sstevel@tonic-gate  * to get the mapping any more, it must return 1. If it tries to get the
11930Sstevel@tonic-gate  * mapping but fails to do so, and it wants to be called back later, it
11940Sstevel@tonic-gate  * must return 0.
11950Sstevel@tonic-gate  *
11960Sstevel@tonic-gate  * Failure to observe this protocol will have unpredictable results.
11970Sstevel@tonic-gate  *
11980Sstevel@tonic-gate  * The callback function must provide its own data structure integrity
11990Sstevel@tonic-gate  * when it is invoked.
12000Sstevel@tonic-gate  */
12010Sstevel@tonic-gate 
12020Sstevel@tonic-gate int
12030Sstevel@tonic-gate ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp,
12040Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
12050Sstevel@tonic-gate 
12060Sstevel@tonic-gate /*
12070Sstevel@tonic-gate  * The following three functions are convenience wrappers for ddi_dma_setup().
12080Sstevel@tonic-gate  */
12090Sstevel@tonic-gate 
12100Sstevel@tonic-gate int
12110Sstevel@tonic-gate ddi_dma_addr_setup(dev_info_t *dip, struct as *as, caddr_t addr, size_t len,
12120Sstevel@tonic-gate 	uint_t flags, int (*waitfp)(), caddr_t arg,
12130Sstevel@tonic-gate 	ddi_dma_lim_t *limits, ddi_dma_handle_t *handlep);
12140Sstevel@tonic-gate 
12150Sstevel@tonic-gate int
12160Sstevel@tonic-gate ddi_dma_buf_setup(dev_info_t *dip, struct buf *bp, uint_t flags,
12170Sstevel@tonic-gate 	int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits,
12180Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
12190Sstevel@tonic-gate 
12200Sstevel@tonic-gate /*
12210Sstevel@tonic-gate  * Kernel addressability of the DMA object
12220Sstevel@tonic-gate  *
12230Sstevel@tonic-gate  * It might often be very useful to be able to get an IU mapping
12240Sstevel@tonic-gate  * to the object which has DMA active to/from it. In fact, it might
12250Sstevel@tonic-gate  * even really be a requirement.
12260Sstevel@tonic-gate  *
12270Sstevel@tonic-gate  * The cacheability of the object with respect to I/O and I/U caches
12280Sstevel@tonic-gate  * is affected by this function as follows:
12290Sstevel@tonic-gate  *
12300Sstevel@tonic-gate  *	If a kernel virtual mapping to the object owned by the handle
12310Sstevel@tonic-gate  *	existed already, and is IU cacheable, then the extant mapping
12320Sstevel@tonic-gate  *	is locked and returned in kaddrp. By inference, kaddrp will
12330Sstevel@tonic-gate  *	be an IU cacheable reference.
12340Sstevel@tonic-gate  *
12350Sstevel@tonic-gate  *	If a kernel virtual mapping to the object owned by the handle
12360Sstevel@tonic-gate  *	existed already, and is not IU cacheable, then the extant mapping
12370Sstevel@tonic-gate  *	is locked and returned in kaddrp. By inference, kaddrp will
12380Sstevel@tonic-gate  *	*not* be an IU cacheable reference.
12390Sstevel@tonic-gate  *
12400Sstevel@tonic-gate  *	If a kernel virtual mapping to the object owned by the handle
12410Sstevel@tonic-gate  *	does not exist already, a mapping will be created that will
12420Sstevel@tonic-gate  *	*not* be an IU cacheable reference.
12430Sstevel@tonic-gate  *
12440Sstevel@tonic-gate  *	The IO cacheability of the object owned by the handle is ignored
12450Sstevel@tonic-gate  *	and unaffected.
12460Sstevel@tonic-gate  *
12470Sstevel@tonic-gate  * This function returns the mapping values as describe above.
12480Sstevel@tonic-gate  *
12490Sstevel@tonic-gate  * When the DMA object owned by handle is freed (by ddi_dma_free()- see
12500Sstevel@tonic-gate  * below), any mappings created by ddi_dma_kvaddrp() cease to be valid.
12510Sstevel@tonic-gate  * This will be the convention that drivers must follow, as it will be
12520Sstevel@tonic-gate  * impossible to enforce this programmatically.
12530Sstevel@tonic-gate  */
12540Sstevel@tonic-gate 
12550Sstevel@tonic-gate int
12560Sstevel@tonic-gate ddi_dma_kvaddrp(ddi_dma_handle_t, off_t, size_t, caddr_t *);
12570Sstevel@tonic-gate 
12580Sstevel@tonic-gate 
12590Sstevel@tonic-gate /*
12600Sstevel@tonic-gate  * Device addressability of the DMA object
12610Sstevel@tonic-gate  *
12620Sstevel@tonic-gate  * The handle that identifies an object mapped for DMA is an opaque entity.
12630Sstevel@tonic-gate  * When a device driver wishes to load its dma engine with the appropriate
12640Sstevel@tonic-gate  * values for transferring data to the mapped object, it has to get the
12650Sstevel@tonic-gate  * value. Since the exact shape and form of this address is device specific,
12660Sstevel@tonic-gate  * the value returned is a 'cookie' that each device may then interpret
12670Sstevel@tonic-gate  * as it needs to. See <sys/dditypes.h> for the form of what the DMA cookie
12680Sstevel@tonic-gate  * looks like.
12690Sstevel@tonic-gate  *
12700Sstevel@tonic-gate  * Returns DDI_SUCCESS for successful cookie generation,
12710Sstevel@tonic-gate  * or DDI_FAILURE if it cannot generate the DMA cookie.
12720Sstevel@tonic-gate  */
12730Sstevel@tonic-gate 
12740Sstevel@tonic-gate int
12750Sstevel@tonic-gate ddi_dma_htoc(ddi_dma_handle_t handle, off_t off, ddi_dma_cookie_t *cookiep);
12760Sstevel@tonic-gate 
12770Sstevel@tonic-gate /*
12780Sstevel@tonic-gate  * Given a DMA cookie, return its offset within the object referred to
12790Sstevel@tonic-gate  * by the DMA handle. This is so at the end of a dma transfer, the device
12800Sstevel@tonic-gate  * may take its specific ending address and find out how far into the
12810Sstevel@tonic-gate  * memory object described by the handle the device got.
12820Sstevel@tonic-gate  */
12830Sstevel@tonic-gate 
12840Sstevel@tonic-gate int
12850Sstevel@tonic-gate ddi_dma_coff(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep, off_t *offp);
12860Sstevel@tonic-gate 
12870Sstevel@tonic-gate /*
12880Sstevel@tonic-gate  * DMA mapping manipulation
12890Sstevel@tonic-gate  *
12900Sstevel@tonic-gate  * It may be desirable or convenient for some devices to allow partial
12910Sstevel@tonic-gate  * mapping of an object for dma. This allows the mapping for DMA of
12920Sstevel@tonic-gate  * arbitrarily large objects since only a portion of the object may
12930Sstevel@tonic-gate  * be mapped for DMA at any point in time.
12940Sstevel@tonic-gate  *
12950Sstevel@tonic-gate  * In order to support this as well as other operations, the paradigm
12960Sstevel@tonic-gate  * of a 'mapping window' is defined here. The object to be mapped has
12970Sstevel@tonic-gate  * attributes of location and length. A window can be established upon
12980Sstevel@tonic-gate  * this object. The window has attributes of offset (from the base mapping
12990Sstevel@tonic-gate  * of the object) and length. It is assumed that length and offset are
13000Sstevel@tonic-gate  * positive with respect to the base of the mapped object.
13010Sstevel@tonic-gate  *
13020Sstevel@tonic-gate  * In order to get support for such a window, the flag DDI_DMA_PARTIAL
13030Sstevel@tonic-gate  * must be set in the request flags when the object is mapped for DMA.
13040Sstevel@tonic-gate  * Each implementation may elect whether or not to support such an
13050Sstevel@tonic-gate  * operation. Each implementation may also choose to ignore the request
13060Sstevel@tonic-gate  * for a PARTIAL mapping and either reject the mapping of the object
13070Sstevel@tonic-gate  * for being too big (DDI_DMA_TOOBIG) or may map the entire object.
13080Sstevel@tonic-gate  * The caller who asks the object to be mapped for DMA will know
13090Sstevel@tonic-gate  * whether a partial mapping has been made by receiving the qualified
13100Sstevel@tonic-gate  * return value of DDI_DMA_PARTIAL_MAP instead of DDI_DMA_MAPPED.
13110Sstevel@tonic-gate  * All dma window functions will return DDI_FAILURE if the object
13120Sstevel@tonic-gate  * is not mapped partially.
13130Sstevel@tonic-gate  *
13140Sstevel@tonic-gate  * All other DDI dma functions (except ddi_dma_Free) operate *only* on
13150Sstevel@tonic-gate  * the mapped portion of the object. That is, functions such as ddi_dma_sync,
13160Sstevel@tonic-gate  * ddi_dma_segtocookie, and so on, only operate on the currently mapped
13170Sstevel@tonic-gate  * window.
13180Sstevel@tonic-gate  */
13190Sstevel@tonic-gate 
13200Sstevel@tonic-gate #if defined(__sparc)
13210Sstevel@tonic-gate 
13220Sstevel@tonic-gate /*
13230Sstevel@tonic-gate  * ddi_dma_movwin - Move window from current offset/length to new
13240Sstevel@tonic-gate  * offset/length. Returns DDI_SUCCESS if able to do so, else returns
13250Sstevel@tonic-gate  * DDI_FAILURE if unable to do so, or the new window would be out of bounds
13260Sstevel@tonic-gate  * or the object isn't set up for windows. If length is (off_t) -1, the
13270Sstevel@tonic-gate  * If the optional cp argument is specified, an implicit ddi_dma_htoc
13280Sstevel@tonic-gate  * is done to fill that in. The new offset and length will be returned
13290Sstevel@tonic-gate  * in the arguments *offp and *lenp (resp).
13300Sstevel@tonic-gate  *
13310Sstevel@tonic-gate  * In this implementation, only fixed width windows are used. It is
13320Sstevel@tonic-gate  * recommended that the windowsize should be retrieved via the function
13330Sstevel@tonic-gate  * ddi_dma_curwin (below) and that used to specify new offsets and lengths
13340Sstevel@tonic-gate  * since the window will be fixed at that size and will only move modulo
13350Sstevel@tonic-gate  * winsize.
13360Sstevel@tonic-gate  *
13370Sstevel@tonic-gate  * The caller must guarantee that their device's dma engine is quiescent
13380Sstevel@tonic-gate  * with respect to the current DMA window.
13390Sstevel@tonic-gate  *
13400Sstevel@tonic-gate  * The implementation will try to be rapid with respect to moving a window,
13410Sstevel@tonic-gate  * but since an appropriate ddi_dma_sync() is likely to be done, there
13420Sstevel@tonic-gate  * will be no guaranteed latency. In practice this should not be too
13430Sstevel@tonic-gate  * horrible, but don't depend upon any particular latency.
13440Sstevel@tonic-gate  */
13450Sstevel@tonic-gate 
13460Sstevel@tonic-gate int
13470Sstevel@tonic-gate ddi_dma_movwin(ddi_dma_handle_t, off_t *offp, size_t *lenp, ddi_dma_cookie_t *);
13480Sstevel@tonic-gate 
13490Sstevel@tonic-gate #endif
13500Sstevel@tonic-gate 
13510Sstevel@tonic-gate /*
13520Sstevel@tonic-gate  * ddi_dma_curwin - report the current offset/length of the window.
13530Sstevel@tonic-gate  *
13540Sstevel@tonic-gate  * Returns DDI_SUCCESS if offset and length
13550Sstevel@tonic-gate  * successfully established, else DDI_FAILURE.
13560Sstevel@tonic-gate  */
13570Sstevel@tonic-gate 
13580Sstevel@tonic-gate int
13590Sstevel@tonic-gate ddi_dma_curwin(ddi_dma_handle_t handle, off_t *offp, size_t *lenp);
13600Sstevel@tonic-gate 
13610Sstevel@tonic-gate /*
13620Sstevel@tonic-gate  * Get next dma window
13630Sstevel@tonic-gate  *
13640Sstevel@tonic-gate  * ddi_dma_nextwin takes a handle and a window, and fills in a pointer to
13650Sstevel@tonic-gate  * the next window within the object. If win is "NULL", a pointer to the
13660Sstevel@tonic-gate  * first window within the object is filled in.
13670Sstevel@tonic-gate  *
13680Sstevel@tonic-gate  * Returns	DDI_SUCCESS if successfully filled in the window pointer,
13690Sstevel@tonic-gate  *		DDI_DMA_STALE if win does not refer to the currently active
13700Sstevel@tonic-gate  *				 window,
13710Sstevel@tonic-gate  *		DDI_DMA_DONE else there is no next window.
13720Sstevel@tonic-gate  */
13730Sstevel@tonic-gate 
13740Sstevel@tonic-gate int
13750Sstevel@tonic-gate ddi_dma_nextwin(ddi_dma_handle_t, ddi_dma_win_t, ddi_dma_win_t *);
13760Sstevel@tonic-gate 
13770Sstevel@tonic-gate /*
13780Sstevel@tonic-gate  * Get next segment
13790Sstevel@tonic-gate  *
13800Sstevel@tonic-gate  * ddi_dma_nextseg takes a window and a segment and fills in a pointer to
13810Sstevel@tonic-gate  * the next segment within the window. If seg is "NULL", a pointer to the
13820Sstevel@tonic-gate  * first segment within the window is filled in.
13830Sstevel@tonic-gate  *
13840Sstevel@tonic-gate  * Returns	DDI_SUCCESS if successfully filled in the segment pointer,
13850Sstevel@tonic-gate  *		DDI_DMA_STALE if win does not refer to the currently active
13860Sstevel@tonic-gate  *				 window.
13870Sstevel@tonic-gate  *		DDI_DMA_DONE else there is no next segment.
13880Sstevel@tonic-gate  */
13890Sstevel@tonic-gate 
13900Sstevel@tonic-gate int
13910Sstevel@tonic-gate ddi_dma_nextseg(ddi_dma_win_t, ddi_dma_seg_t, ddi_dma_seg_t *);
13920Sstevel@tonic-gate 
13930Sstevel@tonic-gate /*
13940Sstevel@tonic-gate  * Segment to cookie
13950Sstevel@tonic-gate  *
13960Sstevel@tonic-gate  * ddi_dma_segtocookie takes a segment and fills in the cookie pointed
13970Sstevel@tonic-gate  * to by cookiep with the appropriate address, length and bus type to be
13980Sstevel@tonic-gate  * used to program the DMA engine. ddi_dma_segtocookie also fills in the
13990Sstevel@tonic-gate  * range within the object (specified by <off, len>) this particular
14000Sstevel@tonic-gate  * segment is mapping. <off, len> are filled in to give some control
14010Sstevel@tonic-gate  * where in the object the current dma transfer is active.
14020Sstevel@tonic-gate  *
14030Sstevel@tonic-gate  * Returns	DDI_SUCCESS if successfully filled in all values,
14040Sstevel@tonic-gate  * else		DDI_FAILURE
14050Sstevel@tonic-gate  *
14060Sstevel@tonic-gate  * This function is documented as Obsolete and is replaced by
14070Sstevel@tonic-gate  * ddi_dma_nextcookie(9F)
14080Sstevel@tonic-gate  */
14090Sstevel@tonic-gate 
14100Sstevel@tonic-gate int
14110Sstevel@tonic-gate ddi_dma_segtocookie(ddi_dma_seg_t, off_t *, off_t *, ddi_dma_cookie_t *);
14120Sstevel@tonic-gate 
14130Sstevel@tonic-gate /*
14140Sstevel@tonic-gate  * Synchronization of I/O with respect to various
14150Sstevel@tonic-gate  * caches and system write buffers.
14160Sstevel@tonic-gate  *
14170Sstevel@tonic-gate  * Done at varying points during an I/O transfer (including at the
14180Sstevel@tonic-gate  * removal of an I/O mapping).
14190Sstevel@tonic-gate  *
14200Sstevel@tonic-gate  * Due to the support of systems with write buffers which may
14210Sstevel@tonic-gate  * not be able to be turned off, this function *must* used at
14220Sstevel@tonic-gate  * any point in which data consistency might be required.
14230Sstevel@tonic-gate  *
14240Sstevel@tonic-gate  * Generally this means that if a memory object has multiple mappings
14250Sstevel@tonic-gate  * (both for I/O, as described by the handle, and the IU, via, e.g.
14260Sstevel@tonic-gate  * a call to ddi_dma_kvaddrp), and one mapping may have been
14270Sstevel@tonic-gate  * used to modify the memory object, this function must be called
14280Sstevel@tonic-gate  * to ensure that the modification of the memory object is
14290Sstevel@tonic-gate  * complete, as well as possibly to inform other mappings of
14300Sstevel@tonic-gate  * the object that any cached references to the object are
14310Sstevel@tonic-gate  * now stale (and flush or invalidate these stale cache references
14320Sstevel@tonic-gate  * as necessary).
14330Sstevel@tonic-gate  *
14340Sstevel@tonic-gate  * The function ddi_dma_sync() provides the general interface with
14350Sstevel@tonic-gate  * respect to this capability. Generally, ddi_dma_free() (below) may
14360Sstevel@tonic-gate  * be used in preference to ddi_dma_sync() as ddi_dma_free() calls
14370Sstevel@tonic-gate  * ddi_dma_sync().
14380Sstevel@tonic-gate  *
14390Sstevel@tonic-gate  * Returns 0 if all caches that exist and are specified by cache_flags
14400Sstevel@tonic-gate  * are successfully operated on, else -1.
14410Sstevel@tonic-gate  *
14420Sstevel@tonic-gate  * The argument offset specifies an offset into the mapping of the mapped
14430Sstevel@tonic-gate  * object in which to perform the synchronization. It will be silently
14440Sstevel@tonic-gate  * truncated to the granularity of underlying cache line sizes as
14450Sstevel@tonic-gate  * appropriate.
14460Sstevel@tonic-gate  *
14470Sstevel@tonic-gate  * The argument len specifies a length starting from offset in which to
14480Sstevel@tonic-gate  * perform the synchronization. A value of (uint_t) -1 means that the length
14490Sstevel@tonic-gate  * proceeds from offset to the end of the mapping. The length argument
14500Sstevel@tonic-gate  * will silently rounded up to the granularity of underlying cache line
14510Sstevel@tonic-gate  * sizes  as appropriate.
14520Sstevel@tonic-gate  *
14530Sstevel@tonic-gate  * The argument flags specifies what to synchronize (the device's view of
14540Sstevel@tonic-gate  * the object or the cpu's view of the object).
14550Sstevel@tonic-gate  *
14560Sstevel@tonic-gate  * Inquiring minds want to know when ddi_dma_sync should be used:
14570Sstevel@tonic-gate  *
14580Sstevel@tonic-gate  * +	When an object is mapped for dma, assume that an
14590Sstevel@tonic-gate  *	implicit ddi_dma_sync() is done for you.
14600Sstevel@tonic-gate  *
14610Sstevel@tonic-gate  * +	When an object is unmapped (ddi_dma_free()), assume
14620Sstevel@tonic-gate  *	that an implicit ddi_dma_sync() is done for you.
14630Sstevel@tonic-gate  *
14640Sstevel@tonic-gate  * +	At any time between the two times above that the
14650Sstevel@tonic-gate  *	memory object may have been modified by either
14660Sstevel@tonic-gate  *	the DMA device or a processor and you wish that
14670Sstevel@tonic-gate  *	the change be noticed by the master that didn't
14680Sstevel@tonic-gate  *	do the modifying.
14690Sstevel@tonic-gate  *
14700Sstevel@tonic-gate  * Clearly, only the third case above requires the use of ddi_dma_sync.
14710Sstevel@tonic-gate  *
14720Sstevel@tonic-gate  * Inquiring minds also want to know which flag to use:
14730Sstevel@tonic-gate  *
14740Sstevel@tonic-gate  * +	If you *modify* with a cpu the object, you use
14750Sstevel@tonic-gate  *	ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure
14760Sstevel@tonic-gate  *	that the DMA device sees the changes you made).
14770Sstevel@tonic-gate  *
14780Sstevel@tonic-gate  * +	If you are checking, with the processor, an area
14790Sstevel@tonic-gate  *	of the object that the DMA device *may* have modified,
14800Sstevel@tonic-gate  *	you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are
14810Sstevel@tonic-gate  *	making sure that the processor(s) will see the changes
14820Sstevel@tonic-gate  *	that the DMA device may have made).
14830Sstevel@tonic-gate  */
14840Sstevel@tonic-gate 
14850Sstevel@tonic-gate int
14860Sstevel@tonic-gate ddi_dma_sync(ddi_dma_handle_t handle, off_t offset, size_t len, uint_t flags);
14870Sstevel@tonic-gate 
14880Sstevel@tonic-gate /*
14890Sstevel@tonic-gate  * DMA mapping de-allocation
14900Sstevel@tonic-gate  *
14910Sstevel@tonic-gate  * When an I/O transfer completes, the resources required to map the
14920Sstevel@tonic-gate  * object for DMA should be completely released. As a side effect,
14930Sstevel@tonic-gate  * various cache synchronization might need to occur (see above).
14940Sstevel@tonic-gate  *
14950Sstevel@tonic-gate  * Returns DDI_SUCCESS if the all underlying caches are successfully
14960Sstevel@tonic-gate  * flushed, else DDI_FAILURE.
14970Sstevel@tonic-gate  *
14980Sstevel@tonic-gate  */
14990Sstevel@tonic-gate 
15000Sstevel@tonic-gate int
15010Sstevel@tonic-gate ddi_dma_free(ddi_dma_handle_t handle);
15020Sstevel@tonic-gate 
15030Sstevel@tonic-gate /*
15040Sstevel@tonic-gate  * Device constraint cognizant kernel memory allocation- consistent access.
15050Sstevel@tonic-gate  *
15060Sstevel@tonic-gate  * IOPB allocation and de-allocation
15070Sstevel@tonic-gate  *
15080Sstevel@tonic-gate  * An IOPB allocation allocates some primary memory such that both
15090Sstevel@tonic-gate  * the kernel and the specified DMA device might be able to access it in a
15100Sstevel@tonic-gate  * non-cacheable (otherwise known as byte-consistent or non-streaming mode)
15110Sstevel@tonic-gate  * fashion. The allocation will obey the beginning alignment and padding
15120Sstevel@tonic-gate  * constraints as specified in the initial limits argument and as subsequently
15130Sstevel@tonic-gate  * modified by intervening parents. The limits argument may be NULL, in
15140Sstevel@tonic-gate  * which case the system picks a reasonable beginning limits.
15150Sstevel@tonic-gate  *
15160Sstevel@tonic-gate  * A kernel virtual address to the allocated primary memory is returned,
15170Sstevel@tonic-gate  * but no DMA mapping to the object is established (drivers must use the
15180Sstevel@tonic-gate  * ddi_dma_map() routines for that).
15190Sstevel@tonic-gate  *
15200Sstevel@tonic-gate  * If no iopb space can be allocated, DDI_FAILURE is returned.
15210Sstevel@tonic-gate  */
15220Sstevel@tonic-gate 
15230Sstevel@tonic-gate int
15240Sstevel@tonic-gate ddi_iopb_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length,
15250Sstevel@tonic-gate 	caddr_t *iopbp);
15260Sstevel@tonic-gate 
15270Sstevel@tonic-gate /*
15280Sstevel@tonic-gate  * Deallocate an IOPB kernel virtual mapping.
15290Sstevel@tonic-gate  */
15300Sstevel@tonic-gate 
15310Sstevel@tonic-gate void
15320Sstevel@tonic-gate ddi_iopb_free(caddr_t iopb);
15330Sstevel@tonic-gate 
15340Sstevel@tonic-gate /*
15350Sstevel@tonic-gate  * Device constraint cognizant kernel memory allocation- streaming access.
15360Sstevel@tonic-gate  *
15370Sstevel@tonic-gate  * Similar to ddi_iopb_alloc, but for primary memory that is intended
15380Sstevel@tonic-gate  * to be accessed in a streaming fashion. The allocation will obey the
15390Sstevel@tonic-gate  * beginning alignment and padding constraints as specified in the initial
15400Sstevel@tonic-gate  * limits argument and as subsequently modified by intervening parents.
15410Sstevel@tonic-gate  * The limits argument may be NULL, in which case the system picks a
15420Sstevel@tonic-gate  * reasonable beginning limits.
15430Sstevel@tonic-gate  *
15440Sstevel@tonic-gate  * A flags value of 0x1 indicates whether the caller can wait for
15450Sstevel@tonic-gate  * memory to become available. Other bits in the flags argument
15460Sstevel@tonic-gate  * are reserved for future use and must be zero.
15470Sstevel@tonic-gate  *
15480Sstevel@tonic-gate  * Upon return from a successful call, the new real length of
15490Sstevel@tonic-gate  * the allocation is returned (for use in mapping the memory
15500Sstevel@tonic-gate  * later).
15510Sstevel@tonic-gate  */
15520Sstevel@tonic-gate 
15530Sstevel@tonic-gate int
15540Sstevel@tonic-gate ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length,
15550Sstevel@tonic-gate 	uint_t flags, caddr_t *kaddrp, uint_t *real_length);
15560Sstevel@tonic-gate 
15570Sstevel@tonic-gate /*
15580Sstevel@tonic-gate  * Free the memory allocated via ddi_mem_alloc().
15590Sstevel@tonic-gate  *
15600Sstevel@tonic-gate  * Note that passing an address not allocated via ddi_mem_alloc()
15610Sstevel@tonic-gate  * will panic the system.
15620Sstevel@tonic-gate  */
15630Sstevel@tonic-gate 
15640Sstevel@tonic-gate void
15650Sstevel@tonic-gate ddi_mem_free(caddr_t kaddr);
15660Sstevel@tonic-gate 
15670Sstevel@tonic-gate /*
15680Sstevel@tonic-gate  * Dma alignment, minimum transfers sizes, and burst sizes allowed.
15690Sstevel@tonic-gate  * Some with tears, some without.
15700Sstevel@tonic-gate  */
15710Sstevel@tonic-gate 
15720Sstevel@tonic-gate /*
15730Sstevel@tonic-gate  * Return a copy of the DMA attributes for the given handle.
15740Sstevel@tonic-gate  */
15750Sstevel@tonic-gate 
15760Sstevel@tonic-gate int
15770Sstevel@tonic-gate ddi_dma_get_attr(ddi_dma_handle_t handle, ddi_dma_attr_t *attrp);
15780Sstevel@tonic-gate 
15790Sstevel@tonic-gate /*
15800Sstevel@tonic-gate  * Return the allowable DMA burst size for the object mapped by handle.
15810Sstevel@tonic-gate  * The burst sizes will returned in an integer that encodes power
15820Sstevel@tonic-gate  * of two burst sizes that are allowed in bit encoded format. For
15830Sstevel@tonic-gate  * example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts
15840Sstevel@tonic-gate  * would be encoded as 0x2f. A transfer that could be allowed as solely
15850Sstevel@tonic-gate  * a halfword (2 byte) transfers would be returned as 0x2.
15860Sstevel@tonic-gate  */
15870Sstevel@tonic-gate 
15880Sstevel@tonic-gate int
15890Sstevel@tonic-gate ddi_dma_burstsizes(ddi_dma_handle_t handle);
15900Sstevel@tonic-gate 
15910Sstevel@tonic-gate /*
15920Sstevel@tonic-gate  * Return the required beginning alignment for a transfer and
15930Sstevel@tonic-gate  * the minimum sized effect a transfer would have. The beginning
15940Sstevel@tonic-gate  * alignment will be some power of two. The minimum sized effect
15950Sstevel@tonic-gate  * indicates, for writes, how much of the mapped object will be
15960Sstevel@tonic-gate  * affected by the minimum access and for reads how much of the
15970Sstevel@tonic-gate  * mapped object will accessed.
15980Sstevel@tonic-gate  */
15990Sstevel@tonic-gate 
16000Sstevel@tonic-gate int
16010Sstevel@tonic-gate ddi_dma_devalign(ddi_dma_handle_t handle, uint_t *alignment, uint_t *mineffect);
16020Sstevel@tonic-gate 
16030Sstevel@tonic-gate /*
16040Sstevel@tonic-gate  * Like ddi_dma_devalign, but without having to map the object.
16050Sstevel@tonic-gate  * The object is assumed to be primary memory, and it is assumed
16060Sstevel@tonic-gate  * a minimum effective transfer is also the appropriate alignment
16070Sstevel@tonic-gate  * to be using. The streaming flag, if non-zero, indicates that the
16080Sstevel@tonic-gate  * returned value should be modified to account for streaming mode
16090Sstevel@tonic-gate  * accesses (e.g., with I/O caches enabled). The initial value
16100Sstevel@tonic-gate  * is passed by the requester if it has a dma engine that has
16110Sstevel@tonic-gate  * a minimum cycle constraint (or, for streaming mode, the most
16120Sstevel@tonic-gate  * efficient size).
16130Sstevel@tonic-gate  */
16140Sstevel@tonic-gate 
16150Sstevel@tonic-gate int
16160Sstevel@tonic-gate ddi_iomin(dev_info_t *dip, int initial, int streaming);
16170Sstevel@tonic-gate 
16180Sstevel@tonic-gate /*
16190Sstevel@tonic-gate  * Given two DMA limit structures, apply the limitations
16200Sstevel@tonic-gate  * of one to the other, following the rules of limits
16210Sstevel@tonic-gate  * and the wishes of the caller.
16220Sstevel@tonic-gate  *
16230Sstevel@tonic-gate  * The rules of dma limit structures are that you cannot
16240Sstevel@tonic-gate  * make things *less* restrictive as you apply one set
16250Sstevel@tonic-gate  * of limits to another.
16260Sstevel@tonic-gate  *
16270Sstevel@tonic-gate  */
16280Sstevel@tonic-gate 
16290Sstevel@tonic-gate void
16300Sstevel@tonic-gate ddi_dmalim_merge(ddi_dma_lim_t *limit, ddi_dma_lim_t *modifier);
16310Sstevel@tonic-gate 
16320Sstevel@tonic-gate /*
16330Sstevel@tonic-gate  * Merge DMA attributes
16340Sstevel@tonic-gate  */
16350Sstevel@tonic-gate 
16360Sstevel@tonic-gate void
16370Sstevel@tonic-gate ddi_dma_attr_merge(ddi_dma_attr_t *attr, ddi_dma_attr_t *mod);
16380Sstevel@tonic-gate 
16390Sstevel@tonic-gate /*
16400Sstevel@tonic-gate  * Allocate a DMA handle
16410Sstevel@tonic-gate  */
16420Sstevel@tonic-gate 
16430Sstevel@tonic-gate int
16440Sstevel@tonic-gate ddi_dma_alloc_handle(dev_info_t *dip, ddi_dma_attr_t *attr,
16450Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg,
16460Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
16470Sstevel@tonic-gate 
16480Sstevel@tonic-gate /*
16490Sstevel@tonic-gate  * Free DMA handle
16500Sstevel@tonic-gate  */
16510Sstevel@tonic-gate 
16520Sstevel@tonic-gate void
16530Sstevel@tonic-gate ddi_dma_free_handle(ddi_dma_handle_t *handlep);
16540Sstevel@tonic-gate 
16550Sstevel@tonic-gate /*
16560Sstevel@tonic-gate  * Allocate memory for DMA transfers
16570Sstevel@tonic-gate  */
16580Sstevel@tonic-gate 
16590Sstevel@tonic-gate int
16600Sstevel@tonic-gate ddi_dma_mem_alloc(ddi_dma_handle_t handle, size_t length,
16610Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, uint_t xfermodes,
16620Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg, caddr_t *kaddrp,
16630Sstevel@tonic-gate 	size_t *real_length, ddi_acc_handle_t *handlep);
16640Sstevel@tonic-gate 
16650Sstevel@tonic-gate /*
16660Sstevel@tonic-gate  * Free DMA memory
16670Sstevel@tonic-gate  */
16680Sstevel@tonic-gate 
16690Sstevel@tonic-gate void
16700Sstevel@tonic-gate ddi_dma_mem_free(ddi_acc_handle_t *hp);
16710Sstevel@tonic-gate 
16720Sstevel@tonic-gate /*
16730Sstevel@tonic-gate  * bind address to a DMA handle
16740Sstevel@tonic-gate  */
16750Sstevel@tonic-gate 
16760Sstevel@tonic-gate int
16770Sstevel@tonic-gate ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as,
16780Sstevel@tonic-gate 	caddr_t addr, size_t len, uint_t flags,
16790Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg,
16800Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, uint_t *ccountp);
16810Sstevel@tonic-gate 
16820Sstevel@tonic-gate /*
16830Sstevel@tonic-gate  * bind buffer to DMA handle
16840Sstevel@tonic-gate  */
16850Sstevel@tonic-gate 
16860Sstevel@tonic-gate int
16870Sstevel@tonic-gate ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp,
16880Sstevel@tonic-gate 	uint_t flags, int (*waitfp)(caddr_t), caddr_t arg,
16890Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, uint_t *ccountp);
16900Sstevel@tonic-gate 
16910Sstevel@tonic-gate /*
16920Sstevel@tonic-gate  * unbind mapping object to handle
16930Sstevel@tonic-gate  */
16940Sstevel@tonic-gate 
16950Sstevel@tonic-gate int
16960Sstevel@tonic-gate ddi_dma_unbind_handle(ddi_dma_handle_t handle);
16970Sstevel@tonic-gate 
16980Sstevel@tonic-gate /*
16990Sstevel@tonic-gate  * get next DMA cookie
17000Sstevel@tonic-gate  */
17010Sstevel@tonic-gate 
17020Sstevel@tonic-gate void
17030Sstevel@tonic-gate ddi_dma_nextcookie(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep);
17040Sstevel@tonic-gate 
17050Sstevel@tonic-gate /*
17060Sstevel@tonic-gate  * get number of DMA windows
17070Sstevel@tonic-gate  */
17080Sstevel@tonic-gate 
17090Sstevel@tonic-gate int
17100Sstevel@tonic-gate ddi_dma_numwin(ddi_dma_handle_t handle, uint_t *nwinp);
17110Sstevel@tonic-gate 
17120Sstevel@tonic-gate /*
17130Sstevel@tonic-gate  * get specific DMA window
17140Sstevel@tonic-gate  */
17150Sstevel@tonic-gate 
17160Sstevel@tonic-gate int
17170Sstevel@tonic-gate ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp,
17180Sstevel@tonic-gate 	size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
17190Sstevel@tonic-gate 
17200Sstevel@tonic-gate /*
17210Sstevel@tonic-gate  * activate 64 bit SBus support
17220Sstevel@tonic-gate  */
17230Sstevel@tonic-gate 
17240Sstevel@tonic-gate int
17250Sstevel@tonic-gate ddi_dma_set_sbus64(ddi_dma_handle_t handle, ulong_t burstsizes);
17260Sstevel@tonic-gate 
17270Sstevel@tonic-gate /*
17280Sstevel@tonic-gate  * Miscellaneous functions
17290Sstevel@tonic-gate  */
17300Sstevel@tonic-gate 
17310Sstevel@tonic-gate /*
17320Sstevel@tonic-gate  * ddi_report_dev:	Report a successful attach.
17330Sstevel@tonic-gate  */
17340Sstevel@tonic-gate 
17350Sstevel@tonic-gate void
17360Sstevel@tonic-gate ddi_report_dev(dev_info_t *dev);
17370Sstevel@tonic-gate 
17380Sstevel@tonic-gate /*
17390Sstevel@tonic-gate  * ddi_dev_regsize
17400Sstevel@tonic-gate  *
17410Sstevel@tonic-gate  *	If the device has h/w register(s), report
17420Sstevel@tonic-gate  *	the size, in bytes, of the specified one into *resultp.
17430Sstevel@tonic-gate  *
17440Sstevel@tonic-gate  *	Returns DDI_FAILURE if there are not registers,
17450Sstevel@tonic-gate  *	or the specified register doesn't exist.
17460Sstevel@tonic-gate  */
17470Sstevel@tonic-gate 
17480Sstevel@tonic-gate int
17490Sstevel@tonic-gate ddi_dev_regsize(dev_info_t *dev, uint_t rnumber, off_t *resultp);
17500Sstevel@tonic-gate 
17510Sstevel@tonic-gate /*
17520Sstevel@tonic-gate  * ddi_dev_nregs
17530Sstevel@tonic-gate  *
17540Sstevel@tonic-gate  *	If the device has h/w register(s), report
17550Sstevel@tonic-gate  *	how many of them that there are into resultp.
17560Sstevel@tonic-gate  *	Return DDI_FAILURE if the device has no registers.
17570Sstevel@tonic-gate  */
17580Sstevel@tonic-gate 
17590Sstevel@tonic-gate int
17600Sstevel@tonic-gate ddi_dev_nregs(dev_info_t *dev, int *resultp);
17610Sstevel@tonic-gate 
17620Sstevel@tonic-gate /*
17630Sstevel@tonic-gate  * ddi_dev_is_sid
17640Sstevel@tonic-gate  *
17650Sstevel@tonic-gate  *	If the device is self-identifying, i.e.,
17660Sstevel@tonic-gate  *	has already been probed by a smart PROM
17670Sstevel@tonic-gate  *	(and thus registers are known to be valid)
17680Sstevel@tonic-gate  *	return DDI_SUCCESS, else DDI_FAILURE.
17690Sstevel@tonic-gate  */
17700Sstevel@tonic-gate 
17710Sstevel@tonic-gate 
17720Sstevel@tonic-gate int
17730Sstevel@tonic-gate ddi_dev_is_sid(dev_info_t *dev);
17740Sstevel@tonic-gate 
17750Sstevel@tonic-gate /*
17760Sstevel@tonic-gate  * ddi_slaveonly
17770Sstevel@tonic-gate  *
17780Sstevel@tonic-gate  *	If the device is on a bus that precludes
17790Sstevel@tonic-gate  *	the device from being either a dma master or
17800Sstevel@tonic-gate  *	a dma slave, return DDI_SUCCESS.
17810Sstevel@tonic-gate  */
17820Sstevel@tonic-gate 
17830Sstevel@tonic-gate int
17840Sstevel@tonic-gate ddi_slaveonly(dev_info_t *);
17850Sstevel@tonic-gate 
17860Sstevel@tonic-gate 
17870Sstevel@tonic-gate /*
17880Sstevel@tonic-gate  * ddi_dev_affinity
17890Sstevel@tonic-gate  *
17900Sstevel@tonic-gate  *	Report, via DDI_SUCCESS, whether there exists
17910Sstevel@tonic-gate  *	an 'affinity' between two dev_info_t's. An
17920Sstevel@tonic-gate  *	affinity is defined to be either a parent-child,
17930Sstevel@tonic-gate  *	or a sibling relationship such that the siblings
17940Sstevel@tonic-gate  *	or in the same part of the bus they happen to be
17950Sstevel@tonic-gate  *	on.
17960Sstevel@tonic-gate  */
17970Sstevel@tonic-gate 
17980Sstevel@tonic-gate int
17990Sstevel@tonic-gate ddi_dev_affinity(dev_info_t *deva, dev_info_t *devb);
18000Sstevel@tonic-gate 
18010Sstevel@tonic-gate 
18020Sstevel@tonic-gate /*
18030Sstevel@tonic-gate  * ddi_set_callback
18040Sstevel@tonic-gate  *
18050Sstevel@tonic-gate  *	Set a function/arg pair into the callback list identified
18060Sstevel@tonic-gate  *	by listid. *listid must always initially start out as zero.
18070Sstevel@tonic-gate  */
18080Sstevel@tonic-gate 
18090Sstevel@tonic-gate void
18100Sstevel@tonic-gate ddi_set_callback(int (*funcp)(caddr_t), caddr_t arg, uintptr_t *listid);
18110Sstevel@tonic-gate 
18120Sstevel@tonic-gate /*
18130Sstevel@tonic-gate  * ddi_run_callback
18140Sstevel@tonic-gate  *
18150Sstevel@tonic-gate  *	Run the callback list identified by listid.
18160Sstevel@tonic-gate  */
18170Sstevel@tonic-gate 
18180Sstevel@tonic-gate void
18190Sstevel@tonic-gate ddi_run_callback(uintptr_t *listid);
18200Sstevel@tonic-gate 
18210Sstevel@tonic-gate /*
18220Sstevel@tonic-gate  * More miscellaneous
18230Sstevel@tonic-gate  */
18240Sstevel@tonic-gate 
18250Sstevel@tonic-gate int
18260Sstevel@tonic-gate nochpoll(dev_t dev, short events, int anyyet, short *reventsp,
18270Sstevel@tonic-gate 	struct pollhead **phpp);
18280Sstevel@tonic-gate 
18290Sstevel@tonic-gate dev_info_t *
18300Sstevel@tonic-gate nodevinfo(dev_t dev, int otyp);
18310Sstevel@tonic-gate 
18320Sstevel@tonic-gate int
18330Sstevel@tonic-gate ddi_no_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result);
18340Sstevel@tonic-gate 
18350Sstevel@tonic-gate int
18360Sstevel@tonic-gate ddi_getinfo_1to1(dev_info_t *dip, ddi_info_cmd_t infocmd,
18370Sstevel@tonic-gate     void *arg, void **result);
18380Sstevel@tonic-gate 
18390Sstevel@tonic-gate int
18400Sstevel@tonic-gate ddifail(dev_info_t *devi, ddi_attach_cmd_t cmd);
18410Sstevel@tonic-gate 
18420Sstevel@tonic-gate int
18430Sstevel@tonic-gate ddi_no_dma_map(dev_info_t *dip, dev_info_t *rdip,
18440Sstevel@tonic-gate     struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
18450Sstevel@tonic-gate 
18460Sstevel@tonic-gate int
18470Sstevel@tonic-gate ddi_no_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
18480Sstevel@tonic-gate     int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
18490Sstevel@tonic-gate 
18500Sstevel@tonic-gate int
18510Sstevel@tonic-gate ddi_no_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
18520Sstevel@tonic-gate     ddi_dma_handle_t handle);
18530Sstevel@tonic-gate 
18540Sstevel@tonic-gate int
18550Sstevel@tonic-gate ddi_no_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
18560Sstevel@tonic-gate     ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
18570Sstevel@tonic-gate     ddi_dma_cookie_t *cp, uint_t *ccountp);
18580Sstevel@tonic-gate 
18590Sstevel@tonic-gate int
18600Sstevel@tonic-gate ddi_no_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
18610Sstevel@tonic-gate     ddi_dma_handle_t handle);
18620Sstevel@tonic-gate 
18630Sstevel@tonic-gate int
18640Sstevel@tonic-gate ddi_no_dma_flush(dev_info_t *dip, dev_info_t *rdip,
18650Sstevel@tonic-gate     ddi_dma_handle_t handle, off_t off, size_t len,
18660Sstevel@tonic-gate     uint_t cache_flags);
18670Sstevel@tonic-gate 
18680Sstevel@tonic-gate int
18690Sstevel@tonic-gate ddi_no_dma_win(dev_info_t *dip, dev_info_t *rdip,
18700Sstevel@tonic-gate     ddi_dma_handle_t handle, uint_t win, off_t *offp,
18710Sstevel@tonic-gate     size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
18720Sstevel@tonic-gate 
18730Sstevel@tonic-gate int
18740Sstevel@tonic-gate ddi_no_dma_mctl(register dev_info_t *dip, dev_info_t *rdip,
18750Sstevel@tonic-gate     ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
18760Sstevel@tonic-gate     off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags);
18770Sstevel@tonic-gate 
18780Sstevel@tonic-gate void
18790Sstevel@tonic-gate ddivoid();
18800Sstevel@tonic-gate 
18810Sstevel@tonic-gate cred_t *
18820Sstevel@tonic-gate ddi_get_cred(void);
18830Sstevel@tonic-gate 
18840Sstevel@tonic-gate clock_t
18850Sstevel@tonic-gate ddi_get_lbolt(void);
18860Sstevel@tonic-gate 
18870Sstevel@tonic-gate time_t
18880Sstevel@tonic-gate ddi_get_time(void);
18890Sstevel@tonic-gate 
18900Sstevel@tonic-gate pid_t
18910Sstevel@tonic-gate ddi_get_pid(void);
18920Sstevel@tonic-gate 
18930Sstevel@tonic-gate kt_did_t
18940Sstevel@tonic-gate ddi_get_kt_did(void);
18950Sstevel@tonic-gate 
18960Sstevel@tonic-gate boolean_t
18970Sstevel@tonic-gate ddi_can_receive_sig(void);
18980Sstevel@tonic-gate 
18990Sstevel@tonic-gate void
19000Sstevel@tonic-gate swab(void *src, void *dst, size_t nbytes);
19010Sstevel@tonic-gate 
19020Sstevel@tonic-gate int
19030Sstevel@tonic-gate ddi_create_minor_node(dev_info_t *dip, char *name, int spec_type,
19040Sstevel@tonic-gate     minor_t minor_num, char *node_type, int flag);
19050Sstevel@tonic-gate 
19060Sstevel@tonic-gate int
19070Sstevel@tonic-gate ddi_create_priv_minor_node(dev_info_t *dip, char *name, int spec_type,
19080Sstevel@tonic-gate     minor_t minor_num, char *node_type, int flag,
19090Sstevel@tonic-gate     const char *rdpriv, const char *wrpriv, mode_t priv_mode);
19100Sstevel@tonic-gate 
19110Sstevel@tonic-gate void
19120Sstevel@tonic-gate ddi_remove_minor_node(dev_info_t *dip, char *name);
19130Sstevel@tonic-gate 
19140Sstevel@tonic-gate int
19150Sstevel@tonic-gate ddi_in_panic(void);
19160Sstevel@tonic-gate 
19170Sstevel@tonic-gate int
19180Sstevel@tonic-gate ddi_streams_driver(dev_info_t *dip);
19190Sstevel@tonic-gate 
19200Sstevel@tonic-gate /*
19210Sstevel@tonic-gate  * DDI wrappers for ffs and fls
19220Sstevel@tonic-gate  */
19230Sstevel@tonic-gate int
19240Sstevel@tonic-gate ddi_ffs(long mask);
19250Sstevel@tonic-gate 
19260Sstevel@tonic-gate int
19270Sstevel@tonic-gate ddi_fls(long mask);
19280Sstevel@tonic-gate 
19290Sstevel@tonic-gate /*
19300Sstevel@tonic-gate  * The next five routines comprise generic storage management utilities
19310Sstevel@tonic-gate  * for driver soft state structures.
19320Sstevel@tonic-gate  */
19330Sstevel@tonic-gate 
19340Sstevel@tonic-gate /*
19350Sstevel@tonic-gate  * Allocate a set of pointers to 'n_items' objects of size 'size'
19360Sstevel@tonic-gate  * bytes.  Each pointer is initialized to nil. 'n_items' is a hint i.e.
19370Sstevel@tonic-gate  * zero is allowed.
19380Sstevel@tonic-gate  */
19390Sstevel@tonic-gate int
19400Sstevel@tonic-gate ddi_soft_state_init(void **state_p, size_t size, size_t n_items);
19410Sstevel@tonic-gate 
19420Sstevel@tonic-gate /*
19430Sstevel@tonic-gate  * Allocate a state structure of size 'size' to be associated
19440Sstevel@tonic-gate  * with item 'item'.
19450Sstevel@tonic-gate  */
19460Sstevel@tonic-gate int
19470Sstevel@tonic-gate ddi_soft_state_zalloc(void *state, int item);
19480Sstevel@tonic-gate 
19490Sstevel@tonic-gate /*
19500Sstevel@tonic-gate  * Fetch a pointer to the allocated soft state structure
19510Sstevel@tonic-gate  * corresponding to 'item.'
19520Sstevel@tonic-gate  */
19530Sstevel@tonic-gate void *
19540Sstevel@tonic-gate ddi_get_soft_state(void *state, int item);
19550Sstevel@tonic-gate 
19560Sstevel@tonic-gate /*
19570Sstevel@tonic-gate  * Free the state structure corresponding to 'item.'
19580Sstevel@tonic-gate  */
19590Sstevel@tonic-gate void
19600Sstevel@tonic-gate ddi_soft_state_free(void *state, int item);
19610Sstevel@tonic-gate 
19620Sstevel@tonic-gate /*
19630Sstevel@tonic-gate  * Free the handle, and any associated soft state structures.
19640Sstevel@tonic-gate  */
19650Sstevel@tonic-gate void
19660Sstevel@tonic-gate ddi_soft_state_fini(void **state_p);
19670Sstevel@tonic-gate 
19680Sstevel@tonic-gate /*
19690Sstevel@tonic-gate  * Set the addr field of the name in dip to name
19700Sstevel@tonic-gate  */
19710Sstevel@tonic-gate void
19720Sstevel@tonic-gate ddi_set_name_addr(dev_info_t *dip, char *name);
19730Sstevel@tonic-gate 
19740Sstevel@tonic-gate /*
19750Sstevel@tonic-gate  * Get the address part of the name.
19760Sstevel@tonic-gate  */
19770Sstevel@tonic-gate char *
19780Sstevel@tonic-gate ddi_get_name_addr(dev_info_t *dip);
19790Sstevel@tonic-gate 
19800Sstevel@tonic-gate void
19810Sstevel@tonic-gate ddi_set_parent_data(dev_info_t *dip, void *pd);
19820Sstevel@tonic-gate 
19830Sstevel@tonic-gate void *
19840Sstevel@tonic-gate ddi_get_parent_data(dev_info_t *dip);
19850Sstevel@tonic-gate 
19860Sstevel@tonic-gate int
19870Sstevel@tonic-gate ddi_initchild(dev_info_t *parent, dev_info_t *proto);
19880Sstevel@tonic-gate 
19890Sstevel@tonic-gate int
19900Sstevel@tonic-gate ddi_uninitchild(dev_info_t *dip);
19910Sstevel@tonic-gate 
19920Sstevel@tonic-gate major_t
19930Sstevel@tonic-gate ddi_name_to_major(char *name);
19940Sstevel@tonic-gate 
19950Sstevel@tonic-gate char *
19960Sstevel@tonic-gate ddi_major_to_name(major_t major);
19970Sstevel@tonic-gate 
19980Sstevel@tonic-gate char *
19990Sstevel@tonic-gate ddi_deviname(dev_info_t *dip, char *name);
20000Sstevel@tonic-gate 
20010Sstevel@tonic-gate char *
20020Sstevel@tonic-gate ddi_pathname(dev_info_t *dip, char *path);
20030Sstevel@tonic-gate 
20040Sstevel@tonic-gate int
20050Sstevel@tonic-gate ddi_dev_pathname(dev_t devt, int spec_type, char *name);
20060Sstevel@tonic-gate 
20070Sstevel@tonic-gate dev_t
20080Sstevel@tonic-gate ddi_pathname_to_dev_t(char *pathname);
20090Sstevel@tonic-gate 
20100Sstevel@tonic-gate /*
20110Sstevel@tonic-gate  * High resolution system timer functions.
20120Sstevel@tonic-gate  *
20130Sstevel@tonic-gate  * These functions are already in the kernel (see sys/time.h).
20140Sstevel@tonic-gate  * The ddi supports the notion of a hrtime_t type and the
20150Sstevel@tonic-gate  * functions gethrtime, hrtadd, hrtsub and hrtcmp.
20160Sstevel@tonic-gate  */
20170Sstevel@tonic-gate 
20180Sstevel@tonic-gate 
20190Sstevel@tonic-gate /*
20200Sstevel@tonic-gate  * Nexus wrapper functions
20210Sstevel@tonic-gate  *
20220Sstevel@tonic-gate  * These functions are for entries in a bus nexus driver's bus_ops
20230Sstevel@tonic-gate  * structure for when the driver doesn't have such a function and
20240Sstevel@tonic-gate  * doesn't wish to prohibit such a function from existing. They
20250Sstevel@tonic-gate  * may also be called to start passing a request up the dev_info
20260Sstevel@tonic-gate  * tree.
20270Sstevel@tonic-gate  */
20280Sstevel@tonic-gate 
20290Sstevel@tonic-gate /*
20300Sstevel@tonic-gate  * bus_ctl wrapper
20310Sstevel@tonic-gate  */
20320Sstevel@tonic-gate 
20330Sstevel@tonic-gate int
20340Sstevel@tonic-gate ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v);
20350Sstevel@tonic-gate 
20360Sstevel@tonic-gate /*
20370Sstevel@tonic-gate  * bus_dma_map wrapper
20380Sstevel@tonic-gate  */
20390Sstevel@tonic-gate 
20400Sstevel@tonic-gate int
20410Sstevel@tonic-gate ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
20420Sstevel@tonic-gate 	struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
20430Sstevel@tonic-gate 
20440Sstevel@tonic-gate int
20450Sstevel@tonic-gate ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
20460Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
20470Sstevel@tonic-gate 
20480Sstevel@tonic-gate int
20490Sstevel@tonic-gate ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
20500Sstevel@tonic-gate 	ddi_dma_handle_t handle);
20510Sstevel@tonic-gate 
20520Sstevel@tonic-gate int
20530Sstevel@tonic-gate ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
20540Sstevel@tonic-gate 	ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
20550Sstevel@tonic-gate 	ddi_dma_cookie_t *cp, uint_t *ccountp);
20560Sstevel@tonic-gate 
20570Sstevel@tonic-gate int
20580Sstevel@tonic-gate ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
20590Sstevel@tonic-gate 	ddi_dma_handle_t handle);
20600Sstevel@tonic-gate 
20610Sstevel@tonic-gate int
20620Sstevel@tonic-gate ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip,
20630Sstevel@tonic-gate 	ddi_dma_handle_t handle, off_t off, size_t len,
20640Sstevel@tonic-gate 	uint_t cache_flags);
20650Sstevel@tonic-gate 
20660Sstevel@tonic-gate int
20670Sstevel@tonic-gate ddi_dma_win(dev_info_t *dip, dev_info_t *rdip,
20680Sstevel@tonic-gate 	ddi_dma_handle_t handle, uint_t win, off_t *offp,
20690Sstevel@tonic-gate 	size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20700Sstevel@tonic-gate 
20710Sstevel@tonic-gate /*
20720Sstevel@tonic-gate  * bus_dma_ctl wrapper
20730Sstevel@tonic-gate  */
20740Sstevel@tonic-gate 
20750Sstevel@tonic-gate int
20760Sstevel@tonic-gate ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
20770Sstevel@tonic-gate 	enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
20780Sstevel@tonic-gate 	caddr_t *objp, uint_t flags);
20790Sstevel@tonic-gate 
20800Sstevel@tonic-gate /*
20810Sstevel@tonic-gate  * dvma support for networking drivers
20820Sstevel@tonic-gate  */
20830Sstevel@tonic-gate 
20840Sstevel@tonic-gate unsigned long
20850Sstevel@tonic-gate dvma_pagesize(dev_info_t *dip);
20860Sstevel@tonic-gate 
20870Sstevel@tonic-gate int
20880Sstevel@tonic-gate dvma_reserve(dev_info_t *dip,  ddi_dma_lim_t *limp, uint_t pages,
20890Sstevel@tonic-gate 	ddi_dma_handle_t *handlep);
20900Sstevel@tonic-gate 
20910Sstevel@tonic-gate void
20920Sstevel@tonic-gate dvma_release(ddi_dma_handle_t h);
20930Sstevel@tonic-gate 
20940Sstevel@tonic-gate void
20950Sstevel@tonic-gate dvma_kaddr_load(ddi_dma_handle_t h, caddr_t a, uint_t len, uint_t index,
20960Sstevel@tonic-gate 	ddi_dma_cookie_t *cp);
20970Sstevel@tonic-gate 
20980Sstevel@tonic-gate void
20990Sstevel@tonic-gate dvma_unload(ddi_dma_handle_t h, uint_t objindex, uint_t type);
21000Sstevel@tonic-gate 
21010Sstevel@tonic-gate void
21020Sstevel@tonic-gate dvma_sync(ddi_dma_handle_t h, uint_t objindex, uint_t type);
21030Sstevel@tonic-gate 
21040Sstevel@tonic-gate /*
21050Sstevel@tonic-gate  * Layered driver support
21060Sstevel@tonic-gate  */
21070Sstevel@tonic-gate 
21080Sstevel@tonic-gate extern int ddi_copyin(const void *, void *, size_t, int);
21090Sstevel@tonic-gate extern int ddi_copyout(const void *, void *, size_t, int);
21100Sstevel@tonic-gate 
21110Sstevel@tonic-gate /*
21120Sstevel@tonic-gate  * Send signals to processes
21130Sstevel@tonic-gate  */
21140Sstevel@tonic-gate extern void *proc_ref(void);
21150Sstevel@tonic-gate extern void proc_unref(void *pref);
21160Sstevel@tonic-gate extern int proc_signal(void *pref, int sig);
21170Sstevel@tonic-gate 
21180Sstevel@tonic-gate /* I/O port access routines */
21190Sstevel@tonic-gate extern uint8_t inb(int port);
21200Sstevel@tonic-gate extern uint16_t inw(int port);
21210Sstevel@tonic-gate extern uint32_t inl(int port);
21220Sstevel@tonic-gate extern void repinsb(int port, uint8_t *addr, int count);
21230Sstevel@tonic-gate extern void repinsw(int port, uint16_t *addr, int count);
21240Sstevel@tonic-gate extern void repinsd(int port, uint32_t *addr, int count);
21250Sstevel@tonic-gate extern void outb(int port, uint8_t value);
21260Sstevel@tonic-gate extern void outw(int port, uint16_t value);
21270Sstevel@tonic-gate extern void outl(int port, uint32_t value);
21280Sstevel@tonic-gate extern void repoutsb(int port, uint8_t *addr, int count);
21290Sstevel@tonic-gate extern void repoutsw(int port, uint16_t *addr, int count);
21300Sstevel@tonic-gate extern void repoutsd(int port, uint32_t *addr, int count);
21310Sstevel@tonic-gate 
21320Sstevel@tonic-gate /*
21330Sstevel@tonic-gate  * Console bell routines
21340Sstevel@tonic-gate  */
21350Sstevel@tonic-gate extern void ddi_ring_console_bell(clock_t duration);
21360Sstevel@tonic-gate extern void ddi_set_console_bell(void (*bellfunc)(clock_t duration));
21370Sstevel@tonic-gate 
21380Sstevel@tonic-gate /*
21390Sstevel@tonic-gate  * Fault-related functions
21400Sstevel@tonic-gate  */
21410Sstevel@tonic-gate extern int ddi_check_acc_handle(ddi_acc_handle_t);
21420Sstevel@tonic-gate extern int ddi_check_dma_handle(ddi_dma_handle_t);
21430Sstevel@tonic-gate extern void ddi_dev_report_fault(dev_info_t *, ddi_fault_impact_t,
21440Sstevel@tonic-gate 	ddi_fault_location_t, const char *);
21450Sstevel@tonic-gate extern ddi_devstate_t ddi_get_devstate(dev_info_t *);
21460Sstevel@tonic-gate 
21470Sstevel@tonic-gate /*
21480Sstevel@tonic-gate  * Miscellaneous redefines
21490Sstevel@tonic-gate  */
21500Sstevel@tonic-gate #define	uiophysio	physio
21510Sstevel@tonic-gate 
21520Sstevel@tonic-gate /*
21530Sstevel@tonic-gate  * utilities - "reg" mapping and all common portable data access functions
21540Sstevel@tonic-gate  */
21550Sstevel@tonic-gate 
21560Sstevel@tonic-gate /*
21570Sstevel@tonic-gate  * error code from ddi_regs_map_setup
21580Sstevel@tonic-gate  */
21590Sstevel@tonic-gate 
21600Sstevel@tonic-gate #define	DDI_REGS_ACC_CONFLICT	(-10)
21610Sstevel@tonic-gate 
21620Sstevel@tonic-gate /*
21630Sstevel@tonic-gate  * Device address advance flags
21640Sstevel@tonic-gate  */
21650Sstevel@tonic-gate 
21660Sstevel@tonic-gate #define	 DDI_DEV_NO_AUTOINCR	0x0000
21670Sstevel@tonic-gate #define	 DDI_DEV_AUTOINCR	0x0001
21680Sstevel@tonic-gate 
21690Sstevel@tonic-gate int
21700Sstevel@tonic-gate ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber, caddr_t *addrp,
21710Sstevel@tonic-gate 	offset_t offset, offset_t len, ddi_device_acc_attr_t *accattrp,
21720Sstevel@tonic-gate 	ddi_acc_handle_t *handle);
21730Sstevel@tonic-gate 
21740Sstevel@tonic-gate void
21750Sstevel@tonic-gate ddi_regs_map_free(ddi_acc_handle_t *handle);
21760Sstevel@tonic-gate 
21770Sstevel@tonic-gate /*
21780Sstevel@tonic-gate  * these are the prototypes for the common portable data access functions
21790Sstevel@tonic-gate  */
21800Sstevel@tonic-gate 
21810Sstevel@tonic-gate #ifdef _LP64
21820Sstevel@tonic-gate 
21830Sstevel@tonic-gate uint8_t
21840Sstevel@tonic-gate ddi_get8(ddi_acc_handle_t handle, uint8_t *addr);
21850Sstevel@tonic-gate 
21860Sstevel@tonic-gate uint16_t
21870Sstevel@tonic-gate ddi_get16(ddi_acc_handle_t handle, uint16_t *addr);
21880Sstevel@tonic-gate 
21890Sstevel@tonic-gate uint32_t
21900Sstevel@tonic-gate ddi_get32(ddi_acc_handle_t handle, uint32_t *addr);
21910Sstevel@tonic-gate 
21920Sstevel@tonic-gate uint64_t
21930Sstevel@tonic-gate ddi_get64(ddi_acc_handle_t handle, uint64_t *addr);
21940Sstevel@tonic-gate 
21950Sstevel@tonic-gate void
21960Sstevel@tonic-gate ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
21970Sstevel@tonic-gate 	size_t repcount, uint_t flags);
21980Sstevel@tonic-gate 
21990Sstevel@tonic-gate void
22000Sstevel@tonic-gate ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
22010Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22020Sstevel@tonic-gate 
22030Sstevel@tonic-gate void
22040Sstevel@tonic-gate ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
22050Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22060Sstevel@tonic-gate 
22070Sstevel@tonic-gate void
22080Sstevel@tonic-gate ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
22090Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22100Sstevel@tonic-gate 
22110Sstevel@tonic-gate void
22120Sstevel@tonic-gate ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value);
22130Sstevel@tonic-gate 
22140Sstevel@tonic-gate void
22150Sstevel@tonic-gate ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value);
22160Sstevel@tonic-gate 
22170Sstevel@tonic-gate void
22180Sstevel@tonic-gate ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value);
22190Sstevel@tonic-gate 
22200Sstevel@tonic-gate void
22210Sstevel@tonic-gate ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value);
22220Sstevel@tonic-gate 
22230Sstevel@tonic-gate void
22240Sstevel@tonic-gate ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
22250Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22260Sstevel@tonic-gate void
22270Sstevel@tonic-gate ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
22280Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22290Sstevel@tonic-gate void
22300Sstevel@tonic-gate ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
22310Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22320Sstevel@tonic-gate 
22330Sstevel@tonic-gate void
22340Sstevel@tonic-gate ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
22350Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22360Sstevel@tonic-gate 
22370Sstevel@tonic-gate #else /* _ILP32 */
22380Sstevel@tonic-gate 
22390Sstevel@tonic-gate uint8_t
22400Sstevel@tonic-gate ddi_getb(ddi_acc_handle_t handle, uint8_t *addr);
22410Sstevel@tonic-gate #define	ddi_get8	ddi_getb
22420Sstevel@tonic-gate 
22430Sstevel@tonic-gate uint16_t
22440Sstevel@tonic-gate ddi_getw(ddi_acc_handle_t handle, uint16_t *addr);
22450Sstevel@tonic-gate #define	ddi_get16	ddi_getw
22460Sstevel@tonic-gate 
22470Sstevel@tonic-gate uint32_t
22480Sstevel@tonic-gate ddi_getl(ddi_acc_handle_t handle, uint32_t *addr);
22490Sstevel@tonic-gate #define	ddi_get32	ddi_getl
22500Sstevel@tonic-gate 
22510Sstevel@tonic-gate uint64_t
22520Sstevel@tonic-gate ddi_getll(ddi_acc_handle_t handle, uint64_t *addr);
22530Sstevel@tonic-gate #define	ddi_get64	ddi_getll
22540Sstevel@tonic-gate 
22550Sstevel@tonic-gate void
22560Sstevel@tonic-gate ddi_rep_getb(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
22570Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22580Sstevel@tonic-gate #define	ddi_rep_get8	ddi_rep_getb
22590Sstevel@tonic-gate 
22600Sstevel@tonic-gate void
22610Sstevel@tonic-gate ddi_rep_getw(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
22620Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22630Sstevel@tonic-gate #define	ddi_rep_get16	ddi_rep_getw
22640Sstevel@tonic-gate 
22650Sstevel@tonic-gate void
22660Sstevel@tonic-gate ddi_rep_getl(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
22670Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22680Sstevel@tonic-gate #define	ddi_rep_get32	ddi_rep_getl
22690Sstevel@tonic-gate 
22700Sstevel@tonic-gate void
22710Sstevel@tonic-gate ddi_rep_getll(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
22720Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22730Sstevel@tonic-gate #define	ddi_rep_get64	ddi_rep_getll
22740Sstevel@tonic-gate 
22750Sstevel@tonic-gate void
22760Sstevel@tonic-gate ddi_putb(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value);
22770Sstevel@tonic-gate #define	ddi_put8	ddi_putb
22780Sstevel@tonic-gate 
22790Sstevel@tonic-gate void
22800Sstevel@tonic-gate ddi_putw(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value);
22810Sstevel@tonic-gate #define	ddi_put16	ddi_putw
22820Sstevel@tonic-gate 
22830Sstevel@tonic-gate void
22840Sstevel@tonic-gate ddi_putl(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value);
22850Sstevel@tonic-gate #define	ddi_put32	ddi_putl
22860Sstevel@tonic-gate 
22870Sstevel@tonic-gate void
22880Sstevel@tonic-gate ddi_putll(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value);
22890Sstevel@tonic-gate #define	ddi_put64	ddi_putll
22900Sstevel@tonic-gate 
22910Sstevel@tonic-gate void
22920Sstevel@tonic-gate ddi_rep_putb(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
22930Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22940Sstevel@tonic-gate #define	ddi_rep_put8	ddi_rep_putb
22950Sstevel@tonic-gate 
22960Sstevel@tonic-gate void
22970Sstevel@tonic-gate ddi_rep_putw(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
22980Sstevel@tonic-gate 	size_t repcount, uint_t flags);
22990Sstevel@tonic-gate #define	ddi_rep_put16	ddi_rep_putw
23000Sstevel@tonic-gate 
23010Sstevel@tonic-gate void
23020Sstevel@tonic-gate ddi_rep_putl(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
23030Sstevel@tonic-gate 	size_t repcount, uint_t flags);
23040Sstevel@tonic-gate #define	ddi_rep_put32	ddi_rep_putl
23050Sstevel@tonic-gate 
23060Sstevel@tonic-gate void
23070Sstevel@tonic-gate ddi_rep_putll(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
23080Sstevel@tonic-gate 	size_t repcount, uint_t flags);
23090Sstevel@tonic-gate #define	ddi_rep_put64	ddi_rep_putll
23100Sstevel@tonic-gate 
23110Sstevel@tonic-gate #endif /* _LP64 */
23120Sstevel@tonic-gate 
23130Sstevel@tonic-gate /*
23140Sstevel@tonic-gate  * these are special device handling functions
23150Sstevel@tonic-gate  */
23160Sstevel@tonic-gate int
23170Sstevel@tonic-gate ddi_device_zero(ddi_acc_handle_t handle, caddr_t dev_addr,
23180Sstevel@tonic-gate 	size_t bytecount, ssize_t dev_advcnt, uint_t dev_datasz);
23190Sstevel@tonic-gate 
23200Sstevel@tonic-gate int
23210Sstevel@tonic-gate ddi_device_copy(
23220Sstevel@tonic-gate 	ddi_acc_handle_t src_handle, caddr_t src_addr, ssize_t src_advcnt,
23230Sstevel@tonic-gate 	ddi_acc_handle_t dest_handle, caddr_t dest_addr, ssize_t dest_advcnt,
23240Sstevel@tonic-gate 	size_t bytecount, uint_t dev_datasz);
23250Sstevel@tonic-gate 
23260Sstevel@tonic-gate /*
23270Sstevel@tonic-gate  * these are software byte swapping functions
23280Sstevel@tonic-gate  */
23290Sstevel@tonic-gate uint16_t
23300Sstevel@tonic-gate ddi_swap16(uint16_t value);
23310Sstevel@tonic-gate 
23320Sstevel@tonic-gate uint32_t
23330Sstevel@tonic-gate ddi_swap32(uint32_t value);
23340Sstevel@tonic-gate 
23350Sstevel@tonic-gate uint64_t
23360Sstevel@tonic-gate ddi_swap64(uint64_t value);
23370Sstevel@tonic-gate 
23380Sstevel@tonic-gate /*
23390Sstevel@tonic-gate  * these are the prototypes for PCI local bus functions
23400Sstevel@tonic-gate  */
23410Sstevel@tonic-gate /*
23420Sstevel@tonic-gate  * PCI power management capabilities reporting in addition to those
23430Sstevel@tonic-gate  * provided by the PCI Power Management Specification.
23440Sstevel@tonic-gate  */
23450Sstevel@tonic-gate #define	PCI_PM_IDLESPEED	0x1		/* clock for idle dev - cap  */
23460Sstevel@tonic-gate #define	PCI_PM_IDLESPEED_ANY	(void *)-1	/* any clock for idle dev */
23470Sstevel@tonic-gate #define	PCI_PM_IDLESPEED_NONE	(void *)-2	/* regular clock for idle dev */
23480Sstevel@tonic-gate 
23490Sstevel@tonic-gate int
23500Sstevel@tonic-gate pci_config_setup(dev_info_t *dip, ddi_acc_handle_t *handle);
23510Sstevel@tonic-gate 
23520Sstevel@tonic-gate void
23530Sstevel@tonic-gate pci_config_teardown(ddi_acc_handle_t *handle);
23540Sstevel@tonic-gate 
23550Sstevel@tonic-gate #ifdef _LP64
23560Sstevel@tonic-gate 
23570Sstevel@tonic-gate uint8_t
23580Sstevel@tonic-gate pci_config_get8(ddi_acc_handle_t handle, off_t offset);
23590Sstevel@tonic-gate 
23600Sstevel@tonic-gate uint16_t
23610Sstevel@tonic-gate pci_config_get16(ddi_acc_handle_t handle, off_t offset);
23620Sstevel@tonic-gate 
23630Sstevel@tonic-gate uint32_t
23640Sstevel@tonic-gate pci_config_get32(ddi_acc_handle_t handle, off_t offset);
23650Sstevel@tonic-gate 
23660Sstevel@tonic-gate uint64_t
23670Sstevel@tonic-gate pci_config_get64(ddi_acc_handle_t handle, off_t offset);
23680Sstevel@tonic-gate 
23690Sstevel@tonic-gate void
23700Sstevel@tonic-gate pci_config_put8(ddi_acc_handle_t handle, off_t offset, uint8_t value);
23710Sstevel@tonic-gate 
23720Sstevel@tonic-gate void
23730Sstevel@tonic-gate pci_config_put16(ddi_acc_handle_t handle, off_t offset, uint16_t value);
23740Sstevel@tonic-gate 
23750Sstevel@tonic-gate void
23760Sstevel@tonic-gate pci_config_put32(ddi_acc_handle_t handle, off_t offset, uint32_t value);
23770Sstevel@tonic-gate 
23780Sstevel@tonic-gate void
23790Sstevel@tonic-gate pci_config_put64(ddi_acc_handle_t handle, off_t offset, uint64_t value);
23800Sstevel@tonic-gate 
23810Sstevel@tonic-gate #else /* _ILP32 */
23820Sstevel@tonic-gate 
23830Sstevel@tonic-gate uint8_t
23840Sstevel@tonic-gate pci_config_getb(ddi_acc_handle_t handle, off_t offset);
23850Sstevel@tonic-gate #define	pci_config_get8		pci_config_getb
23860Sstevel@tonic-gate 
23870Sstevel@tonic-gate uint16_t
23880Sstevel@tonic-gate pci_config_getw(ddi_acc_handle_t handle, off_t offset);
23890Sstevel@tonic-gate #define	pci_config_get16	pci_config_getw
23900Sstevel@tonic-gate 
23910Sstevel@tonic-gate uint32_t
23920Sstevel@tonic-gate pci_config_getl(ddi_acc_handle_t handle, off_t offset);
23930Sstevel@tonic-gate #define	pci_config_get32	pci_config_getl
23940Sstevel@tonic-gate 
23950Sstevel@tonic-gate uint64_t
23960Sstevel@tonic-gate pci_config_getll(ddi_acc_handle_t handle, off_t offset);
23970Sstevel@tonic-gate #define	pci_config_get64	pci_config_getll
23980Sstevel@tonic-gate 
23990Sstevel@tonic-gate void
24000Sstevel@tonic-gate pci_config_putb(ddi_acc_handle_t handle, off_t offset, uint8_t value);
24010Sstevel@tonic-gate #define	pci_config_put8		pci_config_putb
24020Sstevel@tonic-gate 
24030Sstevel@tonic-gate void
24040Sstevel@tonic-gate pci_config_putw(ddi_acc_handle_t handle, off_t offset, uint16_t value);
24050Sstevel@tonic-gate #define	pci_config_put16	pci_config_putw
24060Sstevel@tonic-gate 
24070Sstevel@tonic-gate void
24080Sstevel@tonic-gate pci_config_putl(ddi_acc_handle_t handle, off_t offset, uint32_t value);
24090Sstevel@tonic-gate #define	pci_config_put32	pci_config_putl
24100Sstevel@tonic-gate 
24110Sstevel@tonic-gate void
24120Sstevel@tonic-gate pci_config_putll(ddi_acc_handle_t handle, off_t offset, uint64_t value);
24130Sstevel@tonic-gate #define	pci_config_put64	pci_config_putll
24140Sstevel@tonic-gate 
24150Sstevel@tonic-gate #endif /* _LP64 */
24160Sstevel@tonic-gate 
24170Sstevel@tonic-gate int
24180Sstevel@tonic-gate pci_report_pmcap(dev_info_t *dip, int cap, void *arg);
24190Sstevel@tonic-gate 
24200Sstevel@tonic-gate int
24210Sstevel@tonic-gate pci_restore_config_regs(dev_info_t *dip);
24220Sstevel@tonic-gate 
24230Sstevel@tonic-gate int
24240Sstevel@tonic-gate pci_save_config_regs(dev_info_t *dip);
24250Sstevel@tonic-gate 
24260Sstevel@tonic-gate void
24270Sstevel@tonic-gate pci_ereport_setup(dev_info_t *dip);
24280Sstevel@tonic-gate 
24290Sstevel@tonic-gate void
24300Sstevel@tonic-gate pci_ereport_teardown(dev_info_t *dip);
24310Sstevel@tonic-gate 
24320Sstevel@tonic-gate void
24330Sstevel@tonic-gate pci_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status);
24340Sstevel@tonic-gate 
24350Sstevel@tonic-gate void
24360Sstevel@tonic-gate pci_bdg_ereport_post(dev_info_t *dip, ddi_fm_error_t *derr, uint16_t *status);
24370Sstevel@tonic-gate 
24380Sstevel@tonic-gate int
24390Sstevel@tonic-gate pci_bdg_check_status(dev_info_t *dip, ddi_fm_error_t *derr,
24400Sstevel@tonic-gate     uint16_t pci_cfg_stat, uint16_t pci_cfg_sec_stat);
24410Sstevel@tonic-gate 
24420Sstevel@tonic-gate /*
24430Sstevel@tonic-gate  * the prototype for the C Language Type Model inquiry.
24440Sstevel@tonic-gate  */
24450Sstevel@tonic-gate model_t	ddi_mmap_get_model(void);
24460Sstevel@tonic-gate model_t	ddi_model_convert_from(model_t);
24470Sstevel@tonic-gate 
24480Sstevel@tonic-gate /*
24490Sstevel@tonic-gate  * these are the prototypes for device id functions.
24500Sstevel@tonic-gate  */
24510Sstevel@tonic-gate int
24520Sstevel@tonic-gate ddi_devid_valid(ddi_devid_t devid);
24530Sstevel@tonic-gate 
24540Sstevel@tonic-gate int
24550Sstevel@tonic-gate ddi_devid_register(dev_info_t *dip, ddi_devid_t devid);
24560Sstevel@tonic-gate 
24570Sstevel@tonic-gate void
24580Sstevel@tonic-gate ddi_devid_unregister(dev_info_t *dip);
24590Sstevel@tonic-gate 
24600Sstevel@tonic-gate int
24610Sstevel@tonic-gate ddi_devid_init(dev_info_t *dip, ushort_t devid_type, ushort_t nbytes,
24620Sstevel@tonic-gate     void *id, ddi_devid_t *ret_devid);
24630Sstevel@tonic-gate 
24640Sstevel@tonic-gate size_t
24650Sstevel@tonic-gate ddi_devid_sizeof(ddi_devid_t devid);
24660Sstevel@tonic-gate 
24670Sstevel@tonic-gate void
24680Sstevel@tonic-gate ddi_devid_free(ddi_devid_t devid);
24690Sstevel@tonic-gate 
24700Sstevel@tonic-gate int
24710Sstevel@tonic-gate ddi_devid_compare(ddi_devid_t id1, ddi_devid_t id2);
24720Sstevel@tonic-gate 
24730Sstevel@tonic-gate int
24740Sstevel@tonic-gate ddi_devid_scsi_encode(int version, char *driver_name,
24750Sstevel@tonic-gate     uchar_t *inq, size_t inq_len, uchar_t *inq80, size_t inq80_len,
24760Sstevel@tonic-gate     uchar_t *inq83, size_t inq83_len, ddi_devid_t *ret_devid);
24770Sstevel@tonic-gate 
24780Sstevel@tonic-gate char
24790Sstevel@tonic-gate *ddi_devid_to_guid(ddi_devid_t devid);
24800Sstevel@tonic-gate 
24810Sstevel@tonic-gate void
24820Sstevel@tonic-gate ddi_devid_free_guid(char *guid);
24830Sstevel@tonic-gate 
24840Sstevel@tonic-gate int
24850Sstevel@tonic-gate ddi_lyr_get_devid(dev_t dev, ddi_devid_t *ret_devid);
24860Sstevel@tonic-gate 
24870Sstevel@tonic-gate int
24880Sstevel@tonic-gate ddi_lyr_get_minor_name(dev_t dev, int spec_type, char **minor_name);
24890Sstevel@tonic-gate 
24900Sstevel@tonic-gate int
24910Sstevel@tonic-gate ddi_lyr_devid_to_devlist(ddi_devid_t devid, char *minor_name, int *retndevs,
24920Sstevel@tonic-gate     dev_t **retdevs);
24930Sstevel@tonic-gate 
24940Sstevel@tonic-gate void
24950Sstevel@tonic-gate ddi_lyr_free_devlist(dev_t *devlist, int ndevs);
24960Sstevel@tonic-gate 
24970Sstevel@tonic-gate char *
24980Sstevel@tonic-gate ddi_devid_str_encode(ddi_devid_t devid, char *minor_name);
24990Sstevel@tonic-gate 
25000Sstevel@tonic-gate int
25010Sstevel@tonic-gate ddi_devid_str_decode(char *devidstr, ddi_devid_t *devidp, char **minor_namep);
25020Sstevel@tonic-gate 
25030Sstevel@tonic-gate void
25040Sstevel@tonic-gate ddi_devid_str_free(char *devidstr);
25050Sstevel@tonic-gate 
25060Sstevel@tonic-gate int
25070Sstevel@tonic-gate ddi_devid_str_compare(char *id1_str, char *id2_str);
25080Sstevel@tonic-gate 
25090Sstevel@tonic-gate /*
25100Sstevel@tonic-gate  * Event to post to when a devinfo node is removed.
25110Sstevel@tonic-gate  */
25120Sstevel@tonic-gate #define	DDI_DEVI_REMOVE_EVENT		"DDI:DEVI_REMOVE"
25130Sstevel@tonic-gate #define	DDI_DEVI_INSERT_EVENT		"DDI:DEVI_INSERT"
25140Sstevel@tonic-gate #define	DDI_DEVI_BUS_RESET_EVENT	"DDI:DEVI_BUS_RESET"
25150Sstevel@tonic-gate #define	DDI_DEVI_DEVICE_RESET_EVENT	"DDI:DEVI_DEVICE_RESET"
25160Sstevel@tonic-gate 
25170Sstevel@tonic-gate /*
25180Sstevel@tonic-gate  * Invoke bus nexus driver's implementation of the
25190Sstevel@tonic-gate  * (*bus_remove_eventcall)() interface to remove a registered
25200Sstevel@tonic-gate  * callback handler for "event".
25210Sstevel@tonic-gate  */
25220Sstevel@tonic-gate int
25230Sstevel@tonic-gate ddi_remove_event_handler(ddi_callback_id_t id);
25240Sstevel@tonic-gate 
25250Sstevel@tonic-gate /*
25260Sstevel@tonic-gate  * Invoke bus nexus driver's implementation of the
25270Sstevel@tonic-gate  * (*bus_add_eventcall)() interface to register a callback handler
25280Sstevel@tonic-gate  * for "event".
25290Sstevel@tonic-gate  */
25300Sstevel@tonic-gate int
25310Sstevel@tonic-gate ddi_add_event_handler(dev_info_t *dip, ddi_eventcookie_t event,
25320Sstevel@tonic-gate 	void (*handler)(dev_info_t *, ddi_eventcookie_t, void *, void *),
25330Sstevel@tonic-gate 	void *arg, ddi_callback_id_t *id);
25340Sstevel@tonic-gate 
25350Sstevel@tonic-gate /*
25360Sstevel@tonic-gate  * Return a handle for event "name" by calling up the device tree
25370Sstevel@tonic-gate  * hierarchy via  (*bus_get_eventcookie)() interface until claimed
25380Sstevel@tonic-gate  * by a bus nexus or top of dev_info tree is reached.
25390Sstevel@tonic-gate  */
25400Sstevel@tonic-gate int
25410Sstevel@tonic-gate ddi_get_eventcookie(dev_info_t *dip, char *name,
25420Sstevel@tonic-gate 	ddi_eventcookie_t *event_cookiep);
25430Sstevel@tonic-gate 
25440Sstevel@tonic-gate /*
25450Sstevel@tonic-gate  * log a system event
25460Sstevel@tonic-gate  */
25470Sstevel@tonic-gate int
25480Sstevel@tonic-gate ddi_log_sysevent(dev_info_t *dip, char *vendor, char *class_name,
25490Sstevel@tonic-gate 	char *subclass_name, nvlist_t *attr_list, sysevent_id_t *eidp,
25500Sstevel@tonic-gate 	int sleep_flag);
25510Sstevel@tonic-gate 
25520Sstevel@tonic-gate /*
25530Sstevel@tonic-gate  * ddi_log_sysevent() vendors
25540Sstevel@tonic-gate  */
25550Sstevel@tonic-gate #define	DDI_VENDOR_SUNW		"SUNW"
25560Sstevel@tonic-gate 
25570Sstevel@tonic-gate /*
25580Sstevel@tonic-gate  * Opaque task queue handle.
25590Sstevel@tonic-gate  */
25600Sstevel@tonic-gate typedef struct ddi_taskq ddi_taskq_t;
25610Sstevel@tonic-gate 
25620Sstevel@tonic-gate /*
25630Sstevel@tonic-gate  * Use default system priority.
25640Sstevel@tonic-gate  */
25650Sstevel@tonic-gate #define	TASKQ_DEFAULTPRI -1
25660Sstevel@tonic-gate 
25670Sstevel@tonic-gate /*
25680Sstevel@tonic-gate  * Create a task queue
25690Sstevel@tonic-gate  */
25700Sstevel@tonic-gate ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name,
25710Sstevel@tonic-gate 	int nthreads, pri_t pri, uint_t cflags);
25720Sstevel@tonic-gate 
25730Sstevel@tonic-gate /*
25740Sstevel@tonic-gate  * destroy a task queue
25750Sstevel@tonic-gate  */
25760Sstevel@tonic-gate void ddi_taskq_destroy(ddi_taskq_t *tq);
25770Sstevel@tonic-gate 
25780Sstevel@tonic-gate /*
25790Sstevel@tonic-gate  * Dispatch a task to a task queue
25800Sstevel@tonic-gate  */
25810Sstevel@tonic-gate int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *),
25820Sstevel@tonic-gate 	void *arg, uint_t dflags);
25830Sstevel@tonic-gate 
25840Sstevel@tonic-gate /*
25850Sstevel@tonic-gate  * Wait for all previously scheduled tasks to complete.
25860Sstevel@tonic-gate  */
25870Sstevel@tonic-gate void ddi_taskq_wait(ddi_taskq_t *tq);
25880Sstevel@tonic-gate 
25890Sstevel@tonic-gate /*
25900Sstevel@tonic-gate  * Suspend all task execution.
25910Sstevel@tonic-gate  */
25920Sstevel@tonic-gate void ddi_taskq_suspend(ddi_taskq_t *tq);
25930Sstevel@tonic-gate 
25940Sstevel@tonic-gate /*
25950Sstevel@tonic-gate  * Resume task execution.
25960Sstevel@tonic-gate  */
25970Sstevel@tonic-gate void ddi_taskq_resume(ddi_taskq_t *tq);
25980Sstevel@tonic-gate 
25990Sstevel@tonic-gate /*
26000Sstevel@tonic-gate  * Is task queue suspended?
26010Sstevel@tonic-gate  */
26020Sstevel@tonic-gate boolean_t ddi_taskq_suspended(ddi_taskq_t *tq);
26030Sstevel@tonic-gate 
26040Sstevel@tonic-gate /*
26050Sstevel@tonic-gate  * Parse an interface name of the form <alphanumeric>##<numeric> where
26060Sstevel@tonic-gate  * <numeric> is maximal.
26070Sstevel@tonic-gate  */
26080Sstevel@tonic-gate int ddi_parse(const char *, char *, uint_t *);
26090Sstevel@tonic-gate 
26100Sstevel@tonic-gate #endif	/* _KERNEL */
26110Sstevel@tonic-gate 
26120Sstevel@tonic-gate #ifdef	__cplusplus
26130Sstevel@tonic-gate }
26140Sstevel@tonic-gate #endif
26150Sstevel@tonic-gate 
26160Sstevel@tonic-gate #endif	/* _SYS_SUNDDI_H */
2617