xref: /illumos-gate/usr/src/uts/common/sys/ndi_impldefs.h (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_NDI_IMPLDEFS_H
27 #define	_SYS_NDI_IMPLDEFS_H
28 
29 #include <sys/types.h>
30 #include <sys/param.h>
31 #include <sys/t_lock.h>
32 #include <sys/ddipropdefs.h>
33 #include <sys/devops.h>
34 #include <sys/autoconf.h>
35 #include <sys/mutex.h>
36 #include <vm/page.h>
37 #include <sys/ddi_impldefs.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /* event handle for callback management */
44 struct ndi_event_hdl {
45 	dev_info_t		*ndi_evthdl_dip;
46 
47 	/*
48 	 * mutex that protect the handle and event defs
49 	 */
50 	kmutex_t		ndi_evthdl_mutex;
51 
52 	/*
53 	 * mutex that just protects the callback list
54 	 */
55 	kmutex_t		ndi_evthdl_cb_mutex;
56 
57 	ddi_iblock_cookie_t	ndi_evthdl_iblock_cookie;
58 
59 	uint_t			ndi_evthdl_high_plevels;
60 	uint_t			ndi_evthdl_other_plevels;
61 
62 	uint_t			ndi_evthdl_n_events;
63 	ndi_event_cookie_t 	*ndi_evthdl_cookie_list;
64 	ndi_event_hdl_t 	ndi_next_hdl;
65 };
66 
67 /* prototypes needed by sunndi.c */
68 int ddi_prop_fm_encode_bytes(prop_handle_t *, void *data, uint_t);
69 
70 int ddi_prop_fm_encode_ints(prop_handle_t *, void *data, uint_t);
71 
72 int ddi_prop_fm_encode_int64(prop_handle_t *, void *data, uint_t);
73 
74 int ddi_prop_int64_op(prop_handle_t *, uint_t, int64_t *);
75 
76 int ddi_prop_update_common(dev_t, dev_info_t *, int, char *, void *, uint_t,
77     int (*)(prop_handle_t *, void *, uint_t));
78 
79 int ddi_prop_lookup_common(dev_t, dev_info_t *, uint_t, char *, void *,
80     uint_t *, int (*)(prop_handle_t *, void *, uint_t *));
81 
82 int ddi_prop_remove_common(dev_t, dev_info_t *, char *, int);
83 void ddi_prop_remove_all_common(dev_info_t *, int);
84 
85 int ddi_prop_fm_encode_string(prop_handle_t *, void *, uint_t);
86 
87 int ddi_prop_fm_encode_strings(prop_handle_t *, void *, uint_t);
88 int ddi_prop_fm_decode_strings(prop_handle_t *, void *, uint_t *);
89 
90 /*
91  * Internal configuration routines
92  */
93 int i_ndi_config_node(dev_info_t *, ddi_node_state_t, uint_t);
94 int i_ndi_unconfig_node(dev_info_t *, ddi_node_state_t, uint_t);
95 
96 /*
97  * Obsolete interface, no longer used, to be removed.
98  * Retained only for driver compatibility.
99  */
100 void i_ndi_block_device_tree_changes(uint_t *);		/* obsolete */
101 void i_ndi_allow_device_tree_changes(uint_t);		/* obsolete */
102 
103 /*
104  * ndi_dev_is_auto_assigned_node: Return non-zero if the nodeid in dev
105  * has been auto-assigned by the framework and should be auto-freed.
106  * (Intended for use by the framework only.)
107  */
108 int i_ndi_dev_is_auto_assigned_node(dev_info_t *);
109 
110 /*
111  * Get and set nodeclass and node attributes.
112  * (Intended for ddi framework use only.)
113  */
114 ddi_node_class_t i_ndi_get_node_class(dev_info_t *);
115 void i_ndi_set_node_class(dev_info_t *, ddi_node_class_t);
116 
117 int i_ndi_get_node_attributes(dev_info_t *);
118 void i_ndi_set_node_attributes(dev_info_t *, int);
119 
120 /*
121  * Set nodeid .. not generally advisable.
122  * (Intended for the ddi framework use only.)
123  */
124 void i_ndi_set_nodeid(dev_info_t *, int);
125 
126 /*
127  * Make driver.conf children.
128  * (Intended for the ddi framework use only.)
129  */
130 int i_ndi_make_spec_children(dev_info_t *, uint_t);
131 
132 #ifdef	__cplusplus
133 }
134 #endif
135 
136 #endif	/* _SYS_NDI_IMPLDEFS_H */
137