xref: /titanic_51/usr/src/uts/common/sys/sunndi.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_SUNNDI_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SUNNDI_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Sun Specific NDI definitions
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #include <sys/esunddi.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h>
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
42*7c478bd9Sstevel@tonic-gate extern "C" {
43*7c478bd9Sstevel@tonic-gate #endif
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #define	NDI_SUCCESS	DDI_SUCCESS	/* successful return */
48*7c478bd9Sstevel@tonic-gate #define	NDI_FAILURE	DDI_FAILURE	/* unsuccessful return */
49*7c478bd9Sstevel@tonic-gate #define	NDI_NOMEM	-2	/* failed to allocate resources */
50*7c478bd9Sstevel@tonic-gate #define	NDI_BADHANDLE	-3	/* bad handle passed to in function */
51*7c478bd9Sstevel@tonic-gate #define	NDI_FAULT	-4	/* fault during copyin/copyout */
52*7c478bd9Sstevel@tonic-gate #define	NDI_BUSY	-5	/* device busy - could not offline */
53*7c478bd9Sstevel@tonic-gate #define	NDI_UNBOUND	-6	/* device not bound to a driver */
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate /*
56*7c478bd9Sstevel@tonic-gate  * Property functions:   See also, ddipropdefs.h.
57*7c478bd9Sstevel@tonic-gate  *			In general, the underlying driver MUST be held
58*7c478bd9Sstevel@tonic-gate  *			to call it's property functions.
59*7c478bd9Sstevel@tonic-gate  */
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /*
62*7c478bd9Sstevel@tonic-gate  * Used to create boolean properties
63*7c478bd9Sstevel@tonic-gate  */
64*7c478bd9Sstevel@tonic-gate int
65*7c478bd9Sstevel@tonic-gate ndi_prop_create_boolean(dev_t match_dev, dev_info_t *dip, char *name);
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate /*
68*7c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup integer properties
69*7c478bd9Sstevel@tonic-gate  */
70*7c478bd9Sstevel@tonic-gate int
71*7c478bd9Sstevel@tonic-gate ndi_prop_update_int(dev_t match_dev, dev_info_t *dip, char *name, int data);
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate int
74*7c478bd9Sstevel@tonic-gate ndi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, char *name,
75*7c478bd9Sstevel@tonic-gate     int *data, uint_t nelements);
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate int
78*7c478bd9Sstevel@tonic-gate ndi_prop_update_int64(dev_t match_dev, dev_info_t *dip, char *name,
79*7c478bd9Sstevel@tonic-gate     int64_t data);
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate int
82*7c478bd9Sstevel@tonic-gate ndi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, char *name,
83*7c478bd9Sstevel@tonic-gate     int64_t *data, uint_t nelements);
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate /*
86*7c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup string properties
87*7c478bd9Sstevel@tonic-gate  */
88*7c478bd9Sstevel@tonic-gate int
89*7c478bd9Sstevel@tonic-gate ndi_prop_update_string(dev_t match_dev, dev_info_t *dip, char *name,
90*7c478bd9Sstevel@tonic-gate     char *data);
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate int
93*7c478bd9Sstevel@tonic-gate ndi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
94*7c478bd9Sstevel@tonic-gate     char *name, char **data, uint_t nelements);
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate /*
97*7c478bd9Sstevel@tonic-gate  * Used to create, modify, and lookup byte properties
98*7c478bd9Sstevel@tonic-gate  */
99*7c478bd9Sstevel@tonic-gate int
100*7c478bd9Sstevel@tonic-gate ndi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
101*7c478bd9Sstevel@tonic-gate     char *name, uchar_t *data, uint_t nelements);
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate /*
104*7c478bd9Sstevel@tonic-gate  * Used to remove properties
105*7c478bd9Sstevel@tonic-gate  */
106*7c478bd9Sstevel@tonic-gate int
107*7c478bd9Sstevel@tonic-gate ndi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate void
110*7c478bd9Sstevel@tonic-gate ndi_prop_remove_all(dev_info_t *dip);
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate /*
113*7c478bd9Sstevel@tonic-gate  * Nexus Driver Functions
114*7c478bd9Sstevel@tonic-gate  */
115*7c478bd9Sstevel@tonic-gate /*
116*7c478bd9Sstevel@tonic-gate  * Allocate and initialize a new dev_info structure.
117*7c478bd9Sstevel@tonic-gate  * This routine will often be called at interrupt time by a nexus in
118*7c478bd9Sstevel@tonic-gate  * response to a hotplug event, therefore memory allocations are
119*7c478bd9Sstevel@tonic-gate  * not allowed to sleep.
120*7c478bd9Sstevel@tonic-gate  */
121*7c478bd9Sstevel@tonic-gate int
122*7c478bd9Sstevel@tonic-gate ndi_devi_alloc(dev_info_t *parent, char *node_name, dnode_t nodeid,
123*7c478bd9Sstevel@tonic-gate     dev_info_t **ret_dip);
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate void
126*7c478bd9Sstevel@tonic-gate ndi_devi_alloc_sleep(dev_info_t *parent, char *node_name, dnode_t nodeid,
127*7c478bd9Sstevel@tonic-gate     dev_info_t **ret_dip);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate /*
130*7c478bd9Sstevel@tonic-gate  * Remove an initialized (but not yet attached) dev_info
131*7c478bd9Sstevel@tonic-gate  * node from it's parent.
132*7c478bd9Sstevel@tonic-gate  */
133*7c478bd9Sstevel@tonic-gate int
134*7c478bd9Sstevel@tonic-gate ndi_devi_free(dev_info_t *dip);
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate /* devinfo locking: use DEVI_BUSY_OWNED in ASSERTs to verify */
137*7c478bd9Sstevel@tonic-gate void ndi_devi_enter(dev_info_t *dip, int *circ);
138*7c478bd9Sstevel@tonic-gate void ndi_devi_exit(dev_info_t *dip, int circ);
139*7c478bd9Sstevel@tonic-gate int ndi_devi_tryenter(dev_info_t *dip, int *circ);
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /* devinfo ref counting */
142*7c478bd9Sstevel@tonic-gate void ndi_hold_devi(dev_info_t *dip);
143*7c478bd9Sstevel@tonic-gate void ndi_rele_devi(dev_info_t *dip);
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate /* driver ref counting */
146*7c478bd9Sstevel@tonic-gate struct dev_ops *ndi_hold_driver(dev_info_t *dip);
147*7c478bd9Sstevel@tonic-gate void ndi_rele_driver(dev_info_t *dip);
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate /*
150*7c478bd9Sstevel@tonic-gate  * Change the node name
151*7c478bd9Sstevel@tonic-gate  */
152*7c478bd9Sstevel@tonic-gate int
153*7c478bd9Sstevel@tonic-gate ndi_devi_set_nodename(dev_info_t *dip, char *name, int flags);
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate /*
156*7c478bd9Sstevel@tonic-gate  * Place the devinfo in the DS_BOUND state,
157*7c478bd9Sstevel@tonic-gate  * binding a driver to the device
158*7c478bd9Sstevel@tonic-gate  *
159*7c478bd9Sstevel@tonic-gate  * Flags:
160*7c478bd9Sstevel@tonic-gate  *	all flags are ignored.
161*7c478bd9Sstevel@tonic-gate  */
162*7c478bd9Sstevel@tonic-gate int
163*7c478bd9Sstevel@tonic-gate ndi_devi_bind_driver(dev_info_t *dip, uint_t flags);
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate /*
166*7c478bd9Sstevel@tonic-gate  * Asynchronous version of ndi_devi_bind_driver, callable from
167*7c478bd9Sstevel@tonic-gate  * interrupt context. The dip must be a persistent node.
168*7c478bd9Sstevel@tonic-gate  */
169*7c478bd9Sstevel@tonic-gate int
170*7c478bd9Sstevel@tonic-gate ndi_devi_bind_driver_async(dev_info_t *dip, uint_t flags);
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate /*
173*7c478bd9Sstevel@tonic-gate  * Return devctl state of the child addressed by "name@addr".
174*7c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_GETSTATE handler.
175*7c478bd9Sstevel@tonic-gate  */
176*7c478bd9Sstevel@tonic-gate int
177*7c478bd9Sstevel@tonic-gate ndi_devctl_device_getstate(dev_info_t *parent, struct devctl_iocdata *dcp,
178*7c478bd9Sstevel@tonic-gate 	uint_t *state);
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate /*
181*7c478bd9Sstevel@tonic-gate  * Transition the child addressed by "name@addr" to the online state.
182*7c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_ONLINE handler.
183*7c478bd9Sstevel@tonic-gate  */
184*7c478bd9Sstevel@tonic-gate int
185*7c478bd9Sstevel@tonic-gate ndi_devctl_device_online(dev_info_t *dip, struct devctl_iocdata *dcp,
186*7c478bd9Sstevel@tonic-gate 	uint_t flags);
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate /*
189*7c478bd9Sstevel@tonic-gate  * Transition the child addressed by "name@addr" to the offline state.
190*7c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_OFFLINE handler.
191*7c478bd9Sstevel@tonic-gate  */
192*7c478bd9Sstevel@tonic-gate int
193*7c478bd9Sstevel@tonic-gate ndi_devctl_device_offline(dev_info_t *dip, struct devctl_iocdata *dcp,
194*7c478bd9Sstevel@tonic-gate 	uint_t flags);
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate /*
197*7c478bd9Sstevel@tonic-gate  * Remove the child addressed by name@addr.
198*7c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_DEVICE_REMOVE handler.
199*7c478bd9Sstevel@tonic-gate  */
200*7c478bd9Sstevel@tonic-gate int
201*7c478bd9Sstevel@tonic-gate ndi_devctl_device_remove(dev_info_t *dip, struct devctl_iocdata *dcp,
202*7c478bd9Sstevel@tonic-gate 	uint_t flags);
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate /*
205*7c478bd9Sstevel@tonic-gate  * Bus get state
206*7c478bd9Sstevel@tonic-gate  * For use by a driver's DEVCTL_BUS_GETSTATE handler.
207*7c478bd9Sstevel@tonic-gate  */
208*7c478bd9Sstevel@tonic-gate int
209*7c478bd9Sstevel@tonic-gate ndi_devctl_bus_getstate(dev_info_t *dip, struct devctl_iocdata *dcp,
210*7c478bd9Sstevel@tonic-gate 	uint_t *state);
211*7c478bd9Sstevel@tonic-gate 
212*7c478bd9Sstevel@tonic-gate /*
213*7c478bd9Sstevel@tonic-gate  * Place the devinfo in the ONLINE state
214*7c478bd9Sstevel@tonic-gate  */
215*7c478bd9Sstevel@tonic-gate int
216*7c478bd9Sstevel@tonic-gate ndi_devi_online(dev_info_t *dip, uint_t flags);
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate /*
219*7c478bd9Sstevel@tonic-gate  * Generic devctl ioctl handler
220*7c478bd9Sstevel@tonic-gate  */
221*7c478bd9Sstevel@tonic-gate int
222*7c478bd9Sstevel@tonic-gate ndi_devctl_ioctl(dev_info_t *dip, int cmd, intptr_t arg, int mode,
223*7c478bd9Sstevel@tonic-gate 	uint_t flags);
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate /*
226*7c478bd9Sstevel@tonic-gate  * Asynchronous version of ndi_devi_online, callable from interrupt
227*7c478bd9Sstevel@tonic-gate  * context. The dip must be a persistent node.
228*7c478bd9Sstevel@tonic-gate  */
229*7c478bd9Sstevel@tonic-gate int
230*7c478bd9Sstevel@tonic-gate ndi_devi_online_async(dev_info_t *dip, uint_t flags);
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate /*
234*7c478bd9Sstevel@tonic-gate  * Configure children of a nexus node.
235*7c478bd9Sstevel@tonic-gate  *
236*7c478bd9Sstevel@tonic-gate  * Flags:
237*7c478bd9Sstevel@tonic-gate  *	NDI_ONLINE_ATTACH - Attach driver to devinfo node when placing
238*7c478bd9Sstevel@tonic-gate  *			    the device Online.
239*7c478bd9Sstevel@tonic-gate  *	NDI_CONFIG - Recursively configure children if child is nexus node
240*7c478bd9Sstevel@tonic-gate  */
241*7c478bd9Sstevel@tonic-gate int
242*7c478bd9Sstevel@tonic-gate ndi_devi_config(dev_info_t *dip, int flags);
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate int
245*7c478bd9Sstevel@tonic-gate ndi_devi_config_driver(dev_info_t *dip, int flags, major_t major);
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate int
248*7c478bd9Sstevel@tonic-gate ndi_devi_config_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, int flags);
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate /*
251*7c478bd9Sstevel@tonic-gate  * Unconfigure children of a nexus node.
252*7c478bd9Sstevel@tonic-gate  *
253*7c478bd9Sstevel@tonic-gate  * Flags:
254*7c478bd9Sstevel@tonic-gate  *	NDI_DEVI_REMOVE - Remove child devinfo nodes
255*7c478bd9Sstevel@tonic-gate  *
256*7c478bd9Sstevel@tonic-gate  *	NDI_UNCONFIG - Put child devinfo nodes to uninitialized state,
257*7c478bd9Sstevel@tonic-gate  *			release resources held by child nodes.
258*7c478bd9Sstevel@tonic-gate  */
259*7c478bd9Sstevel@tonic-gate int
260*7c478bd9Sstevel@tonic-gate ndi_devi_unconfig(dev_info_t *dip, int flags);
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate int
263*7c478bd9Sstevel@tonic-gate e_ddi_devi_unconfig(dev_info_t *dip, dev_info_t **dipp, int flags);
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate int
266*7c478bd9Sstevel@tonic-gate ndi_devi_unconfig_one(dev_info_t *dip, char *devnm, dev_info_t **dipp,
267*7c478bd9Sstevel@tonic-gate     int flags);
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate int
270*7c478bd9Sstevel@tonic-gate ndi_devi_unconfig_driver(dev_info_t *dip, int flags, major_t major);
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate /*
273*7c478bd9Sstevel@tonic-gate  * Take a device node "Offline".
274*7c478bd9Sstevel@tonic-gate  *
275*7c478bd9Sstevel@tonic-gate  * Offline means to detach the device instance from the bound
276*7c478bd9Sstevel@tonic-gate  * driver and setting the devinfo state to prevent deferred attach
277*7c478bd9Sstevel@tonic-gate  * from re-attaching the device instance.
278*7c478bd9Sstevel@tonic-gate  *
279*7c478bd9Sstevel@tonic-gate  * Flags:
280*7c478bd9Sstevel@tonic-gate  *	NDI_DEVI_REMOVE	- Remove the node from the devinfo tree after
281*7c478bd9Sstevel@tonic-gate  *			  first taking it Offline.
282*7c478bd9Sstevel@tonic-gate  */
283*7c478bd9Sstevel@tonic-gate 
284*7c478bd9Sstevel@tonic-gate #define	NDI_DEVI_REMOVE		0x00001 /* remove after unconfig */
285*7c478bd9Sstevel@tonic-gate #define	NDI_ONLINE_ATTACH	0x00002 /* online/attach after config */
286*7c478bd9Sstevel@tonic-gate #define	NDI_MDI_FALLBACK	0x00004 /* Leadville to fallback to phci */
287*7c478bd9Sstevel@tonic-gate #define	NDI_CONFIG		0x00008 /* recursively config descendants */
288*7c478bd9Sstevel@tonic-gate #define	NDI_UNCONFIG		0x00010 /* unconfig to uninitialized state */
289*7c478bd9Sstevel@tonic-gate #define	NDI_DEVI_BIND		0x00020 /* transition to DS_BOUND state */
290*7c478bd9Sstevel@tonic-gate #define	NDI_DEVI_PERSIST	0x00040 /* do not config offlined nodes */
291*7c478bd9Sstevel@tonic-gate #define	NDI_PROMNAME		0x00080 /* name comes from prom */
292*7c478bd9Sstevel@tonic-gate #define	NDI_DEVFS_CLEAN		0x01000 /* clean up dv_nodes only, no detach */
293*7c478bd9Sstevel@tonic-gate #define	NDI_AUTODETACH		0x02000 /* moduninstall daemon */
294*7c478bd9Sstevel@tonic-gate #define	NDI_NO_EVENT		0x04000 /* don't devfs add/remove events */
295*7c478bd9Sstevel@tonic-gate #define	NDI_DEVI_DEBUG		0x08000 /* turn on observability */
296*7c478bd9Sstevel@tonic-gate #define	NDI_CONFIG_REPROBE	0x10000 /* force a reprobe (deferred attach) */
297*7c478bd9Sstevel@tonic-gate #define	NDI_DEVI_ONLINE		0x20000 /* force offlined device to online */
298*7c478bd9Sstevel@tonic-gate #define	NDI_DEVI_OFFLINE	0x40000 /* set detached device to offline */
299*7c478bd9Sstevel@tonic-gate #define	NDI_POST_EVENT		0x80000 /* Post NDI events before remove */
300*7c478bd9Sstevel@tonic-gate #define	NDI_BRANCH_EVENT_OP	0x1000000 /* branch op needing a branch event */
301*7c478bd9Sstevel@tonic-gate #define	NDI_NO_EVENT_STATE_CHNG	0x2000000 /* don't change the event state */
302*7c478bd9Sstevel@tonic-gate #define	NDI_DRV_CONF_REPROBE	0x4000000 /* reprobe conf-enum'd nodes only */
303*7c478bd9Sstevel@tonic-gate #define	NDI_DETACH_DRIVER	0x8000000 /* performing driver_detach */
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate /* ndi interface flag values */
306*7c478bd9Sstevel@tonic-gate #define	NDI_SLEEP		0x000000
307*7c478bd9Sstevel@tonic-gate #define	NDI_NOSLEEP		0x100000
308*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_NOPASS	0x200000 /* do not pass event req up the tree */
309*7c478bd9Sstevel@tonic-gate 
310*7c478bd9Sstevel@tonic-gate int
311*7c478bd9Sstevel@tonic-gate ndi_devi_offline(dev_info_t *dip, uint_t flags);
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate /*
314*7c478bd9Sstevel@tonic-gate  * Find the child dev_info node of parent nexus 'p' whose name
315*7c478bd9Sstevel@tonic-gate  * matches "cname"@"caddr".  Use ndi_devi_findchild() instead.
316*7c478bd9Sstevel@tonic-gate  */
317*7c478bd9Sstevel@tonic-gate dev_info_t *
318*7c478bd9Sstevel@tonic-gate ndi_devi_find(dev_info_t *p, char *cname, char *caddr);
319*7c478bd9Sstevel@tonic-gate 
320*7c478bd9Sstevel@tonic-gate /*
321*7c478bd9Sstevel@tonic-gate  * Find the child dev_info node of parent nexus 'p' whose name
322*7c478bd9Sstevel@tonic-gate  * matches device name "name"@"addr".
323*7c478bd9Sstevel@tonic-gate  */
324*7c478bd9Sstevel@tonic-gate dev_info_t *
325*7c478bd9Sstevel@tonic-gate ndi_devi_findchild(dev_info_t *p, char *devname);
326*7c478bd9Sstevel@tonic-gate 
327*7c478bd9Sstevel@tonic-gate /*
328*7c478bd9Sstevel@tonic-gate  * generate debug msg via NDI_DEVI_DEBUG flag
329*7c478bd9Sstevel@tonic-gate  */
330*7c478bd9Sstevel@tonic-gate #define	NDI_DEBUG(flags, args)	\
331*7c478bd9Sstevel@tonic-gate 	if (flags & NDI_DEVI_DEBUG) cmn_err args
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate /*
334*7c478bd9Sstevel@tonic-gate  * Copy in the devctl IOCTL data structure and the strings referenced
335*7c478bd9Sstevel@tonic-gate  * by the structure.
336*7c478bd9Sstevel@tonic-gate  *
337*7c478bd9Sstevel@tonic-gate  * Convenience functions for use by nexus drivers as part of the
338*7c478bd9Sstevel@tonic-gate  * implementation of devctl IOCTL handling.
339*7c478bd9Sstevel@tonic-gate  */
340*7c478bd9Sstevel@tonic-gate int
341*7c478bd9Sstevel@tonic-gate ndi_dc_allochdl(void *iocarg, struct devctl_iocdata **rdcp);
342*7c478bd9Sstevel@tonic-gate 
343*7c478bd9Sstevel@tonic-gate void
344*7c478bd9Sstevel@tonic-gate ndi_dc_freehdl(struct devctl_iocdata *dcp);
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate char *
347*7c478bd9Sstevel@tonic-gate ndi_dc_getpath(struct devctl_iocdata *dcp);
348*7c478bd9Sstevel@tonic-gate 
349*7c478bd9Sstevel@tonic-gate char *
350*7c478bd9Sstevel@tonic-gate ndi_dc_getname(struct devctl_iocdata *dcp);
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate char *
353*7c478bd9Sstevel@tonic-gate ndi_dc_getaddr(struct devctl_iocdata *dcp);
354*7c478bd9Sstevel@tonic-gate 
355*7c478bd9Sstevel@tonic-gate nvlist_t *
356*7c478bd9Sstevel@tonic-gate ndi_dc_get_ap_data(struct devctl_iocdata *dcp);
357*7c478bd9Sstevel@tonic-gate 
358*7c478bd9Sstevel@tonic-gate char *
359*7c478bd9Sstevel@tonic-gate ndi_dc_getminorname(struct devctl_iocdata *dcp);
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate int
362*7c478bd9Sstevel@tonic-gate ndi_dc_return_dev_state(dev_info_t *dip, struct devctl_iocdata *dcp);
363*7c478bd9Sstevel@tonic-gate 
364*7c478bd9Sstevel@tonic-gate int
365*7c478bd9Sstevel@tonic-gate ndi_dc_return_ap_state(devctl_ap_state_t *ap, struct devctl_iocdata *dcp);
366*7c478bd9Sstevel@tonic-gate 
367*7c478bd9Sstevel@tonic-gate int
368*7c478bd9Sstevel@tonic-gate ndi_dc_return_bus_state(dev_info_t *dip, struct devctl_iocdata *dcp);
369*7c478bd9Sstevel@tonic-gate 
370*7c478bd9Sstevel@tonic-gate int
371*7c478bd9Sstevel@tonic-gate ndi_dc_devi_create(struct devctl_iocdata *dcp, dev_info_t *pdip, int flags,
372*7c478bd9Sstevel@tonic-gate     dev_info_t **rdip);
373*7c478bd9Sstevel@tonic-gate 
374*7c478bd9Sstevel@tonic-gate int
375*7c478bd9Sstevel@tonic-gate ndi_get_bus_state(dev_info_t *dip, uint_t *rstate);
376*7c478bd9Sstevel@tonic-gate 
377*7c478bd9Sstevel@tonic-gate int
378*7c478bd9Sstevel@tonic-gate ndi_set_bus_state(dev_info_t *dip, uint_t state);
379*7c478bd9Sstevel@tonic-gate 
380*7c478bd9Sstevel@tonic-gate /*
381*7c478bd9Sstevel@tonic-gate  * Post an event notification up the device tree hierarchy to the
382*7c478bd9Sstevel@tonic-gate  * parent nexus, until claimed by a bus nexus driver or the top
383*7c478bd9Sstevel@tonic-gate  * of the dev_info tree is reached.
384*7c478bd9Sstevel@tonic-gate  */
385*7c478bd9Sstevel@tonic-gate int
386*7c478bd9Sstevel@tonic-gate ndi_post_event(dev_info_t *dip, dev_info_t *rdip, ddi_eventcookie_t eventhdl,
387*7c478bd9Sstevel@tonic-gate     void *impl_data);
388*7c478bd9Sstevel@tonic-gate 
389*7c478bd9Sstevel@tonic-gate /*
390*7c478bd9Sstevel@tonic-gate  * Called by the NDI Event Framework to deliver a registration request to the
391*7c478bd9Sstevel@tonic-gate  * appropriate bus nexus driver.
392*7c478bd9Sstevel@tonic-gate  */
393*7c478bd9Sstevel@tonic-gate int
394*7c478bd9Sstevel@tonic-gate ndi_busop_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
395*7c478bd9Sstevel@tonic-gate     ddi_eventcookie_t eventhdl, void (*callback)(), void *arg,
396*7c478bd9Sstevel@tonic-gate     ddi_callback_id_t *cb_id);
397*7c478bd9Sstevel@tonic-gate 
398*7c478bd9Sstevel@tonic-gate /*
399*7c478bd9Sstevel@tonic-gate  * Called by the NDI Event Framework to deliver an unregister request to the
400*7c478bd9Sstevel@tonic-gate  * appropriate bus nexus driver.
401*7c478bd9Sstevel@tonic-gate  */
402*7c478bd9Sstevel@tonic-gate int
403*7c478bd9Sstevel@tonic-gate ndi_busop_remove_eventcall(dev_info_t *ddip, ddi_callback_id_t id);
404*7c478bd9Sstevel@tonic-gate 
405*7c478bd9Sstevel@tonic-gate /*
406*7c478bd9Sstevel@tonic-gate  * Called by the NDI Event Framework and/or a bus nexus driver's
407*7c478bd9Sstevel@tonic-gate  * implementation of the (*bus_get_eventcookie)() interface up the device tree
408*7c478bd9Sstevel@tonic-gate  * hierarchy, until claimed by a bus nexus driver or the top of the dev_info
409*7c478bd9Sstevel@tonic-gate  * tree is reached.  The NDI Event Framework will skip nexus drivers which are
410*7c478bd9Sstevel@tonic-gate  * not configured to handle NDI events.
411*7c478bd9Sstevel@tonic-gate  */
412*7c478bd9Sstevel@tonic-gate int
413*7c478bd9Sstevel@tonic-gate ndi_busop_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, char *name,
414*7c478bd9Sstevel@tonic-gate     ddi_eventcookie_t *event_cookiep);
415*7c478bd9Sstevel@tonic-gate 
416*7c478bd9Sstevel@tonic-gate /*
417*7c478bd9Sstevel@tonic-gate  * ndi event callback support routines:
418*7c478bd9Sstevel@tonic-gate  *
419*7c478bd9Sstevel@tonic-gate  * these functions require an opaque ndi event handle
420*7c478bd9Sstevel@tonic-gate  */
421*7c478bd9Sstevel@tonic-gate typedef struct ndi_event_hdl *ndi_event_hdl_t;
422*7c478bd9Sstevel@tonic-gate 
423*7c478bd9Sstevel@tonic-gate /*
424*7c478bd9Sstevel@tonic-gate  * structure for maintaining each registered callback
425*7c478bd9Sstevel@tonic-gate  */
426*7c478bd9Sstevel@tonic-gate typedef struct ndi_event_callbacks {
427*7c478bd9Sstevel@tonic-gate 	struct ndi_event_callbacks *ndi_evtcb_next;
428*7c478bd9Sstevel@tonic-gate 	struct ndi_event_callbacks *ndi_evtcb_prev;
429*7c478bd9Sstevel@tonic-gate 	dev_info_t	*ndi_evtcb_dip;
430*7c478bd9Sstevel@tonic-gate 	char		*devname; /* name of device defining this callback */
431*7c478bd9Sstevel@tonic-gate 	void		(*ndi_evtcb_callback)();
432*7c478bd9Sstevel@tonic-gate 	void		*ndi_evtcb_arg;
433*7c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	ndi_evtcb_cookie;
434*7c478bd9Sstevel@tonic-gate } ndi_event_callbacks_t;
435*7c478bd9Sstevel@tonic-gate 
436*7c478bd9Sstevel@tonic-gate /*
437*7c478bd9Sstevel@tonic-gate  * a nexus driver defines events that it can support using the
438*7c478bd9Sstevel@tonic-gate  * following structure
439*7c478bd9Sstevel@tonic-gate  */
440*7c478bd9Sstevel@tonic-gate typedef struct ndi_event_definition {
441*7c478bd9Sstevel@tonic-gate 	int			ndi_event_tag;
442*7c478bd9Sstevel@tonic-gate 	char			*ndi_event_name;
443*7c478bd9Sstevel@tonic-gate 	ddi_plevel_t		ndi_event_plevel;
444*7c478bd9Sstevel@tonic-gate 	uint_t			ndi_event_attributes;
445*7c478bd9Sstevel@tonic-gate } ndi_event_definition_t;
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate typedef struct ndi_event_cookie {
448*7c478bd9Sstevel@tonic-gate 	ndi_event_definition_t 	*definition;	/* Event Description */
449*7c478bd9Sstevel@tonic-gate 	dev_info_t		*ddip;		/* Devi defining this event */
450*7c478bd9Sstevel@tonic-gate 	ndi_event_callbacks_t	*callback_list; /* Cb's reg'd to w/ this evt */
451*7c478bd9Sstevel@tonic-gate 	struct ndi_event_cookie *next_cookie; 	/* Next cookie def'd in hdl */
452*7c478bd9Sstevel@tonic-gate } ndi_event_cookie_t;
453*7c478bd9Sstevel@tonic-gate 
454*7c478bd9Sstevel@tonic-gate 
455*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT(cookie) ((struct ndi_event_cookie *)(void *)(cookie))
456*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_NAME(cookie) (NDI_EVENT(cookie)->definition->ndi_event_name)
457*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_TAG(cookie) (NDI_EVENT(cookie)->definition->ndi_event_tag)
458*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_ATTRIBUTES(cookie) \
459*7c478bd9Sstevel@tonic-gate 	(NDI_EVENT(cookie)->definition->ndi_event_attributes)
460*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_PLEVEL(cookie) \
461*7c478bd9Sstevel@tonic-gate 	(NDI_EVENT(cookie)->definition->ndi_event_plevel)
462*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_DDIP(cookie) (NDI_EVENT(cookie)->ddip)
463*7c478bd9Sstevel@tonic-gate 
464*7c478bd9Sstevel@tonic-gate /* ndi_event_attributes */
465*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_POST_TO_ALL	0x0 /* broadcast: post to all handlers */
466*7c478bd9Sstevel@tonic-gate #define	NDI_EVENT_POST_TO_TGT	0x1 /* call only specific child's hdlr */
467*7c478bd9Sstevel@tonic-gate 
468*7c478bd9Sstevel@tonic-gate typedef struct ndi_event_set {
469*7c478bd9Sstevel@tonic-gate 	ushort_t		ndi_events_version;
470*7c478bd9Sstevel@tonic-gate 	ushort_t		ndi_n_events;
471*7c478bd9Sstevel@tonic-gate 	ndi_event_definition_t	*ndi_event_defs;
472*7c478bd9Sstevel@tonic-gate } ndi_event_set_t;
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate 
475*7c478bd9Sstevel@tonic-gate #define	NDI_EVENTS_REV0			0
476*7c478bd9Sstevel@tonic-gate #define	NDI_EVENTS_REV1			1
477*7c478bd9Sstevel@tonic-gate 
478*7c478bd9Sstevel@tonic-gate /*
479*7c478bd9Sstevel@tonic-gate  * allocate an ndi event handle
480*7c478bd9Sstevel@tonic-gate  */
481*7c478bd9Sstevel@tonic-gate int
482*7c478bd9Sstevel@tonic-gate ndi_event_alloc_hdl(dev_info_t *dip, ddi_iblock_cookie_t cookie,
483*7c478bd9Sstevel@tonic-gate 	ndi_event_hdl_t *ndi_event_hdl, uint_t flag);
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate /*
486*7c478bd9Sstevel@tonic-gate  * free the ndi event handle
487*7c478bd9Sstevel@tonic-gate  */
488*7c478bd9Sstevel@tonic-gate int
489*7c478bd9Sstevel@tonic-gate ndi_event_free_hdl(ndi_event_hdl_t handle);
490*7c478bd9Sstevel@tonic-gate 
491*7c478bd9Sstevel@tonic-gate /*
492*7c478bd9Sstevel@tonic-gate  * bind or unbind a set of events to/from the event handle
493*7c478bd9Sstevel@tonic-gate  */
494*7c478bd9Sstevel@tonic-gate int
495*7c478bd9Sstevel@tonic-gate ndi_event_bind_set(ndi_event_hdl_t	handle,
496*7c478bd9Sstevel@tonic-gate 	ndi_event_set_t		*ndi_event_set,
497*7c478bd9Sstevel@tonic-gate 	uint_t			flag);
498*7c478bd9Sstevel@tonic-gate 
499*7c478bd9Sstevel@tonic-gate int
500*7c478bd9Sstevel@tonic-gate ndi_event_unbind_set(ndi_event_hdl_t	handle,
501*7c478bd9Sstevel@tonic-gate 	ndi_event_set_t		*ndi_event_set,
502*7c478bd9Sstevel@tonic-gate 	uint_t			flag);
503*7c478bd9Sstevel@tonic-gate 
504*7c478bd9Sstevel@tonic-gate /*
505*7c478bd9Sstevel@tonic-gate  * get an event cookie
506*7c478bd9Sstevel@tonic-gate  */
507*7c478bd9Sstevel@tonic-gate int
508*7c478bd9Sstevel@tonic-gate ndi_event_retrieve_cookie(ndi_event_hdl_t 	handle,
509*7c478bd9Sstevel@tonic-gate 	dev_info_t		*child_dip,
510*7c478bd9Sstevel@tonic-gate 	char			*eventname,
511*7c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	*cookiep,
512*7c478bd9Sstevel@tonic-gate 	uint_t			flag);
513*7c478bd9Sstevel@tonic-gate 
514*7c478bd9Sstevel@tonic-gate /*
515*7c478bd9Sstevel@tonic-gate  * add an event callback info to the ndi event handle
516*7c478bd9Sstevel@tonic-gate  */
517*7c478bd9Sstevel@tonic-gate int
518*7c478bd9Sstevel@tonic-gate ndi_event_add_callback(ndi_event_hdl_t 	handle,
519*7c478bd9Sstevel@tonic-gate 	dev_info_t		*child_dip,
520*7c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	cookie,
521*7c478bd9Sstevel@tonic-gate 	void			(*event_callback)
522*7c478bd9Sstevel@tonic-gate 					(dev_info_t *,
523*7c478bd9Sstevel@tonic-gate 					ddi_eventcookie_t,
524*7c478bd9Sstevel@tonic-gate 					void *arg,
525*7c478bd9Sstevel@tonic-gate 					void *impldata),
526*7c478bd9Sstevel@tonic-gate 	void			*arg,
527*7c478bd9Sstevel@tonic-gate 	uint_t			flag,
528*7c478bd9Sstevel@tonic-gate 	ddi_callback_id_t *cb_id);
529*7c478bd9Sstevel@tonic-gate 
530*7c478bd9Sstevel@tonic-gate /*
531*7c478bd9Sstevel@tonic-gate  * remove an event callback registration from the ndi event handle
532*7c478bd9Sstevel@tonic-gate  */
533*7c478bd9Sstevel@tonic-gate int
534*7c478bd9Sstevel@tonic-gate ndi_event_remove_callback(ndi_event_hdl_t handle, ddi_callback_id_t id);
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate /*
537*7c478bd9Sstevel@tonic-gate  * perform callbacks for a specified cookie
538*7c478bd9Sstevel@tonic-gate  */
539*7c478bd9Sstevel@tonic-gate int
540*7c478bd9Sstevel@tonic-gate ndi_event_run_callbacks(ndi_event_hdl_t	handle, dev_info_t *child_dip,
541*7c478bd9Sstevel@tonic-gate     ddi_eventcookie_t cookie, void *bus_impldata);
542*7c478bd9Sstevel@tonic-gate 
543*7c478bd9Sstevel@tonic-gate /*
544*7c478bd9Sstevel@tonic-gate  * do callback for just one child_dip, regardless of attributes
545*7c478bd9Sstevel@tonic-gate  */
546*7c478bd9Sstevel@tonic-gate int ndi_event_do_callback(ndi_event_hdl_t handle, dev_info_t *child_dip,
547*7c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t cookie, void *bus_impldata);
548*7c478bd9Sstevel@tonic-gate 
549*7c478bd9Sstevel@tonic-gate /*
550*7c478bd9Sstevel@tonic-gate  * ndi_event_tag_to_cookie: utility function to find an event cookie
551*7c478bd9Sstevel@tonic-gate  * given an event tag
552*7c478bd9Sstevel@tonic-gate  */
553*7c478bd9Sstevel@tonic-gate ddi_eventcookie_t
554*7c478bd9Sstevel@tonic-gate ndi_event_tag_to_cookie(ndi_event_hdl_t handle, int event_tag);
555*7c478bd9Sstevel@tonic-gate 
556*7c478bd9Sstevel@tonic-gate /*
557*7c478bd9Sstevel@tonic-gate  * ndi_event_cookie_to_tag: utility function to find an event tag
558*7c478bd9Sstevel@tonic-gate  * given an event_cookie
559*7c478bd9Sstevel@tonic-gate  */
560*7c478bd9Sstevel@tonic-gate int
561*7c478bd9Sstevel@tonic-gate ndi_event_cookie_to_tag(ndi_event_hdl_t handle,
562*7c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t cookie);
563*7c478bd9Sstevel@tonic-gate 
564*7c478bd9Sstevel@tonic-gate /*
565*7c478bd9Sstevel@tonic-gate  * ndi_event_cookie_to_name: utility function to find an event
566*7c478bd9Sstevel@tonic-gate  * name given an event_cookie
567*7c478bd9Sstevel@tonic-gate  */
568*7c478bd9Sstevel@tonic-gate char *
569*7c478bd9Sstevel@tonic-gate ndi_event_cookie_to_name(ndi_event_hdl_t handle,
570*7c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t cookie);
571*7c478bd9Sstevel@tonic-gate 
572*7c478bd9Sstevel@tonic-gate /*
573*7c478bd9Sstevel@tonic-gate  * ndi_event_tag_to_name: utility function to find an event
574*7c478bd9Sstevel@tonic-gate  * name given an event_tag
575*7c478bd9Sstevel@tonic-gate  */
576*7c478bd9Sstevel@tonic-gate char *
577*7c478bd9Sstevel@tonic-gate ndi_event_tag_to_name(ndi_event_hdl_t 	handle, int event_tag);
578*7c478bd9Sstevel@tonic-gate 
579*7c478bd9Sstevel@tonic-gate dev_info_t *
580*7c478bd9Sstevel@tonic-gate ndi_devi_config_vhci(char *, int);
581*7c478bd9Sstevel@tonic-gate 
582*7c478bd9Sstevel@tonic-gate #ifdef DEBUG
583*7c478bd9Sstevel@tonic-gate /*
584*7c478bd9Sstevel@tonic-gate  * ndi_event_dump_hdl: debug functionality used to display event handle
585*7c478bd9Sstevel@tonic-gate  */
586*7c478bd9Sstevel@tonic-gate void
587*7c478bd9Sstevel@tonic-gate ndi_event_dump_hdl(struct ndi_event_hdl *hdl, char *location);
588*7c478bd9Sstevel@tonic-gate #endif
589*7c478bd9Sstevel@tonic-gate 
590*7c478bd9Sstevel@tonic-gate /*
591*7c478bd9Sstevel@tonic-gate  * Default busop bus_config helper functions
592*7c478bd9Sstevel@tonic-gate  */
593*7c478bd9Sstevel@tonic-gate int
594*7c478bd9Sstevel@tonic-gate ndi_busop_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op,
595*7c478bd9Sstevel@tonic-gate     void *arg, dev_info_t **child, clock_t reset_delay);
596*7c478bd9Sstevel@tonic-gate 
597*7c478bd9Sstevel@tonic-gate int
598*7c478bd9Sstevel@tonic-gate ndi_busop_bus_unconfig(dev_info_t *dip, uint_t flags, ddi_bus_config_op_t op,
599*7c478bd9Sstevel@tonic-gate     void *arg);
600*7c478bd9Sstevel@tonic-gate 
601*7c478bd9Sstevel@tonic-gate 
602*7c478bd9Sstevel@tonic-gate /*
603*7c478bd9Sstevel@tonic-gate  * Bus Resource allocation structures and function prototypes exported
604*7c478bd9Sstevel@tonic-gate  * by busra module
605*7c478bd9Sstevel@tonic-gate  */
606*7c478bd9Sstevel@tonic-gate 
607*7c478bd9Sstevel@tonic-gate /* structure for specifying a request */
608*7c478bd9Sstevel@tonic-gate typedef struct ndi_ra_request {
609*7c478bd9Sstevel@tonic-gate 	uint_t		ra_flags;	/* General flags		*/
610*7c478bd9Sstevel@tonic-gate 					/* see bit definitions below	*/
611*7c478bd9Sstevel@tonic-gate 
612*7c478bd9Sstevel@tonic-gate 	uint64_t	ra_len;		/* Requested allocation length	*/
613*7c478bd9Sstevel@tonic-gate 
614*7c478bd9Sstevel@tonic-gate 	uint64_t	ra_addr;	/* Specific base address requested */
615*7c478bd9Sstevel@tonic-gate 
616*7c478bd9Sstevel@tonic-gate 	uint64_t	ra_boundbase;	/* Base address of the area for	*/
617*7c478bd9Sstevel@tonic-gate 					/* the allocated resource to be	*/
618*7c478bd9Sstevel@tonic-gate 					/* restricted to		*/
619*7c478bd9Sstevel@tonic-gate 
620*7c478bd9Sstevel@tonic-gate 	uint64_t	ra_boundlen;	/* Length of the area, starting	*/
621*7c478bd9Sstevel@tonic-gate 					/* from ra_boundbase, for the 	*/
622*7c478bd9Sstevel@tonic-gate 					/* allocated resource to be	*/
623*7c478bd9Sstevel@tonic-gate 					/* restricted to.    		*/
624*7c478bd9Sstevel@tonic-gate 
625*7c478bd9Sstevel@tonic-gate 	uint64_t	ra_align_mask;	/* Alignment mask used for	*/
626*7c478bd9Sstevel@tonic-gate 					/* allocated base address	*/
627*7c478bd9Sstevel@tonic-gate } ndi_ra_request_t;
628*7c478bd9Sstevel@tonic-gate 
629*7c478bd9Sstevel@tonic-gate 
630*7c478bd9Sstevel@tonic-gate /* ra_flags bit definitions */
631*7c478bd9Sstevel@tonic-gate #define	NDI_RA_ALIGN_SIZE	0x0001	/* Set the alignment of the	*/
632*7c478bd9Sstevel@tonic-gate 					/* allocated resource address	*/
633*7c478bd9Sstevel@tonic-gate 					/* according to the ra_len	*/
634*7c478bd9Sstevel@tonic-gate 					/* value (alignment mask will	*/
635*7c478bd9Sstevel@tonic-gate 					/* be (ra_len - 1)). Value of	*/
636*7c478bd9Sstevel@tonic-gate 					/* ra_len has to be power of 2.	*/
637*7c478bd9Sstevel@tonic-gate 					/* If this flag is set, value of */
638*7c478bd9Sstevel@tonic-gate 					/* ra_align_mask will be ignored. */
639*7c478bd9Sstevel@tonic-gate 
640*7c478bd9Sstevel@tonic-gate 
641*7c478bd9Sstevel@tonic-gate #define	NDI_RA_ALLOC_BOUNDED	0x0002	/* Indicates that the resource	*/
642*7c478bd9Sstevel@tonic-gate 					/* should be restricted to the	*/
643*7c478bd9Sstevel@tonic-gate 					/* area specified by ra_boundbase */
644*7c478bd9Sstevel@tonic-gate 					/* and ra_boundlen */
645*7c478bd9Sstevel@tonic-gate 
646*7c478bd9Sstevel@tonic-gate #define	NDI_RA_ALLOC_SPECIFIED	0x0004	/* Indicates that a specific	*/
647*7c478bd9Sstevel@tonic-gate 					/* address (ra_addr value) is	*/
648*7c478bd9Sstevel@tonic-gate 					/* requested.			*/
649*7c478bd9Sstevel@tonic-gate 
650*7c478bd9Sstevel@tonic-gate #define	NDI_RA_ALLOC_PARTIAL_OK	0x0008  /* Indicates if requested size	*/
651*7c478bd9Sstevel@tonic-gate 					/* (ra_len) chunk is not available */
652*7c478bd9Sstevel@tonic-gate 					/* then allocate as big chunk as */
653*7c478bd9Sstevel@tonic-gate 					/* possible which is less than or */
654*7c478bd9Sstevel@tonic-gate 					/* equal to ra_len size. */
655*7c478bd9Sstevel@tonic-gate 
656*7c478bd9Sstevel@tonic-gate 
657*7c478bd9Sstevel@tonic-gate /* return values specific to bus resource allocator */
658*7c478bd9Sstevel@tonic-gate #define	NDI_RA_PARTIAL_REQ		-7
659*7c478bd9Sstevel@tonic-gate 
660*7c478bd9Sstevel@tonic-gate 
661*7c478bd9Sstevel@tonic-gate 
662*7c478bd9Sstevel@tonic-gate 
663*7c478bd9Sstevel@tonic-gate /* Predefined types for generic type of resources */
664*7c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_MEM			"memory"
665*7c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_IO			"io"
666*7c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_PCI_BUSNUM		"pci_bus_number"
667*7c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_PCI_PREFETCH_MEM	"pci_prefetchable_memory"
668*7c478bd9Sstevel@tonic-gate #define	NDI_RA_TYPE_INTR		"interrupt"
669*7c478bd9Sstevel@tonic-gate 
670*7c478bd9Sstevel@tonic-gate 
671*7c478bd9Sstevel@tonic-gate 
672*7c478bd9Sstevel@tonic-gate /* flag bit definition */
673*7c478bd9Sstevel@tonic-gate #define	NDI_RA_PASS	0x0001		/* pass request up the dev tree */
674*7c478bd9Sstevel@tonic-gate 
675*7c478bd9Sstevel@tonic-gate 
676*7c478bd9Sstevel@tonic-gate /*
677*7c478bd9Sstevel@tonic-gate  * Prototype definitions for functions exported
678*7c478bd9Sstevel@tonic-gate  */
679*7c478bd9Sstevel@tonic-gate 
680*7c478bd9Sstevel@tonic-gate int
681*7c478bd9Sstevel@tonic-gate ndi_ra_map_setup(dev_info_t *dip, char *type);
682*7c478bd9Sstevel@tonic-gate 
683*7c478bd9Sstevel@tonic-gate int
684*7c478bd9Sstevel@tonic-gate ndi_ra_map_destroy(dev_info_t *dip, char *type);
685*7c478bd9Sstevel@tonic-gate 
686*7c478bd9Sstevel@tonic-gate int
687*7c478bd9Sstevel@tonic-gate ndi_ra_alloc(dev_info_t *dip, ndi_ra_request_t *req, uint64_t *basep,
688*7c478bd9Sstevel@tonic-gate 	uint64_t *lenp, char *type, uint_t flag);
689*7c478bd9Sstevel@tonic-gate 
690*7c478bd9Sstevel@tonic-gate int
691*7c478bd9Sstevel@tonic-gate ndi_ra_free(dev_info_t *dip, uint64_t base, uint64_t len, char *type,
692*7c478bd9Sstevel@tonic-gate 	uint_t flag);
693*7c478bd9Sstevel@tonic-gate 
694*7c478bd9Sstevel@tonic-gate 
695*7c478bd9Sstevel@tonic-gate /*
696*7c478bd9Sstevel@tonic-gate  * ndi_dev_is_prom_node: Return non-zero if the node is a prom node
697*7c478bd9Sstevel@tonic-gate  */
698*7c478bd9Sstevel@tonic-gate int ndi_dev_is_prom_node(dev_info_t *);
699*7c478bd9Sstevel@tonic-gate 
700*7c478bd9Sstevel@tonic-gate /*
701*7c478bd9Sstevel@tonic-gate  * ndi_dev_is_pseudo_node: Return non-zero if the node is a pseudo node.
702*7c478bd9Sstevel@tonic-gate  * NB: all non-prom nodes are pseudo nodes.
703*7c478bd9Sstevel@tonic-gate  * c.f. ndi_dev_is_persistent_node
704*7c478bd9Sstevel@tonic-gate  */
705*7c478bd9Sstevel@tonic-gate int ndi_dev_is_pseudo_node(dev_info_t *);
706*7c478bd9Sstevel@tonic-gate 
707*7c478bd9Sstevel@tonic-gate /*
708*7c478bd9Sstevel@tonic-gate  * ndi_dev_is_persistent_node: Return non-zero if the node has the
709*7c478bd9Sstevel@tonic-gate  * property of persistence.
710*7c478bd9Sstevel@tonic-gate  */
711*7c478bd9Sstevel@tonic-gate int ndi_dev_is_persistent_node(dev_info_t *);
712*7c478bd9Sstevel@tonic-gate 
713*7c478bd9Sstevel@tonic-gate /*
714*7c478bd9Sstevel@tonic-gate  * Event posted when a fault is reported
715*7c478bd9Sstevel@tonic-gate  */
716*7c478bd9Sstevel@tonic-gate #define	DDI_DEVI_FAULT_EVENT	"DDI:DEVI_FAULT"
717*7c478bd9Sstevel@tonic-gate 
718*7c478bd9Sstevel@tonic-gate struct ddi_fault_event_data {
719*7c478bd9Sstevel@tonic-gate 	dev_info_t		*f_dip;
720*7c478bd9Sstevel@tonic-gate 	ddi_fault_impact_t	f_impact;
721*7c478bd9Sstevel@tonic-gate 	ddi_fault_location_t	f_location;
722*7c478bd9Sstevel@tonic-gate 	const char		*f_message;
723*7c478bd9Sstevel@tonic-gate 	ddi_devstate_t		f_oldstate;
724*7c478bd9Sstevel@tonic-gate };
725*7c478bd9Sstevel@tonic-gate 
726*7c478bd9Sstevel@tonic-gate /*
727*7c478bd9Sstevel@tonic-gate  * Access handle/DMA handle fault flag setting/clearing functions for nexi
728*7c478bd9Sstevel@tonic-gate  */
729*7c478bd9Sstevel@tonic-gate void ndi_set_acc_fault(ddi_acc_handle_t ah);
730*7c478bd9Sstevel@tonic-gate void ndi_clr_acc_fault(ddi_acc_handle_t ah);
731*7c478bd9Sstevel@tonic-gate void ndi_set_dma_fault(ddi_dma_handle_t dh);
732*7c478bd9Sstevel@tonic-gate void ndi_clr_dma_fault(ddi_dma_handle_t dh);
733*7c478bd9Sstevel@tonic-gate 
734*7c478bd9Sstevel@tonic-gate /* Driver.conf property merging */
735*7c478bd9Sstevel@tonic-gate int ndi_merge_node(dev_info_t *, int (*)(dev_info_t *, char *, int));
736*7c478bd9Sstevel@tonic-gate void ndi_merge_wildcard_node(dev_info_t *);
737*7c478bd9Sstevel@tonic-gate 
738*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
739*7c478bd9Sstevel@tonic-gate 
740*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
741*7c478bd9Sstevel@tonic-gate }
742*7c478bd9Sstevel@tonic-gate #endif
743*7c478bd9Sstevel@tonic-gate 
744*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_SUNNDI_H */
745