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