xref: /titanic_41/usr/src/uts/common/sys/esunddi.h (revision b509e89b2befbaa42939abad9da1d7f5a8c6aaae)
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_ESUNDDI_H
28 #define	_SYS_ESUNDDI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 */
31 
32 #include <sys/sunddi.h>
33 #include <sys/proc.h>
34 #include <sys/autoconf.h>
35 #include <sys/ddi_impldefs.h>
36 #include <sys/epm.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #ifdef	_KERNEL
43 
44 /*
45  * esunddi.h:		Function prototypes for kernel ddi functions.
46  *	Note that drivers calling these functions are not
47  *	portable.
48  */
49 
50 int
51 e_ddi_prop_create(dev_t dev, dev_info_t *dip, int flag,
52 	char *name, caddr_t value, int length);
53 
54 int
55 e_ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag,
56 	char *name, caddr_t value, int length);
57 
58 int
59 e_ddi_prop_update_int(dev_t match_dev, dev_info_t *dip,
60 	char *name, int data);
61 
62 int
63 e_ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip,
64     char *name, int64_t data);
65 
66 int
67 e_ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip,
68     char *name, int *data, uint_t nelements);
69 
70 int
71 e_ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip,
72     char *name, int64_t *data, uint_t nelements);
73 
74 int
75 e_ddi_prop_update_string(dev_t match_dev, dev_info_t *dip,
76 	char *name, char *data);
77 
78 int
79 e_ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
80     char *name, char **data, uint_t nelements);
81 
82 int
83 e_ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
84     char *name, uchar_t *data, uint_t nelements);
85 
86 int
87 e_ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
88 
89 void
90 e_ddi_prop_remove_all(dev_info_t *dip);
91 
92 int
93 e_ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name);
94 
95 int
96 e_ddi_getprop(dev_t dev, vtype_t type, char *name, int flags, int defaultval);
97 
98 int64_t
99 e_ddi_getprop_int64(dev_t dev, vtype_t type, char *name,
100 	int flags, int64_t defvalue);
101 
102 int
103 e_ddi_getproplen(dev_t dev, vtype_t type, char *name, int flags, int *lengthp);
104 
105 int
106 e_ddi_getlongprop(dev_t dev, vtype_t type, char *name, int flags,
107 	caddr_t valuep, int *lengthp);
108 
109 int
110 e_ddi_getlongprop_buf(dev_t dev, vtype_t type, char *name, int flags,
111 	caddr_t valuep, int *lengthp);
112 
113 int
114 e_ddi_parental_suspend_resume(dev_info_t *dip);
115 
116 int
117 e_ddi_resume(dev_info_t *dip, ddi_attach_cmd_t);
118 
119 int
120 e_ddi_suspend(dev_info_t *dip, ddi_detach_cmd_t cmd);
121 
122 void
123 pm_init(void);
124 
125 void
126 e_ddi_prop_list_delete(ddi_prop_t *proplist);
127 
128 int
129 e_ddi_copyfromdev(dev_info_t *, off_t, const void *, void *, size_t);
130 
131 int
132 e_ddi_copytodev(dev_info_t *, off_t, const void *, void *, size_t);
133 
134 /*
135  * return codes for devi_stillreferenced()
136  *
137  * DEVI_REFERENCED	- specfs has open minor device(s) for the devinfo
138  * DEVI_NOT_REFERENCED	- specfs has no open minor device for the devinfo
139  */
140 #define	DEVI_REFERENCED		1
141 #define	DEVI_NOT_REFERENCED	0
142 
143 int
144 devi_stillreferenced(dev_info_t *dip);
145 
146 extern int (*pm_platform_power)(power_req_t *);
147 
148 /*
149  * A consolidation private function which is essentially equivalent to
150  * ddi_umem_lock but with the addition of arguments ops_vector and procp.
151  * The procp argument can be eliminated eventually as part of proper
152  * dynamic reconfiguration callback implementation.
153  *
154  * The valid flag values are those used for ddi_umem_lock plus an
155  * additional flag (DDI_UMEMLOCK_LONGTERM) which must be set when the
156  * locking will be maintained for an indefinitely long period (essentially
157  * permanent), rather than for what would be required for a typical I/O
158  * completion.  When DDI_UMEMLOCK_LONGTERM is set, umem_lockmemory will
159  * return EFAULT if the memory pertains to a regular file which is
160  * mapped MAP_SHARED.  This is to prevent a deadlock in the pvn routines
161  * if a file truncation is attempted after the locking is done.
162  */
163 int
164 umem_lockmemory(caddr_t addr, size_t size, int flags,
165 		ddi_umem_cookie_t *cookie,
166 		struct umem_callback_ops *ops_vector,
167 		proc_t *procp);
168 
169 #define	DDI_UMEMLOCK_LONGTERM	0x04
170 
171 /*
172  * These are evolving forms of the ddi function ddi_hold_devi_by_instance.
173  * Like ddi_hold_devi_by_instance, the hold should be released with
174  * ddi_release_devi.
175  */
176 dev_info_t	*
177 e_ddi_hold_devi_by_dev(dev_t dev, int flags);
178 
179 dev_info_t	*
180 e_ddi_hold_devi_by_path(char *path, int flags);
181 
182 /* {e_}ddi_hold_devi{_by{instance|dev|path}} flags */
183 #define	E_DDI_HOLD_DEVI_NOATTACH	0x01
184 
185 void
186 e_ddi_hold_devi(dev_info_t *);
187 
188 /*
189  * Return the reference count on a devinfo node. The caller can determine,
190  * with knowledge of his own holds, if the devinfo node is still in use.
191  */
192 int
193 e_ddi_devi_holdcnt(dev_info_t *dip);
194 
195 /*
196  * Perform path reconstruction given a major and instance. Does not
197  * drive attach of the path.
198  */
199 int
200 e_ddi_majorinstance_to_path(major_t major, int instance, char *name);
201 
202 /*
203  * walk all devinfo nodes linked on the driver list
204  */
205 void
206 e_ddi_walk_driver(char *, int (*f)(dev_info_t *, void *), void *);
207 
208 /*
209  * Given the nodeid for a persistent node, find the corresponding
210  * devinfo node.
211  * NOTE: .conf nodeids are not valid arguments to this function.
212  */
213 dev_info_t *
214 e_ddi_nodeid_to_dip(pnode_t nodeid);
215 
216 /*
217  * Obsolete interfaces, no longer used, to be removed.
218  * Retained only for driver compatibility.
219  */
220 void
221 e_ddi_enter_driver_list(struct devnames *, int *);	/* obsolete */
222 
223 int
224 e_ddi_tryenter_driver_list(struct devnames *, int *);	/* obsolete */
225 
226 void
227 e_ddi_exit_driver_list(struct devnames *, int);		/* obsolete */
228 
229 
230 #endif	/* _KERNEL */
231 
232 #ifdef	__cplusplus
233 }
234 #endif
235 
236 #endif /* _SYS_ESUNDDI_H */
237