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.
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.
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]
22 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_ESUNDDI_H
27 #define _SYS_ESUNDDI_H
28 #include <sys/sunddi.h>
30 #include <sys/autoconf.h>
31 #include <sys/ddi_impldefs.h>
41 * esunddi.h: Function prototypes for kernel ddi functions.
42 * Note that drivers calling these functions are not
47 e_ddi_prop_create(dev_t dev
, dev_info_t
*dip
, int flag
,
48 char *name
, caddr_t value
, int length
);
51 e_ddi_prop_modify(dev_t dev
, dev_info_t
*dip
, int flag
,
52 char *name
, caddr_t value
, int length
);
55 e_ddi_prop_update_int(dev_t match_dev
, dev_info_t
*dip
,
56 char *name
, int data
);
59 e_ddi_prop_update_int64(dev_t match_dev
, dev_info_t
*dip
,
60 char *name
, int64_t data
);
63 e_ddi_prop_update_int_array(dev_t match_dev
, dev_info_t
*dip
,
64 char *name
, int *data
, uint_t nelements
);
67 e_ddi_prop_update_int64_array(dev_t match_dev
, dev_info_t
*dip
,
68 char *name
, int64_t *data
, uint_t nelements
);
71 e_ddi_prop_update_string(dev_t match_dev
, dev_info_t
*dip
,
72 char *name
, char *data
);
75 e_ddi_prop_update_string_array(dev_t match_dev
, dev_info_t
*dip
,
76 char *name
, char **data
, uint_t nelements
);
79 e_ddi_prop_update_byte_array(dev_t match_dev
, dev_info_t
*dip
,
80 char *name
, uchar_t
*data
, uint_t nelements
);
83 e_ddi_prop_remove(dev_t dev
, dev_info_t
*dip
, char *name
);
86 e_ddi_prop_remove_all(dev_info_t
*dip
);
89 e_ddi_prop_undefine(dev_t dev
, dev_info_t
*dip
, int flag
, char *name
);
92 e_ddi_getprop(dev_t dev
, vtype_t type
, char *name
, int flags
, int defaultval
);
95 e_ddi_getprop_int64(dev_t dev
, vtype_t type
, char *name
,
96 int flags
, int64_t defvalue
);
99 e_ddi_getproplen(dev_t dev
, vtype_t type
, char *name
, int flags
, int *lengthp
);
102 e_ddi_getlongprop(dev_t dev
, vtype_t type
, char *name
, int flags
,
103 caddr_t valuep
, int *lengthp
);
106 e_ddi_getlongprop_buf(dev_t dev
, vtype_t type
, char *name
, int flags
,
107 caddr_t valuep
, int *lengthp
);
110 e_ddi_parental_suspend_resume(dev_info_t
*dip
);
113 e_ddi_resume(dev_info_t
*dip
, ddi_attach_cmd_t
);
116 e_ddi_suspend(dev_info_t
*dip
, ddi_detach_cmd_t cmd
);
122 e_ddi_prop_list_delete(ddi_prop_t
*proplist
);
125 e_ddi_copyfromdev(dev_info_t
*, off_t
, const void *, void *, size_t);
128 e_ddi_copytodev(dev_info_t
*, off_t
, const void *, void *, size_t);
131 * return codes for devi_stillreferenced()
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
136 #define DEVI_REFERENCED 1
137 #define DEVI_NOT_REFERENCED 0
140 devi_stillreferenced(dev_info_t
*dip
);
142 extern int (*pm_platform_power
)(power_req_t
*);
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.
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.
160 umem_lockmemory(caddr_t addr
, size_t size
, int flags
,
161 ddi_umem_cookie_t
*cookie
,
162 struct umem_callback_ops
*ops_vector
,
165 #define DDI_UMEMLOCK_LONGTERM 0x04
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
173 e_ddi_hold_devi_by_dev(dev_t dev
, int flags
);
176 e_ddi_hold_devi_by_path(char *path
, int flags
);
178 /* {e_}ddi_hold_devi{_by{instance|dev|path}} flags */
179 #define E_DDI_HOLD_DEVI_NOATTACH 0x01
182 e_ddi_hold_devi(dev_info_t
*);
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.
189 e_ddi_devi_holdcnt(dev_info_t
*dip
);
192 * Perform path reconstruction given a major and instance. Does not
193 * drive attach of the path.
196 e_ddi_majorinstance_to_path(major_t major
, int instance
, char *name
);
199 * walk all devinfo nodes linked on the driver list
202 e_ddi_walk_driver(char *, int (*f
)(dev_info_t
*, void *), void *);
205 * Given the nodeid for a persistent node, find the corresponding
207 * NOTE: .conf nodeids are not valid arguments to this function.
210 e_ddi_nodeid_to_dip(pnode_t nodeid
);
213 * Defines for DR interfaces
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 */
223 typedef struct devi_branch
{
225 void (*devi_branch_callback
)(dev_info_t
*, void *, uint_t
);
228 int (*prom_branch_select
)(pnode_t
, void *, uint_t
);
229 int (*sid_branch_create
)(dev_info_t
*, void *, uint_t
);
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
,
237 extern int e_ddi_branch_unconfigure(dev_info_t
*rdip
, dev_info_t
**dipp
,
239 extern int e_ddi_branch_destroy(dev_info_t
*rdip
, dev_info_t
**dipp
,
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
);
248 * Obsolete interfaces, no longer used, to be removed.
249 * Retained only for driver compatibility.
252 e_ddi_enter_driver_list(struct devnames
*, int *); /* obsolete */
255 e_ddi_tryenter_driver_list(struct devnames
*, int *); /* obsolete */
258 e_ddi_exit_driver_list(struct devnames
*, int); /* obsolete */
267 #endif /* _SYS_ESUNDDI_H */