xref: /titanic_52/usr/src/uts/common/sys/sunndi.h (revision 255a2d50c2b10914eecb3c008fadbd29e79f65e6)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5144dfaa9Scth  * Common Development and Distribution License (the "License").
6144dfaa9Scth  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
225febcb4aSScott Carter, SD IOSW  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_SUNNDI_H
277c478bd9Sstevel@tonic-gate #define	_SYS_SUNNDI_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Sun Specific NDI definitions
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <sys/esunddi.h>
357c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
367c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef _KERNEL
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #define	NDI_SUCCESS	DDI_SUCCESS	/* successful return */
457c478bd9Sstevel@tonic-gate #define	NDI_FAILURE	DDI_FAILURE	/* unsuccessful return */
467c478bd9Sstevel@tonic-gate #define	NDI_NOMEM	-2	/* failed to allocate resources */
477c478bd9Sstevel@tonic-gate #define	NDI_BADHANDLE	-3	/* bad handle passed to in function */
487c478bd9Sstevel@tonic-gate #define	NDI_FAULT	-4	/* fault during copyin/copyout */
497c478bd9Sstevel@tonic-gate #define	NDI_BUSY	-5	/* device busy - could not offline */
507c478bd9Sstevel@tonic-gate #define	NDI_UNBOUND	-6	/* device not bound to a driver */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Property functions:   See also, ddipropdefs.h.
547c478bd9Sstevel@tonic-gate  *			In general, the underlying driver MUST be held
557c478bd9Sstevel@tonic-gate  *			to call it's property functions.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  * Used to create boolean properties
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate int
627c478bd9Sstevel@tonic-gate ndi_prop_create_boolean(dev_t match_dev, dev_info_t *dip, char *name);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup integer properties
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate int
687c478bd9Sstevel@tonic-gate ndi_prop_update_int(dev_t match_dev, dev_info_t *dip, char *name, int data);
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate int
717c478bd9Sstevel@tonic-gate ndi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, char *name,
727c478bd9Sstevel@tonic-gate     int *data, uint_t nelements);
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate int
757c478bd9Sstevel@tonic-gate ndi_prop_update_int64(dev_t match_dev, dev_info_t *dip, char *name,
767c478bd9Sstevel@tonic-gate     int64_t data);
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate int
797c478bd9Sstevel@tonic-gate ndi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, char *name,
807c478bd9Sstevel@tonic-gate     int64_t *data, uint_t nelements);
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup string properties
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate int
867c478bd9Sstevel@tonic-gate ndi_prop_update_string(dev_t match_dev, dev_info_t *dip, char *name,
877c478bd9Sstevel@tonic-gate     char *data);
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate int
907c478bd9Sstevel@tonic-gate ndi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
917c478bd9Sstevel@tonic-gate     char *name, char **data, uint_t nelements);
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup byte properties
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate int
977c478bd9Sstevel@tonic-gate ndi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
987c478bd9Sstevel@tonic-gate     char *name, uchar_t *data, uint_t nelements);
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * Used to remove properties
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate int
1047c478bd9Sstevel@tonic-gate ndi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate void
1077c478bd9Sstevel@tonic-gate ndi_prop_remove_all(dev_info_t *dip);
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * Nexus Driver Functions
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * Allocate and initialize a new dev_info structure.
1147c478bd9Sstevel@tonic-gate  * This routine will often be called at interrupt time by a nexus in
1157c478bd9Sstevel@tonic-gate  * response to a hotplug event, therefore memory allocations are
1167c478bd9Sstevel@tonic-gate  * not allowed to sleep.
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate int
119fa9e4066Sahrens ndi_devi_alloc(dev_info_t *parent, char *node_name, pnode_t nodeid,
1207c478bd9Sstevel@tonic-gate     dev_info_t **ret_dip);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate void
123fa9e4066Sahrens ndi_devi_alloc_sleep(dev_info_t *parent, char *node_name, pnode_t nodeid,
1247c478bd9Sstevel@tonic-gate     dev_info_t **ret_dip);
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  * Remove an initialized (but not yet attached) dev_info
1287c478bd9Sstevel@tonic-gate  * node from it's parent.
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate int
1317c478bd9Sstevel@tonic-gate ndi_devi_free(dev_info_t *dip);
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /* devinfo locking: use DEVI_BUSY_OWNED in ASSERTs to verify */
1347c478bd9Sstevel@tonic-gate void ndi_devi_enter(dev_info_t *dip, int *circ);
1357c478bd9Sstevel@tonic-gate void ndi_devi_exit(dev_info_t *dip, int circ);
1367c478bd9Sstevel@tonic-gate int ndi_devi_tryenter(dev_info_t *dip, int *circ);
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /* devinfo ref counting */
1397c478bd9Sstevel@tonic-gate void ndi_hold_devi(dev_info_t *dip);
1407c478bd9Sstevel@tonic-gate void ndi_rele_devi(dev_info_t *dip);
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate /* driver ref counting */
1437c478bd9Sstevel@tonic-gate struct dev_ops *ndi_hold_driver(dev_info_t *dip);
1447c478bd9Sstevel@tonic-gate void ndi_rele_driver(dev_info_t *dip);
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * Change the node name
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate int
1507c478bd9Sstevel@tonic-gate ndi_devi_set_nodename(dev_info_t *dip, char *name, int flags);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * Place the devinfo in the DS_BOUND state,
1547c478bd9Sstevel@tonic-gate  * binding a driver to the device
1557c478bd9Sstevel@tonic-gate  *
1567c478bd9Sstevel@tonic-gate  * Flags:
1577c478bd9Sstevel@tonic-gate  *	all flags are ignored.
1587c478bd9Sstevel@tonic-gate  */
1597c478bd9Sstevel@tonic-gate int
1607c478bd9Sstevel@tonic-gate ndi_devi_bind_driver(dev_info_t *dip, uint_t flags);
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  * Asynchronous version of ndi_devi_bind_driver, callable from
1647c478bd9Sstevel@tonic-gate  * interrupt context. The dip must be a persistent node.
1657c478bd9Sstevel@tonic-gate  */
1667c478bd9Sstevel@tonic-gate int
1677c478bd9Sstevel@tonic-gate ndi_devi_bind_driver_async(dev_info_t *dip, uint_t flags);
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * Return devctl state of the child addressed by "name@addr".
1717c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_GETSTATE handler.
1727c478bd9Sstevel@tonic-gate  */
1737c478bd9Sstevel@tonic-gate int
1747c478bd9Sstevel@tonic-gate ndi_devctl_device_getstate(dev_info_t *parent, struct devctl_iocdata *dcp,
1757c478bd9Sstevel@tonic-gate 	uint_t *state);
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /*
1787c478bd9Sstevel@tonic-gate  * Transition the child addressed by "name@addr" to the online state.
1797c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_ONLINE handler.
1807c478bd9Sstevel@tonic-gate  */
1817c478bd9Sstevel@tonic-gate int
1827c478bd9Sstevel@tonic-gate ndi_devctl_device_online(dev_info_t *dip, struct devctl_iocdata *dcp,
1837c478bd9Sstevel@tonic-gate 	uint_t flags);
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate /*
1867c478bd9Sstevel@tonic-gate  * Transition the child addressed by "name@addr" to the offline state.
1877c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_OFFLINE handler.
1887c478bd9Sstevel@tonic-gate  */
1897c478bd9Sstevel@tonic-gate int
1907c478bd9Sstevel@tonic-gate ndi_devctl_device_offline(dev_info_t *dip, struct devctl_iocdata *dcp,
1917c478bd9Sstevel@tonic-gate 	uint_t flags);
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * Remove the child addressed by name@addr.
1957c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_REMOVE handler.
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate int
1987c478bd9Sstevel@tonic-gate ndi_devctl_device_remove(dev_info_t *dip, struct devctl_iocdata *dcp,
1997c478bd9Sstevel@tonic-gate 	uint_t flags);
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate /*
2027c478bd9Sstevel@tonic-gate  * Bus get state
2037c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_BUS_GETSTATE handler.
2047c478bd9Sstevel@tonic-gate  */
2057c478bd9Sstevel@tonic-gate int
2067c478bd9Sstevel@tonic-gate ndi_devctl_bus_getstate(dev_info_t *dip, struct devctl_iocdata *dcp,
2077c478bd9Sstevel@tonic-gate 	uint_t *state);
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate /*
2107c478bd9Sstevel@tonic-gate  * Place the devinfo in the ONLINE state
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate int
2137c478bd9Sstevel@tonic-gate ndi_devi_online(dev_info_t *dip, uint_t flags);
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate  * Generic devctl ioctl handler
2177c478bd9Sstevel@tonic-gate  */
2187c478bd9Sstevel@tonic-gate int
2197c478bd9Sstevel@tonic-gate ndi_devctl_ioctl(dev_info_t *dip, int cmd, intptr_t arg, int mode,
2207c478bd9Sstevel@tonic-gate 	uint_t flags);
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * Asynchronous version of ndi_devi_online, callable from interrupt
2247c478bd9Sstevel@tonic-gate  * context. The dip must be a persistent node.
2257c478bd9Sstevel@tonic-gate  */
2267c478bd9Sstevel@tonic-gate int
2277c478bd9Sstevel@tonic-gate ndi_devi_online_async(dev_info_t *dip, uint_t flags);
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate /*
2317c478bd9Sstevel@tonic-gate  * Configure children of a nexus node.
2327c478bd9Sstevel@tonic-gate  *
2337c478bd9Sstevel@tonic-gate  * Flags:
2347c478bd9Sstevel@tonic-gate  *	NDI_ONLINE_ATTACH - Attach driver to devinfo node when placing
2357c478bd9Sstevel@tonic-gate  *			    the device Online.
2367c478bd9Sstevel@tonic-gate  *	NDI_CONFIG - Recursively configure children if child is nexus node
2377c478bd9Sstevel@tonic-gate  */
2387c478bd9Sstevel@tonic-gate int
2397c478bd9Sstevel@tonic-gate ndi_devi_config(dev_info_t *dip, int flags);
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate int
2427c478bd9Sstevel@tonic-gate ndi_devi_config_driver(dev_info_t *dip, int flags, major_t major);
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate int
2457c478bd9Sstevel@tonic-gate ndi_devi_config_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, int flags);
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * Unconfigure children of a nexus node.
2497c478bd9Sstevel@tonic-gate  *
2507c478bd9Sstevel@tonic-gate  * Flags:
2517c478bd9Sstevel@tonic-gate  *	NDI_DEVI_REMOVE - Remove child devinfo nodes
2527c478bd9Sstevel@tonic-gate  *
2537c478bd9Sstevel@tonic-gate  *	NDI_UNCONFIG - Put child devinfo nodes to uninitialized state,
2547c478bd9Sstevel@tonic-gate  *			release resources held by child nodes.
2557c478bd9Sstevel@tonic-gate  */
2567c478bd9Sstevel@tonic-gate int
2577c478bd9Sstevel@tonic-gate ndi_devi_unconfig(dev_info_t *dip, int flags);
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate int
2607c478bd9Sstevel@tonic-gate e_ddi_devi_unconfig(dev_info_t *dip, dev_info_t **dipp, int flags);
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate int
2637c478bd9Sstevel@tonic-gate ndi_devi_unconfig_one(dev_info_t *dip, char *devnm, dev_info_t **dipp,
2647c478bd9Sstevel@tonic-gate     int flags);
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate int
2677c478bd9Sstevel@tonic-gate ndi_devi_unconfig_driver(dev_info_t *dip, int flags, major_t major);
2687c478bd9Sstevel@tonic-gate 
269eae2e508Skrishnae void
270eae2e508Skrishnae ndi_set_bus_private(dev_info_t *dip, boolean_t up, uint32_t port_type,
271eae2e508Skrishnae     void *data);
272eae2e508Skrishnae 
273eae2e508Skrishnae void *
274eae2e508Skrishnae ndi_get_bus_private(dev_info_t *dip, boolean_t up);
275eae2e508Skrishnae 
276eae2e508Skrishnae boolean_t
277eae2e508Skrishnae ndi_port_type(dev_info_t *dip, boolean_t up, uint32_t port_type);
278eae2e508Skrishnae 
2797c478bd9Sstevel@tonic-gate /*
2805febcb4aSScott Carter, SD IOSW  * Create/Destroy Interrupt Resource Management (IRM) Pools.
2815febcb4aSScott Carter, SD IOSW  */
2825febcb4aSScott Carter, SD IOSW int
2835febcb4aSScott Carter, SD IOSW ndi_irm_create(dev_info_t *dip, ddi_irm_params_t *paramsp,
2845febcb4aSScott Carter, SD IOSW     ddi_irm_pool_t **pool_retp);
2855febcb4aSScott Carter, SD IOSW 
2865febcb4aSScott Carter, SD IOSW int
2875febcb4aSScott Carter, SD IOSW ndi_irm_destroy(ddi_irm_pool_t *poolp);
2885febcb4aSScott Carter, SD IOSW 
2895febcb4aSScott Carter, SD IOSW /*
2907c478bd9Sstevel@tonic-gate  * Take a device node "Offline".
2917c478bd9Sstevel@tonic-gate  *
2927c478bd9Sstevel@tonic-gate  * Offline means to detach the device instance from the bound
2937c478bd9Sstevel@tonic-gate  * driver and setting the devinfo state to prevent deferred attach
2947c478bd9Sstevel@tonic-gate  * from re-attaching the device instance.
2957c478bd9Sstevel@tonic-gate  *
2967c478bd9Sstevel@tonic-gate  * Flags:
2977c478bd9Sstevel@tonic-gate  *	NDI_DEVI_REMOVE	- Remove the node from the devinfo tree after
2987c478bd9Sstevel@tonic-gate  *			  first taking it Offline.
2997c478bd9Sstevel@tonic-gate  */
3007c478bd9Sstevel@tonic-gate 
3015e3986cbScth #define	NDI_DEVI_REMOVE		0x00000001 /* remove after unconfig */
3025e3986cbScth #define	NDI_ONLINE_ATTACH	0x00000002 /* online/attach after config */
3035e3986cbScth #define	NDI_MDI_FALLBACK	0x00000004 /* Leadville to fallback to phci */
3045e3986cbScth #define	NDI_CONFIG		0x00000008 /* recursively config descendants */
3055e3986cbScth #define	NDI_UNCONFIG		0x00000010 /* unconfig to uninitialized state */
3065e3986cbScth #define	NDI_DEVI_BIND		0x00000020 /* transition to DS_BOUND state */
3075e3986cbScth #define	NDI_DEVI_PERSIST	0x00000040 /* do not config offlined nodes */
3085e3986cbScth #define	NDI_PROMNAME		0x00000080 /* name comes from prom */
3095e3986cbScth #define	NDI_DEVFS_CLEAN		0x00001000 /* clean dv_nodes only, no detach */
3105e3986cbScth #define	NDI_AUTODETACH		0x00002000 /* moduninstall daemon */
3115e3986cbScth #define	NDI_NO_EVENT		0x00004000 /* don't devfs add/remove events */
3125e3986cbScth #define	NDI_DEVI_DEBUG		0x00008000 /* turn on observability */
3135e3986cbScth #define	NDI_CONFIG_REPROBE	0x00010000 /* force reprobe (deferred attach) */
3145e3986cbScth #define	NDI_DEVI_ONLINE		0x00020000 /* force offlined device to online */
3155e3986cbScth #define	NDI_DEVI_OFFLINE	0x00040000 /* set detached device to offline */
3165e3986cbScth #define	NDI_POST_EVENT		0x00080000 /* Post NDI events before remove */
3175e3986cbScth #define	NDI_BRANCH_EVENT_OP	0x01000000 /* branch op needs branch event */
3185e3986cbScth #define	NDI_NO_EVENT_STATE_CHNG	0x02000000 /* don't change the event state */
3195e3986cbScth #define	NDI_DRV_CONF_REPROBE	0x04000000 /* reprobe conf-enum'd nodes only */
3205e3986cbScth #define	NDI_DETACH_DRIVER	0x08000000 /* performing driver_detach */
3215e3986cbScth #define	NDI_MTC_OFF		0x10000000 /* disable multi-threading */
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /* ndi interface flag values */
3247c478bd9Sstevel@tonic-gate #define	NDI_SLEEP		0x000000
3257c478bd9Sstevel@tonic-gate #define	NDI_NOSLEEP		0x100000
3267c478bd9Sstevel@tonic-gate #define	NDI_EVENT_NOPASS	0x200000 /* do not pass event req up the tree */
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate int
3297c478bd9Sstevel@tonic-gate ndi_devi_offline(dev_info_t *dip, uint_t flags);
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate /*
3327c478bd9Sstevel@tonic-gate  * Find the child dev_info node of parent nexus 'p' whose name
3337c478bd9Sstevel@tonic-gate  * matches "cname"@"caddr".  Use ndi_devi_findchild() instead.
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate dev_info_t *
3367c478bd9Sstevel@tonic-gate ndi_devi_find(dev_info_t *p, char *cname, char *caddr);
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate /*
3397c478bd9Sstevel@tonic-gate  * Find the child dev_info node of parent nexus 'p' whose name
3407c478bd9Sstevel@tonic-gate  * matches device name "name"@"addr".
3417c478bd9Sstevel@tonic-gate  */
3427c478bd9Sstevel@tonic-gate dev_info_t *
3437c478bd9Sstevel@tonic-gate ndi_devi_findchild(dev_info_t *p, char *devname);
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate /*
3467c478bd9Sstevel@tonic-gate  * generate debug msg via NDI_DEVI_DEBUG flag
3477c478bd9Sstevel@tonic-gate  */
3487c478bd9Sstevel@tonic-gate #define	NDI_DEBUG(flags, args)	\
3497c478bd9Sstevel@tonic-gate 	if (flags & NDI_DEVI_DEBUG) cmn_err args
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate /*
3527c478bd9Sstevel@tonic-gate  * Copy in the devctl IOCTL data structure and the strings referenced
3537c478bd9Sstevel@tonic-gate  * by the structure.
3547c478bd9Sstevel@tonic-gate  *
3557c478bd9Sstevel@tonic-gate  * Convenience functions for use by nexus drivers as part of the
3567c478bd9Sstevel@tonic-gate  * implementation of devctl IOCTL handling.
3577c478bd9Sstevel@tonic-gate  */
3587c478bd9Sstevel@tonic-gate int
3597c478bd9Sstevel@tonic-gate ndi_dc_allochdl(void *iocarg, struct devctl_iocdata **rdcp);
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate void
3627c478bd9Sstevel@tonic-gate ndi_dc_freehdl(struct devctl_iocdata *dcp);
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate char *
3657c478bd9Sstevel@tonic-gate ndi_dc_getpath(struct devctl_iocdata *dcp);
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate char *
3687c478bd9Sstevel@tonic-gate ndi_dc_getname(struct devctl_iocdata *dcp);
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate char *
3717c478bd9Sstevel@tonic-gate ndi_dc_getaddr(struct devctl_iocdata *dcp);
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate nvlist_t *
3747c478bd9Sstevel@tonic-gate ndi_dc_get_ap_data(struct devctl_iocdata *dcp);
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate char *
3777c478bd9Sstevel@tonic-gate ndi_dc_getminorname(struct devctl_iocdata *dcp);
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate int
3807c478bd9Sstevel@tonic-gate ndi_dc_return_dev_state(dev_info_t *dip, struct devctl_iocdata *dcp);
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate int
3837c478bd9Sstevel@tonic-gate ndi_dc_return_ap_state(devctl_ap_state_t *ap, struct devctl_iocdata *dcp);
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate int
3867c478bd9Sstevel@tonic-gate ndi_dc_return_bus_state(dev_info_t *dip, struct devctl_iocdata *dcp);
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate int
3897c478bd9Sstevel@tonic-gate ndi_dc_devi_create(struct devctl_iocdata *dcp, dev_info_t *pdip, int flags,
3907c478bd9Sstevel@tonic-gate     dev_info_t **rdip);
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate int
3937c478bd9Sstevel@tonic-gate ndi_get_bus_state(dev_info_t *dip, uint_t *rstate);
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate int
3967c478bd9Sstevel@tonic-gate ndi_set_bus_state(dev_info_t *dip, uint_t state);
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate /*
3997c478bd9Sstevel@tonic-gate  * Post an event notification up the device tree hierarchy to the
4007c478bd9Sstevel@tonic-gate  * parent nexus, until claimed by a bus nexus driver or the top
4017c478bd9Sstevel@tonic-gate  * of the dev_info tree is reached.
4027c478bd9Sstevel@tonic-gate  */
4037c478bd9Sstevel@tonic-gate int
4047c478bd9Sstevel@tonic-gate ndi_post_event(dev_info_t *dip, dev_info_t *rdip, ddi_eventcookie_t eventhdl,
4057c478bd9Sstevel@tonic-gate     void *impl_data);
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate /*
4087c478bd9Sstevel@tonic-gate  * Called by the NDI Event Framework to deliver a registration request to the
4097c478bd9Sstevel@tonic-gate  * appropriate bus nexus driver.
4107c478bd9Sstevel@tonic-gate  */
4117c478bd9Sstevel@tonic-gate int
4127c478bd9Sstevel@tonic-gate ndi_busop_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
4137c478bd9Sstevel@tonic-gate     ddi_eventcookie_t eventhdl, void (*callback)(), void *arg,
4147c478bd9Sstevel@tonic-gate     ddi_callback_id_t *cb_id);
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate /*
4177c478bd9Sstevel@tonic-gate  * Called by the NDI Event Framework to deliver an unregister request to the
4187c478bd9Sstevel@tonic-gate  * appropriate bus nexus driver.
4197c478bd9Sstevel@tonic-gate  */
4207c478bd9Sstevel@tonic-gate int
4217c478bd9Sstevel@tonic-gate ndi_busop_remove_eventcall(dev_info_t *ddip, ddi_callback_id_t id);
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate /*
4247c478bd9Sstevel@tonic-gate  * Called by the NDI Event Framework and/or a bus nexus driver's
4257c478bd9Sstevel@tonic-gate  * implementation of the (*bus_get_eventcookie)() interface up the device tree
4267c478bd9Sstevel@tonic-gate  * hierarchy, until claimed by a bus nexus driver or the top of the dev_info
4277c478bd9Sstevel@tonic-gate  * tree is reached.  The NDI Event Framework will skip nexus drivers which are
4287c478bd9Sstevel@tonic-gate  * not configured to handle NDI events.
4297c478bd9Sstevel@tonic-gate  */
4307c478bd9Sstevel@tonic-gate int
4317c478bd9Sstevel@tonic-gate ndi_busop_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, char *name,
4327c478bd9Sstevel@tonic-gate     ddi_eventcookie_t *event_cookiep);
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate /*
4357c478bd9Sstevel@tonic-gate  * ndi event callback support routines:
4367c478bd9Sstevel@tonic-gate  *
4377c478bd9Sstevel@tonic-gate  * these functions require an opaque ndi event handle
4387c478bd9Sstevel@tonic-gate  */
4397c478bd9Sstevel@tonic-gate typedef struct ndi_event_hdl *ndi_event_hdl_t;
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate /*
4427c478bd9Sstevel@tonic-gate  * structure for maintaining each registered callback
4437c478bd9Sstevel@tonic-gate  */
4447c478bd9Sstevel@tonic-gate typedef struct ndi_event_callbacks {
4457c478bd9Sstevel@tonic-gate 	struct ndi_event_callbacks *ndi_evtcb_next;
4467c478bd9Sstevel@tonic-gate 	struct ndi_event_callbacks *ndi_evtcb_prev;
4477c478bd9Sstevel@tonic-gate 	dev_info_t	*ndi_evtcb_dip;
4487c478bd9Sstevel@tonic-gate 	char		*devname; /* name of device defining this callback */
4497c478bd9Sstevel@tonic-gate 	void		(*ndi_evtcb_callback)();
4507c478bd9Sstevel@tonic-gate 	void		*ndi_evtcb_arg;
4517c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	ndi_evtcb_cookie;
4527c478bd9Sstevel@tonic-gate } ndi_event_callbacks_t;
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate /*
4557c478bd9Sstevel@tonic-gate  * a nexus driver defines events that it can support using the
4567c478bd9Sstevel@tonic-gate  * following structure
4577c478bd9Sstevel@tonic-gate  */
4587c478bd9Sstevel@tonic-gate typedef struct ndi_event_definition {
4597c478bd9Sstevel@tonic-gate 	int			ndi_event_tag;
4607c478bd9Sstevel@tonic-gate 	char			*ndi_event_name;
4617c478bd9Sstevel@tonic-gate 	ddi_plevel_t		ndi_event_plevel;
4627c478bd9Sstevel@tonic-gate 	uint_t			ndi_event_attributes;
4637c478bd9Sstevel@tonic-gate } ndi_event_definition_t;
4647c478bd9Sstevel@tonic-gate 
4657c478bd9Sstevel@tonic-gate typedef struct ndi_event_cookie {
4667c478bd9Sstevel@tonic-gate 	ndi_event_definition_t 	*definition;	/* Event Description */
4677c478bd9Sstevel@tonic-gate 	dev_info_t		*ddip;		/* Devi defining this event */
4687c478bd9Sstevel@tonic-gate 	ndi_event_callbacks_t	*callback_list; /* Cb's reg'd to w/ this evt */
4697c478bd9Sstevel@tonic-gate 	struct ndi_event_cookie *next_cookie; 	/* Next cookie def'd in hdl */
4707c478bd9Sstevel@tonic-gate } ndi_event_cookie_t;
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate #define	NDI_EVENT(cookie) ((struct ndi_event_cookie *)(void *)(cookie))
4747c478bd9Sstevel@tonic-gate #define	NDI_EVENT_NAME(cookie) (NDI_EVENT(cookie)->definition->ndi_event_name)
4757c478bd9Sstevel@tonic-gate #define	NDI_EVENT_TAG(cookie) (NDI_EVENT(cookie)->definition->ndi_event_tag)
4767c478bd9Sstevel@tonic-gate #define	NDI_EVENT_ATTRIBUTES(cookie) \
4777c478bd9Sstevel@tonic-gate 	(NDI_EVENT(cookie)->definition->ndi_event_attributes)
4787c478bd9Sstevel@tonic-gate #define	NDI_EVENT_PLEVEL(cookie) \
4797c478bd9Sstevel@tonic-gate 	(NDI_EVENT(cookie)->definition->ndi_event_plevel)
4807c478bd9Sstevel@tonic-gate #define	NDI_EVENT_DDIP(cookie) (NDI_EVENT(cookie)->ddip)
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate /* ndi_event_attributes */
4837c478bd9Sstevel@tonic-gate #define	NDI_EVENT_POST_TO_ALL	0x0 /* broadcast: post to all handlers */
4847c478bd9Sstevel@tonic-gate #define	NDI_EVENT_POST_TO_TGT	0x1 /* call only specific child's hdlr */
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate typedef struct ndi_event_set {
4877c478bd9Sstevel@tonic-gate 	ushort_t		ndi_events_version;
4887c478bd9Sstevel@tonic-gate 	ushort_t		ndi_n_events;
4897c478bd9Sstevel@tonic-gate 	ndi_event_definition_t	*ndi_event_defs;
4907c478bd9Sstevel@tonic-gate } ndi_event_set_t;
4917c478bd9Sstevel@tonic-gate 
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate #define	NDI_EVENTS_REV0			0
4947c478bd9Sstevel@tonic-gate #define	NDI_EVENTS_REV1			1
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate /*
4977c478bd9Sstevel@tonic-gate  * allocate an ndi event handle
4987c478bd9Sstevel@tonic-gate  */
4997c478bd9Sstevel@tonic-gate int
5007c478bd9Sstevel@tonic-gate ndi_event_alloc_hdl(dev_info_t *dip, ddi_iblock_cookie_t cookie,
5017c478bd9Sstevel@tonic-gate 	ndi_event_hdl_t *ndi_event_hdl, uint_t flag);
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate /*
5047c478bd9Sstevel@tonic-gate  * free the ndi event handle
5057c478bd9Sstevel@tonic-gate  */
5067c478bd9Sstevel@tonic-gate int
5077c478bd9Sstevel@tonic-gate ndi_event_free_hdl(ndi_event_hdl_t handle);
5087c478bd9Sstevel@tonic-gate 
5097c478bd9Sstevel@tonic-gate /*
5107c478bd9Sstevel@tonic-gate  * bind or unbind a set of events to/from the event handle
5117c478bd9Sstevel@tonic-gate  */
5127c478bd9Sstevel@tonic-gate int
5137c478bd9Sstevel@tonic-gate ndi_event_bind_set(ndi_event_hdl_t	handle,
5147c478bd9Sstevel@tonic-gate 	ndi_event_set_t		*ndi_event_set,
5157c478bd9Sstevel@tonic-gate 	uint_t			flag);
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate int
5187c478bd9Sstevel@tonic-gate ndi_event_unbind_set(ndi_event_hdl_t	handle,
5197c478bd9Sstevel@tonic-gate 	ndi_event_set_t		*ndi_event_set,
5207c478bd9Sstevel@tonic-gate 	uint_t			flag);
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate /*
5237c478bd9Sstevel@tonic-gate  * get an event cookie
5247c478bd9Sstevel@tonic-gate  */
5257c478bd9Sstevel@tonic-gate int
5267c478bd9Sstevel@tonic-gate ndi_event_retrieve_cookie(ndi_event_hdl_t 	handle,
5277c478bd9Sstevel@tonic-gate 	dev_info_t		*child_dip,
5287c478bd9Sstevel@tonic-gate 	char			*eventname,
5297c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	*cookiep,
5307c478bd9Sstevel@tonic-gate 	uint_t			flag);
5317c478bd9Sstevel@tonic-gate 
5327c478bd9Sstevel@tonic-gate /*
5337c478bd9Sstevel@tonic-gate  * add an event callback info to the ndi event handle
5347c478bd9Sstevel@tonic-gate  */
5357c478bd9Sstevel@tonic-gate int
5367c478bd9Sstevel@tonic-gate ndi_event_add_callback(ndi_event_hdl_t 	handle,
5377c478bd9Sstevel@tonic-gate 	dev_info_t		*child_dip,
5387c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	cookie,
5397c478bd9Sstevel@tonic-gate 	void			(*event_callback)
5407c478bd9Sstevel@tonic-gate 					(dev_info_t *,
5417c478bd9Sstevel@tonic-gate 					ddi_eventcookie_t,
5427c478bd9Sstevel@tonic-gate 					void *arg,
5437c478bd9Sstevel@tonic-gate 					void *impldata),
5447c478bd9Sstevel@tonic-gate 	void			*arg,
5457c478bd9Sstevel@tonic-gate 	uint_t			flag,
5467c478bd9Sstevel@tonic-gate 	ddi_callback_id_t *cb_id);
5477c478bd9Sstevel@tonic-gate 
5487c478bd9Sstevel@tonic-gate /*
5497c478bd9Sstevel@tonic-gate  * remove an event callback registration from the ndi event handle
5507c478bd9Sstevel@tonic-gate  */
5517c478bd9Sstevel@tonic-gate int
5527c478bd9Sstevel@tonic-gate ndi_event_remove_callback(ndi_event_hdl_t handle, ddi_callback_id_t id);
5537c478bd9Sstevel@tonic-gate 
5547c478bd9Sstevel@tonic-gate /*
5557c478bd9Sstevel@tonic-gate  * perform callbacks for a specified cookie
5567c478bd9Sstevel@tonic-gate  */
5577c478bd9Sstevel@tonic-gate int
5587c478bd9Sstevel@tonic-gate ndi_event_run_callbacks(ndi_event_hdl_t	handle, dev_info_t *child_dip,
5597c478bd9Sstevel@tonic-gate     ddi_eventcookie_t cookie, void *bus_impldata);
5607c478bd9Sstevel@tonic-gate 
5617c478bd9Sstevel@tonic-gate /*
5627c478bd9Sstevel@tonic-gate  * do callback for just one child_dip, regardless of attributes
5637c478bd9Sstevel@tonic-gate  */
5647c478bd9Sstevel@tonic-gate int ndi_event_do_callback(ndi_event_hdl_t handle, dev_info_t *child_dip,
5657c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t cookie, void *bus_impldata);
5667c478bd9Sstevel@tonic-gate 
5677c478bd9Sstevel@tonic-gate /*
5687c478bd9Sstevel@tonic-gate  * ndi_event_tag_to_cookie: utility function to find an event cookie
5697c478bd9Sstevel@tonic-gate  * given an event tag
5707c478bd9Sstevel@tonic-gate  */
5717c478bd9Sstevel@tonic-gate ddi_eventcookie_t
5727c478bd9Sstevel@tonic-gate ndi_event_tag_to_cookie(ndi_event_hdl_t handle, int event_tag);
5737c478bd9Sstevel@tonic-gate 
5747c478bd9Sstevel@tonic-gate /*
5757c478bd9Sstevel@tonic-gate  * ndi_event_cookie_to_tag: utility function to find an event tag
5767c478bd9Sstevel@tonic-gate  * given an event_cookie
5777c478bd9Sstevel@tonic-gate  */
5787c478bd9Sstevel@tonic-gate int
5797c478bd9Sstevel@tonic-gate ndi_event_cookie_to_tag(ndi_event_hdl_t handle,
5807c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t cookie);
5817c478bd9Sstevel@tonic-gate 
5827c478bd9Sstevel@tonic-gate /*
5837c478bd9Sstevel@tonic-gate  * ndi_event_cookie_to_name: utility function to find an event
5847c478bd9Sstevel@tonic-gate  * name given an event_cookie
5857c478bd9Sstevel@tonic-gate  */
5867c478bd9Sstevel@tonic-gate char *
5877c478bd9Sstevel@tonic-gate ndi_event_cookie_to_name(ndi_event_hdl_t handle,
5887c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t cookie);
5897c478bd9Sstevel@tonic-gate 
5907c478bd9Sstevel@tonic-gate /*
5917c478bd9Sstevel@tonic-gate  * ndi_event_tag_to_name: utility function to find an event
5927c478bd9Sstevel@tonic-gate  * name given an event_tag
5937c478bd9Sstevel@tonic-gate  */
5947c478bd9Sstevel@tonic-gate char *
5957c478bd9Sstevel@tonic-gate ndi_event_tag_to_name(ndi_event_hdl_t 	handle, int event_tag);
5967c478bd9Sstevel@tonic-gate 
5977c478bd9Sstevel@tonic-gate dev_info_t *
5987c478bd9Sstevel@tonic-gate ndi_devi_config_vhci(char *, int);
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate #ifdef DEBUG
6017c478bd9Sstevel@tonic-gate /*
6027c478bd9Sstevel@tonic-gate  * ndi_event_dump_hdl: debug functionality used to display event handle
6037c478bd9Sstevel@tonic-gate  */
6047c478bd9Sstevel@tonic-gate void
6057c478bd9Sstevel@tonic-gate ndi_event_dump_hdl(struct ndi_event_hdl *hdl, char *location);
6067c478bd9Sstevel@tonic-gate #endif
6077c478bd9Sstevel@tonic-gate 
6087c478bd9Sstevel@tonic-gate /*
6097c478bd9Sstevel@tonic-gate  * Default busop bus_config helper functions
6107c478bd9Sstevel@tonic-gate  */
6117c478bd9Sstevel@tonic-gate int
6127c478bd9Sstevel@tonic-gate ndi_busop_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op,
6137c478bd9Sstevel@tonic-gate     void *arg, dev_info_t **child, clock_t reset_delay);
6147c478bd9Sstevel@tonic-gate 
6157c478bd9Sstevel@tonic-gate int
6167c478bd9Sstevel@tonic-gate ndi_busop_bus_unconfig(dev_info_t *dip, uint_t flags, ddi_bus_config_op_t op,
6177c478bd9Sstevel@tonic-gate     void *arg);
6187c478bd9Sstevel@tonic-gate 
6197c478bd9Sstevel@tonic-gate 
6207c478bd9Sstevel@tonic-gate /*
6217c478bd9Sstevel@tonic-gate  * Bus Resource allocation structures and function prototypes exported
6227c478bd9Sstevel@tonic-gate  * by busra module
6237c478bd9Sstevel@tonic-gate  */
6247c478bd9Sstevel@tonic-gate 
6257c478bd9Sstevel@tonic-gate /* structure for specifying a request */
6267c478bd9Sstevel@tonic-gate typedef struct ndi_ra_request {
6277c478bd9Sstevel@tonic-gate 	uint_t		ra_flags;	/* General flags		*/
6287c478bd9Sstevel@tonic-gate 					/* see bit definitions below	*/
6297c478bd9Sstevel@tonic-gate 
6307c478bd9Sstevel@tonic-gate 	uint64_t	ra_len;		/* Requested allocation length	*/
6317c478bd9Sstevel@tonic-gate 
6327c478bd9Sstevel@tonic-gate 	uint64_t	ra_addr;	/* Specific base address requested */
6337c478bd9Sstevel@tonic-gate 
6347c478bd9Sstevel@tonic-gate 	uint64_t	ra_boundbase;	/* Base address of the area for	*/
6357c478bd9Sstevel@tonic-gate 					/* the allocated resource to be	*/
6367c478bd9Sstevel@tonic-gate 					/* restricted to		*/
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate 	uint64_t	ra_boundlen;	/* Length of the area, starting	*/
6397c478bd9Sstevel@tonic-gate 					/* from ra_boundbase, for the 	*/
6407c478bd9Sstevel@tonic-gate 					/* allocated resource to be	*/
6417c478bd9Sstevel@tonic-gate 					/* restricted to.    		*/
6427c478bd9Sstevel@tonic-gate 
6437c478bd9Sstevel@tonic-gate 	uint64_t	ra_align_mask;	/* Alignment mask used for	*/
6447c478bd9Sstevel@tonic-gate 					/* allocated base address	*/
6457c478bd9Sstevel@tonic-gate } ndi_ra_request_t;
6467c478bd9Sstevel@tonic-gate 
6477c478bd9Sstevel@tonic-gate 
6487c478bd9Sstevel@tonic-gate /* ra_flags bit definitions */
6497c478bd9Sstevel@tonic-gate #define	NDI_RA_ALIGN_SIZE	0x0001	/* Set the alignment of the	*/
6507c478bd9Sstevel@tonic-gate 					/* allocated resource address	*/
6517c478bd9Sstevel@tonic-gate 					/* according to the ra_len	*/
6527c478bd9Sstevel@tonic-gate 					/* value (alignment mask will	*/
6537c478bd9Sstevel@tonic-gate 					/* be (ra_len - 1)). Value of	*/
6547c478bd9Sstevel@tonic-gate 					/* ra_len has to be power of 2.	*/
6557c478bd9Sstevel@tonic-gate 					/* If this flag is set, value of */
6567c478bd9Sstevel@tonic-gate 					/* ra_align_mask will be ignored. */
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate 
6597c478bd9Sstevel@tonic-gate #define	NDI_RA_ALLOC_BOUNDED	0x0002	/* Indicates that the resource	*/
6607c478bd9Sstevel@tonic-gate 					/* should be restricted to the	*/
6617c478bd9Sstevel@tonic-gate 					/* area specified by ra_boundbase */
6627c478bd9Sstevel@tonic-gate 					/* and ra_boundlen */
6637c478bd9Sstevel@tonic-gate 
6647c478bd9Sstevel@tonic-gate #define	NDI_RA_ALLOC_SPECIFIED	0x0004	/* Indicates that a specific	*/
6657c478bd9Sstevel@tonic-gate 					/* address (ra_addr value) is	*/
6667c478bd9Sstevel@tonic-gate 					/* requested.			*/
6677c478bd9Sstevel@tonic-gate 
6687c478bd9Sstevel@tonic-gate #define	NDI_RA_ALLOC_PARTIAL_OK	0x0008  /* Indicates if requested size	*/
6697c478bd9Sstevel@tonic-gate 					/* (ra_len) chunk is not available */
6707c478bd9Sstevel@tonic-gate 					/* then allocate as big chunk as */
6717c478bd9Sstevel@tonic-gate 					/* possible which is less than or */
6727c478bd9Sstevel@tonic-gate 					/* equal to ra_len size. */
6737c478bd9Sstevel@tonic-gate 
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate /* return values specific to bus resource allocator */
6767c478bd9Sstevel@tonic-gate #define	NDI_RA_PARTIAL_REQ		-7
6777c478bd9Sstevel@tonic-gate 
6787c478bd9Sstevel@tonic-gate 
6797c478bd9Sstevel@tonic-gate 
6807c478bd9Sstevel@tonic-gate 
6817c478bd9Sstevel@tonic-gate /* Predefined types for generic type of resources */
6827c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_MEM			"memory"
6837c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_IO			"io"
6847c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_PCI_BUSNUM		"pci_bus_number"
6857c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_PCI_PREFETCH_MEM	"pci_prefetchable_memory"
6867c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_INTR		"interrupt"
6877c478bd9Sstevel@tonic-gate 
6887c478bd9Sstevel@tonic-gate 
6897c478bd9Sstevel@tonic-gate 
6907c478bd9Sstevel@tonic-gate /* flag bit definition */
6917c478bd9Sstevel@tonic-gate #define	NDI_RA_PASS	0x0001		/* pass request up the dev tree */
6927c478bd9Sstevel@tonic-gate 
6937c478bd9Sstevel@tonic-gate 
6947c478bd9Sstevel@tonic-gate /*
6957c478bd9Sstevel@tonic-gate  * Prototype definitions for functions exported
6967c478bd9Sstevel@tonic-gate  */
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate int
6997c478bd9Sstevel@tonic-gate ndi_ra_map_setup(dev_info_t *dip, char *type);
7007c478bd9Sstevel@tonic-gate 
7017c478bd9Sstevel@tonic-gate int
7027c478bd9Sstevel@tonic-gate ndi_ra_map_destroy(dev_info_t *dip, char *type);
7037c478bd9Sstevel@tonic-gate 
7047c478bd9Sstevel@tonic-gate int
7057c478bd9Sstevel@tonic-gate ndi_ra_alloc(dev_info_t *dip, ndi_ra_request_t *req, uint64_t *basep,
7067c478bd9Sstevel@tonic-gate 	uint64_t *lenp, char *type, uint_t flag);
7077c478bd9Sstevel@tonic-gate 
7087c478bd9Sstevel@tonic-gate int
7097c478bd9Sstevel@tonic-gate ndi_ra_free(dev_info_t *dip, uint64_t base, uint64_t len, char *type,
7107c478bd9Sstevel@tonic-gate 	uint_t flag);
7117c478bd9Sstevel@tonic-gate 
7127c478bd9Sstevel@tonic-gate 
7137c478bd9Sstevel@tonic-gate /*
7147c478bd9Sstevel@tonic-gate  * ndi_dev_is_prom_node: Return non-zero if the node is a prom node
7157c478bd9Sstevel@tonic-gate  */
7167c478bd9Sstevel@tonic-gate int ndi_dev_is_prom_node(dev_info_t *);
7177c478bd9Sstevel@tonic-gate 
7187c478bd9Sstevel@tonic-gate /*
7197c478bd9Sstevel@tonic-gate  * ndi_dev_is_pseudo_node: Return non-zero if the node is a pseudo node.
7207c478bd9Sstevel@tonic-gate  * NB: all non-prom nodes are pseudo nodes.
7217c478bd9Sstevel@tonic-gate  * c.f. ndi_dev_is_persistent_node
7227c478bd9Sstevel@tonic-gate  */
7237c478bd9Sstevel@tonic-gate int ndi_dev_is_pseudo_node(dev_info_t *);
7247c478bd9Sstevel@tonic-gate 
7257c478bd9Sstevel@tonic-gate /*
7267c478bd9Sstevel@tonic-gate  * ndi_dev_is_persistent_node: Return non-zero if the node has the
7277c478bd9Sstevel@tonic-gate  * property of persistence.
7287c478bd9Sstevel@tonic-gate  */
7297c478bd9Sstevel@tonic-gate int ndi_dev_is_persistent_node(dev_info_t *);
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate /*
7327c478bd9Sstevel@tonic-gate  * Event posted when a fault is reported
7337c478bd9Sstevel@tonic-gate  */
7347c478bd9Sstevel@tonic-gate #define	DDI_DEVI_FAULT_EVENT	"DDI:DEVI_FAULT"
7357c478bd9Sstevel@tonic-gate 
7367c478bd9Sstevel@tonic-gate struct ddi_fault_event_data {
7377c478bd9Sstevel@tonic-gate 	dev_info_t		*f_dip;
7387c478bd9Sstevel@tonic-gate 	ddi_fault_impact_t	f_impact;
7397c478bd9Sstevel@tonic-gate 	ddi_fault_location_t	f_location;
7407c478bd9Sstevel@tonic-gate 	const char		*f_message;
7417c478bd9Sstevel@tonic-gate 	ddi_devstate_t		f_oldstate;
7427c478bd9Sstevel@tonic-gate };
7437c478bd9Sstevel@tonic-gate 
7447c478bd9Sstevel@tonic-gate /*
7457c478bd9Sstevel@tonic-gate  * Access handle/DMA handle fault flag setting/clearing functions for nexi
7467c478bd9Sstevel@tonic-gate  */
7477c478bd9Sstevel@tonic-gate void ndi_set_acc_fault(ddi_acc_handle_t ah);
7487c478bd9Sstevel@tonic-gate void ndi_clr_acc_fault(ddi_acc_handle_t ah);
7497c478bd9Sstevel@tonic-gate void ndi_set_dma_fault(ddi_dma_handle_t dh);
7507c478bd9Sstevel@tonic-gate void ndi_clr_dma_fault(ddi_dma_handle_t dh);
7517c478bd9Sstevel@tonic-gate 
7527c478bd9Sstevel@tonic-gate /* Driver.conf property merging */
7537c478bd9Sstevel@tonic-gate int ndi_merge_node(dev_info_t *, int (*)(dev_info_t *, char *, int));
7547c478bd9Sstevel@tonic-gate void ndi_merge_wildcard_node(dev_info_t *);
7557c478bd9Sstevel@tonic-gate 
756*255a2d50SMatthew Jacob /*
757*255a2d50SMatthew Jacob  * Ndi 'flavor' support: These interfaces are to support a nexus driver
758*255a2d50SMatthew Jacob  * with multiple 'flavors' of children (devi_flavor of child), coupled
759*255a2d50SMatthew Jacob  * with a child flavor-specifc private data mechanism (via devi_flavor_v
760*255a2d50SMatthew Jacob  * of parent). This is provided as an extension to ddi_[sg]et_driver_private,
761*255a2d50SMatthew Jacob  * where the vanilla 'flavor' is what is stored or retrieved via
762*255a2d50SMatthew Jacob  * ddi_[sg]et_driver_private.
763*255a2d50SMatthew Jacob  *
764*255a2d50SMatthew Jacob  * Flavors are indexed with a small integer. The first flavor, flavor
765*255a2d50SMatthew Jacob  * zero, is always present and reserved as the 'vanilla' flavor.
766*255a2d50SMatthew Jacob  * Space for extra flavors can be allocated and private pointers
767*255a2d50SMatthew Jacob  * with respect to each flavor set and retrieved.
768*255a2d50SMatthew Jacob  *
769*255a2d50SMatthew Jacob  * NOTE:For a nexus driver, if the need to support multiple flavors of
770*255a2d50SMatthew Jacob  *	children is understood from the begining, then a private 'flavor'
771*255a2d50SMatthew Jacob  *	mechanism can be implemented via ddi_[sg]et_driver_private.
772*255a2d50SMatthew Jacob  *
773*255a2d50SMatthew Jacob  *	With SCSA, the need to support multiple flavors of children was not
774*255a2d50SMatthew Jacob  *	anticipated, and ddi_get_driver_private(9F) of an initiator port
775*255a2d50SMatthew Jacob  *	devinfo node was publicly defined in the DDI to return a
776*255a2d50SMatthew Jacob  *	scsi_device(9S) child-flavor specific value: a pointer to
777*255a2d50SMatthew Jacob  *	scsi_hba_tran(9S).  Over the years, each time the need to support
778*255a2d50SMatthew Jacob  *	a new flavor of child has occurred, a new form of overload/kludge
779*255a2d50SMatthew Jacob  *	has been devised. The ndi 'flavors' interfaces provide a simple way
780*255a2d50SMatthew Jacob  *	to address this issue that can be used by both SCSA nexus support,
781*255a2d50SMatthew Jacob  *	and by other nexus drivers.
782*255a2d50SMatthew Jacob  */
783*255a2d50SMatthew Jacob 
784*255a2d50SMatthew Jacob /*
785*255a2d50SMatthew Jacob  * Interfaces to maintain flavor-specific private data for children of self
786*255a2d50SMatthew Jacob  */
787*255a2d50SMatthew Jacob #define	NDI_FLAVOR_VANILLA	0
788*255a2d50SMatthew Jacob 
789*255a2d50SMatthew Jacob void	ndi_flavorv_alloc(dev_info_t *self, int nflavors);
790*255a2d50SMatthew Jacob void	ndi_flavorv_set(dev_info_t *self, ndi_flavor_t child_flavor, void *);
791*255a2d50SMatthew Jacob void	*ndi_flavorv_get(dev_info_t *self, ndi_flavor_t child_flavor);
792*255a2d50SMatthew Jacob 
793*255a2d50SMatthew Jacob /* Interfaces for 'self' nexus driver to get/set flavor of child */
794*255a2d50SMatthew Jacob void		ndi_flavor_set(dev_info_t *child, ndi_flavor_t child_flavor);
795*255a2d50SMatthew Jacob ndi_flavor_t	ndi_flavor_get(dev_info_t *child);
796*255a2d50SMatthew Jacob 
7977c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
7987c478bd9Sstevel@tonic-gate 
7997c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
8007c478bd9Sstevel@tonic-gate }
8017c478bd9Sstevel@tonic-gate #endif
8027c478bd9Sstevel@tonic-gate 
8037c478bd9Sstevel@tonic-gate #endif	/* _SYS_SUNNDI_H */
804