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.
24 * Copyright (c) 2016 by Delphix. All rights reserved.
27 #ifndef _SYS_ESUNDDI_H
28 #define _SYS_ESUNDDI_H
29 #include <sys/sunddi.h>
31 #include <sys/autoconf.h>
32 #include <sys/ddi_impldefs.h>
42 * esunddi.h: Function prototypes for kernel ddi functions.
43 * Note that drivers calling these functions are not
48 e_ddi_prop_create(dev_t dev
, dev_info_t
*dip
, int flag
,
49 char *name
, caddr_t value
, int length
);
52 e_ddi_prop_modify(dev_t dev
, dev_info_t
*dip
, int flag
,
53 char *name
, caddr_t value
, int length
);
56 e_ddi_prop_update_int(dev_t match_dev
, dev_info_t
*dip
,
57 char *name
, int data
);
60 e_ddi_prop_update_int64(dev_t match_dev
, dev_info_t
*dip
,
61 char *name
, int64_t data
);
64 e_ddi_prop_update_int_array(dev_t match_dev
, dev_info_t
*dip
,
65 char *name
, int *data
, uint_t nelements
);
68 e_ddi_prop_update_int64_array(dev_t match_dev
, dev_info_t
*dip
,
69 char *name
, int64_t *data
, uint_t nelements
);
72 e_ddi_prop_update_string(dev_t match_dev
, dev_info_t
*dip
,
73 char *name
, char *data
);
76 e_ddi_prop_update_string_array(dev_t match_dev
, dev_info_t
*dip
,
77 char *name
, char **data
, uint_t nelements
);
80 e_ddi_prop_update_byte_array(dev_t match_dev
, dev_info_t
*dip
,
81 char *name
, uchar_t
*data
, uint_t nelements
);
84 e_ddi_prop_remove(dev_t dev
, dev_info_t
*dip
, char *name
);
87 e_ddi_prop_remove_all(dev_info_t
*dip
);
90 e_ddi_prop_undefine(dev_t dev
, dev_info_t
*dip
, int flag
, char *name
);
93 e_ddi_getprop(dev_t dev
, vtype_t type
, char *name
, int flags
, int defaultval
);
96 e_ddi_getprop_int64(dev_t dev
, vtype_t type
, char *name
,
97 int flags
, int64_t defvalue
);
100 e_ddi_getproplen(dev_t dev
, vtype_t type
, char *name
, int flags
, int *lengthp
);
103 e_ddi_getlongprop(dev_t dev
, vtype_t type
, char *name
, int flags
,
104 caddr_t valuep
, int *lengthp
);
107 e_ddi_getlongprop_buf(dev_t dev
, vtype_t type
, char *name
, int flags
,
108 caddr_t valuep
, int *lengthp
);
111 e_ddi_parental_suspend_resume(dev_info_t
*dip
);
114 e_ddi_resume(dev_info_t
*dip
, ddi_attach_cmd_t
);
117 e_ddi_suspend(dev_info_t
*dip
, ddi_detach_cmd_t cmd
);
123 e_ddi_prop_list_delete(ddi_prop_t
*proplist
);
126 e_ddi_copyfromdev(dev_info_t
*, off_t
, const void *, void *, size_t);
129 e_ddi_copytodev(dev_info_t
*, off_t
, const void *, void *, size_t);
132 * return codes for devi_stillreferenced()
134 * DEVI_REFERENCED - specfs has open minor device(s) for the devinfo
135 * DEVI_NOT_REFERENCED - specfs has no open minor device for the devinfo
137 #define DEVI_REFERENCED 1
138 #define DEVI_NOT_REFERENCED 0
141 devi_stillreferenced(dev_info_t
*dip
);
143 extern int (*pm_platform_power
)(power_req_t
*);
146 * A consolidation private function which is essentially equivalent to
147 * ddi_umem_lock but with the addition of arguments ops_vector and procp.
148 * The procp argument can be eliminated eventually as part of proper
149 * dynamic reconfiguration callback implementation.
151 * The valid flag values are those used for ddi_umem_lock plus an
152 * additional flag (DDI_UMEMLOCK_LONGTERM) which must be set when the
153 * locking will be maintained for an indefinitely long period (essentially
154 * permanent), rather than for what would be required for a typical I/O
155 * completion. When DDI_UMEMLOCK_LONGTERM is set, umem_lockmemory will
156 * return EFAULT if the memory pertains to a regular file which is
157 * mapped MAP_SHARED. This is to prevent a deadlock in the pvn routines
158 * if a file truncation is attempted after the locking is done.
161 umem_lockmemory(caddr_t addr
, size_t size
, int flags
,
162 ddi_umem_cookie_t
*cookie
,
163 struct umem_callback_ops
*ops_vector
,
166 #define DDI_UMEMLOCK_LONGTERM 0x04
169 * These are evolving forms of the ddi function ddi_hold_devi_by_instance.
170 * Like ddi_hold_devi_by_instance, the hold should be released with
174 e_ddi_hold_devi_by_dev(dev_t dev
, int flags
);
177 e_ddi_hold_devi_by_path(char *path
, int flags
);
179 /* {e_}ddi_hold_devi{_by{instance|dev|path}} flags */
180 #define E_DDI_HOLD_DEVI_NOATTACH 0x01
183 e_ddi_hold_devi(dev_info_t
*);
186 * Return the reference count on a devinfo node. The caller can determine,
187 * with knowledge of its own holds, if the devinfo node is still in use.
190 e_ddi_devi_holdcnt(dev_info_t
*dip
);
193 * Perform path reconstruction given a major and instance. Does not
194 * drive attach of the path.
197 e_ddi_majorinstance_to_path(major_t major
, int instance
, char *name
);
200 * walk all devinfo nodes linked on the driver list
203 e_ddi_walk_driver(char *, int (*f
)(dev_info_t
*, void *), void *);
206 * Given the nodeid for a persistent node, find the corresponding
208 * NOTE: .conf nodeids are not valid arguments to this function.
211 e_ddi_nodeid_to_dip(pnode_t nodeid
);
214 * Defines for DR interfaces
216 #define DEVI_BRANCH_CHILD 0x01 /* Walk immediate children of root */
217 #define DEVI_BRANCH_CONFIGURE 0x02 /* Configure branch after create */
218 #define DEVI_BRANCH_DESTROY 0x04 /* Destroy branch after unconfigure */
219 #define DEVI_BRANCH_EVENT 0x08 /* Post NDI event */
220 #define DEVI_BRANCH_PROM 0x10 /* Branches derived from PROM nodes */
221 #define DEVI_BRANCH_SID 0x20 /* SID node branches */
222 #define DEVI_BRANCH_ROOT 0x40 /* Node is the root of a branch */
224 typedef struct devi_branch
{
226 void (*devi_branch_callback
)(dev_info_t
*, void *, uint_t
);
229 int (*prom_branch_select
)(pnode_t
, void *, uint_t
);
230 int (*sid_branch_create
)(dev_info_t
*, void *, uint_t
);
234 extern int e_ddi_branch_create(dev_info_t
*pdip
, devi_branch_t
*bp
,
235 dev_info_t
**dipp
, uint_t flags
);
236 extern int e_ddi_branch_configure(dev_info_t
*rdip
, dev_info_t
**dipp
,
238 extern int e_ddi_branch_unconfigure(dev_info_t
*rdip
, dev_info_t
**dipp
,
240 extern int e_ddi_branch_destroy(dev_info_t
*rdip
, dev_info_t
**dipp
,
242 extern void e_ddi_branch_hold(dev_info_t
*rdip
);
243 extern void e_ddi_branch_rele(dev_info_t
*rdip
);
244 extern int e_ddi_branch_held(dev_info_t
*rdip
);
245 extern int e_ddi_branch_referenced(dev_info_t
*rdip
,
246 int (*cb
)(dev_info_t
*dip
, void *, uint_t
), void *arg
);
249 * Obsolete interfaces, no longer used, to be removed.
250 * Retained only for driver compatibility.
253 e_ddi_enter_driver_list(struct devnames
*, int *); /* obsolete */
256 e_ddi_tryenter_driver_list(struct devnames
*, int *); /* obsolete */
259 e_ddi_exit_driver_list(struct devnames
*, int); /* obsolete */
268 #endif /* _SYS_ESUNDDI_H */