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