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