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