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